Add AudioSource.latency
This PR adds a latency field to AudioSource that returns the estimated playback latency of the sound.
On native targets (that use OpenAL Soft) the same method from https://github.com/openfl/lime/pull/1759 is used, although exposing it as a seperate field instead of applying it directly to the sound's time.
HTML5 uses AudioContext.baseLatency and AudioContext.outputLatency
In the case where it's not possible to query the playback latency (eg. Flash) 0 is returned.
iOS will give null since it uses
mojoalinstead ifOpenAL SOFT.
@ACrazyTown Since some platforms might use mojoAl or something else for example, I'd suggest checking if the extension is supported first AL.isExtensionPresent("AL_SOFT_source_latency").
@mcagabe19 @MAJigsaw77 The native C++ functions will return null if LIME_OPENALSOFT is not defined. This is later checked on the Haxe side: https://github.com/openfl/lime/blob/3f9041ab7d63c7c1cbc397dc482dd8cd2a0e7401/src/lime/_internal/backend/native/NativeAudioSource.hx#L592-L599
Is that not enough?
@mcagabe19 @MAJigsaw77 The native C++ functions will return null if
LIME_OPENALSOFTis not defined. This is later checked on the Haxe side:https://github.com/openfl/lime/blob/3f9041ab7d63c7c1cbc397dc482dd8cd2a0e7401/src/lime/_internal/backend/native/NativeAudioSource.hx#L592-L599
Is that not enough?
It's not because openal soft can be there, but the platform might not support latency, in any case that check should make it fine if added.
If it is problematic to add this to the AudioSource API (as Lime uses 3 different OpenAL backends depending on the configuration and only OpenAL Soft can query latency) would it be better to just reduce this to binding the necessary functions and exposing them in Haxe thru OpenALAudioContext or whatever? If so, would be nice to also review https://github.com/openfl/lime/pull/1912 so the backend specific functions can be hidden behind a proper conditional