diff options
author | Juan Linietsky <reduzio@gmail.com> | 2019-04-27 14:05:16 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2019-04-27 14:05:16 -0300 |
commit | c2027c82334c680e078dae5deb29f4f8e2d64ca2 (patch) | |
tree | 77db8701d0be656bedebb0f0cb3a66bb86ceb420 /servers/audio_server.cpp | |
parent | 040b59c010f3cce63b4c45956c418b74079e24e6 (diff) |
Added functions to further improve music timing
Diffstat (limited to 'servers/audio_server.cpp')
-rw-r--r-- | servers/audio_server.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/servers/audio_server.cpp b/servers/audio_server.cpp index 604d500fb3..fc3ecedd03 100644 --- a/servers/audio_server.cpp +++ b/servers/audio_server.cpp @@ -73,6 +73,11 @@ void AudioDriver::update_mix_time(int p_frames) { _last_mix_time = OS::get_singleton()->get_ticks_usec(); } +double AudioDriver::get_time_since_last_mix() const { + + return (OS::get_singleton()->get_ticks_usec() - _last_mix_time) / 1000000.0; +} + double AudioDriver::get_time_to_next_mix() const { double total = (OS::get_singleton()->get_ticks_usec() - _last_mix_time) / 1000000.0; @@ -1110,6 +1115,11 @@ double AudioServer::get_time_to_next_mix() const { return AudioDriver::get_singleton()->get_time_to_next_mix(); } +double AudioServer::get_time_since_last_mix() const { + + return AudioDriver::get_singleton()->get_time_since_last_mix(); +} + AudioServer *AudioServer::singleton = NULL; void *AudioServer::audio_data_alloc(uint32_t p_data_len, const uint8_t *p_from_data) { @@ -1352,6 +1362,7 @@ void AudioServer::_bind_methods() { ClassDB::bind_method(D_METHOD("set_device", "device"), &AudioServer::set_device); ClassDB::bind_method(D_METHOD("get_time_to_next_mix"), &AudioServer::get_time_to_next_mix); + ClassDB::bind_method(D_METHOD("get_time_since_last_mix"), &AudioServer::get_time_since_last_mix); ClassDB::bind_method(D_METHOD("get_output_latency"), &AudioServer::get_output_latency); ClassDB::bind_method(D_METHOD("capture_get_device_list"), &AudioServer::capture_get_device_list); |