giosrc: Ensure that an error is posted when underlying file is deleted

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/1001>
This commit is contained in:
Thibault Saunier 2021-01-07 16:27:25 -03:00 committed by GStreamer Merge Bot
parent 2d198ff10b
commit dc969bf538

View file

@ -105,6 +105,25 @@ static GInputStream *gst_gio_src_get_stream (GstGioBaseSrc * bsrc);
static gboolean gst_gio_src_query (GstBaseSrc * base_src, GstQuery * query); static gboolean gst_gio_src_query (GstBaseSrc * base_src, GstQuery * query);
static gboolean
gst_gio_src_check_deleted (GstGioSrc * src)
{
GstGioBaseSrc *bsrc = GST_GIO_BASE_SRC (src);
if (!g_file_query_exists (src->file, bsrc->cancel)) {
gchar *uri = g_file_get_uri (src->file);
GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND, (NULL),
("The underlying file %s is not available anymore", uri));
g_free (uri);
return TRUE;
}
return FALSE;
}
static void static void
gst_gio_src_file_changed_cb (GstGioSrc * src) gst_gio_src_file_changed_cb (GstGioSrc * src)
{ {
@ -114,6 +133,8 @@ gst_gio_src_file_changed_cb (GstGioSrc * src)
if (src->monitoring_mainloop) if (src->monitoring_mainloop)
g_main_loop_quit (src->monitoring_mainloop); g_main_loop_quit (src->monitoring_mainloop);
GST_OBJECT_UNLOCK (src); GST_OBJECT_UNLOCK (src);
gst_gio_src_check_deleted (src);
} }
static void static void
@ -133,6 +154,9 @@ gst_gio_src_wait_for_data (GstGioBaseSrc * bsrc)
g_return_val_if_fail (!src->monitor, FALSE); g_return_val_if_fail (!src->monitor, FALSE);
if (gst_gio_src_check_deleted (src))
return FALSE;
GST_OBJECT_LOCK (src); GST_OBJECT_LOCK (src);
if (!src->is_growing) { if (!src->is_growing) {
GST_OBJECT_UNLOCK (src); GST_OBJECT_UNLOCK (src);