From 30a75fd8110601c89ecc7c1a0832a96878917cd4 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sat, 27 Feb 2016 16:07:05 +0100 Subject: [PATCH] Send the audio format explicitly down, not just the ID. --- bmusb.cpp | 11 ++++++++--- bmusb.h | 8 +++++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/bmusb.cpp b/bmusb.cpp index 4db8541..85b92a6 100644 --- a/bmusb.cpp +++ b/bmusb.cpp @@ -191,6 +191,9 @@ void BMUSBCapture::dequeue_thread_func() uint16_t video_timecode = pending_video_frames.front().timecode; uint16_t audio_timecode = pending_audio_frames.front().timecode; + AudioFormat audio_format; + audio_format.bits_per_sample = 24; + audio_format.num_channels = 8; if (uint16_less_than_with_wraparound(video_timecode, audio_timecode)) { printf("Video block 0x%04x without corresponding audio block, dropping.\n", video_timecode); @@ -204,9 +207,10 @@ void BMUSBCapture::dequeue_thread_func() QueuedFrame audio_frame = pending_audio_frames.front(); pending_audio_frames.pop_front(); lock.unlock(); + audio_format.id = audio_frame.format; frame_callback(audio_timecode, FrameAllocator::Frame(), 0, VideoFormat(), - audio_frame.frame, AUDIO_HEADER_SIZE, audio_frame.format); + audio_frame.frame, AUDIO_HEADER_SIZE, audio_format); } else { QueuedFrame video_frame = pending_video_frames.front(); QueuedFrame audio_frame = pending_audio_frames.front(); @@ -222,14 +226,15 @@ void BMUSBCapture::dequeue_thread_func() #endif VideoFormat video_format; + audio_format.id = audio_frame.format; if (decode_video_format(video_frame.format, &video_format)) { frame_callback(video_timecode, video_frame.frame, HEADER_SIZE, video_format, - audio_frame.frame, AUDIO_HEADER_SIZE, audio_frame.format); + audio_frame.frame, AUDIO_HEADER_SIZE, audio_format); } else { frame_callback(video_timecode, FrameAllocator::Frame(), 0, video_format, - audio_frame.frame, AUDIO_HEADER_SIZE, audio_frame.format); + audio_frame.frame, AUDIO_HEADER_SIZE, audio_format); } } } diff --git a/bmusb.h b/bmusb.h index 935318c..5b7c0f9 100644 --- a/bmusb.h +++ b/bmusb.h @@ -66,9 +66,15 @@ struct VideoFormat { bool has_signal = false; }; +struct AudioFormat { + uint16_t id = 0; // For debugging/logging only. + unsigned bits_per_sample = 0; + unsigned num_channels = 0; +}; + typedef std::function + FrameAllocator::Frame audio_frame, size_t audio_offset, AudioFormat audio_format)> frame_callback_t; class CaptureInterface { -- 2.39.2