]> git.sesse.net Git - bmusb/commitdiff
Send the audio format explicitly down, not just the ID.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 27 Feb 2016 15:07:05 +0000 (16:07 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 27 Feb 2016 15:07:05 +0000 (16:07 +0100)
bmusb.cpp
bmusb.h

index 4db8541eb1286e8578f778bad53656181ed8c326..85b92a6186c2e90debb70b4cc3fa85a0598d5eb7 100644 (file)
--- 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 935318c35cda00c91965ac076ba7102d4980a7ce..5b7c0f9c8e35a501c91bf40bdc81fb8d79f3770f 100644 (file)
--- 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<void(uint16_t timecode,
                            FrameAllocator::Frame video_frame, size_t video_offset, VideoFormat video_format,
-                           FrameAllocator::Frame audio_frame, size_t audio_offset, uint16_t audio_format)>
+                           FrameAllocator::Frame audio_frame, size_t audio_offset, AudioFormat audio_format)>
        frame_callback_t;
 
 class CaptureInterface {