Re: [AD] make al_create_voice not fail? |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
On 2009-08-10, Elias Pschernig <elias.pschernig@xxxxxxxxxx> wrote:
> 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
It sounds like documentation for implementors extracted out to the
user's manual ;) And it makes no sense.
> 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 it's expecting al_create_voice to make a best effort to create
a voice with the suggested parameters, as you say:
> 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.
I agree. Not sure what purpose the al_create_voice parameters serve
though, but maybe it gives the sound driver a starting point?
Peter