From 6427d127aaedcf7f68f7ad7438c5ffb284b8c9aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Stenberg?= Date: Sat, 10 Jan 2009 21:10:56 +0000 Subject: Calculate watermark from bitrate and harddisk spinup time. Use a smaller PCM buffer on targets with 2MB or less ram. (FS#9703) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19743 a1c6a512-1295-4272-9138-f99709370657 --- apps/buffering.c | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) (limited to 'apps/buffering.c') diff --git a/apps/buffering.c b/apps/buffering.c index 1e643c5..d715456 100644 --- a/apps/buffering.c +++ b/apps/buffering.c @@ -56,11 +56,7 @@ #include "albumart.h" #endif -#if MEM > 1 #define GUARD_BUFSIZE (32*1024) -#else -#define GUARD_BUFSIZE (8*1024) -#endif /* Define LOGF_ENABLE to enable logf output in this file */ /*#define LOGF_ENABLE*/ @@ -88,11 +84,9 @@ #endif /* default point to start buffer refill */ -#define BUFFERING_DEFAULT_WATERMARK (1024*512) +#define BUFFERING_DEFAULT_WATERMARK (1024*128) /* amount of data to read in one read() call */ #define BUFFERING_DEFAULT_FILECHUNK (1024*32) -/* point at which the file buffer will fight for CPU time */ -#define BUFFERING_CRITICAL_LEVEL (1024*128) #define BUF_HANDLE_MASK 0x7FFFFFFF @@ -173,7 +167,6 @@ enum { Q_BASE_HANDLE, /* Set the reference handle for buf_useful_data */ /* Configuration: */ - Q_SET_WATERMARK, Q_START_FILL, /* Request that the buffering thread initiate a buffer fill at its earliest convenience */ Q_HANDLE_ADDED, /* Inform the buffering thread that a handle was added, @@ -555,7 +548,7 @@ static void update_data_counters(void) static inline bool buffer_is_low(void) { update_data_counters(); - return data_counters.useful < BUFFERING_CRITICAL_LEVEL; + return data_counters.useful < (conf_watermark / 2); } /* Buffer data for the given handle. @@ -1313,8 +1306,7 @@ size_t buf_used(void) void buf_set_watermark(size_t bytes) { - LOGFQUEUE("buffering > Q_SET_WATERMARK %ld", (long)bytes); - queue_post(&buffering_queue, Q_SET_WATERMARK, bytes); + conf_watermark = bytes; } static void shrink_buffer_inner(struct memory_handle *h) @@ -1386,17 +1378,6 @@ void buffering_thread(void) base_handle_id = (int)ev.data; break; - case Q_SET_WATERMARK: - LOGFQUEUE("buffering < Q_SET_WATERMARK"); - conf_watermark = (size_t)ev.data; - if (conf_watermark < BUFFERING_DEFAULT_FILECHUNK) - { - logf("wmark