summaryrefslogtreecommitdiff
path: root/apps/playback.c
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2007-04-12 05:58:09 +0000
committerMichael Sevakis <jethead71@rockbox.org>2007-04-12 05:58:09 +0000
commit9cd6394d8c1b1cfc74540f1ed43171a9893e1e4d (patch)
tree72e45659d940b011f375fd46ae4b6e6a56691a93 /apps/playback.c
parent6c9a433ca15f40f268fe26515c9ba1629dc00c3d (diff)
downloadrockbox-9cd6394d8c1b1cfc74540f1ed43171a9893e1e4d.tar.gz
rockbox-9cd6394d8c1b1cfc74540f1ed43171a9893e1e4d.zip
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
Diffstat (limited to 'apps/playback.c')
-rw-r--r--apps/playback.c17
1 files changed, 14 insertions, 3 deletions
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)
425#endif /* PLAYBACK_VOICE */ 425#endif /* PLAYBACK_VOICE */
426} 426}
427 427
428/* This sends a stop message and the audio thread will dump all it's
429 subsequenct messages */
430static void audio_hard_stop(void)
431{
432 /* Stop playback */
433 LOGFQUEUE("audio >| audio Q_AUDIO_STOP: 1");
434 queue_send(&audio_queue, Q_AUDIO_STOP, 1);
435}
436
428unsigned char *audio_get_buffer(bool talk_buf, size_t *buffer_size) 437unsigned char *audio_get_buffer(bool talk_buf, size_t *buffer_size)
429{ 438{
430 unsigned char *buf, *end; 439 unsigned char *buf, *end;
431 440
432 if (audio_is_initialized) 441 if (audio_is_initialized)
433 { 442 {
434 audio_stop(); 443 audio_hard_stop();
435 wait_for_voice_swap_in(); 444 wait_for_voice_swap_in();
436 voice_stop(); 445 voice_stop();
437 } 446 }
@@ -488,7 +497,7 @@ unsigned char *audio_get_buffer(bool talk_buf, size_t *buffer_size)
488void audio_iram_steal(void) 497void audio_iram_steal(void)
489{ 498{
490 /* We need to stop audio playback in order to use codec IRAM */ 499 /* We need to stop audio playback in order to use codec IRAM */
491 audio_stop(); 500 audio_hard_stop();
492 501
493#ifdef PLAYBACK_VOICE 502#ifdef PLAYBACK_VOICE
494 if (NULL != iram_buf) 503 if (NULL != iram_buf)
@@ -527,7 +536,7 @@ unsigned char *audio_get_recording_buffer(size_t *buffer_size)
527 536
528 /* Stop audio and voice. Wait for voice to swap in and be clear 537 /* Stop audio and voice. Wait for voice to swap in and be clear
529 of pending events to ensure trouble-free operation of encoders */ 538 of pending events to ensure trouble-free operation of encoders */
530 audio_stop(); 539 audio_hard_stop();
531 wait_for_voice_swap_in(); 540 wait_for_voice_swap_in();
532 voice_stop(); 541 voice_stop();
533 talk_buffer_steal(); 542 talk_buffer_steal();
@@ -3636,6 +3645,8 @@ static void audio_thread(void)
3636 case Q_AUDIO_STOP: 3645 case Q_AUDIO_STOP:
3637 LOGFQUEUE("audio < Q_AUDIO_STOP"); 3646 LOGFQUEUE("audio < Q_AUDIO_STOP");
3638 audio_stop_playback(); 3647 audio_stop_playback();
3648 if (ev.data != 0)
3649 queue_clear(&audio_queue);
3639 break ; 3650 break ;
3640 3651
3641 case Q_AUDIO_PAUSE: 3652 case Q_AUDIO_PAUSE: