From 9c5d3191b3f4f71b0db7ab1111f7d5cdf4eb16da Mon Sep 17 00:00:00 2001 From: Naushir Patuck Date: Thu, 1 Dec 2022 15:34:17 +0000 Subject: [PATCH] output: null_encoder: Fix bug in ordering of input/output callbacks This would cause a pop from the metadata queue in the output callback before the input callback has a chance to push to the queue. Signed-off-by: Naushir Patuck --- encoder/null_encoder.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/encoder/null_encoder.cpp b/encoder/null_encoder.cpp index ebc39719..a80dc60b 100644 --- a/encoder/null_encoder.cpp +++ b/encoder/null_encoder.cpp @@ -57,7 +57,10 @@ void NullEncoder::outputThread() return; } } - output_ready_callback_(item.mem, item.length, item.timestamp_us, true); + // Ensure the input done callback happens before the output ready callback. + // This is needed as the metadata queue gets pushed in the former, and popped + // in the latter. input_done_callback_(nullptr); + output_ready_callback_(item.mem, item.length, item.timestamp_us, true); } }