Bug 1097849 - Assert sane audio sample rates in MediaEncoder. r=derf

We believe the rate is constrained by the audio driver, but we
should verify this assumption. 8-192 kHz covers all sample rates
in general use for audio data.
This commit is contained in:
Ralph Giles 2014-11-12 11:03:00 -08:00
parent 03d133df88
commit 0dd30629a3
2 changed files with 6 additions and 0 deletions

View File

@ -158,6 +158,9 @@ OpusTrackEncoder::Init(int aChannels, int aSamplingRate)
// let InterleaveTrackData downmix pcm data.
mChannels = aChannels > MAX_CHANNELS ? MAX_CHANNELS : aChannels;
MOZ_ASSERT(aSamplingRate >= 8000 && aSamplingRate <= 192000,
"Unreasonable sample rate for audio data.");
// According to www.opus-codec.org, creating an opus encoder requires the
// sampling rate of source signal be one of 8000, 12000, 16000, 24000, or
// 48000. If this constraint is not satisfied, we resample the input to 48kHz.

View File

@ -54,6 +54,9 @@ VorbisTrackEncoder::Init(int aChannels, int aSamplingRate)
return NS_ERROR_INVALID_ARG;
}
MOZ_ASSERT(aSamplingRate >= 8000 && aSamplingRate <= 192000,
"Unreasonable sample rate for audio data.");
// This monitor is used to wake up other methods that are waiting for encoder
// to be completely initialized.
ReentrantMonitorAutoEnter mon(mReentrantMonitor);