Title: [268521] trunk/Source
Revision
268521
Author
[email protected]
Date
2020-10-15 04:36:46 -0700 (Thu, 15 Oct 2020)

Log Message

Introduce a RemoteAudioSourceProvider to receive audio samples for web audio from GPUProcess
https://bugs.webkit.org/show_bug.cgi?id=217710

Reviewed by Eric Carlson.

Source/WebCore:

Split WebAudioSourceProviderAVFObjC MediaStreamTrack specific bits in a separate MediaStreamTrackAudioSourceProviderAVFObjC class.
This allows reusing WebAudioSourceProviderAVFObjC for samples coming from audio playback living in GPUProcess.
No change of behavior.

* SourcesCocoa.txt:
* WebCore.xcodeproj/project.pbxproj:
* platform/audio/cocoa/AudioSampleBufferList.cpp:
* platform/audio/cocoa/AudioSampleBufferList.h:
* platform/audio/cocoa/AudioSampleDataSource.h:
* platform/audio/cocoa/AudioSampleDataSource.mm:
* platform/mediastream/MediaStreamTrackPrivate.cpp:
(WebCore::MediaStreamTrackPrivate::audioSourceProvider):
* platform/mediastream/RealtimeMediaSource.h:
* platform/mediastream/WebAudioSourceProvider.h:
* platform/mediastream/mac/CoreAudioCaptureSource.cpp:
* platform/mediastream/mac/MediaStreamTrackAudioSourceProviderCocoa.cpp: Added.
(WebCore::MediaStreamTrackAudioSourceProviderCocoa::create):
(WebCore::MediaStreamTrackAudioSourceProviderCocoa::MediaStreamTrackAudioSourceProviderCocoa):
(WebCore::MediaStreamTrackAudioSourceProviderCocoa::~MediaStreamTrackAudioSourceProviderCocoa):
(WebCore::MediaStreamTrackAudioSourceProviderCocoa::hasNewClient):
(WebCore::MediaStreamTrackAudioSourceProviderCocoa::trackEnabledChanged):
(WebCore::MediaStreamTrackAudioSourceProviderCocoa::audioSamplesAvailable):
* platform/mediastream/mac/MediaStreamTrackAudioSourceProviderCocoa.h: Added.
* platform/mediastream/mac/MockAudioSharedUnit.h:
* platform/mediastream/mac/MockAudioSharedUnit.mm:
* platform/mediastream/mac/WebAudioSourceProviderCocoa.h: Renamed from Source/WebCore/platform/mediastream/mac/WebAudioSourceProviderAVFObjC.h.
* platform/mediastream/mac/WebAudioSourceProviderCocoa.mm: Renamed from Source/WebCore/platform/mediastream/mac/WebAudioSourceProviderAVFObjC.mm.
(WebCore::WebAudioSourceProviderCocoa::WebAudioSourceProviderCocoa):
(WebCore::WebAudioSourceProviderCocoa::~WebAudioSourceProviderCocoa):
(WebCore::WebAudioSourceProviderCocoa::setClient):
(WebCore::WebAudioSourceProviderCocoa::provideInput):
(WebCore::WebAudioSourceProviderCocoa::prepare):
(WebCore::WebAudioSourceProviderCocoa::receivedNewAudioSamples):

Source/WebKit:

Make use of WebAudioSourceProviderAVFObjC to implement RemoteAudioSourceProvider.
RemoteAudioSourceProvider currently implements an AudioSourceProvider but it is not yet connected to GPUProcess media players.
This will be implemented in a follow-up.

* SourcesCocoa.txt:
* WebKit.xcodeproj/project.pbxproj:
* WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp:
(WebKit::MediaPlayerPrivateRemote::~MediaPlayerPrivateRemote):
(WebKit::MediaPlayerPrivateRemote::audioSourceProvider):
* WebProcess/GPU/media/MediaPlayerPrivateRemote.h:
* WebProcess/GPU/media/RemoteAudioSourceProvider.cpp: Added.
(WebKit::RemoteAudioSourceProvider::create):
(WebKit::RemoteAudioSourceProvider::RemoteAudioSourceProvider):
(WebKit::RemoteAudioSourceProvider::~RemoteAudioSourceProvider):
(WebKit::RemoteAudioSourceProvider::close):
(WebKit::RemoteAudioSourceProvider::hasNewClient):
(WebKit::RemoteAudioSourceProvider::audioSamplesAvailable):
(WebKit::RemoteAudioSourceProvider::logChannel const):
* WebProcess/GPU/media/RemoteAudioSourceProvider.h: Added.
* WebProcess/GPU/media/cocoa/MediaPlayerPrivateRemoteCocoa.mm:

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (268520 => 268521)


--- trunk/Source/WebCore/ChangeLog	2020-10-15 11:32:32 UTC (rev 268520)
+++ trunk/Source/WebCore/ChangeLog	2020-10-15 11:36:46 UTC (rev 268521)
@@ -1,3 +1,44 @@
+2020-10-15  Youenn Fablet  <[email protected]>
+
+        Introduce a RemoteAudioSourceProvider to receive audio samples for web audio from GPUProcess
+        https://bugs.webkit.org/show_bug.cgi?id=217710
+
+        Reviewed by Eric Carlson.
+
+        Split WebAudioSourceProviderAVFObjC MediaStreamTrack specific bits in a separate MediaStreamTrackAudioSourceProviderAVFObjC class.
+        This allows reusing WebAudioSourceProviderAVFObjC for samples coming from audio playback living in GPUProcess.
+        No change of behavior.
+
+        * SourcesCocoa.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/audio/cocoa/AudioSampleBufferList.cpp:
+        * platform/audio/cocoa/AudioSampleBufferList.h:
+        * platform/audio/cocoa/AudioSampleDataSource.h:
+        * platform/audio/cocoa/AudioSampleDataSource.mm:
+        * platform/mediastream/MediaStreamTrackPrivate.cpp:
+        (WebCore::MediaStreamTrackPrivate::audioSourceProvider):
+        * platform/mediastream/RealtimeMediaSource.h:
+        * platform/mediastream/WebAudioSourceProvider.h:
+        * platform/mediastream/mac/CoreAudioCaptureSource.cpp:
+        * platform/mediastream/mac/MediaStreamTrackAudioSourceProviderCocoa.cpp: Added.
+        (WebCore::MediaStreamTrackAudioSourceProviderCocoa::create):
+        (WebCore::MediaStreamTrackAudioSourceProviderCocoa::MediaStreamTrackAudioSourceProviderCocoa):
+        (WebCore::MediaStreamTrackAudioSourceProviderCocoa::~MediaStreamTrackAudioSourceProviderCocoa):
+        (WebCore::MediaStreamTrackAudioSourceProviderCocoa::hasNewClient):
+        (WebCore::MediaStreamTrackAudioSourceProviderCocoa::trackEnabledChanged):
+        (WebCore::MediaStreamTrackAudioSourceProviderCocoa::audioSamplesAvailable):
+        * platform/mediastream/mac/MediaStreamTrackAudioSourceProviderCocoa.h: Added.
+        * platform/mediastream/mac/MockAudioSharedUnit.h:
+        * platform/mediastream/mac/MockAudioSharedUnit.mm:
+        * platform/mediastream/mac/WebAudioSourceProviderCocoa.h: Renamed from Source/WebCore/platform/mediastream/mac/WebAudioSourceProviderAVFObjC.h.
+        * platform/mediastream/mac/WebAudioSourceProviderCocoa.mm: Renamed from Source/WebCore/platform/mediastream/mac/WebAudioSourceProviderAVFObjC.mm.
+        (WebCore::WebAudioSourceProviderCocoa::WebAudioSourceProviderCocoa):
+        (WebCore::WebAudioSourceProviderCocoa::~WebAudioSourceProviderCocoa):
+        (WebCore::WebAudioSourceProviderCocoa::setClient):
+        (WebCore::WebAudioSourceProviderCocoa::provideInput):
+        (WebCore::WebAudioSourceProviderCocoa::prepare):
+        (WebCore::WebAudioSourceProviderCocoa::receivedNewAudioSamples):
+
 2020-10-15  Antti Koivisto  <[email protected]>
 
         Remove <br> render tree dump quirk

Modified: trunk/Source/WebCore/SourcesCocoa.txt (268520 => 268521)


