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.