Re: [AD] A5 Audio API issues |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
> > 2. Provide file stream loading/saving functions
> >
> > Right now all we have al_save_sample_wav_pf. We should
> have all the
> > other ones though, again to mimic the image addon.
> >
> > So, we'll have to add:
> > al_load_{formats}_stream
> > al_load_{formats}_audio_stream_stream <-- awkward,
> but that's how it is
> > al_save_wav_stream
>
> Ugh. _pf would at least have been unambiguous.
Yeah, I'd prefer something other that _stream, but that's what 99% of the other functions use....
> > 3. Remove ALLEGRO_SAMPLE_ID, it's useless as is. Make
> al_play_sample
> > return ALLEGRO_SAMPLE_INSTANCE* which
> ALLEGRO_SAMPLE_ID is a wrapper
> > around anyway.
>
> SAMPLE_ID basically solves a single problem, that the
> underlying
> reserved SAMPLE_INSTANCE may be reused after the current
> sample is
> finished. The user should be able to reliably stop a
> sample he started,
> even if the sample instance is reused for something else.
>
> I agree with the intention to remove SAMPLE_ID
> though. It seems
> feasible.
Hmm, yes that is a problem. I'm not entirely sure how this is handled in the addon right now though...
Here are some possible solutions to this:
1. Provide an al_get_sample_instance_source (or _sample) which would return the source of that sample instance. The user would then check that this matches the sample he originally played before stopping it (or doing anything to it, for that matter). Won't work that well if you play the same sample multiple times though (and the sample instance gets recycled to the same sample).
2.. Make the sample instance an event source, which sends out an ALLEGRO_EVENT_SAMPLE_INSTANCE_STOPPED or something when the sample is stopped. Pretty much foolproof, but may or may not be clunky to use.
3. Abandon the idea, and provide an al_get_sample_instance_from_id which would return the sample instance from the sample id, if it's valid (i.e. represents the original played sample). Although it won't require any changes in the API it seems like a hack. Perhaps provides a workable compromise though?
-SiegeLord