--- trunk/Source/WebCore/SourcesCocoa.txt	2020-10-15 11:32:32 UTC (rev 268520)
+++ trunk/Source/WebCore/SourcesCocoa.txt	2020-10-15 11:36:46 UTC (rev 268521)
@@ -530,6 +530,7 @@
 platform/mediastream/mac/CoreAudioCaptureSource.cpp
 platform/mediastream/mac/DisplayCaptureManagerCocoa.cpp
 platform/mediastream/mac/DisplayCaptureSourceCocoa.cpp
+platform/mediastream/mac/MediaStreamTrackAudioSourceProviderCocoa.cpp
 platform/mediastream/mac/MockAudioSharedUnit.mm
 platform/mediastream/mac/MockRealtimeVideoSourceMac.mm
 platform/mediastream/mac/RealtimeIncomingAudioSourceCocoa.cpp
@@ -540,7 +541,7 @@
 platform/mediastream/mac/RealtimeOutgoingVideoSourceCocoa.cpp
 platform/mediastream/mac/RealtimeVideoUtilities.mm
 platform/mediastream/mac/ScreenDisplayCapturerMac.mm
-platform/mediastream/mac/WebAudioSourceProviderAVFObjC.mm
+platform/mediastream/mac/WebAudioSourceProviderCocoa.mm
 platform/mediastream/mac/WindowDisplayCapturerMac.mm
 platform/mock/MediaPlaybackTargetMock.cpp
 platform/mock/MediaPlaybackTargetPickerMock.cpp

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (268520 => 268521)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2020-10-15 11:32:32 UTC (rev 268520)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2020-10-15 11:36:46 UTC (rev 268521)
@@ -207,7 +207,7 @@
 		07CB9E72249C36B200A69489 /* AVRoutePickerViewTargetPicker.mm in Sources */ = {isa = PBXBuildFile; fileRef = 07CB9E6F249C226C00A69489 /* AVRoutePickerViewTargetPicker.mm */; };
 		07CE77D516712A6A00C55A47 /* InbandTextTrackPrivateClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 07CE77D416712A6A00C55A47 /* InbandTextTrackPrivateClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		07D12F5C23DE543F0080997D /* ISOVTTCue.h in Headers */ = {isa = PBXBuildFile; fileRef = CD871C651FB52B6700F0B965 /* ISOVTTCue.h */; settings = {ATTRIBUTES = (Private, ); }; };
-		07D637401BB0B11300256CE9 /* WebAudioSourceProviderAVFObjC.h in Headers */ = {isa = PBXBuildFile; fileRef = 07D6373E1BB0B11300256CE9 /* WebAudioSourceProviderAVFObjC.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		07D637401BB0B11300256CE9 /* WebAudioSourceProviderCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = 07D6373E1BB0B11300256CE9 /* WebAudioSourceProviderCocoa.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		07D6A4F41BED5F8800174146 /* MockRealtimeAudioSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 07D6A4F21BED5F8800174146 /* MockRealtimeAudioSource.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		07D6A4F81BF2307D00174146 /* AudioTrackPrivateMediaStream.h in Headers */ = {isa = PBXBuildFile; fileRef = 07D6A4F61BF2307D00174146 /* AudioTrackPrivateMediaStream.h */; };
 		07E3DFD11A9E786500764CA8 /* MediaPlaybackTarget.h in Headers */ = {isa = PBXBuildFile; fileRef = 07E3DFD01A9E786500764CA8 /* MediaPlaybackTarget.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -5319,7 +5319,7 @@
 		FD581FAF1520F91F003A7A75 /* OscillatorNode.h in Headers */ = {isa = PBXBuildFile; fileRef = FD581FAC1520F91F003A7A75 /* OscillatorNode.h */; };
 		FD581FB51520F93B003A7A75 /* PeriodicWave.h in Headers */ = {isa = PBXBuildFile; fileRef = FD581FB21520F93B003A7A75 /* PeriodicWave.h */; };
 		FD629EA3154B47160006D026 /* AudioBasicInspectorNode.h in Headers */ = {isa = PBXBuildFile; fileRef = FD629EA1154B47160006D026 /* AudioBasicInspectorNode.h */; };
-		FD62F52E145898D80094B0ED /* AudioSourceProviderClient.h in Headers */ = {isa = PBXBuildFile; fileRef = FD62F52D145898D80094B0ED /* AudioSourceProviderClient.h */; };
+		FD62F52E145898D80094B0ED /* AudioSourceProviderClient.h in Headers */ = {isa = PBXBuildFile; fileRef = FD62F52D145898D80094B0ED /* AudioSourceProviderClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		FD671A78159BB07000197559 /* MediaStreamAudioSourceNode.h in Headers */ = {isa = PBXBuildFile; fileRef = FD671A75159BB07000197559 /* MediaStreamAudioSourceNode.h */; };
 		FD6ED2C4136B8E42003CF072 /* DynamicsCompressorNode.h in Headers */ = {isa = PBXBuildFile; fileRef = FD6ED2C2136B8E42003CF072 /* DynamicsCompressorNode.h */; };
 		FD6ED2C8136B8E66003CF072 /* DynamicsCompressor.h in Headers */ = {isa = PBXBuildFile; fileRef = FD6ED2C6136B8E66003CF072 /* DynamicsCompressor.h */; };
@@ -5772,8 +5772,8 @@
 		07CB9E6F249C226C00A69489 /* AVRoutePickerViewTargetPicker.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = AVRoutePickerViewTargetPicker.mm; sourceTree = "<group>"; };
 		07CB9E71249C226C00A69489 /* AVRoutePickerViewTargetPicker.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AVRoutePickerViewTargetPicker.h; sourceTree = "<group>"; };
 		07CE77D416712A6A00C55A47 /* InbandTextTrackPrivateClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InbandTextTrackPrivateClient.h; sourceTree = "<group>"; };
-		07D6373E1BB0B11300256CE9 /* WebAudioSourceProviderAVFObjC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebAudioSourceProviderAVFObjC.h; sourceTree = "<group>"; };
-		07D6373F1BB0B11300256CE9 /* WebAudioSourceProviderAVFObjC.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebAudioSourceProviderAVFObjC.mm; sourceTree = "<group>"; };
+		07D6373E1BB0B11300256CE9 /* WebAudioSourceProviderCocoa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebAudioSourceProviderCocoa.h; sourceTree = "<group>"; };
+		07D6373F1BB0B11300256CE9 /* WebAudioSourceProviderCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebAudioSourceProviderCocoa.mm; sourceTree = "<group>"; };
 		07D6A4F11BED5F8800174146 /* MockRealtimeAudioSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MockRealtimeAudioSource.cpp; sourceTree = "<group>"; };
 		07D6A4F21BED5F8800174146 /* MockRealtimeAudioSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MockRealtimeAudioSource.h; sourceTree = "<group>"; };
 		07D6A4F61BF2307D00174146 /* AudioTrackPrivateMediaStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AudioTrackPrivateMediaStream.h; path = platform/mediastream/AudioTrackPrivateMediaStream.h; sourceTree = SOURCE_ROOT; };
@@ -7599,6 +7599,8 @@
 		4170A2E91D8C0CC000318452 /* JSDOMWrapper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMWrapper.cpp; sourceTree = "<group>"; };
 		417253A81354BBBC00360F2A /* MediaControlTextTrackContainerElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaControlTextTrackContainerElement.cpp; sourceTree = "<group>"; };
 		417253A91354BBBC00360F2A /* MediaControlTextTrackContainerElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaControlTextTrackContainerElement.h; sourceTree = "<group>"; };
+		4174E91E2535DCD600FE4202 /* MediaStreamTrackAudioSourceProviderCocoa.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MediaStreamTrackAudioSourceProviderCocoa.h; sourceTree = "<group>"; };
+		4174E9202535DCDD00FE4202 /* MediaStreamTrackAudioSourceProviderCocoa.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = MediaStreamTrackAudioSourceProviderCocoa.cpp; sourceTree = "<group>"; };
 		417612AB1E3A993B00C3D81D /* LibWebRTCMediaEndpoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LibWebRTCMediaEndpoint.cpp; path = libwebrtc/LibWebRTCMediaEndpoint.cpp; sourceTree = "<group>"; };
 		417612AC1E3A993B00C3D81D /* LibWebRTCMediaEndpoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LibWebRTCMediaEndpoint.h; path = libwebrtc/LibWebRTCMediaEndpoint.h; sourceTree = "<group>"; };
 		417612AD1E3A993B00C3D81D /* LibWebRTCPeerConnectionBackend.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LibWebRTCPeerConnectionBackend.cpp; path = libwebrtc/LibWebRTCPeerConnectionBackend.cpp; sourceTree = "<group>"; };
@@ -17051,6 +17053,8 @@
 				07A6D8491FEB700C006441DE /* DisplayCaptureManagerCocoa.h */,
 				07A6D8471FEB700B006441DE /* DisplayCaptureSourceCocoa.cpp */,
 				07A6D84A1FEB700D006441DE /* DisplayCaptureSourceCocoa.h */,
+				4174E9202535DCDD00FE4202 /* MediaStreamTrackAudioSourceProviderCocoa.cpp */,
+				4174E91E2535DCD600FE4202 /* MediaStreamTrackAudioSourceProviderCocoa.h */,
 				0744ECEB1E0C4AE5000D0944 /* MockAudioSharedUnit.h */,
 				0744ECEC1E0C4AE5000D0944 /* MockAudioSharedUnit.mm */,
 				07EE76ED1BEA619800F89133 /* MockRealtimeVideoSourceMac.h */,
@@ -17070,8 +17074,8 @@
 				4158649F23BF7B9300A0A61E /* RealtimeVideoUtilities.mm */,
 				416F807C24509F3300B68F02 /* ScreenDisplayCapturerMac.h */,
 				416F807A24509F3200B68F02 /* ScreenDisplayCapturerMac.mm */,
-				07D6373E1BB0B11300256CE9 /* WebAudioSourceProviderAVFObjC.h */,
-				07D6373F1BB0B11300256CE9 /* WebAudioSourceProviderAVFObjC.mm */,
+				07D6373E1BB0B11300256CE9 /* WebAudioSourceProviderCocoa.h */,
+				07D6373F1BB0B11300256CE9 /* WebAudioSourceProviderCocoa.mm */,
 				416F807924509F3200B68F02 /* WindowDisplayCapturerMac.h */,
 				416F807B24509F3300B68F02 /* WindowDisplayCapturerMac.mm */,
 			);
@@ -34554,7 +34558,7 @@
 				E18C35441F71970C00FF632D /* WebArchiveResourceWebResourceHandler.h in Headers */,
 				417F7AEE2139BF6800FBA7EC /* WebAudioBufferList.h in Headers */,
 				41B2A6261EF1BF6D002B9D7A /* WebAudioSourceProvider.h in Headers */,
-				07D637401BB0B11300256CE9 /* WebAudioSourceProviderAVFObjC.h in Headers */,
+				07D637401BB0B11300256CE9 /* WebAudioSourceProviderCocoa.h in Headers */,
 				574F55E1204F3B23002948C6 /* WebAuthenticationConstants.h in Headers */,
 				57152B8021DDA581000C37CA /* WebAuthenticationUtils.h in Headers */,
 				CDB6354923F6023A00C0F9DE /* WebAVPlayerController.h in Headers */,

Modified: trunk/Source/WebCore/platform/audio/cocoa/AudioSampleBufferList.cpp (268520 => 268521)


--- trunk/Source/WebCore/platform/audio/cocoa/AudioSampleBufferList.cpp	2020-10-15 11:32:32 UTC (rev 268520)
+++ trunk/Source/WebCore/platform/audio/cocoa/AudioSampleBufferList.cpp	2020-10-15 11:36:46 UTC (rev 268521)
@@ -26,8 +26,6 @@
 #include "config.h"
 #include "AudioSampleBufferList.h"
 
-#if ENABLE(MEDIA_STREAM)
-
 #include "Logging.h"
 #include "VectorMath.h"
 #include <Accelerate/Accelerate.h>
@@ -320,5 +318,3 @@
 }
 
 } // namespace WebCore
