summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorJames Dong <jdong@google.com>2010-11-15 10:38:37 -0800
committerJames Dong <jdong@google.com>2010-11-15 13:14:59 -0800
commitdf7a856d3d7a62049e3d1091cf07e95019da4609 (patch)
tree43c9ce0d78057be9200a6c8bc6697ca62f46e82d /media
parent64f1163084433952766eed31dbd26df420ba6cfb (diff)
downloadframeworks_base-df7a856d3d7a62049e3d1091cf07e95019da4609.zip
frameworks_base-df7a856d3d7a62049e3d1091cf07e95019da4609.tar.gz
frameworks_base-df7a856d3d7a62049e3d1091cf07e95019da4609.tar.bz2
Fixed a race condition where some recording frames may not be released.
When startRecording() is called before setListener(), recording frames are sent right after startRecording(), but there is no listener to release the recording frames. This causes the hang in media server. bug - 3166356 Change-Id: I19366ca682ef9f6b847590c190c30a15ed32b8e4
Diffstat (limited to 'media')
-rw-r--r--media/libstagefright/CameraSource.cpp23
1 files changed, 3 insertions, 20 deletions
diff --git a/media/libstagefright/CameraSource.cpp b/media/libstagefright/CameraSource.cpp
index b8450fb..d9ff723 100644
--- a/media/libstagefright/CameraSource.cpp
+++ b/media/libstagefright/CameraSource.cpp
@@ -495,26 +495,6 @@ status_t CameraSource::init(
mIsMetaDataStoredInVideoBuffers = true;
}
- /*
- * mCamera->startRecording() signals camera hal to make
- * available the video buffers (for instance, allocation
- * of the video buffers may be triggered when camera hal's
- * startRecording() method is called). Making available these
- * video buffers earlier (before calling start()) is critical,
- * if one wants to configure omx video encoders to use these
- * buffers for passing video frame data during video recording
- * without the need to memcpy the video frame data stored
- * in these buffers. Eliminating memcpy for video frame data
- * is crucial in performance for HD quality video recording
- * applications.
- *
- * Based on OMX IL spec, configuring the omx video encoders
- * must occur in loaded state. When start() is called, omx
- * video encoders are already in idle state, which is too
- * late. Thus, we must call mCamera->startRecording() earlier.
- */
- startCameraRecording();
-
IPCThreadState::self()->restoreCallingIdentity(token);
int64_t glitchDurationUs = (1000000LL / mVideoFrameRate);
@@ -565,8 +545,11 @@ status_t CameraSource::start(MetaData *meta) {
mStartTimeUs = startTimeUs;
}
+ // Call setListener first before calling startCameraRecording()
+ // to avoid recording frames being dropped.
int64_t token = IPCThreadState::self()->clearCallingIdentity();
mCamera->setListener(new CameraSourceListener(this));
+ startCameraRecording();
IPCThreadState::self()->restoreCallingIdentity(token);
mStarted = true;