зеркало из https://github.com/mozilla/gecko-dev.git
Bug 889238 - Add error handling to OMXCodecProxy. r=doublec
This commit is contained in:
Родитель
29c6905220
Коммит
c3d49a4e85
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include <binder/IPCThreadState.h>
|
||||
#include <cutils/properties.h>
|
||||
#include <stagefright/foundation/ADebug.h>
|
||||
#include <stagefright/MetaData.h>
|
||||
#include <stagefright/OMXCodec.h>
|
||||
#include <utils/Log.h>
|
||||
|
@ -65,6 +66,8 @@ OMXCodecProxy::OMXCodecProxy(
|
|||
|
||||
OMXCodecProxy::~OMXCodecProxy()
|
||||
{
|
||||
mState = MediaResourceManagerClient::CLIENT_STATE_SHUTDOWN;
|
||||
|
||||
if (mOMXCodec.get()) {
|
||||
wp<MediaSource> tmp = mOMXCodec;
|
||||
mOMXCodec.clear();
|
||||
|
@ -142,9 +145,14 @@ void OMXCodecProxy::statusChanged(int event)
|
|||
}
|
||||
|
||||
mState = (MediaResourceManagerClient::State) event;
|
||||
if (mState != MediaResourceManagerClient::CLIENT_STATE_RESOURCE_ASSIGNED) {
|
||||
return;
|
||||
}
|
||||
|
||||
const char *mime;
|
||||
if (!mSrcMeta->findCString(kKeyMIMEType, &mime)) {
|
||||
mState = MediaResourceManagerClient::CLIENT_STATE_SHUTDOWN;
|
||||
notifyStatusChangedLocked();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -172,6 +180,7 @@ void OMXCodecProxy::statusChanged(int event)
|
|||
width * height <= maxWidth * maxHeight)) {
|
||||
printf_stderr("Failed to get video size, or it was too large for HW decoder (<w=%d, h=%d> but <maxW=%d, maxH=%d>)",
|
||||
width, height, maxWidth, maxHeight);
|
||||
mOMXCodec.clear();
|
||||
mState = MediaResourceManagerClient::CLIENT_STATE_SHUTDOWN;
|
||||
notifyStatusChangedLocked();
|
||||
return;
|
||||
|
@ -179,6 +188,7 @@ void OMXCodecProxy::statusChanged(int event)
|
|||
|
||||
if (mOMXCodec->start() != OK) {
|
||||
NS_WARNING("Couldn't start OMX video source");
|
||||
mOMXCodec.clear();
|
||||
mState = MediaResourceManagerClient::CLIENT_STATE_SHUTDOWN;
|
||||
notifyStatusChangedLocked();
|
||||
return;
|
||||
|
@ -191,9 +201,10 @@ status_t OMXCodecProxy::start(MetaData *params)
|
|||
{
|
||||
Mutex::Autolock autoLock(mLock);
|
||||
|
||||
if (!mOMXCodec.get()) {
|
||||
if (mState != MediaResourceManagerClient::CLIENT_STATE_RESOURCE_ASSIGNED) {
|
||||
return NO_INIT;
|
||||
}
|
||||
CHECK(mOMXCodec.get() != NULL);
|
||||
return mOMXCodec->start();
|
||||
}
|
||||
|
||||
|
@ -201,9 +212,10 @@ status_t OMXCodecProxy::stop()
|
|||
{
|
||||
Mutex::Autolock autoLock(mLock);
|
||||
|
||||
if (!mOMXCodec.get()) {
|
||||
if (mState != MediaResourceManagerClient::CLIENT_STATE_RESOURCE_ASSIGNED) {
|
||||
return NO_INIT;
|
||||
}
|
||||
CHECK(mOMXCodec.get() != NULL);
|
||||
return mOMXCodec->stop();
|
||||
}
|
||||
|
||||
|
@ -211,10 +223,11 @@ sp<MetaData> OMXCodecProxy::getFormat()
|
|||
{
|
||||
Mutex::Autolock autoLock(mLock);
|
||||
|
||||
if (!mOMXCodec.get()) {
|
||||
sp<MetaData> meta = new MetaData;
|
||||
if (mState != MediaResourceManagerClient::CLIENT_STATE_RESOURCE_ASSIGNED) {
|
||||
sp<MetaData> meta = new MetaData;
|
||||
return meta;
|
||||
}
|
||||
CHECK(mOMXCodec.get() != NULL);
|
||||
return mOMXCodec->getFormat();
|
||||
}
|
||||
|
||||
|
@ -222,9 +235,10 @@ status_t OMXCodecProxy::read(MediaBuffer **buffer, const ReadOptions *options)
|
|||
{
|
||||
Mutex::Autolock autoLock(mLock);
|
||||
|
||||
if (!mOMXCodec.get()) {
|
||||
if (mState != MediaResourceManagerClient::CLIENT_STATE_RESOURCE_ASSIGNED) {
|
||||
return NO_INIT;
|
||||
}
|
||||
CHECK(mOMXCodec.get() != NULL);
|
||||
return mOMXCodec->read(buffer, options);
|
||||
}
|
||||
|
||||
|
@ -232,9 +246,10 @@ status_t OMXCodecProxy::pause()
|
|||
{
|
||||
Mutex::Autolock autoLock(mLock);
|
||||
|
||||
if (!mOMXCodec.get()) {
|
||||
if (mState != MediaResourceManagerClient::CLIENT_STATE_RESOURCE_ASSIGNED) {
|
||||
return NO_INIT;
|
||||
}
|
||||
CHECK(mOMXCodec.get() != NULL);
|
||||
return mOMXCodec->pause();
|
||||
}
|
||||
|
||||
|
|
|
@ -408,6 +408,7 @@ bool OmxDecoder::AllocateMediaResources()
|
|||
}
|
||||
if (mAudioSource->start() != OK) {
|
||||
NS_WARNING("Couldn't start OMX audio source");
|
||||
mAudioSource.clear();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче