buffer: handle gst_buffer_map failures

This commit is contained in:
Wim Taymans 2017-03-10 10:13:05 +01:00
parent 64a1d4ad0b
commit 586b34436e
2 changed files with 26 additions and 5 deletions

View file

@ -1741,9 +1741,12 @@ gst_harness_dump_to_file (GstHarness * h, const gchar * filename)
while ((buf = g_async_queue_try_pop (priv->buffer_queue))) {
GstMapInfo info;
gst_buffer_map (buf, &info, GST_MAP_READ);
fwrite (info.data, 1, info.size, fd);
gst_buffer_unmap (buf, &info);
if (gst_buffer_map (buf, &info, GST_MAP_READ)) {
fwrite (info.data, 1, info.size, fd);
gst_buffer_unmap (buf, &info);
} else {
GST_ERROR ("failed to map buffer %p", buf);
}
gst_buffer_unref (buf);
}

View file

@ -780,7 +780,8 @@ gst_download_buffer_read_buffer (GstDownloadBuffer * dlbuf, guint64 offset,
else
buf = *buffer;
gst_buffer_map (buf, &info, GST_MAP_WRITE);
if (!gst_buffer_map (buf, &info, GST_MAP_WRITE))
goto map_failed;
GST_DEBUG_OBJECT (dlbuf, "Reading %u bytes from %" G_GUINT64_FORMAT, length,
offset);
@ -835,6 +836,14 @@ hit_eos:
GST_DEBUG_OBJECT (dlbuf, "EOS hit");
return GST_FLOW_EOS;
}
map_failed:
{
GST_ELEMENT_ERROR (dlbuf, RESOURCE, BUSY,
(_("Failed to map buffer.")), ("failed to map buffer in WRITE mode"));
if (*buffer == NULL)
gst_buffer_unref (buf);
return GST_FLOW_ERROR;
}
out_flushing:
{
GST_DEBUG_OBJECT (dlbuf, "we are flushing");
@ -1163,7 +1172,8 @@ gst_download_buffer_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
GST_BUFFER_OFFSET (buffer), offset);
}
gst_buffer_map (buffer, &info, GST_MAP_READ);
if (!gst_buffer_map (buffer, &info, GST_MAP_READ))
goto map_error;
GST_DEBUG_OBJECT (dlbuf, "Writing %" G_GSIZE_FORMAT " bytes to %"
G_GUINT64_FORMAT, info.size, offset);
@ -1248,6 +1258,14 @@ out_seeking:
gst_buffer_unref (buffer);
return GST_FLOW_OK;
}
map_error:
{
GST_DOWNLOAD_BUFFER_MUTEX_UNLOCK (dlbuf);
gst_buffer_unref (buffer);
GST_ELEMENT_ERROR (dlbuf, RESOURCE, BUSY,
(_("Failed to map buffer.")), ("failed to map buffer in READ mode"));
return GST_FLOW_ERROR;
}
write_error:
{
GST_DOWNLOAD_BUFFER_MUTEX_UNLOCK (dlbuf);