summaryrefslogtreecommitdiffstats
path: root/dom/media/WavDumper.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:35:37 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:35:37 +0000
commita90a5cba08fdf6c0ceb95101c275108a152a3aed (patch)
tree532507288f3defd7f4dcf1af49698bcb76034855 /dom/media/WavDumper.h
parentAdding debian version 126.0.1-1. (diff)
downloadfirefox-a90a5cba08fdf6c0ceb95101c275108a152a3aed.tar.xz
firefox-a90a5cba08fdf6c0ceb95101c275108a152a3aed.zip
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/media/WavDumper.h')
-rw-r--r--dom/media/WavDumper.h15
1 files changed, 12 insertions, 3 deletions
diff --git a/dom/media/WavDumper.h b/dom/media/WavDumper.h
index de4195066a..971fa8a32f 100644
--- a/dom/media/WavDumper.h
+++ b/dom/media/WavDumper.h
@@ -107,13 +107,23 @@ class WavDumper {
if (!mFile) {
return;
}
- WriteDumpFileHelper(aBuffer, aSamples);
+ if (aBuffer) {
+ WriteDumpFileHelper(aBuffer, aSamples);
+ } else {
+ constexpr size_t blockSize = 128;
+ T block[blockSize] = {};
+ for (size_t remaining = aSamples; remaining;) {
+ size_t toWrite = std::min(remaining, blockSize);
+ fwrite(block, sizeof(T), toWrite, mFile);
+ remaining -= toWrite;
+ }
+ }
+ fflush(mFile);
}
private:
void WriteDumpFileHelper(const int16_t* aInput, size_t aSamples) {
mozilla::Unused << fwrite(aInput, sizeof(int16_t), aSamples, mFile);
- fflush(mFile);
}
void WriteDumpFileHelper(const float* aInput, size_t aSamples) {
@@ -127,7 +137,6 @@ class WavDumper {
MOZ_ASSERT(rv);
}
mozilla::Unused << fwrite(buf.Elements(), buf.Length(), 1, mFile);
- fflush(mFile);
}
FILE* mFile = nullptr;