diff --git a/reactos/drivers/wdm/audio/legacy/wdmaud/control.c b/reactos/drivers/wdm/audio/legacy/wdmaud/control.c index 795f0ffcfd0..2f9507c1c15 100644 --- a/reactos/drivers/wdm/audio/legacy/wdmaud/control.c +++ b/reactos/drivers/wdm/audio/legacy/wdmaud/control.c @@ -146,6 +146,7 @@ WdmAudControlOpen( KSDATAFORMAT_WAVEFORMATEX * DataFormat; ULONG FilterId; ULONG PinId; + ULONG FreeIndex; if (DeviceInfo->DeviceType == MIXER_DEVICE_TYPE) { @@ -166,12 +167,14 @@ WdmAudControlOpen( } /* 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; } } @@ -248,19 +251,16 @@ WdmAudControlOpen( { 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; + /* 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)); - } + DeviceInfo->hDevice = PinHandle; + return SetIrpIoStatus(Irp, Status, sizeof(WDMAUD_DEVICE_INFO)); } Handels = ExAllocatePool(NonPagedPool, sizeof(WDMAUD_HANDLE) * (ClientInfo->NumPins+1)); @@ -411,7 +411,7 @@ WdmAudControlDeviceState( 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); @@ -647,6 +647,8 @@ WdmAudDeviceControl( 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: diff --git a/reactos/drivers/wdm/audio/legacy/wdmaud/interface.h b/reactos/drivers/wdm/audio/legacy/wdmaud/interface.h index e541453fbc6..7221fc447cc 100644 --- a/reactos/drivers/wdm/audio/legacy/wdmaud/interface.h +++ b/reactos/drivers/wdm/audio/legacy/wdmaud/interface.h @@ -30,8 +30,6 @@ typedef struct HANDLE hDevice; ULONG DeviceCount; - KSSTATE State; - ULONG Volume; ULONG BufferSize; PUCHAR Buffer; @@ -41,7 +39,10 @@ typedef struct WAVEFORMATEX WaveFormatEx; WAVEOUTCAPSW WaveOutCaps; AUXCAPSW AuxCaps; - WAVEINCAPSW WaveInCaps; + WAVEINCAPSW WaveInCaps; + ULONGLONG Position; + KSSTATE State; + ULONG Volume; }u; }WDMAUD_DEVICE_INFO, *PWDMAUD_DEVICE_INFO; @@ -204,5 +205,22 @@ typedef struct 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