1 /*
2  * COPYRIGHT:       See COPYING in the top level directory
3  * PROJECT:         ReactOS Kernel Streaming
4  * FILE:            drivers/wdm/audio/filters/splitter/filter.c
5  * PURPOSE:         Filter File Context Handling
6  * PROGRAMMER:      Johannes Anderwald
7  */
8 
9 #include "precomp.h"
10 
11 NTSTATUS
12 NTAPI
FilterProcess(IN PKSFILTER Filter,IN PKSPROCESSPIN_INDEXENTRY ProcessPinsIndex)13 FilterProcess(
14     IN PKSFILTER  Filter,
15     IN PKSPROCESSPIN_INDEXENTRY  ProcessPinsIndex)
16 {
17     ULONG Index;
18     PKSPROCESSPIN CurPin, Pin;
19     BOOLEAN PendingFrames = FALSE;
20 
21     if (ProcessPinsIndex->Count)
22     {
23         /* check if there are outstanding frames */
24         for(Index = 1; Index < ProcessPinsIndex->Count; Index++)
25         {
26             /* get current pin */
27             CurPin = ProcessPinsIndex->Pins[Index];
28 
29             if (CurPin->BytesAvailable && CurPin->Pin->DeviceState == KSSTATE_RUN)
30             {
31                 /* pin has pending frames
32                  * to keep all pins synchronized, every pin has to wait untill each chained pin has send its frames downwards
33                  */
34                 PendingFrames = TRUE;
35             }
36         }
37     }
38 
39     if (!PendingFrames && ProcessPinsIndex->Count)
40     {
41         /* get first pin */
42         Pin = ProcessPinsIndex->Pins[0];
43 
44         /* check if there is new data available */
45         if (Pin->BytesAvailable)
46         {
47             for(Index = 1; Index < ProcessPinsIndex->Count; Index++)
48             {
49                 /* get current pin */
50                 CurPin = ProcessPinsIndex->Pins[Index];
51 
52                 /* copy the frame to pin */
53                 RtlMoveMemory(CurPin->Data, Pin->Data, Pin->BytesAvailable);
54                 CurPin->BytesUsed = Pin->BytesAvailable;
55             }
56         }
57     }
58     /* done */
59     return STATUS_SUCCESS;
60 }
61 
62