ga_Handle* gau_create_handle_memory(ga_Mixer* in_mixer, ga_Memory* in_memory, const char* in_format, ga_FinishCallback in_callback, void* in_context, gau_SampleSourceLoop** out_loopSrc) { ga_Handle* ret = 0; ga_DataSource* dataSrc = gau_data_source_create_memory(in_memory); if(dataSrc) { ga_SampleSource* sampleSrc = 0; if(strcmp(in_format, "ogg") == 0) sampleSrc = gau_sample_source_create_ogg(dataSrc); else if(strcmp(in_format, "wav") == 0) sampleSrc = gau_sample_source_create_wav(dataSrc); if(sampleSrc) { ga_SampleSource* sampleSrc2 = sampleSrc; if(out_loopSrc) { gau_SampleSourceLoop* loopSampleSrc = gau_sample_source_create_loop(sampleSrc); gau_sample_source_loop_set(loopSampleSrc, -1, 0); ga_sample_source_release(sampleSrc); *out_loopSrc = loopSampleSrc; sampleSrc2 = (ga_SampleSource*)loopSampleSrc; } if(sampleSrc2) { ret = ga_handle_create(in_mixer, sampleSrc2); if(sampleSrc == sampleSrc2) ga_sample_source_release(sampleSrc2); ga_handle_setCallback(ret, in_callback, in_context); } } } return ret; }
ga_Handle* gau_create_handle_buffered_file(ga_Mixer* in_mixer, ga_StreamManager* in_streamMgr, const char* in_filename, const char* in_format, ga_FinishCallback in_callback, void* in_context, gau_SampleSourceLoop** out_loopSrc) { ga_Handle* ret = 0; ga_DataSource* dataSrc = gau_data_source_create_file(in_filename); if(dataSrc) { ga_SampleSource* sampleSrc = 0; if(stricmp(in_format, "ogg") == 0) sampleSrc = gau_sample_source_create_ogg(dataSrc); else if(stricmp(in_format, "wav") == 0) sampleSrc = gau_sample_source_create_wav(dataSrc); ga_data_source_release(dataSrc); if(sampleSrc) { ga_SampleSource* sampleSrc2 = sampleSrc; if(out_loopSrc) { gau_SampleSourceLoop* loopSampleSrc = gau_sample_source_create_loop(sampleSrc); gau_sample_source_loop_set(loopSampleSrc, -1, 0); ga_sample_source_release(sampleSrc); *out_loopSrc = loopSampleSrc; sampleSrc2 = (ga_SampleSource*)loopSampleSrc; } if(sampleSrc2) { ga_SampleSource* streamSampleSrc = gau_sample_source_create_stream(in_streamMgr, sampleSrc2, 131072); if(sampleSrc == sampleSrc2) ga_sample_source_release(sampleSrc2); if(streamSampleSrc) { ret = ga_handle_create(in_mixer, streamSampleSrc); ga_sample_source_release(streamSampleSrc); ga_handle_setCallback(ret, in_callback, in_context); } } } } return ret; }
ga_Sound* gau_load_sound_file(const char* in_filename, const char* in_format) { ga_Sound* ret = 0; ga_DataSource* dataSrc = gau_data_source_create_file(in_filename); if(dataSrc) { ga_SampleSource* sampleSrc = 0; if(strcmp(in_format, "ogg") == 0) sampleSrc = gau_sample_source_create_ogg(dataSrc); else if(strcmp(in_format, "wav") == 0) sampleSrc = gau_sample_source_create_wav(dataSrc); ga_data_source_release(dataSrc); if(sampleSrc) { ret = ga_sound_create_sample_source(sampleSrc); ga_sample_source_release(sampleSrc); } } return ret; }