ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

pin.c
Go to the documentation of this file.
00001 /*
00002  * COPYRIGHT:       See COPYING in the top level directory
00003  * PROJECT:         ReactOS Kernel Streaming
00004  * FILE:            drivers/wdm/audio/filters/splitter/pin.c
00005  * PURPOSE:         Pin Context Handling
00006  * PROGRAMMER:      Johannes Anderwald
00007  */
00008 
00009 #include "precomp.h"
00010 
00011 NTSTATUS
00012 NTAPI
00013 PinCreate(
00014     IN PKSPIN  Pin,
00015     IN PIRP  Irp)
00016 {
00017     PKSFILTER Filter;
00018     PKSPIN FirstPin;
00019     PPIN_CONTEXT PinContext;
00020 
00021     /* first get the parent filter */
00022     Filter = KsPinGetParentFilter(Pin);
00023 
00024     /* now get first child pin */
00025     FirstPin = KsFilterGetFirstChildPin(Filter, Pin->Id);
00026 
00027     /* sanity check */
00028     ASSERT(FirstPin);
00029 
00030     if (FirstPin != Pin)
00031     {
00032         /* a previous pin already exists */
00033         if (RtlCompareMemory(FirstPin->ConnectionFormat, Pin->ConnectionFormat, Pin->ConnectionFormat->FormatSize) != Pin->ConnectionFormat->FormatSize)
00034         {
00035             /* each instantiated pin must have the same connection format */
00036             return STATUS_INVALID_PARAMETER;
00037         }
00038     }
00039 
00040     /* allocate pin context */
00041     PinContext = ExAllocatePool(NonPagedPool, sizeof(PIN_CONTEXT));
00042     if (!PinContext)
00043         return STATUS_INSUFFICIENT_RESOURCES;
00044 
00045     /* store pin context */
00046     Pin->Context = PinContext;
00047 
00048     /* clear pin context */
00049     RtlZeroMemory(PinContext, sizeof(PIN_CONTEXT));
00050 
00051     /* FIXME
00052      * check allocator framing and apply to all pins 
00053      */
00054 
00055     return STATUS_SUCCESS;
00056 }
00057 
00058 NTSTATUS
00059 NTAPI
00060 PinClose(
00061     IN PKSPIN  Pin,
00062     IN PIRP  Irp)
00063 {
00064     /* is there a context */
00065     if (Pin->Context)
00066     {
00067         /* free pin context */
00068         ExFreePool(Pin->Context);
00069     }
00070 
00071     return STATUS_SUCCESS;
00072 }
00073 
00074 VOID
00075 NTAPI
00076 PinReset(
00077     IN PKSPIN  Pin)
00078 {
00079     PKSFILTER Filter;
00080 
00081     /* sanity check */
00082     ASSERT(Pin->Context);
00083 
00084     /* clear pin context */
00085     RtlZeroMemory(Pin->Context, sizeof(PIN_CONTEXT));
00086 
00087     /* get parent filter */
00088     Filter = KsPinGetParentFilter(Pin);
00089 
00090     /* sanity check */
00091     ASSERT(Filter);
00092 
00093     /* attempt processing */
00094     KsFilterAttemptProcessing(Filter, TRUE);
00095 }
00096 
00097 NTSTATUS
00098 NTAPI
00099 PinState(
00100     IN PKSPIN  Pin,
00101     IN KSSTATE  ToState,
00102     IN KSSTATE  FromState)
00103 {
00104     PKSFILTER Filter;
00105 
00106     /* should the pin stop */
00107     if (ToState == KSSTATE_STOP)
00108     {
00109         /* clear pin context */
00110         RtlZeroMemory(Pin->Context, sizeof(PIN_CONTEXT));
00111     }
00112 
00113     /* get parent filter */
00114     Filter = KsPinGetParentFilter(Pin);
00115 
00116     /* sanity check */
00117     ASSERT(Filter);
00118 
00119     /* attempt processing */
00120     KsFilterAttemptProcessing(Filter, TRUE);
00121 
00122     return STATUS_SUCCESS;
00123 }
00124 
00125 NTSTATUS
00126 NTAPI
00127 AudioPositionPropertyHandler(
00128     IN PIRP Irp,
00129     IN PKSIDENTIFIER Request,
00130     IN OUT PVOID Data)
00131 {
00132     PKSFILTER Filter;
00133     PKSPIN Pin, FirstPin;
00134     PFILE_OBJECT FileObject;
00135     NTSTATUS Status;
00136     ULONG BytesReturned;
00137 
00138     /* first get the pin */
00139     Pin = KsGetPinFromIrp(Irp);
00140 
00141     /* sanity check */
00142     ASSERT(Pin);
00143 
00144     /* get parent filter */
00145     Filter = KsPinGetParentFilter(Pin);
00146 
00147     /* acquire filter control mutex */
00148     KsFilterAcquireControl(Filter);
00149 
00150     /* get first pin */
00151     FirstPin = KsFilterGetFirstChildPin(Filter, Pin->Id);
00152 
00153     /* get connected pin of first pin */
00154     FileObject = KsPinGetConnectedPinFileObject(FirstPin);
00155 
00156     if (!FileObject)
00157     {
00158         /* no pin connected */
00159         Status = STATUS_INVALID_PARAMETER;
00160     }
00161     else
00162     {
00163         /* perform request */
00164         Status = KsSynchronousIoControlDevice(FileObject, KernelMode, IOCTL_KS_PROPERTY, (PVOID)Request, sizeof(KSPROPERTY), Data, sizeof(KSAUDIO_POSITION), &BytesReturned);
00165 
00166         /* store result size */
00167         Irp->IoStatus.Information = sizeof(KSAUDIO_POSITION);
00168     }
00169 
00170     /* release control */
00171     KsFilterReleaseControl(Filter);
00172 
00173     /* done */
00174     return Status;
00175 }
00176 
00177 NTSTATUS
00178 NTAPI
00179 PinIntersectHandler(
00180     IN PVOID Context,
00181     IN PIRP Irp,
00182     IN PKSP_PIN Pin,
00183     IN PKSDATARANGE DataRange,
00184     IN PKSDATARANGE MatchingDataRange,
00185     IN ULONG DataBufferSize,
00186     OUT PVOID Data OPTIONAL,
00187     OUT PULONG DataSize)
00188 {
00189     PKSPIN FirstPin;
00190     NTSTATUS Status;
00191 
00192     /* get first pin */
00193     FirstPin = KsFilterGetFirstChildPin((PKSFILTER)Context, Pin->PinId);
00194 
00195     /* sanity check */
00196     ASSERT(FirstPin);
00197 
00198     /* check for matching dataformat */
00199     if (!IsEqualGUIDAligned(&FirstPin->ConnectionFormat->SubFormat, &DataRange->SubFormat) ||
00200         !IsEqualGUIDAligned(&FirstPin->ConnectionFormat->Specifier, &DataRange->Specifier) ||
00201         !IsEqualGUIDAligned(&GUID_NULL, &DataRange->SubFormat) ||
00202         !IsEqualGUIDAligned(&GUID_NULL, &DataRange->Specifier))
00203     {
00204         /* no match */
00205         return STATUS_NO_MATCH;
00206     }
00207 
00208 
00209     if (DataBufferSize)
00210     {
00211         /* there is output buffer */
00212         if (DataBufferSize >= FirstPin->ConnectionFormat->FormatSize)
00213         {
00214             /* copy dataformat */
00215             RtlMoveMemory(Data, FirstPin->ConnectionFormat, FirstPin->ConnectionFormat->FormatSize);
00216 
00217             /* store output length */
00218             *DataSize = FirstPin->ConnectionFormat->FormatSize;
00219 
00220             Status = STATUS_SUCCESS;
00221         }
00222         else
00223         {
00224             /* buffer too small */
00225             Status = STATUS_BUFFER_TOO_SMALL;
00226         }
00227     }
00228     else
00229     {
00230         /* store output length */
00231         *DataSize = FirstPin->ConnectionFormat->FormatSize;
00232 
00233         Status = STATUS_BUFFER_OVERFLOW;
00234     }
00235 
00236     /* done */
00237     return Status;
00238 }
00239 

Generated on Sun May 27 2012 04:21:58 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.