diff options
author | Sebastian Dröge <sebastian@centricular.com> | 2014-03-07 16:22:10 +0100 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2014-03-07 16:24:18 +0100 |
commit | 73b188cfb904a0c031a87dbe019e84bfb63e981d (patch) | |
tree | 3938b5ad3075e50ef9d008e36a2179ee11dd9692 /gst-libs/gst/uridownloader | |
parent | d2880dce68591d9b85ba777abcb4f4e4f6baa70c (diff) |
uridownload: Handle no buffers before EOS as error instead of crashing
Diffstat (limited to 'gst-libs/gst/uridownloader')
-rw-r--r-- | gst-libs/gst/uridownloader/gstfragment.c | 2 | ||||
-rw-r--r-- | gst-libs/gst/uridownloader/gsturidownloader.c | 8 |
2 files changed, 10 insertions, 0 deletions
diff --git a/gst-libs/gst/uridownloader/gstfragment.c b/gst-libs/gst/uridownloader/gstfragment.c index d595e8253..33e4d7040 100644 --- a/gst-libs/gst/uridownloader/gstfragment.c +++ b/gst-libs/gst/uridownloader/gstfragment.c @@ -211,6 +211,8 @@ gst_fragment_get_buffer (GstFragment * fragment) if (!fragment->completed) return NULL; + if (!fragment->priv->buffer) + return NULL; gst_buffer_ref (fragment->priv->buffer); return fragment->priv->buffer; diff --git a/gst-libs/gst/uridownloader/gsturidownloader.c b/gst-libs/gst/uridownloader/gsturidownloader.c index 01c845631..473285482 100644 --- a/gst-libs/gst/uridownloader/gsturidownloader.c +++ b/gst-libs/gst/uridownloader/gsturidownloader.c @@ -39,6 +39,7 @@ struct _GstUriDownloaderPrivate GstPad *pad; GTimeVal *timeout; GstFragment *download; + gboolean got_buffer; GMutex download_lock; /* used to restrict to one download only */ GError *err; @@ -258,6 +259,7 @@ gst_uri_downloader_chain (GstPad * pad, GstObject * parent, GstBuffer * buf) GST_LOG_OBJECT (downloader, "The uri fetcher received a new buffer " "of size %" G_GSIZE_FORMAT, gst_buffer_get_size (buf)); + downloader->priv->got_buffer = TRUE; if (!gst_fragment_add_buffer (downloader->priv->download, buf)) GST_WARNING_OBJECT (downloader, "Could not add buffer to fragment"); GST_OBJECT_UNLOCK (downloader); @@ -420,6 +422,7 @@ gst_uri_downloader_fetch_uri_with_range (GstUriDownloader * downloader, g_mutex_lock (&downloader->priv->download_lock); downloader->priv->err = NULL; + downloader->priv->got_buffer = FALSE; GST_OBJECT_LOCK (downloader); if (downloader->priv->cancelled) { @@ -487,6 +490,11 @@ gst_uri_downloader_fetch_uri_with_range (GstUriDownloader * downloader, download = downloader->priv->download; downloader->priv->download = NULL; + if (!downloader->priv->got_buffer) { + g_object_unref (download); + download = NULL; + GST_ERROR_OBJECT (downloader, "Didn't retrieve a buffer before EOS"); + } if (download != NULL) GST_INFO_OBJECT (downloader, "URI fetched successfully"); |