void audio_StreamSource_free(audio_StreamSource *source) { // Stop without rewind audio_StreamSource_stop1(source); free(source->filename); alDeleteBuffers(preloadBufferCount, source->buffers); audio_SourceCommon_free(&source->common); source->decoder->closeFile(source->decoderData); }
static int l_audio_SourceCommon_free(lua_State* state){ if (moduleData.audio_type == audio_type_stream){ audio_StreamSource* source = (audio_StreamSource *)lua_touserdata(state, 1); audio_StreamSource_free(source, lua_toboolean(state, 2)); } else { audio_SourceCommon* source = (audio_SourceCommon*)lua_touserdata(state, 1); audio_SourceCommon_free(source); } return 1; }
Obj* c_audio_gc(void* root, Obj** env, Obj** list) { Obj* arg = eval(root, env, &(*list)->car); if (moduleData.audio_type == audio_type_static) { audio_SourceCommon* source = (audio_SourceCommon*)arg->custom; audio_SourceCommon_free(source); return True; } audio_StreamSource* source = (audio_StreamSource*)arg->custom; audio_StreamSource_free(source); return True; }
bool audio_loadStatic(audio_StaticSource *source, char const * filename) { while(filename[0] == '/') { ++filename; } char const* infile = filesystem_locateReadableFile(filename); audio_SourceCommon_init(&source->common); source->buffer = audio_StaticBuffer_new(); // decoder shall close the file bool loaded = staticDecoders[0]->loadFile(source->buffer->buffer, infile); if(!loaded) { audio_StaticBuffer_free(source->buffer); audio_SourceCommon_free(&source->common); return false; } alSourcei(source->common.source, AL_BUFFER, source->buffer->buffer); return true; }
void audio_StaticSource_free(audio_StaticSource *source) { audio_SourceCommon_stop(&source->common); alSourcei(source->common.source, AL_BUFFER, AL_NONE); audio_StaticBuffer_unref(source->buffer); audio_SourceCommon_free(&source->common); }