ReactOS  0.4.14-dev-593-g1793dcc
notify.c File Reference
#include "precomp.h"
Include dependency graph for notify.c:

Go to the source code of this file.

Classes

struct  tagNOTIFYEVENT
 
struct  CDirectSoundNotifyImpl
 

Typedefs

typedef struct tagNOTIFYEVENT NOTIFYEVENT
 
typedef struct tagNOTIFYEVENTLPNOTIFYEVENT
 
typedef struct CDirectSoundNotifyImplLPCDirectSoundNotifyImpl
 

Functions

static ULONG WINAPI IDirectSoundNotify_fnAddRef (LPDIRECTSOUNDNOTIFY iface)
 
static ULONG WINAPI IDirectSoundNotify_fnRelease (LPDIRECTSOUNDNOTIFY iface)
 
HRESULT WINAPI IDirectSoundNotify_fnQueryInterface (LPDIRECTSOUNDNOTIFY iface, IN REFIID riid, LPVOID *ppobj)
 
HRESULT WINAPI IDirectSoundNotify_fnSetNotificationPositions (LPDIRECTSOUNDNOTIFY iface, DWORD dwPositionNotifies, LPCDSBPOSITIONNOTIFY pcPositionNotifies)
 
VOID DoNotifyPositionEvents (LPDIRECTSOUNDNOTIFY iface, DWORD OldPosition, DWORD NewPosition)
 
HRESULT NewDirectSoundNotify (LPDIRECTSOUNDNOTIFY *Notify, BOOL bLoop, BOOL bMix, HANDLE hPin, DWORD BufferSize)
 

Variables

static IDirectSoundNotifyVtbl vt_DirectSoundNotify
 

Typedef Documentation

◆ LPCDirectSoundNotifyImpl

◆ LPNOTIFYEVENT

◆ NOTIFYEVENT

Function Documentation

◆ DoNotifyPositionEvents()

VOID DoNotifyPositionEvents ( LPDIRECTSOUNDNOTIFY  iface,
DWORD  OldPosition,
DWORD  NewPosition 
)

Definition at line 190 of file notify.c.

194 {
195  DWORD Index;
196  LPNOTIFYEVENT CurEventList;
197 
199 
200  CurEventList = This->EventListHead;
201 
202  while(CurEventList)
203  {
204  for(Index = 0; Index < CurEventList->NotifyCount; Index++)
205  {
206  if (NewPosition > OldPosition)
207  {
208  /* buffer progress no overlap */
209  if (OldPosition < CurEventList->Notify[Index].Position && CurEventList->Notify[Index].Position <= NewPosition)
210  {
211  /* process event */
212  SetEvent(CurEventList->Notify[Index].KsEventData.EventHandle.Event);
213  }
214  }
215  else
216  {
217  /* buffer wrap-arround */
218  if (OldPosition < CurEventList->Notify[Index].Position || NewPosition > CurEventList->Notify[Index].Position)
219  {
220  /* process event */
221  SetEvent(CurEventList->Notify[Index].KsEventData.EventHandle.Event);
222  }
223  }
224  }
225 
226  /* iterate to next event list */
227  CurEventList = CurEventList->lpNext;
228  }
229 }
BOOL WINAPI SHIM_OBJ_NAME() Notify(DWORD fdwReason, PVOID ptr)
static COORD Position
Definition: mouse.c:34
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
struct KSEVENTDATA::@2913::@2915 EventHandle
struct tagNOTIFYEVENT * lpNext
Definition: notify.c:17
DWORD NotifyCount
Definition: notify.c:15
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
static const UCHAR Index[8]
Definition: usbohci.c:18
unsigned long DWORD
Definition: ntddk_ex.h:95
PLOOPEDSTREAMING_POSITION_EVENT_DATA Notify
Definition: notify.c:16
struct CDirectSoundNotifyImpl * LPCDirectSoundNotifyImpl

Referenced by MixerThreadRoutine().

◆ IDirectSoundNotify_fnAddRef()

static ULONG WINAPI IDirectSoundNotify_fnAddRef ( LPDIRECTSOUNDNOTIFY  iface)
static

Definition at line 36 of file notify.c.

38 {
39  ULONG ref;
41 
42  /* increment reference count */
43  ref = InterlockedIncrement(&This->ref);
44 
45  return ref;
46 }
Definition: send.c:47
GLenum GLint ref
Definition: glext.h:6028
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define InterlockedIncrement
Definition: armddk.h:53
struct CDirectSoundNotifyImpl * LPCDirectSoundNotifyImpl
unsigned int ULONG
Definition: retypes.h:1

◆ IDirectSoundNotify_fnQueryInterface()

