summaryrefslogtreecommitdiffstats
path: root/dom/media/AudioPacketizer.h
diff options
context:
space:
mode:
Diffstat (limited to 'dom/media/AudioPacketizer.h')
-rw-r--r--dom/media/AudioPacketizer.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/dom/media/AudioPacketizer.h b/dom/media/AudioPacketizer.h
index 8df04c0c5c..17579618ea 100644
--- a/dom/media/AudioPacketizer.h
+++ b/dom/media/AudioPacketizer.h
@@ -100,11 +100,15 @@ class AudioPacketizer {
return out;
}
- void Output(OutputType* aOutputBuffer) {
+ // Return the number of actual frames dequeued -- this can be lower than the
+ // packet size when underruning or draining.
+ size_t Output(OutputType* aOutputBuffer) {
uint32_t samplesNeeded = mPacketSize * mChannels;
+ size_t rv = 0;
// Under-run. Pad the end of the buffer with silence.
if (AvailableSamples() < samplesNeeded) {
+ rv = AvailableSamples() / mChannels;
#ifdef LOG_PACKETIZER_UNDERRUN
char buf[256];
snprintf(buf, 256,
@@ -115,6 +119,8 @@ class AudioPacketizer {
uint32_t zeros = samplesNeeded - AvailableSamples();
PodZero(aOutputBuffer + AvailableSamples(), zeros);
samplesNeeded -= zeros;
+ } else {
+ rv = mPacketSize;
}
if (ReadIndex() + samplesNeeded <= mLength) {
ConvertAudioSamples<InputType, OutputType>(mStorage.get() + ReadIndex(),
@@ -128,6 +134,7 @@ class AudioPacketizer {
mStorage.get(), aOutputBuffer + firstPartLength, secondPartLength);
}
mReadIndex += samplesNeeded;
+ return rv;
}
void Clear() {