Example #1
0
ga_Handle* gau_create_handle_sound(ga_Mixer* in_mixer, ga_Sound* in_sound,
                                   ga_FinishCallback in_callback, void* in_context,
                                   gau_SampleSourceLoop** out_loopSrc)
{
  ga_Handle* ret = 0;
  ga_SampleSource* sampleSrc = sampleSrc = gau_sample_source_create_sound(in_sound);
  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;
}
Example #2
0
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;
}
Example #3
0
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;
}