From 89744513e07c29e54a3d773734a111081f24a96c Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Mon, 16 Nov 2015 22:47:08 +0100 Subject: [PATCH] Make the implausible audio length check work with lower frame rates. --- mixer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mixer.cpp b/mixer.cpp index db5980d..2eb037c 100644 --- a/mixer.cpp +++ b/mixer.cpp @@ -273,7 +273,8 @@ void Mixer::bm_frame(unsigned card_index, uint16_t timecode, int64_t frame_length = find_frame_length(video_format); - if (audio_frame.len - audio_offset > 30000) { + size_t num_samples = (audio_frame.len >= audio_offset) ? (audio_frame.len - audio_offset) / 8 / 3 : 0; + if (num_samples > OUTPUT_FREQUENCY / 10) { printf("Card %d: Dropping frame with implausible audio length (len=%d, offset=%d) [timecode=0x%04x video_len=%d video_offset=%d video_format=%x)\n", card_index, int(audio_frame.len), int(audio_offset), timecode, int(video_frame.len), int(video_offset), video_format); @@ -294,7 +295,6 @@ void Mixer::bm_frame(unsigned card_index, uint16_t timecode, card->last_timecode = timecode; // Convert the audio to stereo fp32 and add it. - size_t num_samples = (audio_frame.len >= audio_offset) ? (audio_frame.len - audio_offset) / 8 / 3 : 0; vector audio; audio.resize(num_samples * 2); convert_fixed24_to_fp32(&audio[0], 2, audio_frame.data + audio_offset, 8, num_samples); -- 2.39.2