HRESULT WINAPI IDirectSoundNotify_fnQueryInterface ( LPDIRECTSOUNDNOTIFY  iface,
IN REFIID  riid,
LPVOID ppobj 
)

Definition at line 69 of file notify.c.

73 {
75 
76  /* check if the interface is supported */
77  if (IsEqualIID(riid, &IID_IDirectSoundNotify) || IsEqualIID(riid, &IID_IUnknown))
78  {
79  *ppobj = (LPVOID)&This->lpVtbl;
81  return S_OK;
82  }
83 
84  return E_NOINTERFACE;
85 }
#define E_NOINTERFACE
Definition: winerror.h:2364
REFIID riid
Definition: precomp.h:44
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
const GUID IID_IUnknown
#define LPVOID
Definition: nt_native.h:45
#define S_OK
Definition: intsafe.h:59
#define InterlockedIncrement
Definition: armddk.h:53
struct CDirectSoundNotifyImpl * LPCDirectSoundNotifyImpl
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95

◆ IDirectSoundNotify_fnRelease()

static ULONG WINAPI IDirectSoundNotify_fnRelease ( LPDIRECTSOUNDNOTIFY  iface)
static

Definition at line 51 of file notify.c.

53 {
54  ULONG ref;
56 
57  ref = InterlockedDecrement(&(This->ref));
58 
59  if (!ref)
60  {
62  }
63 
64  return ref;
65 }
Definition: send.c:47
GLenum GLint ref
Definition: glext.h:6028
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define GetProcessHeap()
Definition: compat.h:403
#define InterlockedDecrement
Definition: armddk.h:52
struct CDirectSoundNotifyImpl * LPCDirectSoundNotifyImpl
unsigned int ULONG
Definition: retypes.h:1
#define HeapFree(x, y, z)
Definition: compat.h:402

◆ IDirectSoundNotify_fnSetNotificationPositions()

HRESULT WINAPI IDirectSoundNotify_fnSetNotificationPositions ( LPDIRECTSOUNDNOTIFY  iface,
DWORD  dwPositionNotifies,
LPCDSBPOSITIONNOTIFY  pcPositionNotifies 
)

Definition at line 89 of file notify.c.

93 {
94  DWORD Index;
96  DWORD Result;
98 
100 
101  if (dwPositionNotifies > DSBNOTIFICATIONS_MAX)
102  {
103  /* invalid param */
104  return DSERR_INVALIDPARAM;
105  }
106 
107  /* verify notification event handles */
108  for(Index = 0; Index < dwPositionNotifies; Index++)
109  {
110  ASSERT(pcPositionNotifies[Index].hEventNotify);
111  ASSERT(pcPositionNotifies[Index].dwOffset < This->BufferSize || pcPositionNotifies[Index].dwOffset != DSBPN_OFFSETSTOP);
112 
113  if (pcPositionNotifies[Index].hEventNotify == NULL)
114  return DSERR_INVALIDPARAM;
115 
116  if (pcPositionNotifies[Index].dwOffset > This->BufferSize && pcPositionNotifies[Index].dwOffset != DSBPN_OFFSETSTOP)
117  return DSERR_INVALIDPARAM;
118  }
119 
120  /* allocate new array */
122  if (!Notify)
123  {
124  /* not enough memory */
125  return DSERR_OUTOFMEMORY;
126  }
127 
128  /* allocate new array */
129  Notify->Notify = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwPositionNotifies * sizeof(LOOPEDSTREAMING_POSITION_EVENT_DATA));
130  if (!Notify->Notify)
131  {
132  /* not enough memory */
134  return DSERR_OUTOFMEMORY;
135  }
136 
137  /* FIXME support non-looped streaming */
138  ASSERT(This->bLoop);
139 
140  /* prepare request */
144 
145  for(Index = 0; Index < dwPositionNotifies; Index++)
146  {
147  /* initialize event entries */
148  Notify->Notify[Index].Position = pcPositionNotifies[Index].dwOffset;
149  Notify->Notify[Index].KsEventData.EventHandle.Event = pcPositionNotifies[Index].hEventNotify;
150  Notify->Notify[Index].KsEventData.NotificationType = KSEVENTF_EVENT_HANDLE;
151 
152  if (This->bMix == FALSE)
153  {
154  /* format is supported natively */
156 
157  if (Result != ERROR_SUCCESS)
158  {
159  DPRINT1("Failed to enable event %p Position %u\n", pcPositionNotifies[Index].hEventNotify, pcPositionNotifies[Index].dwOffset);
160  }
161  }
162  }
163 
164  /* enlarge notify count */
165  Notify->NotifyCount = dwPositionNotifies;
166 
167  if (This->EventListHead)
168  {
169  Notify->lpNext = This->EventListHead;
170  }
171 
172  /* insert at front */
173  (void)InterlockedExchangePointer((LPVOID*)&This->EventListHead, Notify);
174 
175  return DS_OK;
176 }
BOOL WINAPI SHIM_OBJ_NAME() Notify(DWORD fdwReason, PVOID ptr)
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
#define DSBPN_OFFSETSTOP
Definition: dsound.h:876
_In_ DWORD _In_ DWORD dwOffset
Definition: ntgdi.h:2032
_In_ NDIS_HANDLE _In_ PNDIS_REQUEST Request
Definition: ndis.h:5173
#define DSERR_OUTOFMEMORY
Definition: dsound.h:125
#define DSERR_INVALIDPARAM
Definition: dsound.h:121
const GUID KSEVENTSETID_LoopedStreaming
Definition: capturebuffer.c:18
smooth NULL
Definition: ftsmooth.c:416
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
HANDLE hEventNotify
Definition: dsound.h:300
#define KSEVENT_TYPE_ENABLE
Definition: ks.h:1789
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define DS_OK
Definition: dsound.h:116
#define InterlockedExchangePointer(Target, Value)
Definition: dshow.h:45
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
static const UCHAR Index[8]
Definition: usbohci.c:18
#define BufferSize
Definition: classpnp.h:419
unsigned long DWORD
Definition: ntddk_ex.h:95
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define DSBNOTIFICATIONS_MAX
Definition: dsound.h:235
#define IOCTL_KS_ENABLE_EVENT
Definition: ks.h:130
DWORD SyncOverlappedDeviceIoControl(IN HANDLE Handle, IN DWORD IoControlCode, IN LPVOID InBuffer, IN DWORD InBufferSize, OUT LPVOID OutBuffer, IN DWORD OutBufferSize, OUT LPDWORD BytesTransferred OPTIONAL)
Definition: misc.c:298
struct CDirectSoundNotifyImpl * LPCDirectSoundNotifyImpl
#define KSEVENTF_EVENT_HANDLE
Definition: ks.h:1778
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define DPRINT1
Definition: precomp.h:8
#define HeapFree(x, y, z)
Definition: compat.h:402

