Android:Open'/dev/snd/pcmC0D1p';在非根电话中输入本机代码

Android:Open'/dev/snd/pcmC0D1p';在非根电话中输入本机代码,android,android-ndk,alsa,Android,Android Ndk,Alsa,我正在尝试创建一个本机android应用程序,它应该与非根设备一起工作。此应用程序的目标是重新路由和修改音频混音器路径。目前,我正在根手机上测试我的代码,并计划在非根手机上测试 首先,我把它们放在我的/dev/snd文件夹中(device=motorolag4)。因此,可以清楚地看到我试图打开的设备就在那里(pcmC0D1p) 我的原生C代码摘录有如下问题 struct mixer_ctl *ctl; const char* device = "/dev/snd/pcmC0D1p"; mixer

我正在尝试创建一个本机android应用程序,它应该与非根设备一起工作。此应用程序的目标是重新路由和修改音频混音器路径。目前,我正在根手机上测试我的代码,并计划在非根手机上测试

首先,我把它们放在我的/dev/snd文件夹中(device=motorolag4)。因此,可以清楚地看到我试图打开的设备就在那里(pcmC0D1p)

我的原生C代码摘录有如下问题

struct mixer_ctl *ctl;
const char* device = "/dev/snd/pcmC0D1p";
mixer = mixer_open(device);
以及混合器的打开功能

struct mixer *mixer_open(const char *device)
{
    struct snd_ctl_elem_list elist;
    struct snd_ctl_elem_info tmp;
    struct snd_ctl_elem_id *eid = NULL;
    struct mixer *mixer = NULL;
    unsigned n, m;
    int fd;
    fd = open(device, O_RDWR);
    if (fd < 0) {
        ALOGE("Control open failed\n");
        return 0
    }
}
所以我有一些关于这个的问题。 1.我做错了什么? 2.此方法是否适用于无根电话。(直接访问声音设备)
3.是否有人知道第三方库可以提供类似于ALSA库中amix和aplay的功能。

堆栈跟踪点位于
libamix.so
,不管是什么。这与你的
混合器打开功能有什么关系?哦,是的,我的错。已编辑。该日志条目报告SELinux冲突。你可以尝试研究Android设备的SELinux规则,但答案可能归结为“SELinux说不”。在Android上,对硬件设备的访问往往是通过先检查应用程序权限的服务来实现的。所谓“应用程序权限”是指Android运行时权限吗?我已读取外部存储、写入外部存储、读取手机状态、修改音频设置。这是否意味着我们无法通过本机代码直接访问此设备?的图表似乎表明,您所做的操作永远不会在非根设备上工作,因为您无法绕过SELinux。
struct mixer *mixer_open(const char *device)
{
    struct snd_ctl_elem_list elist;
    struct snd_ctl_elem_info tmp;
    struct snd_ctl_elem_id *eid = NULL;
    struct mixer *mixer = NULL;
    unsigned n, m;
    int fd;
    fd = open(device, O_RDWR);
    if (fd < 0) {
        ALOGE("Control open failed\n");
        return 0
    }
}
Control open failed --> this is my log :)
09-27 01:19:40.843 24403-24403/? W/ee.playbacktest: type=1400 audit(0.0:323): avc: denied { search } for uid=10117 name="snd" dev="tmpfs" ino=7893 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:object_r:audio_device:s0 tclass=dir permissive=0