Exemple #1
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;
}
Exemple #2
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;
}
Exemple #3
0
Fichier : ga.c Projet : Botyto/Core
gc_result gaX_handle_cleanup(ga_Handle* in_handle)
{
  /* May only be called from the dispatch thread */
  ga_Mixer* m = in_handle->mixer;
  ga_sample_source_release(in_handle->sampleSrc);
  gc_mutex_destroy(in_handle->handleMutex);
  gcX_ops->freeFunc(in_handle);
  return GC_SUCCESS;
}
Exemple #4
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;
}
Exemple #5
0
void gaX_stream_destroy(ga_BufferedStream* in_stream)
{
  ga_BufferedStream* s = in_stream;
  gaX_stream_link_kill((gaX_StreamLink*)s->streamLink); /* This must be done first, so that the stream remains valid until it killed */
  gaX_stream_link_release((gaX_StreamLink*)s->streamLink);
  gc_mutex_destroy(s->produceMutex);
  gc_mutex_destroy(s->seekMutex);
  gc_mutex_destroy(s->readMutex);
  gc_mutex_destroy(s->refMutex);
  gc_buffer_destroy(s->buffer);
  gauX_tell_jump_clear(&s->tellJumps);
  ga_sample_source_release(s->innerSrc);
  gcX_ops->freeFunc(s);
}
Exemple #6
0
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;
}
Exemple #7
0
void gauX_sample_source_loop_close(void* in_context)
{
  gau_SampleSourceLoopContext* ctx = &((gau_SampleSourceLoop*)in_context)->context;
  ga_sample_source_release(ctx->innerSrc);
  gc_mutex_destroy(ctx->loopMutex);
}