Bug 725152 - Only use force_stereo_mode pref if it's explicitly set. r=kinetik a=akeybl
authorMatthew Gregan <kinetik@flim.org>
Tue, 20 Mar 2012 12:48:47 +1300
changeset 88603 6c62f6405499d4093d479013deb3c4ae955d240c
parent 88602 1df24b97a06c1129bf499b6c888640488c004188
child 88604 c6c5fbe3eb36310dbec082c7ea11340005e75b86
push id697
push usermgregan@mozilla.com
push dateMon, 19 Mar 2012 23:49:44 +0000
treeherdermozilla-beta@6c62f6405499 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskinetik, akeybl
bugs725152
milestone12.0
Bug 725152 - Only use force_stereo_mode pref if it's explicitly set. r=kinetik a=akeybl
content/media/webm/nsWebMReader.cpp
content/media/webm/nsWebMReader.h
--- a/content/media/webm/nsWebMReader.cpp
+++ b/content/media/webm/nsWebMReader.cpp
@@ -133,21 +133,25 @@ nsWebMReader::nsWebMReader(nsBuiltinDeco
   mPacketCount(0),
   mChannels(0),
   mVideoTrack(0),
   mAudioTrack(0),
   mAudioStartUsec(-1),
   mAudioFrames(0),
   mHasVideo(false),
   mHasAudio(false),
-  mForceStereoMode(0)
+  mForceStereoMode(0),
+  mStereoModeForced(false)
 {
   MOZ_COUNT_CTOR(nsWebMReader);
 
-  Preferences::GetInt("media.webm.force_stereo_mode", &mForceStereoMode);
+  mStereoModeForced =
+    NS_SUCCEEDED(Preferences::GetInt(
+          "media.webm.force_stereo_mode",
+          &mForceStereoMode));
 }
 
 nsWebMReader::~nsWebMReader()
 {
   Cleanup();
 
   mVideoPackets.Reset();
   mAudioPackets.Reset();
@@ -304,31 +308,34 @@ nsresult nsWebMReader::ReadMetadata(nsVi
       case NESTEGG_VIDEO_STEREO_TOP_BOTTOM:
         mInfo.mStereoMode = STEREO_MODE_TOP_BOTTOM;
         break;
       case NESTEGG_VIDEO_STEREO_RIGHT_LEFT:
         mInfo.mStereoMode = STEREO_MODE_RIGHT_LEFT;
         break;
       }
 
-      switch (mForceStereoMode) {
-      case 1:
-        mInfo.mStereoMode = STEREO_MODE_LEFT_RIGHT;
-        break;
-      case 2:
-        mInfo.mStereoMode = STEREO_MODE_RIGHT_LEFT;
-        break;
-      case 3:
-        mInfo.mStereoMode = STEREO_MODE_TOP_BOTTOM;
-        break;
-      case 4:
-        mInfo.mStereoMode = STEREO_MODE_BOTTOM_TOP;
-        break;
-      default:
-        mInfo.mStereoMode = STEREO_MODE_MONO;
+      // Switch only when stereo mode is explicitly set 
+      if (mStereoModeForced) {
+        switch (mForceStereoMode) {
+        case 1:
+          mInfo.mStereoMode = STEREO_MODE_LEFT_RIGHT;
+          break;
+        case 2:
+          mInfo.mStereoMode = STEREO_MODE_RIGHT_LEFT;
+          break;
+        case 3:
+          mInfo.mStereoMode = STEREO_MODE_TOP_BOTTOM;
+          break;
+        case 4:
+          mInfo.mStereoMode = STEREO_MODE_BOTTOM_TOP;
+          break;
+        default:
+          mInfo.mStereoMode = STEREO_MODE_MONO;
+        }
       }
     }
     else if (!mHasAudio && type == NESTEGG_TRACK_AUDIO) {
       nestegg_audio_params params;
       r = nestegg_track_audio_params(mContext, track, &params);
       if (r == -1) {
         Cleanup();
         return NS_ERROR_FAILURE;
--- a/content/media/webm/nsWebMReader.h
+++ b/content/media/webm/nsWebMReader.h
@@ -239,11 +239,15 @@ private:
 
   // Booleans to indicate if we have audio and/or video data
   bool mHasVideo;
   bool mHasAudio;
 
   // Value of the "media.webm.force_stereo_mode" pref, which we need off the
   // main thread.
   PRInt32 mForceStereoMode;
+
+  // Boolean which is set to true when the "media.webm.force_stereo_mode" is
+  // explicitly set.
+  bool mStereoModeForced;
 };
 
 #endif