Bug 1022705 - allow StopRecordingImpl() to be called from any thread, r=jesup

This commit is contained in:
Mike Habicher 2014-06-10 09:52:22 -04:00
parent 7d954e43ff
commit 0dfa16ea76
3 changed files with 11 additions and 3 deletions

View File

@ -7,7 +7,6 @@ support-files =
systemapp_helper.js
[test_sandbox_permission.html]
skip-if = true # bug 984274 - frequent timeouts
[test_filepicker_path.html]
[test_permission_deny.html]
[test_permission_gum_remember.html]

View File

@ -72,10 +72,11 @@ nsGonkCameraControl::nsGonkCameraControl(uint32_t aCameraId)
, mDeferConfigUpdate(0)
, mMediaProfiles(nullptr)
, mRecorder(nullptr)
, mRecorderMonitor("GonkCameraControl::mRecorder.Monitor")
, mProfileManager(nullptr)
, mRecorderProfile(nullptr)
, mVideoFile(nullptr)
, mReentrantMonitor("GonkCameraControl::OnTakePictureMonitor")
, mReentrantMonitor("GonkCameraControl::OnTakePicture.Monitor")
{
// Constructor runs on the main thread...
DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
@ -952,6 +953,8 @@ nsGonkCameraControl::StartRecordingImpl(DeviceStorageFileDescriptor* aFileDescri
{
MOZ_ASSERT(NS_GetCurrentThread() == mCameraThread);
ReentrantMonitorAutoEnter mon(mRecorderMonitor);
NS_ENSURE_TRUE(mRecorderProfile, NS_ERROR_NOT_INITIALIZED);
NS_ENSURE_FALSE(mRecorder, NS_ERROR_FAILURE);
@ -1041,7 +1044,7 @@ nsGonkCameraControl::StopRecordingImpl()
nsRefPtr<DeviceStorageFile> mFile;
};
MOZ_ASSERT(NS_GetCurrentThread() == mCameraThread);
ReentrantMonitorAutoEnter mon(mRecorderMonitor);
// nothing to do if we have no mRecorder
NS_ENSURE_TRUE(mRecorder, NS_OK);
@ -1570,6 +1573,8 @@ nsGonkCameraControl::SetupRecording(int aFd, int aRotation,
const size_t SIZE = 256;
char buffer[SIZE];
ReentrantMonitorAutoEnter mon(mRecorderMonitor);
mRecorder = new GonkRecorder();
CHECK_SETARG_RETURN(mRecorder->init(), NS_ERROR_FAILURE);

View File

@ -155,6 +155,10 @@ protected:
android::MediaProfiles* mMediaProfiles;
nsRefPtr<android::GonkRecorder> mRecorder;
// Touching mRecorder happens inside this monitor because the destructor
// can run on any thread, and we need to be able to clean up properly if
// GonkCameraControl goes away.
ReentrantMonitor mRecorderMonitor;
// Camcorder profile settings for the desired quality level
nsRefPtr<GonkRecorderProfileManager> mProfileManager;