Bug 224672 - Make RealtimeIncomingAudioSourceCocoa preallocate audio buffer
Summary: Make RealtimeIncomingAudioSourceCocoa preallocate audio buffer
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebRTC (show other bugs)
Version: WebKit Local Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: youenn fablet
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-04-16 07:09 PDT by youenn fablet
Modified: 2021-04-24 15:05 PDT (History)
10 users (show)

See Also:


Attachments
Patch (3.06 KB, patch)
2021-04-16 07:27 PDT, youenn fablet
no flags Details | Formatted Diff | Diff
Patch for landing (3.73 KB, patch)
2021-04-19 02:52 PDT, youenn fablet
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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>