matroska: Check return value of GstByteReader/Writer

This commit is contained in:
Edward Hervey 2012-04-12 15:49:44 +02:00
parent 97591c1e77
commit 4aef223db0
3 changed files with 13 additions and 7 deletions

View file

@ -223,11 +223,12 @@ gst_ebml_peek_id_full (GstEbmlRead * ebml, guint32 * id, guint64 * length,
GstByteReader *br = gst_ebml_read_br (ebml);
guint size = gst_byte_reader_get_remaining (br);
gst_byte_reader_peek_data (br, size, &data);
if (gst_byte_reader_peek_data (br, size, &data)) {
GST_LOG_OBJECT (ebml->el, "current br %p; remaining %d", br, size);
if (data)
GST_MEMDUMP_OBJECT (ebml->el, "element", data, MIN (size, *length));
GST_LOG_OBJECT (ebml->el, "current br %p; remaining %d", br, size);
if (data)
GST_MEMDUMP_OBJECT (ebml->el, "element", data, MIN (size, *length));
}
}
#endif

View file

@ -427,14 +427,16 @@ gst_ebml_write_element_push (GstEbmlWrite * ebml, GstBuffer * buf,
gst_buffer_map (buf, &map, GST_MAP_READ);
buf_data = map.data;
}
gst_byte_writer_put_data (ebml->streamheader, buf_data, data_size);
if (!gst_byte_writer_put_data (ebml->streamheader, buf_data, data_size))
GST_WARNING ("Error writing data to streamheader");
}
if (ebml->cache) {
if (!buf_data) {
gst_buffer_map (buf, &map, GST_MAP_READ);
buf_data = map.data;
}
gst_byte_writer_put_data (ebml->cache, buf_data, data_size);
if (!gst_byte_writer_put_data (ebml->cache, buf_data, data_size))
GST_WARNING ("Error writing data to cache");
if (map.data)
gst_buffer_unmap (buf, &map);
gst_buffer_unref (buf);

View file

@ -1669,7 +1669,10 @@ gst_matroska_demux_search_cluster (GstMatroskaDemux * demux, gint64 * pos)
if (cluster_pos >= 0) {
newpos += cluster_pos;
/* prepare resuming at next byte */
gst_byte_reader_skip (&reader, cluster_pos + 1);
if (!gst_byte_reader_skip (&reader, cluster_pos + 1)) {
GST_DEBUG_OBJECT (demux, "Need more data -> continue");
continue;
}
GST_DEBUG_OBJECT (demux,
"found cluster ebml id at offset %" G_GINT64_FORMAT, newpos);
/* extra checks whether we really sync'ed to a cluster: