RealtimeOutgoingAudioSourceCocoa should unobserve its source at destruction time
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 Nov 2018 16:14:27 +0000 (16:14 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 Nov 2018 16:14:27 +0000 (16:14 +0000)
https://bugs.webkit.org/show_bug.cgi?id=191295

Reviewed by Eric Carlson.

Make RealtimeOutgoingAudioSource subclasses unobserve their source
inside their destructor instead of RealtimeOutgoingAudioSource.
This is consistent with how starting to observe works.
Covered by existing tests.

* platform/mediastream/RealtimeOutgoingAudioSource.cpp:
(WebCore::RealtimeOutgoingAudioSource::unobserveSource):
* platform/mediastream/RealtimeOutgoingAudioSource.h:
* platform/mediastream/gstreamer/RealtimeOutgoingAudioSourceLibWebRTC.cpp:
(WebCore::RealtimeOutgoingAudioSourceLibWebRTC::~RealtimeOutgoingAudioSourceLibWebRTC):
* platform/mediastream/mac/RealtimeOutgoingAudioSourceCocoa.cpp:
(WebCore::RealtimeOutgoingAudioSourceCocoa::RealtimeOutgoingAudioSourceCocoa):
(WebCore::RealtimeOutgoingAudioSourceCocoa::~RealtimeOutgoingAudioSourceCocoa):
* platform/mediastream/mac/RealtimeOutgoingAudioSourceCocoa.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237867 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/mediastream/RealtimeOutgoingAudioSource.cpp
Source/WebCore/platform/mediastream/RealtimeOutgoingAudioSource.h
Source/WebCore/platform/mediastream/gstreamer/RealtimeOutgoingAudioSourceLibWebRTC.cpp
Source/WebCore/platform/mediastream/mac/RealtimeOutgoingAudioSourceCocoa.cpp
Source/WebCore/platform/mediastream/mac/RealtimeOutgoingAudioSourceCocoa.h

index 00bd449..a05adf5 100644 (file)
@@ -1,5 +1,27 @@
 2018-11-06  Youenn Fablet  <youenn@apple.com>
 
+        RealtimeOutgoingAudioSourceCocoa should unobserve its source at destruction time
+        https://bugs.webkit.org/show_bug.cgi?id=191295
+
+        Reviewed by Eric Carlson.
+
+        Make RealtimeOutgoingAudioSource subclasses unobserve their source
+        inside their destructor instead of RealtimeOutgoingAudioSource.
+        This is consistent with how starting to observe works.
+        Covered by existing tests.
+
+        * platform/mediastream/RealtimeOutgoingAudioSource.cpp:
+        (WebCore::RealtimeOutgoingAudioSource::unobserveSource):
+        * platform/mediastream/RealtimeOutgoingAudioSource.h:
+        * platform/mediastream/gstreamer/RealtimeOutgoingAudioSourceLibWebRTC.cpp:
+        (WebCore::RealtimeOutgoingAudioSourceLibWebRTC::~RealtimeOutgoingAudioSourceLibWebRTC):
+        * platform/mediastream/mac/RealtimeOutgoingAudioSourceCocoa.cpp:
+        (WebCore::RealtimeOutgoingAudioSourceCocoa::RealtimeOutgoingAudioSourceCocoa):
+        (WebCore::RealtimeOutgoingAudioSourceCocoa::~RealtimeOutgoingAudioSourceCocoa):
+        * platform/mediastream/mac/RealtimeOutgoingAudioSourceCocoa.h:
+
+2018-11-06  Youenn Fablet  <youenn@apple.com>
+
         Make sure RTCIceCandidateStats address is undefined for host and peer reflexive case
         https://bugs.webkit.org/show_bug.cgi?id=191263
 
index afa13e1..5ef7444 100644 (file)
@@ -47,6 +47,11 @@ void RealtimeOutgoingAudioSource::observeSource()
     initializeConverter();
 }
 
+void RealtimeOutgoingAudioSource::unobserveSource()
+{
+    m_audioSource->removeObserver(*this);
+}
+
 bool RealtimeOutgoingAudioSource::setSource(Ref<MediaStreamTrackPrivate>&& newSource)
 {
     m_audioSource->removeObserver(*this);
index 8651ed1..694bdae 100644 (file)
@@ -65,6 +65,7 @@ protected:
     explicit RealtimeOutgoingAudioSource(Ref<MediaStreamTrackPrivate>&&);
 
     void observeSource();
+    void unobserveSource();
 
     virtual void pullAudioData() { }
 
index 0120ac0..060fc10 100644 (file)
@@ -39,6 +39,7 @@ RealtimeOutgoingAudioSourceLibWebRTC::RealtimeOutgoingAudioSourceLibWebRTC(Ref<M
 
 RealtimeOutgoingAudioSourceLibWebRTC::~RealtimeOutgoingAudioSourceLibWebRTC()
 {
+    unobserveSource();
     if (m_sampleConverter)
         g_clear_pointer(&m_sampleConverter, gst_audio_converter_free);
 }
index c0ea324..2fbe067 100644 (file)
@@ -50,6 +50,11 @@ RealtimeOutgoingAudioSourceCocoa::RealtimeOutgoingAudioSourceCocoa(Ref<MediaStre
     observeSource();
 }
 
+RealtimeOutgoingAudioSourceCocoa::~RealtimeOutgoingAudioSourceCocoa()
+{
+    unobserveSource();
+}
+
 Ref<RealtimeOutgoingAudioSource> RealtimeOutgoingAudioSource::create(Ref<MediaStreamTrackPrivate>&& audioSource)
 {
     return RealtimeOutgoingAudioSourceCocoa::create(WTFMove(audioSource));
index 8500c53..74b7469 100644 (file)
@@ -43,6 +43,7 @@ public:
 
 private:
     explicit RealtimeOutgoingAudioSourceCocoa(Ref<MediaStreamTrackPrivate>&&);
+    ~RealtimeOutgoingAudioSourceCocoa();
 
     void audioSamplesAvailable(const MediaTime&, const PlatformAudioData&, const AudioStreamDescription&, size_t) final;