Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AudioSource.latency #1896

Open
wants to merge 3 commits into
base: 8.3.0-Dev
Choose a base branch
from

Conversation

ACrazyTown
Copy link
Contributor

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 #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.

Copy link

@mcagabe19 mcagabe19 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iOS will give null since it uses mojoal instead if OpenAL SOFT.

@MAJigsaw77
Copy link
Contributor

iOS will give null since it uses mojoal instead if OpenAL 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").

@ACrazyTown
Copy link
Contributor Author

@mcagabe19 @MAJigsaw77 The native C++ functions will return null if LIME_OPENALSOFT is not defined. This is later checked on the Haxe side:

public function getLatency():Float
{
var offsets = AL.getSourcedvSOFT(handle, AL.SEC_OFFSET_LATENCY_SOFT, 2);
if (offsets != null)
return offsets[1] * 1000;
return 0;
}

Is that not enough?

@MAJigsaw77
Copy link
Contributor

@mcagabe19 @MAJigsaw77 The native C++ functions will return null if LIME_OPENALSOFT is not defined. This is later checked on the Haxe side:

public function getLatency():Float
{
var offsets = AL.getSourcedvSOFT(handle, AL.SEC_OFFSET_LATENCY_SOFT, 2);
if (offsets != null)
return offsets[1] * 1000;
return 0;
}

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants