Question

I've tried the native-audio code sample in android NDK. When i try to record some speech and then play it back it works fine. It uses the main speaker(loud speaker) for the speech playback. I want to modify the code so that the speech is played in the ear speaker instead of the main speaker. Any help?

Was it helpful?

Solution

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

I tested it in the native-audio example provided with android NDK. You've to take interface of android configuration first and then set stream type to STREAM_VOICE after creating the audio player.

// 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));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top