Bug 848954 - Part 16 - Make AudioCallbackDriver respect the AudioChannelType. r=roc

This commit is contained in:
Paul Adenot 2014-08-26 17:02:08 +02:00
Родитель 4dffa09424
Коммит 2dc4962f29
5 изменённых файлов: 18 добавлений и 11 удалений

Просмотреть файл

@ -461,8 +461,9 @@ AsyncCubebTask::Run()
}
AudioCallbackDriver::AudioCallbackDriver(MediaStreamGraphImpl* aGraphImpl, dom::AudioChannel aChannel)
: GraphDriver(aGraphImpl),
mStarted(false)
: GraphDriver(aGraphImpl)
, mStarted(false)
, mAudioChannel(aChannel)
{
}
@ -482,15 +483,16 @@ AudioCallbackDriver::Init()
#if defined(__ANDROID__)
#if defined(MOZ_B2G)
params.stream_type = CubebUtils::ConvertChannelToCubebType(aChannels);
params.stream_type = CubebUtils::ConvertChannelToCubebType(mAudioChannel);
#else
params.stream_type = CUBEB_STREAM_TYPE_MUSIC;
#endif
if (params.stream_type == CUBEB_STREAM_TYPE_MAX) {
NS_WARNING("Bad stream type");
return;
}
#else
(void)mAudioChannel;
#endif
params.channels = mGraphImpl->AudioChannelCount();

Просмотреть файл

@ -2641,7 +2641,8 @@ ProcessedMediaStream::DestroyImpl()
MediaStreamGraphImpl::MediaStreamGraphImpl(bool aRealtime,
TrackRate aSampleRate,
DOMMediaStream::TrackTypeHints aHint= DOMMediaStream::HINT_CONTENTS_UNKNOWN)
DOMMediaStream::TrackTypeHints aHint= DOMMediaStream::HINT_CONTENTS_UNKNOWN,
dom::AudioChannel aChannel)
: mDriverHolder(MOZ_THIS_IN_INITIALIZER_LIST())
, mProcessingGraphUpdateIndex(0)
, mPortCount(0)
@ -2674,7 +2675,7 @@ MediaStreamGraphImpl::MediaStreamGraphImpl(bool aRealtime,
if (mRealtime) {
if (aHint & DOMMediaStream::HINT_CONTENTS_AUDIO) {
AudioCallbackDriver* driver = new AudioCallbackDriver(this);
AudioCallbackDriver* driver = new AudioCallbackDriver(this, aChannel);
mDriverHolder.Switch(driver);
mMixer.AddCallback(driver);
} else {
@ -2719,7 +2720,7 @@ MediaStreamGraphShutdownObserver::Observe(nsISupports *aSubject,
}
MediaStreamGraph*
MediaStreamGraph::GetInstance(DOMMediaStream::TrackTypeHints aHint)
MediaStreamGraph::GetInstance(DOMMediaStream::TrackTypeHints aHint, dom::AudioChannel aChannel)
{
NS_ASSERTION(NS_IsMainThread(), "Main thread only");
@ -2731,7 +2732,7 @@ MediaStreamGraph::GetInstance(DOMMediaStream::TrackTypeHints aHint)
CubebUtils::InitPreferredSampleRate();
gGraph = new MediaStreamGraphImpl(true, CubebUtils::PreferredSampleRate(), aHint);
gGraph = new MediaStreamGraphImpl(true, CubebUtils::PreferredSampleRate(), aHint, aChannel);
STREAM_LOG(PR_LOG_DEBUG, ("Starting up MediaStreamGraph %p", gGraph));
}

Просмотреть файл

@ -1129,7 +1129,8 @@ public:
//
// Main thread only
static MediaStreamGraph* GetInstance(DOMMediaStream::TrackTypeHints aHint = DOMMediaStream::HINT_CONTENTS_UNKNOWN);
static MediaStreamGraph* GetInstance(DOMMediaStream::TrackTypeHints aHint = DOMMediaStream::HINT_CONTENTS_UNKNOWN,
dom::AudioChannel aChannel = dom::AudioChannel::Normal);
static MediaStreamGraph* CreateNonRealtimeInstance(TrackRate aSampleRate);
// Idempotent
static void DestroyNonRealtimeInstance(MediaStreamGraph* aGraph);

Просмотреть файл

@ -94,7 +94,10 @@ public:
* output. Those objects currently only support audio, and are used to
* implement OfflineAudioContext. They do not support MediaStream inputs.
*/
explicit MediaStreamGraphImpl(bool aRealtime, TrackRate aSampleRate, DOMMediaStream::TrackTypeHints aHint);
explicit MediaStreamGraphImpl(bool aRealtime,
TrackRate aSampleRate,
DOMMediaStream::TrackTypeHints aHint,
dom::AudioChannel aChannel = dom::AudioChannel::Normal);
/**
* Unregisters memory reporting and deletes this instance. This should be

Просмотреть файл

@ -322,7 +322,7 @@ AudioDestinationNode::AudioDestinationNode(AudioContext* aContext,
{
MediaStreamGraph* graph = aIsOffline ?
MediaStreamGraph::CreateNonRealtimeInstance(aSampleRate) :
MediaStreamGraph::GetInstance(DOMMediaStream::HINT_CONTENTS_AUDIO);
MediaStreamGraph::GetInstance(DOMMediaStream::HINT_CONTENTS_AUDIO, aChannel);
AudioNodeEngine* engine = aIsOffline ?
new OfflineDestinationNodeEngine(this, aNumberOfChannels,
aLength, aSampleRate) :