Bug 1052169: Proxy thread destruction to avoid recursing event loops within OMX H264 shutdown r=bsmedberg

This commit is contained in:
Randell Jesup 2014-08-20 04:36:38 -04:00
parent 74d6fa680a
commit 87e617255b

View File

@ -23,6 +23,7 @@ using namespace android;
// WebRTC
#include "common_video/interface/texture_video_frame.h"
#include "video_engine/include/vie_external_codec.h"
#include "runnable_utils.h"
// Gecko
#include "GonkNativeWindow.h"
@ -104,6 +105,12 @@ struct EncodedFrame
int64_t mRenderTimeMs;
};
static void
ShutdownThread(nsCOMPtr<nsIThread>& aThread)
{
aThread->Shutdown();
}
// Base runnable class to repeatly pull OMX output buffers in seperate thread.
// How to use:
// - implementing DrainOutput() to get output. Remember to return false to tell
@ -137,7 +144,9 @@ public:
if (mThread != nullptr) {
MonitorAutoUnlock unlock(mMonitor);
CODEC_LOGD("OMXOutputDrain thread shutdown");
mThread->Shutdown();
NS_DispatchToMainThread(
WrapRunnableNM<decltype(&ShutdownThread),
nsCOMPtr<nsIThread> >(&ShutdownThread, mThread));
mThread = nullptr;
}
CODEC_LOGD("OMXOutputDrain stopped");