Skip to content

Commit 237a430

Browse files
committed
Rialto with WebKit audio sink https://bugs.webkit.org/show_bug.cgi?id=278911
Reviewed by Philippe Normand. Rialto supports single instance of webaudio pcm sing so it is not possible to create more than one WebAudio context. Use WebKit audio sink instead, that mixes all webaudio contextes into single stream and pass it to rialto webaudio sink. With webkit 2.38 webaudio src element produce 'non-interleaved' audio format that is not fully supported by some platform sinks (audio output is breaking). WebKit audio sink (mixer pipeline) also doesn't seem to handle that correctly. Mixer pipeline fails to negotiate caps and inter audio sink reqires the latest gst version to work with such stream. Patch by Andrzej Surdej <Andrzej_Surdej@comcast.com>. * Source/WebCore/platform/audio/gstreamer/AudioDestinationGStreamer.cpp: (WebCore::AudioDestinationGStreamer::AudioDestinationGStreamer): * Source/WebCore/platform/gstreamer/GStreamerQuirkRialto.cpp: (WebCore::GStreamerQuirkRialto::createWebAudioSink): Canonical link: https://commits.webkit.org/283137@main
1 parent 2b4e92d commit 237a430

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

Source/WebCore/platform/audio/gstreamer/AudioDestinationGStreamer.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,24 @@ AudioDestinationGStreamer::AudioDestinationGStreamer(AudioIOCallback& callback,
157157

158158
gst_bin_add_many(GST_BIN_CAST(m_pipeline.get()), m_src.get(), audioConvert, audioResample, queue, audioSink.get(), nullptr);
159159

160-
// Link src pads from webkitAudioSrc to audioConvert ! audioResample ! queue ! autoaudiosink.
160+
// Link src pads from webkitAudioSrc to audioConvert ! audioResample ! [capsfilter !] queue ! autoaudiosink.
161161
gst_element_link_pads_full(m_src.get(), "src", audioConvert, "sink", GST_PAD_LINK_CHECK_NOTHING);
162162
gst_element_link_pads_full(audioConvert, "src", audioResample, "sink", GST_PAD_LINK_CHECK_NOTHING);
163-
gst_element_link_pads_full(audioResample, "src", queue, "sink", GST_PAD_LINK_CHECK_NOTHING);
163+
164+
if (!webkitGstCheckVersion(1, 20, 4)) {
165+
// Force audio conversion to 'interleaved' format (by audioconvert element).
166+
// 1) Some platform sinks don't support non-interleaved audio without special caps (rialtowebaudiosink).
167+
// 2) Interaudio sink/src doesn't fully support non-interleaved audio (webkit audio sink)
168+
// 3) audiomixer doesn't support non-interleaved audio in output pipeline (webkit audio sink)
169+
GstElement* capsFilter = makeGStreamerElement("capsfilter", nullptr);
170+
GRefPtr<GstCaps> caps = adoptGRef(gst_caps_new_simple("audio/x-raw", "layout", G_TYPE_STRING, "interleaved", nullptr));
171+
g_object_set(capsFilter, "caps", caps.get(), nullptr);
172+
gst_bin_add(GST_BIN_CAST(m_pipeline.get()), capsFilter);
173+
gst_element_link_pads_full(audioResample, "src", capsFilter, "sink", GST_PAD_LINK_CHECK_NOTHING);
174+
gst_element_link_pads_full(capsFilter, "src", queue, "sink", GST_PAD_LINK_CHECK_NOTHING);
175+
} else
176+
gst_element_link_pads_full(audioResample, "src", queue, "sink", GST_PAD_LINK_CHECK_NOTHING);
177+
164178
gst_element_link_pads_full(queue, "src", audioSink.get(), "sink", GST_PAD_LINK_CHECK_NOTHING);
165179
}
166180

Source/WebCore/platform/gstreamer/GStreamerQuirkRialto.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#if USE(GSTREAMER)
3030

3131
#include "GStreamerCommon.h"
32+
#include "WebKitAudioSinkGStreamer.h"
3233
#include <wtf/OptionSet.h>
3334

3435
namespace WebCore {
@@ -95,6 +96,9 @@ GstElement* GStreamerQuirkRialto::createAudioSink()
9596

9697
GstElement* GStreamerQuirkRialto::createWebAudioSink()
9798
{
99+
if (GstElement* sink = webkitAudioSinkNew())
100+
return sink;
101+
98102
auto sink = makeGStreamerElement("rialtowebaudiosink", nullptr);
99103
RELEASE_ASSERT_WITH_MESSAGE(sink, "rialtowebaudiosink should be available in the system but it is not");
100104
return sink;

0 commit comments

Comments
 (0)