]> git.sesse.net Git - nageru/commitdiff
Remove the unused frame_length parameter to AudioMixer::add_audio().
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 19 Feb 2019 23:25:43 +0000 (00:25 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 19 Feb 2019 23:38:58 +0000 (00:38 +0100)
nageru/alsa_input.cpp
nageru/alsa_input.h
nageru/alsa_pool.cpp
nageru/audio_mixer.cpp
nageru/audio_mixer.h
nageru/benchmark_audio_mixer.cpp
nageru/mixer.cpp

index 90a440f68bd84c1e65be1cc6a1609df2501c9999..ae2e7ffbdee3ce4e62c6578f1a59346a9c8b40cb 100644 (file)
@@ -246,21 +246,13 @@ ALSAInput::CaptureEndReason ALSAInput::do_capture()
                }
                RETURN_ON_ERROR("snd_pcm_readi()", frames);
 
-               const int64_t prev_pts = frames_to_pts(num_frames_output);
-               const int64_t pts = frames_to_pts(num_frames_output + frames);
                const steady_clock::time_point now = steady_clock::now();
                bool success;
                do {
                        if (should_quit.should_quit()) return CaptureEndReason::REQUESTED_QUIT;
-                       success = audio_callback(buffer.get(), frames, audio_format, pts - prev_pts, now);
+                       success = audio_callback(buffer.get(), frames, audio_format, now);
                } while (!success);
                num_frames_output += frames;
        }
        return CaptureEndReason::REQUESTED_QUIT;
 }
-
-int64_t ALSAInput::frames_to_pts(uint64_t n) const
-{
-       return (n * TIMEBASE) / sample_rate;
-}
-
index 060b9212690fce317f9dfac701af37d597af908a..825d4b686d05c11a6ffddcb17510f61a9f361dbe 100644 (file)
@@ -5,9 +5,7 @@
 // in callbacks.
 //
 // Note: “frame” here generally refers to the ALSA definition of frame,
-// which is a set of samples, exactly one for each channel. The only exception
-// is in frame_length, where it means the TIMEBASE length of the buffer
-// as a whole, since that's what AudioMixer::add_audio() wants.
+// which is a set of samples, exactly one for each channel.
 
 #include <alsa/asoundlib.h>
 #include <stdint.h>
@@ -26,7 +24,7 @@ class ALSAPool;
 
 class ALSAInput {
 public:
-       typedef std::function<bool(const uint8_t *data, unsigned num_samples, bmusb::AudioFormat audio_format, int64_t frame_length, std::chrono::steady_clock::time_point ts)> audio_callback_t;
+       typedef std::function<bool(const uint8_t *data, unsigned num_samples, bmusb::AudioFormat audio_format, std::chrono::steady_clock::time_point ts)> audio_callback_t;
 
        ALSAInput(const char *device, unsigned sample_rate, unsigned num_channels, audio_callback_t audio_callback, ALSAPool *parent_pool, unsigned internal_dev_index);
        ~ALSAInput();
@@ -51,7 +49,6 @@ public:
 
 private:
        void capture_thread_func();
-       int64_t frames_to_pts(uint64_t n) const;
 
        enum class CaptureEndReason {
                REQUESTED_QUIT,
index 3092dc32335551deed1b2b7b2255c07b7e9a19db..978f236886256e529e448c6dbcd37c53be951bfc 100644 (file)
@@ -402,7 +402,7 @@ void ALSAPool::reset_device(unsigned index)
                inputs[index].reset();
        } else {
                // TODO: Put on a background thread instead of locking?
-               auto callback = bind(&AudioMixer::add_audio, global_audio_mixer, DeviceSpec{InputSourceType::ALSA_INPUT, index}, _1, _2, _3, _4, _5);
+               auto callback = bind(&AudioMixer::add_audio, global_audio_mixer, DeviceSpec{InputSourceType::ALSA_INPUT, index}, _1, _2, _3, _4);
                inputs[index].reset(new ALSAInput(device->address.c_str(), OUTPUT_FREQUENCY, device->num_channels, callback, this, index));
                inputs[index]->start_capture_thread();
        }
index f63fe242460fcfbc1fa51f3b5f23809d627e68ab..d62f1e180ff7f8a2f14fef69c44b9145763bfa44 100644 (file)
@@ -244,7 +244,7 @@ void AudioMixer::reset_resampler_mutex_held(DeviceSpec device_spec)
        }
 }
 
