summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorAndy Hung <hunga@google.com>2015-04-28 19:02:33 -0700
committerAndy Hung <hunga@google.com>2015-04-29 14:10:12 -0700
commit48a31bf3f1c1ed5953a4e64f71cdf528f3a38ee5 (patch)
tree1227f65215a97e0c73a453bb0ffb09ff636ad432 /media
parent1e2a0e6adc3d70879b00e5295c54a74209b71e1b (diff)
downloadframeworks_av-48a31bf3f1c1ed5953a4e64f71cdf528f3a38ee5.zip
frameworks_av-48a31bf3f1c1ed5953a4e64f71cdf528f3a38ee5.tar.gz
frameworks_av-48a31bf3f1c1ed5953a4e64f71cdf528f3a38ee5.tar.bz2
Omx: Return an error if no IOMX is available
Previously caused fatal crash. Bug: 20566134 Change-Id: I9761d043422954615dbe81b301401765146a7283
Diffstat (limited to 'media')
-rw-r--r--media/libstagefright/ACodec.cpp5
-rw-r--r--media/libstagefright/MediaCodec.cpp4
-rw-r--r--media/libstagefright/MediaCodecList.cpp6
-rw-r--r--media/libstagefright/OMXClient.cpp10
4 files changed, 21 insertions, 4 deletions
diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp
index c7df5a0..955d12f 100644
--- a/media/libstagefright/ACodec.cpp
+++ b/media/libstagefright/ACodec.cpp
@@ -4909,7 +4909,10 @@ bool ACodec::UninitializedState::onAllocateComponent(const sp<AMessage> &msg) {
CHECK(mCodec->mNode == 0);
OMXClient client;
- CHECK_EQ(client.connect(), (status_t)OK);
+ if (client.connect() != OK) {
+ mCodec->signalError(OMX_ErrorUndefined, NO_INIT);
+ return false;
+ }
sp<IOMX> omx = client.interface();
diff --git a/media/libstagefright/MediaCodec.cpp b/media/libstagefright/MediaCodec.cpp
index aa0d2e6..8a2dc35 100644
--- a/media/libstagefright/MediaCodec.cpp
+++ b/media/libstagefright/MediaCodec.cpp
@@ -392,6 +392,10 @@ status_t MediaCodec::init(const AString &name, bool nameIsType, bool encoder) {
tmp.erase(tmp.size() - 7, 7);
}
const sp<IMediaCodecList> mcl = MediaCodecList::getInstance();
+ if (mcl == NULL) {
+ mCodec = NULL; // remove the codec.
+ return NO_INIT; // if called from Java should raise IOException
+ }
ssize_t codecIdx = mcl->findCodecByName(tmp.c_str());
if (codecIdx >= 0) {
const sp<MediaCodecInfo> info = mcl->getCodecInfo(codecIdx);
diff --git a/media/libstagefright/MediaCodecList.cpp b/media/libstagefright/MediaCodecList.cpp
index 26798ae..97640a8 100644
--- a/media/libstagefright/MediaCodecList.cpp
+++ b/media/libstagefright/MediaCodecList.cpp
@@ -80,6 +80,10 @@ sp<IMediaCodecList> MediaCodecList::getLocalInstance() {
infos.push_back(gCodecList->getCodecInfo(i));
}
}
+ } else {
+ // failure to initialize may be temporary. retry on next call.
+ delete gCodecList;
+ gCodecList = NULL;
}
}
}
@@ -168,7 +172,7 @@ void MediaCodecList::parseTopLevelXMLFile(const char *codecs_xml, bool ignore_er
OMXClient client;
mInitCheck = client.connect();
if (mInitCheck != OK) {
- return;
+ return; // this may fail if IMediaPlayerService is not available.
}
mOMX = client.interface();
parseXMLFile(codecs_xml);
diff --git a/media/libstagefright/OMXClient.cpp b/media/libstagefright/OMXClient.cpp
index 230c1f7..06a598f 100644
--- a/media/libstagefright/OMXClient.cpp
+++ b/media/libstagefright/OMXClient.cpp
@@ -400,10 +400,16 @@ status_t OMXClient::connect() {
sp<IBinder> binder = sm->getService(String16("media.player"));
sp<IMediaPlayerService> service = interface_cast<IMediaPlayerService>(binder);
- CHECK(service.get() != NULL);
+ if (service.get() == NULL) {
+ ALOGE("Cannot obtain IMediaPlayerService");
+ return NO_INIT;
+ }
mOMX = service->getOMX();
- CHECK(mOMX.get() != NULL);
+ if (mOMX.get() == NULL) {
+ ALOGE("Cannot obtain IOMX");
+ return NO_INIT;
+ }
if (!mOMX->livesLocally(0 /* node */, getpid())) {
ALOGI("Using client-side OMX mux.");