Bug 1724994 - Promote GraphRunner to higher priority on Android. r=agi,pehrsons

Differential Revision: https://phabricator.services.mozilla.com/D123346
This commit is contained in:
Paul Adenot 2021-08-24 15:13:31 +00:00
parent 4e0c60c99c
commit a7b4d10bbb
3 changed files with 28 additions and 0 deletions

View File

@ -14,6 +14,9 @@
#include "prthread.h" #include "prthread.h"
#include "Tracing.h" #include "Tracing.h"
#include "audio_thread_priority.h" #include "audio_thread_priority.h"
#ifdef ANDROID
# include "AndroidProcess.h"
#endif
namespace mozilla { namespace mozilla {
@ -95,12 +98,31 @@ auto GraphRunner::OneIteration(GraphTime aStateTime, GraphTime aIterationEnd,
return result; return result;
} }
#ifdef ANDROID
namespace {
void PromoteRenderingThreadAndroid() {
MOZ_LOG(gMediaTrackGraphLog, LogLevel::Debug,
("GraphRunner default thread priority: %d",
java::sdk::Process::GetThreadPriority(java::sdk::Process::MyTid())));
java::sdk::Process::SetThreadPriority(
java::sdk::Process::THREAD_PRIORITY_URGENT_AUDIO);
MOZ_LOG(gMediaTrackGraphLog, LogLevel::Debug,
("GraphRunner promoted thread priority: %d",
java::sdk::Process::GetThreadPriority(java::sdk::Process::MyTid())));
}
}; // namespace
#endif
NS_IMETHODIMP GraphRunner::Run() { NS_IMETHODIMP GraphRunner::Run() {
#ifndef XP_LINUX #ifndef XP_LINUX
atp_handle* handle = atp_handle* handle =
atp_promote_current_thread_to_real_time(0, mGraph->GraphRate()); atp_promote_current_thread_to_real_time(0, mGraph->GraphRate());
#endif #endif
#ifdef ANDROID
PromoteRenderingThreadAndroid();
#endif
nsCOMPtr<nsIThreadInternal> threadInternal = do_QueryInterface(mThread); nsCOMPtr<nsIThreadInternal> threadInternal = do_QueryInterface(mThread);
threadInternal->SetObserver(mGraph); threadInternal->SetObserver(mGraph);

View File

@ -0,0 +1,5 @@
[android.os.Process = skip:true]
setThreadPriority =
getThreadPriority =
myTid =
THREAD_PRIORITY_URGENT_AUDIO =

View File

@ -14,6 +14,7 @@ generated = [
"AndroidBuild", "AndroidBuild",
"AndroidGraphics", "AndroidGraphics",
"AndroidInputType", "AndroidInputType",
"AndroidProcess",
"AndroidRect", "AndroidRect",
"InetAddress", "InetAddress",
"JavaBuiltins", "JavaBuiltins",