Skip to content

opensl: implement get_min_latency and get_preferred_sample_rate - #863

Merged
padenot merged 1 commit into
mozilla:masterfrom
jamienicol:opensl-get-min-latency
Oct 12, 2026
Merged

padenot merged 1 commit into
mozilla:masterfrom
jamienicol:opensl-get-min-latency

Conversation

@jamienicol

Copy link
Copy Markdown
Contributor

Use JNI to call Android's AudioManager.getProperty() API to query the OUTPUT_FRAMES_PER_BUFFER and OUTPUT_SAMPLE_RATE properties, respectively.

These are available from API level 17 onwards, matching the existing JNI usage for getOutputLatency(). On earlier API levels CUBEB_ERROR_NOT_SUPPORTED will continue to be returned.

Use JNI to call Android's AudioManager.getProperty() API to query the
OUTPUT_FRAMES_PER_BUFFER and OUTPUT_SAMPLE_RATE properties,
respectively.

These are available from API level 17 onwards, matching the existing
JNI usage for getOutputLatency(). On earlier API levels
CUBEB_ERROR_NOT_SUPPORTED will continue to be returned.
@jamienicol

Copy link
Copy Markdown
Contributor Author

This is for firefox: https://phabricator.services.mozilla.com/D332484

Comment thread src/cubeb_opensl.cpp
{
XASSERT(ctx && latency_frames);
output_latency_function * ol = ctx->p_output_latency_function;
if (!ol || !ol->from_jni) {

@jamienicol jamienicol Oct 12, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't love piggybacking on the ouptut_latency_function to obtain the JNI. Fortunately the output latency function and the new ones we're adding both have the same minimum API level so it works out, but I'm open to suggestions on how to improve this.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Good enough. The OpenSL ES backend is legacy. AAudio is what we're using mostly (I hope?).

@padenot
padenot merged commit 2e87c63 into mozilla:master Oct 12, 2026
16 checks passed
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.

2 participants