adaptivedemux2: Don't use g_str_equal on potentially NULL strings

It is only meant to be used as a callback. The fallback macro uses strcmp which
doesn't handle NULL strings gracefully. Instead use g_strcmp0

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6392>
This commit is contained in:
Edward Hervey 2024-03-18 15:07:28 +01:00 committed by GStreamer Marge Bot
parent ab11c20d59
commit 3d500636a9
6 changed files with 10 additions and 10 deletions

View file

@ -309,7 +309,7 @@ gst_hls_demux_playlist_loader_has_current_uri (GstHLSDemuxPlaylistLoader * pl,
target_playlist_uri = priv->target_playlist_uri;
if (priv->current_playlist == NULL
|| !g_str_equal (target_playlist_uri, priv->current_playlist_uri))
|| g_strcmp0 (target_playlist_uri, priv->current_playlist_uri))
return FALSE;
return TRUE;
@ -496,7 +496,7 @@ on_download_complete (DownloadRequest * download, DownloadRequestState state,
return;
}
if (!g_str_equal (priv->target_playlist_uri, priv->loading_playlist_uri)) {
if (g_strcmp0 (priv->target_playlist_uri, priv->loading_playlist_uri)) {
/* This callback happened just as the playlist URI was updated. There should be
* a pending state update scheduled, but we can just kick off the new download
* immediately */
@ -796,7 +796,7 @@ gst_hls_demux_playlist_loader_update (GstHLSDemuxPlaylistLoader * pl)
/* A download is in progress, but if we reach here it's
* because the target playlist URI got updated, so check
* for cancelling the current download. */
if (g_str_equal (priv->target_playlist_uri, priv->current_playlist_uri))
if (!g_strcmp0 (priv->target_playlist_uri, priv->current_playlist_uri))
break;
/* A download is in progress. Cancel it and trigger a new one */

View file

@ -521,7 +521,7 @@ gst_hls_demux_preloader_provide_request (GstHLSDemuxPreloader * preloader,
g_ptr_array_index (preloader->active_preloads, idx);
GstM3U8PreloadHint *hint = preload_req->hint;
if (!g_str_equal (hint->uri, target_req->uri))
if (g_strcmp0 (hint->uri, target_req->uri))
continue;
GST_LOG ("Possible matching preload type %d uri: %s, range start:%"

View file

@ -1396,7 +1396,7 @@ gst_hls_demux_stream_handle_playlist_update (GstHLSDemuxStream * stream,
} else if (stream->pending_rendition) {
/* Switching rendition configures a new playlist on the loader,
* and we should never get a callback for a stale download URI */
g_assert (g_str_equal (stream->pending_rendition->uri, new_playlist_uri));
g_assert (!g_strcmp0 (stream->pending_rendition->uri, new_playlist_uri));
gst_hls_rendition_stream_unref (stream->current_rendition);
/* Stealing ref */

View file

@ -539,7 +539,7 @@ gst_hlsdemux_handle_content_id3 (GstHLSDemux * demux,
if (!gst_tag_list_get_sample (taglist, GST_TAG_PRIVATE_DATA, &priv_data))
goto out;
if (!g_str_equal ("com.apple.streaming.transportStreamTimestamp",
if (g_strcmp0 ("com.apple.streaming.transportStreamTimestamp",
gst_structure_get_string (gst_sample_get_info (priv_data), "owner")))
goto out;

View file

@ -1085,7 +1085,7 @@ gst_hls_demux_handle_variant_playlist_update (GstHLSDemux * demux,
if (demux->pending_variant) {
/* The pending variant must always match the one that just got updated:
* The loader should only do a callback for the most recently set URI */
g_assert (g_str_equal (demux->pending_variant->uri, playlist_uri));
g_assert (!g_strcmp0 (demux->pending_variant->uri, playlist_uri));
gboolean changed = (demux->pending_variant != demux->current_variant);
@ -1162,7 +1162,7 @@ gst_hls_demux_handle_variant_playlist_update_error (GstHLSDemux * demux,
/* The variant must always match the one that just got updated:
* The loader should only do a callback for the most recently set URI */
g_assert (g_str_equal (variant->uri, playlist_uri));
g_assert (!g_strcmp0 (variant->uri, playlist_uri));
/* If we didn't already add this playlist to the failed variants list
* do so now. It's possible we get an update error again if we failed

View file

@ -174,7 +174,7 @@ gst_m3u8_preload_hint_equal (GstM3U8PreloadHint * hint1,
if (hint1->hint_type != hint2->hint_type)
return FALSE;
if (!g_str_equal (hint1->uri, hint2->uri))
if (g_strcmp0 (hint1->uri, hint2->uri))
return FALSE;
if (hint1->offset != hint2->offset)
@ -235,7 +235,7 @@ gst_m3u8_init_file_equal (const GstM3U8InitFile * ifile1,
if (ifile1 != NULL && ifile2 == NULL)
return FALSE;
if (!g_str_equal (ifile1->uri, ifile2->uri))
if (g_strcmp0 (ifile1->uri, ifile2->uri))
return FALSE;
if (ifile1->offset != ifile2->offset)
return FALSE;