mixer_control: don't lock the mutex twice in mixer_failed()

The function mixer_failed() expects the mixer mutex to be already
locked, yet it calls mixer_close(), which attempts to lock the mutex
again, deadlocking itself.
This commit is contained in:
Max Kellermann 2009-03-27 16:44:31 +01:00
parent e7519829ac
commit 1a411b1ced

View File

@ -89,6 +89,17 @@ mixer_open(struct mixer *mixer)
return success;
}
static void
mixer_close_internal(struct mixer *mixer)
{
assert(mixer != NULL);
assert(mixer->plugin != NULL);
assert(mixer->open);
mixer->plugin->close(mixer);
mixer->open = false;
}
void
mixer_close(struct mixer *mixer)
{
@ -97,10 +108,8 @@ mixer_close(struct mixer *mixer)
g_mutex_lock(mixer->mutex);
if (mixer->open) {
mixer->plugin->close(mixer);
mixer->open = false;
}
if (mixer->open)
mixer_close_internal(mixer);
g_mutex_unlock(mixer->mutex);
}
@ -121,7 +130,7 @@ mixer_failed(struct mixer *mixer)
{
assert(mixer->open);
mixer_close(mixer);
mixer_close_internal(mixer);
mixer->failed = true;
}