◆ NewDirectSoundNotify()

HRESULT NewDirectSoundNotify ( LPDIRECTSOUNDNOTIFY Notify,
BOOL  bLoop,
BOOL  bMix,
HANDLE  hPin,
DWORD  BufferSize 
)

Definition at line 232 of file notify.c.

238 {
240 
241  if (!This)
242  return DSERR_OUTOFMEMORY;
243 
244  This->lpVtbl = &vt_DirectSoundNotify;
245  This->bLoop = bLoop;
246  This->bMix = bMix;
247  This->hPin = hPin;
248  This->ref = 1;
249  This->EventListHead = NULL;
250  This->BufferSize = BufferSize;
251 
252  *Notify = (LPDIRECTSOUNDNOTIFY)&This->lpVtbl;
253  return DS_OK;
254 
255 }
BOOL WINAPI SHIM_OBJ_NAME() Notify(DWORD fdwReason, PVOID ptr)
#define DSERR_OUTOFMEMORY
Definition: dsound.h:125
smooth NULL
Definition: ftsmooth.c:416
#define DS_OK
Definition: dsound.h:116
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define BufferSize
Definition: classpnp.h:419
static IDirectSoundNotifyVtbl vt_DirectSoundNotify
Definition: notify.c:178
struct IDirectSoundNotify * LPDIRECTSOUNDNOTIFY
Definition: dsound.h:82

Referenced by IDirectSoundCaptureBufferImpl_QueryInterface().

Variable Documentation

◆ vt_DirectSoundNotify

IDirectSoundNotifyVtbl vt_DirectSoundNotify
static
Initial value:
=
{
}
static ULONG WINAPI IDirectSoundNotify_fnRelease(LPDIRECTSOUNDNOTIFY iface)
Definition: notify.c:51
static ULONG WINAPI IDirectSoundNotify_fnAddRef(LPDIRECTSOUNDNOTIFY iface)
Definition: notify.c:36
HRESULT WINAPI IDirectSoundNotify_fnSetNotificationPositions(LPDIRECTSOUNDNOTIFY iface, DWORD dwPositionNotifies, LPCDSBPOSITIONNOTIFY pcPositionNotifies)
Definition: notify.c:89
HRESULT WINAPI IDirectSoundNotify_fnQueryInterface(LPDIRECTSOUNDNOTIFY iface, IN REFIID riid, LPVOID *ppobj)
Definition: notify.c:69

Definition at line 178 of file notify.c.

Referenced by NewDirectSoundNotify().