Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than winmm, prefix the name with the module name and a period.
waveoutprepareheader (winmm)
.
C# Signature:
[DllImport("winmm.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern uint waveOutPrepareHeader(IntPtr hWaveOut, IntPtr pwh, int uSize);
// Need to use IntPtr as WAVEHEADER struct must be in a fixed memory location. See Tips & Tricks below
VB Signature:
Declare Function waveOutPrepareHeader Lib "winmm.dll" (TODO) As TODO
User-Defined Types:
None.
Alternative Managed API:
Do you know one? Please contribute it!
Notes:
None.
Tips & Tricks:
The same WAVEHDR structure used with waveOutPrepareHeader() is also used with
the waveOutWrite() and waveOutUnPrepareHeader() functions. The latter is called
after the audio playback has been stopped with a call to waveOutReset(); The
audio driver will asynchronously set the WHDR_DONE bit in WAVEHDR.dwflags when
it has released the audio data block.
This means that the WAVEHDR struct passed to the waveOutWrite() function must be
allocated in unmanaged memory so it will survive after the call to waveOutWrite().
What I do is preallocate a block of unmanaged memory in my class's Open() method:
When the WHDR_DONE bit sets we can call the waveOutUnPrepareHeader() function to release
the resources previously set up:
if ((MMRESULT = waveOutUnprepareHeader(waveDevice, waveHdrPtr, Marshal.SizeOf(waveHdr))) != MMSYSERR_NOERROR)
[snipped]
I release the unmanaged memory allocated in the Open() method in the class's Close method:
Marshal.FreeHGlobal(waveHdrPtr);
Sample Code:
Please add some!
Please edit this page!
Do you have...
helpful tips or sample code to share for using this API in managed code?
corrections to the existing content?
variations of the signature you want to share?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).