summaryrefslogtreecommitdiffstats
path: root/dom/media/driftcontrol/AudioResampler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'dom/media/driftcontrol/AudioResampler.cpp')
-rw-r--r--dom/media/driftcontrol/AudioResampler.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/dom/media/driftcontrol/AudioResampler.cpp b/dom/media/driftcontrol/AudioResampler.cpp
index ecef033a5c..1402fae39e 100644
--- a/dom/media/driftcontrol/AudioResampler.cpp
+++ b/dom/media/driftcontrol/AudioResampler.cpp
@@ -5,12 +5,14 @@
#include "AudioResampler.h"
+#include "TimeUnits.h"
+
namespace mozilla {
AudioResampler::AudioResampler(uint32_t aInRate, uint32_t aOutRate,
- media::TimeUnit aPreBufferDuration,
+ uint32_t aInputPreBufferFrameCount,
const PrincipalHandle& aPrincipalHandle)
- : mResampler(aInRate, aOutRate, aPreBufferDuration),
+ : mResampler(aInRate, aOutRate, aInputPreBufferFrameCount),
mOutputChunks(aOutRate / 10, STEREO, aPrincipalHandle) {}
void AudioResampler::AppendInput(const AudioSegment& aInSegment) {
@@ -59,11 +61,11 @@ AudioSegment AudioResampler::Resample(uint32_t aOutFrames, bool* aHasUnderrun) {
return segment;
}
- media::TimeUnit outDuration(aOutFrames, mResampler.GetOutRate());
+ media::TimeUnit outDuration(aOutFrames, mResampler.mOutRate);
mResampler.EnsurePreBuffer(outDuration);
const media::TimeUnit chunkCapacity(mOutputChunks.ChunkCapacity(),
- mResampler.GetOutRate());
+ mResampler.mOutRate);
while (!outDuration.IsZero()) {
MOZ_ASSERT(outDuration.IsPositive());
@@ -71,8 +73,7 @@ AudioSegment AudioResampler::Resample(uint32_t aOutFrames, bool* aHasUnderrun) {
const media::TimeUnit chunkDuration = std::min(outDuration, chunkCapacity);
outDuration -= chunkDuration;
- const uint32_t outFrames =
- chunkDuration.ToTicksAtRate(mResampler.GetOutRate());
+ const uint32_t outFrames = chunkDuration.ToTicksAtRate(mResampler.mOutRate);
for (uint32_t i = 0; i < chunk.ChannelCount(); ++i) {
if (chunk.mBufferFormat == AUDIO_FORMAT_FLOAT32) {
*aHasUnderrun |= mResampler.Resample(
@@ -92,8 +93,8 @@ AudioSegment AudioResampler::Resample(uint32_t aOutFrames, bool* aHasUnderrun) {
return segment;
}
-void AudioResampler::Update(uint32_t aOutRate, uint32_t aChannels) {
- mResampler.UpdateResampler(aOutRate, aChannels);
+void AudioResampler::Update(uint32_t aInRate, uint32_t aChannels) {
+ mResampler.UpdateResampler(aInRate, aChannels);
mOutputChunks.Update(aChannels);
}