AudioMediaStreamTrackRendererCocoa does not recover from AudioSession interruption
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 Mar 2020 14:33:42 +0000 (14:33 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 Mar 2020 14:33:42 +0000 (14:33 +0000)
https://bugs.webkit.org/show_bug.cgi?id=209412

Reviewed by Eric Carlson.

In case there is an AudioSession interruption, like the app is in the background
and another app starts to play audio, AudioMediaStreamTrackRendererCocoa will not restart playing audio.
Fix this by clearing the AudioUnit when starting since the renderer is paused during the interruption.
This ensures resuming from the interruption in a clean state.

Manually tested.

* platform/mediastream/mac/AudioMediaStreamTrackRendererCocoa.cpp:
(WebCore::AudioMediaStreamTrackRendererCocoa::start):

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

Source/WebCore/ChangeLog
Source/WebCore/platform/mediastream/mac/AudioMediaStreamTrackRendererCocoa.cpp

index e8de9a9..4b37d40 100644 (file)
@@ -1,3 +1,20 @@
+2020-03-23  Youenn Fablet  <youenn@apple.com>
+
+        AudioMediaStreamTrackRendererCocoa does not recover from AudioSession interruption
+        https://bugs.webkit.org/show_bug.cgi?id=209412
+
+        Reviewed by Eric Carlson.
+
+        In case there is an AudioSession interruption, like the app is in the background
+        and another app starts to play audio, AudioMediaStreamTrackRendererCocoa will not restart playing audio.
+        Fix this by clearing the AudioUnit when starting since the renderer is paused during the interruption.
+        This ensures resuming from the interruption in a clean state.
+
+        Manually tested.
+
+        * platform/mediastream/mac/AudioMediaStreamTrackRendererCocoa.cpp:
+        (WebCore::AudioMediaStreamTrackRendererCocoa::start):
+
 2020-03-23  youenn fablet  <youenn@apple.com>
 
         MediaDevices::refreshDevices should take device type into account
index 7cd3165..19dc4a9 100644 (file)
@@ -45,6 +45,8 @@ AudioMediaStreamTrackRendererCocoa::~AudioMediaStreamTrackRendererCocoa() = defa
 
 void AudioMediaStreamTrackRendererCocoa::start()
 {
+    clear();
+
     m_shouldPlay = true;
 
     if (m_dataSource)