oboe icon indicating copy to clipboard operation
oboe copied to clipboard

Add MinimalOboe Kotlin app

Open philburk opened this issue 3 years ago • 6 comments
trafficstars

Uses coroutine to call Oboe native to prevent ANR.

philburk avatar Sep 28 '22 00:09 philburk

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

robertwu1 avatar Sep 29 '22 17:09 robertwu1

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

robertwu1 avatar Sep 29 '22 17:09 robertwu1

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.

philburk avatar Sep 29 '22 20:09 philburk

@mmoczkowski - Do you know Kotlin/Compose? If so can you review to see if this demonstrates proper techniques? I am new to both.

philburk avatar Oct 03 '22 16:10 philburk

@robertwu1 wrote:

This file also needs to a line about DrumThumper

I don't understand. Can you clarify?

philburk avatar Oct 03 '22 16:10 philburk

@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

robertwu1 avatar Oct 03 '22 17:10 robertwu1

@donturner - Thanks for the coroutine scope patch. Requesting final review and Approval.

philburk avatar Nov 13 '22 15:11 philburk

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.

philburk avatar Nov 23 '22 23:11 philburk