mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Thread: Check for realtimeAudioPriority in more locations
This commit is contained in:
parent
c27279b356
commit
1de762218a
2 changed files with 12 additions and 12 deletions
|
|
@ -139,16 +139,11 @@ void Thread::startThread (int priority)
|
|||
|
||||
if (threadHandle.get() == nullptr)
|
||||
{
|
||||
auto isRealtime = (priority == realtimeAudioPriority);
|
||||
|
||||
#if JUCE_ANDROID
|
||||
isAndroidRealtimeThread = isRealtime;
|
||||
isAndroidRealtimeThread = (priority == realtimeAudioPriority);
|
||||
#endif
|
||||
|
||||
if (isRealtime)
|
||||
priority = 9;
|
||||
|
||||
threadPriority = priority;
|
||||
threadPriority = getAdjustedPriority (priority);
|
||||
startThread();
|
||||
}
|
||||
else
|
||||
|
|
@ -257,10 +252,7 @@ void Thread::removeListener (Listener* listener)
|
|||
//==============================================================================
|
||||
bool Thread::setPriority (int newPriority)
|
||||
{
|
||||
bool isRealtime = (newPriority == realtimeAudioPriority);
|
||||
|
||||
if (isRealtime)
|
||||
newPriority = 9;
|
||||
newPriority = getAdjustedPriority (newPriority);
|
||||
|
||||
// NB: deadlock possible if you try to set the thread prio from the thread itself,
|
||||
// so using setCurrentThreadPriority instead in that case.
|
||||
|
|
@ -270,6 +262,8 @@ bool Thread::setPriority (int newPriority)
|
|||
const ScopedLock sl (startStopLock);
|
||||
|
||||
#if JUCE_ANDROID
|
||||
bool isRealtime = (newPriority == realtimeAudioPriority);
|
||||
|
||||
// you cannot switch from or to an Android realtime thread once the
|
||||
// thread is already running!
|
||||
jassert (isThreadRunning() && (isRealtime == isAndroidRealtimeThread));
|
||||
|
|
@ -288,7 +282,7 @@ bool Thread::setPriority (int newPriority)
|
|||
|
||||
bool Thread::setCurrentThreadPriority (const int newPriority)
|
||||
{
|
||||
return setThreadPriority ({}, newPriority);
|
||||
return setThreadPriority ({}, getAdjustedPriority (newPriority));
|
||||
}
|
||||
|
||||
void Thread::setAffinityMask (const uint32 newAffinityMask)
|
||||
|
|
@ -296,6 +290,11 @@ void Thread::setAffinityMask (const uint32 newAffinityMask)
|
|||
affinityMask = newAffinityMask;
|
||||
}
|
||||
|
||||
int Thread::getAdjustedPriority (int newPriority)
|
||||
{
|
||||
return jlimit (0, 10, newPriority == realtimeAudioPriority ? 9 : newPriority);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
bool Thread::wait (const int timeOutMilliseconds) const
|
||||
{
|
||||
|
|
|
|||
|
|
@ -407,6 +407,7 @@ private:
|
|||
void killThread();
|
||||
void threadEntryPoint();
|
||||
static bool setThreadPriority (void*, int);
|
||||
static int getAdjustedPriority (int);
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Thread)
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue