Bug 216425

Summary: Add proper support for AudioContextOptions.sampleRate
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: Web AudioAssignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: eric.carlson, ews-watchlist, glenn, hta, jer.noble, peng.liu6, philipj, sergio, tommyw, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 212611, 216371    
Attachments:
Description Flags
Patch
none
Patch
ews-feeder: commit-queue-
Patch
ews-feeder: commit-queue-
Patch
ews-feeder: commit-queue-
Patch
ews-feeder: commit-queue-
Patch
ews-feeder: commit-queue-
Patch
none
Patch none

Description Chris Dumez 2020-09-11 16:52:43 PDT
Add proper support for AudioContextOptions.sampleRate. Our audio context currently always runs at the hardware sample rate, no matter what value is set for AudioContextOptions.sampleRate.
Comment 1 Chris Dumez 2020-09-11 17:19:28 PDT
Created attachment 408574 [details]
Patch
Comment 2 Chris Dumez 2020-09-11 17:53:25 PDT
Created attachment 408576 [details]
Patch
Comment 3 Chris Dumez 2020-09-11 18:27:34 PDT
Created attachment 408577 [details]
Patch
Comment 4 Chris Dumez 2020-09-11 18:32:03 PDT
Created attachment 408578 [details]
Patch
Comment 5 Chris Dumez 2020-09-11 18:38:41 PDT
Created attachment 408579 [details]
Patch
Comment 6 Chris Dumez 2020-09-11 18:50:17 PDT
Created attachment 408580 [details]
Patch
Comment 7 Chris Dumez 2020-09-11 19:37:34 PDT
Created attachment 408581 [details]
Patch
Comment 8 Peng Liu 2020-09-11 20:29:41 PDT
Comment on attachment 408581 [details]
Patch

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

> Source/WebCore/ChangeLog:9
> +        at the hardware's sampleRate, no matter what value for set for AudioContextOptions.sampleRate.

Nit.
s/for set/set/

> Source/WebCore/ChangeLog:18
> +        When creating a AudioDestination, pass the requested AudioContext sample rate

Nit.
s/a/an/

> Source/WebCore/ChangeLog:58
> +          MultiChannelResampler and use in in render() to do the resampling.

Nit.
s/in in/it in/

> Source/WebCore/platform/graphics/cocoa/SourceBufferParserWebM.cpp:59
> +constexpr CMVideoCodecType kCMVideoCodecType_VP9 { 'vp09' };

There is some update about this in bug 216205.
:-)
Comment 9 Eric Carlson 2020-09-11 22:45:34 PDT
Comment on attachment 408581 [details]
Patch

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

Can we enable or add tests for AudioContextOptions.sampleRate?

> Source/WebCore/ChangeLog:8
> +        Add proper support for AudioContextOptions.sampleRate. Previously, our AudioContext always run

s/always run/always ran/

> Source/WebCore/Modules/webaudio/DefaultAudioDestinationNode.cpp:-86
> -    float hardwareSampleRate = AudioDestination::hardwareSampleRate();
> -    LOG(WebAudio, ">>>> hardwareSampleRate = %f\n", hardwareSampleRate);

Is this needed now?
Comment 10 Chris Dumez 2020-09-14 08:14:23 PDT
(In reply to Eric Carlson from comment #9)
> Comment on attachment 408581 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=408581&action=review
> 
> Can we enable or add tests for AudioContextOptions.sampleRate?

The tests for AudioContextOptions.sampleRate were already passing since we were lying to the JS and returning the sample rate it expected (even though it was not the sample rate we used internally. Do you have an idea on how to better test this?

> 
> > Source/WebCore/ChangeLog:8
> > +        Add proper support for AudioContextOptions.sampleRate. Previously, our AudioContext always run
> 
> s/always run/always ran/
> 
> > Source/WebCore/Modules/webaudio/DefaultAudioDestinationNode.cpp:-86
> > -    float hardwareSampleRate = AudioDestination::hardwareSampleRate();
> > -    LOG(WebAudio, ">>>> hardwareSampleRate = %f\n", hardwareSampleRate);
> 
> Is this needed now?
Comment 11 Chris Dumez 2020-09-14 08:19:28 PDT
Created attachment 408706 [details]
Patch
Comment 12 Chris Dumez 2020-09-14 08:47:58 PDT
Comment on attachment 408706 [details]
Patch

Clearing flags on attachment: 408706

Committed r267014: <https://trac.webkit.org/changeset/267014>
Comment 13 Chris Dumez 2020-09-14 08:48:00 PDT
All reviewed patches have been landed.  Closing bug.
Comment 14 Radar WebKit Bug Importer 2020-09-14 08:48:17 PDT
<rdar://problem/68856997>
Comment 15 Eric Carlson 2020-09-14 09:15:12 PDT
(In reply to Chris Dumez from comment #10)
> (In reply to Eric Carlson from comment #9)
> > Comment on attachment 408581 [details]
> > Patch
> > 
> > View in context:
> > https://bugs.webkit.org/attachment.cgi?id=408581&action=review
> > 
> > Can we enable or add tests for AudioContextOptions.sampleRate?
> 
> The tests for AudioContextOptions.sampleRate were already passing since we
> were lying to the JS and returning the sample rate it expected (even though
> it was not the sample rate we used internally. 
> 
LOL, why not!



> Do you have an idea on how to better test this?
> 
It seems fine as long as we aren't just returning the expected rate.