summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWim Taymans <wtaymans@redhat.com>2014-05-08 14:49:07 +0200
committerWim Taymans <wtaymans@redhat.com>2014-05-08 14:49:07 +0200
commite0db6b3f8c30b146817873d9d73ca38d25d04242 (patch)
treea12ef585636aa947b9d20a07fe8451257318270c
parenta7b4487ce4d1168a0bc73df27ced8b0feba50a33 (diff)
-rw-r--r--plugins/elements/gstcache.c58
1 files changed, 28 insertions, 30 deletions
diff --git a/plugins/elements/gstcache.c b/plugins/elements/gstcache.c
index 7104e5d53..63159481e 100644
--- a/plugins/elements/gstcache.c
+++ b/plugins/elements/gstcache.c
@@ -1026,38 +1026,36 @@ gst_cache_write_buffer (GstCache * queue, GstBuffer * buffer)
queue->write_pos = offset + info.size;
queue->bytes_in += info.size;
- if (available > 0) {
- /* we merged with a next range, see what to do */
- if (queue->write_pos + available == queue->upstream_size) {
- gsize start, stop;
-
- /* we have everything up to the end, find a region to fill */
- if (gst_sparse_file_get_range_after (queue->cache, 0, &start, &stop)) {
- if (stop < queue->upstream_size) {
- /* a hole to fill, seek to its end */
- perform_seek_to_offset (queue, stop);
- } else {
- /* we filled all the holes, post a message */
- queue->filling = FALSE;
- queue->is_eos = TRUE;
- update_levels (queue, queue->max_level.bytes);
- gst_element_post_message (GST_ELEMENT_CAST (queue),
- gst_message_new_element (GST_OBJECT_CAST (queue),
- gst_structure_new ("GstCacheDownloadComplete",
- "location", G_TYPE_STRING, queue->temp_location, NULL)));
- }
- }
- } else {
- /* see if we need to skip this region or just read it again. The idea
- * is that when the region is not big, we want to avoid a seek and just
- * let it reread */
- guint64 threshold = get_seek_threshold (queue);
-
- if (available > threshold) {
- /* further than threshold, it's better to skip than to reread */
- perform_seek_to_offset (queue, queue->write_pos + available);
+ /* we hit the end, see what to do */
+ if (queue->write_pos + available == queue->upstream_size) {
+ gsize start, stop;
+
+ /* we have everything up to the end, find a region to fill */
+ if (gst_sparse_file_get_range_after (queue->cache, 0, &start, &stop)) {
+ if (stop < queue->upstream_size) {
+ /* a hole to fill, seek to its end */
+ perform_seek_to_offset (queue, stop);
+ } else {
+ /* we filled all the holes, post a message */
+ queue->filling = FALSE;
+ queue->is_eos = TRUE;
+ update_levels (queue, queue->max_level.bytes);
+ gst_element_post_message (GST_ELEMENT_CAST (queue),
+ gst_message_new_element (GST_OBJECT_CAST (queue),
+ gst_structure_new ("GstCacheDownloadComplete",
+ "location", G_TYPE_STRING, queue->temp_location, NULL)));
}
}
+ } else {
+ /* see if we need to skip this region or just read it again. The idea
+ * is that when the region is not big, we want to avoid a seek and just
+ * let it reread */
+ guint64 threshold = get_seek_threshold (queue);
+
+ if (available > threshold) {
+ /* further than threshold, it's better to skip than to reread */
+ perform_seek_to_offset (queue, queue->write_pos + available);
+ }
}
if (queue->filling) {
if (queue->write_pos > queue->read_pos)