How to set up OpenSL to work with an ear speaker other than the main speaker or headphones

I tried a sample of my own sound code in android NDK. When I try to record some kind of speech and then play it, it works great. It uses the main speaker (loudspeaker) to play speech. I want to change the code so that speech is played in the ear dynamics instead of the main speaker. Any help?

+4
source share
1 answer

I solved the problem and I found a google group on the topic. It was really helpful. Here's the link: https://groups.google.com/forum/#!topic/android-ndk/O-hufEm20cU

, NDK. Android, STREAM_VOICE .

// Code for working with ear speaker by setting stream type to STREAM_VOICE
SLAndroidConfigurationItf playerConfig;
result = (*bqPlayerObject)->GetInterface(bqPlayerObject, SL_IID_ANDROIDCONFIGURATION, &playerConfig);
SLint32 streamType = SL_ANDROID_STREAM_VOICE;
result = (*playerConfig)->SetConfiguration(playerConfig, SL_ANDROID_KEY_STREAM_TYPE, &streamType, sizeof(SLint32));
+6

Source: https://habr.com/ru/post/1525405/


All Articles