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

Android低延迟OpenSLES:录音机停止工作,音频路由更改为扬声器,android,android-ndk,android-audiomanager,android-audiorecord,opensl,Android,Android Ndk,Android Audiomanager,Android Audiorecord,Opensl,我正在使用低延迟快速路径开发VoIP应用程序,问题是,当我将音频路由更改为speaker时,我注意到录音机回调每100ms启动一次,而不是应该每5ms启动一次,并生成以下错误: 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):

我正在使用低延迟快速路径开发VoIP应用程序,问题是,当我将音频路由更改为speaker时,我注意到录音机回调每100ms启动一次,而不是应该每5ms启动一次,并生成以下错误:

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
  • 设备:Nexus5Android 5.0.1
  • 本机缓冲区大小240个样本 (短片)
  • 本机频率48000 Hz播放器预设:
    SL_ANDROID_流_语音
  • 录音机预设:SL_ANDROID_录音_预设_语音_通信
  • 音频管理器在通信模式中
重要的是要注意,如果音频线路保持在耳机上,则工作正常。
有人知道问题出在哪里吗?

您的代码与耳机配合得很好,这告诉我,更改到扬声器的路径会产生延迟

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

我不知道确切的原因,为什么你的录音机回调是在100毫秒而不是5毫秒后触发的。但不管怎样,我认为你已经正确地设置了

还有一件事要检查的是缓冲区的大小。是的,没问题。但是您可以尝试设置较小的大小,因为您需要经常启动记录器回调


希望有帮助

谢谢你的回答,录音机每5毫秒就启动一次,直到我将音频线路改为扬声器,所以录音机工作正常,直到出现问题。你是说我需要重新初始化播放机的每个音频路径?我不明白。很抱歉你又出什么问题了?问题是当我把音频线路换成扬声器时,远端听不到我的声音,因为我的录音机回叫停止工作。只有当我使用快速路径时才会发生这种情况,也就是说,只有当我使用本机缓冲区大小和采样率时才会发生这种情况。