Skip to content

Commit 7c28049

Browse files
committed
[GStreamer] Fix audio sink detection in custom platforms
https://bugs.webkit.org/show_bug.cgi?id=269782 Reviewed by Philippe Normand. Sometimes we can get a message from a new audio sink that we should store as such even when we already have one. Based on a patch by Pawel Lampe <pawel.lampe@gmail.com>. * Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp: (WebCore::MediaPlayerPrivateGStreamer::handleMessage): Canonical link: https://commits.webkit.org/275037@main
1 parent ee188e8 commit 7c28049

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1915,15 +1915,13 @@ void MediaPlayerPrivateGStreamer::handleMessage(GstMessage* message)
19151915

19161916
#if PLATFORM(BROADCOM) || USE(WESTEROS_SINK) || PLATFORM(AMLOGIC) || PLATFORM(REALTEK)
19171917
if (currentState <= GST_STATE_READY && newState >= GST_STATE_READY) {
1918-
// If we didn't create an audio sink, store a reference to the created one.
1919-
if (!m_audioSink) {
1920-
// Detect an audio sink element.
1921-
GstElement* element = GST_ELEMENT(GST_MESSAGE_SRC(message));
1922-
if (GST_OBJECT_FLAG_IS_SET(element, GST_ELEMENT_FLAG_SINK)) {
1923-
const gchar* klassStr = gst_element_get_metadata(element, "klass");
1924-
if (strstr(klassStr, "Sink") && strstr(klassStr, "Audio"))
1925-
m_audioSink = element;
1926-
}
1918+
// Detect an audio sink element and store reference to it if it supersedes what we currently have.
1919+
GstElement* element = GST_ELEMENT(GST_MESSAGE_SRC(message));
1920+
if (GST_OBJECT_FLAG_IS_SET(element, GST_ELEMENT_FLAG_SINK)) {
1921+
const gchar* klassStr = gst_element_get_metadata(element, "klass");
1922+
if (g_strrstr(klassStr, "Sink") && g_strrstr(klassStr, "Audio")
1923+
&& (!m_audioSink || (m_audioSink.get() != element && GST_STATE(m_audioSink.get()) == GST_STATE_NULL)))
1924+
m_audioSink = element;
19271925
}
19281926
}
19291927
#endif

0 commit comments

Comments
 (0)