playbin/playbin3: Allow setting a NULL URI

The URI is already initialized to NULL at the beginning and GstPlayer
was assuming that it is possible to set to NULL at a later time too.

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/1124

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2090>
This commit is contained in:
Sebastian Dröge 2022-04-01 10:25:23 +03:00
parent b358897a3b
commit 16ed0a6961
2 changed files with 18 additions and 18 deletions

View file

@ -1670,12 +1670,7 @@ gst_play_bin_set_uri (GstPlayBin * playbin, const gchar * uri)
{
GstSourceGroup *group;
if (uri == NULL) {
g_warning ("cannot set NULL uri");
return;
}
if (!gst_playbin_uri_is_valid (playbin, uri)) {
if (uri && !gst_playbin_uri_is_valid (playbin, uri)) {
if (g_str_has_prefix (uri, "file:")) {
GST_WARNING_OBJECT (playbin, "not entirely correct file URI '%s' - make "
"sure to escape spaces and non-ASCII characters properly and specify "
@ -1692,11 +1687,16 @@ gst_play_bin_set_uri (GstPlayBin * playbin, const gchar * uri)
GST_SOURCE_GROUP_LOCK (group);
/* store the uri in the next group we will play */
g_free (group->uri);
if (uri) {
group->uri = g_strdup (uri);
group->valid = TRUE;
} else {
group->uri = NULL;
group->valid = FALSE;
}
GST_SOURCE_GROUP_UNLOCK (group);
GST_DEBUG ("set new uri to %s", uri);
GST_DEBUG ("set new uri to %s", GST_STR_NULL (uri));
GST_PLAY_BIN_UNLOCK (playbin);
}

View file

@ -1476,12 +1476,7 @@ gst_play_bin3_set_uri (GstPlayBin3 * playbin, const gchar * uri)
{
GstSourceGroup *group;
if (uri == NULL) {
g_warning ("cannot set NULL uri");
return;
}
if (!gst_playbin_uri_is_valid (playbin, uri)) {
if (uri && !gst_playbin_uri_is_valid (playbin, uri)) {
if (g_str_has_prefix (uri, "file:")) {
GST_WARNING_OBJECT (playbin, "not entirely correct file URI '%s' - make "
"sure to escape spaces and non-ASCII characters properly and specify "
@ -1498,11 +1493,16 @@ gst_play_bin3_set_uri (GstPlayBin3 * playbin, const gchar * uri)
GST_SOURCE_GROUP_LOCK (group);
/* store the uri in the next group we will play */
g_free (group->uri);
if (uri) {
group->uri = g_strdup (uri);
group->valid = TRUE;
} else {
group->uri = NULL;
group->valid = FALSE;
}
GST_SOURCE_GROUP_UNLOCK (group);
GST_DEBUG ("set new uri to %s", uri);
GST_DEBUG ("set new uri to %s", GST_STR_NULL (uri));
GST_PLAY_BIN3_UNLOCK (playbin);
}