summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiika Pekkarinen <miipekk@ihme.org>2005-11-18 20:21:13 +0000
committerMiika Pekkarinen <miipekk@ihme.org>2005-11-18 20:21:13 +0000
commit9c0f1a9e395a4a680e7b2532ebdb468cbeccaca5 (patch)
tree81c2f4619b1f12503c278dd71f71af47f57f19d0
parent88a2a8a53a875f6af90fa2b479dc281e752881d2 (diff)
downloadrockbox-9c0f1a9e395a4a680e7b2532ebdb468cbeccaca5.zip
rockbox-9c0f1a9e395a4a680e7b2532ebdb468cbeccaca5.tar.gz
rockbox-9c0f1a9e395a4a680e7b2532ebdb468cbeccaca5.tar.bz2
rockbox-9c0f1a9e395a4a680e7b2532ebdb468cbeccaca5.tar.xz
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
-rw-r--r--apps/codecs/a52.c1
-rw-r--r--apps/codecs/aac.c1
-rw-r--r--apps/codecs/alac.c1
-rw-r--r--apps/codecs/flac.c1
-rw-r--r--apps/codecs/mpa.c1
-rw-r--r--apps/codecs/mpc.c1
-rw-r--r--apps/codecs/shorten.c1
-rw-r--r--apps/codecs/vorbis.c1
-rw-r--r--apps/codecs/wav.c1
-rw-r--r--apps/codecs/wavpack.c1
-rw-r--r--apps/dsp.h1
-rw-r--r--apps/playback.c37
12 files changed, 22 insertions, 26 deletions
diff --git a/apps/codecs/a52.c b/apps/codecs/a52.c
index 050bfff..ee80f66 100644
--- a/apps/codecs/a52.c
+++ b/apps/codecs/a52.c
@@ -140,7 +140,6 @@ enum codec_status codec_start(struct codec_api *api)
ci->configure(DSP_SET_SAMPLE_DEPTH, (long *)30);
ci->configure(DSP_SET_CLIP_MAX, (long *)((1 << 30) - 1));
ci->configure(DSP_SET_CLIP_MIN, (long *)-(1 << 30));
- ci->configure(CODEC_SET_FILEBUF_LIMIT, (long *)(1024*1024*2));
ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (long *)(1024*128));
next_track:
diff --git a/apps/codecs/aac.c b/apps/codecs/aac.c
index f6a6de5..c62fb2d 100644
--- a/apps/codecs/aac.c
+++ b/apps/codecs/aac.c
@@ -60,7 +60,6 @@ enum codec_status codec_start(struct codec_api* api)
rb->memcpy(iramstart, iramcopy, iramend-iramstart);
#endif
- ci->configure(CODEC_SET_FILEBUF_LIMIT, (int *)(1024*1024*2));
ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*16));
ci->configure(CODEC_SET_FILEBUF_WATERMARK, (int *)(1024*512));
diff --git a/apps/codecs/alac.c b/apps/codecs/alac.c
index 1ecaab6..deb1e28 100644
--- a/apps/codecs/alac.c
+++ b/apps/codecs/alac.c
@@ -57,7 +57,6 @@ enum codec_status codec_start(struct codec_api* api)
rb->memcpy(iramstart, iramcopy, iramend-iramstart);
#endif
- ci->configure(CODEC_SET_FILEBUF_LIMIT, (int *)(1024*1024*10));
ci->configure(CODEC_SET_FILEBUF_WATERMARK, (int *)(1024*512));
ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*128));
diff --git a/apps/codecs/flac.c b/apps/codecs/flac.c
index b94152d..7639b9a 100644
--- a/apps/codecs/flac.c
+++ b/apps/codecs/flac.c
@@ -233,7 +233,6 @@ enum codec_status codec_start(struct codec_api* api)
ci->memcpy(iramstart, iramcopy, iramend-iramstart);
#endif
- ci->configure(CODEC_SET_FILEBUF_LIMIT, (int *)(1024*1024*10));
ci->configure(CODEC_SET_FILEBUF_WATERMARK, (int *)(1024*512));
ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*128));
diff --git a/apps/codecs/mpa.c b/apps/codecs/mpa.c
index c6342df..0f57592 100644
--- a/apps/codecs/mpa.c
+++ b/apps/codecs/mpa.c
@@ -95,7 +95,6 @@ enum codec_status codec_start(struct codec_api *api)
ci->configure(DSP_SET_SAMPLE_DEPTH, (int *)(MAD_F_FRACBITS));
ci->configure(DSP_SET_CLIP_MIN, (int *)-MAD_F_ONE);
ci->configure(DSP_SET_CLIP_MAX, (int *)(MAD_F_ONE - 1));
- ci->configure(CODEC_SET_FILEBUF_LIMIT, (int *)(1024*1024*2));
ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*16));
ci->memset(&stream, 0, sizeof(struct mad_stream));
diff --git a/apps/codecs/mpc.c b/apps/codecs/mpc.c
index 0f113c7..db25015 100644
--- a/apps/codecs/mpc.c
+++ b/apps/codecs/mpc.c
@@ -96,7 +96,6 @@ enum codec_status codec_start(struct codec_api *api)
/* disable these until we can figure out what's going on.
ci->configure(DSP_SET_CLIP_MAX, (long *)MPC_FIXED_POINT_SCALE);
ci->configure(DSP_SET_CLIP_MIN, (long *)-MPC_FIXED_POINT_SCALE);*/
- ci->configure(CODEC_SET_FILEBUF_LIMIT, (long *)(1024*1024*2));
ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (long *)(1024*16));
/* Create a decoder instance */
diff --git a/apps/codecs/shorten.c b/apps/codecs/shorten.c
index 50d7299..26b5e09 100644
--- a/apps/codecs/shorten.c
+++ b/apps/codecs/shorten.c
@@ -56,7 +56,6 @@ enum codec_status codec_start(struct codec_api* api)
ci->memcpy(iramstart, iramcopy, iramend-iramstart);
#endif
- ci->configure(CODEC_SET_FILEBUF_LIMIT, (int *)(1024*1024*10));
ci->configure(CODEC_SET_FILEBUF_WATERMARK, (int *)(1024*512));
ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*128));
diff --git a/apps/codecs/vorbis.c b/apps/codecs/vorbis.c
index 1fbe131..69eba24 100644
--- a/apps/codecs/vorbis.c
+++ b/apps/codecs/vorbis.c
@@ -135,7 +135,6 @@ enum codec_status codec_start(struct codec_api *api)
/* Note: These are sane defaults for these values. Perhaps
* they should be set differently based on quality setting
*/
- rb->configure(CODEC_SET_FILEBUF_LIMIT, (long *)(1024*1024*2));
/* The chunk size below is magic. If set any lower, resume
* doesn't work properly (ov_raw_seek() does the wrong thing).
diff --git a/apps/codecs/wav.c b/apps/codecs/wav.c
index 6bf7bcd..85e2412 100644
--- a/apps/codecs/wav.c
+++ b/apps/codecs/wav.c
@@ -237,7 +237,6 @@ enum codec_status codec_start(struct codec_api* api)
ci->memcpy(iramstart, iramcopy, iramend-iramstart);
#endif
- ci->configure(CODEC_SET_FILEBUF_LIMIT, (int *)(1024*1024*10));
ci->configure(CODEC_SET_FILEBUF_WATERMARK, (int *)(1024*512));
ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*256));
diff --git a/apps/codecs/wavpack.c b/apps/codecs/wavpack.c
index 93f5002..21c1947 100644
--- a/apps/codecs/wavpack.c
+++ b/apps/codecs/wavpack.c
@@ -58,7 +58,6 @@ enum codec_status codec_start(struct codec_api* api)
ci->memcpy(iramstart, iramcopy, iramend-iramstart);
#endif
- ci->configure(CODEC_SET_FILEBUF_LIMIT, (int *)(1024*1024*10));
ci->configure(CODEC_SET_FILEBUF_WATERMARK, (int *)(1024*512));
ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*128));
diff --git a/apps/dsp.h b/apps/dsp.h
index 19ba6db..f250d89 100644
--- a/apps/dsp.h
+++ b/apps/dsp.h
@@ -31,7 +31,6 @@
enum {
CODEC_SET_FILEBUF_WATERMARK = 1,
CODEC_SET_FILEBUF_CHUNKSIZE,
- CODEC_SET_FILEBUF_LIMIT,
CODEC_DSP_ENABLE,
DSP_SET_FREQUENCY,
DSP_SWITCH_FREQUENCY,
diff --git a/apps/playback.c b/apps/playback.c
index 6a944c9..2418eba 100644
--- a/apps/playback.c
+++ b/apps/playback.c
@@ -81,6 +81,7 @@ static volatile bool paused;
#define CODEC_AAC "/.rockbox/codecs/aac.codec"
#define CODEC_SHN "/.rockbox/codecs/shorten.codec"
+#define AUDIO_DEFAULT_FIRST_LIMIT (1024*1024*10)
#define AUDIO_FILL_CYCLE (1024*256)
#define AUDIO_DEFAULT_WATERMARK (1024*512)
#define AUDIO_DEFAULT_FILECHUNK (1024*32)
@@ -717,10 +718,6 @@ void codec_configure_callback(int setting, void *value)
conf_filechunk = (unsigned int)value;
break;
- case CODEC_SET_FILEBUF_LIMIT:
- conf_bufferlimit = (unsigned int)value;
- break;
-
case CODEC_DSP_ENABLE:
if ((bool)value)
ci.pcmbuf_insert = codec_pcmbuf_insert_callback;
@@ -1009,9 +1006,11 @@ bool read_next_metadata(void)
fd = open(trackname, O_RDONLY);
if (fd < 0)
return false;
-
- /* Start buffer refilling also because we need to spin-up the disk. */
- filling = true;
+
+ /** Start buffer refilling also because we need to spin-up the disk.
+ * In fact, it might be better not to start filling here, because if user
+ * is manipulating the playlist a lot, we will just lose battery. */
+ // filling = true;
tracks[next_track].id3.codectype = probe_file_format(trackname);
status = get_metadata(&tracks[next_track],fd,trackname,v1first);
tracks[next_track].id3.codectype = 0;
@@ -1081,7 +1080,7 @@ bool audio_load_track(int offset, bool start_play, int peek_offset)
if (start_play) {
int last_codec = current_codec;
current_codec = CODEC_IDX_AUDIO;
- conf_bufferlimit = 0;
+ conf_bufferlimit = AUDIO_DEFAULT_FIRST_LIMIT;
conf_watermark = AUDIO_DEFAULT_WATERMARK;
conf_filechunk = AUDIO_DEFAULT_FILECHUNK;
dsp_configure(DSP_RESET, 0);
@@ -1329,13 +1328,13 @@ void initialize_buffer_fill(void)
{
int cur_idx, i;
-
- fill_bytesleft = filebuflen - filebufused;
- cur_ti->start_pos = ci.curpos;
-
+ /* Initialize only once; do not truncate the tracks. */
if (filling)
return ;
+ fill_bytesleft = filebuflen - filebufused;
+ cur_ti->start_pos = ci.curpos;
+
pcmbuf_set_boost_mode(true);
filling = true;
@@ -1392,8 +1391,14 @@ void audio_check_buffer(void)
/* Load new files to fill the entire buffer. */
if (audio_load_track(0, false, last_peek_offset + 1)) {
-
- } else if (tracks[track_widx].filerem == 0 || fill_bytesleft == 0) {
+ if (conf_bufferlimit)
+ fill_bytesleft = 0;
+ }
+ else if (tracks[track_widx].filerem == 0)
+ fill_bytesleft = 0;
+
+ if (fill_bytesleft <= 0)
+ {
/* Read next unbuffered track's metadata as necessary. */
read_next_metadata();
@@ -1659,7 +1664,7 @@ void audio_thread(void)
bool play_pending = false;
while (1) {
- if (!play_pending)
+ if (!play_pending && queue_empty(&audio_queue))
{
yield_codecs();
audio_check_buffer();
@@ -1683,12 +1688,14 @@ void audio_thread(void)
* fast to prevent UI lag. */
track_count = 0;
last_peek_offset = 0;
+ track_changed = true;
if (current_tick - last_tick < HZ/2)
{
play_pending = true;
break ;
}
play_pending = false;
+ last_tick = current_tick;
/* Do not start crossfading if audio is paused. */
if (paused)