Bug 224672

Summary: Make RealtimeIncomingAudioSourceCocoa preallocate audio buffer
Product: WebKit Reporter: youenn fablet <youennf>
Component: WebRTCAssignee: youenn fablet <youennf>
Status: RESOLVED FIXED    
Severity: Normal CC: eric.carlson, ews-watchlist, glenn, hta, jer.noble, philipj, sergio, tommyw, webkit-bug-importer, youennf
Priority: P2 Keywords: InRadar
Version: WebKit Local Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch for landing none

Description youenn fablet 2021-04-16 07:09:06 PDT
Make RealtimeIncomingAudioSourceCocoa preallocate audio buffer
Comment 1 youenn fablet 2021-04-16 07:27:17 PDT
Created attachment 426223 [details]
Patch
Comment 2 Eric Carlson 2021-04-16 18:02:57 PDT
Comment on attachment 426223 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=426223&action=review

> Source/WebCore/platform/mediastream/mac/RealtimeIncomingAudioSourceCocoa.cpp:66
> +    , m_numberOfChannels(1)

One channel is the most common configuration?

> Source/WebCore/platform/mediastream/mac/RealtimeIncomingAudioSourceCocoa.cpp:76
> +    if (sampleRate != m_sampleRate)
> +        return;
> +

Why do we bail if the sample rate changes, but not the number of channels?

You can remove the sample rate check in `if (!m_audioBufferList || m_sampleRate != sampleRate || m_numberOfChannels != numberOfChannels)`
Comment 3 youenn fablet 2021-04-19 02:49:17 PDT
Comment on attachment 426223 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=426223&action=review

>> Source/WebCore/platform/mediastream/mac/RealtimeIncomingAudioSourceCocoa.cpp:66
>> +    , m_numberOfChannels(1)
> 
> One channel is the most common configuration?

Yes, as of now, codecs usually encode in mono.
I guess we could try to improve for stereo in the future.

>> Source/WebCore/platform/mediastream/mac/RealtimeIncomingAudioSourceCocoa.cpp:76
>> +
> 
> Why do we bail if the sample rate changes, but not the number of channels?
> 
> You can remove the sample rate check in `if (!m_audioBufferList || m_sampleRate != sampleRate || m_numberOfChannels != numberOfChannels)`

LibWebRTC initially sends 16KHz data a few times before switching to 48KHz, not sure why.
I will remove below sample check.
Comment 4 youenn fablet 2021-04-19 02:52:52 PDT
Created attachment 426403 [details]
Patch for landing
Comment 5 EWS 2021-04-19 03:29:04 PDT
Committed r276245 (236727@main): <https://commits.webkit.org/236727@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 426403 [details].
Comment 6 Radar WebKit Bug Importer 2021-04-24 15:05:17 PDT
<rdar://problem/77110055>