From 9cd6394d8c1b1cfc74540f1ed43171a9893e1e4d Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Thu, 12 Apr 2007 05:58:09 +0000 Subject: SWCODEC: Fix a race condition caused by yielding in pcm_mute that could have playback messing around with pcm after supposedly being fully stopped. The pcm buffer mutes consistently on some players (the PP ones) which made audio_stop return too soon. Won't matter if it yields or not now and this should take care of the mpegplayer 'next video' issue. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13117 a1c6a512-1295-4272-9138-f99709370657 --- apps/playback.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'apps/playback.c') diff --git a/apps/playback.c b/apps/playback.c index a4f5bee9fc..545076954f 100644 --- a/apps/playback.c +++ b/apps/playback.c @@ -425,13 +425,22 @@ static void wait_for_voice_swap_in(void) #endif /* PLAYBACK_VOICE */ } +/* This sends a stop message and the audio thread will dump all it's + subsequenct messages */ +static void audio_hard_stop(void) +{ + /* Stop playback */ + LOGFQUEUE("audio >| audio Q_AUDIO_STOP: 1"); + queue_send(&audio_queue, Q_AUDIO_STOP, 1); +} + unsigned char *audio_get_buffer(bool talk_buf, size_t *buffer_size) { unsigned char *buf, *end; if (audio_is_initialized) { - audio_stop(); + audio_hard_stop(); wait_for_voice_swap_in(); voice_stop(); } @@ -488,7 +497,7 @@ unsigned char *audio_get_buffer(bool talk_buf, size_t *buffer_size) void audio_iram_steal(void) { /* We need to stop audio playback in order to use codec IRAM */ - audio_stop(); + audio_hard_stop(); #ifdef PLAYBACK_VOICE if (NULL != iram_buf) @@ -527,7 +536,7 @@ unsigned char *audio_get_recording_buffer(size_t *buffer_size) /* Stop audio and voice. Wait for voice to swap in and be clear of pending events to ensure trouble-free operation of encoders */ - audio_stop(); + audio_hard_stop(); wait_for_voice_swap_in(); voice_stop(); talk_buffer_steal(); @@ -3636,6 +3645,8 @@ static void audio_thread(void) case Q_AUDIO_STOP: LOGFQUEUE("audio < Q_AUDIO_STOP"); audio_stop_playback(); + if (ev.data != 0) + queue_clear(&audio_queue); break ; case Q_AUDIO_PAUSE: -- cgit v1.2.3