Alsa Snd_pcm_readi () function and Snd_pcm_writei () __ function

Source: Internet
Author: User

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:

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 The PCM is isn't in the right state (snd_pcm_state_prepared or snd_pcm_state_running)
-epipe An overrun occurred
-estrpipe A suspend event occurred (the stream is suspended and waiting for a application recovery)

If the blocking behaviour was selected and it are running, then routine waits until all requested frames are. 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 in 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:

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 The PCM is isn't in the right state (snd_pcm_state_prepared or snd_pcm_state_running)
-epipe An underrun occurred
-estrpipe A suspend event occurred (the stream is suspended and waiting for a application recovery)
If The blocking behaviour is selected and it are running, then routine waits until the all requested frames are played or put T o 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 in all.

My understanding of ALSA recording and broadcasting, when we collect the sound from the voice of the microphone, the process of reading the sound data from the sound card is the recording process, that is, the execution of the Snd_pcm_readi () function, the process of writing the audio data to the sound card in memory is the broadcasting process, that is Snd_ Execution of the Pcm_writei () function.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.