From b71aad65f5b69e2c3212a3efdd3abca29516c450 Mon Sep 17 00:00:00 2001 From: Boris Gjenero Date: Sun, 19 Apr 2009 19:38:56 +0000 Subject: Add anti-skip buffer time when calculating watermark. This fixes the "Anti-Skip Buffer" setting. Since the minimum and default value is 5 seconds, this is relevant even when that setting isn't changed. It prevents playback pauses on the 5G iPod, and it should also prevent pauses on other SWCODEC hard drive based players, including FS#10115. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20747 a1c6a512-1295-4272-9138-f99709370657 --- apps/playback.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/apps/playback.c b/apps/playback.c index baed012ddf..fc34fe863f 100644 --- a/apps/playback.c +++ b/apps/playback.c @@ -264,7 +264,7 @@ static bool track_load_started = false; static bool codec_requested_stop = false; #ifdef HAVE_DISK_STORAGE -static size_t buffer_margin = 0; /* Buffer margin aka anti-skip buffer (A/C-) */ +static size_t buffer_margin = 5; /* Buffer margin aka anti-skip buffer (A/C-) */ #endif /* Multiple threads */ @@ -776,7 +776,7 @@ int audio_get_file_pos(void) #ifdef HAVE_DISK_STORAGE void audio_set_buffer_margin(int setting) { - static const int lookup[] = {5, 15, 30, 60, 120, 180, 300, 600}; + static const unsigned short lookup[] = {5, 15, 30, 60, 120, 180, 300, 600}; buffer_margin = lookup[setting]; logf("buffer margin: %ld", (long)buffer_margin); set_filebuf_watermark(); @@ -830,15 +830,18 @@ static void set_filebuf_watermark(void) if (!filebuf) return; /* Audio buffers not yet set up */ -#ifdef HAVE_FLASH_STORAGE - int seconds = 1; -#else +#ifdef HAVE_DISK_STORAGE int seconds; - int spinup = ata_spinup_time(); + int spinup = storage_spinup_time(); if (spinup) seconds = (spinup / HZ) + 1; else seconds = 5; + + seconds += buffer_margin; +#else + /* flash storage */ + int seconds = 1; #endif /* bitrate of last track in buffer dictates watermark */ -- cgit v1.2.3