Playing and Recording

The play operation involves an interrupt and two direct memory access (DMA) buffers for output data. The wave API manager prepares the data blocks and sends them to the audio driver's MDD layer. The MDD looks for block data to be played. If MDD finds block data, it calls the PDD_WaveProc function by using the WPDM_START message. The PDD copies data from the block to the temporary DMA buffers. The DMA begins playing the data. When the first of the two buffers finishes playing, an interrupt occurs. The PDD should report the interrupt to be of type AUDIO_STATE_OUT_PLAYING. If there is more data to be played, the MDD sends the message WPDM_CONTINUE. Otherwise, it sends WPDM_ENDOFDATA. As data blocks finish playing, the MDD marks them as complete and sends them back to the wave API manager.

The PDD should alternate between the two DMA buffers, filling one buffer as the other plays. If the reserve buffer is not full before the first buffer's data is finished playing, the PDD layer should report this with the return value AUDIO_STATE_OUT_UNDERFLOW. This gives the MDD layer an opportunity to synchronize and continue playing.

The record operation uses a similar mechanism to the play operation, but in reverse order. Recording starts with the PDD message WPDM_START, but no data is copied until the first DMA buffer is full. Then, the PDD copies the data from the DMA buffer into the user block. Again, as blocks are filled, the MDD returns them to the wave API manager. Recording continues until the user application requests a stop and sends the WPDM_STOP message.

Note   Audio drivers should always inspect the header information on audio data to ensure that the format matches the driver expectations. Unusual alignments of the header relative to physical page boundaries can sometimes cause the format to appear differently than it is. This occurs when some of the header data falls onto a page that has not been loaded. The driver should always verify that the audio data is in PCMWAVEFORMAT or WAVEFORMATEX format before accessing the data.

See Also

Sample Wavedev Drivers

 Last updated on Tuesday, May 18, 2004

© 1992-2003 Microsoft Corporation. All rights reserved.