summaryrefslogtreecommitdiffstats
path: root/dom/media/AudioPacketizer.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:34:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:34:50 +0000
commitdef92d1b8e9d373e2f6f27c366d578d97d8960c6 (patch)
tree2ef34b9ad8bb9a9220e05d60352558b15f513894 /dom/media/AudioPacketizer.h
parentAdding debian version 125.0.3-1. (diff)
downloadfirefox-def92d1b8e9d373e2f6f27c366d578d97d8960c6.tar.xz
firefox-def92d1b8e9d373e2f6f27c366d578d97d8960c6.zip
Merging upstream version 126.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
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() {