alsa的snd_pcm_readi()函数和snd_pcm_writei()

99 篇文章 0 订阅
80 篇文章 0 订阅

snd_pcm_readi ()

snd_pcm_sframes_t snd_pcm_readi ( snd_pcm_t *pcm,

                                                             void*     buffer,

                                                             snd_pcm_uframes_t   size

                                                           )

Read interleaved frames from a PCM.

Parameters:

 pcmPCM handle
 bufferframes containing buffer
 sizeframes to be read
Returns:
a positive number of frames actually read otherwise a negative error code
Return values:
 -EBADFDPCM is not in the right state (SND_PCM_STATE_PREPARED or SND_PCM_STATE_RUNNING)
 -EPIPEan overrun occurred
 -ESTRPIPEa 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_sframes_t snd_pcm_writei (snd_pcm_t * pcm,

                                                  const void * buffer,

                                                  snd_pcm_uframes_t size

                                                   )

Write interleaved frames to a PCM.

Parameters:
 pcmPCM handle
 bufferframes containing buffer
 sizeframes to be written
Returns:
a positive number of frames actually written otherwise a negative error code
Return values:
 -EBADFDPCM is not in the right state (SND_PCM_STATE_PREPARED or SND_PCM_STATE_RUNNING)
 -EPIPEan underrun occurred
 -ESTRPIPEa 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://blog.csdn.net/woxiaozhi/article/details/6284099

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值