From 2ee047a1ddf2bb4d7e25a259492952c6128a749d Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 4 Nov 2010 23:40:43 +0100 Subject: output_internal: protect attribute "fail_timer" with mutex --- src/output_thread.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/output_thread.c') diff --git a/src/output_thread.c b/src/output_thread.c index e652eae57..b97694169 100644 --- a/src/output_thread.c +++ b/src/output_thread.c @@ -105,7 +105,12 @@ ao_play_chunk(struct audio_output *ao, const struct music_chunk *chunk) /* don't automatically reopen this device for 10 seconds */ + g_mutex_lock(ao->mutex); + + assert(ao->fail_timer == NULL); ao->fail_timer = g_timer_new(); + + g_mutex_unlock(ao->mutex); return false; } -- cgit v1.2.3 From 8d5fa754e8e9a0de7b03413bb5433e1626368927 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 4 Nov 2010 21:30:16 +0100 Subject: output_thread: fix assertion failure due to race condition in OPEN Change the assertion on "fail_timer==NULL" in OPEN to a runtime check. This assertion crashed when the output thread failed while the player thread was calling audio_output_open(). --- src/output_thread.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/output_thread.c') diff --git a/src/output_thread.c b/src/output_thread.c index b97694169..035cf99c1 100644 --- a/src/output_thread.c +++ b/src/output_thread.c @@ -197,10 +197,18 @@ static gpointer audio_output_task(gpointer arg) case AO_COMMAND_OPEN: assert(!ao->open); - assert(ao->fail_timer == NULL); assert(ao->pipe != NULL); assert(ao->chunk == NULL); + if (ao->fail_timer != NULL) { + /* this can only happen when this + output thread fails while + audio_output_open() is run in the + player thread */ + g_timer_destroy(ao->fail_timer); + ao->fail_timer = NULL; + } + error = NULL; ret = ao_plugin_open(ao->plugin, ao->data, &ao->out_audio_format, -- cgit v1.2.3