summaryrefslogtreecommitdiff
path: root/gst-libs/gst/uridownloader
diff options
context:
space:
mode:
authorThiago Santos <thiago.sousa.santos@collabora.com>2013-07-08 22:00:48 -0300
committerThiago Santos <thiago.sousa.santos@collabora.com>2013-07-08 23:39:49 -0300
commit9e313eb0a717a8d99c55d1a3d92b951a2d89a24b (patch)
tree2d9ca536445f3cf78158531617dd4b6f586daf43 /gst-libs/gst/uridownloader
parentf3d53fcd97aee4488c064a356452691eb4028fd8 (diff)
downloadgstreamer-plugins-bad-9e313eb0a717a8d99c55d1a3d92b951a2d89a24b.tar.gz
uridownloader: do not set cancelled unless explicitly called by user
Cancelled is a 'permanent' state of the uridownloader and is only removed by a call to _reset. When a download fails we just want to return NULL on the fetch function and leave the downloader ready for another fetch, otherwise the user has to call _reset after failed downloader, even when it didn't call _cancel.
Diffstat (limited to 'gst-libs/gst/uridownloader')
-rw-r--r--gst-libs/gst/uridownloader/gsturidownloader.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/gst-libs/gst/uridownloader/gsturidownloader.c b/gst-libs/gst/uridownloader/gsturidownloader.c
index 696320289..f068630ec 100644
--- a/gst-libs/gst/uridownloader/gsturidownloader.c
+++ b/gst-libs/gst/uridownloader/gsturidownloader.c
@@ -203,7 +203,16 @@ gst_uri_downloader_bus_handler (GstBus * bus,
/* remove the sync handler to avoid duplicated messages */
gst_bus_set_sync_handler (downloader->priv->bus, NULL, NULL, NULL);
- gst_uri_downloader_cancel (downloader);
+
+ /* stop the download */
+ GST_OBJECT_LOCK (downloader);
+ if (downloader->priv->download != NULL) {
+ GST_DEBUG_OBJECT (downloader, "Stopping download");
+ g_object_unref (downloader->priv->download);
+ downloader->priv->download = NULL;
+ g_cond_signal (&downloader->priv->cond);
+ }
+ GST_OBJECT_UNLOCK (downloader);
}
gst_message_unref (message);
@@ -303,7 +312,7 @@ gst_uri_downloader_cancel (GstUriDownloader * downloader)
downloader->priv->cancelled = TRUE;
if (cancelled)
GST_DEBUG_OBJECT (downloader,
- "Trying to cancell a download that was alredy cancelled");
+ "Trying to cancel a download that was alredy cancelled");
}
GST_OBJECT_UNLOCK (downloader);
}
@@ -378,10 +387,13 @@ gst_uri_downloader_fetch_uri_with_range (GstUriDownloader * downloader,
GstStateChangeReturn ret;
GstFragment *download = NULL;
+ GST_DEBUG_OBJECT (downloader, "Fetching URI %s", uri);
+
g_mutex_lock (&downloader->priv->download_lock);
GST_OBJECT_LOCK (downloader);
if (downloader->priv->cancelled) {
+ GST_DEBUG_OBJECT (downloader, "Cancelled, aborting fetch");
goto quit;
}
@@ -391,10 +403,12 @@ gst_uri_downloader_fetch_uri_with_range (GstUriDownloader * downloader,
}
gst_bus_set_flushing (downloader->priv->bus, FALSE);
+ downloader->priv->download = gst_fragment_new ();
GST_OBJECT_UNLOCK (downloader);
ret = gst_element_set_state (downloader->priv->urisrc, GST_STATE_READY);
GST_OBJECT_LOCK (downloader);
- if (ret == GST_STATE_CHANGE_FAILURE) {
+ if (ret == GST_STATE_CHANGE_FAILURE || downloader->priv->download == NULL) {
+ GST_WARNING_OBJECT (downloader, "Failed to set src to READY");
goto quit;
}
@@ -408,7 +422,6 @@ gst_uri_downloader_fetch_uri_with_range (GstUriDownloader * downloader,
goto quit;
}
- downloader->priv->download = gst_fragment_new ();
GST_OBJECT_UNLOCK (downloader);
ret = gst_element_set_state (downloader->priv->urisrc, GST_STATE_PLAYING);
GST_OBJECT_LOCK (downloader);