Skip to content

Commit

Permalink
clapper: media-item: Fix construct with NULL as "cache-location"
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafostar committed Jun 28, 2024
1 parent 2843a17 commit 147399a
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/lib/clapper/clapper-media-item.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ clapper_media_item_new_cached (const gchar *uri, const gchar *location)
{
ClapperMediaItem *item = clapper_media_item_new (uri);

if (G_LIKELY (item != NULL) && location)
if (location && G_LIKELY (item != NULL))
clapper_media_item_set_cache_location (item, location);

return item;
Expand Down Expand Up @@ -486,9 +486,13 @@ clapper_media_item_update_from_discoverer_info (ClapperMediaItem *self, GstDisco
void
clapper_media_item_set_cache_location (ClapperMediaItem *self, const gchar *location)
{
g_free (self->cache_uri);
self->cache_uri = g_filename_to_uri (location, NULL, NULL);
GST_DEBUG_OBJECT (self, "Set cache URI: \"%s\"", self->cache_uri);
g_clear_pointer (&self->cache_uri, g_free);

if (location)
self->cache_uri = g_filename_to_uri (location, NULL, NULL);

GST_DEBUG_OBJECT (self, "Set cache URI: \"%s\"",
GST_STR_NULL (self->cache_uri));
}

/* XXX: Can only be read from player thread.
Expand All @@ -509,9 +513,7 @@ clapper_media_item_get_playback_uri (ClapperMediaItem *self)
return self->cache_uri;

/* Do not test file existence next time */
GST_DEBUG_OBJECT (self, "Cleared cache URI for non-existing file: \"%s\"",
self->cache_uri);
g_clear_pointer (&self->cache_uri, g_free);
clapper_media_item_set_cache_location (self, NULL);
}

return self->uri;
Expand Down

0 comments on commit 147399a

Please sign in to comment.