简体   繁体   English

如何指定AudioRecorder对象的输入源?

[英]How can I specify the input source for the AudioRecorder object?

I'm porting an audio capture loop from Java (using AudioRecord class) to a native library using OpenSL. 我正在使用OpenSL将Java的音频捕获循环(使用AudioRecord类)移植到本机库。

The reason for this is that after profiling, the capture loop is consuming in our test phones around 2% less CPU in OpenSL. 这样做的原因是,在分析之后,我们的测试手机中的捕获循环正在消耗大约2%的OpenSL中的CPU。 That is a significative gain! 这是一个有意义的收获!

The constructor for the Java AudioRecord class receives a source parameter that can be configured to several values ( MIC, CAMCORDER, VOICE_DOWNLINK , etc.) Java AudioRecord类的构造函数接收可以配置为多个值的source参数( MIC, CAMCORDER, VOICE_DOWNLINK等)

So far, I haven't been able to find the equivalence (if there exists) for the source parameter in OpenSL. 到目前为止,我还没有找到OpenSL中source参数的等价(如果存在)。

Does anybody know if there's a way to specify this Source parameter for the AudioRecorder object? 有没有人知道是否有办法为AudioRecorder对象指定此Source参数?

Cheers! 干杯!

Check out the functions and constants defined in SLES/OpenSLES_Android.h and SLES/OpenSLES_AndroidConfiguration.h . 查看SLES/OpenSLES_Android.hSLES/OpenSLES_AndroidConfiguration.h定义的函数和常量。 When you get your recording object from OpenSLES, use GetInterface() to get the interface pointer for SL_IID_ANDROIDCONFIGURATION . 从OpenSLES获取录制对象时,使用GetInterface()获取SL_IID_ANDROIDCONFIGURATION的接口指针。 From there you can call SetConfiguration() using key SL_ANDROID_KEY_RECORDING_PRESET on the returned SLAndroidConfigurationItf pointer. 从那里,您可以使用返回的SLAndroidConfigurationItf指针上的键SL_ANDROID_KEY_RECORDING_PRESET调用SetConfiguration()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM