Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2002:
[Freeciv-Dev] Re: [Patch] Sound8
Home

[Freeciv-Dev] Re: [Patch] Sound8

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Freeciv-Dev <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: [Patch] Sound8
From: "Per I. Mathisen" <Per.Inge.Mathisen@xxxxxxxxxxx>
Date: Fri, 15 Feb 2002 23:32:34 +0100 (MET)

On Fri, 15 Feb 2002, Jason Short wrote:
> Ahh, this makes things clearer.  esd_sample_free destroys the cached
> data - so it is safe to call esd_sample_free on a sample, even after it
> has stopped playing.
>
> What happens if we call esd_sample_free on a sample that is still
> playing?  Will it continue to run?  Such a thing is unlikely but
> possible, in the event that all of our "sound channels" get used up
> before a sample finishes.

Yes, it is possible. No, I don't know exactly what will happen. I have
supposed that it will be killed instantly and replaced. If that doesn't
happen the new sound won't play. In any case, either way is an acceptable
outcome given the situation.

> Eventually, some comments explaining this process would be good.

I'll look into it when I get around to looking at Raimar's patch, but for
me improving the esound code is much lower priority than eg adding support
for other sound systems, since esound is a piece of dying, broken legacy
software that just happens to be on a lot of people's boxes because gnome
hasn't managed to replace it yet (they will replace it with gstreamer
eventually).

> The music channel is tracked separately.  But, it's also held somewhere
> within the audio_sdl_wave[] array.  So it is conceivable that a regular
> sample, when Mix_PlayChannel is called, could overwrite it.  Hopefully
> this is not possible (?), but if we're not sure it might be a good idea
> to add an assertion to verify it.

Ah, now I get what you are getting at. Note however, that we don't cycle
through the wave array mindlessly like we do in the case of esd. SDL finds
the first available channel and uses it. Much less danger of overwriting
something useful. If you _are_ playing MAX_CHANNELS number of sounds at
the same time, well, you are out of luck, and, I think, the sound won't be
played.

SDL has a separate music channel, though, but I think that is only for
special soundtrack formats like MOD, MIDI, etc.. I'll check that to be
absolutely sure.

> Also, we don't know what happens if we play more than MIX_CHANNELS
> sounds at the same time.  If this were to happen then most likely either
> (1) we'll get -1 or something from Mix_PlayChannel or (2)
> Mix_PlayChannel will replace a previously-used channel with the new
> sample.  Either way, we should check for it - although it's probably not
> a problem since MIX_CHANNELS is probably really big (?).

MIX_CHANNELS is usually 14, I believe. Big enough. I'll have to check the
return value and result when there is no available channel, since there
will be a bug if it is negative.

> I recommend applying the patch.  These are small problems that will not
> come up during normal play (if at all), and can easily be fixed later.

Thanks for the comments. Since I've now returned from Brazil, please give
me a chance to read & comment on Raimar's changes before committing.

Yours,
Per

"What we anticipate seldom occurs: but what we least expect generally
happens." -- Benjamin Disraeli



[Prev in Thread] Current Thread [Next in Thread]