Question

This one is for all you ALSA guys. I need a sanity check here. I am using the the alsa-lib api to play sounds and the function that I am using to write the data to the driver is

snd_pcm_sframes_t snd_pcm_writei (snd_pcm_t* pcm,
                                  const void* buffer,
                                  snd_pcm_uframes_t size);

For the third parameter, should it be the frame count or the size of the buffer in bytes? I'm asking because I have seen numerous examples where the size in bytes is passed in. One example is included in the documentation.

Was it helpful?

Solution

According to the documentation, it's the amount of frames, not bytes.

In the example you linked to the values just happen to be the same because it's using 8-bit samples and one channel, and one frame of one channel 8-bit data is one byte.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top