X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=mixer.cpp;h=38578f90ea7b85609531a63d5bc1bc3806a983b7;hb=01181e6e22e5cfc9d0cb17231f2c1866cc53b04a;hp=7624c8013823ca5c67e119503cb306a449438eda;hpb=19a44f0f0dacb3cd96bacf83bb55ceda7590fda9;p=nageru diff --git a/mixer.cpp b/mixer.cpp index 7624c80..38578f9 100644 --- a/mixer.cpp +++ b/mixer.cpp @@ -287,7 +287,7 @@ void Mixer::configure_card(unsigned card_index, CaptureInterface *capture, bool card->capture->configure_card(); DeviceSpec device{InputSourceType::CAPTURE_CARD, card_index}; - audio_mixer.reset_device(device); + audio_mixer.reset_resampler(device); audio_mixer.set_name(device, card->capture->get_description()); } @@ -384,14 +384,17 @@ void Mixer::bm_frame(unsigned card_index, uint16_t timecode, if (dropped_frames > MAX_FPS * 2) { fprintf(stderr, "Card %d lost more than two seconds (or time code jumping around; from 0x%04x to 0x%04x), resetting resampler\n", card_index, card->last_timecode, timecode); - audio_mixer.reset_device(device); + audio_mixer.reset_resampler(device); dropped_frames = 0; } else if (dropped_frames > 0) { // Insert silence as needed. fprintf(stderr, "Card %d dropped %d frame(s) (before timecode 0x%04x), inserting silence.\n", card_index, dropped_frames, timecode); - audio_mixer.add_silence(device, silence_samples, dropped_frames, frame_length); + bool success; + do { + success = audio_mixer.add_silence(device, silence_samples, dropped_frames, frame_length); + } while (!success); } audio_mixer.add_audio(device, audio_frame.data + audio_offset, num_samples, audio_format, frame_length); @@ -569,9 +572,9 @@ void Mixer::thread_func() int stats_dropped_frames = 0; while (!should_quit) { - CaptureCard::NewFrame new_frames[MAX_CARDS]; - bool has_new_frame[MAX_CARDS] = { false }; - int num_samples[MAX_CARDS] = { 0 }; + CaptureCard::NewFrame new_frames[MAX_VIDEO_CARDS]; + bool has_new_frame[MAX_VIDEO_CARDS] = { false }; + int num_samples[MAX_VIDEO_CARDS] = { 0 }; unsigned master_card_index = theme->map_signal(master_clock_channel); assert(master_card_index < num_cards); @@ -681,7 +684,7 @@ void Mixer::thread_func() resource_pool->clean_context(); } -void Mixer::get_one_frame_from_each_card(unsigned master_card_index, CaptureCard::NewFrame new_frames[MAX_CARDS], bool has_new_frame[MAX_CARDS], int num_samples[MAX_CARDS]) +void Mixer::get_one_frame_from_each_card(unsigned master_card_index, CaptureCard::NewFrame new_frames[MAX_VIDEO_CARDS], bool has_new_frame[MAX_VIDEO_CARDS], int num_samples[MAX_VIDEO_CARDS]) { start: // The first card is the master timer, so wait for it to have a new frame.