зеркало из https://github.com/mozilla/gecko-dev.git
Bug 984498: To plumb audiochannel type from AudioContext to MediaStreamGraph r=roc
This commit is contained in:
Родитель
ccbab3da7e
Коммит
59feac455c
|
@ -849,7 +849,7 @@ MediaStreamGraphImpl::CreateOrDestroyAudioStreams(GraphTime aAudioOutputStartTim
|
|||
// match the system's ideal channel configuration.
|
||||
// NOTE: we presume this is either fast or async-under-the-covers
|
||||
audioOutputStream->mStream->Init(2, mSampleRate,
|
||||
AudioChannel::Normal,
|
||||
aStream->mAudioChannelType,
|
||||
AudioStream::LowLatency);
|
||||
audioOutputStream->mTrackID = tracks->GetID();
|
||||
|
||||
|
@ -1784,6 +1784,7 @@ MediaStream::MediaStream(DOMMediaStream* aWrapper)
|
|||
, mMainThreadFinished(false)
|
||||
, mMainThreadDestroyed(false)
|
||||
, mGraph(nullptr)
|
||||
, mAudioChannelType(dom::AudioChannel::Normal)
|
||||
{
|
||||
MOZ_COUNT_CTOR(MediaStream);
|
||||
// aWrapper should not already be connected to a MediaStream! It needs
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "nsAutoRef.h"
|
||||
#include "speex/speex_resampler.h"
|
||||
#include "AudioMixer.h"
|
||||
#include "mozilla/dom/AudioChannelBinding.h"
|
||||
|
||||
class nsIRunnable;
|
||||
|
||||
|
@ -524,6 +525,8 @@ public:
|
|||
virtual size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const;
|
||||
virtual size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const;
|
||||
|
||||
void SetAudioChannelType(dom::AudioChannel aType) { mAudioChannelType = aType; }
|
||||
|
||||
protected:
|
||||
virtual void AdvanceTimeVaryingValuesToCurrentTime(GraphTime aCurrentTime, GraphTime aBlockedTime)
|
||||
{
|
||||
|
@ -650,6 +653,8 @@ protected:
|
|||
|
||||
// Our media stream graph
|
||||
MediaStreamGraphImpl* mGraph;
|
||||
|
||||
dom::AudioChannel mAudioChannelType;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -77,6 +77,7 @@ static float GetSampleRateForAudioContext(bool aIsOffline, float aSampleRate)
|
|||
|
||||
AudioContext::AudioContext(nsPIDOMWindow* aWindow,
|
||||
bool aIsOffline,
|
||||
AudioChannel aChannel,
|
||||
uint32_t aNumberOfChannels,
|
||||
uint32_t aLength,
|
||||
float aSampleRate)
|
||||
|
@ -92,8 +93,8 @@ AudioContext::AudioContext(nsPIDOMWindow* aWindow,
|
|||
|
||||
// Note: AudioDestinationNode needs an AudioContext that must already be
|
||||
// bound to the window.
|
||||
mDestination = new AudioDestinationNode(this, aIsOffline, aNumberOfChannels,
|
||||
aLength, aSampleRate);
|
||||
mDestination = new AudioDestinationNode(this, aIsOffline, aChannel,
|
||||
aNumberOfChannels, aLength, aSampleRate);
|
||||
// We skip calling SetIsOnlyNodeForContext during mDestination's constructor,
|
||||
// because we can only call SetIsOnlyNodeForContext after mDestination has
|
||||
// been set up.
|
||||
|
@ -137,6 +138,24 @@ AudioContext::Constructor(const GlobalObject& aGlobal,
|
|||
return object.forget();
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<AudioContext>
|
||||
AudioContext::Constructor(const GlobalObject& aGlobal,
|
||||
AudioChannel aChannel,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
if (!window) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsRefPtr<AudioContext> object = new AudioContext(window, false, aChannel);
|
||||
|
||||
RegisterWeakMemoryReporter(object);
|
||||
|
||||
return object.forget();
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<AudioContext>
|
||||
AudioContext::Constructor(const GlobalObject& aGlobal,
|
||||
uint32_t aNumberOfChannels,
|
||||
|
@ -162,6 +181,7 @@ AudioContext::Constructor(const GlobalObject& aGlobal,
|
|||
|
||||
nsRefPtr<AudioContext> object = new AudioContext(window,
|
||||
true,
|
||||
AudioChannel::Normal,
|
||||
aNumberOfChannels,
|
||||
aLength,
|
||||
aSampleRate);
|
||||
|
|
|
@ -67,6 +67,7 @@ class AudioContext MOZ_FINAL : public DOMEventTargetHelper,
|
|||
{
|
||||
AudioContext(nsPIDOMWindow* aParentWindow,
|
||||
bool aIsOffline,
|
||||
AudioChannel aChannel = AudioChannel::Normal,
|
||||
uint32_t aNumberOfChannels = 0,
|
||||
uint32_t aLength = 0,
|
||||
float aSampleRate = 0.0f);
|
||||
|
@ -95,6 +96,12 @@ public:
|
|||
static already_AddRefed<AudioContext>
|
||||
Constructor(const GlobalObject& aGlobal, ErrorResult& aRv);
|
||||
|
||||
// Constructor for regular AudioContext. A default audio channel is needed.
|
||||
static already_AddRefed<AudioContext>
|
||||
Constructor(const GlobalObject& aGlobal,
|
||||
AudioChannel aChannel,
|
||||
ErrorResult& aRv);
|
||||
|
||||
// Constructor for offline AudioContext
|
||||
static already_AddRefed<AudioContext>
|
||||
Constructor(const GlobalObject& aGlobal,
|
||||
|
|
|
@ -228,6 +228,7 @@ NS_IMPL_RELEASE_INHERITED(AudioDestinationNode, AudioNode)
|
|||
|
||||
AudioDestinationNode::AudioDestinationNode(AudioContext* aContext,
|
||||
bool aIsOffline,
|
||||
AudioChannel aChannel,
|
||||
uint32_t aNumberOfChannels,
|
||||
uint32_t aLength,
|
||||
float aSampleRate)
|
||||
|
@ -252,13 +253,13 @@ AudioDestinationNode::AudioDestinationNode(AudioContext* aContext,
|
|||
static_cast<AudioNodeEngine*>(new DestinationNodeEngine(this));
|
||||
|
||||
mStream = graph->CreateAudioNodeStream(engine, MediaStreamGraph::EXTERNAL_STREAM);
|
||||
mStream->SetAudioChannelType(aChannel);
|
||||
mStream->AddMainThreadListener(this);
|
||||
mStream->AddAudioOutput(&gWebAudioOutputKey);
|
||||
|
||||
AudioChannel channel = AudioChannelService::GetDefaultAudioChannel();
|
||||
if (channel != AudioChannel::Normal) {
|
||||
if (aChannel != AudioChannel::Normal) {
|
||||
ErrorResult rv;
|
||||
SetMozAudioChannelType(channel, rv);
|
||||
SetMozAudioChannelType(aChannel, rv);
|
||||
}
|
||||
|
||||
if (!aIsOffline && UseAudioChannelService()) {
|
||||
|
|
|
@ -30,6 +30,7 @@ public:
|
|||
// whether it's in offline mode.
|
||||
AudioDestinationNode(AudioContext* aContext,
|
||||
bool aIsOffline,
|
||||
AudioChannel aChannel = AudioChannel::Normal,
|
||||
uint32_t aNumberOfChannels = 0,
|
||||
uint32_t aLength = 0,
|
||||
float aSampleRate = 0.0f);
|
||||
|
|
|
@ -66,7 +66,7 @@ function test_preferences(aChannel) {
|
|||
SpecialPowers.pushPermissions(
|
||||
[{ "type": "audio-channel-" + aChannel, "allow": false, "context": document }],
|
||||
function() {
|
||||
var ac = new AudioContext();
|
||||
var ac = new AudioContext(aChannel);
|
||||
ok(ac, "AudioContext created");
|
||||
is(ac.mozAudioChannelType, aChannel, "Default ac channel == '" + aChannel + "'");
|
||||
runTest();
|
||||
|
|
Загрузка…
Ссылка в новой задаче