Bug 884654 - Fix deadlock come from OmxDecoder::statusChanged(). r=doublec

This commit is contained in:
Sotaro Ikeda 2013-06-26 09:36:22 -04:00
parent e0b09909b4
commit e6911a901b
2 changed files with 28 additions and 8 deletions

View File

@ -8,6 +8,7 @@
#include "base/basictypes.h"
#include <cutils/properties.h>
#include <stagefright/foundation/ADebug.h>
#include <stagefright/foundation/AMessage.h>
#include <stagefright/MediaExtractor.h>
#include <stagefright/MetaData.h>
@ -174,8 +175,10 @@ OmxDecoder::~OmxDecoder()
void OmxDecoder::statusChanged()
{
mozilla::ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
mDecoder->GetReentrantMonitor().NotifyAll();
sp<AMessage> notify =
new AMessage(kNotifyStatusChanged, mReflector->id());
// post AMessage to OmxDecoder via ALooper.
notify->post();
}
static sp<IOMX> sOMX = nullptr;
@ -765,12 +768,28 @@ void OmxDecoder::Pause()
// Called on ALooper thread.
void OmxDecoder::onMessageReceived(const sp<AMessage> &msg)
{
Mutex::Autolock autoLock(mSeekLock);
switch (msg->what()) {
case kNotifyPostReleaseVideoBuffer:
{
Mutex::Autolock autoLock(mSeekLock);
// Free pending video buffers when OmxDecoder is not seeking video.
// If OmxDecoder is seeking video, the buffers are freed on seek exit.
if (!mIsVideoSeeking) {
ReleaseAllPendingVideoBuffersLocked();
}
break;
}
// Free pending video buffers when OmxDecoder is not seeking video.
// If OmxDecoder is in seeking video, the buffers are freed on seek exit.
if (mIsVideoSeeking != true) {
ReleaseAllPendingVideoBuffersLocked();
case kNotifyStatusChanged:
{
mozilla::ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
mDecoder->GetReentrantMonitor().NotifyAll();
break;
}
default:
TRESPASS();
break;
}
}

View File

@ -86,7 +86,8 @@ class OmxDecoder : public OMXCodecProxy::EventListener {
};
enum {
kNotifyPostReleaseVideoBuffer = 'noti'
kNotifyPostReleaseVideoBuffer = 'noti',
kNotifyStatusChanged = 'stat'
};
AbstractMediaDecoder *mDecoder;