summaryrefslogtreecommitdiff
path: root/apps/pcmbuf.c
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2008-03-25 02:34:12 +0000
committerMichael Sevakis <jethead71@rockbox.org>2008-03-25 02:34:12 +0000
commit27cf67733936abd75fcb1f8da765977cd75906ee (patch)
treef894211a8a0c77b402dd3250b2bee2d17dcfe13f /apps/pcmbuf.c
parentbc2f8fd8f38a3e010cd67bbac358f6e9991153c6 (diff)
downloadrockbox-27cf67733936abd75fcb1f8da765977cd75906ee.tar.gz
rockbox-27cf67733936abd75fcb1f8da765977cd75906ee.zip
Add a complete priority inheritance implementation to the scheduler (all mutex ownership and queue_send calls are inheritable). Priorities are differential so that dispatch depends on the runnable range of priorities. Codec priority can therefore be raised in small steps (pcmbuf updated to enable). Simplify the kernel functions to ease implementation and use the same kernel.c for both sim and target (I'm tired of maintaining two ;_). 1) Not sure if a minor audio break at first buffering issue will exist on large-sector disks (the main mutex speed issue was genuinely resolved earlier). At this point it's best dealt with at the buffering level. It seems a larger filechunk could be used again. 2) Perhaps 64-bit sims will have some minor issues (finicky) but a backroll of the code of concern there is a 5-minute job. All kernel objects become incompatible so a full rebuild and update is needed.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16791 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/pcmbuf.c')
-rw-r--r--apps/pcmbuf.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/apps/pcmbuf.c b/apps/pcmbuf.c
index 8153118715..8f16c90523 100644
--- a/apps/pcmbuf.c
+++ b/apps/pcmbuf.c
@@ -116,7 +116,7 @@ static bool low_latency_mode = false;
116static bool pcmbuf_flush; 116static bool pcmbuf_flush;
117 117
118#ifdef HAVE_PRIORITY_SCHEDULING 118#ifdef HAVE_PRIORITY_SCHEDULING
119static int codec_thread_priority = 0; 119static int codec_thread_priority = PRIORITY_PLAYBACK;
120#endif 120#endif
121 121
122extern struct thread_entry *codec_thread_p; 122extern struct thread_entry *codec_thread_p;
@@ -256,18 +256,21 @@ static void boost_codec_thread(bool boost)
256 * will starve if the codec thread's priority is boosted. */ 256 * will starve if the codec thread's priority is boosted. */
257 if (boost) 257 if (boost)
258 { 258 {
259 if (codec_thread_priority == 0) 259 int priority = (PRIORITY_PLAYBACK - PRIORITY_PLAYBACK_MAX)*pcmbuf_unplayed_bytes
260 / (2*NATIVE_FREQUENCY) + PRIORITY_PLAYBACK_MAX;
261
262 if (priority != codec_thread_priority)
260 { 263 {
261 codec_thread_priority = thread_set_priority( 264 codec_thread_priority = priority;
262 codec_thread_p, PRIORITY_REALTIME); 265 thread_set_priority(codec_thread_p, priority);
263 voice_thread_set_priority(PRIORITY_REALTIME); 266 voice_thread_set_priority(priority);
264 } 267 }
265 } 268 }
266 else if (codec_thread_priority != 0) 269 else if (codec_thread_priority != PRIORITY_PLAYBACK)
267 { 270 {
268 thread_set_priority(codec_thread_p, codec_thread_priority); 271 thread_set_priority(codec_thread_p, PRIORITY_PLAYBACK);
269 voice_thread_set_priority(codec_thread_priority); 272 voice_thread_set_priority(PRIORITY_PLAYBACK);
270 codec_thread_priority = 0; 273 codec_thread_priority = PRIORITY_PLAYBACK;
271 } 274 }
272} 275}
273#endif /* HAVE_PRIORITY_SCHEDULING */ 276#endif /* HAVE_PRIORITY_SCHEDULING */
@@ -818,7 +821,7 @@ static bool prepare_insert(size_t length)
818 if (low_latency_mode) 821 if (low_latency_mode)
819 { 822 {
820 /* 1/4s latency. */ 823 /* 1/4s latency. */
821 if (pcmbuf_unplayed_bytes > NATIVE_FREQUENCY * 4 / 4 824 if (pcmbuf_unplayed_bytes > NATIVE_FREQUENCY * 4 / 2
822 && pcm_is_playing()) 825 && pcm_is_playing())
823 return false; 826 return false;
824 } 827 }