Bug 1432779 - P7. Use typedef rather than actual type. r?padenot
this improve readability.
MozReview-Commit-ID: IYfrLMZ5djX
--- 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;