CoreAudio: use libardour provided DSP load calc.
This commit is contained in:
parent
e125c78070
commit
1c43383e92
@ -701,7 +701,7 @@ CoreAudioBackend::freewheel (bool onoff)
|
|||||||
float
|
float
|
||||||
CoreAudioBackend::dsp_load () const
|
CoreAudioBackend::dsp_load () const
|
||||||
{
|
{
|
||||||
return std::min(100.f, 100.f * _dsp_load);
|
return 100.f * _dsp_load;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
@ -1718,7 +1718,7 @@ int
|
|||||||
CoreAudioBackend::process_callback (const uint32_t n_samples, const uint64_t host_time)
|
CoreAudioBackend::process_callback (const uint32_t n_samples, const uint64_t host_time)
|
||||||
{
|
{
|
||||||
uint32_t i = 0;
|
uint32_t i = 0;
|
||||||
uint64_t clock1, clock2;
|
uint64_t clock1;
|
||||||
|
|
||||||
_active_ca = true;
|
_active_ca = true;
|
||||||
|
|
||||||
@ -1846,16 +1846,10 @@ CoreAudioBackend::process_callback (const uint32_t n_samples, const uint64_t hos
|
|||||||
_processed_samples += n_samples;
|
_processed_samples += n_samples;
|
||||||
|
|
||||||
/* calc DSP load. */
|
/* calc DSP load. */
|
||||||
clock2 = g_get_monotonic_time();
|
_dsp_load_calc.set_max_time (_samplerate, _samples_per_period);
|
||||||
const int64_t elapsed_time = clock2 - clock1;
|
_dsp_load_calc.set_start_timestamp_us (clock1);
|
||||||
// low pass filter
|
_dsp_load_calc.set_stop_timestamp_us (g_get_monotonic_time());
|
||||||
const float load = elapsed_time / (float) nominal_time;
|
_dsp_load = _dsp_load_calc.get_dsp_load ();
|
||||||
if (load > _dsp_load) {
|
|
||||||
_dsp_load = load;
|
|
||||||
} else {
|
|
||||||
const float a = .2 * _samples_per_period / _samplerate;
|
|
||||||
_dsp_load = _dsp_load + a * (load - _dsp_load) + 1e-12;
|
|
||||||
}
|
|
||||||
|
|
||||||
pthread_mutex_unlock (&_process_callback_mutex);
|
pthread_mutex_unlock (&_process_callback_mutex);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
|
|
||||||
#include "ardour/audio_backend.h"
|
#include "ardour/audio_backend.h"
|
||||||
|
#include "ardour/dsp_load_calculator.h"
|
||||||
#include "ardour/types.h"
|
#include "ardour/types.h"
|
||||||
|
|
||||||
#include "coreaudio_pcmio.h"
|
#include "coreaudio_pcmio.h"
|
||||||
@ -371,6 +372,7 @@ class CoreAudioBackend : public AudioBackend {
|
|||||||
|
|
||||||
/* processing */
|
/* processing */
|
||||||
float _dsp_load;
|
float _dsp_load;
|
||||||
|
ARDOUR::DSPLoadCalculator _dsp_load_calc;
|
||||||
uint64_t _processed_samples;
|
uint64_t _processed_samples;
|
||||||
|
|
||||||
pthread_t _main_thread;
|
pthread_t _main_thread;
|
||||||
|
Loading…
Reference in New Issue
Block a user