Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
使用 ALSA 播放音频,在调用snd__pcm__writei之后,我可以立即释放声音样本缓冲区还是需要等到声音播放完毕才能释放样本缓冲区?
例如:
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)
最简单的找出方法是从缓冲区的末尾开始向后写入,看看是否影响音频播放。如果你这样做了,那么你肯定不能释放缓冲区。如果没有区别,那么您可以安全地释放缓冲区,因为声卡没有从该特定内存块读取。