Bug 928547: Change AudioStream cubeb-dependent logic to handle success cases first, so we can add #ifdef that ends in failure case. r=padenot
authorDaniel Holbert <dholbert@cs.stanford.edu>
Wed, 23 Oct 2013 17:44:13 +0200
changeset 166641 a5bb5255845ad2c2bfce0f146a0c6eedc1bb57cd
parent 166640 b71812b077de5a078af83968fd2f2809017ba19f
child 166642 e3687ede61bd64623ee43e4784a2b56a4a851ddb
push id428
push userbbajaj@mozilla.com
push dateTue, 28 Jan 2014 00:16:25 +0000
treeherdermozilla-release@cd72a7ff3a75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspadenot
bugs928547
milestone27.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 928547: Change AudioStream cubeb-dependent logic to handle success cases first, so we can add #ifdef that ends in failure case. r=padenot
content/media/AudioStream.cpp
--- a/content/media/AudioStream.cpp
+++ b/content/media/AudioStream.cpp
@@ -428,39 +428,44 @@ AudioStream* AudioStream::AllocateStream
 #if defined(MOZ_CUBEB)
   return new BufferedAudioStream();
 #endif
   return nullptr;
 }
 
 int AudioStream::MaxNumberOfChannels()
 {
-  uint32_t maxNumberOfChannels, rv;
-
-  rv = cubeb_get_max_channel_count(GetCubebContext(), &maxNumberOfChannels);
+#if defined(MOZ_CUBEB)
+  uint32_t maxNumberOfChannels;
 
-  if (rv != CUBEB_OK) {
-    return 0;
+  if (cubeb_get_max_channel_count(GetCubebContext(),
+                                  &maxNumberOfChannels) == CUBEB_OK) {
+    return static_cast<int>(maxNumberOfChannels);
   }
+#endif
 
-  return static_cast<int>(maxNumberOfChannels);
+  return 0;
 }
 
 int AudioStream::PreferredSampleRate()
 {
   StaticMutexAutoLock lock(AudioStream::mMutex);
   // Get the preferred samplerate for this platform, or fallback to something
   // sensible if we fail. We cache the value, because this might be accessed
   // often, and the complexity of the function call below depends on the
   // backend used.
   const int fallbackSampleRate = 44100;
   if (mPreferredSampleRate == 0) {
-    if (cubeb_get_preferred_sample_rate(GetCubebContext(), &mPreferredSampleRate) != CUBEB_OK) {
-      mPreferredSampleRate = fallbackSampleRate;
+#if defined(MOZ_CUBEB)
+    if (cubeb_get_preferred_sample_rate(GetCubebContext(),
+                                        &mPreferredSampleRate) == CUBEB_OK) {
+      return mPreferredSampleRate;
     }
+#endif
+    mPreferredSampleRate = fallbackSampleRate;
   }
 
   return mPreferredSampleRate;
 }
 
 static void SetUint16LE(uint8_t* aDest, uint16_t aValue)
 {
   aDest[0] = aValue & 0xFF;