-bool AudioMixer::add_audio(DeviceSpec device_spec, const uint8_t *data, unsigned num_samples, AudioFormat audio_format, int64_t frame_length, steady_clock::time_point frame_time)
+bool AudioMixer::add_audio(DeviceSpec device_spec, const uint8_t *data, unsigned num_samples, AudioFormat audio_format, steady_clock::time_point frame_time)
 {
        AudioDevice *device = find_audio_device(device_spec);
 
@@ -294,7 +294,7 @@ bool AudioMixer::add_audio(DeviceSpec device_spec, const uint8_t *data, unsigned
        return true;
 }
 
-bool AudioMixer::add_silence(DeviceSpec device_spec, unsigned samples_per_frame, unsigned num_frames, int64_t frame_length)
+bool AudioMixer::add_silence(DeviceSpec device_spec, unsigned samples_per_frame, unsigned num_frames)
 {
        AudioDevice *device = find_audio_device(device_spec);
 
index e435b46280c0d28e549c2fb36ae3df40f810f640..1cf4da349e71d4cc28d7c2ad5b4689f56fd7586d 100644 (file)
@@ -54,9 +54,9 @@ public:
        // the lock wasn't successfully taken; if so, you should simply try again.
        // (This is to avoid a deadlock where a card hangs on the mutex in add_audio()
        // while we are trying to shut it down from another thread that also holds
-       // the mutex.) frame_length is in TIMEBASE units.
-       bool add_audio(DeviceSpec device_spec, const uint8_t *data, unsigned num_samples, bmusb::AudioFormat audio_format, int64_t frame_length, std::chrono::steady_clock::time_point frame_time);
-       bool add_silence(DeviceSpec device_spec, unsigned samples_per_frame, unsigned num_frames, int64_t frame_length);
+       // the mutex.)
+       bool add_audio(DeviceSpec device_spec, const uint8_t *data, unsigned num_samples, bmusb::AudioFormat audio_format, std::chrono::steady_clock::time_point frame_time);
+       bool add_silence(DeviceSpec device_spec, unsigned samples_per_frame, unsigned num_frames);
 
        // If a given device is offline for whatever reason and cannot deliver audio
        // (by means of add_audio() or add_silence()), you can call put it in silence mode,
index 7ec3450dc60d942d617cbfeff0210f58a9b4ddc5..edb4955335f30ec7b734a32a27a88ff19a94b1cc 100644 (file)
@@ -73,7 +73,7 @@ vector<float> process_frame(unsigned frame_num, AudioMixer *mixer)
                unsigned num_samples = NUM_SAMPLES + (lcgrand() % 9) - 5;
                bool ok = mixer->add_audio(DeviceSpec{InputSourceType::CAPTURE_CARD, card_index},
                        card_index == 3 ? samples24 : samples16, num_samples, audio_format,
-                       NUM_SAMPLES * TIMEBASE / OUTPUT_FREQUENCY, ts);
+                       ts);
                assert(ok);
        }
 
index 9fd1e153ce71592adc782dba326a187463d72fcf..f8c39e877f394d68f9f30df967436701d30111f5 100644 (file)
@@ -779,12 +779,12 @@ void Mixer::bm_frame(unsigned card_index, uint16_t timecode,
 
                bool success;
                do {
-                       success = audio_mixer->add_silence(device, silence_samples, dropped_frames, frame_length);
+                       success = audio_mixer->add_silence(device, silence_samples, dropped_frames);
                } while (!success);
        }
 
        if (num_samples > 0) {
-               audio_mixer->add_audio(device, audio_frame.data + audio_offset, num_samples, audio_format, frame_length, audio_frame.received_timestamp);
+               audio_mixer->add_audio(device, audio_frame.data + audio_offset, num_samples, audio_format, audio_frame.received_timestamp);
        }
 
        // Done with the audio, so release it.