google / oboe

Oboe is a C++ library that makes it easy to build high-performance audio apps on Android.
Apache License 2.0
3.63k stars 551 forks source link

Oboe sometimes cannot play very short sounds #2027

Open philburk opened 1 month ago

philburk commented 1 month ago

Some apps play short sounds, eg. 30 msec, by opening a file, playing the sound and then stopping the stream. In some cases the sound may never be heard.

One part of the problem may be here:

src/opensles/AudioStreamOpenSLES.cpp#L407

When the app callback returns DataCallbackResult::Stop, Oboe does not queue the data from that callback to OpenSL ES.

Also the Oboe requestStop() method flushes/clears the queue of any unplayed data. The comment says it is "so the old data won't be played if the stream is restarted." Maybe we should just clear the queue when we restart the stream instead.

We should add a "Short Sound" test in OboeTester to experiment with these various techniques.

We could tag buffers with varying frequency sinewaves that fit an exact number of cycles within the buffer. Then we could use loopback analysis to identify which buffers get played and which get dropped.

philburk commented 1 month ago

Internal bug at: b/333514437 | P3 | [Oboe/OpenSL] Not able to play short duration file when BTHS is connected.