google / oboe

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

Glitch in background, exclusive mode #2062

Closed simdax closed 4 months ago

simdax commented 4 months ago

Hello.

I'm working on a plugin that should be open when my application runs in background.

I use a fullduplex stream, as i filter the input from the default microphone. The idea is to keep the app alive while recording the surrounding sound.

For now, all is ok when I run my plugin from the app. But when going in background the stream becomes glitchy.

I'm not sure also to really be able to be able to start a stream with exclusive mode. Do I need to do something special?

Thank you!

robertwu1 commented 4 months ago

Try the LiveEffect sample. It currently does not run in the background so I created a Pull Request (#2063). It seems to work fine in the background with the minor change with that PR.

simdax commented 4 months ago

As I mentionned it here https://github.com/google/oboe/pull/2063#issuecomment-2218522159 It seems that passing in background make some few glitches.

philburk commented 4 months ago

If your callback function does a lot of processing then there may be a problem running in the background. That is because the CPU gives lower priority to background tasks and lowers the CPU frequency.

What device are you on? OS version? etcetera

robertwu1 commented 4 months ago

See https://developer.android.com/develop/background-work/services/foreground-services. Starting for Android U, foreground services are required.

simdax commented 4 months ago

It would be nice to have a background example, with the foreground service. I'm not sure how to keep enough CPU for my plugin processing

robertwu1 commented 4 months ago

I filed issue #2065

robertwu1 commented 4 months ago

@simdax can you try PR #2070?