mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-04-10 05:42:37 +02:00
PulseAudio: Remove get_latency() caching
This commit is contained in:
parent
2be3b9c0ce
commit
f80e276363
@ -131,7 +131,7 @@
|
|||||||
<method name="get_output_latency" qualifiers="const">
|
<method name="get_output_latency" qualifiers="const">
|
||||||
<return type="float" />
|
<return type="float" />
|
||||||
<description>
|
<description>
|
||||||
Returns the audio driver's output latency.
|
Returns the audio driver's output latency. This can be expensive, it is not recommended to call this every frame.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="get_speaker_mode" qualifiers="const">
|
<method name="get_speaker_mode" qualifiers="const">
|
||||||
|
@ -117,7 +117,7 @@
|
|||||||
Number of islands in the 3D physics engine.
|
Number of islands in the 3D physics engine.
|
||||||
</constant>
|
</constant>
|
||||||
<constant name="AUDIO_OUTPUT_LATENCY" value="31" enum="Monitor">
|
<constant name="AUDIO_OUTPUT_LATENCY" value="31" enum="Monitor">
|
||||||
Output latency of the [AudioServer].
|
Output latency of the [AudioServer].Equivalent to calling [method AudioServer.get_output_latency], it is not recommended to call this every frame.
|
||||||
</constant>
|
</constant>
|
||||||
<constant name="NAVIGATION_ACTIVE_MAPS" value="32" enum="Monitor">
|
<constant name="NAVIGATION_ACTIVE_MAPS" value="32" enum="Monitor">
|
||||||
Number of active navigation maps in the [NavigationServer3D]. This also includes the two empty default navigation maps created by World2D and World3D.
|
Number of active navigation maps in the [NavigationServer3D]. This also includes the two empty default navigation maps created by World2D and World3D.
|
||||||
|
@ -353,27 +353,24 @@ Error AudioDriverPulseAudio::init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
float AudioDriverPulseAudio::get_latency() {
|
float AudioDriverPulseAudio::get_latency() {
|
||||||
if (latency == 0) { //only do this once since it's approximate anyway
|
lock();
|
||||||
lock();
|
|
||||||
|
|
||||||
pa_usec_t palat = 0;
|
pa_usec_t pa_lat = 0;
|
||||||
if (pa_stream_get_state(pa_str) == PA_STREAM_READY) {
|
if (pa_stream_get_state(pa_str) == PA_STREAM_READY) {
|
||||||
int negative = 0;
|
int negative = 0;
|
||||||
|
|
||||||
if (pa_stream_get_latency(pa_str, &palat, &negative) >= 0) {
|
if (pa_stream_get_latency(pa_str, &pa_lat, &negative) >= 0) {
|
||||||
if (negative) {
|
if (negative) {
|
||||||
palat = 0;
|
pa_lat = 0;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (palat > 0) {
|
|
||||||
latency = double(palat) / 1000000.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pa_lat > 0) {
|
||||||
|
latency = double(pa_lat) / 1000000.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
unlock();
|
||||||
return latency;
|
return latency;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user