From 078cfcf7cce9185ec7559910d08b0bc02bfc88a3 Mon Sep 17 00:00:00 2001 From: Andreas Huber Date: Thu, 15 Sep 2011 12:25:04 -0700 Subject: Various improvements to nuplayer playback - Drastically cut down the number of times we supply the AudioSink with data by estimating the time until the sink would run out of data and then scheduling a refill in advance of that. - Use a dedicated looper for video decoders since they are currently taking too long to return from OMX_FillThisBuffer (bug 5325201) - Revise thread priorities for the OMX dispatcher and software codecs, instead of running them at ANDROID_PRIORITY_AUDIO, they now only run at ANDROID_PRIORITY_FOREGROUND - Since threads created by pthread_create inherit all of the parent threads attributes including thread priority, briefly reset thread priority to ANDROID_PRIORITY_FOREGROUND before instantiating OMX components and then restore it. Change-Id: If9332a3a20dad5485333d68c11de0d2d5d3fffc3 --- media/libstagefright/chromium_http/support.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'media/libstagefright/chromium_http/support.cpp') diff --git a/media/libstagefright/chromium_http/support.cpp b/media/libstagefright/chromium_http/support.cpp index de936c4..f15014e 100644 --- a/media/libstagefright/chromium_http/support.cpp +++ b/media/libstagefright/chromium_http/support.cpp @@ -74,10 +74,32 @@ bool logMessageHandler( return false; } +struct AutoPrioritySaver { + AutoPrioritySaver() + : mTID(androidGetTid()), + mPrevPriority(androidGetThreadPriority(mTID)) { + androidSetThreadPriority(mTID, ANDROID_PRIORITY_NORMAL); + } + + ~AutoPrioritySaver() { + androidSetThreadPriority(mTID, mPrevPriority); + } + +private: + pid_t mTID; + int mPrevPriority; + + DISALLOW_EVIL_CONSTRUCTORS(AutoPrioritySaver); +}; static void InitializeNetworkThreadIfNecessary() { Mutex::Autolock autoLock(gNetworkThreadLock); + if (gNetworkThread == NULL) { + // Make sure any threads spawned by the chromium framework are + // running at normal priority instead of inheriting this thread's. + AutoPrioritySaver saver; + gNetworkThread = new base::Thread("network"); base::Thread::Options options; options.message_loop_type = MessageLoop::TYPE_IO; -- cgit v1.1