summaryrefslogtreecommitdiff
path: root/apps/codec_thread.c
diff options
context:
space:
mode:
authorJeffrey Goode <jeffg7@gmail.com>2009-11-04 03:58:33 +0000
committerJeffrey Goode <jeffg7@gmail.com>2009-11-04 03:58:33 +0000
commit5ce8e2cb0d2361606f3646e9fa59a39393500ba8 (patch)
treea7e294dd9b06aaddec5f8d0e6372a9209cd74af2 /apps/codec_thread.c
parent606a333a5f9701375b6efac55adf1c0d2e6e4b7e (diff)
downloadrockbox-5ce8e2cb0d2361606f3646e9fa59a39393500ba8.tar.gz
rockbox-5ce8e2cb0d2361606f3646e9fa59a39393500ba8.zip
Clarify track transition code in pcmbuf and playback. No functional changes yet.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23506 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codec_thread.c')
-rw-r--r--apps/codec_thread.c44
1 files changed, 3 insertions, 41 deletions
diff --git a/apps/codec_thread.c b/apps/codec_thread.c
index d4217c3789..affb560183 100644
--- a/apps/codec_thread.c
+++ b/apps/codec_thread.c
@@ -416,46 +416,8 @@ void codec_init_codec_api(void)
416} 416}
417 417
418 418
419/** pcmbuf track change callbacks */
420
421/* Between the codec and PCM track change, we need to keep updating the
422 "elapsed" value of the previous (to the codec, but current to the
423 user/PCM/WPS) track, so that the progressbar reaches the end.
424 During that transition, the WPS will display prevtrack_id3. */
425static void codec_pcmbuf_position_callback(size_t size) ICODE_ATTR;
426static void codec_pcmbuf_position_callback(size_t size)
427{
428 /* This is called from an ISR, so be quick */
429 unsigned int time = size * 1000 / 4 / NATIVE_FREQUENCY +
430 othertrack_id3->elapsed;
431
432 if (time >= othertrack_id3->length)
433 {
434 pcmbuf_set_position_callback(NULL);
435 othertrack_id3->elapsed = othertrack_id3->length;
436 }
437 else
438 othertrack_id3->elapsed = time;
439}
440
441static void codec_pcmbuf_track_changed_callback(void)
442{
443 LOGFQUEUE("codec > pcmbuf/audio Q_AUDIO_TRACK_CHANGED");
444 pcmbuf_set_position_callback(NULL);
445 audio_post_track_change();
446}
447
448
449/** track change functions */ 419/** track change functions */
450 420
451static inline void codec_gapless_track_change(void)
452{
453 /* callback keeps the progress bar moving while the pcmbuf empties */
454 pcmbuf_set_position_callback(codec_pcmbuf_position_callback);
455 /* set the pcmbuf callback for when the track really changes */
456 pcmbuf_set_event_handler(codec_pcmbuf_track_changed_callback);
457}
458
459static inline void codec_crossfade_track_change(void) 421static inline void codec_crossfade_track_change(void)
460{ 422{
461 /* Initiate automatic crossfade mode */ 423 /* Initiate automatic crossfade mode */
@@ -484,8 +446,8 @@ static void codec_track_skip_done(bool was_manual)
484 /* shuffle mode is on, so crossfade: */ 446 /* shuffle mode is on, so crossfade: */
485 codec_crossfade_track_change(); 447 codec_crossfade_track_change();
486 else 448 else
487 /* shuffle mode is off, so do a gapless track change */ 449 /* shuffle mode is off, so normal gapless playback */
488 codec_gapless_track_change(); 450 pcmbuf_start_track_change();
489 } 451 }
490 else 452 else
491 /* normal crossfade: */ 453 /* normal crossfade: */
@@ -493,7 +455,7 @@ static void codec_track_skip_done(bool was_manual)
493 } 455 }
494 else 456 else
495 /* normal gapless playback. */ 457 /* normal gapless playback. */
496 codec_gapless_track_change(); 458 pcmbuf_start_track_change();
497} 459}
498 460
499static bool codec_load_next_track(void) 461static bool codec_load_next_track(void)