]> git.sesse.net Git - nageru/blobdiff - mixer.cpp
Release Nageru 1.3.1.
[nageru] / mixer.cpp
index fa3a6de81086d4aa03bd7a8a83c3133f3909e151..1934ee9429bcae271b3c6d22a9df64e2820a49fc 100644 (file)
--- a/mixer.cpp
+++ b/mixer.cpp
@@ -249,6 +249,7 @@ Mixer::Mixer(const QSurfaceFormat &format, unsigned num_cards)
        // except the final makeup gain.
        if (global_flags.flat_audio) {
                set_locut_enabled(false);
+               set_gain_staging_auto(false);
                set_limiter_enabled(false);
                set_compressor_enabled(false);
        }
@@ -290,7 +291,7 @@ void Mixer::configure_card(unsigned card_index, const QSurfaceFormat &format, Ca
        card->frame_allocator.reset(new PBOFrameAllocator(8 << 20, WIDTH, HEIGHT));  // 8 MB.
        card->capture->set_video_frame_allocator(card->frame_allocator.get());
        card->surface = create_surface(format);
-       card->resampling_queue.reset(new ResamplingQueue(OUTPUT_FREQUENCY, OUTPUT_FREQUENCY, 2));
+       card->resampling_queue.reset(new ResamplingQueue(card_index, OUTPUT_FREQUENCY, OUTPUT_FREQUENCY, 2));
        card->capture->configure_card();
 }
 
@@ -359,7 +360,7 @@ void Mixer::bm_frame(unsigned card_index, uint16_t timecode,
                }
        }
 
-       int64_t frame_length = int64_t(TIMEBASE * video_format.frame_rate_den) / video_format.frame_rate_nom;
+       int64_t frame_length = int64_t(TIMEBASE) * video_format.frame_rate_den / video_format.frame_rate_nom;
 
        size_t num_samples = (audio_frame.len > audio_offset) ? (audio_frame.len - audio_offset) / audio_format.num_channels / (audio_format.bits_per_sample / 8) : 0;
        if (num_samples > OUTPUT_FREQUENCY / 10) {
@@ -410,7 +411,7 @@ 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);
-                       card->resampling_queue.reset(new ResamplingQueue(OUTPUT_FREQUENCY, OUTPUT_FREQUENCY, 2));
+                       card->resampling_queue.reset(new ResamplingQueue(card_index, OUTPUT_FREQUENCY, OUTPUT_FREQUENCY, 2));
                        dropped_frames = 0;
                } else if (dropped_frames > 0) {
                        // Insert silence as needed.
@@ -853,9 +854,7 @@ void Mixer::process_audio_one_frame(int64_t frame_pts_int, int num_samples)
                samples_card.resize(num_samples * 2);
                {
                        unique_lock<mutex> lock(cards[card_index].audio_mutex);
-                       if (!cards[card_index].resampling_queue->get_output_samples(double(frame_pts_int) / TIMEBASE, &samples_card[0], num_samples)) {
-                               printf("Card %d reported previous underrun.\n", card_index);
-                       }
+                       cards[card_index].resampling_queue->get_output_samples(double(frame_pts_int) / TIMEBASE, &samples_card[0], num_samples);
                }
                if (card_index == selected_audio_card) {
                        samples_out = move(samples_card);