5.1 Sound I/O Requests

The system-supplied soundblaster driver creates device objects of the types FILE_DEVICE_WAVE_IN, FILE_DEVICE_WAVE_OUT, FILE_DEVICE_MIDI_IN, FILE_DEVICE_MIDI_OUT, and FILE_DEVICE_SOUND, which supports the Win32 Multimedia Aux driver handler. Information about all requests for the soundblaster driver's device objects has been compressed.

IRP_MJ_CREATE

Operation

Determines whether the caller can be given a handle for the file object representing the target device object (one of wave input, wave output, MIDI input, MIDI output, or MMAux), according to the access rights requested. In general, each of the wave input, wave output, and MIDI input device objects can be opened for write access once, while all device objects can be opened concurrently for read access. That is, each device object can have only one writer at a time but many readers. However, the driver satisfies I/O control requests to set the volume from callers with read access rights when a device object has already been opened with shared-write access, so that mixer applications can be written without undue complexity.

When Called

A user-mode multimedia application has called a Win32 function and a user-mode audio driver handler opens its corresponding file object for the wave, MIDI, or MMAux device object.

Input

None

Output

None

I/O Status Block

The Information field is set to zero. The Status field either is set to STATUS_SUCCESS or possibly to STATUS_ACCESS_DENIED if the requested access is not at least FILE_READ_DATA for target input devices and both FILE_READ_DATA and FILE_WRITE_DATA for target output devices, or to STATUS_DEVICE_BUSY if the requested access is valid but resource(s) are currently unavailable.

IRP_MJ_CLEANUP

Operation

Resets the device to an idle state and cancels any IRPs currently queued to the target device object.

When Called

The Win32 subsystem is closing a multimedia application for which the device was opened.

Input

None

Output

None

I/O Status Block

The Information field is set to zero, and the Status field is set to STATUS_SUCCESS.

IRP_MJ_CLOSE

Operation

Resets the device to an idle state.

When Called

Following a cleanup request.

Input

None

Output

None

I/O Status Block

The Information field is set to zero, and the Status field is set to STATUS_SUCCESS.

IRP_MJ_READ

Operation

For the wave input device, adds the request to the queue of buffers to be recorded into. The driver copies data from its internal DMA buffer to each user-supplied buffer. For the MIDI input device, reads in data or queues the request to be read in later.

Input

Parameters.Read.Length indicates the size of the user-supplied buffer in bytes, which must be >= sizeof(MIDI_INPUT_DATA) for requests to the MIDI input device.

Output

For the wave input device, the driver copies data from its DMA buffer to the user buffer at Irp->MdlAddress. For the MIDI input device, the driver returns some number of MIDI_INPUT_DATA packets to the buffer at
Irp->AssociatedIrp.SystemBuffer.

I/O Status Block

For the wave input device, the Information field is set to the number of bytes recorded when Status is set to STATUS_SUCCESS or to STATUS_CANCELLED, but Status can be set to STATUS_PENDING if the data has not yet been recorded, to STATUS_NOT_SUPPORTED if the target device object is not the wave input device, or to STATUS_BUFFER_TOO_SMALL. For the MIDI input device, the Information field is set to the amount of data recorded when the Status field is set to STATUS_SUCCESS; otherwise, Status can be set to STATUS_PENDING if the request is queued or to STATUS_BUFFER_TOO_SMALL.

IRP_MJ_WRITE

Operation

If the target of the write is a wave output device, adds the request to the list of buffers to be played on the wave output device. The driver copies user-supplied data at Irp->MdlAddress to an internal buffer for DMA to the device.

If the target of the write is a mixer device, sets the controls details for a given control id.

Input

For a wave output device, Parameters.Write.Length indicates the number of bytes of user-supplied wave data to be played. The user buffer at Irp->MdlAddress contains the wave data to be played, which is queued in the order of received requests and, then, copied into the driver's internal DMA buffer.

For a mixer output device, Parameters.Write.Length indicates the number of bytes to be written. Parameters.Write.ByteOffset.LowPart contains the control id of the target. Irp->AssociatedIrp.SystemBuffer contains the data for the mixer control defined by control id.

Output

None

I/O Status Block

For a wave output device, the Information field is set to the number of bytes played when Status is set to STATUS_SUCCESS, but Status can be set to STATUS_PENDING if the data has not yet been played or to STATUS_NOT_SUPPORTED if the target device object is not the wave output device.

For a mixer device, the Information field is set to zero. If the call completes normally, the Status field is set to STATUS_SUCCESS. Status can be set to STATUS_BUFFER_TOO_SMALL if the data length is invalid for the control id or to STATUS_INVALID_PARAMETER if the control id is invalid.

IRP_MJ_DEVICE_CONTROL

Operation

Determined by the I/O control code at Parameters.DeviceIoControl.IoControlCode in the driver's I/O stack location of the IRP.

When Called

A Win32 application has called a Win32 multimedia function or DeviceIoControl to communicate a request to the sound driver for the MIDI or wave device.

Input

Determined by the I/O control code, but can be caller-supplied data in the buffer at Irp->AssociatedIrp.SystemBuffer, in the buffer described by the MDL at Irp->MdlAddress, or (for MIDI output) in the user buffer at Parameters.DeviceIoControl.Type3InputBuffer, with the buffer's size in the I/O stack location at Parameters.DeviceIoControl.InputBufferLength.

Output

Also determined by the I/O control code in the I/O stack location of the IRP, but data can be written into the buffer at Irp->AssociatedIrp.SystemBuffer or into the buffer described by the MDL at Irp->MdlAddress, as long as the transfer does not exceed the buffer's size in the I/O stack location at Parameters.DeviceIoControl.OutputBufferLength.

I/O Status Block

The Status field value depends on the operation, either STATUS_SUCCESS or an appropriate STATUS_XXX value. For most operations, the set of possible STATUS_XXX values includes those propagated from a call to a support routine or those chosen by the driver designer. Usually, the Information field is set to the number of bytes of data transferred.