From: Wim Taymans Date: Tue, 3 Jun 2014 12:49:44 +0000 (+0200) Subject: downloadbuffer: reset read and write positions X-Git-Tag: 1.3.3~52 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8cbc35a93db9bc220dde95d7953c4aff86906eca;p=platform%2Fupstream%2Fgstreamer.git downloadbuffer: reset read and write positions Reset the read and write positions right after we open the file or flush it. We are also in the buffering state with 0 percent buffered when we start. --- diff --git a/plugins/elements/gstdownloadbuffer.c b/plugins/elements/gstdownloadbuffer.c index 9b155fc..73e0f7f 100644 --- a/plugins/elements/gstdownloadbuffer.c +++ b/plugins/elements/gstdownloadbuffer.c @@ -327,8 +327,6 @@ gst_download_buffer_init (GstDownloadBuffer * dlbuf) dlbuf->waiting_add = FALSE; g_cond_init (&dlbuf->item_add); - dlbuf->buffering_percent = 100; - /* tempfile related */ dlbuf->temp_template = NULL; dlbuf->temp_location = NULL; @@ -354,6 +352,18 @@ gst_download_buffer_finalize (GObject * object) } static void +reset_positions (GstDownloadBuffer * dlbuf) +{ + dlbuf->write_pos = 0; + dlbuf->read_pos = 0; + dlbuf->filling = TRUE; + dlbuf->buffering_percent = 0; + dlbuf->is_buffering = TRUE; + dlbuf->seeking = FALSE; + GST_DOWNLOAD_BUFFER_CLEAR_LEVEL (dlbuf->cur_level); +} + +static void reset_rate_timer (GstDownloadBuffer * dlbuf) { dlbuf->bytes_in = 0; @@ -882,6 +892,7 @@ gst_download_buffer_open_temp_location_file (GstDownloadBuffer * dlbuf) g_free (dlbuf->temp_location); dlbuf->temp_location = name; dlbuf->temp_fd = fd; + reset_positions (dlbuf); GST_DOWNLOAD_BUFFER_MUTEX_UNLOCK (dlbuf); @@ -962,7 +973,7 @@ gst_download_buffer_locked_flush (GstDownloadBuffer * dlbuf, gboolean full, { if (clear_temp) gst_download_buffer_flush_temp_file (dlbuf); - GST_DOWNLOAD_BUFFER_CLEAR_LEVEL (dlbuf->cur_level); + reset_positions (dlbuf); gst_event_replace (&dlbuf->stream_start_event, NULL); gst_event_replace (&dlbuf->segment_event, NULL); }