mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-08 12:45:26 -05:00
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
This commit is contained in:
parent
88a2a8a53a
commit
9c0f1a9e39
12 changed files with 22 additions and 26 deletions
|
|
@ -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_SAMPLE_DEPTH, (long *)30);
|
||||||
ci->configure(DSP_SET_CLIP_MAX, (long *)((1 << 30) - 1));
|
ci->configure(DSP_SET_CLIP_MAX, (long *)((1 << 30) - 1));
|
||||||
ci->configure(DSP_SET_CLIP_MIN, (long *)-(1 << 30));
|
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));
|
ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (long *)(1024*128));
|
||||||
|
|
||||||
next_track:
|
next_track:
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,6 @@ enum codec_status codec_start(struct codec_api* api)
|
||||||
rb->memcpy(iramstart, iramcopy, iramend-iramstart);
|
rb->memcpy(iramstart, iramcopy, iramend-iramstart);
|
||||||
#endif
|
#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_CHUNKSIZE, (int *)(1024*16));
|
||||||
ci->configure(CODEC_SET_FILEBUF_WATERMARK, (int *)(1024*512));
|
ci->configure(CODEC_SET_FILEBUF_WATERMARK, (int *)(1024*512));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,6 @@ enum codec_status codec_start(struct codec_api* api)
|
||||||
rb->memcpy(iramstart, iramcopy, iramend-iramstart);
|
rb->memcpy(iramstart, iramcopy, iramend-iramstart);
|
||||||
#endif
|
#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_WATERMARK, (int *)(1024*512));
|
||||||
ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*128));
|
ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*128));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -233,7 +233,6 @@ enum codec_status codec_start(struct codec_api* api)
|
||||||
ci->memcpy(iramstart, iramcopy, iramend-iramstart);
|
ci->memcpy(iramstart, iramcopy, iramend-iramstart);
|
||||||
#endif
|
#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_WATERMARK, (int *)(1024*512));
|
||||||
ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*128));
|
ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*128));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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_SAMPLE_DEPTH, (int *)(MAD_F_FRACBITS));
|
||||||
ci->configure(DSP_SET_CLIP_MIN, (int *)-MAD_F_ONE);
|
ci->configure(DSP_SET_CLIP_MIN, (int *)-MAD_F_ONE);
|
||||||
ci->configure(DSP_SET_CLIP_MAX, (int *)(MAD_F_ONE - 1));
|
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->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*16));
|
||||||
|
|
||||||
ci->memset(&stream, 0, sizeof(struct mad_stream));
|
ci->memset(&stream, 0, sizeof(struct mad_stream));
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,6 @@ enum codec_status codec_start(struct codec_api *api)
|
||||||
/* disable these until we can figure out what's going on.
|
/* 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_MAX, (long *)MPC_FIXED_POINT_SCALE);
|
||||||
ci->configure(DSP_SET_CLIP_MIN, (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));
|
ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (long *)(1024*16));
|
||||||
|
|
||||||
/* Create a decoder instance */
|
/* Create a decoder instance */
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,6 @@ enum codec_status codec_start(struct codec_api* api)
|
||||||
ci->memcpy(iramstart, iramcopy, iramend-iramstart);
|
ci->memcpy(iramstart, iramcopy, iramend-iramstart);
|
||||||
#endif
|
#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_WATERMARK, (int *)(1024*512));
|
||||||
ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*128));
|
ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*128));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -135,7 +135,6 @@ enum codec_status codec_start(struct codec_api *api)
|
||||||
/* Note: These are sane defaults for these values. Perhaps
|
/* Note: These are sane defaults for these values. Perhaps
|
||||||
* they should be set differently based on quality setting
|
* 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
|
/* The chunk size below is magic. If set any lower, resume
|
||||||
* doesn't work properly (ov_raw_seek() does the wrong thing).
|
* doesn't work properly (ov_raw_seek() does the wrong thing).
|
||||||
|
|
|
||||||
|
|
@ -237,7 +237,6 @@ enum codec_status codec_start(struct codec_api* api)
|
||||||
ci->memcpy(iramstart, iramcopy, iramend-iramstart);
|
ci->memcpy(iramstart, iramcopy, iramend-iramstart);
|
||||||
#endif
|
#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_WATERMARK, (int *)(1024*512));
|
||||||
ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*256));
|
ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*256));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,6 @@ enum codec_status codec_start(struct codec_api* api)
|
||||||
ci->memcpy(iramstart, iramcopy, iramend-iramstart);
|
ci->memcpy(iramstart, iramcopy, iramend-iramstart);
|
||||||
#endif
|
#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_WATERMARK, (int *)(1024*512));
|
||||||
ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*128));
|
ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*128));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,6 @@
|
||||||
enum {
|
enum {
|
||||||
CODEC_SET_FILEBUF_WATERMARK = 1,
|
CODEC_SET_FILEBUF_WATERMARK = 1,
|
||||||
CODEC_SET_FILEBUF_CHUNKSIZE,
|
CODEC_SET_FILEBUF_CHUNKSIZE,
|
||||||
CODEC_SET_FILEBUF_LIMIT,
|
|
||||||
CODEC_DSP_ENABLE,
|
CODEC_DSP_ENABLE,
|
||||||
DSP_SET_FREQUENCY,
|
DSP_SET_FREQUENCY,
|
||||||
DSP_SWITCH_FREQUENCY,
|
DSP_SWITCH_FREQUENCY,
|
||||||
|
|
|
||||||
|
|
@ -81,6 +81,7 @@ static volatile bool paused;
|
||||||
#define CODEC_AAC "/.rockbox/codecs/aac.codec"
|
#define CODEC_AAC "/.rockbox/codecs/aac.codec"
|
||||||
#define CODEC_SHN "/.rockbox/codecs/shorten.codec"
|
#define CODEC_SHN "/.rockbox/codecs/shorten.codec"
|
||||||
|
|
||||||
|
#define AUDIO_DEFAULT_FIRST_LIMIT (1024*1024*10)
|
||||||
#define AUDIO_FILL_CYCLE (1024*256)
|
#define AUDIO_FILL_CYCLE (1024*256)
|
||||||
#define AUDIO_DEFAULT_WATERMARK (1024*512)
|
#define AUDIO_DEFAULT_WATERMARK (1024*512)
|
||||||
#define AUDIO_DEFAULT_FILECHUNK (1024*32)
|
#define AUDIO_DEFAULT_FILECHUNK (1024*32)
|
||||||
|
|
@ -717,10 +718,6 @@ void codec_configure_callback(int setting, void *value)
|
||||||
conf_filechunk = (unsigned int)value;
|
conf_filechunk = (unsigned int)value;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CODEC_SET_FILEBUF_LIMIT:
|
|
||||||
conf_bufferlimit = (unsigned int)value;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CODEC_DSP_ENABLE:
|
case CODEC_DSP_ENABLE:
|
||||||
if ((bool)value)
|
if ((bool)value)
|
||||||
ci.pcmbuf_insert = codec_pcmbuf_insert_callback;
|
ci.pcmbuf_insert = codec_pcmbuf_insert_callback;
|
||||||
|
|
@ -1009,9 +1006,11 @@ bool read_next_metadata(void)
|
||||||
fd = open(trackname, O_RDONLY);
|
fd = open(trackname, O_RDONLY);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* Start buffer refilling also because we need to spin-up the disk. */
|
/** Start buffer refilling also because we need to spin-up the disk.
|
||||||
filling = true;
|
* 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);
|
tracks[next_track].id3.codectype = probe_file_format(trackname);
|
||||||
status = get_metadata(&tracks[next_track],fd,trackname,v1first);
|
status = get_metadata(&tracks[next_track],fd,trackname,v1first);
|
||||||
tracks[next_track].id3.codectype = 0;
|
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) {
|
if (start_play) {
|
||||||
int last_codec = current_codec;
|
int last_codec = current_codec;
|
||||||
current_codec = CODEC_IDX_AUDIO;
|
current_codec = CODEC_IDX_AUDIO;
|
||||||
conf_bufferlimit = 0;
|
conf_bufferlimit = AUDIO_DEFAULT_FIRST_LIMIT;
|
||||||
conf_watermark = AUDIO_DEFAULT_WATERMARK;
|
conf_watermark = AUDIO_DEFAULT_WATERMARK;
|
||||||
conf_filechunk = AUDIO_DEFAULT_FILECHUNK;
|
conf_filechunk = AUDIO_DEFAULT_FILECHUNK;
|
||||||
dsp_configure(DSP_RESET, 0);
|
dsp_configure(DSP_RESET, 0);
|
||||||
|
|
@ -1329,13 +1328,13 @@ void initialize_buffer_fill(void)
|
||||||
{
|
{
|
||||||
int cur_idx, i;
|
int cur_idx, i;
|
||||||
|
|
||||||
|
/* Initialize only once; do not truncate the tracks. */
|
||||||
fill_bytesleft = filebuflen - filebufused;
|
|
||||||
cur_ti->start_pos = ci.curpos;
|
|
||||||
|
|
||||||
if (filling)
|
if (filling)
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
|
fill_bytesleft = filebuflen - filebufused;
|
||||||
|
cur_ti->start_pos = ci.curpos;
|
||||||
|
|
||||||
pcmbuf_set_boost_mode(true);
|
pcmbuf_set_boost_mode(true);
|
||||||
|
|
||||||
filling = true;
|
filling = true;
|
||||||
|
|
@ -1392,8 +1391,14 @@ void audio_check_buffer(void)
|
||||||
|
|
||||||
/* Load new files to fill the entire buffer. */
|
/* Load new files to fill the entire buffer. */
|
||||||
if (audio_load_track(0, false, last_peek_offset + 1)) {
|
if (audio_load_track(0, false, last_peek_offset + 1)) {
|
||||||
|
if (conf_bufferlimit)
|
||||||
} else if (tracks[track_widx].filerem == 0 || fill_bytesleft == 0) {
|
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 unbuffered track's metadata as necessary. */
|
||||||
read_next_metadata();
|
read_next_metadata();
|
||||||
|
|
||||||
|
|
@ -1659,7 +1664,7 @@ void audio_thread(void)
|
||||||
bool play_pending = false;
|
bool play_pending = false;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if (!play_pending)
|
if (!play_pending && queue_empty(&audio_queue))
|
||||||
{
|
{
|
||||||
yield_codecs();
|
yield_codecs();
|
||||||
audio_check_buffer();
|
audio_check_buffer();
|
||||||
|
|
@ -1683,12 +1688,14 @@ void audio_thread(void)
|
||||||
* fast to prevent UI lag. */
|
* fast to prevent UI lag. */
|
||||||
track_count = 0;
|
track_count = 0;
|
||||||
last_peek_offset = 0;
|
last_peek_offset = 0;
|
||||||
|
track_changed = true;
|
||||||
if (current_tick - last_tick < HZ/2)
|
if (current_tick - last_tick < HZ/2)
|
||||||
{
|
{
|
||||||
play_pending = true;
|
play_pending = true;
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
play_pending = false;
|
play_pending = false;
|
||||||
|
last_tick = current_tick;
|
||||||
|
|
||||||
/* Do not start crossfading if audio is paused. */
|
/* Do not start crossfading if audio is paused. */
|
||||||
if (paused)
|
if (paused)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue