From c7bed1320e7fb4c72aec6d37ce9a20522d0ede15 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 26 Jun 2021 11:04:03 -0600 Subject: [PATCH] adding DSP stats to coreaudio backend (uncompiled) --- libs/backends/coreaudio/coreaudio_backend.cc | 3 ++- libs/backends/coreaudio/coreaudio_pcmio.cc | 9 ++++++--- libs/backends/coreaudio/coreaudio_pcmio.h | 9 ++++++++- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/libs/backends/coreaudio/coreaudio_backend.cc b/libs/backends/coreaudio/coreaudio_backend.cc index e95220f1dd..9e9a119cdd 100644 --- a/libs/backends/coreaudio/coreaudio_backend.cc +++ b/libs/backends/coreaudio/coreaudio_backend.cc @@ -548,7 +548,7 @@ CoreAudioBackend::_start (bool for_latency_measurement) _pcmio->set_buffer_size_callback (buffer_size_callback_ptr, this); _pcmio->set_sample_rate_callback (sample_rate_callback_ptr, this); - _pcmio->pcm_start (device1, device2, _samplerate, _samples_per_period, process_callback_ptr, this); + _pcmio->pcm_start (device1, device2, _samplerate, _samples_per_period, process_callback_ptr, this, dsp_stats[AudioBackend::DeviceWait]); #ifndef NDEBUG printf("STATE: %d\n", _pcmio->state ()); #endif @@ -1366,6 +1366,7 @@ CoreAudioBackend::process_callback (const uint32_t n_samples, const uint64_t hos { uint32_t i = 0; uint64_t clock1; + PBD::TimerRAII tr (dsp_stats[RunLoop]); _active_ca = true; diff --git a/libs/backends/coreaudio/coreaudio_pcmio.cc b/libs/backends/coreaudio/coreaudio_pcmio.cc index ca0a57de43..3690d04d9a 100644 --- a/libs/backends/coreaudio/coreaudio_pcmio.cc +++ b/libs/backends/coreaudio/coreaudio_pcmio.cc @@ -792,9 +792,10 @@ CoreAudioPCM::set_samples_per_period (uint32_t n_samples) int CoreAudioPCM::pcm_start ( - uint32_t device_id_in, uint32_t device_id_out, - uint32_t sample_rate, uint32_t samples_per_period, - int (process_callback (void*, const uint32_t, const uint64_t)), void *process_arg) + uint32_t device_id_in, uint32_t device_id_out, + uint32_t sample_rate, uint32_t samples_per_period, + int (process_callback (void*, const uint32_t, const uint64_t)), void *process_arg, + PBD::Timing& dsp_timer) { assert(_device_ids); @@ -812,6 +813,7 @@ CoreAudioPCM::pcm_start ( _process_arg = process_arg; _samples_per_period = samples_per_period; _cur_samples_per_period = 0; + _dsp_timer = &dsp_timer; _active_device_id = 0; _capture_channels = 0; _playback_channels = 0; @@ -1119,6 +1121,7 @@ CoreAudioPCM::render_callback ( UInt32 inNumberSamples, AudioBufferList* ioData) { + PBD::WaitTimerRAII tr (*_dsp_timer); OSStatus retVal = kAudioHardwareNoError; if (_samples_per_period < inNumberSamples) { diff --git a/libs/backends/coreaudio/coreaudio_pcmio.h b/libs/backends/coreaudio/coreaudio_pcmio.h index 84381c8e60..694f26c556 100644 --- a/libs/backends/coreaudio/coreaudio_pcmio.h +++ b/libs/backends/coreaudio/coreaudio_pcmio.h @@ -36,6 +36,10 @@ #define AUHAL_INPUT_ELEMENT 1 +namespace PBD { +class Timing; +} + namespace ARDOUR { class CoreAudioPCM { @@ -78,7 +82,8 @@ public: uint32_t samples_per_period, int (process_callback (void*, const uint32_t, const uint64_t)), void * process_arg - ); + PBD::Timing& dsp_timer, + ); void set_error_callback ( void ( error_callback (void*)), @@ -174,6 +179,8 @@ private: int (* _process_callback) (void*, const uint32_t, const uint64_t); void * _process_arg; + PBD::Timing* _dsp_timer; + void (* _error_callback) (void*); void * _error_arg;