зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1231939 - change Shutdown() as a block API. r=cpearce
This commit is contained in:
Родитель
9ac3b8bc44
Коммит
d3a2880ccb
|
@ -68,7 +68,7 @@ OmxDataDecoder::OmxDataDecoder(const TrackInfo& aTrackInfo,
|
||||||
, mOmxState(OMX_STATETYPE::OMX_StateInvalid, "OmxDataDecoder::mOmxState")
|
, mOmxState(OMX_STATETYPE::OMX_StateInvalid, "OmxDataDecoder::mOmxState")
|
||||||
, mTrackInfo(aTrackInfo.Clone())
|
, mTrackInfo(aTrackInfo.Clone())
|
||||||
, mFlushing(false)
|
, mFlushing(false)
|
||||||
, mShutdown(false)
|
, mShuttingDown(false)
|
||||||
, mCheckingInputExhausted(false)
|
, mCheckingInputExhausted(false)
|
||||||
, mPortSettingsChanged(-1, "OmxDataDecoder::mPortSettingsChanged")
|
, mPortSettingsChanged(-1, "OmxDataDecoder::mPortSettingsChanged")
|
||||||
, mAudioCompactor(mAudioQueue)
|
, mAudioCompactor(mAudioQueue)
|
||||||
|
@ -86,7 +86,6 @@ OmxDataDecoder::~OmxDataDecoder()
|
||||||
{
|
{
|
||||||
LOG("(%p)", this);
|
LOG("(%p)", this);
|
||||||
mWatchManager.Shutdown();
|
mWatchManager.Shutdown();
|
||||||
mOmxTaskQueue->AwaitShutdownAndIdle();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -207,12 +206,25 @@ OmxDataDecoder::Shutdown()
|
||||||
{
|
{
|
||||||
LOG("(%p)", this);
|
LOG("(%p)", this);
|
||||||
|
|
||||||
mShutdown = true;
|
mShuttingDown = true;
|
||||||
|
|
||||||
nsCOMPtr<nsIRunnable> r =
|
nsCOMPtr<nsIRunnable> r =
|
||||||
NS_NewRunnableMethod(this, &OmxDataDecoder::DoAsyncShutdown);
|
NS_NewRunnableMethod(this, &OmxDataDecoder::DoAsyncShutdown);
|
||||||
mOmxTaskQueue->Dispatch(r.forget());
|
mOmxTaskQueue->Dispatch(r.forget());
|
||||||
|
|
||||||
|
{
|
||||||
|
// DoAsyncShutdown() will be running for a while, it could be still running
|
||||||
|
// when reader releasing the decoder and then it causes problem. To avoid it,
|
||||||
|
// Shutdown() must block until DoAsyncShutdown() is completed.
|
||||||
|
MonitorAutoLock lock(mMonitor);
|
||||||
|
while (mShuttingDown) {
|
||||||
|
lock.Wait();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mOmxTaskQueue->BeginShutdown();
|
||||||
|
mOmxTaskQueue->AwaitShutdownAndIdle();
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,9 +285,17 @@ OmxDataDecoder::DoAsyncShutdown()
|
||||||
[self] () {
|
[self] () {
|
||||||
LOG("DoAsyncShutdown: OMX_StateLoaded, it is safe to shutdown omx");
|
LOG("DoAsyncShutdown: OMX_StateLoaded, it is safe to shutdown omx");
|
||||||
self->mOmxLayer->Shutdown();
|
self->mOmxLayer->Shutdown();
|
||||||
|
|
||||||
|
MonitorAutoLock lock(self->mMonitor);
|
||||||
|
self->mShuttingDown = false;
|
||||||
|
self->mMonitor.Notify();
|
||||||
},
|
},
|
||||||
[self] () {
|
[self] () {
|
||||||
self->mOmxLayer->Shutdown();
|
self->mOmxLayer->Shutdown();
|
||||||
|
|
||||||
|
MonitorAutoLock lock(self->mMonitor);
|
||||||
|
self->mShuttingDown = false;
|
||||||
|
self->mMonitor.Notify();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -400,12 +420,8 @@ OmxDataDecoder::FillAndEmptyBuffers()
|
||||||
MOZ_ASSERT(mOmxTaskQueue->IsCurrentThreadIn());
|
MOZ_ASSERT(mOmxTaskQueue->IsCurrentThreadIn());
|
||||||
MOZ_ASSERT(mOmxState == OMX_StateExecuting);
|
MOZ_ASSERT(mOmxState == OMX_StateExecuting);
|
||||||
|
|
||||||
// During the port setting changed, it is forbided to do any buffer operations.
|
// During the port setting changed, it is forbidden to do any buffer operation.
|
||||||
if (mPortSettingsChanged != -1 || mShutdown) {
|
if (mPortSettingsChanged != -1 || mShuttingDown || mFlushing) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mFlushing) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -842,7 +858,6 @@ OmxDataDecoder::DoFlush()
|
||||||
|
|
||||||
// 1. Call OMX command OMX_CommandFlush in Omx TaskQueue.
|
// 1. Call OMX command OMX_CommandFlush in Omx TaskQueue.
|
||||||
// 2. Remove all elements in mMediaRawDatas when flush is completed.
|
// 2. Remove all elements in mMediaRawDatas when flush is completed.
|
||||||
RefPtr<OmxDataDecoder> self = this;
|
|
||||||
mOmxLayer->SendCommand(OMX_CommandFlush, OMX_ALL, nullptr)
|
mOmxLayer->SendCommand(OMX_CommandFlush, OMX_ALL, nullptr)
|
||||||
->Then(mOmxTaskQueue, __func__, this,
|
->Then(mOmxTaskQueue, __func__, this,
|
||||||
&OmxDataDecoder::FlushComplete,
|
&OmxDataDecoder::FlushComplete,
|
||||||
|
|
|
@ -163,7 +163,7 @@ protected:
|
||||||
Atomic<bool> mFlushing;
|
Atomic<bool> mFlushing;
|
||||||
|
|
||||||
// It is accessed in Omx/reader TaskQeueu.
|
// It is accessed in Omx/reader TaskQeueu.
|
||||||
Atomic<bool> mShutdown;
|
Atomic<bool> mShuttingDown;
|
||||||
|
|
||||||
// It is accessed in Omx TaskQeueu.
|
// It is accessed in Omx TaskQeueu.
|
||||||
bool mCheckingInputExhausted;
|
bool mCheckingInputExhausted;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче