/** * @brief Updates the music. */ void music_update( double dt ) { char buf[PATH_MAX]; if (music_disabled) return; /* Timer stuff. */ if (music_timer > 0.) { music_timer -= dt; if (music_timer <= 0.) music_runchoose = 1; } /* Lock music and see if needs to update. */ SDL_mutexP(music_lock); if (music_runchoose == 0) { SDL_mutexV(music_lock); return; } music_runchoose = 0; strncpy(buf, music_situation, PATH_MAX); SDL_mutexV(music_lock); music_runLua( buf ); /* Make sure music is playing. */ if (!music_isPlaying()) music_choose("idle"); }
/** * @brief Tells the music thread to resume. */ void music_al_resume (void) { musicLock(); music_command = MUSIC_CMD_PLAY; while (1) { SDL_CondWait( music_state_cond, music_state_lock ); if (music_isPlaying()) break; } musicUnlock(); }
/** * @brief Checks to see if something is playing. * * @luareturn true if something is playing. * @luafunc isPlaying() */ static int musicL_isPlaying( lua_State* L ) { lua_pushboolean(L, music_isPlaying()); return 1; }