[GStreamer][WebAudio] Winamp2-js woes
authorphiln@webkit.org <philn@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 9 Feb 2018 16:48:53 +0000 (16:48 +0000)
committerphiln@webkit.org <philn@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 9 Feb 2018 16:48:53 +0000 (16:48 +0000)
https://bugs.webkit.org/show_bug.cgi?id=182612

Reviewed by Xabier Rodriguez Calvar and Carlos Alberto Lopez Perez.

Source/WebCore:

Test: webaudio/silence-after-playback.html

* platform/audio/gstreamer/AudioSourceProviderGStreamer.cpp:
(WebCore::copyGStreamerBuffersToAudioChannel): Clear the bus if
the adapter can't provide enough data. This prevents a nasty noise
after playing songs in Winamp.
(WebCore::AudioSourceProviderGStreamer::setClient): No need to set
the client more than once, this fixes runtime warnings.

LayoutTests:

* webaudio/silence-after-playback-expected.wav: Added.
* webaudio/silence-after-playback.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/platform/gtk/webaudio/silence-after-playback-expected.wav [new file with mode: 0644]
LayoutTests/platform/mac/webaudio/silence-after-playback-expected.wav [new file with mode: 0644]
LayoutTests/webaudio/silence-after-playback.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/audio/gstreamer/AudioSourceProviderGStreamer.cpp

index b0ff036..1f64346 100644 (file)
@@ -1,3 +1,13 @@
+2018-02-09  Philippe Normand  <pnormand@igalia.com>
+
+        [GStreamer][WebAudio] Winamp2-js woes
+        https://bugs.webkit.org/show_bug.cgi?id=182612
+
+        Reviewed by Xabier Rodriguez Calvar and Carlos Alberto Lopez Perez.
+
+        * webaudio/silence-after-playback-expected.wav: Added.
+        * webaudio/silence-after-playback.html: Added.
+
 2018-02-09  Javier Fernandez  <jfernandez@igalia.com>
 
         [css-align] Implement the new behavior of 'legacy' for justify-items
diff --git a/LayoutTests/platform/gtk/webaudio/silence-after-playback-expected.wav b/LayoutTests/platform/gtk/webaudio/silence-after-playback-expected.wav
new file mode 100644 (file)
index 0000000..7cf5a42
Binary files /dev/null and b/LayoutTests/platform/gtk/webaudio/silence-after-playback-expected.wav differ
diff --git a/LayoutTests/platform/mac/webaudio/silence-after-playback-expected.wav b/LayoutTests/platform/mac/webaudio/silence-after-playback-expected.wav
new file mode 100644 (file)
index 0000000..41c9475
Binary files /dev/null and b/LayoutTests/platform/mac/webaudio/silence-after-playback-expected.wav differ
diff --git a/LayoutTests/webaudio/silence-after-playback.html b/LayoutTests/webaudio/silence-after-playback.html
new file mode 100644 (file)
index 0000000..adaf316
--- /dev/null
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <script src="../resources/js-test.js"></script>
+        <script src="resources/audio-testing.js"></script>
+    </head>
+
+    <body>
+        <div id="description"></div>
+        <div id="console"></div>
+
+        <script>
+         description("Test ensuring silence is output after <audio> playback ended.");
+
+         let context = 0;
+         const sampleRate = 44100.0;
+         const lengthInSeconds = 3;
+
+         function ended() {
+             context.startRendering();
+             context.oncomplete = finishAudioTest;
+         }
+
+         function runTest() {
+             context = new webkitOfflineAudioContext(2, sampleRate * lengthInSeconds, sampleRate);
+
+             audioElement = new Audio();
+             audioElement.src = "resources/media/128kbps-44khz.mp3";
+             document.body.appendChild(audioElement);
+
+             mediaSource = context.createMediaElementSource(audioElement);
+             window.audioNode = mediaSource;
+
+             mediaSource.connect(context.destination);
+
+             audioElement.play();
+             audioElement.addEventListener("ended", ended, true);
+             testRunner.waitUntilDone();
+         }
+
+         runTest();
+        </script>
+    </body>
+</html>
index b4f9b02..b0319d5 100644 (file)
@@ -1,3 +1,19 @@
+2018-02-08  Philippe Normand  <pnormand@igalia.com>
+
+        [GStreamer][WebAudio] Winamp2-js woes
+        https://bugs.webkit.org/show_bug.cgi?id=182612
+
+        Reviewed by Xabier Rodriguez Calvar and Carlos Alberto Lopez Perez.
+
+        Test: webaudio/silence-after-playback.html
+
+        * platform/audio/gstreamer/AudioSourceProviderGStreamer.cpp:
+        (WebCore::copyGStreamerBuffersToAudioChannel): Clear the bus if
+        the adapter can't provide enough data. This prevents a nasty noise
+        after playing songs in Winamp.
+        (WebCore::AudioSourceProviderGStreamer::setClient): No need to set
+        the client more than once, this fixes runtime warnings.
+
 2018-02-09  Zalan Bujtas  <zalan@apple.com>
 
         [RenderTreeBuilder] Move multicolumn spanner mutation logic to RenderTreeBuilder
index 16bbf59..4d7e3e4 100644 (file)
@@ -79,7 +79,8 @@ static void copyGStreamerBuffersToAudioChannel(GstAdapter* adapter, AudioBus* bu
     if (gst_adapter_available(adapter) >= bytes) {
         gst_adapter_copy(adapter, bus->channel(channelNumber)->mutableData(), 0, bytes);
         gst_adapter_flush(adapter, bytes);
-    }
+    } else
+        bus->zero();
 }
 
 AudioSourceProviderGStreamer::AudioSourceProviderGStreamer()
@@ -201,6 +202,9 @@ GstFlowReturn AudioSourceProviderGStreamer::handleAudioBuffer(GstAppSink* sink)
 
 void AudioSourceProviderGStreamer::setClient(AudioSourceProviderClient* client)
 {
+    if (m_client)
+        return;
+
     ASSERT(client);
     m_client = client;