diff options
| author | Linus Nielsen Feltzing <linus@haxx.se> | 2005-07-06 19:40:17 +0000 |
|---|---|---|
| committer | Linus Nielsen Feltzing <linus@haxx.se> | 2005-07-06 19:40:17 +0000 |
| commit | ffd207f4b03d3a38f9ab5793d8990cfcf9b0ae13 (patch) | |
| tree | b868da96d101877fa2ea2dd78142c4c098916b2a | |
| parent | d3424f0f51f564c6408b7d27fe3bc89fbfaba87d (diff) | |
| download | rockbox-ffd207f4b03d3a38f9ab5793d8990cfcf9b0ae13.zip rockbox-ffd207f4b03d3a38f9ab5793d8990cfcf9b0ae13.tar.gz rockbox-ffd207f4b03d3a38f9ab5793d8990cfcf9b0ae13.tar.bz2 rockbox-ffd207f4b03d3a38f9ab5793d8990cfcf9b0ae13.tar.xz | |
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
| -rw-r--r-- | apps/playback.c | 71 |
1 files 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) |