summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 */