waveoutwrite函数将WAVEHDR *复制到设备缓冲区还是将其用作参考? [英] does waveoutwrite function copy WAVEHDR* to device buffer OR it uses it as reference?

查看:228
本文介绍了waveoutwrite函数将WAVEHDR *复制到设备缓冲区还是将其用作参考?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我正在使用mmsystem的wavout *函数播放音频.

I am using mmsystem's wavout* functions for audio playback. 

我想在waveOutWrite函数之后立即删除分配的堆.我每次都会为新块分配512 * 16大小的新堆,并且出于内存管理的考虑,我想在waveOutWrite之后将其删除.

I want to delete the allocated heap immediately after waveOutWrite function. I am allocating new heap of 512 * 16 size for new chunk every time and I wanted to delete it after waveOutWrite, for the matter of memory management.

如果我这样做,可以在设备上使用吗?或waveOutWrite将使用我传递给它的waveHdr指针的引用,由于这个原因,我需要等待直到WOM_DONE回调删除分配的缓冲区?

If i do this, will it be ok for device? OR waveOutWrite will use the reference of the waveHdr pointer I have passed to it and due to this I need to wait until WOM_DONE callback to delete allocated buffer? 

我每次都会为新块分配新的堆,以防止急促的音频播放.

I am allocating new heaps each time for new chunks for the purpose of anit-jerk audio playback.

 

谢谢.

推荐答案

无论使用哪种通知机制,您都必须等待驱动程序完成缓冲区的播放.

You must wait until the driver has finished playing the buffer, whatever notification mechanism you use.

分配内存是非常昂贵的操作.每次分配一个新缓冲区都比使用预先分配的缓冲区慢.

Allocating memory is a very expensive operation. Allocating a new buffer each time is going to be slower than using a pool of preallocated buffers.


这篇关于waveoutwrite函数将WAVEHDR *复制到设备缓冲区还是将其用作参考?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