Commit 3eb5b1d0 authored by Oswald Buddenhagen's avatar Oswald Buddenhagen Committed by Takashi Iwai

ALSA: emu10k1: don't forget to reset reclaimed synth voices

The subsequent allocation may still fail after freeing some voices, so
we shouldn't leave them in their programmed state.
Signed-off-by: default avatarOswald Buddenhagen <oswald.buddenhagen@gmx.de>
Link: https://lore.kernel.org/r/20230518140947.3725394-3-oswald.buddenhagen@gmx.deSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent f26a4cf0
...@@ -98,6 +98,15 @@ static int voice_alloc(struct snd_emu10k1 *emu, int type, int number, ...@@ -98,6 +98,15 @@ static int voice_alloc(struct snd_emu10k1 *emu, int type, int number,
return 0; return 0;
} }
static void voice_free(struct snd_emu10k1 *emu,
struct snd_emu10k1_voice *pvoice)
{
snd_emu10k1_voice_init(emu, pvoice->number);
pvoice->interrupt = NULL;
pvoice->use = pvoice->pcm = pvoice->synth = pvoice->midi = pvoice->efx = 0;
pvoice->epcm = NULL;
}
int snd_emu10k1_voice_alloc(struct snd_emu10k1 *emu, int type, int number, int snd_emu10k1_voice_alloc(struct snd_emu10k1 *emu, int type, int number,
struct snd_emu10k1_voice **rvoice) struct snd_emu10k1_voice **rvoice)
{ {
...@@ -118,12 +127,8 @@ int snd_emu10k1_voice_alloc(struct snd_emu10k1 *emu, int type, int number, ...@@ -118,12 +127,8 @@ int snd_emu10k1_voice_alloc(struct snd_emu10k1 *emu, int type, int number,
/* free a voice from synth */ /* free a voice from synth */
if (emu->get_synth_voice) { if (emu->get_synth_voice) {
result = emu->get_synth_voice(emu); result = emu->get_synth_voice(emu);
if (result >= 0) { if (result >= 0)
struct snd_emu10k1_voice *pvoice = &emu->voices[result]; voice_free(emu, &emu->voices[result]);
pvoice->interrupt = NULL;
pvoice->use = pvoice->pcm = pvoice->synth = pvoice->midi = pvoice->efx = 0;
pvoice->epcm = NULL;
}
} }
if (result < 0) if (result < 0)
break; break;
...@@ -143,10 +148,7 @@ int snd_emu10k1_voice_free(struct snd_emu10k1 *emu, ...@@ -143,10 +148,7 @@ int snd_emu10k1_voice_free(struct snd_emu10k1 *emu,
if (snd_BUG_ON(!pvoice)) if (snd_BUG_ON(!pvoice))
return -EINVAL; return -EINVAL;
spin_lock_irqsave(&emu->voice_lock, flags); spin_lock_irqsave(&emu->voice_lock, flags);
pvoice->interrupt = NULL; voice_free(emu, pvoice);
pvoice->use = pvoice->pcm = pvoice->synth = pvoice->midi = pvoice->efx = 0;
pvoice->epcm = NULL;
snd_emu10k1_voice_init(emu, pvoice->number);
spin_unlock_irqrestore(&emu->voice_lock, flags); spin_unlock_irqrestore(&emu->voice_lock, flags);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment