diff options
| author | Marcelo Fernandez <marcelofg55@gmail.com> | 2018-07-16 22:43:47 -0300 |
|---|---|---|
| committer | Marcelo Fernandez <marcelofg55@gmail.com> | 2018-07-17 08:54:59 -0300 |
| commit | 3930e755e4642e5705bb00edc1b35bec6077f9dc (patch) | |
| tree | bf43080e3d2fc9e71a7467d40379f2526c9847fb /servers | |
| parent | e1f2feec2eccbc0589a66b84ea8b3af34c1740b4 (diff) | |
Added Performance.AUDIO_OUTPUT_LATENCY
Diffstat (limited to 'servers')
| -rw-r--r-- | servers/audio_server.cpp | 9 | ||||
| -rw-r--r-- | servers/audio_server.h | 5 |
2 files changed, 14 insertions, 0 deletions
diff --git a/servers/audio_server.cpp b/servers/audio_server.cpp index f2df7119e7..69c1318a48 100644 --- a/servers/audio_server.cpp +++ b/servers/audio_server.cpp @@ -234,6 +234,13 @@ void AudioServer::_driver_process(int p_frames, int32_t *p_buffer) { todo -= to_copy; to_mix -= to_copy; } + + // Calculate latency for Performance.AUDIO_OUTPUT_LATENCY + if (OS::get_singleton()) { + uint64_t ticks = OS::get_singleton()->get_ticks_usec(); + output_latency = (ticks - output_latency_ticks) / 1000000.f; + output_latency_ticks = ticks; + } } void AudioServer::_mix_step() { @@ -1178,6 +1185,8 @@ AudioServer::AudioServer() { mix_frames = 0; channel_count = 0; to_mix = 0; + output_latency = 0; + output_latency_ticks = 0; } AudioServer::~AudioServer() { diff --git a/servers/audio_server.h b/servers/audio_server.h index b7fcd9c093..f928acc7b5 100644 --- a/servers/audio_server.h +++ b/servers/audio_server.h @@ -190,6 +190,9 @@ private: Mutex *audio_data_lock; + float output_latency; + uint64_t output_latency_ticks; + void init_channels_and_buffers(); void _mix_step(); @@ -306,6 +309,8 @@ public: String get_device(); void set_device(String device); + float get_output_latency() { return output_latency; } + AudioServer(); virtual ~AudioServer(); }; |