Bug 1432779 - P7. Use typedef rather than actual type. r?padenot draft
authorJean-Yves Avenard <jyavenard@mozilla.com>
Tue, 06 Mar 2018 17:13:31 +0100
changeset 768204 082ddfa280dd1acac8de11615ad2c01b4692dffa
parent 768203 92eb5678e4796f96471648a515eb0c540449040f
child 768205 328e8710f8482c487800b8fcb07868fa95ee8932
push id102819
push userbmo:jyavenard@mozilla.com
push dateThu, 15 Mar 2018 19:46:59 +0000
reviewerspadenot
bugs1432779
milestone61.0a1
Bug 1432779 - P7. Use typedef rather than actual type. r?padenot this improve readability. MozReview-Commit-ID: IYfrLMZ5djX
dom/media/AudioStream.cpp
dom/media/AudioStream.h
dom/media/mediasink/AudioSink.cpp
--- a/dom/media/AudioStream.cpp
+++ b/dom/media/AudioStream.cpp
@@ -330,30 +330,32 @@ struct ToCubebFormat<AUDIO_FORMAT_S16> {
 template <typename Function, typename... Args>
 int AudioStream::InvokeCubeb(Function aFunction, Args&&... aArgs)
 {
   MonitorAutoUnlock mon(mMonitor);
   return aFunction(mCubebStream.get(), Forward<Args>(aArgs)...);
 }
 
 nsresult
-AudioStream::Init(uint32_t aNumChannels, uint32_t aChannelMap, uint32_t aRate)
+AudioStream::Init(uint32_t aNumChannels,
+                  AudioConfig::ChannelLayout::ChannelMap aChannelMap,
+                  uint32_t aRate)
 {
   auto startTime = TimeStamp::Now();
 
   LOG("%s channels: %d, rate: %d", __FUNCTION__, aNumChannels, aRate);
   mChannels = aNumChannels;
   mOutChannels = aNumChannels;
 
   mDumpFile = OpenDumpFile(aNumChannels, aRate);
 
   cubeb_stream_params params;
   params.rate = aRate;
   params.channels = mOutChannels;
-  params.layout = CUBEB_LAYOUT_UNDEFINED;
+  params.layout = static_cast<uint32_t>(aChannelMap);
   params.format = ToCubebFormat<AUDIO_OUTPUT_FORMAT>::value;
   params.prefs = CUBEB_STREAM_PREF_NONE;
 
   mAudioClock.Init(aRate);
 
   cubeb* cubebContext = CubebUtils::GetCubebContext();
   if (!cubebContext) {
     LOGE("Can't get cubeb context!");
--- a/dom/media/AudioStream.h
+++ b/dom/media/AudioStream.h
@@ -2,24 +2,25 @@
 /* vim:set ts=2 sw=2 sts=2 et cindent: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 #if !defined(AudioStream_h_)
 #define AudioStream_h_
 
 #include "AudioSampleFormat.h"
-#include "nsAutoPtr.h"
-#include "nsCOMPtr.h"
-#include "nsThreadUtils.h"
+#include "CubebUtils.h"
+#include "MediaInfo.h"
 #include "mozilla/Monitor.h"
 #include "mozilla/RefPtr.h"
 #include "mozilla/TimeStamp.h"
 #include "mozilla/UniquePtr.h"
-#include "CubebUtils.h"
+#include "nsAutoPtr.h"
+#include "nsCOMPtr.h"
+#include "nsThreadUtils.h"
 #include "soundtouch/SoundTouchFactory.h"
 
 #if defined(XP_WIN)
 #include "mozilla/audio/AudioNotificationReceiver.h"
 #endif
 
 namespace mozilla {
 
@@ -192,17 +193,19 @@ public:
   };
 
   explicit AudioStream(DataSource& aSource);
 
   // Initialize the audio stream. aNumChannels is the number of audio
   // channels (1 for mono, 2 for stereo, etc), aChannelMap is the indicator for
   // channel layout(mono, stereo, 5.1 or 7.1 ) and aRate is the sample rate
   // (22050Hz, 44100Hz, etc).
-  nsresult Init(uint32_t aNumChannels, uint32_t aChannelMap, uint32_t aRate);
+  nsresult Init(uint32_t aNumChannels,
+                AudioConfig::ChannelLayout::ChannelMap aChannelMap,
+                uint32_t aRate);
 
   // Closes the stream. All future use of the stream is an error.
   void Shutdown();
 
   void Reset();
 
   // Set the current volume of the audio playback. This is a value from
   // 0 (meaning muted) to 1 (meaning full volume).  Thread-safe.
--- a/dom/media/mediasink/AudioSink.cpp
+++ b/dom/media/mediasink/AudioSink.cpp
@@ -190,19 +190,19 @@ AudioSink::SetPlaying(bool aPlaying)
 }
 
 nsresult
 AudioSink::InitializeAudioStream(const PlaybackParams& aParams)
 {
   mAudioStream = new AudioStream(*this);
   // When AudioQueue is empty, there is no way to know the channel layout of
   // the coming audio data, so we use the predefined channel map instead.
-  uint32_t channelMap = mConverter
-                        ? mConverter->OutputConfig().Layout().Map()
-                        : AudioConfig::ChannelLayout(mOutputChannels).Map();
+  AudioConfig::ChannelLayout::ChannelMap channelMap =
+    mConverter ? mConverter->OutputConfig().Layout().Map()
+               : AudioConfig::ChannelLayout(mOutputChannels).Map();
   // The layout map used here is already processed by mConverter with
   // mOutputChannels into SMPTE format, so there is no need to worry if
   // MediaPrefs::MonoAudio() or MediaPrefs::AudioSinkForceStereo() is applied.
   nsresult rv = mAudioStream->Init(mOutputChannels, channelMap, mOutputRate);
   if (NS_FAILED(rv)) {
     mAudioStream->Shutdown();
     mAudioStream = nullptr;
     return rv;