[ros-diffs] [janderwald] 43045: - Remove obsolete code - Fix closing of virtual audio devices introduced 43035

janderwald at svn.reactos.org janderwald at svn.reactos.org
Mon Sep 14 00:26:59 CEST 2009


Author: janderwald
Date: Mon Sep 14 00:26:59 2009
New Revision: 43045

URL: http://svn.reactos.org/svn/reactos?rev=43045&view=rev
Log:
- Remove obsolete code
- Fix closing of virtual audio devices introduced 43035

Modified:
    trunk/reactos/drivers/wdm/audio/sysaudio/pin.c

Modified: trunk/reactos/drivers/wdm/audio/sysaudio/pin.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/sysaudio/pin.c?rev=43045&r1=43044&r2=43045&view=diff
==============================================================================
--- trunk/reactos/drivers/wdm/audio/sysaudio/pin.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/sysaudio/pin.c [iso-8859-1] Mon Sep 14 00:26:59 2009
@@ -61,31 +61,43 @@
     return Status;
 }
 
+
+
 NTSTATUS
 NTAPI
-Pin_fnRead(
+Pin_fnWrite(
     PDEVICE_OBJECT DeviceObject,
     PIRP Irp)
 {
     PDISPATCH_CONTEXT Context;
     PIO_STACK_LOCATION IoStack;
-    ULONG BytesReturned;
     PFILE_OBJECT FileObject;
     NTSTATUS Status;
+    ULONG Length;
 
     /* Get current stack location */
     IoStack = IoGetCurrentIrpStackLocation(Irp);
 
+    Length = IoStack->Parameters.Write.Length;
+
     /* The dispatch context is stored in the FsContext member */
     Context = (PDISPATCH_CONTEXT)IoStack->FileObject->FsContext;
 
     /* Sanity check */
     ASSERT(Context);
 
+    if (Context->hMixerPin)
+    {
+        // FIXME
+        // call kmixer to convert stream
+        UNIMPLEMENTED
+    }
+
     /* acquire real pin file object */
     Status = ObReferenceObjectByHandle(Context->Handle, GENERIC_WRITE, IoFileObjectType, KernelMode, (PVOID*)&FileObject, NULL);
     if (!NT_SUCCESS(Status))
     {
+        DPRINT1("failed\n");
         Irp->IoStatus.Information = 0;
         Irp->IoStatus.Status = Status;
         /* Complete the irp */
@@ -93,179 +105,19 @@
         return Status;
     }
 
-    /* Re-dispatch the request to the real target pin */
-    Status = KsSynchronousIoControlDevice(FileObject, KernelMode, IOCTL_KS_READ_STREAM,
-                                          MmGetMdlVirtualAddress(Irp->MdlAddress),
-                                          IoStack->Parameters.Read.Length,
-                                          NULL,
-                                          0,
-                                          &BytesReturned);
-
-    /* release file object */
-    ObDereferenceObject(FileObject);
-
-    if (Context->hMixerPin)
-    {
-        // FIXME
-        // call kmixer to convert stream
-        UNIMPLEMENTED
-    }
-
-    /* Save status and information */
-    Irp->IoStatus.Status = Status;
-    Irp->IoStatus.Information = 0;
-    /* Complete the irp */
-    IoCompleteRequest(Irp, IO_NO_INCREMENT);
-    /* Done */
-    return Status;
-}
-
-NTSTATUS
-NTAPI
-Pin_fnWrite(
-    PDEVICE_OBJECT DeviceObject,
-    PIRP Irp)
-{
-    PDISPATCH_CONTEXT Context;
-    PIO_STACK_LOCATION IoStack;
-    PFILE_OBJECT FileObject;
-    PVOID Buffer;
-    NTSTATUS Status;
-    ULONG BytesReturned;
-
-    /* Get current stack location */
-    IoStack = IoGetCurrentIrpStackLocation(Irp);
-
-    /* The dispatch context is stored in the FsContext member */
-    Context = (PDISPATCH_CONTEXT)IoStack->FileObject->FsContext;
-
-    /* Sanity check */
-    ASSERT(Context);
-
-    if (Context->hMixerPin)
-    {
-        // FIXME
-        // call kmixer to convert stream
-        UNIMPLEMENTED
-    }
-
-    /* acquire real pin file object */
-    Status = ObReferenceObjectByHandle(Context->Handle, GENERIC_WRITE, IoFileObjectType, KernelMode, (PVOID*)&FileObject, NULL);
-    if (!NT_SUCCESS(Status))
-    {
-        Irp->IoStatus.Information = 0;
-        Irp->IoStatus.Status = Status;
-        /* Complete the irp */
-        IoCompleteRequest(Irp, IO_NO_INCREMENT);
-        return Status;
-    }
-
-    Buffer = MmGetSystemAddressForMdlSafe(Irp->MdlAddress, NormalPagePriority);
-
-    if (!Buffer)
-    {
-        /* insufficient resources */
-        Irp->IoStatus.Status = STATUS_INSUFFICIENT_RESOURCES;
-        /* Complete the irp */
-        IoCompleteRequest(Irp, IO_NO_INCREMENT);
-        return STATUS_INSUFFICIENT_RESOURCES;
-    }
-
-
-    /* call the portcls audio pin */
-    Status = KsSynchronousIoControlDevice(FileObject, KernelMode, IOCTL_KS_WRITE_STREAM,
-                                          NULL,
-                                          0,
-                                          Buffer,
-                                          IoStack->Parameters.Write.Length,
-                                          &BytesReturned);
-
-    /* Release file object */
-    ObDereferenceObject(FileObject);
-
-    /* Save status and information */
-    Irp->IoStatus.Status = Status;
-    Irp->IoStatus.Information = BytesReturned;
-    /* Complete the irp */
-    IoCompleteRequest(Irp, IO_NO_INCREMENT);
-    /* Done */
-    return Status;
-}
-
-NTSTATUS
-NTAPI
-Pin_fnFlush(
-    PDEVICE_OBJECT DeviceObject,
-    PIRP Irp)
-{
-    PDISPATCH_CONTEXT Context;
-    PIO_STACK_LOCATION IoStack;
-    PDEVICE_OBJECT PinDeviceObject;
-    PIRP PinIrp;
-    PFILE_OBJECT FileObject;
-    IO_STATUS_BLOCK IoStatus;
-    KEVENT Event;
-    NTSTATUS Status = STATUS_UNSUCCESSFUL;
-
-    /* Get current stack location */
-    IoStack = IoGetCurrentIrpStackLocation(Irp);
-
-    /* The dispatch context is stored in the FsContext member */
-    Context = (PDISPATCH_CONTEXT)IoStack->FileObject->FsContext;
-
-    /* Sanity check */
-    ASSERT(Context);
-
-
-    /* acquire real pin file object */
-    Status = ObReferenceObjectByHandle(Context->Handle, GENERIC_WRITE, IoFileObjectType, KernelMode, (PVOID*)&FileObject, NULL);
-    if (!NT_SUCCESS(Status))
-    {
-        Irp->IoStatus.Information = 0;
-        Irp->IoStatus.Status = Status;
-        /* Complete the irp */
-        IoCompleteRequest(Irp, IO_NO_INCREMENT);
-        return Status;
-    }
-
-    /* Get Pin's device object */
-    PinDeviceObject = IoGetRelatedDeviceObject(FileObject);
-
-    /* release file object */
-    ObDereferenceObject(FileObject);
-
-    /* Initialize notification event */
-    KeInitializeEvent(&Event, NotificationEvent, FALSE);
-
-    /* build target irp */
-    PinIrp = IoBuildSynchronousFsdRequest(IRP_MJ_FLUSH_BUFFERS, PinDeviceObject, NULL, 0, NULL, &Event, &IoStatus);
-    if (PinIrp)
-    {
-
-        /* Get the next stack location */
-        IoStack = IoGetNextIrpStackLocation(PinIrp);
-        /* The file object must be present in the irp as it contains the KSOBJECT_HEADER */
-        IoStack->FileObject = FileObject;
-
-        /* call the driver */
-        Status = IoCallDriver(PinDeviceObject, PinIrp);
-        /* Has request already completed ? */
-        if (Status == STATUS_PENDING)
-        {
-            /* Wait untill the request has completed */
-            KeWaitForSingleObject(&Event, UserRequest, KernelMode, FALSE, NULL);
-            /* Update status */
-            Status = IoStatus.Status;
-        }
-    }
-
-    /* store status */
-    Irp->IoStatus.Status = Status;
-    Irp->IoStatus.Information = 0;
-    /* Complete the irp */
-    IoCompleteRequest(Irp, IO_NO_INCREMENT);
-    /* Done */
-    return Status;
+    /* skip current irp location */
+    IoSkipCurrentIrpStackLocation(Irp);
+
+    /* get next stack location */
+    IoStack = IoGetNextIrpStackLocation(Irp);
+    /* store file object of next device object */
+    IoStack->FileObject = FileObject;
+    IoStack->MajorFunction = IRP_MJ_DEVICE_CONTROL;
+    IoStack->Parameters.DeviceIoControl.IoControlCode = IOCTL_KS_WRITE_STREAM; //FIXME
+    IoStack->Parameters.DeviceIoControl.OutputBufferLength = Length;
+
+    /* now call the driver */
+    return IoCallDriver(IoGetRelatedDeviceObject(FileObject), Irp);
 }
 
 NTSTATUS
@@ -297,68 +149,6 @@
     Irp->IoStatus.Information = 0;
     IoCompleteRequest(Irp, IO_NO_INCREMENT);
     return STATUS_SUCCESS;
-}
-
-NTSTATUS
-NTAPI
-Pin_fnQuerySecurity(
-    PDEVICE_OBJECT DeviceObject,
-    PIRP Irp)
-{
-    DPRINT("Pin_fnQuerySecurity called DeviceObject %p Irp %p\n", DeviceObject);
-
-    Irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
-    Irp->IoStatus.Information = 0;
-    IoCompleteRequest(Irp, IO_NO_INCREMENT);
-    return STATUS_UNSUCCESSFUL;
-}
-
-NTSTATUS
-NTAPI
-Pin_fnSetSecurity(
-    PDEVICE_OBJECT DeviceObject,
-    PIRP Irp)
-{
-
-    DPRINT("Pin_fnSetSecurity called DeviceObject %p Irp %p\n", DeviceObject);
-
-    Irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
-    Irp->IoStatus.Information = 0;
-    IoCompleteRequest(Irp, IO_NO_INCREMENT);
-    return STATUS_UNSUCCESSFUL;
-}
-
-BOOLEAN
-NTAPI
-Pin_fnFastDeviceIoControl(
-    PFILE_OBJECT FileObject,
-    BOOLEAN Wait,
-    PVOID InputBuffer,
-    ULONG InputBufferLength,
-    PVOID OutputBuffer,
-    ULONG OutputBufferLength,
-    ULONG IoControlCode,
-    PIO_STATUS_BLOCK IoStatus,
-    PDEVICE_OBJECT DeviceObject)
-{
-    return FALSE;
-}
-
-
-BOOLEAN
-NTAPI
-Pin_fnFastRead(
-    PFILE_OBJECT FileObject,
-    PLARGE_INTEGER FileOffset,
-    ULONG Length,
-    BOOLEAN Wait,
-    ULONG LockKey,
-    PVOID Buffer,
-    PIO_STATUS_BLOCK IoStatus,
-    PDEVICE_OBJECT DeviceObject)
-{
-    return FALSE;
-
 }
 
 BOOLEAN
@@ -404,7 +194,7 @@
 
     Status = KsStreamIo(RealFileObject, NULL, NULL, NULL, NULL, 0, IoStatus, Buffer, Length, KSSTREAM_WRITE, UserMode);
 
-    //ObDereferenceObject(RealFileObject);
+    ObDereferenceObject(RealFileObject);
 
     if (NT_SUCCESS(Status))
         return TRUE;
@@ -415,14 +205,14 @@
 static KSDISPATCH_TABLE PinTable =
 {
     Pin_fnDeviceIoControl,
-    Pin_fnRead,
+    KsDispatchInvalidDeviceRequest,
     Pin_fnWrite,
-    Pin_fnFlush,
+    KsDispatchInvalidDeviceRequest,
     Pin_fnClose,
-    Pin_fnQuerySecurity,
-    Pin_fnSetSecurity,
-    Pin_fnFastDeviceIoControl,
-    Pin_fnFastRead,
+    KsDispatchInvalidDeviceRequest,
+    KsDispatchInvalidDeviceRequest,
+    KsDispatchFastIoDeviceControlFailure,
+    KsDispatchFastReadFailure,
     Pin_fnFastWrite,
 };
 




More information about the Ros-diffs mailing list