Re: [AD] A5 Audio API issues

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


On 2010-01-10, Paul Suntsov <siegelords_abode@xxxxxxxxxx> wrote:
> > > 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...

al_play_sample generates a unique id every time it is called, which is stored
in the ALLEGRO_SAMPLE_ID that the user passes in.  al_stop_sample only stops
the reserved sample instance if the id hasn't changed.

> 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).

Right.

> 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.

The event would need to contain something equivalent to the 'id'.  The address
of the sample instance is no good, as obviously the sample instance might be
reused by the time the user notices the event.

> 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?

I don't think so.  The sample instance returned by
al_get_sample_instance_from_id could still be reused while the user is
accessing it.

I'm back to thinking that we should leave ALLEGRO_SAMPLE_ID as it is :)

Peter




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