Merge "Camera2: Fix metering/focusing region coordinates, minor bugs" into jb-mr1-dev
diff --git a/include/media/stagefright/OMXCodec.h b/include/media/stagefright/OMXCodec.h
index bb9e595..e6739ae 100644
--- a/include/media/stagefright/OMXCodec.h
+++ b/include/media/stagefright/OMXCodec.h
@@ -354,6 +354,8 @@
const void *data, size_t size,
unsigned *profile, unsigned *level);
+ status_t stopOmxComponent_l();
+
OMXCodec(const OMXCodec &);
OMXCodec &operator=(const OMXCodec &);
};
diff --git a/media/libmediaplayerservice/MediaPlayerService.cpp b/media/libmediaplayerservice/MediaPlayerService.cpp
index 58e4723..6346363 100644
--- a/media/libmediaplayerservice/MediaPlayerService.cpp
+++ b/media/libmediaplayerservice/MediaPlayerService.cpp
@@ -1042,9 +1042,14 @@
void* cookie, int msg, int ext1, int ext2, const Parcel *obj)
{
Client* client = static_cast<Client*>(cookie);
+ if (client == NULL) {
+ return;
+ }
+ sp<IMediaPlayerClient> c;
{
Mutex::Autolock l(client->mLock);
+ c = client->mClient;
if (msg == MEDIA_PLAYBACK_COMPLETE && client->mNextClient != NULL) {
if (client->mAudioOutput != NULL)
client->mAudioOutput->switchToNextOutput();
@@ -1065,8 +1070,11 @@
// also access mMetadataUpdated and clears it.
client->addNewMetadataUpdate(metadata_type);
}
- ALOGV("[%d] notify (%p, %d, %d, %d)", client->mConnId, cookie, msg, ext1, ext2);
- client->mClient->notify(msg, ext1, ext2, obj);
+
+ if (c != NULL) {
+ ALOGV("[%d] notify (%p, %d, %d, %d)", client->mConnId, cookie, msg, ext1, ext2);
+ c->notify(msg, ext1, ext2, obj);
+ }
}
diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp
index 5615d0f..d0e306c 100755
--- a/media/libstagefright/OMXCodec.cpp
+++ b/media/libstagefright/OMXCodec.cpp
@@ -3621,7 +3621,11 @@
}
params->setInt32(kKeyNumBuffers, mPortBuffers[kPortIndexInput].size());
- return mSource->start(params.get());
+ err = mSource->start(params.get());
+ if (err != OK) {
+ stopOmxComponent_l();
+ }
+ return err;
}
// Decoder case
@@ -3633,8 +3637,16 @@
status_t OMXCodec::stop() {
CODEC_LOGV("stop mState=%d", mState);
-
Mutex::Autolock autoLock(mLock);
+ status_t err = stopOmxComponent_l();
+ mSource->stop();
+
+ CODEC_LOGV("stopped in state %d", mState);
+ return err;
+}
+
+status_t OMXCodec::stopOmxComponent_l() {
+ CODEC_LOGV("stopOmxComponent_l mState=%d", mState);
while (isIntermediateState(mState)) {
mAsyncCompletion.wait(mLock);
@@ -3732,10 +3744,6 @@
mLeftOverBuffer = NULL;
}
- mSource->stop();
-
- CODEC_LOGV("stopped in state %d", mState);
-
return OK;
}