-
-#endif // ENABLE(MEDIA_STREAM)

Modified: trunk/Source/WebCore/platform/audio/cocoa/AudioSampleBufferList.h (268520 => 268521)


--- trunk/Source/WebCore/platform/audio/cocoa/AudioSampleBufferList.h	2020-10-15 11:32:32 UTC (rev 268520)
+++ trunk/Source/WebCore/platform/audio/cocoa/AudioSampleBufferList.h	2020-10-15 11:36:46 UTC (rev 268521)
@@ -25,8 +25,6 @@
 
 #pragma once
 
-#if ENABLE(MEDIA_STREAM)
-
 #include "CARingBuffer.h"
 #include "WebAudioBufferList.h"
 #include <CoreAudio/CoreAudioTypes.h>
@@ -97,5 +95,3 @@
 }
 
 } // namespace WebCore
-
-#endif // ENABLE(MEDIA_STREAM)

Modified: trunk/Source/WebCore/platform/audio/cocoa/AudioSampleDataSource.h (268520 => 268521)


--- trunk/Source/WebCore/platform/audio/cocoa/AudioSampleDataSource.h	2020-10-15 11:32:32 UTC (rev 268520)
+++ trunk/Source/WebCore/platform/audio/cocoa/AudioSampleDataSource.h	2020-10-15 11:36:46 UTC (rev 268521)
@@ -25,8 +25,6 @@
 
 #pragma once
 
-#if ENABLE(MEDIA_STREAM)
-
 #include "AudioSampleBufferList.h"
 #include <CoreAudio/CoreAudioTypes.h>
 #include <wtf/LoggerHelper.h>
@@ -123,5 +121,3 @@
 };
 
 } // namespace WebCore
-
-#endif // ENABLE(MEDIA_STREAM)

Modified: trunk/Source/WebCore/platform/audio/cocoa/AudioSampleDataSource.mm (268520 => 268521)


--- trunk/Source/WebCore/platform/audio/cocoa/AudioSampleDataSource.mm	2020-10-15 11:32:32 UTC (rev 268520)
+++ trunk/Source/WebCore/platform/audio/cocoa/AudioSampleDataSource.mm	2020-10-15 11:36:46 UTC (rev 268521)
@@ -26,12 +26,10 @@
 #import "config.h"
 #import "AudioSampleDataSource.h"
 
-#if ENABLE(MEDIA_STREAM)
-
 #import "CAAudioStreamDescription.h"
 #import "CARingBuffer.h"
 #import "Logging.h"
-#import "MediaStreamTrackPrivate.h"
+#import "PlatformAudioData.h"
 #import <AudioToolbox/AudioConverter.h>
 #import <mach/mach.h>
 #import <mach/mach_time.h>
@@ -379,5 +377,3 @@
 #endif
 
 } // namespace WebCore
-
-#endif // ENABLE(MEDIA_STREAM)

Modified: trunk/Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.cpp (268520 => 268521)


--- trunk/Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.cpp	2020-10-15 11:32:32 UTC (rev 268520)
+++ trunk/Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.cpp	2020-10-15 11:36:46 UTC (rev 268521)
@@ -37,7 +37,7 @@
 #include <wtf/UUID.h>
 
 #if PLATFORM(COCOA)
-#include "WebAudioSourceProviderAVFObjC.h"
+#include "MediaStreamTrackAudioSourceProviderCocoa.h"
 #elif ENABLE(WEB_AUDIO) && ENABLE(MEDIA_STREAM) && USE(LIBWEBRTC) && USE(GSTREAMER)
 #include "AudioSourceProviderGStreamer.h"
 #else
