GstAviVideoPad *vidpad = (GstAviVideoPad *) avipad;
if (vidpad->prepend_buffer) {
+ /* Keep a reference to data until we copy the timestamps, then release it */
GstBuffer *newdata =
gst_buffer_append (vidpad->prepend_buffer, gst_buffer_ref (data));
gst_buffer_copy_into (newdata, data, GST_BUFFER_COPY_TIMESTAMPS, 0, -1);
if (avimux->restart) {
if ((res = gst_avi_mux_restart_file (avimux)) != GST_FLOW_OK)
- return res;
+ goto done;
}
datasize = gst_buffer_get_size (data);
datasize > GST_AVI_MAX_SIZE) {
if (avimux->enable_large_avi) {
if ((res = gst_avi_mux_bigfile (avimux, FALSE)) != GST_FLOW_OK)
- return res;
+ goto done;
} else {
if ((res = gst_avi_mux_restart_file (avimux)) != GST_FLOW_OK)
- return res;
+ goto done;
}
}
avimux->data_size += total_size;
}
- if (G_UNLIKELY (avipad->hook))
+ if (G_UNLIKELY (avipad->hook)) {
+ gst_buffer_ref (data);
avipad->hook (avimux, avipad, data);
+ }
/* the suggested buffer size is the max frame size */
if (avipad->hdr.bufsize < datasize)
GST_LOG_OBJECT (avimux, "pushing buffers: head, data");
if ((res = gst_pad_push (avimux->srcpad, header)) != GST_FLOW_OK)
- return res;
+ goto done;
+
+ gst_buffer_ref (data);
if ((res = gst_pad_push (avimux->srcpad, data)) != GST_FLOW_OK)
- return res;
+ goto done;
if (pad_bytes) {
if ((res = gst_avi_mux_send_pad_data (avimux, pad_bytes)) != GST_FLOW_OK)
- return res;
+ goto done;
}
/* if any push above fails, we're in trouble with file consistency anyway */
avimux->total_data += total_size;
avimux->idx_offset += total_size;
+done:
+ gst_buffer_unref (data);
return res;
}