After the mixer device is set up to use DART, the application instructs the device to allocate memory by sending the MCI_BUFFER message with the MCI_ALLOCATE_MEMORY flag set. The application uses the MCI_BUFFER_PARMS structure to specify the number of buffers it wants and the size to be used for each buffer.
Note: Because of device driver restrictions, buffers are limited to 64KB on Intel-based systems. No such limit exists on PowerPC systems.
The pBufList field contains a pointer to an array of MCI_MIX_BUFFER structures where the allocated information is to be returned.
typedef struct_MCI_BUFFER_PARMS { HWND hwndCallback; /* Window for notifications */ ULONG ulStructLength; /* Length of MCI_BUFFER_PARMS */ ULONG ulNumBuffers; /* Number of buffers to allocate (IN/OUT)*/ ULONG ulBufferSize; /* Size of buffers mixer should use */ ULONG ulMintoStart; /* Unused */ ULONG ulSrcStart; /* Unused */ ULONG ulTgtStart; /* Unused */ PVOID pBufList; /* Pointer to array of buffers */ } MCI_BUFFER_PARMS; typedef MCI_BUFFER_PARMS *PMCI_BUFFER_PARMS;
The following example illustrates using MCI_BUFFER to allocate memory.
MCI_MIX_BUFFER MyBuffers[ MAX_BUFFERS ]; BufferParms.ulNumBuffers = 40; BufferParms.ulBufferSize = 4096; BufferParms.pBufList = MyBuffers; rc = mciSendCommand( usDeviceID, MCI_BUFFER, MCI_WAIT | MCI_ALLOCATE_MEMORY, ( PVOID ) &BufferParms, 0 ); if ( ULONG_LOWD( rc) != MCIERR_SUCCESS ) { printf( "Error allocating memory. rc is : %d", rc ); exit ( 1 ); } // MCI driver will return the number of buffers it // was able to allocate // it will also return the size of the information // allocated with each buffer. ulNumBuffers = BufferParms.ulNumBuffers; for ( ulLoop = 0; ulLoop < ulNumBuffers; ulLoop++ ) { rc = mmioRead ( hmmio, MyBuffers[ ulLoop ].pBuffer, MyBuffers[ ulLoop ].ulBufferLength); if ( !rc ) { exit( rc ); } MyBuffers[ ulLoop ].ulUserParm = ulLoop; }