2,Error恢复
分析Error Code,根据error Code做不同的处理
-EBADFD(77)
|
PCM is not in the right state (SND_PCM_STATE_PREPARED or SND_PCM_STATE_RUNNING)
|
-EPIPE(32)
|
an underrun or overrun occurred
|
-ESTRPIPE(86)
|
a suspend event occurred (stream is suspended and waiting for an application recovery)
|
3,PCM STATE具体介绍
SND_PCM_STATE_OPEN
The PCM device is in the open state. After the
snd_pcm_open()
open call, the device is in this state. Also, when
snd_pcm_hw_params()
call fails, then this state is entered to force application calling
snd_pcm_hw_params()
function to set right communication parameters.
SND_PCM_STATE_SETUP
The PCM device has accepted communication parameters and it is waiting for
snd_pcm_prepare()
call to prepare the hardware for selected operation (playback or capture).
SND_PCM_STATE_PREPARED
The PCM device is prepared for operation. Application can use
snd_pcm_start()
call, write or read data to start the operation.
SND_PCM_STATE_RUNNING
The PCM device has been started and is running. It processes the samples. The stream can be stopped using the
snd_pcm_drop()
or
snd_pcm_drain()
calls.
SND_PCM_STATE_XRUN
The PCM device reached overrun (capture) or underrun (playback). You can use the -EPIPE return code from I/O functions (
snd_pcm_writei()
,
snd_pcm_writen()
,
snd_pcm_readi()
,
snd_pcm_readn()
) to determine this state without checking the actual state via
snd_pcm_state()
call. It is recommended to use the helper function
snd_pcm_recover()
to recover from this state, but you can also use
snd_pcm_prepare()
,
snd_pcm_drop()
or
snd_pcm_drain()
calls.
SND_PCM_STATE_DRAINING
The device is in this state when application using the capture mode called
snd_pcm_drain()
function. Until all data are read from the internal ring buffer using I/O routines (
snd_pcm_readi()
,
snd_pcm_readn()
), then the device stays in this state.
SND_PCM_STATE_PAUSED
The device is in this state when application called the
snd_pcm_pause()
function until the pause is released. Not all hardware supports this feature. Application should check the capability with the
snd_pcm_hw_params_can_pause()
.
SND_PCM_STATE_SUSPENDED
The device is in the suspend state provoked with the power management system. The stream can be resumed using
snd_pcm_resume()
call, but not all hardware supports this feature. Application should check the capability with the
snd_pcm_hw_params_can_resume()
. In other case, the calls
snd_pcm_prepare()
,
snd_pcm_drop()
,
snd_pcm_drain()
can be used to leave this state.
SND_PCM_STATE_DISCONNECTED
The device is physicaly disconnected. It does not accept any I/O calls in this state.
4,PCM State值
enum
|
snd_pcm_state_t
{
SND_PCM_STATE_OPEN
= 0 ,
SND_PCM_STATE_SETUP
,
SND_PCM_STATE_PREPARED
,
SND_PCM_STATE_RUNNING
,
SND_PCM_STATE_XRUN
,
SND_PCM_STATE_DRAINING
,
SND_PCM_STATE_PAUSED
,
SND_PCM_STATE_SUSPENDED
,
SND_PCM_STATE_DISCONNECTED
,
SND_PCM_STATE_LAST
= SND_PCM_STATE_DISCONNECTED ,
SND_PCM_STATE_PRIVATE1
= 1024
}
|
分析Error Code,根据error Code做不同的处理SND_PCM_STATE_OPENThe PCM device is in the open state. After the snd_pcm_open() open call, the device is in this state. Also, when snd_pcm_hw_params() call fails, then this state is entered to force application calling snd_pc
对于一个wave文件,如果需要播放,涉及到几个方面
1.对于wave文件的解析
2.通过解析wave文件,将得到的参数(主要是sampfrequency, bitsperSample,channel)通过
alsa
api设下去
3.正确找到data的起始点
4.play
alsa
1.1 detail:
1.对于wave文件的解析,...
ALSA
学习
笔记
(3)
PCM
1. 概述2. 示例代码2.1 创建
pcm
实例2.2 设置
PCM
设备的操作函数2.3 定义
PCM
的操作函数2.4 定义硬件参数3. 创建
pcm
实例代码分析5
PCM
逻辑设备的注册6
PCM
信息运行时指针6.1 硬件描述6.2 运行状态6.3 私有数据7 结构图
1. 概述
每个
pcm
实例对应一个
pcm
设备文件。一个
pcm
实例由一个playback stream和一个capture stream组成,而每个
pcm
stream由一个或多个
pcm
子流组成。当一个子流已经存在,并且
"
alsa
lib
pcm
.c:8512"是一个错误信息,它是
ALSA
(Advanced Linux Sound Architecture)库中的一个错误代码。
ALSA
是用于在Linux操作系统上处理音频和声音的软件框架。
pcm
.c是该库中与
PCM
(Pulse-code Modulation)音频数据处理相关的文件。当出现"
alsa
lib
pcm
.c:8512"错误时,表示在执行
PCM
音频数据读取或写入操作时发生了错误,具体是在
pcm
.c文件的第8512行。
要解决这个错误,可以考虑以下几个步骤:
1. 检查设备配置:确保
使用
正确的音频设备进行读取或写入操作。可以
使用
命令"aplay -l"和"arecord -l"来列出系统中可用的音频设备。
2. 检查权限:确保当前用户有足够的权限来访问音频设备。可以
使用
命令"ls -l /dev/snd/"来查看设备文件的权限。
3. 检查设置参数:检查
PCM
音频处理的设置参数是否正确。可以参考
ALSA
文档和相应的程序代码来确认参数设置的正确性。
4. 检查驱动和库版本:确保
ALSA
库和音频驱动程序的版本是兼容的。更新驱动程序或升级
ALSA
库可能有助于解决一些已知的问题。
5. 查找其他错误信息:在"
alsa
lib
pcm
.c:8512"错误之前或之后的错误信息中,可能会提供更多有关问题原因的线索。对这些错误信息进行分析,可能会帮助定位和解决问题。
6. 检查其他系统资源:确保系统上的其他资源,如内存、磁盘空间等,充足且没有其他问题。
如果以上步骤都无法解决问题,建议查看
ALSA
论坛或咨询相关的技术支持团队,寻求更详细的帮助和指导。