diff options
author | Brandon Low <lostlogic@rockbox.org> | 2006-01-21 22:58:08 +0000 |
---|---|---|
committer | Brandon Low <lostlogic@rockbox.org> | 2006-01-21 22:58:08 +0000 |
commit | 0a9179cb0a4bda8191fcfcb45404ea361fcacdc5 (patch) | |
tree | 1a02ff91647446a21ca51bd119660f690535598f /apps/playback.c | |
parent | a3868d35d3621e700abfd51de61ac6f83908a472 (diff) | |
download | rockbox-0a9179cb0a4bda8191fcfcb45404ea361fcacdc5.tar.gz rockbox-0a9179cb0a4bda8191fcfcb45404ea361fcacdc5.zip |
Add seamless seeking support, this is needed for AB-repeat mode on swcodec.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8408 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/playback.c')
-rw-r--r-- | apps/playback.c | 47 |
1 files changed, 31 insertions, 16 deletions
diff --git a/apps/playback.c b/apps/playback.c index 48b993474b..932bf115f9 100644 --- a/apps/playback.c +++ b/apps/playback.c | |||
@@ -86,19 +86,20 @@ static volatile bool paused; | |||
86 | #define AUDIO_DEFAULT_WATERMARK (1024*512) | 86 | #define AUDIO_DEFAULT_WATERMARK (1024*512) |
87 | #define AUDIO_DEFAULT_FILECHUNK (1024*32) | 87 | #define AUDIO_DEFAULT_FILECHUNK (1024*32) |
88 | 88 | ||
89 | #define AUDIO_PLAY 1 | 89 | #define AUDIO_PLAY 1 |
90 | #define AUDIO_STOP 2 | 90 | #define AUDIO_STOP 2 |
91 | #define AUDIO_PAUSE 3 | 91 | #define AUDIO_PAUSE 3 |
92 | #define AUDIO_RESUME 4 | 92 | #define AUDIO_RESUME 4 |
93 | #define AUDIO_NEXT 5 | 93 | #define AUDIO_NEXT 5 |
94 | #define AUDIO_PREV 6 | 94 | #define AUDIO_PREV 6 |
95 | #define AUDIO_FF_REWIND 7 | 95 | #define AUDIO_FF_REWIND 7 |
96 | #define AUDIO_FLUSH_RELOAD 8 | 96 | #define AUDIO_FLUSH_RELOAD 8 |
97 | #define AUDIO_CODEC_DONE 9 | 97 | #define AUDIO_CODEC_DONE 9 |
98 | #define AUDIO_FLUSH 10 | 98 | #define AUDIO_FLUSH 10 |
99 | #define AUDIO_TRACK_CHANGED 11 | 99 | #define AUDIO_TRACK_CHANGED 11 |
100 | #define AUDIO_DIR_NEXT 12 | 100 | #define AUDIO_DIR_NEXT 12 |
101 | #define AUDIO_DIR_PREV 13 | 101 | #define AUDIO_DIR_PREV 13 |
102 | #define AUDIO_SEAMLESS_SEEK 14 | ||
102 | 103 | ||
103 | #define CODEC_LOAD 1 | 104 | #define CODEC_LOAD 1 |
104 | #define CODEC_LOAD_DISK 2 | 105 | #define CODEC_LOAD_DISK 2 |
@@ -306,13 +307,15 @@ bool codec_pcmbuf_insert_split_callback(void *ch1, void *ch2, | |||
306 | 307 | ||
307 | while (length > 0) { | 308 | while (length > 0) { |
308 | /* This will prevent old audio from playing when skipping tracks. */ | 309 | /* This will prevent old audio from playing when skipping tracks. */ |
309 | if ((ci.reload_codec || ci.stop_codec) && current_codec != CODEC_IDX_VOICE) | 310 | if ((ci.reload_codec || ci.stop_codec) && |
311 | current_codec != CODEC_IDX_VOICE) | ||
310 | return true; | 312 | return true; |
311 | 313 | ||
312 | while ((dest = pcmbuf_request_buffer(dsp_output_size(length), | 314 | while ((dest = pcmbuf_request_buffer(dsp_output_size(length), |
313 | &output_size)) == NULL) { | 315 | &output_size)) == NULL) { |
314 | sleep(1); | 316 | sleep(1); |
315 | if ((ci.reload_codec || ci.stop_codec) && current_codec != CODEC_IDX_VOICE) | 317 | if ((ci.reload_codec || ci.stop_codec) && |
318 | current_codec != CODEC_IDX_VOICE) | ||
316 | return true; | 319 | return true; |
317 | } | 320 | } |
318 | 321 | ||
@@ -330,9 +333,10 @@ bool codec_pcmbuf_insert_split_callback(void *ch1, void *ch2, | |||
330 | DEBUGF("Warning: dsp_input_size(%ld=dsp_output_size(%ld))=%ld <= 0\n", | 333 | DEBUGF("Warning: dsp_input_size(%ld=dsp_output_size(%ld))=%ld <= 0\n", |
331 | output_size, length, input_size); | 334 | output_size, length, input_size); |
332 | /* should we really continue, or should we break? | 335 | /* should we really continue, or should we break? |
333 | * We should probably continue because calling pcmbuf_flush_buffer(0) | 336 | * We should probably continue because calling |
334 | * will wrap the buffer if it was fully filled and so next call to | 337 | * pcmbuf_flush_buffer(0) will wrap the buffer if it was fully |
335 | * pcmbuf_request_buffer should give the requested output_size. */ | 338 | * filled and so next call to pcmbuf_request_buffer should give |
339 | * the requested output_size. */ | ||
336 | continue; | 340 | continue; |
337 | } | 341 | } |
338 | 342 | ||
@@ -665,7 +669,6 @@ void codec_seek_complete_callback(void) | |||
665 | { | 669 | { |
666 | /* assume we're called from non-voice codec, as they shouldn't seek */ | 670 | /* assume we're called from non-voice codec, as they shouldn't seek */ |
667 | ci.seek_time = 0; | 671 | ci.seek_time = 0; |
668 | pcmbuf_play_stop(); | ||
669 | } | 672 | } |
670 | 673 | ||
671 | bool codec_seek_buffer_callback(off_t newpos) | 674 | bool codec_seek_buffer_callback(off_t newpos) |
@@ -1868,6 +1871,12 @@ void audio_thread(void) | |||
1868 | ci.seek_time = (int)ev.data+1; | 1871 | ci.seek_time = (int)ev.data+1; |
1869 | break ; | 1872 | break ; |
1870 | 1873 | ||
1874 | case AUDIO_SEAMLESS_SEEK: | ||
1875 | if (!playing) | ||
1876 | break ; | ||
1877 | ci.seek_time = (int)ev.data+1; | ||
1878 | break ; | ||
1879 | |||
1871 | case AUDIO_DIR_NEXT: | 1880 | case AUDIO_DIR_NEXT: |
1872 | logf("audio_dir_next"); | 1881 | logf("audio_dir_next"); |
1873 | playlist_end = false; | 1882 | playlist_end = false; |
@@ -2222,6 +2231,12 @@ void audio_ff_rewind(int newpos) | |||
2222 | queue_post(&audio_queue, AUDIO_FF_REWIND, (int *)newpos); | 2231 | queue_post(&audio_queue, AUDIO_FF_REWIND, (int *)newpos); |
2223 | } | 2232 | } |
2224 | 2233 | ||
2234 | void audio_seamless_seek(int newpos) | ||
2235 | { | ||
2236 | logf("seamless_seek: %d", newpos); | ||
2237 | queue_post(&audio_queue, AUDIO_SEAMLESS_SEEK, (int *)newpos); | ||
2238 | } | ||
2239 | |||
2225 | void audio_flush_and_reload_tracks(void) | 2240 | void audio_flush_and_reload_tracks(void) |
2226 | { | 2241 | { |
2227 | logf("flush & reload"); | 2242 | logf("flush & reload"); |