Bug 1331869 - Initialize new field of cubeb_stream_params. r=kinetik,padenot
authorAlex Chronopoulos <achronop@gmail.com>
Fri, 20 Jan 2017 16:54:00 +0200
changeset 377590 2d93fb71eb88ab0ef03943f883ccbff284db9fc2
parent 377589 056197b55d495037138db1507583816efd574d87
child 377591 1658b20cb69c92497cceb6254c2f63de08faff12
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskinetik, padenot
bugs1331869
milestone53.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 1331869 - Initialize new field of cubeb_stream_params. r=kinetik,padenot MozReview-Commit-ID: KZ08mckJX44
dom/media/AudioStream.cpp
dom/media/GraphDriver.cpp
--- a/dom/media/AudioStream.cpp
+++ b/dom/media/AudioStream.cpp
@@ -349,16 +349,21 @@ AudioStream::Init(uint32_t aNumChannels,
 
   cubeb* cubebContext = CubebUtils::GetCubebContext();
   if (!cubebContext) {
     NS_WARNING("Can't get cubeb context!");
     CubebUtils::ReportCubebStreamInitFailure(true);
     return NS_ERROR_DOM_MEDIA_CUBEB_INITIALIZATION_ERR;
   }
 
+  cubeb_channel_layout layout;
+  int r = cubeb_get_preferred_channel_layout(cubebContext, &layout);
+  MOZ_ASSERT(r == CUBEB_OK || r == CUBEB_ERROR_NOT_SUPPORTED);
+  params.layout = (r == CUBEB_OK) ? layout : CUBEB_LAYOUT_UNDEFINED;
+
   return OpenCubeb(cubebContext, params, startTime, CubebUtils::GetFirstStream());
 }
 
 nsresult
 AudioStream::OpenCubeb(cubeb* aContext, cubeb_stream_params& aParams,
                        TimeStamp aStartTime, bool aIsFirst)
 {
   MOZ_ASSERT(aContext);
--- a/dom/media/GraphDriver.cpp
+++ b/dom/media/GraphDriver.cpp
@@ -634,16 +634,21 @@ AudioCallbackDriver::Init()
 
   output.channels = mGraphImpl->AudioChannelCount();
   if (AUDIO_OUTPUT_FORMAT == AUDIO_FORMAT_S16) {
     output.format = CUBEB_SAMPLE_S16NE;
   } else {
     output.format = CUBEB_SAMPLE_FLOAT32NE;
   }
 
+  cubeb_channel_layout layout;
+  int r = cubeb_get_preferred_channel_layout(cubebContext, &layout);
+  MOZ_ASSERT(r == CUBEB_OK || r == CUBEB_ERROR_NOT_SUPPORTED);
+  output.layout = (r == CUBEB_OK) ? layout : CUBEB_LAYOUT_UNDEFINED;
+
   Maybe<uint32_t> latencyPref = CubebUtils::GetCubebMSGLatencyInFrames();
   if (latencyPref) {
     latency_frames = latencyPref.value();
   } else {
     if (cubeb_get_min_latency(cubebContext, output, &latency_frames) != CUBEB_OK) {
       NS_WARNING("Could not get minimal latency from cubeb.");
       return false;
     }
@@ -653,16 +658,17 @@ AudioCallbackDriver::Init()
   // MediaStreamGraphs, cap the minimal latency to 512 frames int this case.
   if (IsMacbookOrMacbookAir()) {
     latency_frames = std::max((uint32_t) 512, latency_frames);
   }
 
 
   input = output;
   input.channels = mInputChannels; // change to support optional stereo capture
+  input.layout = CUBEB_LAYOUT_MONO;
 
   cubeb_stream* stream = nullptr;
   CubebUtils::AudioDeviceID input_id = nullptr, output_id = nullptr;
   // We have to translate the deviceID values to cubeb devid's since those can be
   // freed whenever enumerate is called.
   {
 #ifdef MOZ_WEBRTC
     StaticMutexAutoLock lock(AudioInputCubeb::Mutex());