Skip to content
Permalink
Browse files
Add a runtime setting for switching on/off AudioSampleDataSource buff…
…er adaptation

https://bugs.webkit.org/show_bug.cgi?id=240634

Patch by Youenn Fablet <youennf@gmail.com> on 2022-05-23
Reviewed by Eric Carlson.

* Source/WTF/Scripts/Preferences/WebPreferencesInternal.yaml:
* Source/WebCore/page/RuntimeEnabledFeatures.h:
(WebCore::RuntimeEnabledFeatures::webRTCAudioLatencyAdaptationEnabled const):
(WebCore::RuntimeEnabledFeatures::setWebRTCAudioLatencyAdaptationEnabled):
* Source/WebCore/platform/audio/cocoa/AudioSampleDataConverter.mm:
(WebCore::AudioSampleDataConverter::updateBufferedAmount):

Canonical link: https://commits.webkit.org/250856@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@294630 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
youennf authored and webkit-commit-queue committed May 23, 2022
1 parent b143b0e commit 0b6bd43552e9ce59facadcb3af5dfa1538de21c9
Showing 4 changed files with 25 additions and 1 deletion.
@@ -976,6 +976,17 @@ WebAPIStatisticsEnabled:
WebKit:
default: false

WebRTCAudioLatencyAdaptationEnabled:
type: bool
humanReadableName: "WebRTC Audio Latency Adaptation"
humanReadableDescription: "Enable WebRTC Audio Latency Adaptation"
webcoreBinding: RuntimeEnabledFeatures
defaultValue:
WebKitLegacy:
default: true
WebKit:
default: true

# FIXME: Is this implemented for WebKitLegacy? If not, this should be excluded from WebKitLegacy entirely.
WebRTCDTMFEnabled:
type: bool
@@ -150,6 +150,8 @@ class RuntimeEnabledFeatures {
bool webRTCPlatformUDPSocketsEnabled() const { return m_isWebRTCPlatformUDPSocketsEnabled; }
void setWebRTCPlatformUDPSocketsEnabled(bool isEnabled) { m_isWebRTCPlatformUDPSocketsEnabled = isEnabled; }
#endif
bool webRTCAudioLatencyAdaptationEnabled() const { return m_isWebRTCAudioLatencyAdaptationEnabled; }
void setWebRTCAudioLatencyAdaptationEnabled(bool isEnabled) { m_isWebRTCAudioLatencyAdaptationEnabled = isEnabled; }

#if ENABLE(DATALIST_ELEMENT)
bool dataListElementEnabled() const { return m_isDataListElementEnabled; }
@@ -314,6 +316,7 @@ class RuntimeEnabledFeatures {
bool m_isWebRTCPlatformTCPSocketsEnabled { false };
bool m_isWebRTCPlatformUDPSocketsEnabled { false };
#endif
bool m_isWebRTCAudioLatencyAdaptationEnabled { true };

#if ENABLE(DATALIST_ELEMENT)
bool m_isDataListElementEnabled { false };
@@ -38,7 +38,7 @@ class PlatformAudioData;
class AudioSampleDataConverter {
WTF_MAKE_FAST_ALLOCATED;
public:
AudioSampleDataConverter() = default;
AudioSampleDataConverter();
~AudioSampleDataConverter();

OSStatus setFormats(const CAAudioStreamDescription& inputDescription, const CAAudioStreamDescription& outputDescription);
@@ -66,6 +66,7 @@ class AudioSampleDataConverter {
AudioConverterRef m_audioConverter { nullptr };
};

bool m_latencyAdaptationEnabled { true };
Converter m_lowConverter;
Converter m_regularConverter;
Converter m_highConverter;
@@ -28,11 +28,17 @@

#import "AudioSampleBufferList.h"
#import "Logging.h"
#import "RuntimeEnabledFeatures.h"
#import <AudioToolbox/AudioConverter.h>
#import <pal/cf/AudioToolboxSoftLink.h>

namespace WebCore {

AudioSampleDataConverter::AudioSampleDataConverter()
: m_latencyAdaptationEnabled(RuntimeEnabledFeatures::sharedFeatures().webRTCAudioLatencyAdaptationEnabled())
{
}

AudioSampleDataConverter::~AudioSampleDataConverter()
{
}
@@ -75,6 +81,9 @@

bool AudioSampleDataConverter::updateBufferedAmount(size_t currentBufferedAmount, size_t pushedSampleSize)
{
if (!m_latencyAdaptationEnabled)
return !!m_selectedConverter;

if (currentBufferedAmount) {
if (m_selectedConverter == m_regularConverter) {
if (currentBufferedAmount <= m_lowBufferSize) {

0 comments on commit 0b6bd43

Please sign in to comment.