google / google/oboe

AAudio API to require exact sample rate / format / channel count match

Open
#2,193 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
4.1k
Forks
639
Avg merge
2d 23h
Merged PRs (30d)
8

Description

Hi,

my custom audio processing engine can output multiple format combinations, but not every format supported by AAudio is supported by me. I however do not want a useless conversion to occur (for example, I can output both 96kHz and 48kHz, and I prefer 96kHz so I open a 96kHz stream - but the device does not support 96kHz hence sample rate conversion will be activated, even though I could just use 48kHz instead). Hence, to pick the closest match, I create an AAudio stream, check if hardware sample rate / format / channel count match what is requested, close the stream again and adjust as needed.

It would be nice to be able to avoid creating a stream I will not actually use. For example, I could imagine three new APIs:

- `AAudioStreamBuilder_setExactSampleRateMatchRequired(builder, true);` to disable sample rate conversion
- `AAudioStreamBuilder_setExactFormatMatchRequired(builder, true);` to disable format conversion
- `AAudioStreamBuilder_setExactChannelCountMatchRequired(builder, true);` to disable up/downmixing

if hardware does not support selected parameters, just error out instead of creating the stream successfully.

Alternatively, an API to query if some combination is supported would work for the use case (e.g. `AAudio_isConversionNeeded(builder);`) returning true if we'll need conversion if creating a stream with this builder's parameters.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.