summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2007-03-06 20:32:13 +0000
committerMichael Sevakis <jethead71@rockbox.org>2007-03-06 20:32:13 +0000
commitb425de71df7acdc82b4e466a5bac709d0dc15f64 (patch)
tree341a404edde5d4192bbf45b1b63f605f81ef3d8a /apps
parentbf133996d52eb6adb04c103a15ef18af1ccc7674 (diff)
downloadrockbox-b425de71df7acdc82b4e466a5bac709d0dc15f64.tar.gz
rockbox-b425de71df7acdc82b4e466a5bac709d0dc15f64.zip
Fix problem with recording screen creep and bag a bigfoot. Voice clips aren't long enough now to untrigger the thread boost that was supposed to be applied to the codec thread. The voice thread was needlessly boosting the codec thread and leaving it boosted which explains the encoders' ability to flood the output buffer when everything else was stopped in its tracks. Check which thread is calling pcmbuf_under_watermark and only initiate the boost when it's the codec thread. Always return the codec thread to its usual priority in pcmbuf_play_stop.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12649 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/pcmbuf.c50
1 files changed, 32 insertions, 18 deletions
diff --git a/apps/pcmbuf.c b/apps/pcmbuf.c
index e2b1d7f87b..91b9f1329b 100644
--- a/apps/pcmbuf.c
+++ b/apps/pcmbuf.c
@@ -104,6 +104,8 @@ static size_t pcmbuf_mix_sample IDATA_ATTR;
104static bool low_latency_mode = false; 104static bool low_latency_mode = false;
105static bool pcmbuf_flush; 105static bool pcmbuf_flush;
106 106
107static int codec_thread_priority = 0;
108
107extern struct thread_entry *codec_thread_p; 109extern struct thread_entry *codec_thread_p;
108 110
109/* Helpful macros for use in conditionals this assumes some of the above 111/* Helpful macros for use in conditionals this assumes some of the above
@@ -235,30 +237,37 @@ static inline void pcmbuf_add_chunk(void)
235 audiobuffer_fillpos = 0; 237 audiobuffer_fillpos = 0;
236} 238}
237 239
238static void pcmbuf_under_watermark(void)
239{
240#ifdef HAVE_PRIORITY_SCHEDULING 240#ifdef HAVE_PRIORITY_SCHEDULING
241 static int old_priority = 0; 241static void boost_codec_thread(bool boost)
242 242{
243 if (LOW_DATA(2) && pcm_is_playing()) 243 if (boost)
244 { 244 {
245 if (!old_priority) 245 if (codec_thread_priority == 0)
246 { 246 codec_thread_priority = thread_set_priority(
247 /* Buffer is critically low so override UI priority. */ 247 codec_thread_p, PRIORITY_REALTIME);
248 old_priority = thread_set_priority(codec_thread_p,
249 PRIORITY_REALTIME);
250 }
251 } 248 }
252 else if (old_priority) 249 else if (codec_thread_priority != 0)
253 { 250 {
254 /* Set back the original priority. */ 251 thread_set_priority(codec_thread_p, codec_thread_priority);
255 thread_set_priority(codec_thread_p, old_priority); 252 codec_thread_priority = 0;
256 old_priority = 0;
257 } 253 }
258#endif 254}
255#endif /* HAVE_PRIORITY_SCHEDULING */
259 256
260 /* Fill audio buffer by boosting cpu */ 257static void pcmbuf_under_watermark(void)
261 trigger_cpu_boost(); 258{
259 /* Only codec thread initiates boost - voice boosts the cpu when playing
260 a clip */
261 if (thread_get_current() == codec_thread_p)
262 {
263#ifdef HAVE_PRIORITY_SCHEDULING
264 /* If buffer is critically low, override UI priority, else
265 set back to the original priority. */
266 boost_codec_thread(LOW_DATA(2) && pcm_is_playing());
267#endif
268 /* Fill audio buffer by boosting cpu */
269 trigger_cpu_boost();
270 }
262 271
263 /* Disable crossfade if < .5s of audio */ 272 /* Disable crossfade if < .5s of audio */
264 if (LOW_DATA(2)) 273 if (LOW_DATA(2))
@@ -364,6 +373,11 @@ void pcmbuf_play_stop(void)
364 crossfade_init = false; 373 crossfade_init = false;
365 crossfade_active = false; 374 crossfade_active = false;
366 pcmbuf_flush = false; 375 pcmbuf_flush = false;
376
377#ifdef HAVE_PRIORITY_SCHEDULING
378 /* Can unboost the codec thread here no matter who's calling */
379 boost_codec_thread(false);
380#endif
367} 381}
368 382
369int pcmbuf_used_descs(void) { 383int pcmbuf_used_descs(void) {