Bug 1265794: P1. Ensure we can always fit a complete audio frame in an audio buffer. r?rillian
MozReview-Commit-ID: 7oF2Yp1ZQIG
--- a/dom/media/AudioCompactor.h
+++ b/dom/media/AudioCompactor.h
@@ -44,17 +44,17 @@ public:
uint32_t aFrames, uint32_t aChannels, CopyFunc aCopyFunc)
{
// If we are losing more than a reasonable amount to padding, try to chunk
// the data.
size_t maxSlop = AudioDataSize(aFrames, aChannels) / MAX_SLOP_DIVISOR;
while (aFrames > 0) {
uint32_t samples = GetChunkSamples(aFrames, aChannels, maxSlop);
- if (aFrames * aChannels > mSamplesPadding) {
+ if (samples / aChannels > mSamplesPadding / aChannels + 1) {
samples -= mSamplesPadding;
}
AlignedAudioBuffer buffer(samples);
if (!buffer) {
return false;
}
// Copy audio data to buffer using caller-provided functor.