From ffd207f4b03d3a38f9ab5793d8990cfcf9b0ae13 Mon Sep 17 00:00:00 2001 From: Linus Nielsen Feltzing Date: Wed, 6 Jul 2005 19:40:17 +0000 Subject: Makes sure that the pause/resume/prev/next functions are executed in the audio thread git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7043 a1c6a512-1295-4272-9138-f99709370657 --- apps/playback.c | 71 ++++++++++++++++++++++++++++++--------------------------- 1 file changed, 38 insertions(+), 33 deletions(-) diff --git a/apps/playback.c b/apps/playback.c index f190f08..13c66a4 100644 --- a/apps/playback.c +++ b/apps/playback.c @@ -1333,6 +1333,27 @@ void audio_invalidate_tracks(void) read_next_metadata(); } +static void initiate_track_change(int peek_index) +{ + if (!playlist_check(peek_index)) + return ; + + new_track = peek_index; + ci.reload_codec = true; + + /* Detect if disk is spinning.. */ + if (filling) { + ci.stop_codec = true; + playlist_next(peek_index); + queue_post(&audio_queue, AUDIO_PLAY, 0); + } + + else if (!pcm_crossfade_init()) + pcm_flush_audio(); + else + codec_track_changed(); +} + void audio_thread(void) { struct event ev; @@ -1364,14 +1385,27 @@ void audio_thread(void) break ; case AUDIO_PAUSE: + logf("audio_pause"); + pcm_play_pause(false); + paused = true; break ; case AUDIO_RESUME: + logf("audio_resume"); + pcm_play_pause(true); + paused = false; break ; case AUDIO_NEXT: + logf("audio_next"); + initiate_track_change(1); break ; + case AUDIO_PREV: + logf("audio_prev"); + initiate_track_change(-1); + break; + case AUDIO_FLUSH: audio_invalidate_tracks(); break ; @@ -1532,51 +1566,22 @@ void audio_stop(void) void audio_pause(void) { - logf("audio_pause"); - pcm_play_pause(false); - paused = true; - //queue_post(&audio_queue, AUDIO_PAUSE, 0); + queue_post(&audio_queue, AUDIO_PAUSE, 0); } void audio_resume(void) { - logf("audio_resume"); - pcm_play_pause(true); - paused = false; - //queue_post(&audio_queue, AUDIO_RESUME, 0); -} - -static void initiate_track_change(int peek_index) -{ - if (!playlist_check(peek_index)) - return ; - - new_track = peek_index; - ci.reload_codec = true; - - /* Detect if disk is spinning.. */ - if (filling) { - ci.stop_codec = true; - playlist_next(peek_index); - queue_post(&audio_queue, AUDIO_PLAY, 0); - } - - else if (!pcm_crossfade_init()) - pcm_flush_audio(); - else - codec_track_changed(); + queue_post(&audio_queue, AUDIO_RESUME, 0); } void audio_next(void) { - logf("audio_next"); - initiate_track_change(1); + queue_post(&audio_queue, AUDIO_NEXT, 0); } void audio_prev(void) { - logf("audio_prev"); - initiate_track_change(-1); + queue_post(&audio_queue, AUDIO_PREV, 0); } void audio_ff_rewind(int newpos) -- cgit v1.1