欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  移动技术

android AudioRecord 遇到的问题

程序员文章站 2022-06-24 19:49:55
AudioRecord 遇到的问题问题1:AudioRecord: Could not get audio input for session xxx, record source xx, sample rate 16000, format ...AudioRecord-JNI: Error creating AudioRecord instance: initialization check failed with status -22.android.media.AudioRecord: Err...

AudioRecord 遇到的问题

问题1:

AudioRecord: Could not get audio input for session xxx, record source xx, sample rate 16000, format ...
AudioRecord-JNI: Error creating AudioRecord instance: initialization check failed with status -22.
android.media.AudioRecord: Error code -20 when initializing native AudioRecord object

这个问题的愿意可以在整个系统日志中看到

	ServiceManager: Permission failure: android.permission.CAPTURE_AUDIO_OUT from uid=xxx
	AudioPolicyIntefaceImpl: getInputForAttr() permission denied: capture not allowd

也就是这个是一个权限问题,解决方法:

方法1. 把此应用置为系统应用(android:sharedUserId=“android.uid.system”)

方法2. 在frameworks/base/core/java/android/content/PermissionChecker.java中 checkPermission 函数中直接允许你的包名有录音权限

public static int checkPermission(...) {
	if (packageName.equals("包名")) {
		return PERMISSION_GRANTED;
	}
}

问题2:

AudioPolicyManagerCustom: startInput(134) failed: other input 110 already started
AudioRecord: start() status -38

这个是由于在音频关闭前去录音了,需要在音频打开后录音。

本文地址:https://blog.csdn.net/LHshooter/article/details/108120393

相关标签: Android