bool cdAudio_PlayTrack(SONG_CONTEXT context) { debug(LOG_SOUND, "called(%d)", (int)context); switch (context) { case SONG_FRONTEND: return cdAudio_OpenTrack("music/menu.ogg"); case SONG_INGAME: { const char *filename = PlayList_CurrentSong(); if (filename == nullptr) { return false; } return cdAudio_OpenTrack(filename); } } ASSERT(!"Invalid songcontext", "Invalid song context specified for playing: %u", (unsigned int)context); return false; }
void playListTest() { int i; for (i = 0; i < 10; i++) { const char *cur, *next; PlayList_Quit(); PlayList_Init(); PlayList_Read("music"); if (numSongs != 2) { debug(LOG_ERROR, "Use the default playlist for selftest!"); } cur = PlayList_CurrentSong(); next = PlayList_NextSong(); assert(cur != NULL && next != NULL && cur != next); next = PlayList_NextSong(); assert(cur == next); // loop around assert(songList); assert(numSongs == 2); } fprintf(stdout, "\tPlaylist self-test: PASSED\n"); }
const char *PlayList_NextSong() { // If there's a next song in the playlist select it if (currentSong && currentSong->next) { currentSong = currentSong->next; } // Otherwise jump to the start of the playlist else { currentSong = songList; } return PlayList_CurrentSong(); }