[sound] Add a threaded field to snd_t

Care needs to be taken when freeing channels as doing so while an
asynchronous mixer is using them is unlikely to end well. However,
whether the mixer is asynchronous depends on the output driver. This
lets the driver inform the rest of the system that the output and mixer
are running asynchronously.
This commit is contained in:
Bill Currie 2022-06-05 18:08:49 +09:00
parent 48f704c84e
commit fdd070f6dc
4 changed files with 5 additions and 1 deletions

View file

@ -106,6 +106,7 @@ struct snd_s {
int submission_chunk; //!< don't mix less than this #
unsigned paintedtime; //!< sound clock in samples
int framepos; //!< position of dma cursor
int threaded; //!< output runs in a thread
unsigned char *buffer; //!< destination for mixed sound
/** Transfer mixed samples to the output.
\param paintbuffer The buffer of mixed samples to be transferred.

View file

@ -186,7 +186,7 @@ static void
s_stop_all_sounds (void)
{
SND_StopAllSounds (&snd);
SND_ScanChannels (&snd, 0);
SND_ScanChannels (&snd, snd.threaded);
s_clear_buffer (&snd);
}

View file

@ -655,6 +655,8 @@ SNDDMA_Init (snd_t *snd)
snd->frames = buffer_size;
snd->threaded = 1;//XXX FIXME double check whether it's always true
// send the first period to fill the buffer
// also sets snd->buffer
if (alsa_process (pcm, snd) < 0) {

View file

@ -278,6 +278,7 @@ static int
s_init (snd_t *snd)
{
snd->xfer = snd_jack_xfer;
snd->threaded = 1;
return s_jack_connect (snd);
}