summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2007-11-20 22:45:46 +0000
committerMichael Sevakis <jethead71@rockbox.org>2007-11-20 22:45:46 +0000
commit398d9fd8b41bdb9fbc7685c55de94a170bb9a6b1 (patch)
tree55cb4d3669877b348fa4904d465af553b72da5bf
parentacbd78023965cce0b0499ff150caf8078cb33b58 (diff)
downloadrockbox-398d9fd8b41bdb9fbc7685c55de94a170bb9a6b1.zip
rockbox-398d9fd8b41bdb9fbc7685c55de94a170bb9a6b1.tar.gz
rockbox-398d9fd8b41bdb9fbc7685c55de94a170bb9a6b1.tar.bz2
rockbox-398d9fd8b41bdb9fbc7685c55de94a170bb9a6b1.tar.xz
Hopefully the last word on getting rid of yield_codecs loops (cut read chunk to 16kB). Sansa ata driver also didn't yield enough so buffering would starve other threads. Bump priority of audio thread to keep UI more responsive.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15724 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/buffering.c40
-rw-r--r--apps/playback.c2
-rw-r--r--firmware/target/arm/sandisk/ata-c200_e200.c2
3 files changed, 14 insertions, 30 deletions
diff --git a/apps/buffering.c b/apps/buffering.c
index 18cdb99..85bbe86 100644
--- a/apps/buffering.c
+++ b/apps/buffering.c
@@ -88,7 +88,7 @@
/* default point to start buffer refill */
#define BUFFERING_DEFAULT_WATERMARK (1024*512)
/* amount of data to read in one read() call */
-#define BUFFERING_DEFAULT_FILECHUNK (1024*32)
+#define BUFFERING_DEFAULT_FILECHUNK (1024*16)
/* point at which the file buffer will fight for CPU time */
#define BUFFERING_CRITICAL_LEVEL (1024*128)
@@ -505,7 +505,6 @@ BUFFER SPACE MANAGEMENT
update_data_counters: Updates the values in data_counters
buffer_is_low : Returns true if the amount of useful data in the buffer is low
-yield_codec : Used by buffer_handle to know if it should interrupt buffering
buffer_handle : Buffer data for a handle
reset_handle : Reset write position and data buffer of a handle to its offset
rebuffer_handle : Seek to a nonbuffered part of a handle by rebuffering the data
@@ -552,25 +551,6 @@ static inline bool buffer_is_low(void)
return data_counters.useful < BUFFERING_CRITICAL_LEVEL;
}
-/* Yield to the codec thread for as long as possible if it is in need of data.
- Return true if the caller should break to let the buffering thread process
- new queue events */
-static bool yield_codec(void)
-{
- if (!queue_empty(&buffering_queue))
- return true;
-
- while (pcmbuf_is_lowdata() && !buffer_is_low())
- {
- sleep(2);
-
- if (!queue_empty(&buffering_queue))
- return true;
- }
-
- return false;
-}
-
/* Buffer data for the given handle.
Return whether or not the buffering should continue explicitly. */
static bool buffer_handle(int handle_id)
@@ -653,15 +633,19 @@ static bool buffer_handle(int handle_id)
h->available += rc;
h->filerem -= rc;
-#ifdef SIMULATOR
- sleep(1);
-#else
- yield();
-#endif
-
/* If this is a large file, see if we need to break or give the codec
* more time */
- if (h->type == TYPE_PACKET_AUDIO && yield_codec())
+ if (h->type == TYPE_PACKET_AUDIO &&
+ pcmbuf_is_lowdata() && !buffer_is_low())
+ {
+ sleep(1);
+ }
+ else
+ {
+ yield();
+ }
+
+ if (!queue_empty(&buffering_queue))
break;
}
diff --git a/apps/playback.c b/apps/playback.c
index 782c613..ac60750 100644
--- a/apps/playback.c
+++ b/apps/playback.c
@@ -2574,7 +2574,7 @@ void audio_init(void)
audio_thread_p = create_thread(audio_thread, audio_stack,
sizeof(audio_stack), CREATE_THREAD_FROZEN,
- audio_thread_name IF_PRIO(, PRIORITY_BACKGROUND)
+ audio_thread_name IF_PRIO(, PRIORITY_SYSTEM)
IF_COP(, CPU));
#ifdef PLAYBACK_VOICE
diff --git a/firmware/target/arm/sandisk/ata-c200_e200.c b/firmware/target/arm/sandisk/ata-c200_e200.c
index d8f9cb9..5a7577f 100644
--- a/firmware/target/arm/sandisk/ata-c200_e200.c
+++ b/firmware/target/arm/sandisk/ata-c200_e200.c
@@ -140,7 +140,7 @@ long last_disk_activity = -1;
static bool initialized = false;
static long next_yield = 0;
-#define MIN_YIELD_PERIOD 2000
+#define MIN_YIELD_PERIOD 1000
static tSDCardInfo card_info[2];
static tSDCardInfo *currcard = NULL; /* current active card */