void testStopLoopedSong() { TEST_SETUP(); SIMSG_SEND(it, SIMSG_SET_LOOPS(3)); message = songit_next(&it, &cmds, &result, IT_READER_MASK_ALL); TESTEQUAL(0xAA, message); SIMSG_SEND(it, SIMSG_STOP); message = songit_next(&it, &cmds, &result, IT_READER_MASK_ALL); TESTEQUAL(SI_FINISHED, message); TEST_TEARDOWN(); }
int songit_next(SongIterator **it, byte *buf, int *result, int mask) { int retval; if (!*it) return SI_FINISHED; do { retval = (*it)->nextCommand(buf, result); if (retval == SI_MORPH) { debugC(2, kDebugLevelSound, " Morphing %p (stored at %p)\n", (void *)*it, (void *)it); if (!SIMSG_SEND((*it), SIMSG_ACK_MORPH)) { error("SI_MORPH failed. Breakpoint in %s, line %d", __FILE__, __LINE__); } else debugC(2, kDebugLevelSound, "SI_MORPH successful\n"); } if (retval == SI_FINISHED) debugC(2, kDebugLevelSound, "[song-iterator] Song finished. mask = %04x, cm=%04x\n", mask, (*it)->channel_mask); if (retval == SI_FINISHED && (mask & IT_READER_MAY_CLEAN) && (*it)->channel_mask) { /* This last test will fail ** with a terminated ** cleanup iterator */ int channel_mask = (*it)->channel_mask; SongIterator *old_it = *it; *it = new CleanupSongIterator(channel_mask); song_iterator_transfer_death_listeners(*it, old_it); if (mask & IT_READER_MAY_FREE) delete old_it; retval = -9999; /* Continue */ } } while (!( /* Until one of the following holds */ (retval > 0 && (mask & IT_READER_MASK_DELAY)) || (retval == 0 && (mask & IT_READER_MASK_MIDI)) || (retval == SI_LOOP && (mask & IT_READER_MASK_LOOP)) || (retval == SI_ABSOLUTE_CUE && (mask & IT_READER_MASK_CUE)) || (retval == SI_RELATIVE_CUE && (mask & IT_READER_MASK_CUE)) || (retval == SI_PCM && (mask & IT_READER_MASK_PCM)) || (retval == SI_FINISHED) )); if (retval == SI_FINISHED && (mask & IT_READER_MAY_FREE)) { delete *it; *it = NULL; } return retval; }
void testChangeSongMask() { TEST_SETUP(); message = songit_next(&it, &cmds, &result, IT_READER_MASK_ALL); TESTEQUAL(0xAA, message); SIMSG_SEND(it, SIMSG_SET_PLAYMASK(0x40)); message = songit_next(&it, &cmds, &result, IT_READER_MASK_ALL); TESTEQUAL(0, message); TESTEQUAL(0, result); TEST_TEARDOWN(); }