コード例 #1
0
ファイル: kcm_voice.c プロジェクト: sesc4mt/mvcdecoder
/* Function: al_create_voice
 */
ALLEGRO_VOICE *al_create_voice(unsigned int freq,
   ALLEGRO_AUDIO_DEPTH depth, ALLEGRO_CHANNEL_CONF chan_conf)
{
   ALLEGRO_VOICE *voice = NULL;

   if (!freq) {
      _al_set_error(ALLEGRO_INVALID_PARAM, "Invalid Voice Frequency");
      return NULL;
   }

   voice = calloc(1, sizeof(*voice));
   if (!voice) {
      return NULL;
   }

   voice->depth     = depth;
   voice->chan_conf = chan_conf;
   voice->frequency = freq;

   voice->mutex = al_create_mutex();
   /* XXX why is this needed? there should only be one active driver */
   voice->driver = _al_kcm_driver;

   ASSERT(_al_kcm_driver);
   if (_al_kcm_driver->allocate_voice(voice) != 0) {
      al_destroy_mutex(voice->mutex);
      free(voice);
      return NULL;
   }

   _al_kcm_register_destructor(voice, (void (*)(void *)) al_destroy_voice);

   return voice;
}
コード例 #2
0
ファイル: kcm_sample.c プロジェクト: tsteinholz/SR-Gaming
/* Function: al_create_sample
 */
ALLEGRO_SAMPLE *al_create_sample(void *buf, unsigned int samples,
   unsigned int freq, ALLEGRO_AUDIO_DEPTH depth,
   ALLEGRO_CHANNEL_CONF chan_conf, bool free_buf)
{
   ALLEGRO_SAMPLE *spl;

   ASSERT(buf);

   if (!freq) {
      _al_set_error(ALLEGRO_INVALID_PARAM, "Invalid sample frequency");
      return NULL;
   }

   spl = al_calloc(1, sizeof(*spl));
   if (!spl) {
      _al_set_error(ALLEGRO_GENERIC_ERROR,
         "Out of memory allocating sample data object");
      return NULL;
   }

   spl->depth = depth;
   spl->chan_conf = chan_conf;
   spl->frequency = freq;
   spl->len = samples;
   spl->buffer.ptr = buf;
   spl->free_buf = free_buf;

   _al_kcm_register_destructor(spl, (void (*)(void *)) al_destroy_sample);

   return spl;
}
コード例 #3
0
ファイル: kcm_instance.c プロジェクト: BorisCarvajal/allegro5
/* Function: al_create_sample_instance
 */
ALLEGRO_SAMPLE_INSTANCE *al_create_sample_instance(ALLEGRO_SAMPLE *sample_data)
{
    ALLEGRO_SAMPLE_INSTANCE *spl;

    spl = al_calloc(1, sizeof(*spl));
    if (!spl) {
        _al_set_error(ALLEGRO_GENERIC_ERROR,
                      "Out of memory allocating sample object");
        return NULL;
    }

    if (sample_data) {
        spl->spl_data = *sample_data;
    }
    spl->spl_data.free_buf = false;

    spl->loop = ALLEGRO_PLAYMODE_ONCE;
    spl->speed = 1.0f;
    spl->gain = 1.0f;
    spl->pan = 0.0f;
    spl->pos = 0;
    spl->loop_start = 0;
    spl->loop_end = sample_data ? sample_data->len : 0;
    spl->step = 0;

    spl->matrix = NULL;

    spl->is_mixer = false;
    spl->spl_read = NULL;

    spl->mutex = NULL;
    spl->parent.u.ptr = NULL;

    _al_kcm_register_destructor("sample_instance", spl,
                                (void (*)(void *))al_destroy_sample_instance);

    return spl;
}