博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
alsa的snd_pcm_readi()函数和snd_pcm_writei()
阅读量:6294 次
发布时间:2019-06-22

本文共 1617 字,大约阅读时间需要 5 分钟。

snd_pcm_readi ()

 

  snd_pcm_readi ( *pcm,

                                                             void*     buffer,

 

                                                                size

 

                                                           )

Read interleaved frames from a PCM.

 

Parameters:

  pcm  PCM handle
  buffer  frames containing buffer
  size  frames to be read
Returns:
a positive number of frames actually read otherwise a negative error code
Return values:
  -EBADFD  PCM is not in the right state ( or )
  -EPIPE  an overrun occurred
  -ESTRPIPE  a suspend event occurred (stream is suspended and waiting for an application recovery)

If the blocking behaviour was selected and it is running, then routine waits until all requested frames are filled. The returned number of frames can be less only if a signal or underrun occurred.

If the non-blocking behaviour is selected, then routine doesn't wait at all.

 

/

snd_pcm_writei()

 

snd_pcm_writei (pcm,

                                                  const void * buffer,

                                                   size

 

                                                   )

 

Write interleaved frames to a PCM.

Parameters:
  pcm  PCM handle
  buffer  frames containing buffer
  size  frames to be written
Returns:
a positive number of frames actually written otherwise a negative error code
Return values:
  -EBADFD  PCM is not in the right state ( or )
  -EPIPE  an underrun occurred
  -ESTRPIPE  a suspend event occurred (stream is suspended and waiting for an application recovery)
If the blocking behaviour is selected and it is running, then routine waits until all requested frames are played or put to the playback ring buffer. The returned number of frames can be less only if a signal or underrun occurred.

If the non-blocking behaviour is selected, then routine doesn't wait at all.

 

 我对ALSA录音和播音的理解,当我们通过麦克风讲话的声音搜集到声卡里之后,内存从声卡里读取声音数据的过程就是录音过程,即snd_pcm_readi()函数的执行,把内存中的声音数据写入到声卡的过程就是播音过程,即snd_pcm_writei()函数的执行。

转载地址:http://utpta.baihongyu.com/

你可能感兴趣的文章
Android开发笔记——常见BUG类型之内存泄露与线程安全
查看>>
oracle active data guard概述
查看>>
网络管理员基础
查看>>
myeclipse文件目录自动定位(右编辑界面点击 左边Package Explorer导航自动定位)...
查看>>
React源码学习——ReactClass
查看>>
电脑爱好者GHOSTWIN764位V4.0
查看>>
MYSQL——常用运算符和函数
查看>>
JS获取上传文件的大小
查看>>
Shell脚本调用mysql语句
查看>>
远程连接服务器的方法:
查看>>
docker入门
查看>>
linux下如何判断oracle数据库tns是否设置正常
查看>>
dell物理服务器硬件磁盘监控
查看>>
sqlserver的事务回滚和设置事务保存点操作
查看>>
https搭建(openssl)
查看>>
CISCO上ADSL配置的方法
查看>>
队列实现qq解密
查看>>
制作RPM包
查看>>
mysql多实例脚本
查看>>
python文件操作举例
查看>>