timecodestamper: Only allow requesting LTC audio pad in NULL/READY states

And don't introduce any latency at all if not LTC audio pad was
requested.
This commit is contained in:
Sebastian Dröge 2020-01-09 15:27:28 +02:00
parent 0a499242e9
commit 0a53f6560a

View file

@ -877,7 +877,7 @@ gst_timecodestamper_query (GstBaseTransform * trans,
g_mutex_lock (&timecodestamper->mutex); g_mutex_lock (&timecodestamper->mutex);
if (res && timecodestamper->vinfo.fps_n && timecodestamper->vinfo.fps_d) { if (res && timecodestamper->vinfo.fps_n && timecodestamper->vinfo.fps_d) {
gst_query_parse_latency (query, &live, &min_latency, &max_latency); gst_query_parse_latency (query, &live, &min_latency, &max_latency);
if (live) { if (live && timecodestamper->ltcpad) {
/* Introduce additional 8 frames of latency for LTC processing as /* Introduce additional 8 frames of latency for LTC processing as
* the LTC library seems to usually lag behind 1-6 frames with the * the LTC library seems to usually lag behind 1-6 frames with the
* values reported back to us. */ * values reported back to us. */
@ -1171,7 +1171,7 @@ gst_timecodestamper_transform_ip (GstBaseTransform * vfilter,
/* Update LTC-based timecode as needed */ /* Update LTC-based timecode as needed */
#if HAVE_LTC #if HAVE_LTC
{ if (timecodestamper->ltcpad) {
GstClockTime frame_duration; GstClockTime frame_duration;
gchar *tc_str; gchar *tc_str;
LTCFrameExt ltc_frame; LTCFrameExt ltc_frame;
@ -1520,6 +1520,14 @@ gst_timecodestamper_request_new_pad (GstElement * element,
return NULL; return NULL;
} }
if (GST_STATE (timecodestamper) > GST_STATE_READY ||
GST_STATE_TARGET (timecodestamper) > GST_STATE_READY) {
GST_ERROR_OBJECT (timecodestamper,
"LTC audio pad can only be requested in NULL or READY state");
GST_OBJECT_UNLOCK (timecodestamper);
return NULL;
}
timecodestamper->ltcpad = gst_pad_new_from_static_template timecodestamper->ltcpad = gst_pad_new_from_static_template
(&gst_timecodestamper_ltc_template, "ltc_sink"); (&gst_timecodestamper_ltc_template, "ltc_sink");