From 6c8f0514b83ee6ca1c119258016f4fc9955c0808 Mon Sep 17 00:00:00 2001
From: Yun-Jing Huang <yun-jing.huang@ligo.org>
Date: Tue, 19 Sep 2023 12:42:02 -0400
Subject: [PATCH] bug fix: fix missing output before gaps

---
 gstlal-ugly/gst/lal/gstlal_interpolator.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/gstlal-ugly/gst/lal/gstlal_interpolator.c b/gstlal-ugly/gst/lal/gstlal_interpolator.c
index 13b1d623f7..e65d727047 100644
--- a/gstlal-ugly/gst/lal/gstlal_interpolator.c
+++ b/gstlal-ugly/gst/lal/gstlal_interpolator.c
@@ -831,6 +831,7 @@ static GstFlowReturn transform(GstBaseTransform *trans, GstBuffer *inbuf, GstBuf
 	guint output_length;
 	GstFlowReturn result = GST_FLOW_OK;
 	gboolean copied_nongap;
+	gboolean copied_nongap_all = FALSE;
 	GstMapInfo mapinfo;
 
 	g_assert(GST_BUFFER_PTS_IS_VALID(inbuf));
@@ -915,6 +916,9 @@ static GstFlowReturn transform(GstBaseTransform *trans, GstBuffer *inbuf, GstBuf
 				else
 					gst_audioadapter_copy_samples(element->adapter, element->workspace32->data, element->blocksampsin, NULL, &copied_nongap);
 
+				if (copied_nongap)
+					copied_nongap_all = TRUE;
+
 				if (element->outrate > element->inrate)
 					upsample32(output, element->kernel32, element->workspace32->data, kernel_length(element), element->outrate / element->inrate, element->channels, element->blockstrideout, copied_nongap);
 				else
@@ -934,7 +938,7 @@ static GstFlowReturn transform(GstBaseTransform *trans, GstBuffer *inbuf, GstBuf
 				processed += element->blockstrideout;
 			}
 			GST_INFO_OBJECT(element, "Processed a %d samples", processed);
-			set_metadata(element, outbuf, output_length, !copied_nongap);
+			set_metadata(element, outbuf, output_length, !copied_nongap_all);
 			gst_buffer_unmap(outbuf, &mapinfo);
 		}
 		if (element->width == 64) {
@@ -962,6 +966,9 @@ static GstFlowReturn transform(GstBaseTransform *trans, GstBuffer *inbuf, GstBuf
 				else
 					gst_audioadapter_copy_samples(element->adapter, element->workspace64->data, element->blocksampsin, NULL, &copied_nongap);
 
+				if (copied_nongap)
+					copied_nongap_all = TRUE;
+
 				if (element->outrate > element->inrate)
 					upsample64(output, element->kernel64, element->workspace64->data, kernel_length(element), element->outrate / element->inrate, element->channels, element->blockstrideout, copied_nongap);
 				else
@@ -981,7 +988,7 @@ static GstFlowReturn transform(GstBaseTransform *trans, GstBuffer *inbuf, GstBuf
 				processed += element->blockstrideout;
 			}
 			GST_INFO_OBJECT(element, "Processed a %d samples", processed);
-			set_metadata(element, outbuf, output_length, !copied_nongap);
+			set_metadata(element, outbuf, output_length, !copied_nongap_all);
 			gst_buffer_unmap(outbuf, &mapinfo);
 		}
 	}
-- 
GitLab