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
This commit is contained in:
parent
bf133996d5
commit
b425de71df
3 changed files with 40 additions and 20 deletions
|
@ -104,6 +104,8 @@ static size_t pcmbuf_mix_sample IDATA_ATTR;
|
||||||
static bool low_latency_mode = false;
|
static bool low_latency_mode = false;
|
||||||
static bool pcmbuf_flush;
|
static bool pcmbuf_flush;
|
||||||
|
|
||||||
|
static int codec_thread_priority = 0;
|
||||||
|
|
||||||
extern struct thread_entry *codec_thread_p;
|
extern struct thread_entry *codec_thread_p;
|
||||||
|
|
||||||
/* Helpful macros for use in conditionals this assumes some of the above
|
/* Helpful macros for use in conditionals this assumes some of the above
|
||||||
|
@ -235,30 +237,37 @@ static inline void pcmbuf_add_chunk(void)
|
||||||
audiobuffer_fillpos = 0;
|
audiobuffer_fillpos = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_PRIORITY_SCHEDULING
|
||||||
|
static void boost_codec_thread(bool boost)
|
||||||
|
{
|
||||||
|
if (boost)
|
||||||
|
{
|
||||||
|
if (codec_thread_priority == 0)
|
||||||
|
codec_thread_priority = thread_set_priority(
|
||||||
|
codec_thread_p, PRIORITY_REALTIME);
|
||||||
|
}
|
||||||
|
else if (codec_thread_priority != 0)
|
||||||
|
{
|
||||||
|
thread_set_priority(codec_thread_p, codec_thread_priority);
|
||||||
|
codec_thread_priority = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* HAVE_PRIORITY_SCHEDULING */
|
||||||
|
|
||||||
static void pcmbuf_under_watermark(void)
|
static void pcmbuf_under_watermark(void)
|
||||||
|
{
|
||||||
|
/* Only codec thread initiates boost - voice boosts the cpu when playing
|
||||||
|
a clip */
|
||||||
|
if (thread_get_current() == codec_thread_p)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_PRIORITY_SCHEDULING
|
#ifdef HAVE_PRIORITY_SCHEDULING
|
||||||
static int old_priority = 0;
|
/* If buffer is critically low, override UI priority, else
|
||||||
|
set back to the original priority. */
|
||||||
if (LOW_DATA(2) && pcm_is_playing())
|
boost_codec_thread(LOW_DATA(2) && pcm_is_playing());
|
||||||
{
|
|
||||||
if (!old_priority)
|
|
||||||
{
|
|
||||||
/* Buffer is critically low so override UI priority. */
|
|
||||||
old_priority = thread_set_priority(codec_thread_p,
|
|
||||||
PRIORITY_REALTIME);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (old_priority)
|
|
||||||
{
|
|
||||||
/* Set back the original priority. */
|
|
||||||
thread_set_priority(codec_thread_p, old_priority);
|
|
||||||
old_priority = 0;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Fill audio buffer by boosting cpu */
|
/* Fill audio buffer by boosting cpu */
|
||||||
trigger_cpu_boost();
|
trigger_cpu_boost();
|
||||||
|
}
|
||||||
|
|
||||||
/* Disable crossfade if < .5s of audio */
|
/* Disable crossfade if < .5s of audio */
|
||||||
if (LOW_DATA(2))
|
if (LOW_DATA(2))
|
||||||
|
@ -364,6 +373,11 @@ void pcmbuf_play_stop(void)
|
||||||
crossfade_init = false;
|
crossfade_init = false;
|
||||||
crossfade_active = false;
|
crossfade_active = false;
|
||||||
pcmbuf_flush = false;
|
pcmbuf_flush = false;
|
||||||
|
|
||||||
|
#ifdef HAVE_PRIORITY_SCHEDULING
|
||||||
|
/* Can unboost the codec thread here no matter who's calling */
|
||||||
|
boost_codec_thread(false);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int pcmbuf_used_descs(void) {
|
int pcmbuf_used_descs(void) {
|
||||||
|
|
|
@ -150,6 +150,7 @@ void wakeup_thread(struct thread_entry **thread);
|
||||||
int thread_set_priority(struct thread_entry *thread, int priority);
|
int thread_set_priority(struct thread_entry *thread, int priority);
|
||||||
int thread_get_priority(struct thread_entry *thread);
|
int thread_get_priority(struct thread_entry *thread);
|
||||||
#endif
|
#endif
|
||||||
|
struct thread_entry * thread_get_current(void);
|
||||||
void init_threads(void);
|
void init_threads(void);
|
||||||
int thread_stack_usage(const struct thread_entry *thread);
|
int thread_stack_usage(const struct thread_entry *thread);
|
||||||
int thread_get_status(const struct thread_entry *thread);
|
int thread_get_status(const struct thread_entry *thread);
|
||||||
|
|
|
@ -776,6 +776,11 @@ int thread_get_priority(struct thread_entry *thread)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
struct thread_entry * thread_get_current(void)
|
||||||
|
{
|
||||||
|
return cores[CURRENT_CORE].running;
|
||||||
|
}
|
||||||
|
|
||||||
void init_threads(void)
|
void init_threads(void)
|
||||||
{
|
{
|
||||||
unsigned int core = CURRENT_CORE;
|
unsigned int core = CURRENT_CORE;
|
||||||
|
|
Loading…
Reference in a new issue