Bug 211287

Summary: AudioMediaStreamTrackRendererCocoa should create/start/stop its remote unit on the main thread
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, m.zdila, philipj, sergio, tommyw, webkit-bug-importer, youennf
Priority: P2 Keywords: InRadar
Version: WebKit Local Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=198545
Attachments:
Description Flags
Patch
none
Patch
none
Patch for landing
none
Patch for landing none

Description youenn fablet 2020-05-01 07:12:11 PDT
AudioMediaStreamTrackRendererCocoa should create/start/stop its remote unit on the main thread
Comment 1 youenn fablet 2020-05-01 07:20:42 PDT
Created attachment 398180 [details]
Patch
Comment 2 youenn fablet 2020-05-01 08:58:57 PDT
Created attachment 398187 [details]
Patch
Comment 3 youenn fablet 2020-05-01 09:24:22 PDT
As discussed with Eric offline, I'll add a comment stating that the design is that pushSamples can only be called between start and stop which is enforced by AudioTrackPrivateMediaStream::startRenderer/stopRenderer.
Comment 4 youenn fablet 2020-05-01 09:35:08 PDT
Created attachment 398191 [details]
Patch for landing
Comment 5 Eric Carlson 2020-05-01 09:42:12 PDT
Comment on attachment 398180 [details]
Patch

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

> Source/WebCore/platform/mediastream/mac/AudioMediaStreamTrackRendererCocoa.cpp:79
>      if (m_remoteIOUnit) {
>          AudioOutputUnitStop(m_remoteIOUnit);
>          AudioComponentInstanceDispose(m_remoteIOUnit);

stop() does the same thing, you could call it here.

> Source/WebCore/platform/mediastream/mac/AudioMediaStreamTrackRendererCocoa.cpp:159
> +    if (!m_dataSource || !m_dataSource->inputDescription() || toCAAudioStreamDescription(*m_dataSource->inputDescription()) != description) {

You can use CAAudioStreamDescription's `operator==(const AudioStreamDescription&)` instead of calling toCAAudioStreamDescription
Comment 6 youenn fablet 2020-05-01 09:54:12 PDT
Created attachment 398193 [details]
Patch for landing
Comment 7 youenn fablet 2020-05-01 09:54:43 PDT
(In reply to Eric Carlson from comment #5)
> Comment on attachment 398180 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=398180&action=review
> 
> > Source/WebCore/platform/mediastream/mac/AudioMediaStreamTrackRendererCocoa.cpp:79
> >      if (m_remoteIOUnit) {
> >          AudioOutputUnitStop(m_remoteIOUnit);
> >          AudioComponentInstanceDispose(m_remoteIOUnit);
> 
> stop() does the same thing, you could call it here.

Will do.

> 
> > Source/WebCore/platform/mediastream/mac/AudioMediaStreamTrackRendererCocoa.cpp:159
> > +    if (!m_dataSource || !m_dataSource->inputDescription() || toCAAudioStreamDescription(*m_dataSource->inputDescription()) != description) {
> 
> You can use CAAudioStreamDescription's `operator==(const
> AudioStreamDescription&)` instead of calling toCAAudioStreamDescription

Tried that but it failed so went this way.
I updated CAAudioStreamDescription to make it work, much nicer.
Comment 8 EWS 2020-05-03 11:16:36 PDT
Committed r261063: <https://trac.webkit.org/changeset/261063>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 398193 [details].
Comment 9 Radar WebKit Bug Importer 2020-05-03 11:17:13 PDT
<rdar://problem/62811472>
Comment 10 youenn fablet 2020-06-08 11:02:07 PDT
*** Bug 208134 has been marked as a duplicate of this bug. ***