How to configure OpenSL to work with ear speaker other than main speaker or headphones

放肆的年华 提交于 2019-12-18 05:13:12

问题


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?


回答1:


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));


来源:https://stackoverflow.com/questions/21576739/how-to-configure-opensl-to-work-with-ear-speaker-other-than-main-speaker-or-head

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!