Title: [228875] trunk/Source/WebCore
- Revision
- 228875
- Author
- [email protected]
- Date
- 2018-02-21 09:00:53 -0800 (Wed, 21 Feb 2018)
Log Message
[GStreamer] Rewrite purgeInvalid*Tracks methods
https://bugs.webkit.org/show_bug.cgi?id=183004
Reviewed by Carlos Garcia Campos.
Removing items from a hashmap while iterating is bad.
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::MediaPlayerPrivateGStreamer::purgeInvalidAudioTracks):
Safely remove items from the hashmap using removeIf().
(WebCore::MediaPlayerPrivateGStreamer::purgeInvalidVideoTracks): Ditto.
(WebCore::MediaPlayerPrivateGStreamer::purgeInvalidTextTracks): Ditto.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (228874 => 228875)
--- trunk/Source/WebCore/ChangeLog 2018-02-21 17:00:21 UTC (rev 228874)
+++ trunk/Source/WebCore/ChangeLog 2018-02-21 17:00:53 UTC (rev 228875)
@@ -1,3 +1,18 @@
+2018-02-21 Philippe Normand <[email protected]>
+
+ [GStreamer] Rewrite purgeInvalid*Tracks methods
+ https://bugs.webkit.org/show_bug.cgi?id=183004
+
+ Reviewed by Carlos Garcia Campos.
+
+ Removing items from a hashmap while iterating is bad.
+
+ * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
+ (WebCore::MediaPlayerPrivateGStreamer::purgeInvalidAudioTracks):
+ Safely remove items from the hashmap using removeIf().
+ (WebCore::MediaPlayerPrivateGStreamer::purgeInvalidVideoTracks): Ditto.
+ (WebCore::MediaPlayerPrivateGStreamer::purgeInvalidTextTracks): Ditto.
+
2018-02-21 Chris Dumez <[email protected]>
Unreviewed attempt to fix build after r228867.
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp (228874 => 228875)
--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp 2018-02-21 17:00:21 UTC (rev 228874)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp 2018-02-21 17:00:53 UTC (rev 228875)
@@ -1455,50 +1455,23 @@
void MediaPlayerPrivateGStreamer::purgeInvalidAudioTracks(Vector<String> validTrackIds)
{
- if (validTrackIds.isEmpty()) {
- m_audioTracks.clear();
- return;
- }
- for (auto audioTrackId : m_audioTracks.keys()) {
- if (validTrackIds.contains(audioTrackId))
- continue;
- auto track = m_audioTracks.get(audioTrackId);
- track->disconnect();
- m_player->removeAudioTrack(*track);
- m_audioTracks.remove(audioTrackId);
- }
+ m_audioTracks.removeIf([validTrackIds](auto& keyAndValue) {
+ return !validTrackIds.contains(keyAndValue.key);
+ });
}
void MediaPlayerPrivateGStreamer::purgeInvalidVideoTracks(Vector<String> validTrackIds)
{
- if (validTrackIds.isEmpty()) {
- m_videoTracks.clear();
- return;
- }
- for (auto videoTrackId : m_videoTracks.keys()) {
- if (validTrackIds.contains(videoTrackId))
- continue;
- auto track = m_videoTracks.get(videoTrackId);
- track->disconnect();
- m_player->removeVideoTrack(*track);
- m_videoTracks.remove(videoTrackId);
- }
+ m_videoTracks.removeIf([validTrackIds](auto& keyAndValue) {
+ return !validTrackIds.contains(keyAndValue.key);
+ });
}
void MediaPlayerPrivateGStreamer::purgeInvalidTextTracks(Vector<String> validTrackIds)
{
- if (validTrackIds.isEmpty()) {
- m_textTracks.clear();
- return;
- }
- for (auto textTrackId : m_textTracks.keys()) {
- if (validTrackIds.contains(textTrackId))
- continue;
- auto track = m_textTracks.get(textTrackId);
- track->disconnect();
- m_player->removeTextTrack(*track);
- m_textTracks.remove(textTrackId);
- }
+ m_textTracks.removeIf([validTrackIds](auto& keyAndValue) {
+ return !validTrackIds.contains(keyAndValue.key);
+ });
}
#endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes