diff options
author | Miika Pekkarinen <miipekk@ihme.org> | 2005-11-18 20:21:13 +0000 |
---|---|---|
committer | Miika Pekkarinen <miipekk@ihme.org> | 2005-11-18 20:21:13 +0000 |
commit | 9c0f1a9e395a4a680e7b2532ebdb468cbeccaca5 (patch) | |
tree | 81c2f4619b1f12503c278dd71f71af47f57f19d0 /apps/playback.c | |
parent | 88a2a8a53a875f6af90fa2b479dc281e752881d2 (diff) | |
download | rockbox-9c0f1a9e395a4a680e7b2532ebdb468cbeccaca5.tar.gz rockbox-9c0f1a9e395a4a680e7b2532ebdb468cbeccaca5.zip |
More stable playback with reduced stuttering when skipping tracks.
Removed CODEC_SET_FILEBUF_LIMIT setting; now playback.c determines how
to buffer the files.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7970 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/playback.c')
-rw-r--r-- | apps/playback.c | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/apps/playback.c b/apps/playback.c index 6a944c9dc8..2418eba367 100644 --- a/apps/playback.c +++ b/apps/playback.c | |||
@@ -81,6 +81,7 @@ static volatile bool paused; | |||
81 | #define CODEC_AAC "/.rockbox/codecs/aac.codec" | 81 | #define CODEC_AAC "/.rockbox/codecs/aac.codec" |
82 | #define CODEC_SHN "/.rockbox/codecs/shorten.codec" | 82 | #define CODEC_SHN "/.rockbox/codecs/shorten.codec" |
83 | 83 | ||
84 | #define AUDIO_DEFAULT_FIRST_LIMIT (1024*1024*10) | ||
84 | #define AUDIO_FILL_CYCLE (1024*256) | 85 | #define AUDIO_FILL_CYCLE (1024*256) |
85 | #define AUDIO_DEFAULT_WATERMARK (1024*512) | 86 | #define AUDIO_DEFAULT_WATERMARK (1024*512) |
86 | #define AUDIO_DEFAULT_FILECHUNK (1024*32) | 87 | #define AUDIO_DEFAULT_FILECHUNK (1024*32) |
@@ -717,10 +718,6 @@ void codec_configure_callback(int setting, void *value) | |||
717 | conf_filechunk = (unsigned int)value; | 718 | conf_filechunk = (unsigned int)value; |
718 | break; | 719 | break; |
719 | 720 | ||
720 | case CODEC_SET_FILEBUF_LIMIT: | ||
721 | conf_bufferlimit = (unsigned int)value; | ||
722 | break; | ||
723 | |||
724 | case CODEC_DSP_ENABLE: | 721 | case CODEC_DSP_ENABLE: |
725 | if ((bool)value) | 722 | if ((bool)value) |
726 | ci.pcmbuf_insert = codec_pcmbuf_insert_callback; | 723 | ci.pcmbuf_insert = codec_pcmbuf_insert_callback; |
@@ -1009,9 +1006,11 @@ bool read_next_metadata(void) | |||
1009 | fd = open(trackname, O_RDONLY); | 1006 | fd = open(trackname, O_RDONLY); |
1010 | if (fd < 0) | 1007 | if (fd < 0) |
1011 | return false; | 1008 | return false; |
1012 | 1009 | ||
1013 | /* Start buffer refilling also because we need to spin-up the disk. */ | 1010 | /** Start buffer refilling also because we need to spin-up the disk. |
1014 | filling = true; | 1011 | * In fact, it might be better not to start filling here, because if user |
1012 | * is manipulating the playlist a lot, we will just lose battery. */ | ||
1013 | // filling = true; | ||
1015 | tracks[next_track].id3.codectype = probe_file_format(trackname); | 1014 | tracks[next_track].id3.codectype = probe_file_format(trackname); |
1016 | status = get_metadata(&tracks[next_track],fd,trackname,v1first); | 1015 | status = get_metadata(&tracks[next_track],fd,trackname,v1first); |
1017 | tracks[next_track].id3.codectype = 0; | 1016 | tracks[next_track].id3.codectype = 0; |
@@ -1081,7 +1080,7 @@ bool audio_load_track(int offset, bool start_play, int peek_offset) | |||
1081 | if (start_play) { | 1080 | if (start_play) { |
1082 | int last_codec = current_codec; | 1081 | int last_codec = current_codec; |
1083 | current_codec = CODEC_IDX_AUDIO; | 1082 | current_codec = CODEC_IDX_AUDIO; |
1084 | conf_bufferlimit = 0; | 1083 | conf_bufferlimit = AUDIO_DEFAULT_FIRST_LIMIT; |
1085 | conf_watermark = AUDIO_DEFAULT_WATERMARK; | 1084 | conf_watermark = AUDIO_DEFAULT_WATERMARK; |
1086 | conf_filechunk = AUDIO_DEFAULT_FILECHUNK; | 1085 | conf_filechunk = AUDIO_DEFAULT_FILECHUNK; |
1087 | dsp_configure(DSP_RESET, 0); | 1086 | dsp_configure(DSP_RESET, 0); |
@@ -1329,13 +1328,13 @@ void initialize_buffer_fill(void) | |||
1329 | { | 1328 | { |
1330 | int cur_idx, i; | 1329 | int cur_idx, i; |
1331 | 1330 | ||
1332 | 1331 | /* Initialize only once; do not truncate the tracks. */ | |
1333 | fill_bytesleft = filebuflen - filebufused; | ||
1334 | cur_ti->start_pos = ci.curpos; | ||
1335 | |||
1336 | if (filling) | 1332 | if (filling) |
1337 | return ; | 1333 | return ; |
1338 | 1334 | ||
1335 | fill_bytesleft = filebuflen - filebufused; | ||
1336 | cur_ti->start_pos = ci.curpos; | ||
1337 | |||
1339 | pcmbuf_set_boost_mode(true); | 1338 | pcmbuf_set_boost_mode(true); |
1340 | 1339 | ||
1341 | filling = true; | 1340 | filling = true; |
@@ -1392,8 +1391,14 @@ void audio_check_buffer(void) | |||
1392 | 1391 | ||
1393 | /* Load new files to fill the entire buffer. */ | 1392 | /* Load new files to fill the entire buffer. */ |
1394 | if (audio_load_track(0, false, last_peek_offset + 1)) { | 1393 | if (audio_load_track(0, false, last_peek_offset + 1)) { |
1395 | 1394 | if (conf_bufferlimit) | |
1396 | } else if (tracks[track_widx].filerem == 0 || fill_bytesleft == 0) { | 1395 | fill_bytesleft = 0; |
1396 | } | ||
1397 | else if (tracks[track_widx].filerem == 0) | ||
1398 | fill_bytesleft = 0; | ||
1399 | |||
1400 | if (fill_bytesleft <= 0) | ||
1401 | { | ||
1397 | /* Read next unbuffered track's metadata as necessary. */ | 1402 | /* Read next unbuffered track's metadata as necessary. */ |
1398 | read_next_metadata(); | 1403 | read_next_metadata(); |
1399 | 1404 | ||
@@ -1659,7 +1664,7 @@ void audio_thread(void) | |||
1659 | bool play_pending = false; | 1664 | bool play_pending = false; |
1660 | 1665 | ||
1661 | while (1) { | 1666 | while (1) { |
1662 | if (!play_pending) | 1667 | if (!play_pending && queue_empty(&audio_queue)) |
1663 | { | 1668 | { |
1664 | yield_codecs(); | 1669 | yield_codecs(); |
1665 | audio_check_buffer(); | 1670 | audio_check_buffer(); |
@@ -1683,12 +1688,14 @@ void audio_thread(void) | |||
1683 | * fast to prevent UI lag. */ | 1688 | * fast to prevent UI lag. */ |
1684 | track_count = 0; | 1689 | track_count = 0; |
1685 | last_peek_offset = 0; | 1690 | last_peek_offset = 0; |
1691 | track_changed = true; | ||
1686 | if (current_tick - last_tick < HZ/2) | 1692 | if (current_tick - last_tick < HZ/2) |
1687 | { | 1693 | { |
1688 | play_pending = true; | 1694 | play_pending = true; |
1689 | break ; | 1695 | break ; |
1690 | } | 1696 | } |
1691 | play_pending = false; | 1697 | play_pending = false; |
1698 | last_tick = current_tick; | ||
1692 | 1699 | ||
1693 | /* Do not start crossfading if audio is paused. */ | 1700 | /* Do not start crossfading if audio is paused. */ |
1694 | if (paused) | 1701 | if (paused) |