typedef struct _WAVE_INFO {
ULONG Key;
#define WAVE_INFO_KEY (*(ULONG *)"Wave")
PDEVICE_OBJECT DeviceObject;
SOUND_DMA_BUFFER DMABuf;
SOUND_DOUBLE_BUFFER DoubleBuffer;
SOUND_BUFFER_QUEUE BufferQueue;
ULONG SamplesPerSec;
UCHAR BitsPerSample;
UCHAR Channels;
BOOLEAN FormatChanged;
PWAVEFORMATEX WaveFormat;
BOOLEAN LowPrioritySaved;
PFILE_OBJECT LowPriorityHandle;
PLOCAL_DEVICE_INFO LowPriorityDevice;
struct {
SOUND_BUFFER_QUEUE BufferQueue;
ULONG SamplesPerSec;
UCHAR BitsPerSample;
UCHAR Channels;
PWAVEFORMATEX WaveFormat;
ULONG State;
} LowPriorityModeSave;
PVOID MRB[2];
KEVENT DmaSetupEvent;
KEVENT DpcEvent;
KEVENT TimerDpcEvent;
KSPIN_LOCK DeviceSpinLock;
#if DBG
BOOLEAN LockHeld;
#endif
PKINTERRUPT Interrupt;
BOOLEAN Direction;
UCHAR DMAType;
UCHAR InterruptHalf;
volatile BOOLEAN DMABusy;
volatile BOOLEAN DpcQueued;
ULONG Overrun;
PVOID HwContext;
WORK_QUEUE_ITEM WaveStopWorkItem;
KEVENT WaveReallyComplete;
PSOUND_QUERY_FORMAT_ROUTINE QueryFormat;
PWAVE_INTERFACE_ROUTINE
HwSetupDMA,
HwStopDMA,
HwSetWaveFormat;
KDPC TimerDpc;
KTIMER DeviceCheckTimer;
BOOLEAN GotWaveDpc;
BOOLEAN DeviceBad;
BOOLEAN TimerActive;
UCHAR FailureCount;
} WAVE_INFO, *PWAVE_INFO;
The WAVE_INFO structure contains wave device context information.
LowPrioritySaved
LowPriorityHandle
LowPriorityDevice
enum {
SoundNoDMA,
SoundAutoInitDMA, // Use auto-initialize
SoundReprogramOnInterruptDMA, // Reprogram on interrupt
Sound2ChannelDMA // Keep 2 channels going
};
Sound2ChannelDMA is not currently supported in soundlib.lib. It
is intended for a device whose hardware uses two DMA channels and alternates
between them to achieve continuous sound.
The function is called after soundlib.lib has set up map registers by
calling IoMapTransfer. For more
information, see \src\mmedia\soundlib\wave.c.
The function is called just before soundlib.lib calls IoFlushAdapterBuffers. For more information, see \src\mmedia\soundlib\wave.c.
Note: HwStopDMA must not acquire the device exclusion mutex that soundlib.lib uses to synchronize device access. Code in soundlib.lib waits for a transfer to complete before starting a new one, and this wait occurs inside a request to the device, when the mutex is owned by the waiting thread. This means that HwStopDMA can require extra synchronization code, even though no further hardware calls to the current device can occur until the current transfer is complete.
The function is called just before soundlib.lib starts each DMA
transfer. For more information, see \src\mmedia\soundlib\wave.c.
One WAVE_INFO structure must be defined for each waveform device (input or output) that can be in operation simultaneously. WAVE_INFO is defined in wave.h.
Allocate a WAVE_INFO structure from the nonpaged memory pool by calling ExAllocatePool, and then zero it by calling RtlZeroMemory. To initialize a WAVE_INFO structure, assign values to the HwSetupDMA, HwStopDMA, and HwSetWaveFormat members and then call SoundInitializeWaveInfo.
To create a waveform device object, call SoundCreateDevice and specify a WAVE_INFO structure pointer for the DeviceSpecificData parameter.