Skip to content

Commit 33bfbb4

Browse files
committed
[MSE][GStreamer] Avoid changing ref count of trackId string from non-main thread
StringImpl's ref count in not thread safe.
1 parent 59d63a5 commit 33bfbb4

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

Source/WebCore/platform/graphics/gstreamer/mse/MediaSourceTrackGStreamer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class MediaSourceTrackGStreamer final: public ThreadSafeRefCounted<MediaSourceTr
4545
virtual ~MediaSourceTrackGStreamer();
4646

4747
TrackPrivateBaseGStreamer::TrackType type() const { return m_type; }
48-
AtomString trackId() const { return m_trackId; }
48+
const AtomString& trackId() const { return m_trackId; }
4949
GRefPtr<GstCaps>& initialCaps() { return m_initialCaps; }
5050
DataMutex<TrackQueue>& queueDataMutex() { return m_queueDataMutex; }
5151

Source/WebCore/platform/graphics/gstreamer/mse/SourceBufferPrivateGStreamer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,12 @@ void SourceBufferPrivateGStreamer::notifyClientWhenReadyForMoreSamples(const Ato
185185
ASSERT(isMainThread());
186186
ASSERT(m_tracks.contains(trackId));
187187
MediaSourceTrackGStreamer* track = m_tracks.get(trackId);
188-
track->notifyWhenReadyForMoreSamples([weakPtr = WeakPtr { *this }, this, trackId]() mutable {
189-
RunLoop::main().dispatch([weakPtr = WTFMove(weakPtr), this, trackId]() {
188+
track->notifyWhenReadyForMoreSamples([weakPtr = WeakPtr { *this }, this, trackId = trackId.string().isolatedCopy()]() mutable {
189+
RunLoop::main().dispatch([weakPtr = WTFMove(weakPtr), this, trackId = WTFMove(trackId)]() {
190190
if (!weakPtr)
191191
return;
192192
if (!m_hasBeenRemovedFromMediaSource)
193-
provideMediaData(trackId);
193+
provideMediaData(AtomString{ trackId });
194194
});
195195
});
196196
}

0 commit comments

Comments
 (0)