KSDATAFORMAT_WAVEFORMATEX * DataFormat;
ULONG FilterId;
ULONG PinId;
+ ULONG FreeIndex;
if (DeviceInfo->DeviceType == MIXER_DEVICE_TYPE)
{
}
/* close pin handle which uses same virtual audio device id and pin id */
+ FreeIndex = (ULONG)-1;
for(Index = 0; Index < ClientInfo->NumPins; Index++)
{
- if (ClientInfo->hPins[Index].FilterId == FilterId && ClientInfo->hPins[Index].PinId == PinId && ClientInfo->hPins[Index].Handle)
+ if (ClientInfo->hPins[Index].FilterId == FilterId && ClientInfo->hPins[Index].PinId == PinId && ClientInfo->hPins[Index].Handle && ClientInfo->hPins[Index].Type == DeviceInfo->DeviceType)
{
ZwClose(ClientInfo->hPins[Index].Handle);
ClientInfo->hPins[Index].Handle = NULL;
+ FreeIndex = Index;
}
}
{
PWDMAUD_HANDLE Handels;
- for(Index = 0; Index < ClientInfo->NumPins; Index++)
+ if (FreeIndex != (ULONG)-1)
{
- if (ClientInfo->hPins[Index].Handle == NULL)
- {
- /* re-use a free index */
- ClientInfo->hPins[Index].Handle = PinHandle;
- ClientInfo->hPins[Index].FilterId = FilterId;
- ClientInfo->hPins[Index].PinId = PinId;
- ClientInfo->hPins[Index].Type = DeviceInfo->DeviceType;
-
- DeviceInfo->hDevice = PinHandle;
- return SetIrpIoStatus(Irp, Status, sizeof(WDMAUD_DEVICE_INFO));
- }
+ /* re-use a free index */
+ ClientInfo->hPins[Index].Handle = PinHandle;
+ ClientInfo->hPins[Index].FilterId = FilterId;
+ ClientInfo->hPins[Index].PinId = PinId;
+ ClientInfo->hPins[Index].Type = DeviceInfo->DeviceType;
+
+ DeviceInfo->hDevice = PinHandle;
+ return SetIrpIoStatus(Irp, Status, sizeof(WDMAUD_DEVICE_INFO));
}
Handels = ExAllocatePool(NonPagedPool, sizeof(WDMAUD_HANDLE) * (ClientInfo->NumPins+1));
Property.Id = KSPROPERTY_CONNECTION_STATE;
Property.Flags = KSPROPERTY_TYPE_SET;
- State = DeviceInfo->State;
+ State = DeviceInfo->u.State;
Status = KsSynchronousIoControlDevice(FileObject, KernelMode, IOCTL_KS_PROPERTY, (PVOID)&Property, sizeof(KSPROPERTY), (PVOID)&State, sizeof(KSSTATE), &BytesReturned);
return WdmAudCapabilities(DeviceObject, Irp, DeviceInfo, ClientInfo);
case IOCTL_CLOSE_WDMAUD:
return WdmAudIoctlClose(DeviceObject, Irp, DeviceInfo, ClientInfo);
+ case IOCTL_GETPOS:
+ DPRINT1("IOCTL_GETPOS\n");
case IOCTL_GETDEVID:
case IOCTL_GETVOLUME:
case IOCTL_SETVOLUME:
HANDLE hDevice;
ULONG DeviceCount;
- KSSTATE State;
- ULONG Volume;
ULONG BufferSize;
PUCHAR Buffer;
WAVEFORMATEX WaveFormatEx;
WAVEOUTCAPSW WaveOutCaps;
AUXCAPSW AuxCaps;
- WAVEINCAPSW WaveInCaps;
+ WAVEINCAPSW WaveInCaps;
+ ULONGLONG Position;
+ KSSTATE State;
+ ULONG Volume;
}u;
}WDMAUD_DEVICE_INFO, *PWDMAUD_DEVICE_INFO;
METHOD_BUFFERED, \
FILE_CREATE_TREE_CONNECTION | FILE_ANY_ACCESS)
+/// IOCTL_GETPOS
+///
+/// Description: This IOCTL retrieves the current playback / write position
+///
+/// Arguments: InputBuffer is a pointer to a WDMAUD_DEVICE_INFO structure,
+/// InputBufferSize is size of WDMAUD_DEVICE_INFO structure
+/// Note: The DeviceType and hDevice must be set
+/// Result: The result is returned in Volume
+/// ReturnCode: STATUS_SUCCESS indicates success
+/// Prequsites: opened device
+
+#define IOCTL_GETPOS \
+ CTL_CODE(FILE_DEVICE_SOUND, \
+ 9, \
+ METHOD_BUFFERED, \
+ FILE_CREATE_TREE_CONNECTION | FILE_ANY_ACCESS)
+
#endif