@@ -188,7 +188,7 @@
 {
 #if PLATFORM(COCOA)
     if (!m_audioSourceProvider)
-        m_audioSourceProvider = WebAudioSourceProviderAVFObjC::create(*this);
+        m_audioSourceProvider = MediaStreamTrackAudioSourceProviderCocoa::create(*this);
 #elif USE(LIBWEBRTC) && USE(GSTREAMER)
     if (!m_audioSourceProvider)
         m_audioSourceProvider = AudioSourceProviderGStreamer::create(*this);

Modified: trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.h (268520 => 268521)


--- trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.h	2020-10-15 11:32:32 UTC (rev 268520)
+++ trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.h	2020-10-15 11:36:46 UTC (rev 268521)
@@ -71,7 +71,7 @@
     : public ThreadSafeRefCounted<RealtimeMediaSource, WTF::DestructionThread::MainRunLoop>
     , public CanMakeWeakPtr<RealtimeMediaSource, WeakPtrFactoryInitialization::Eager>
 #if !RELEASE_LOG_DISABLED
-    , protected LoggerHelper
+    , public LoggerHelper
 #endif
 {
 public:

Modified: trunk/Source/WebCore/platform/mediastream/WebAudioSourceProvider.h (268520 => 268521)


--- trunk/Source/WebCore/platform/mediastream/WebAudioSourceProvider.h	2020-10-15 11:32:32 UTC (rev 268520)
+++ trunk/Source/WebCore/platform/mediastream/WebAudioSourceProvider.h	2020-10-15 11:36:46 UTC (rev 268521)
@@ -25,7 +25,7 @@
 
 #pragma once
 
-#if ENABLE(WEB_AUDIO) && ENABLE(MEDIA_STREAM)
+#if ENABLE(WEB_AUDIO)
 
 #include "AudioSourceProvider.h"
 #include <wtf/ThreadSafeRefCounted.h>

Modified: trunk/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.cpp (268520 => 268521)


--- trunk/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.cpp	2020-10-15 11:32:32 UTC (rev 268520)
+++ trunk/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.cpp	2020-10-15 11:36:46 UTC (rev 268521)
@@ -37,7 +37,7 @@
 #include "Logging.h"
 #include "PlatformMediaSessionManager.h"
 #include "Timer.h"
-#include "WebAudioSourceProviderAVFObjC.h"
+#include "WebAudioSourceProviderCocoa.h"
 #include <AudioToolbox/AudioConverter.h>
 #include <AudioUnit/AudioUnit.h>
 #include <CoreMedia/CMSync.h>

Added: trunk/Source/WebCore/platform/mediastream/mac/MediaStreamTrackAudioSourceProviderCocoa.cpp (0 => 268521)


--- trunk/Source/WebCore/platform/mediastream/mac/MediaStreamTrackAudioSourceProviderCocoa.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/mediastream/mac/MediaStreamTrackAudioSourceProviderCocoa.cpp	2020-10-15 11:36:46 UTC (rev 268521)
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "MediaStreamTrackAudioSourceProviderCocoa.h"
+
+#if ENABLE(WEB_AUDIO) && ENABLE(MEDIA_STREAM)
+
+namespace WebCore {
+
+Ref<MediaStreamTrackAudioSourceProviderCocoa> MediaStreamTrackAudioSourceProviderCocoa::create(MediaStreamTrackPrivate& source)
+{
+    return adoptRef(*new MediaStreamTrackAudioSourceProviderCocoa(source));
+}
+
+MediaStreamTrackAudioSourceProviderCocoa::MediaStreamTrackAudioSourceProviderCocoa(MediaStreamTrackPrivate& source)
+    : m_captureSource(makeWeakPtr(source))
+    , m_source(source.source())
+{
+}
+
+MediaStreamTrackAudioSourceProviderCocoa::~MediaStreamTrackAudioSourceProviderCocoa()
+{
+    ASSERT(!m_connected);
+    m_source->removeAudioSampleObserver(*this);
+}
+
+void MediaStreamTrackAudioSourceProviderCocoa::hasNewClient(AudioSourceProviderClient* client)
+{
+    bool shouldBeConnected = !!client;
+    if (m_connected == shouldBeConnected)
+        return;
+
+    m_connected = shouldBeConnected;
+    if (!client) {
+        m_captureSource->removeObserver(*this);
+        m_source->removeAudioSampleObserver(*this);
+        return;
+    }
+
+    m_enabled = m_captureSource->enabled();
+    m_captureSource->addObserver(*this);
+    m_source->addAudioSampleObserver(*this);
+}
+
+void MediaStreamTrackAudioSourceProviderCocoa::trackEnabledChanged(MediaStreamTrackPrivate& track)
+{
+    m_enabled = track.enabled();
+}
+
+// May get called on a background thread.
+void MediaStreamTrackAudioSourceProviderCocoa::audioSamplesAvailable(const MediaTime&, const PlatformAudioData& data, const AudioStreamDescription& description, size_t frameCount)
+{
+    if (!m_enabled)
+        return;
+
+    receivedNewAudioSamples(data, description, frameCount);
+}
+
+}
+
+#endif // ENABLE(WEB_AUDIO) && ENABLE(MEDIA_STREAM)

Copied: trunk/Source/WebCore/platform/mediastream/mac/MediaStreamTrackAudioSourceProviderCocoa.h (from rev 268520, trunk/Source/WebCore/platform/mediastream/mac/WebAudioSourceProviderAVFObjC.h) (0 => 268521)


--- trunk/Source/WebCore/platform/mediastream/mac/MediaStreamTrackAudioSourceProviderCocoa.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/mediastream/mac/MediaStreamTrackAudioSourceProviderCocoa.h	2020-10-15 11:36:46 UTC (rev 268521)
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(WEB_AUDIO) && ENABLE(MEDIA_STREAM)
+
+#include "MediaStreamTrackPrivate.h"
+#include "RealtimeMediaSource.h"
+#include "WebAudioSourceProviderCocoa.h"
+
+namespace WebCore {
+
+class MediaStreamTrackAudioSourceProviderCocoa final
+    : public WebAudioSourceProviderCocoa
+    , MediaStreamTrackPrivate::Observer
+    , RealtimeMediaSource::AudioSampleObserver {
+public:
+    static Ref<MediaStreamTrackAudioSourceProviderCocoa> create(MediaStreamTrackPrivate&);
+    ~MediaStreamTrackAudioSourceProviderCocoa();
+
+private:
+    explicit MediaStreamTrackAudioSourceProviderCocoa(MediaStreamTrackPrivate&);
+
+    // WebAudioSourceProviderCocoa
+    void hasNewClient(AudioSourceProviderClient*) final;
+#if !RELEASE_LOG_DISABLED
+    WTF::LoggerHelper& loggerHelper() final { return m_source.get(); }
+#endif
+
+    // MediaStreamTrackPrivate::Observer
+    void trackEnded(MediaStreamTrackPrivate&) final { }
+    void trackMutedChanged(MediaStreamTrackPrivate&) final { }
+    void trackSettingsChanged(MediaStreamTrackPrivate&) final { }
+    void trackEnabledChanged(MediaStreamTrackPrivate&) final;
+
+    // RealtimeMediaSource::AudioSampleObserver
+    void audioSamplesAvailable(const MediaTime&, const PlatformAudioData&, const AudioStreamDescription&, size_t) final;
+
+    WeakPtr<MediaStreamTrackPrivate> m_captureSource;
+    Ref<RealtimeMediaSource> m_source;
+    bool m_enabled { true };
+    bool m_connected { false };
+};
+
+}
+
+#endif

Modified: trunk/Source/WebCore/platform/mediastream/mac/MockAudioSharedUnit.h (268520 => 268521)


--- trunk/Source/WebCore/platform/mediastream/mac/MockAudioSharedUnit.h	2020-10-15 11:32:32 UTC (rev 268520)
+++ trunk/Source/WebCore/platform/mediastream/mac/MockAudioSharedUnit.h	2020-10-15 11:36:46 UTC (rev 268521)
@@ -40,7 +40,7 @@
 namespace WebCore {
 
 class WebAudioBufferList;
-class WebAudioSourceProviderAVFObjC;
+class WebAudioSourceProviderCocoa;
 
 class MockAudioSharedUnit final : public BaseAudioSharedUnit {
 public:

Modified: trunk/Source/WebCore/platform/mediastream/mac/MockAudioSharedUnit.mm (268520 => 268521)


--- trunk/Source/WebCore/platform/mediastream/mac/MockAudioSharedUnit.mm	2020-10-15 11:32:32 UTC (rev 268520)
+++ trunk/Source/WebCore/platform/mediastream/mac/MockAudioSharedUnit.mm	2020-10-15 11:36:46 UTC (rev 268521)
@@ -39,7 +39,7 @@
 #import "NotImplemented.h"
 #import "RealtimeMediaSourceSettings.h"
 #import "WebAudioBufferList.h"
-#import "WebAudioSourceProviderAVFObjC.h"
+#import "WebAudioSourceProviderCocoa.h"
 #import <AVFoundation/AVAudioBuffer.h>
 #import <AudioToolbox/AudioConverter.h>
 #import <CoreAudio/CoreAudioTypes.h>

Deleted: trunk/Source/WebCore/platform/mediastream/mac/WebAudioSourceProviderAVFObjC.h (268520 => 268521)


--- trunk/Source/WebCore/platform/mediastream/mac/WebAudioSourceProviderAVFObjC.h	2020-10-15 11:32:32 UTC (rev 268520)
+++ trunk/Source/WebCore/platform/mediastream/mac/WebAudioSourceProviderAVFObjC.h	2020-10-15 11:36:46 UTC (rev 268521)
@@ -1,95 +0,0 @@
-/*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
- */
-
-#pragma once
-
-#if ENABLE(WEB_AUDIO) && ENABLE(MEDIA_STREAM)
-
-#include "CAAudioStreamDescription.h"
-#include "MediaStreamTrackPrivate.h"
-#include "WebAudioSourceProvider.h"
-#include <CoreAudio/CoreAudioTypes.h>
-#include <wtf/Lock.h>
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
-
-typedef struct AudioBufferList AudioBufferList;
-typedef struct OpaqueAudioConverter* AudioConverterRef;
-typedef struct AudioStreamBasicDescription AudioStreamBasicDescription;
-typedef const struct opaqueCMFormatDescription *CMFormatDescriptionRef;
-typedef struct opaqueCMSampleBuffer *CMSampleBufferRef;
-
-namespace WebCore {
-
-class AudioSampleDataSource;
-class CAAudioStreamDescription;
-class WebAudioBufferList;
-
-class WEBCORE_EXPORT WebAudioSourceProviderAVFObjC final
-    : public WebAudioSourceProvider
-    , MediaStreamTrackPrivate::Observer
-    , RealtimeMediaSource::AudioSampleObserver {
-public:
-    static Ref<WebAudioSourceProviderAVFObjC> create(MediaStreamTrackPrivate&);
-    virtual ~WebAudioSourceProviderAVFObjC();
-
-    void prepare(const AudioStreamBasicDescription&);
-    void unprepare();
-
-private:
-    explicit WebAudioSourceProviderAVFObjC(MediaStreamTrackPrivate&);
-
-    // AudioSourceProvider
-    void provideInput(AudioBus*, size_t) final;
-    void setClient(AudioSourceProviderClient*) final;
-
-    // MediaStreamTrackPrivate::Observer
-    void trackEnded(MediaStreamTrackPrivate&) final { }
-    void trackMutedChanged(MediaStreamTrackPrivate&) final { }
-    void trackSettingsChanged(MediaStreamTrackPrivate&) final { }
-    void trackEnabledChanged(MediaStreamTrackPrivate&) final;
-
-    // RealtimeMediaSource::AudioSampleObserver
-    void audioSamplesAvailable(const MediaTime&, const PlatformAudioData&, const AudioStreamDescription&, size_t) final;
-
-    size_t m_listBufferSize { 0 };
-    Optional<CAAudioStreamDescription> m_inputDescription;
-    Optional<CAAudioStreamDescription> m_outputDescription;
-    std::unique_ptr<WebAudioBufferList> m_audioBufferList;
-    RefPtr<AudioSampleDataSource> m_dataSource;
-
-    uint64_t m_writeCount { 0 };
-    uint64_t m_readCount { 0 };
-    AudioSourceProviderClient* m_client { nullptr };
-    MediaStreamTrackPrivate* m_captureSource { nullptr };
-    Ref<RealtimeMediaSource> m_source;
-    Lock m_lock;
-    bool m_connected { false };
-    bool m_enabled { true };
-};
-
-}
-
-#endif

Deleted: trunk/Source/WebCore/platform/mediastream/mac/WebAudioSourceProviderAVFObjC.mm (268520 => 268521)


--- trunk/Source/WebCore/platform/mediastream/mac/WebAudioSourceProviderAVFObjC.mm	2020-10-15 11:32:32 UTC (rev 268520)
+++ trunk/Source/WebCore/platform/mediastream/mac/WebAudioSourceProviderAVFObjC.mm	2020-10-15 11:36:46 UTC (rev 268521)
@@ -1,200 +0,0 @@
-/*
- * Copyright (C) 2015-2017 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
- */
-
-#import "config.h"
-#import "WebAudioSourceProviderAVFObjC.h"
-
-#if ENABLE(WEB_AUDIO) && ENABLE(MEDIA_STREAM)
-
-#import "AudioBus.h"
-#import "AudioChannel.h"
-#import "AudioSampleDataSource.h"
-#import "AudioSourceProviderClient.h"
-#import "Logging.h"
-#import "WebAudioBufferList.h"
-#import <objc/runtime.h>
-#import <wtf/MainThread.h>
-
-#if !LOG_DISABLED
-#import <wtf/StringPrintStream.h>
-#endif
-
-#import <pal/cf/CoreMediaSoftLink.h>
-
-namespace WebCore {
-
-static const double kRingBufferDuration = 1;
-
-Ref<WebAudioSourceProviderAVFObjC> WebAudioSourceProviderAVFObjC::create(MediaStreamTrackPrivate& source)
-{
-    return adoptRef(*new WebAudioSourceProviderAVFObjC(source));
-}
-
-WebAudioSourceProviderAVFObjC::WebAudioSourceProviderAVFObjC(MediaStreamTrackPrivate& source)
-    : m_captureSource(&source)
-    , m_source(source.source())
-    , m_enabled(source.enabled())
-{
-    m_source->addAudioSampleObserver(*this);
-}
-
-WebAudioSourceProviderAVFObjC::~WebAudioSourceProviderAVFObjC()
-{
-    m_source->removeAudioSampleObserver(*this);
-
-    auto locker = holdLock(m_lock);
-
-    if (m_connected && m_captureSource)
-        m_captureSource->removeObserver(*this);
-}
-
-void WebAudioSourceProviderAVFObjC::provideInput(AudioBus* bus, size_t framesToProcess)
-{
-    auto locker = tryHoldLock(m_lock);
-    if (!locker || !m_dataSource || !m_audioBufferList) {
-        bus->zero();
-        return;
-    }
-
-    if (m_writeCount <= m_readCount) {
-        bus->zero();
-        return;
-    }
-
-    if (bus->numberOfChannels() < m_audioBufferList->bufferCount()) {
-        bus->zero();
-        return;
-    }
-
-    for (unsigned i = 0; i < bus->numberOfChannels(); ++i) {
-        auto& channel = *bus->channel(i);
-        if (i >= m_audioBufferList->bufferCount()) {
-            channel.zero();
-            continue;
-        }
-        auto* buffer = m_audioBufferList->buffer(i);
-        buffer->mNumberChannels = 1;
-        buffer->mData = channel.mutableData();
-        buffer->mDataByteSize = channel.length() * sizeof(float);
-    }
-
-    ASSERT(framesToProcess <= bus->length());
-    m_dataSource->pullSamples(*m_audioBufferList->list(), framesToProcess, m_readCount, 0, AudioSampleDataSource::Copy);
-    m_readCount += framesToProcess;
-}
-
-void WebAudioSourceProviderAVFObjC::setClient(AudioSourceProviderClient* client)
-{
-    if (m_client == client)
-        return;
-
-    m_client = client;
-
-    if (!m_captureSource)
-        return;
-
-    if (m_client && !m_connected) {
-        m_connected = true;
-        m_captureSource->addObserver(*this);
-    } else if (!m_client && m_connected) {
-        m_captureSource->removeObserver(*this);
-        m_connected = false;
-    }
-}
-
-void WebAudioSourceProviderAVFObjC::prepare(const AudioStreamBasicDescription& format)
-{
-    auto locker = holdLock(m_lock);
-
-    LOG(Media, "WebAudioSourceProviderAVFObjC::prepare(%p)", this);
-
-    m_inputDescription = CAAudioStreamDescription(format);
-    int numberOfChannels = format.mChannelsPerFrame;
-    double sampleRate = format.mSampleRate;
-    ASSERT(sampleRate >= 0);
-
-    const int bytesPerFloat = sizeof(Float32);
-    const int bitsPerByte = 8;
-    const bool isFloat = true;
-    const bool isBigEndian = false;
-    const bool isNonInterleaved = true;
-    AudioStreamBasicDescription outputDescription { };
-    FillOutASBDForLPCM(outputDescription, sampleRate, numberOfChannels, bitsPerByte * bytesPerFloat, bitsPerByte * bytesPerFloat, isFloat, isBigEndian, isNonInterleaved);
-    m_outputDescription = CAAudioStreamDescription(outputDescription);
-    m_audioBufferList = makeUnique<WebAudioBufferList>(m_outputDescription.value());
-
-    if (!m_dataSource)
-        m_dataSource = AudioSampleDataSource::create(kRingBufferDuration * sampleRate, *m_captureSource);
-    m_dataSource->setInputFormat(m_inputDescription.value());
-    m_dataSource->setOutputFormat(m_outputDescription.value());
-
-    callOnMainThread([protectedThis = makeRef(*this), numberOfChannels, sampleRate] {
-        if (protectedThis->m_client)
-            protectedThis->m_client->setFormat(numberOfChannels, sampleRate);
-    });
-}
-
-void WebAudioSourceProviderAVFObjC::unprepare()
-{
-    auto locker = holdLock(m_lock);
-
-    m_inputDescription = WTF::nullopt;
-    m_outputDescription = WTF::nullopt;
-    m_audioBufferList = nullptr;
-    m_dataSource = nullptr;
-    m_listBufferSize = 0;
-    if (m_captureSource) {
-        m_captureSource->removeObserver(*this);
-        m_captureSource = nullptr;
-    }
-}
-
-void WebAudioSourceProviderAVFObjC::trackEnabledChanged(MediaStreamTrackPrivate& track)
-{
-    m_enabled = track.enabled();
-}
-
-// May get called on a background thread.
-void WebAudioSourceProviderAVFObjC::audioSamplesAvailable(const MediaTime&, const PlatformAudioData& data, const AudioStreamDescription& description, size_t frameCount)
-{
-    if (!m_enabled || !m_connected)
-        return;
-
-    ASSERT(description.platformDescription().type == PlatformDescription::CAAudioStreamBasicType);
-    auto& basicDescription = *WTF::get<const AudioStreamBasicDescription*>(description.platformDescription().description);
-    if (!m_inputDescription || m_inputDescription->streamDescription() != basicDescription)
-        prepare(basicDescription);
-
-    if (!m_dataSource)
-        return;
-
-    m_dataSource->pushSamples(MediaTime(m_writeCount, m_outputDescription->sampleRate()), data, frameCount);
-
-    m_writeCount += frameCount;
-}
-
-}
-
-#endif // ENABLE(WEB_AUDIO) && ENABLE(MEDIA_STREAM)

Copied: trunk/Source/WebCore/platform/mediastream/mac/WebAudioSourceProviderCocoa.h (from rev 268520, trunk/Source/WebCore/platform/mediastream/mac/WebAudioSourceProviderAVFObjC.h) (0 => 268521)


--- trunk/Source/WebCore/platform/mediastream/mac/WebAudioSourceProviderCocoa.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/mediastream/mac/WebAudioSourceProviderCocoa.h	2020-10-15 11:36:46 UTC (rev 268521)
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2015-2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#pragma once
+
+#if ENABLE(WEB_AUDIO)
+
+#include "CAAudioStreamDescription.h"
+#include "WebAudioSourceProvider.h"
+#include <CoreAudio/CoreAudioTypes.h>
+#include <wtf/Lock.h>
+#include <wtf/RefCounted.h>
+#include <wtf/RefPtr.h>
+
+typedef struct AudioBufferList AudioBufferList;
+typedef struct OpaqueAudioConverter* AudioConverterRef;
+typedef struct AudioStreamBasicDescription AudioStreamBasicDescription;
+typedef const struct opaqueCMFormatDescription *CMFormatDescriptionRef;
+typedef struct opaqueCMSampleBuffer *CMSampleBufferRef;
+
+namespace WTF {
+class LoggerHelper;
+}
+
+namespace WebCore {
+
+class AudioSampleDataSource;
+class CAAudioStreamDescription;
+class PlatformAudioData;
+class WebAudioBufferList;
+
+class WEBCORE_EXPORT WebAudioSourceProviderCocoa
+    : public WebAudioSourceProvider {
+public:
+    WebAudioSourceProviderCocoa();
+    ~WebAudioSourceProviderCocoa();
+
+protected:
+    void receivedNewAudioSamples(const PlatformAudioData&, const AudioStreamDescription&, size_t);
+
+private:
+    virtual void hasNewClient(AudioSourceProviderClient*) = 0;
+#if !RELEASE_LOG_DISABLED
+    virtual WTF::LoggerHelper& loggerHelper() = 0;
+#endif
+
+    // AudioSourceProvider
+    void provideInput(AudioBus*, size_t) final;
+    void setClient(AudioSourceProviderClient*) final;
+
+    void prepare(const AudioStreamBasicDescription&);
+
+    Lock m_lock;
+    AudioSourceProviderClient* m_client { nullptr };
+
+    Optional<CAAudioStreamDescription> m_inputDescription;
+    Optional<CAAudioStreamDescription> m_outputDescription;
+    std::unique_ptr<WebAudioBufferList> m_audioBufferList;
+    RefPtr<AudioSampleDataSource> m_dataSource;
+
+    uint64_t m_writeCount { 0 };
+    uint64_t m_readCount { 0 };
+};
+
+}
+
+#endif // ENABLE(WEB_AUDIO)

Copied: trunk/Source/WebCore/platform/mediastream/mac/WebAudioSourceProviderCocoa.mm (from rev 268520, trunk/Source/WebCore/platform/mediastream/mac/WebAudioSourceProviderAVFObjC.mm) (0 => 268521)


--- trunk/Source/WebCore/platform/mediastream/mac/WebAudioSourceProviderCocoa.mm	                        (rev 0)
+++ trunk/Source/WebCore/platform/mediastream/mac/WebAudioSourceProviderCocoa.mm	2020-10-15 11:36:46 UTC (rev 268521)
@@ -0,0 +1,151 @@
+/*
+ * Copyright (C) 2015-2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#import "config.h"
+#import "WebAudioSourceProviderCocoa.h"
+
+#if ENABLE(WEB_AUDIO)
+
+#import "AudioBus.h"
+#import "AudioChannel.h"
+#import "AudioSampleDataSource.h"
+#import "AudioSourceProviderClient.h"
+#import "Logging.h"
+#import "WebAudioBufferList.h"
+#import <objc/runtime.h>
+#import <wtf/MainThread.h>
+
+#if !LOG_DISABLED
+#import <wtf/StringPrintStream.h>
+#endif
+
+#import <pal/cf/CoreMediaSoftLink.h>
+
+namespace WebCore {
+
+static const double kRingBufferDuration = 1;
+
+WebAudioSourceProviderCocoa::WebAudioSourceProviderCocoa()
+{
+}
+
+WebAudioSourceProviderCocoa::~WebAudioSourceProviderCocoa()
+{
+}
+
+void WebAudioSourceProviderCocoa::setClient(AudioSourceProviderClient* client)
+{
+    if (m_client == client)
+        return;
+    m_client = client;
+    hasNewClient(client);
+}
+
+void WebAudioSourceProviderCocoa::provideInput(AudioBus* bus, size_t framesToProcess)
+{
+    auto locker = tryHoldLock(m_lock);
+    if (!locker || !m_dataSource || !m_audioBufferList) {
+        bus->zero();
+        return;
+    }
+
+    if (m_writeCount <= m_readCount) {
+        bus->zero();
+        return;
+    }
+
+    if (bus->numberOfChannels() < m_audioBufferList->bufferCount()) {
+        bus->zero();
+        return;
+    }
+
+    for (unsigned i = 0; i < bus->numberOfChannels(); ++i) {
+        auto& channel = *bus->channel(i);
+        if (i >= m_audioBufferList->bufferCount()) {
+            channel.zero();
+            continue;
+        }
+        auto* buffer = m_audioBufferList->buffer(i);
+        buffer->mNumberChannels = 1;
+        buffer->mData = channel.mutableData();
+        buffer->mDataByteSize = channel.length() * sizeof(float);
+    }
+
+    ASSERT(framesToProcess <= bus->length());
+    m_dataSource->pullSamples(*m_audioBufferList->list(), framesToProcess, m_readCount, 0, AudioSampleDataSource::Copy);
+    m_readCount += framesToProcess;
+}
+
+void WebAudioSourceProviderCocoa::prepare(const AudioStreamBasicDescription& format)
+{
+    auto locker = holdLock(m_lock);
+
+    LOG(Media, "WebAudioSourceProviderCocoa::prepare(%p)", this);
+
+    m_inputDescription = CAAudioStreamDescription(format);
+    int numberOfChannels = format.mChannelsPerFrame;
+    double sampleRate = format.mSampleRate;
+    ASSERT(sampleRate >= 0);
+
+    const int bytesPerFloat = sizeof(Float32);
+    const int bitsPerByte = 8;
+    const bool isFloat = true;
+    const bool isBigEndian = false;
+    const bool isNonInterleaved = true;
+    AudioStreamBasicDescription outputDescription { };
+    FillOutASBDForLPCM(outputDescription, sampleRate, numberOfChannels, bitsPerByte * bytesPerFloat, bitsPerByte * bytesPerFloat, isFloat, isBigEndian, isNonInterleaved);
+    m_outputDescription = CAAudioStreamDescription(outputDescription);
+    m_audioBufferList = makeUnique<WebAudioBufferList>(m_outputDescription.value());
+
+    if (!m_dataSource)
+        m_dataSource = AudioSampleDataSource::create(kRingBufferDuration * sampleRate, loggerHelper());
+    m_dataSource->setInputFormat(m_inputDescription.value());
+    m_dataSource->setOutputFormat(m_outputDescription.value());
+
+    callOnMainThread([protectedThis = makeRef(*this), numberOfChannels, sampleRate] {
+        if (protectedThis->m_client)
+            protectedThis->m_client->setFormat(numberOfChannels, sampleRate);
+    });
+}
+
+// May get called on a background thread.
+void WebAudioSourceProviderCocoa::receivedNewAudioSamples(const PlatformAudioData& data, const AudioStreamDescription& description, size_t frameCount)
+{
+    ASSERT(description.platformDescription().type == PlatformDescription::CAAudioStreamBasicType);
+    auto& basicDescription = *WTF::get<const AudioStreamBasicDescription*>(description.platformDescription().description);
+    if (!m_inputDescription || m_inputDescription->streamDescription() != basicDescription)
+        prepare(basicDescription);
+
+    if (!m_dataSource)
+        return;
+
+    m_dataSource->pushSamples(MediaTime(m_writeCount, m_outputDescription->sampleRate()), data, frameCount);
+
+    m_writeCount += frameCount;
+}
+
+}
+
+#endif // ENABLE(WEB_AUDIO)

Modified: trunk/Source/WebKit/ChangeLog (268520 => 268521)


--- trunk/Source/WebKit/ChangeLog	2020-10-15 11:32:32 UTC (rev 268520)
+++ trunk/Source/WebKit/ChangeLog	2020-10-15 11:36:46 UTC (rev 268521)
@@ -1,3 +1,31 @@
+2020-10-15  Youenn Fablet  <[email protected]>
+
+        Introduce a RemoteAudioSourceProvider to receive audio samples for web audio from GPUProcess
+        https://bugs.webkit.org/show_bug.cgi?id=217710
+
+        Reviewed by Eric Carlson.
+
+        Make use of WebAudioSourceProviderAVFObjC to implement RemoteAudioSourceProvider.
+        RemoteAudioSourceProvider currently implements an AudioSourceProvider but it is not yet connected to GPUProcess media players.
+        This will be implemented in a follow-up.
+
+        * SourcesCocoa.txt:
+        * WebKit.xcodeproj/project.pbxproj:
+        * WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp:
+        (WebKit::MediaPlayerPrivateRemote::~MediaPlayerPrivateRemote):
+        (WebKit::MediaPlayerPrivateRemote::audioSourceProvider):
+        * WebProcess/GPU/media/MediaPlayerPrivateRemote.h:
+        * WebProcess/GPU/media/RemoteAudioSourceProvider.cpp: Added.
+        (WebKit::RemoteAudioSourceProvider::create):
+        (WebKit::RemoteAudioSourceProvider::RemoteAudioSourceProvider):
+        (WebKit::RemoteAudioSourceProvider::~RemoteAudioSourceProvider):
+        (WebKit::RemoteAudioSourceProvider::close):
+        (WebKit::RemoteAudioSourceProvider::hasNewClient):
+        (WebKit::RemoteAudioSourceProvider::audioSamplesAvailable):
+        (WebKit::RemoteAudioSourceProvider::logChannel const):
+        * WebProcess/GPU/media/RemoteAudioSourceProvider.h: Added.
+        * WebProcess/GPU/media/cocoa/MediaPlayerPrivateRemoteCocoa.mm:
+
 2020-10-15  Adrian Perez de Castro  <[email protected]>
 
         Non-unified build fixes, mid October 2020, take two

Modified: trunk/Source/WebKit/SourcesCocoa.txt (268520 => 268521)


--- trunk/Source/WebKit/SourcesCocoa.txt	2020-10-15 11:32:32 UTC (rev 268520)
+++ trunk/Source/WebKit/SourcesCocoa.txt	2020-10-15 11:36:46 UTC (rev 268521)
@@ -564,6 +564,7 @@
 WebProcess/EntryPoint/Cocoa/XPCService/WebContentServiceEntryPoint.mm
 
 WebProcess/GPU/graphics/cocoa/ImageBufferShareableIOSurfaceBackend.cpp
+WebProcess/GPU/media/RemoteAudioSourceProvider.cpp
 WebProcess/GPU/media/cocoa/MediaPlayerPrivateRemoteCocoa.mm
 WebProcess/GPU/media/cocoa/VideoLayerRemoteCocoa.mm
 WebProcess/GPU/media/ios/RemoteMediaSessionHelper.cpp

Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (268520 => 268521)


--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2020-10-15 11:32:32 UTC (rev 268520)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2020-10-15 11:36:46 UTC (rev 268521)
@@ -3422,6 +3422,8 @@
 		41287D4B225C05C4009A3E26 /* WebSocketTaskCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebSocketTaskCocoa.mm; sourceTree = "<group>"; };
 		41287D4C225C05C5009A3E26 /* WebSocketTaskCocoa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSocketTaskCocoa.h; sourceTree = "<group>"; };
 		41287D4D225C161F009A3E26 /* WebSocketTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSocketTask.h; sourceTree = "<group>"; };
+		412FF91625373F9D001DF036 /* RemoteAudioSourceProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteAudioSourceProvider.cpp; sourceTree = "<group>"; };
+		412FF91725373F9D001DF036 /* RemoteAudioSourceProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteAudioSourceProvider.h; sourceTree = "<group>"; };
 		4130759A1DE84FB00039EC69 /* NetworkRTCMonitor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkRTCMonitor.cpp; sourceTree = "<group>"; };
 		4130759B1DE84FB00039EC69 /* NetworkRTCMonitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkRTCMonitor.h; sourceTree = "<group>"; };
 		4130759C1DE84FB00039EC69 /* NetworkRTCMonitor.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = NetworkRTCMonitor.messages.in; sourceTree = "<group>"; };
@@ -5564,6 +5566,8 @@
 				CDD5356F240DD34300F7B8C4 /* RemoteAudioSession.messages.in */,
 				CDBB49FC240D9A720017C292 /* RemoteAudioSessionConfiguration.h */,
 				CDBB49FB240D974A0017C292 /* RemoteAudioSessionIdentifier.h */,
+				412FF91625373F9D001DF036 /* RemoteAudioSourceProvider.cpp */,
+				412FF91725373F9D001DF036 /* RemoteAudioSourceProvider.h */,
 				CDAC20BF23FC2F750021DEE3 /* RemoteCDM.cpp */,
 				CDAC20BA23FC2F740021DEE3 /* RemoteCDM.h */,
 				CDAC20B823FC2F730021DEE3 /* RemoteCDMConfiguration.h */,

Modified: trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp (268520 => 268521)


--- trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp	2020-10-15 11:32:32 UTC (rev 268520)
+++ trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp	2020-10-15 11:36:46 UTC (rev 268521)
@@ -29,6 +29,7 @@
 #if ENABLE(GPU_PROCESS)
 
 #include "Logging.h"
+#include "RemoteAudioSourceProvider.h"
 #include "RemoteLegacyCDM.h"
 #include "RemoteLegacyCDMFactory.h"
 #include "RemoteLegacyCDMSession.h"
@@ -115,6 +116,11 @@
     m_videoLayerManager->didDestroyVideoLayer();
 #endif
     m_manager.deleteRemoteMediaPlayer(m_id);
+
+#if ENABLE(WEB_AUDIO) && PLATFORM(COCOA)
+    if (m_audioSourceProvider)
+        m_audioSourceProvider->close();
+#endif
 }
 
 void MediaPlayerPrivateRemote::setConfiguration(RemoteMediaPlayerConfiguration&& configuration, WebCore::SecurityOriginData&& documentSecurityOrigin)
@@ -924,8 +930,15 @@
 #if ENABLE(WEB_AUDIO)
 AudioSourceProvider* MediaPlayerPrivateRemote::audioSourceProvider()
 {
+#if PLATFORM(COCOA)
+    if (!m_audioSourceProvider)
+        m_audioSourceProvider = RemoteAudioSourceProvider::create(m_id, *this);
+
+    return m_audioSourceProvider.get();
+#else
     notImplemented();
     return nullptr;
+#endif
 }
 #endif
 

Modified: trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h (268520 => 268521)


--- trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h	2020-10-15 11:32:32 UTC (rev 268520)
+++ trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h	2020-10-15 11:36:46 UTC (rev 268521)
@@ -56,6 +56,7 @@
 
 namespace WebKit {
 
+class RemoteAudioSourceProvider;
 class UserData;
 struct TextTrackPrivateRemoteConfiguration;
 struct TrackPrivateRemoteConfiguration;
@@ -374,6 +375,10 @@
     RemoteMediaPlayerState m_cachedState;
     std::unique_ptr<WebCore::PlatformTimeRanges> m_cachedBufferedTimeRanges;
 
+#if ENABLE(WEB_AUDIO) && PLATFORM(COCOA)
+    RefPtr<RemoteAudioSourceProvider> m_audioSourceProvider;
+#endif
+
     HashMap<RemoteMediaResourceIdentifier, RefPtr<WebCore::PlatformMediaResource>> m_mediaResources;
     HashMap<TrackPrivateRemoteIdentifier, Ref<AudioTrackPrivateRemote>> m_audioTracks;
     HashMap<TrackPrivateRemoteIdentifier, Ref<VideoTrackPrivateRemote>> m_videoTracks;

Added: trunk/Source/WebKit/WebProcess/GPU/media/RemoteAudioSourceProvider.cpp (0 => 268521)


--- trunk/Source/WebKit/WebProcess/GPU/media/RemoteAudioSourceProvider.cpp	                        (rev 0)
+++ trunk/Source/WebKit/WebProcess/GPU/media/RemoteAudioSourceProvider.cpp	2020-10-15 11:36:46 UTC (rev 268521)
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "RemoteAudioSourceProvider.h"
+
+#if ENABLE(GPU_PROCESS) && ENABLE(WEB_AUDIO) && PLATFORM(COCOA)
+
+namespace WebCore {
+#if !RELEASE_LOG_DISABLED
+extern WTFLogChannel LogMedia;
+#endif
+}
+
+namespace WebKit {
+using namespace WebCore;
+
+Ref<RemoteAudioSourceProvider> RemoteAudioSourceProvider::create(WebCore::MediaPlayerIdentifier identifier, WTF::LoggerHelper& helper)
+{
+    return adoptRef(*new RemoteAudioSourceProvider(identifier, helper));
+}
+
+RemoteAudioSourceProvider::RemoteAudioSourceProvider(MediaPlayerIdentifier identifier, WTF::LoggerHelper& helper)
+    : m_identifier(identifier)
+#if !RELEASE_LOG_DISABLED
+    , m_logger(helper.logger())
+    , m_logIdentifier(helper.logIdentifier())
+#endif
+{
+    UNUSED_PARAM(helper);
+}
+
+RemoteAudioSourceProvider::~RemoteAudioSourceProvider()
+{
+}
+
+void RemoteAudioSourceProvider::close()
+{
+}
+
+void RemoteAudioSourceProvider::hasNewClient(AudioSourceProviderClient*)
+{
+    // FIXME: register/unregister as needed.
+}
+
+void RemoteAudioSourceProvider::audioSamplesAvailable(const PlatformAudioData& data, const AudioStreamDescription& description, size_t size)
+{
+    receivedNewAudioSamples(data, description, size);
+}
+
+#if !RELEASE_LOG_DISABLED
+WTFLogChannel& RemoteAudioSourceProvider::logChannel() const
+{
+    return LogMedia;
+}
+#endif
+
+} // namespace WebKit
+
+#endif // ENABLE(GPU_PROCESS) && ENABLE(WEB_AUDIO) && PLATFORM(COCOA)

Added: trunk/Source/WebKit/WebProcess/GPU/media/RemoteAudioSourceProvider.h (0 => 268521)


--- trunk/Source/WebKit/WebProcess/GPU/media/RemoteAudioSourceProvider.h	                        (rev 0)
+++ trunk/Source/WebKit/WebProcess/GPU/media/RemoteAudioSourceProvider.h	2020-10-15 11:36:46 UTC (rev 268521)
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(GPU_PROCESS) && ENABLE(WEB_AUDIO) && PLATFORM(COCOA)
+
+#include <WebCore/MediaPlayerIdentifier.h>
+#include <WebCore/WebAudioSourceProviderCocoa.h>
+#include <wtf/LoggerHelper.h>
+
+namespace WebKit {
+
+class RemoteAudioSourceProvider final
+    : public WebCore::WebAudioSourceProviderCocoa
+#if !RELEASE_LOG_DISABLED
+    , protected WTF::LoggerHelper
+#endif
+{
+public:
+    static Ref<RemoteAudioSourceProvider> create(WebCore::MediaPlayerIdentifier, WTF::LoggerHelper&);
+    ~RemoteAudioSourceProvider();
+
+    void audioSamplesAvailable(const WebCore::PlatformAudioData&, const WebCore::AudioStreamDescription&, size_t);
+    void close();
+
+    WebCore::MediaPlayerIdentifier identifier() const { return m_identifier; }
+
+private:
+    RemoteAudioSourceProvider(WebCore::MediaPlayerIdentifier, WTF::LoggerHelper&);
+
+    // WebCore::WebAudioSourceProviderCocoa
+    void hasNewClient(WebCore::AudioSourceProviderClient*) final;
+
+#if !RELEASE_LOG_DISABLED
+    WTF::LoggerHelper& loggerHelper() final { return *this; }
+
+    // WTF::LoggerHelper
+    const Logger& logger() const final { return m_logger.get(); }
+    const void* logIdentifier() const final { return m_logIdentifier; }
+    const char* logClassName() const final { return "RemoteAudioSourceProvider"; }
+    WTFLogChannel& logChannel() const final;
+#endif
+
+    WebCore::MediaPlayerIdentifier m_identifier;
+#if !RELEASE_LOG_DISABLED
+    Ref<const Logger> m_logger;
+    const void* m_logIdentifier;
+#endif
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(GPU_PROCESS) && ENABLE(WEB_AUDIO) && PLATFORM(COCOA)

Modified: trunk/Source/WebKit/WebProcess/GPU/media/cocoa/MediaPlayerPrivateRemoteCocoa.mm (268520 => 268521)


--- trunk/Source/WebKit/WebProcess/GPU/media/cocoa/MediaPlayerPrivateRemoteCocoa.mm	2020-10-15 11:32:32 UTC (rev 268520)
+++ trunk/Source/WebKit/WebProcess/GPU/media/cocoa/MediaPlayerPrivateRemoteCocoa.mm	2020-10-15 11:36:46 UTC (rev 268521)
@@ -28,6 +28,7 @@
 
 #if ENABLE(GPU_PROCESS) && PLATFORM(COCOA)
 
+#import "RemoteAudioSourceProvider.h"
 #import <WebCore/VideoLayerManagerObjC.h>
 #import <pal/spi/cocoa/QuartzCoreSPI.h>
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to