You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-22 15:06:45 +00:00
Clean up latency related functions
This commit is contained in:
@@ -68,16 +68,16 @@ void AudioDriver::audio_server_process(int p_frames, int32_t *p_buffer, bool p_u
|
||||
|
||||
void AudioDriver::update_mix_time(int p_frames) {
|
||||
|
||||
_mix_amount += p_frames;
|
||||
_last_mix_frames = p_frames;
|
||||
if (OS::get_singleton())
|
||||
_last_mix_time = OS::get_singleton()->get_ticks_usec();
|
||||
}
|
||||
|
||||
double AudioDriver::get_mix_time() const {
|
||||
double AudioDriver::get_time_to_next_mix() const {
|
||||
|
||||
double total = (OS::get_singleton()->get_ticks_usec() - _last_mix_time) / 1000000.0;
|
||||
total += _mix_amount / (double)get_mix_rate();
|
||||
return total;
|
||||
double mix_buffer = _last_mix_frames / (double)get_mix_rate();
|
||||
return mix_buffer - total;
|
||||
}
|
||||
|
||||
void AudioDriver::input_buffer_init(int driver_buffer_frames) {
|
||||
@@ -148,7 +148,7 @@ Array AudioDriver::capture_get_device_list() {
|
||||
AudioDriver::AudioDriver() {
|
||||
|
||||
_last_mix_time = 0;
|
||||
_mix_amount = 0;
|
||||
_last_mix_frames = 0;
|
||||
input_position = 0;
|
||||
input_size = 0;
|
||||
|
||||
@@ -281,13 +281,6 @@ void AudioServer::_driver_process(int p_frames, int32_t *p_buffer) {
|
||||
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;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
prof_time += OS::get_singleton()->get_ticks_usec() - prof_ticks;
|
||||
#endif
|
||||
@@ -1107,13 +1100,14 @@ AudioServer *AudioServer::get_singleton() {
|
||||
return singleton;
|
||||
}
|
||||
|
||||
double AudioServer::get_mix_time() const {
|
||||
double AudioServer::get_output_latency() const {
|
||||
|
||||
return 0;
|
||||
return AudioDriver::get_singleton()->get_latency();
|
||||
}
|
||||
double AudioServer::get_output_delay() const {
|
||||
|
||||
return 0;
|
||||
double AudioServer::get_time_to_next_mix() const {
|
||||
|
||||
return AudioDriver::get_singleton()->get_time_to_next_mix();
|
||||
}
|
||||
|
||||
AudioServer *AudioServer::singleton = NULL;
|
||||
@@ -1357,6 +1351,9 @@ void AudioServer::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_device"), &AudioServer::get_device);
|
||||
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_output_latency"), &AudioServer::get_output_latency);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("capture_get_device_list"), &AudioServer::capture_get_device_list);
|
||||
ClassDB::bind_method(D_METHOD("capture_get_device"), &AudioServer::capture_get_device);
|
||||
ClassDB::bind_method(D_METHOD("capture_set_device", "name"), &AudioServer::capture_set_device);
|
||||
@@ -1386,6 +1383,8 @@ AudioServer::AudioServer() {
|
||||
#ifdef DEBUG_ENABLED
|
||||
prof_time = 0;
|
||||
#endif
|
||||
mix_time = 0;
|
||||
mix_size = 0;
|
||||
}
|
||||
|
||||
AudioServer::~AudioServer() {
|
||||
|
||||
Reference in New Issue
Block a user