static int l_audio_SourceCommon_stop(lua_State* state) { if (moduleData.audio_type == audio_type_stream){ audio_StreamSource* source = (audio_StreamSource *)lua_touserdata(state, 1); audio_StreamSource_stop(source); } else { audio_StaticSource* source = (audio_StaticSource *)lua_touserdata(state, 1); audio_StaticSource_stop(source); } return 0; }
void audio_StreamSource_rewind(audio_StreamSource *source) { // TODO Skip to end of current buffers if playing or paused audio_SourceState state = source->common.state; audio_StreamSource_stop(source); if(state == audio_SourceState_playing) { audio_StreamSource_play(source); } else { prepareToPlay(source); source->common.state = audio_SourceState_paused; } }
Obj* c_audio_stop(void* root, Obj** env, Obj** list) { if (length(*list) != 1) error("Expected <custom> to stop in audio-stop."); Obj* arg = eval(root, env, &(*list)->car); if (moduleData.audio_type == audio_type_static) { audio_StaticSource* source = (audio_StaticSource*)arg->custom; audio_StaticSource_stop(source); return True; } audio_StreamSource* source = (audio_StreamSource*)arg->custom; audio_StreamSource_stop(source); return True; }