13
0

Fix CoreAudio systemic latency, implement hw latency report

This commit is contained in:
Robin Gareus 2020-02-24 04:24:50 +01:00
parent 53a6c24147
commit a9c75f9760
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
3 changed files with 25 additions and 2 deletions

View File

@ -440,6 +440,24 @@ CoreAudioBackend::systemic_output_latency () const
return _systemic_audio_output_latency;
}
uint32_t
CoreAudioBackend::systemic_hw_input_latency () const
{
if (name_to_id (_input_audio_device) != UINT32_MAX) {
return _pcmio->get_latency(name_to_id(_input_audio_device, Input), true);
}
return 0;
}
uint32_t
CoreAudioBackend::systemic_hw_output_latency () const
{
if (name_to_id (_output_audio_device) != UINT32_MAX) {
return _pcmio->get_latency(name_to_id(_output_audio_device, Output), false);
}
return 0;
}
/* MIDI */
std::vector<std::string>
@ -1120,7 +1138,7 @@ CoreAudioBackend::register_system_audio_ports()
#endif
/* audio ports */
lr.min = lr.max = coreaudio_reported_input_latency + (_measure_latency ? 0 : _systemic_audio_input_latency);
lr.min = lr.max = _measure_latency ? 0 : _systemic_audio_input_latency;
for (uint32_t i = 0; i < a_ins; ++i) {
char tmp[64];
snprintf(tmp, sizeof(tmp), "system:capture_%d", i+1);
@ -1132,7 +1150,7 @@ CoreAudioBackend::register_system_audio_ports()
_system_inputs.push_back(cp);
}
lr.min = lr.max = coreaudio_reported_output_latency + (_measure_latency ? 0 : _systemic_audio_output_latency);
lr.min = lr.max = _measure_latency ? 0 : _systemic_audio_output_latency;
for (uint32_t i = 0; i < a_out; ++i) {
char tmp[64];
snprintf(tmp, sizeof(tmp), "system:playback_%d", i+1);

View File

@ -262,6 +262,9 @@ class CoreAudioBackend : public AudioBackend {
uint32_t systemic_midi_input_latency (std::string const) const { return 0; }
uint32_t systemic_midi_output_latency (std::string const) const { return 0; }
uint32_t systemic_hw_input_latency () const;
uint32_t systemic_hw_output_latency () const;
bool can_set_systemic_midi_latencies () const { return false; /* XXX */}
/* External control app */

View File

@ -474,7 +474,9 @@ CoreAudioPCM::get_latency(uint32_t device_id, bool input)
for (size_t i = 0; i < stream_latencies.size(); ++i) {
max_stream_latency = std::max(max_stream_latency, stream_latencies[i]);
}
#if 0
latency += max_stream_latency;
#endif
return latency;
}