[AD] make al_create_voice not fail?

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


The docs for "al_create_voice" say:

"The sound driver's allocate_voice function should change the voice's
frequency, depth, chan_conf, and settings fields to match what is
actually allocated. If it cannot create a voice with exact settings it
will fail."

This sounds a bit like a contradiction - where exactly are those
actually allocated settings written to? The source code of
al_create_default_mixer has this:

   if (!allegro_voice) {
      allegro_voice = al_create_voice(44100, ALLEGRO_AUDIO_DEPTH_INT16,
         ALLEGRO_CHANNEL_CONF_2);
      if (!allegro_voice) {
         TRACE("al_create_voice failed\n");
         goto Error;
      }
   }

So basically, if only a 24bit voice with 48000 Hz is avalable, it fails.
I think better semantics would be for the function to never fail because
of a wrong format and instead simply return a voice with supported
parameters. (It would still fail if no more voices are available of
course.) The user can then always check the values for the actual
values, as the documentation already suggests.

-- 
Elias Pschernig <elias@xxxxxxxxxx>





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/