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.
This commit is contained in:
Wim Taymans 2014-06-03 14:49:44 +02:00
parent 36d4c4c218
commit 8cbc35a93d

View file

@ -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;
@ -353,6 +351,18 @@ gst_download_buffer_finalize (GObject * object)
G_OBJECT_CLASS (parent_class)->finalize (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)
{
@ -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);
}