- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在尝试播放从服务器接收的 pcm 音频缓冲区。我下载了一个示例 alsa 播放文件,将录制的文件作为输入,它工作正常,但我在我的 SIP 客户端应用程序中添加的相同代码出现不允许操作错误。打开设备并设置设备配置没问题,但尝试获取我配置的参数时出现Operation not permitted error
。谁能告诉我出现此错误的原因?
/* Open the PCM device in playback mode */
if (pcm = snd_pcm_open(&pcm_handle, PCM_DEVICE,
SND_PCM_STREAM_PLAYBACK, 0) < 0)
printf("ERROR: Can't open \"%s\" PCM device. %s\n",
PCM_DEVICE, snd_strerror(pcm));
/* Allocate parameters object and fill it with default values*/
snd_pcm_hw_params_alloca(¶ms);
snd_pcm_hw_params_any(pcm_handle, params);
/* Set parameters */
if (pcm = snd_pcm_hw_params_set_access(pcm_handle, params,
SND_PCM_ACCESS_RW_INTERLEAVED) < 0)
printf("ERROR: Can't set interleaved mode. %s\n", snd_strerror(pcm));
if (pcm = snd_pcm_hw_params_set_format(pcm_handle, params,
//SND_PCM_FORMAT_S16_LE) < 0)
SND_PCM_FORMAT_MU_LAW) < 0)
printf("ERROR: Can't set format. %s\n", snd_strerror(pcm));
if (pcm = snd_pcm_hw_params_set_channels(pcm_handle, params, channels) < 0)
printf("ERROR: Can't set channels number. %s\n", snd_strerror(pcm));
if (pcm = snd_pcm_hw_params_set_rate_near(pcm_handle, params, &rate, 0) < 0)
printf("ERROR: Can't set rate. %s\n", snd_strerror(pcm));
/* Write parameters */
if (pcm = snd_pcm_hw_params(pcm_handle, params) < 0)
printf("ERROR: Can't set harware parameters. %s\n", snd_strerror(pcm));
/* Resume information */
printf("PCM name: '%s'\n", snd_pcm_name(pcm_handle));
printf("PCM state: %s\n", snd_pcm_state_name(snd_pcm_state(pcm_handle)));
pcm = snd_pcm_hw_params_get_channels(params, &tmp);
printf("channels: %i %d", tmp, pcm);
if (tmp == 1)
printf("(mono)\n");
else if (tmp == 2)
printf("(stereo)\n");
snd_pcm_hw_params_get_rate(params, &tmp, 0);
printf("rate: %d bps\n", tmp);
printf("seconds: %d\n", seconds);
/* Allocate buffer to hold single period */
snd_pcm_hw_params_get_period_size(params, &frames, 0);
buff_size = frames * channels * 2 /* 2 -> sample size */;
buff = (char *) malloc(buff_size);
printf("buffsize: %d\n", buff_size);
snd_pcm_hw_params_get_period_time(params, &tmp, NULL);
最佳答案
你所有的错误检查都是错误的。
<
运算符绑定(bind)强于 =
, 所以在这样一行中:
if (err = snd_something(...) < 0)
将函数的返回值与零进行比较,并将比较结果(假或真,0 或 1)分配给变量。
要使其正常工作,您必须在赋值周围添加括号:
if ((err = snd_something(...)) < 0)
但最好不要尝试将所有内容都放在一个表达式中:
err = snd_something(...);
if (err < 0)
关于c - Operation not Permitted on ALSA get hw parameters 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22830540/
我试图设置 POSIX 消息队列的大小,但似乎不被允许。 msgctl() 手册页指出: IPC_SET can only be executed by a process with appropri
好的,我在尝试对 MOV 文件进行编码时收到“av_interleaved_write_frame(): Operation not allowed”错误。首先,我需要概述其背后的条件。 我通过在 c
我有一个运行带有选项 allow_other 和 umask 0 的 fuse fs。这给了我一组权限设置为 777 的文件。虽然当我尝试 ls -l 时在包含文件的目录中,我得到以下输出: ls:
我已经安装了 JENKINS 并创建了一个 bob,但是作业因以下错误而失败。我尝试了很多方法,例如授予权限,但都无法使其运行。 谁能告诉我可能是什么原因以及如何让它运行。 13:45:49 Star
我有这行简单的代码: mkdir($path_to_rpi, 0755); chgrp($path_to_rpi, 'sambashare'); 目录创建为 www-data
我是初学者。我尝试使用 git 创建用户名。但是当我打字的时候 git config --global user.name "XXX" 消息显示 Unable to read current work
我的代码如下: calcstep ::Integral a => a -> a calcstep n = calcstep2 n 0 calcstep2 :: Integral (Integral
我们正在gitlab CI中的Alpine Docker镜像中运行vault-cli。 升级后,在调用保管库时会得到以下信息: /bin/bash: line 117: /usr/sbin/vault
在 WinSCP 中,如果您从本地服务器打开了一个文件,并进行更改并按 (Ctrl + S),基本上保存它,您会得到错误提示: /path of the file/ set times: Operat
尽管使用 sudo,pip install 命令有时会生成类似于以下内容的错误: ...Installing collected packages: setuptools, protobuf, whe
我的任务是为系统上的所有用户列出用户所属的所有组。这个想法是通过 /etc/passwd 并为每个用户打印其组。 [编辑] 成功了: if( getgrouplist(passwd->pw_name,
我正在研究 UNIX 网络编程中的示例,并且我已将“daytimeclientcli.c”改编为此处特定于 linux 的代码(这些示例使用 BSD)。我在 here 上针对时间服务器运行了该程序.无
import config from flask import Flask from flask_redis import Redis from werkzeug.contrib.fixers imp
HugeTLB - Large Page Support in the Linux Kernel #include #include #include #include #define MB_
我正在开发一个 Google App Engine Go 应用程序,需要在我的一个包中使用一些 HTML 模板。当前文件结构为: GOPATH/github.com/NAME/PROJECT/
我正在使用 isolate ,一个隔离器,用于隔离另一个使用 Linux 容器的程序的执行。它非常方便,并且在我的本地计算机上运行良好(我可以运行 fork 炸弹和无限循环,它可以保护一切)。 现在我
我正在尝试在用户空间中使用 mmap 来读取“mem_map”开始的物理内存。它是一个包含所有物理页面的数组。这是一台运行 3.0 内核的 i386 机器。 代码是这样的: .... //define
我有问题,我需要通过 php 脚本为系统中的不同用户设置文件所有者权限 所以我通过以下命令执行此操作,其中 1002 是系统的用户 ID。 file_put_contents($filename, $
在拉取一些 docker 镜像(但不是全部)时出现此错误: failed to register layer: Error processing tar file(exit status 1): op
我有一个带有 Rails API 的 React SPA。我最近更改了 React 端的 API 请求以通过 axios 而不是 jquery,我的 axios 设置是: export default
我是一名优秀的程序员,十分优秀!