oboe icon indicating copy to clipboard operation
oboe copied to clipboard

Support earpiece speaker in demos for OpenSL ES

Open chrbsg opened this issue 5 years ago • 2 comments

According to https://stackoverflow.com/questions/21576739/how-to-configure-opensl-to-work-with-ear-speaker-other-than-main-speaker-or-head and https://groups.google.com/forum/#!topic/android-ndk/O-hufEm20cU

Earpiece speaker can be selected by using option SL_ANDROID_STREAM_VOICE in OpenSL config.

It would be useful to somehow expose this in the audio demos (output device dropdown?) to demonstrate playback with OpenSL through that speaker.

chrbsg avatar Jun 11 '20 09:06 chrbsg

OpenSL ES does not support setting the device menu.

But there are two oboe:Usages that map to that OpenSL stream:

    case Usage::VoiceCommunication:
    case Usage::VoiceCommunicationSignalling:
        openslStream = SL_ANDROID_STREAM_VOICE;

It gets set here: https://github.com/google/oboe/blob/eecaf3e26af7496c6824dcaf83ac270fc4d7fbf5/src/opensles/AudioOutputStreamOpenSLES.cpp#L196

So if we add a Usage menu to the demo then it should work.

philburk avatar Jun 11 '20 20:06 philburk

When OpenSL ES is being used we should disable the output devices which it isn't possible to select. We can use SL_ANDROID_STREAM_VOICE to select the earpiece speaker.

dturner avatar Jun 17 '20 17:06 dturner