summaryrefslogtreecommitdiff
path: root/apps/pcmbuf.c
diff options
context:
space:
mode:
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 }