diff options
Diffstat (limited to 'apps/playback.c')
-rw-r--r-- | apps/playback.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/apps/playback.c b/apps/playback.c index 3da4b6fbdb..48b993474b 100644 --- a/apps/playback.c +++ b/apps/playback.c | |||
@@ -179,6 +179,7 @@ static struct track_info tracks[MAX_TRACK]; | |||
179 | 179 | ||
180 | /* Pointer to track info structure about current song playing. */ | 180 | /* Pointer to track info structure about current song playing. */ |
181 | static struct track_info *cur_ti; | 181 | static struct track_info *cur_ti; |
182 | static struct track_info *prev_ti; | ||
182 | 183 | ||
183 | /* Have we reached end of the current playlist. */ | 184 | /* Have we reached end of the current playlist. */ |
184 | static bool playlist_end = false; | 185 | static bool playlist_end = false; |
@@ -395,6 +396,17 @@ void* get_codec_memory_callback(long *size) | |||
395 | return &audiobuf[0]; | 396 | return &audiobuf[0]; |
396 | } | 397 | } |
397 | 398 | ||
399 | static void pcmbuf_position_callback(int size) ICODE_ATTR; | ||
400 | static void pcmbuf_position_callback(int size) { | ||
401 | unsigned int time = size * 1000 / 4 / 44100 + prev_ti->id3.elapsed; | ||
402 | if (time >= prev_ti->id3.length) { | ||
403 | pcmbuf_set_position_callback(NULL); | ||
404 | prev_ti->id3.elapsed = cur_ti->id3.length; | ||
405 | } else { | ||
406 | prev_ti->id3.elapsed = time; | ||
407 | } | ||
408 | } | ||
409 | |||
398 | void codec_set_elapsed_callback(unsigned int value) | 410 | void codec_set_elapsed_callback(unsigned int value) |
399 | { | 411 | { |
400 | unsigned int latency; | 412 | unsigned int latency; |
@@ -1640,8 +1652,8 @@ static void audio_change_track(void) | |||
1640 | 1652 | ||
1641 | bool codec_request_next_track_callback(void) | 1653 | bool codec_request_next_track_callback(void) |
1642 | { | 1654 | { |
1643 | struct track_info *prev_ti = cur_ti; | 1655 | prev_ti = cur_ti; |
1644 | 1656 | ||
1645 | if (current_codec == CODEC_IDX_VOICE) { | 1657 | if (current_codec == CODEC_IDX_VOICE) { |
1646 | voice_remaining = 0; | 1658 | voice_remaining = 0; |
1647 | /* Terminate the codec if there are messages waiting on the queue or | 1659 | /* Terminate the codec if there are messages waiting on the queue or |
@@ -1649,6 +1661,8 @@ bool codec_request_next_track_callback(void) | |||
1649 | return !ci_voice.stop_codec && queue_empty(&voice_codec_queue); | 1661 | return !ci_voice.stop_codec && queue_empty(&voice_codec_queue); |
1650 | } | 1662 | } |
1651 | 1663 | ||
1664 | pcmbuf_set_position_callback(pcmbuf_position_callback); | ||
1665 | |||
1652 | if (ci.stop_codec || !playing) | 1666 | if (ci.stop_codec || !playing) |
1653 | return false; | 1667 | return false; |
1654 | 1668 | ||
@@ -1878,6 +1892,7 @@ void audio_thread(void) | |||
1878 | if (track_changed_callback) | 1892 | if (track_changed_callback) |
1879 | track_changed_callback(&cur_ti->id3); | 1893 | track_changed_callback(&cur_ti->id3); |
1880 | playlist_update_resume_info(audio_current_track()); | 1894 | playlist_update_resume_info(audio_current_track()); |
1895 | pcmbuf_set_position_callback(NULL); | ||
1881 | break ; | 1896 | break ; |
1882 | 1897 | ||
1883 | case AUDIO_CODEC_DONE: | 1898 | case AUDIO_CODEC_DONE: |