IN PWDMAUD_CLIENT ClientInfo)
{
ULONG Result = 0;
- NTSTATUS Status = STATUS_SUCCESS;
- //PWDMAUD_DEVICE_EXTENSION DeviceExtension;
-
- //DeviceExtension = (PWDMAUD_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
if (DeviceInfo->DeviceType == MIXER_DEVICE_TYPE)
{
}
else if (DeviceInfo->DeviceType == WAVE_OUT_DEVICE_TYPE)
{
- Result = WdmAudGetWaveInDeviceCount();
+ Result = WdmAudGetWaveOutDeviceCount();
}
else if (DeviceInfo->DeviceType == WAVE_IN_DEVICE_TYPE)
{
- Result = WdmAudGetWaveOutDeviceCount();
+ Result = WdmAudGetWaveInDeviceCount();
}
else if (DeviceInfo->DeviceType == MIDI_IN_DEVICE_TYPE)
{
/* store result count */
DeviceInfo->DeviceCount = Result;
- DPRINT("WdmAudControlDeviceType Status %x Devices %u\n", Status, DeviceInfo->DeviceCount);
+ DPRINT("WdmAudControlDeviceType Devices %u\n", DeviceInfo->DeviceCount);
return SetIrpIoStatus(Irp, STATUS_SUCCESS, sizeof(WDMAUD_DEVICE_INFO));
}
}
else if (ClientInfo->hPins[Index].Handle == DeviceInfo->hDevice && ClientInfo->hPins[Index].Type == MIXER_DEVICE_TYPE)
{
- if (ClientInfo->hPins[Index].NotifyEvent)
- {
- ObDereferenceObject(ClientInfo->hPins[Index].NotifyEvent);
- ClientInfo->hPins[Index].NotifyEvent = NULL;
- }
+ DPRINT1("Closing mixer %p\n", DeviceInfo->hDevice);
+ return WdmAudControlCloseMixer(DeviceObject, Irp, DeviceInfo, ClientInfo, Index);
}
}
IN PIRP Irp,
IN PWDMAUD_DEVICE_INFO DeviceInfo)
{
- //PWDMAUD_DEVICE_EXTENSION DeviceExtension;
NTSTATUS Status;
LPWSTR Device;
ULONG Size, Length;
- /* get device extension */
- //DeviceExtension = (PWDMAUD_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
-
/* get device interface string input length */
Size = DeviceInfo->u.Interface.DeviceInterfaceStringSize;
case IOCTL_GETVOLUME:
case IOCTL_SETVOLUME:
- DPRINT1("Unhandeled %x\n", IoStack->Parameters.DeviceIoControl.IoControlCode);
+ DPRINT1("Unhandled %x\n", IoStack->Parameters.DeviceIoControl.IoControlCode);
break;
}
PVOID Ctx)
{
PKSSTREAM_HEADER Header;
- ULONG Length = 0;
PMDL Mdl, NextMdl;
PWDMAUD_COMPLETION_CONTEXT Context = (PWDMAUD_COMPLETION_CONTEXT)Ctx;
/* grab next mdl */
Mdl = NextMdl;
}
-
+ //IoFreeMdl(Mdl);
/* clear mdl list */
- Irp->MdlAddress = NULL;
+ Irp->MdlAddress = Context->Mdl;
- /* check if mdl is locked */
- if (Context->Mdl->MdlFlags & MDL_PAGES_LOCKED)
- {
- /* unlock pages */
- MmUnlockPages(Context->Mdl);
- }
- /* now free the mdl */
- IoFreeMdl(Context->Mdl);
- DPRINT("IoCompletion Irp %p IoStatus %lx Information %lx Length %lu\n", Irp, Irp->IoStatus.Status, Irp->IoStatus.Information, Length);
+ DPRINT("IoCompletion Irp %p IoStatus %lx Information %lx\n", Irp, Irp->IoStatus.Status, Irp->IoStatus.Information);
if (!NT_SUCCESS(Irp->IoStatus.Status))
{
Irp->IoStatus.Information = 0;
}
+ /* dereference file object */
+ ObDereferenceObject(Context->FileObject);
+
/* free context */
FreeItem(Context);
/* store mdl address */
Mdl = Irp->MdlAddress;
- /* remove mdladdress as KsProbeStreamIrp will interprete it as an already probed audio buffer */
+ /* remove mdladdress as KsProbeStreamIrp will interpret it as an already probed audio buffer */
Irp->MdlAddress = NULL;
- /* check for success */
-
if (IoStack->MajorFunction == IRP_MJ_WRITE)
{
/* probe the write stream irp */
{
DPRINT1("KsProbeStreamIrp failed with Status %x Cancel %u\n", Status, Irp->Cancel);
Irp->MdlAddress = Mdl;
+ FreeItem(Context);
return SetIrpIoStatus(Irp, Status, 0);
}
if (!NT_SUCCESS(Status))
{
DPRINT1("Invalid pin handle %p\n", DeviceInfo->hDevice);
+ Irp->MdlAddress = Mdl;
+ FreeItem(Context);
return SetIrpIoStatus(Irp, Status, 0);
}
+ /* store file object whose reference is released in the completion callback */
+ Context->FileObject = FileObject;
+
/* skip current irp stack location */
IoSkipCurrentIrpStackLocation(Irp);
/* get next stack location */
IoStack = IoGetNextIrpStackLocation(Irp);
- if (Read)
- {
- IoStack->Parameters.DeviceIoControl.IoControlCode = IOCTL_KS_READ_STREAM;
- }
- else
- {
- IoStack->Parameters.DeviceIoControl.IoControlCode = IOCTL_KS_WRITE_STREAM;
- }
-
- /* attach file object */
+ /* prepare stack location */
IoStack->FileObject = FileObject;
IoStack->Parameters.Write.Length = Length;
IoStack->MajorFunction = IRP_MJ_WRITE;
-
+ IoStack->Parameters.DeviceIoControl.IoControlCode = (Read ? IOCTL_KS_READ_STREAM : IOCTL_KS_WRITE_STREAM);
IoSetCompletionRoutine(Irp, IoCompletion, (PVOID)Context, TRUE, TRUE, TRUE);
-
/* mark irp as pending */
// IoMarkIrpPending(Irp);
/* call the driver */
Status = IoCallDriver(IoGetRelatedDeviceObject(FileObject), Irp);
-
- /* dereference file object */
- ObDereferenceObject(FileObject);
-
return Status;
}