qtmux: fix corner case buffer handling for reorder method

This commit is contained in:
Mark Nauwelaerts 2011-04-15 12:34:05 +02:00
parent 283b30e312
commit 4df05e76ed

View File

@ -1734,11 +1734,6 @@ gst_qt_mux_stop_file (GstQTMux * qtmux)
GstCollectData *cdata = (GstCollectData *) walk->data; GstCollectData *cdata = (GstCollectData *) walk->data;
GstQTPad *qtpad = (GstQTPad *) cdata; GstQTPad *qtpad = (GstQTPad *) cdata;
if (!qtpad->last_buf) {
GST_DEBUG_OBJECT (qtmux, "Pad %s has no buffers",
GST_PAD_NAME (qtpad->collect.pad));
continue;
}
/* send last buffer */ /* send last buffer */
GST_DEBUG_OBJECT (qtmux, "Sending the last buffer for pad %s", GST_DEBUG_OBJECT (qtmux, "Sending the last buffer for pad %s",
GST_PAD_NAME (qtpad->collect.pad)); GST_PAD_NAME (qtpad->collect.pad));
@ -1747,6 +1742,13 @@ gst_qt_mux_stop_file (GstQTMux * qtmux)
GST_WARNING_OBJECT (qtmux, "Failed to send last buffer for %s, " GST_WARNING_OBJECT (qtmux, "Failed to send last buffer for %s, "
"flow return: %s", GST_PAD_NAME (qtpad->collect.pad), "flow return: %s", GST_PAD_NAME (qtpad->collect.pad),
gst_flow_get_name (ret)); gst_flow_get_name (ret));
if (!GST_CLOCK_TIME_IS_VALID (qtpad->first_ts)) {
GST_DEBUG_OBJECT (qtmux, "Pad %s has no buffers",
GST_PAD_NAME (qtpad->collect.pad));
continue;
}
/* determine max stream duration */ /* determine max stream duration */
if (!GST_CLOCK_TIME_IS_VALID (first_ts) || if (!GST_CLOCK_TIME_IS_VALID (first_ts) ||
(GST_CLOCK_TIME_IS_VALID (qtpad->first_ts) && (GST_CLOCK_TIME_IS_VALID (qtpad->first_ts) &&
@ -2069,7 +2071,7 @@ gst_qt_mux_add_buffer (GstQTMux * qtmux, GstQTPad * pad, GstBuffer * buf)
gint64 pts_offset = 0; gint64 pts_offset = 0;
gboolean sync = FALSE, do_pts = FALSE; gboolean sync = FALSE, do_pts = FALSE;
gboolean drain = (buf == NULL); gboolean drain = (buf == NULL);
GstFlowReturn ret; GstFlowReturn ret = GST_FLOW_OK;
if (!pad->fourcc) if (!pad->fourcc)
goto not_negotiated; goto not_negotiated;
@ -2080,15 +2082,15 @@ gst_qt_mux_add_buffer (GstQTMux * qtmux, GstQTPad * pad, GstBuffer * buf)
} }
again: again:
last_buf = pad->last_buf;
if (G_UNLIKELY (qtmux->dts_method == DTS_METHOD_REORDER)) { if (G_UNLIKELY (qtmux->dts_method == DTS_METHOD_REORDER)) {
buf = gst_qt_mux_get_asc_buffer_ts (qtmux, pad, buf); buf = gst_qt_mux_get_asc_buffer_ts (qtmux, pad, buf);
if (!buf) { if (!buf && !last_buf) {
GST_DEBUG_OBJECT (qtmux, "no reordered buffer yet"); GST_DEBUG_OBJECT (qtmux, "no reordered buffer");
return GST_FLOW_OK; return GST_FLOW_OK;
} }
} }
last_buf = pad->last_buf;
if (last_buf == NULL) { if (last_buf == NULL) {
#ifndef GST_DISABLE_GST_DEBUG #ifndef GST_DISABLE_GST_DEBUG
if (buf == NULL) { if (buf == NULL) {
@ -2102,7 +2104,7 @@ again:
} }
#endif #endif
pad->last_buf = buf; pad->last_buf = buf;
return GST_FLOW_OK; goto exit;
} else } else
gst_buffer_ref (last_buf); gst_buffer_ref (last_buf);
@ -2352,6 +2354,7 @@ again:
ret = gst_qt_mux_send_buffer (qtmux, last_buf, &qtmux->mdat_size, TRUE); ret = gst_qt_mux_send_buffer (qtmux, last_buf, &qtmux->mdat_size, TRUE);
} }
exit:
if (G_UNLIKELY (drain && qtmux->dts_method == DTS_METHOD_REORDER && if (G_UNLIKELY (drain && qtmux->dts_method == DTS_METHOD_REORDER &&
ret == GST_FLOW_OK)) { ret == GST_FLOW_OK)) {
buf = NULL; buf = NULL;