Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 1957f6961aef9bdac7fd99296bad45f4d3d90534
https://github.com/WebKit/WebKit/commit/1957f6961aef9bdac7fd99296bad45f4d3d90534
Author: Ahmad Saleem <[email protected]>
Date: 2026-09-06 (Sun, 06 Sep 2026)
Changed paths:
M Source/WebCore/platform/audio/cocoa/AudioSampleBufferList.cpp
M Source/WebCore/platform/audio/cocoa/AudioSampleBufferList.h
M Source/WebCore/platform/audio/cocoa/AudioSampleDataSource.mm
Log Message:
-----------
AudioSampleDataSource does an extra full-quantum memcpy per render when
mixing a source at less-than-unity gain
https://bugs.webkit.org/show_bug.cgi?id=323573
rdar://186814894
Reviewed by Chris Dumez.
In the Mix pull path, when a source's volume is below unity,
pullSamplesInternal() fetched the ring buffer into a scratch buffer,
applied gain, mixed the destination buffer into the scratch buffer, and
then copied the scratch buffer back over the destination:
scratch = ring // fetch
scratch *= volume // applyGain
scratch += buffer // mixFrom
buffer = scratch // copyTo <- extra full-quantum memcpy
That final copyTo is a redundant per-channel memcpy of the whole quantum,
paid on the real-time audio render thread on every callback for every
sub-unity-gain source. Because mixBuffers() is a commutative accumulate
(dest += src), the same result (buffer + ring*volume) can be produced by
mixing the gained scratch buffer directly into the destination:
scratch = ring // fetch
scratch *= volume // applyGain
buffer += scratch // mixTo
This drops one full-quantum memcpy per render. The unity-gain Mix path
already mixed in place via fetchModeForMixing and is unchanged.
Generalize the internal mixBuffers() helper to take a raw AudioBufferList&
destination (existing callers pass WebAudioBufferList via its implicit
operator AudioBufferList&), and add AudioSampleBufferList::mixTo(),
symmetric to copyTo(), that mixes the list's contents into a caller-owned
AudioBufferList.
* Source/WebCore/platform/audio/cocoa/AudioSampleBufferList.cpp:
(WebCore::mixBuffers):
(WebCore::AudioSampleBufferList::mixTo):
* Source/WebCore/platform/audio/cocoa/AudioSampleBufferList.h:
* Source/WebCore/platform/audio/cocoa/AudioSampleDataSource.mm:
(WebCore::AudioSampleDataSource::pullSamplesInternal):
Canonical link: https://commits.webkit.org/320600@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications