Using the ALSA snd_pcm_writei function, can you free the fetch buffer right away?

Using ALSA to play sound, after calling snd__pcm__writei , can I immediately release the sound sample buffer, or do I need to wait for the sound to finish playing before I can free the sample buffer?

For example:

unsigned short *buffer;

buffer = malloc(size of sample to play);
...load data into buffer...
snd_pcm_writei (playback_handle, buffer, size of sample)
free(buffer)

      

+2


source to share


1 answer


The easiest way to find out how to start recording backwards from the end of the buffer and see if you are affecting the audio playback. If you do this, you definitely won't be able to free the buffer. If it doesn't matter, you can safely free the buffer, since the sound card does not read this block of memory.



0


source







All Articles