flvmux: Avoid crash when best pad gets flushed

The 'best' pad might receive a flush event between us picking it and us
popping the buffer. In this case, the buffer will be missing.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/711>
This commit is contained in:
Jan Alexander Steffens (heftig) 2020-08-31 15:01:32 +02:00 committed by GStreamer Merge Bot
parent 01594d19b8
commit 2d08d16002

View file

@ -2005,6 +2005,15 @@ gst_flv_mux_aggregate (GstAggregator * aggregator, gboolean timeout)
best = gst_flv_mux_find_best_pad (aggregator, &ts, timeout);
}
if (best) {
buffer = gst_aggregator_pad_pop_buffer (GST_AGGREGATOR_PAD (best));
if (!buffer) {
/* We might have gotten a flush event after we picked the pad */
gst_object_unref (best);
return GST_AGGREGATOR_FLOW_NEED_DATA;
}
}
if (mux->new_tags && mux->streamable) {
GstBuffer *buf = gst_flv_mux_create_metadata (mux);
if (buf)
@ -2013,8 +2022,6 @@ gst_flv_mux_aggregate (GstAggregator * aggregator, gboolean timeout)
}
if (best) {
buffer = gst_aggregator_pad_pop_buffer (GST_AGGREGATOR_PAD (best));
g_assert (buffer);
best->dts =
gst_flv_mux_segment_to_running_time (&GST_AGGREGATOR_PAD
(best)->segment, GST_BUFFER_DTS_OR_PTS (buffer));