oboe
oboe copied to clipboard
Add MinimalOboe Kotlin app
Uses coroutine to call Oboe native to prevent ANR.
Btw, I thought about Java samples a bit more and Soundboard and Megadrone may be too simple as examples. We simply start the audio engine when the app is resumed and stop the audio engine when the app is paused. This is good for many apps, but not all apps want to have an open audio stream all the time.
For Soundboard and Megadrone, I don't think we should change anything. Letting the UI thread open audio is fine in these cases because having pads that do not play audio at the beginning feels like a bug.
LiveEffect uses a different mechanism. Only when LiveEffectEngine.setEffectOn(bool) is called, should the engine be started or stopped. This seems like a good place to spin off another non-UI thread.
HelloOboe is more complicated than all of samples listed above. It creates an audio stream onResume() and deletes it onPause(). It also closes the current stream and reopens a new stream whenever PlaybackEngine.setChannelCount, PlaybackEngine.setAudioDeviceId, or PlaybackEngine.setAudioApi is called. This is clearly the largest sample despite the name.
I recommend making changes to LiveEffect for a Java sample. For the wiki, we can list out 4 samples in the following chart:
| Type of sample | Kotlin | Java |
|---|---|---|
| Create engine at on resume | DrumThumper | Soundboard |
| Dynamically create engine | MinimalOboe | LiveEffect |
Create a README.md file describing the app and update https://github.com/google/oboe/blob/main/samples/README.md. This file also needs to a line about DrumThumper
I agree LiveEffect would be a good candidate for a background task.
Re modifying SoundBoard
having pads that do not play audio at the beginning feels like a bug.
Ideally the open should just take 100-200 msec. The user should not notice the unresponsive pads. But if the audioserver dies and takes 10 seconds to recover then the ANR in the UI thread will kill the app. That is not acceptable. So all apps should really use a background task to avoid ANRs.
@mmoczkowski - Do you know Kotlin/Compose? If so can you review to see if this demonstrates proper techniques? I am new to both.
@robertwu1 wrote:
This file also needs to a line about DrumThumper
I don't understand. Can you clarify?
@robertwu1 wrote:
This file also needs to a line about DrumThumper
I don't understand. Can you clarify?
It currently lists out 5 samples. It doesn't list out DrumThumper
@donturner - Thanks for the coroutine scope patch. Requesting final review and Approval.
This was merged manually to avoid merge conflicts. I followed the instructions given by GitHub, which unfortunately did not involve a squash. So it was a messy merge.