X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=benchmark_audio_mixer.cpp;h=3327179c3518e6dc492b794c636d7d24bafde7a7;hb=e284d1c7a2e18ee7e4aea082c4a57a3504a0f5e8;hp=8fe4710cbc8e834b4f84f6ca44a67309db7c28a1;hpb=2da661c06c945b2fb3521bbabcc7e81d63dabdd7;p=nageru diff --git a/benchmark_audio_mixer.cpp b/benchmark_audio_mixer.cpp index 8fe4710..3327179 100644 --- a/benchmark_audio_mixer.cpp +++ b/benchmark_audio_mixer.cpp @@ -2,12 +2,21 @@ // with the default settings, feeds some white noise to the inputs and // runs a while. Useful for e.g. profiling. -#include +#include +#include #include -#include +#include +#include #include +#include +#include +#include + #include "audio_mixer.h" #include "db.h" +#include "defs.h" +#include "input_mapping.h" +#include "resampling_queue.h" #include "timebase.h" #define NUM_BENCHMARK_CARDS 4 @@ -52,6 +61,10 @@ void callback(float level_lufs, float peak_db, vector process_frame(unsigned frame_num, AudioMixer *mixer) { + duration> frame_duration(frame_num); + steady_clock::time_point ts = steady_clock::time_point::min() + + duration_cast(frame_duration); + // Feed the inputs. for (unsigned card_index = 0; card_index < NUM_BENCHMARK_CARDS; ++card_index) { bmusb::AudioFormat audio_format; @@ -61,12 +74,11 @@ vector 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); + NUM_SAMPLES * TIMEBASE / OUTPUT_FREQUENCY, ts); assert(ok); } - double pts = double(frame_num) * NUM_SAMPLES / OUTPUT_FREQUENCY; - return mixer->get_output(pts, NUM_SAMPLES, ResamplingQueue::ADJUST_RATE); + return mixer->get_output(ts, NUM_SAMPLES, ResamplingQueue::ADJUST_RATE); } void init_mapping(AudioMixer *mixer)