Bug 1007832 - Reset recording hint when stopping video recording to fix driver state. r=dhylands
authorAndrew Osmond <aosmond@mozilla.com>
Mon, 19 May 2014 11:10:00 +0200
changeset 184035 62d5b643d0ba1dc2d980d76495a32030fe86a74e
parent 184034 4c9fa6efddeec2ee7556111a12db9682c44ebb4d
child 184036 20caba7576251fd2a86a0a9cfbabf309830363ac
push id7192
push usercbook@mozilla.com
push dateWed, 21 May 2014 10:07:00 +0000
treeherderb2g-inbound@b7757cf53850 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdhylands
bugs1007832
milestone32.0a1
Bug 1007832 - Reset recording hint when stopping video recording to fix driver state. r=dhylands
dom/camera/GonkCameraControl.cpp
dom/camera/GonkCameraParameters.cpp
dom/camera/ICameraControl.h
--- a/dom/camera/GonkCameraControl.cpp
+++ b/dom/camera/GonkCameraControl.cpp
@@ -1039,18 +1039,33 @@ nsGonkCameraControl::StopRecordingImpl()
 
   // nothing to do if we have no mRecorder
   NS_ENSURE_TRUE(mRecorder, NS_OK);
 
   mRecorder->stop();
   mRecorder = nullptr;
   OnRecorderStateChange(CameraControlListener::kRecorderStopped);
 
-  if (mAutoFlashModeOverridden) {
-    SetAndPush(CAMERA_PARAM_FLASHMODE, NS_LITERAL_STRING("auto"));
+  {
+    ICameraControlParameterSetAutoEnter set(this);
+
+    // clear the recording hint once stopped because some drivers will solely
+    // check this flag to determine the mode, despite its actual internal state,
+    // thus causing problems when taking pictures
+    nsresult rv = mParams.Set(CAMERA_PARAM_RECORDINGHINT, false);
+    if (NS_FAILED(rv)) {
+      DOM_CAMERA_LOGE("Failed to set recording hint (0x%x)\n", rv);
+    }
+
+    if (mAutoFlashModeOverridden) {
+      rv = mParams.Set(CAMERA_PARAM_FLASHMODE, NS_LITERAL_STRING("auto"));
+      if (NS_FAILED(rv)) {
+        DOM_CAMERA_LOGE("Failed to set flash mode (0x%x)\n", rv);
+      }
+    }
   }
 
   // notify DeviceStorage that the new video file is closed and ready
   return NS_DispatchToMainThread(new RecordingComplete(mVideoFile), NS_DISPATCH_NORMAL);
 }
 
 nsresult
 nsGonkCameraControl::ResumeContinuousFocusImpl()
--- a/dom/camera/GonkCameraParameters.cpp
+++ b/dom/camera/GonkCameraParameters.cpp
@@ -80,16 +80,18 @@ GonkCameraParameters::Parameters::GetTex
       // for those that don't, we use the raw string key.
       return "iso";
     case CAMERA_PARAM_LUMINANCE:
       return "luminance-condition";
     case CAMERA_PARAM_SCENEMODE_HDR_RETURNNORMALPICTURE:
       // Not every platform defines KEY_QC_HDR_NEED_1X;
       // for those that don't, we use the raw string key.
       return "hdr-need-1x";
+    case CAMERA_PARAM_RECORDINGHINT:
+      return KEY_RECORDING_HINT;
 
     case CAMERA_PARAM_SUPPORTED_PREVIEWSIZES:
       return KEY_SUPPORTED_PREVIEW_SIZES;
     case CAMERA_PARAM_SUPPORTED_PICTURESIZES:
       return KEY_SUPPORTED_PICTURE_SIZES;
     case CAMERA_PARAM_SUPPORTED_VIDEOSIZES:
       return KEY_SUPPORTED_VIDEO_SIZES;
     case CAMERA_PARAM_SUPPORTED_PICTUREFORMATS:
--- a/dom/camera/ICameraControl.h
+++ b/dom/camera/ICameraControl.h
@@ -47,16 +47,17 @@ enum {
   CAMERA_PARAM_FOCUSDISTANCEFAR,
   CAMERA_PARAM_EXPOSURECOMPENSATION,
   CAMERA_PARAM_THUMBNAILSIZE,
   CAMERA_PARAM_THUMBNAILQUALITY,
   CAMERA_PARAM_SENSORANGLE,
   CAMERA_PARAM_ISOMODE,
   CAMERA_PARAM_LUMINANCE,
   CAMERA_PARAM_SCENEMODE_HDR_RETURNNORMALPICTURE,
+  CAMERA_PARAM_RECORDINGHINT,
 
   // supported features
   CAMERA_PARAM_SUPPORTED_PREVIEWSIZES,
   CAMERA_PARAM_SUPPORTED_PICTURESIZES,
   CAMERA_PARAM_SUPPORTED_VIDEOSIZES,
   CAMERA_PARAM_SUPPORTED_PICTUREFORMATS,
   CAMERA_PARAM_SUPPORTED_WHITEBALANCES,
   CAMERA_PARAM_SUPPORTED_SCENEMODES,