-Subproject commit b3aaee8df3039891d79f4f673e6a8050d3fb65b5
+Subproject commit 30a75fd8110601c89ecc7c1a0832a96878917cd4
FrameAllocator::Frame current_video_frame, current_audio_frame;
VideoFormat video_format;
+ AudioFormat audio_format;
if (video_frame) {
video_format.has_signal = !(video_frame->GetFlags() & bmdFrameHasNoInputSource);
}
}
+ if (audio_frame) {
+ int num_samples = audio_frame->GetSampleFrameCount();
+
+ current_audio_frame = audio_frame_allocator->alloc_frame();
+ if (current_audio_frame.data != nullptr) {
+ const uint8_t *frame_bytes;
+ audio_frame->GetBytes((void **)&frame_bytes);
+
+ memcpy(current_audio_frame.data, frame_bytes, sizeof(int32_t) * 2 * num_samples);
+
+ audio_format.bits_per_sample = 32;
+ audio_format.num_channels = 2;
+ }
+ }
+
if (current_video_frame.data != nullptr || current_audio_frame.data != nullptr) {
// TODO: Put into a queue and put into a dequeue thread, if the
// BlackMagic drivers don't already do that for us?
frame_callback(timecode,
current_video_frame, /*video_offset=*/0, video_format,
- current_audio_frame, /*audio_offset=*/0, 0x0000);
+ current_audio_frame, /*audio_offset=*/0, audio_format);
}
timecode++;
void Mixer::bm_frame(unsigned card_index, 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)
{
CaptureCard *card = &cards[card_index];
// Convert the audio to stereo fp32 and add it.
vector<float> audio;
audio.resize(num_samples * 2);
- convert_fixed24_to_fp32(&audio[0], 2, audio_frame.data + audio_offset, 8, num_samples);
+ switch (audio_format.bits_per_sample) {
+ case 24:
+ convert_fixed24_to_fp32(&audio[0], 2, audio_frame.data + audio_offset, audio_format.num_channels, num_samples);
+ break;
+ default:
+ fprintf(stderr, "Cannot handle audio with %u bits per sample\n", audio_format.bits_per_sample);
+ assert(false);
+ }
// Add the audio.
{
void configure_card(unsigned card_index, const QSurfaceFormat &format, CaptureInterface *capture);
void bm_frame(unsigned card_index, 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);
void place_rectangle(movit::Effect *resample_effect, movit::Effect *padding_effect, float x0, float y0, float x1, float y1);
void thread_func();
void audio_thread_func();