Bug 1454998 - Remove AudioNodeStream::SampleRate(). r=karlt

AudioNodeStream is a subclass of MediaStream, which now exposes a
public const mSampleRate member.

Differential Revision: https://phabricator.services.mozilla.com/D47688

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Andreas Pehrson 2019-10-02 08:17:59 +00:00
Родитель 1bc37d8ea4
Коммит 05d6bfa0c1
11 изменённых файлов: 28 добавлений и 24 удалений

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

@ -1205,7 +1205,7 @@ void MediaStreamGraphImpl::Process() {
for (uint32_t j = i + 1; j < mStreams.Length(); ++j) {
AudioNodeStream* nextStream = mStreams[j]->AsAudioNodeStream();
if (nextStream) {
MOZ_ASSERT(n->SampleRate() == nextStream->SampleRate(),
MOZ_ASSERT(n->mSampleRate == nextStream->mSampleRate,
"All AudioNodeStreams in the graph must have the same "
"sampling rate");
}
@ -1213,7 +1213,7 @@ void MediaStreamGraphImpl::Process() {
#endif
// Since an AudioNodeStream is present, go ahead and
// produce audio block by block for all the rest of the streams.
ProduceDataForStreamsBlockByBlock(i, n->SampleRate());
ProduceDataForStreamsBlockByBlock(i, n->mSampleRate);
doneAllProducing = true;
} else {
ps->ProcessInput(mProcessedTime, mStateComputedTime,

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

@ -97,7 +97,7 @@ class AudioBufferSourceNodeEngine final : public AudioNodeEngine {
switch (aIndex) {
case AudioBufferSourceNode::START:
MOZ_ASSERT(!mStart, "Another START?");
mStart = aParam * mDestination->SampleRate();
mStart = aParam * mDestination->mSampleRate;
// Round to nearest
mBeginProcessing = mStart + 0.5;
break;
@ -439,7 +439,7 @@ class AudioBufferSourceNodeEngine final : public AudioNodeEngine {
float computedPlaybackRate = aPlaybackRate * exp2(aDetune / 1200.f);
// Make sure the playback rate is something our resampler can work with.
int32_t rate = WebAudioUtils::TruncateFloatToInt<int32_t>(
mSource->SampleRate() / computedPlaybackRate);
mSource->mSampleRate / computedPlaybackRate);
return rate ? rate : mBufferSampleRate;
}

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

@ -194,7 +194,7 @@ void AudioNodeStream::SendTimelineEvent(uint32_t aIndex,
const AudioTimelineEvent& aEvent)
: ControlMessage(aStream),
mEvent(aEvent),
mSampleRate(aStream->SampleRate()),
mSampleRate(aStream->mSampleRate),
mIndex(aIndex) {}
void Run() override {
static_cast<AudioNodeStream*>(mStream)->Engine()->RecvTimelineEvent(
@ -222,11 +222,15 @@ void AudioNodeStream::SetBuffer(AudioChunk&& aBuffer) {
GraphImpl()->AppendMessage(MakeUnique<Message>(this, std::move(aBuffer)));
}
void AudioNodeStream::SetReverb(WebCore::Reverb* aReverb, uint32_t aImpulseChannelCount) {
void AudioNodeStream::SetReverb(WebCore::Reverb* aReverb,
uint32_t aImpulseChannelCount) {
class Message final : public ControlMessage {
public:
Message(AudioNodeStream* aStream, WebCore::Reverb* aReverb, uint32_t aImpulseChannelCount)
: ControlMessage(aStream), mReverb(aReverb), mImpulseChanelCount(aImpulseChannelCount) {}
Message(AudioNodeStream* aStream, WebCore::Reverb* aReverb,
uint32_t aImpulseChannelCount)
: ControlMessage(aStream),
mReverb(aReverb),
mImpulseChanelCount(aImpulseChannelCount) {}
void Run() override {
static_cast<AudioNodeStream*>(mStream)->Engine()->SetReverb(
mReverb.forget(), mImpulseChanelCount);
@ -235,7 +239,8 @@ void AudioNodeStream::SetReverb(WebCore::Reverb* aReverb, uint32_t aImpulseChann
uint32_t mImpulseChanelCount;
};
GraphImpl()->AppendMessage(MakeUnique<Message>(this, aReverb, aImpulseChannelCount));
GraphImpl()->AppendMessage(
MakeUnique<Message>(this, aReverb, aImpulseChannelCount));
}
void AudioNodeStream::SetRawArrayData(nsTArray<float>& aData) {

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

@ -153,7 +153,6 @@ class AudioNodeStream : public ProcessedMediaStream {
// Any thread
AudioNodeEngine* Engine() { return mEngine; }
TrackRate SampleRate() const { return mSampleRate; }
size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const override;
size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const override;

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

@ -188,8 +188,8 @@ class BiquadFilterNodeEngine final : public AudioNodeEngine {
input = alignedInputBuffer;
}
}
SetParamsOnBiquad(mBiquads[i], aStream->SampleRate(), mType, freq, q,
gain, detune);
SetParamsOnBiquad(mBiquads[i], aStream->mSampleRate, mType, freq, q, gain,
detune);
mBiquads[i].process(input, aOutput->ChannelFloatsForWrite(i),
aInput.GetDuration());

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

@ -65,7 +65,7 @@ class DelayNodeEngine final : public AudioNodeEngine {
void ProcessBlock(AudioNodeStream* aStream, GraphTime aFrom,
const AudioBlock& aInput, AudioBlock* aOutput,
bool* aFinished) override {
MOZ_ASSERT(aStream->SampleRate() == mDestination->SampleRate());
MOZ_ASSERT(aStream->mSampleRate == mDestination->mSampleRate);
if (!aInput.IsSilentOrSubnormal()) {
if (mLeftOverData <= 0) {
@ -106,7 +106,7 @@ class DelayNodeEngine final : public AudioNodeEngine {
void UpdateOutputBlock(AudioNodeStream* aStream, GraphTime aFrom,
AudioBlock* aOutput, float minDelay) {
float maxDelay = mMaxDelay;
float sampleRate = aStream->SampleRate();
float sampleRate = aStream->mSampleRate;
ChannelInterpretation channelInterpretation =
aStream->GetChannelInterpretation();
if (mDelay.HasSimpleValue()) {

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

@ -41,7 +41,7 @@ class DynamicsCompressorNodeEngine final : public AudioNodeEngine {
mRatio(12.f),
mAttack(0.003f),
mRelease(0.25f),
mCompressor(new DynamicsCompressor(mDestination->SampleRate(), 2)) {}
mCompressor(new DynamicsCompressor(mDestination->mSampleRate, 2)) {}
enum Parameters { THRESHOLD, KNEE, RATIO, ATTACK, RELEASE };
void RecvTimelineEvent(uint32_t aIndex, AudioTimelineEvent& aEvent) override {
@ -82,7 +82,7 @@ class DynamicsCompressorNodeEngine final : public AudioNodeEngine {
const uint32_t channelCount = aInput.ChannelCount();
if (mCompressor->numberOfChannels() != channelCount) {
// Create a new compressor object with a new channel count
mCompressor = new WebCore::DynamicsCompressor(aStream->SampleRate(),
mCompressor = new WebCore::DynamicsCompressor(aStream->mSampleRate,
aInput.ChannelCount());
}

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

@ -131,7 +131,7 @@ class OscillatorNodeEngine final : public AudioNodeEngine {
"PeriodicWave should have sent two channels");
MOZ_ASSERT(aBuffer.mVolume == 1.0f);
mPeriodicWave = WebCore::PeriodicWave::create(
mSource->SampleRate(), aBuffer.ChannelData<float>()[0],
mSource->mSampleRate, aBuffer.ChannelData<float>()[0],
aBuffer.ChannelData<float>()[1], aBuffer.mDuration,
mCustomDisableNormalization);
}
@ -172,7 +172,7 @@ class OscillatorNodeEngine final : public AudioNodeEngine {
}
float finalFrequency = frequency * exp2(detune / 1200.);
float signalPeriod = mSource->SampleRate() / finalFrequency;
float signalPeriod = mSource->mSampleRate / finalFrequency;
mRecomputeParameters = false;
mPhaseIncrement = 2 * M_PI / signalPeriod;

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

@ -244,7 +244,7 @@ class ScriptProcessorNodeEngine final : public AudioNodeEngine {
uint32_t aNumberOfInputChannels)
: AudioNodeEngine(aNode),
mDestination(aDestination->Stream()),
mSharedBuffers(new SharedBuffers(mDestination->SampleRate())),
mSharedBuffers(new SharedBuffers(mDestination->mSampleRate)),
mBufferSize(aBufferSize),
mInputChannelCount(aNumberOfInputChannels),
mInputWriteIndex(0) {}

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

@ -242,19 +242,19 @@ class WaveShaperNodeEngine final : public AudioNodeEngine {
switch (mType) {
case OverSampleType::None:
mResampler.Reset(channelCount, aStream->SampleRate(),
mResampler.Reset(channelCount, aStream->mSampleRate,
OverSampleType::None);
ProcessCurve<1>(inputSamples, outputBuffer);
break;
case OverSampleType::_2x:
mResampler.Reset(channelCount, aStream->SampleRate(),
mResampler.Reset(channelCount, aStream->mSampleRate,
OverSampleType::_2x);
sampleBuffer = mResampler.UpSample(i, inputSamples, 2);
ProcessCurve<2>(sampleBuffer, sampleBuffer);
mResampler.DownSample(i, outputBuffer, 2);
break;
case OverSampleType::_4x:
mResampler.Reset(channelCount, aStream->SampleRate(),
mResampler.Reset(channelCount, aStream->mSampleRate,
OverSampleType::_4x);
sampleBuffer = mResampler.UpSample(i, inputSamples, 4);
ProcessCurve<4>(sampleBuffer, sampleBuffer);

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

@ -23,8 +23,8 @@ void WebAudioUtils::ConvertAudioTimelineEventToTicks(AudioTimelineEvent& aEvent,
AudioNodeStream* aDest) {
aEvent.SetTimeInTicks(
aDest->SecondsToNearestStreamTime(aEvent.Time<double>()));
aEvent.mTimeConstant *= aDest->SampleRate();
aEvent.mDuration *= aDest->SampleRate();
aEvent.mTimeConstant *= aDest->mSampleRate;
aEvent.mDuration *= aDest->mSampleRate;
}
void WebAudioUtils::Shutdown() { WebCore::HRTFDatabaseLoader::shutdown(); }