Skip to content

Commit

Permalink
[GStreamer] MediaPlayer's codecs hashmap needs protection
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=264707

Reviewed by Xabier Rodriguez-Calvar.

The m_codecs HashMap can be accessed from multiple threads, so it needs to be protected by a mutex.

* Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::MediaPlayerPrivateGStreamer::setupCodecProbe):
(WebCore::MediaPlayerPrivateGStreamer::codecForStreamId):
* Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h:

Canonical link: https://commits.webkit.org/270629@main
  • Loading branch information
philn committed Nov 13, 2023
1 parent 749c582 commit 9c761fd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3073,7 +3073,10 @@ void MediaPlayerPrivateGStreamer::setupCodecProbe(GstElement* element)
}

GST_INFO_OBJECT(player->pipeline(), "Setting codec for stream %s to %s", streamId.get(), codec.get());
player->m_codecs.add(String::fromLatin1(streamId.get()), String::fromLatin1(codec.get()));
{
Locker locker { player->m_codecsLock };
player->m_codecs.add(String::fromLatin1(streamId.get()), String::fromLatin1(codec.get()));
}
return GST_PAD_PROBE_REMOVE;
}), this, nullptr);
#else
Expand Down Expand Up @@ -4477,6 +4480,7 @@ void MediaPlayerPrivateGStreamer::checkPlayingConsistency()

String MediaPlayerPrivateGStreamer::codecForStreamId(const String& streamId)
{
Locker locker { m_codecsLock };
if (UNLIKELY(!m_codecs.contains(streamId)))
return emptyString();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,8 @@ class MediaPlayerPrivateGStreamer : public MediaPlayerPrivateInterface
MediaTime m_pausedTime;

void setupCodecProbe(GstElement*);
HashMap<String, String> m_codecs;
Lock m_codecsLock;
HashMap<String, String> m_codecs WTF_GUARDED_BY_LOCK(m_codecsLock);

bool isSeamlessSeekingEnabled() const { return m_seekFlags & (1 << GST_SEEK_FLAG_SEGMENT); }

Expand Down

0 comments on commit 9c761fd

Please sign in to comment.