[webkit-changes] [WebKit/WebKit] de609b: AudioSampleBufferCompressor shouldn't buffer 0.1s ...
Jean-Yves Avenard
noreply at github.com
Thu Oct 24 19:19:05 PDT 2024
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: de609bdd72dc763504c546ae0e87662ea8d0667f
https://github.com/WebKit/WebKit/commit/de609bdd72dc763504c546ae0e87662ea8d0667f
Author: Jean-Yves Avenard <jya at apple.com>
Date: 2024-10-24 (Thu, 24 Oct 2024)
Changed paths:
M Source/WebCore/PAL/pal/cf/AudioToolboxSoftLink.cpp
M Source/WebCore/PAL/pal/cf/AudioToolboxSoftLink.h
M Source/WebCore/platform/mediarecorder/cocoa/AudioSampleBufferCompressor.h
M Source/WebCore/platform/mediarecorder/cocoa/AudioSampleBufferCompressor.mm
Log Message:
-----------
AudioSampleBufferCompressor shouldn't buffer 0.1s at all time
https://bugs.webkit.org/show_bug.cgi?id=281958
rdar://138465744
Reviewed by Jer Noble.
Have AudioSampleBufferCompressor always process all available frames and
output them as soon as possible.
When flushing, output all decoded frames, keeping the converter's internal
buffer so that it can continues where it left off.
It was previously possible to fully drain the encoder by calling finish, but
this would set the AudioConverter to EOF and it would no longer encode samples.
The AudioConverter can differentiate final EOF from just having processed all
content by returning a code other than noErr.
Add a drain() method that will output all data available, a method similar to
finish() but will reset the encoder so it can continue to be used.
Resuming will include samples that will get trimmed from the start upon decoding due to codec delay.
Simplify memory management by only ever using the AudioConverter to encode one packet at a time.
Following this change, the latency of the encoder goes from 0.1s to the duration of an audio frame only.
Covered by existing tests.
* Source/WebCore/PAL/pal/cf/AudioToolboxSoftLink.cpp:
* Source/WebCore/PAL/pal/cf/AudioToolboxSoftLink.h:
* Source/WebCore/platform/mediarecorder/cocoa/AudioSampleBufferCompressor.h:
* Source/WebCore/platform/mediarecorder/cocoa/AudioSampleBufferCompressor.mm:
(WebCore::AudioSampleBufferCompressor::AudioSampleBufferCompressor):
(WebCore::AudioSampleBufferCompressor::drain):
(WebCore::AudioSampleBufferCompressor::flushInternal):
(WebCore::AudioSampleBufferCompressor::initAudioConverterForSourceFormatDescription):
(WebCore::AudioSampleBufferCompressor::sampleBuffer): Rename method to enforce that it can only be used with one packet at a time.
(WebCore::AudioSampleBufferCompressor::provideSourceDataNumOutputPackets):
(WebCore::AudioSampleBufferCompressor::processSampleBuffers):
(WebCore::AudioSampleBufferCompressor::processSampleBuffer):
(WebCore::AudioSampleBufferCompressor::computeBufferSizeForAudioFormat): Deleted.
(WebCore::AudioSampleBufferCompressor::sampleBufferWithNumPackets): Deleted.
(WebCore::AudioSampleBufferCompressor::processSampleBuffersUntilLowWaterTime): Deleted.
Canonical link: https://commits.webkit.org/285681@main
To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications
More information about the webkit-changes
mailing list