Android低延迟OpenSLES:录音机停止工作音频路由更改为扬声器

时间:2016-05-22 08:48:32

标签: android android-ndk android-audiomanager android-audiorecord opensl

我正在使用低延迟快速路径开发VoIP应用程序,问题是当我将音频路由更改为扬声器时,我注意到记录器回调每隔100毫秒而不是5毫秒触发,因为它应该工作并产生以下错误:

E/ACDB-LOADER(  183): Error: ACDB AudProc vol returned = -19
D/audio_hw_primary(  183): enable_snd_device: snd_device(32: speaker-mic)
D/audio_hw_primary(  183): enable_audio_route: apply and update mixer path: low-latency-record
D/audio_hw_primary(  183): disable_audio_route: reset and update mixer path: low-latency-record
D/audio_hw_primary(  183): disable_snd_device: snd_device(32: speaker-mic)
E/AudioFlinger(  183): read failed: framesRead=-2147483631
D/audio_hw_primary(  183): select_devices: out_snd_device(0: none) in_snd_device(32: speaker-mic)
D/msm8974_platform(  183): platform_send_audio_calibration: sending audio calibration for snd_device(32) acdb_id(11)
D/        (  183): Failed to fetch the lookup information of the device 0000000B 
E/ACDB-LOADER(  183): Error: ACDB AudProc vol returned = -19
D/audio_hw_primary(  183): enable_snd_device: snd_device(32: speaker-mic)
D/audio_hw_primary(  183): enable_audio_route: apply and update mixer path: low-latency-record
D/audio_hw_primary(  183): disable_audio_route: reset and update mixer path: low-latency-record
D/audio_hw_primary(  183): disable_snd_device: snd_device(32: speaker-mic)
E/AudioFlinger(  183): read failed: framesRead=-2147483631
D/audio_hw_primary(  183): select_devices: out_snd_device(0: none) in_snd_device(32: speaker-mic)
D/msm8974_platform(  183): platform_send_audio_calibration: sending audio calibration for snd_device(32) acdb_id(11)
D/        (  183): Failed to fetch the lookup information of the device 0000000B 
E/ACDB-LOADER(  183): Error: ACDB AudProc vol returned = -19
D/audio_hw_primary(  183): enable_snd_device: snd_device(32: speaker-mic)
D/audio_hw_primary(  183): enable_audio_route: apply and update mixer path: low-latency-record
D/audio_hw_primary(  183): disable_audio_route: reset and update mixer path: low-latency-record
D/audio_hw_primary(  183): disable_snd_device: snd_device(32: speaker-mic)
E/AudioFlinger(  183): read failed: framesRead=-2147483631
D/audio_hw_primary(  183): select_devices: out_snd_device(0: none) in_snd_device(32: speaker-mic)
D/msm8974_platform(  183): platform_send_audio_calibration: sending audio calibration for snd_device(32) acdb_id(11)
D/        (  183): Failed to fetch the lookup information of the device 0000000B 
E/ACDB-LOADER(  183): Error: ACDB AudProc vol returned = -19
D/audio_hw_primary(  183): enable_snd_device: snd_device(32: speaker-mic)
D/audio_hw_primary(  183): enable_audio_route: apply and update mixer path: low-latency-record
D/audio_hw_primary(  183): disable_audio_route: reset and update mixer path: low-latency-record
D/audio_hw_primary(  183): disable_snd_device: snd_device(32: speaker-mic)
E/AudioFlinger(  183): read failed: framesRead=-2147483631
D/audio_hw_primary(  183): select_devices: out_snd_device(0: none) in_snd_device(32: speaker-mic)
D/msm8974_platform(  183): platform_send_audio_calibration: sending audio calibration for snd_device(32) acdb_id(11)
D/        (  183): Failed to fetch the lookup information of the device 0000000B 
E/ACDB-LOADER(  183): Error: ACDB AudProc vol returned = -19
D/audio_hw_primary(  183): enable_snd_device: snd_device(32: speaker-mic)
D/audio_hw_primary(  183): enable_audio_route: apply and update mixer path: low-latency-record
D/audio_hw_primary(  183): disable_audio_route: reset and update mixer path: low-latency-record
D/audio_hw_primary(  183): disable_snd_device: snd_device(32: speaker-mic)
E/AudioFlinger(  183): read failed: framesRead=-2147483631
  • 设备:Nexus 5 Android 5.0.1
  • 原生缓冲区大小为240个样本 (短裤)
  • 原生频率48000赫兹播放器预设:
    SL_ANDROID_STREAM_VOICE
  • 记录器预设:SL_ANDROID_RECORDING_PRESET_VOICE_COMMUNICATION
  • MODE_IN_COMMUNICATION上的AudioManager

重要的是要注意,如果音频路线保留在耳机上,它可以正常工作。 有谁知道问题是什么?

1 个答案:

答案 0 :(得分:1)

您的代码可以正常使用耳机告诉我,更改到扬声器的路径会产生延迟。

OpenSL默认将音频播放路由到扬声器。现在,当您将streamType设置为SL_ANDROID_STREAM_VOICE时,它会将音频路由到您的耳机。将音频路由回扬声器时,可能需要将streamType设置为默认值并再次初始化播放器。

我不知道确切的原因,为什么你的录音机回调在100ms而不是5ms之后被解雇。但无论如何,我认为你已正确设置了audio sampling rate of your device

还有另一件要检查的是缓冲区大小。是的240是可以的。但您可能会尝试设置较小的尺寸,因为您需要经常触发录像机回调。

希望有所帮助。