ReactOS  0.4.14-dev-552-g2fad488
capturebuffer.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS Configuration of network devices
4  * FILE: dll/directx/dsound_new/capturebuffer.c
5  * PURPOSE: IDirectSoundCaptureBuffer8 implementation
6  *
7  * PROGRAMMERS: Johannes Anderwald (johannes.anderwald@reactos.org)
8  */
9 
10 
11 #include "precomp.h"
12 
13 const GUID KSINTERFACESETID_Standard = {0x1A8766A0L, 0x62CE, 0x11CF, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}};
14 const GUID KSMEDIUMSETID_Standard = {0x4747B320L, 0x62CE, 0x11CF, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}};
15 const GUID KSDATAFORMAT_TYPE_AUDIO = {0x73647561L, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
16 const GUID KSDATAFORMAT_SPECIFIER_WAVEFORMATEX = {0x05589f81L, 0xc356, 0x11ce, {0xbf, 0x01, 0x00, 0xaa, 0x00, 0x55, 0x59, 0x5a}};
17 const GUID KSPROPSETID_Connection = {0x1D58C920L, 0xAC9B, 0x11CF, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}};
18 const GUID KSEVENTSETID_LoopedStreaming = {0x4682B940L, 0xC6EF, 0x11D0, {0x96, 0xD8, 0x00, 0xAA, 0x00, 0x51, 0xE5, 0x1D}};
19 
20 
21 
22 typedef struct
23 {
24  IDirectSoundCaptureBuffer8Vtbl *lpVtbl;
25 
41 
43 
45 
46 DWORD
47 WINAPI
50 {
53  DWORD Result, MixPosition, BufferPosition, BytesWritten, BytesRead, MixLength, BufferLength;
55 
56  /* setup audio position property request */
60 
61  MixPosition = 0;
62  BufferPosition = 0;
63  do
64  {
65  /* query current position */
67 
68  /* sanity check */
70 
71  /* FIXME implement samplerate conversion */
72  ASSERT(This->MixFormat.nSamplesPerSec == This->Format->nSamplesPerSec);
73 
74  /* FIXME implement bitrate conversion */
75  ASSERT(This->MixFormat.wBitsPerSample == This->Format->wBitsPerSample);
76 
77  /* sanity check */
78  ASSERT(BufferPosition <= This->BufferSize);
79  ASSERT(MixPosition <= This->MixBufferSize);
80 
81  if (BufferPosition == This->BufferSize)
82  {
83  /* restart from front */
84  BufferPosition = 0;
85  }
86 
87  if (MixPosition == This->MixBufferSize)
88  {
89  /* restart from front */
90  MixPosition = 0;
91  }
92 
93  if (This->MixFormat.nChannels != This->Format->nChannels)
94  {
95  if ((DWORD)Position.PlayOffset >= MixPosition)
96  {
97  /* calculate buffer position difference */
98  MixLength = Position.PlayOffset - MixPosition;
99  }
100  else
101  {
102  /* buffer overlap */
103  MixLength = This->MixBufferSize - MixPosition;
104  }
105 
106  BufferLength = This->BufferSize - BufferPosition;
107 
108  /* convert the format */
109  PerformChannelConversion(&This->MixBuffer[MixPosition], MixLength, &BytesRead, This->MixFormat.nChannels, This->Format->nChannels, This->Format->wBitsPerSample, &This->Buffer[BufferPosition], BufferLength, &BytesWritten);
110 
111  /* update buffer offsets */
112  MixPosition += BytesRead;
113  BufferPosition += BytesWritten;
114  DPRINT("MixPosition %u BufferPosition %u BytesRead %u BytesWritten %u MixLength %u BufferLength %u\n", MixPosition, BufferPosition, BytesRead, BytesWritten, MixLength, BufferLength);
115  }
116 
117  /* Notify Events */
118  if (This->Notify)
119  {
120  DoNotifyPositionEvents(This->Notify, This->CurrentMixPosition, BufferPosition);
121  }
122 
123  /* update offset */
124  InterlockedExchange(&This->CurrentMixPosition, (LONG)BufferPosition);
125 
126  /* FIXME use timer */
127  Sleep(10);
128 
129  }while(InterlockedCompareExchange(&This->StopMixerThread, 0, 0) == 0);
130 
131 
132  /* signal stop event */
133  SetEvent(This->hStopEvent);
134 
135  /* done */
136  return 0;
137 }
138 
139 
140 
141 HRESULT
142 WINAPI
145  IN REFIID riid,
146  LPVOID* ppobj)
147 {
148  LPOLESTR pStr;
150 
151  /* check if requested interface is supported */
152  if (IsEqualIID(riid, &IID_IUnknown) ||
153  IsEqualIID(riid, &IID_IDirectSoundCaptureBuffer) ||
154  IsEqualIID(riid, &IID_IDirectSoundCaptureBuffer8))
155  {
156  *ppobj = (LPVOID)&This->lpVtbl;
157  InterlockedIncrement(&This->ref);
158  return S_OK;
159  }
160 
161  /* check if the interface is supported */
162  if (IsEqualIID(riid, &IID_IDirectSoundNotify))
163  {
164  if (!This->Notify)
165  {
166  HRESULT hr = NewDirectSoundNotify(&This->Notify, This->bLoop, This->bMix, This->hPin, This->BufferSize);
167  if (FAILED(hr))
168  return hr;
169 
170  *ppobj = (LPVOID)This->Notify;
171  return S_OK;
172  }
173 
174  /* increment reference count on existing notify object */
176  *ppobj = (LPVOID)This->Notify;
177  return S_OK;
178  }
179 
180  /* interface not supported */
181  if (SUCCEEDED(StringFromIID(riid, &pStr)))
182  {
183  DPRINT("No Interface for class %s\n", pStr);
184  CoTaskMemFree(pStr);
185  }
186  return E_NOINTERFACE;
187 }
188 
189 ULONG
190 WINAPI
193 {
194  ULONG ref;
196 
197  /* increment reference count */
198  ref = InterlockedIncrement(&This->ref);
199 
200  return ref;
201 
202 }
203 
204 ULONG
205 WINAPI
208 {
209  ULONG ref;
211 
212  /* release reference count */
213  ref = InterlockedDecrement(&(This->ref));
214 
215  if (!ref)
216  {
217  if (This->hPin)
218  {
219  /* close pin handle */
220  CloseHandle(This->hPin);
221  }
222 
223  if (This->hStopEvent)
224  {
225  /* close stop event handle */
226  CloseHandle(This->hStopEvent);
227  }
228 
229  if (This->MixBuffer)
230  {
231  /* free mix buffer */
232  HeapFree(GetProcessHeap(), 0, This->MixBuffer);
233  }
234 
235  /* free capture buffer */
236  HeapFree(GetProcessHeap(), 0, This->Buffer);
237  /* free wave format */
238  HeapFree(GetProcessHeap(), 0, This->Format);
239  /* free capture buffer */
241  }
242 
243  return ref;
244 }
245 
246 
247 HRESULT
248 WINAPI
251  LPDSCBCAPS lpDSCBCaps )
252 {
254 
255  if (!lpDSCBCaps)
256  {
257  /* invalid parameter */
258  return DSERR_INVALIDPARAM;
259  }
260 
261  if (lpDSCBCaps->dwSize != sizeof(DSCBCAPS))
262  {
263  /* invalid parameter */
264  return DSERR_INVALIDPARAM;
265  }
266 
267  lpDSCBCaps->dwBufferBytes = This->BufferSize;
268  lpDSCBCaps->dwReserved = 0;
269  //lpDSCBCaps->dwFlags = DSCBCAPS_WAVEMAPPED;
270 
271  return DS_OK;
272 }
273 
274 HRESULT
275 WINAPI
278  LPDWORD lpdwCapturePosition,
279  LPDWORD lpdwReadPosition)
280 {
283  DWORD Result;
284  DWORD Value;
285 
287 
288  if (!This->hPin)
289  {
290  if (lpdwCapturePosition)
291  *lpdwCapturePosition = 0;
292 
293  if (lpdwReadPosition)
294  *lpdwReadPosition = 0;
295 
296  DPRINT("No Audio Pin\n");
297  return DS_OK;
298  }
299 
300  if (This->bMix)
301  {
302  /* read current position */
303  Value = InterlockedCompareExchange(&This->CurrentMixPosition, 0, 0);
304 
305  if (lpdwCapturePosition)
306  *lpdwCapturePosition = (DWORD)Value;
307 
308  if (lpdwReadPosition)
309  *lpdwReadPosition = (DWORD)Value;
310 
311  return DS_OK;
312  }
313 
314  /* setup audio position property request */
318 
319 
321 
322  if (Result != ERROR_SUCCESS)
323  {
324  DPRINT("GetPosition failed with %x\n", Result);
325  return DSERR_UNSUPPORTED;
326  }
327 
328  //DPRINT("Play %I64u Write %I64u \n", Position.PlayOffset, Position.WriteOffset);
329 
330  if (lpdwCapturePosition)
331  *lpdwCapturePosition = (DWORD)Position.PlayOffset;
332 
333  if (lpdwReadPosition)
334  *lpdwReadPosition = (DWORD)Position.WriteOffset;
335 
336  return DS_OK;
337 }
338 
339 
340 HRESULT
341 WINAPI
344  LPWAVEFORMATEX lpwfxFormat,
345  DWORD dwSizeAllocated,
346  LPDWORD lpdwSizeWritten)
347 {
348  DWORD FormatSize;
350 
351  FormatSize = sizeof(WAVEFORMATEX) + This->Format->cbSize;
352 
353  if (!lpwfxFormat && !lpdwSizeWritten)
354  {
355  /* invalid parameter */
356  return DSERR_INVALIDPARAM;
357  }
358 
359  if (!lpwfxFormat)
360  {
361  /* return required format size */
362  *lpdwSizeWritten = FormatSize;
363  return DS_OK;
364  }
365  else
366  {
367  if (dwSizeAllocated >= FormatSize)
368  {
369  /* copy format */
370  CopyMemory(lpwfxFormat, This->Format, FormatSize);
371 
372  if (lpdwSizeWritten)
373  *lpdwSizeWritten = FormatSize;
374 
375  return DS_OK;
376  }
377  /* buffer too small */
378  if (lpdwSizeWritten)
379  *lpdwSizeWritten = 0;
380  return DSERR_INVALIDPARAM;
381  }
382 }
383 
384 HRESULT
385 WINAPI
388  LPDWORD lpdwStatus )
389 {
391 
392  if (!lpdwStatus)
393  {
394  /* invalid parameter */
395  return DSERR_INVALIDPARAM;
396  }
397 
398  /* reset flags */
399  *lpdwStatus = 0;
400 
401  /* check if pin is running */
402  if (This->State == KSSTATE_RUN)
403  *lpdwStatus |= DSCBSTATUS_CAPTURING;
404 
405  /* check if a looped buffer is used */
406  if (This->bLoop)
407  *lpdwStatus |= DSCBSTATUS_LOOPING;
408 
409  /* done */
410  return DS_OK;
411 }
412 
413 HRESULT
414 WINAPI
417  LPDIRECTSOUNDCAPTURE lpDSC,
418  LPCDSCBUFFERDESC lpcDSCBDesc)
419 {
420  /* capture buffer is already initialized */
422 }
423 
424 HRESULT
425 WINAPI
428  DWORD dwOffset,
429  DWORD dwBytes,
430  LPVOID* ppvAudioPtr1,
431  LPDWORD pdwAudioBytes1,
432  LPVOID* ppvAudioPtr2,
433  LPDWORD pdwAudioBytes2,
434  DWORD dwFlags )
435 {
437 
438  DPRINT("This %p dwOffset %u dwBytes %u ppvAudioPtr1 %p pdwAudioBytes1 %p ppvAudioPtr2 %p pdwAudioBytes2 %p dwFlags %x This->BufferSize %u\n",
439  This, dwOffset, dwBytes, ppvAudioPtr1, pdwAudioBytes1, ppvAudioPtr2, pdwAudioBytes2, dwFlags, This->BufferSize);
440 
442  {
443  *ppvAudioPtr1 = (LPVOID)This->Buffer;
444  *pdwAudioBytes1 = This->BufferSize;
445  if (ppvAudioPtr2)
446  *ppvAudioPtr2 = NULL;
447  if (pdwAudioBytes2)
448  *pdwAudioBytes2 = 0;
449 
450  return DS_OK;
451  }
452  else
453  {
454  ASSERT(dwOffset < This->BufferSize);
455  ASSERT(dwBytes < This->BufferSize);
456  ASSERT(dwBytes + dwOffset <= This->BufferSize);
457 
458  *ppvAudioPtr1 = This->Buffer + dwOffset;
459  *pdwAudioBytes1 = dwBytes;
460  if (ppvAudioPtr2)
461  *ppvAudioPtr2 = NULL;
462  if (pdwAudioBytes2)
463  *pdwAudioBytes2 = 0;
464 
465  return DS_OK;
466  }
467 }
468 
469 HRESULT
470 WINAPI
473  DWORD dwFlags )
474 {
477  DWORD Result, BytesTransferred;
478  OVERLAPPED Overlapped;
479  KSSTATE State;
480  HANDLE hThread;
481 
483 
484  DPRINT("IDirectSoundCaptureBufferImpl_Start Flags %x\n", dwFlags);
486 
487  /* check if pin is already running */
488  if (This->State == KSSTATE_RUN)
489  return DS_OK;
490 
491 
492  /* check if there is a pin instance */
493  if (!This->hPin)
494  return DSERR_GENERIC;
495 
496  /* setup request */
500  State = KSSTATE_RUN;
501 
502  /* set pin to run */
503  Result = SyncOverlappedDeviceIoControl(This->hPin, IOCTL_KS_PROPERTY, (PVOID)&Property, sizeof(KSPROPERTY), (PVOID)&State, sizeof(KSSTATE), &BytesTransferred);
504 
506 
507  if (Result == ERROR_SUCCESS)
508  {
509  /* store result */
510  This->State = State;
511  }
512 
513  /* initialize overlapped struct */
514  ZeroMemory(&Overlapped, sizeof(OVERLAPPED));
515  Overlapped.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
516 
517  /* clear stream header */
518  ZeroMemory(&Header, sizeof(KSSTREAM_HEADER));
519 
520  /* initialize stream header */
521  Header.FrameExtent = This->BufferSize;
522  Header.DataUsed = 0;
523  Header.Data = (This->bMix ? This->MixBuffer : This->Buffer);
524  Header.Size = sizeof(KSSTREAM_HEADER);
525  Header.PresentationTime.Numerator = 1;
526  Header.PresentationTime.Denominator = 1;
527 
528  Result = DeviceIoControl(This->hPin, IOCTL_KS_WRITE_STREAM, NULL, 0, &Header, sizeof(KSSTREAM_HEADER), &BytesTransferred, &Overlapped);
529 
530  if (Result != ERROR_SUCCESS)
531  {
532  DPRINT("Failed submit buffer with %lx\n", Result);
533  return DSERR_GENERIC;
534  }
535 
536  if (This->bMix)
537  {
538  if (!This->hStopEvent)
539  {
540  /* create stop event */
541  This->hStopEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
542  if (!This->hStopEvent)
543  {
544  DPRINT1("Failed to create event object with %x\n", GetLastError());
545  return DSERR_GENERIC;
546  }
547  }
548 
549  /* set state to stop false */
550  This->StopMixerThread = FALSE;
551 
553  if (!hThread)
554  {
555  DPRINT1("Failed to create thread with %x\n", GetLastError());
556  return DSERR_GENERIC;
557  }
558 
559  /* close thread handle */
561  }
562 
563 
564  return DS_OK;
565 }
566 
567 HRESULT
568 WINAPI
570 {
572  DWORD Result;
573  KSSTATE State;
574 
576 
577  if (This->State == KSSTATE_STOP)
578  {
579  /* stream has already been stopped */
580  return DS_OK;
581  }
582 
583  if (!This->hPin)
584  return DSERR_GENERIC;
585 
586  /* setup request */
591 
592 
593  /* set pin to stop */
595 
597 
598 
599  if (This->bMix)
600  {
601  /* sanity check */
602  ASSERT(This->hStopEvent);
603  /* reset event */
604  ResetEvent(This->hStopEvent);
605  /* signal event to stop */
606  This->StopMixerThread = TRUE;
607  /* Wait for the event to stop */
608  WaitForSingleObject(This->hStopEvent, INFINITE);
609  }
610 
611 
612  if (Result == ERROR_SUCCESS)
613  {
614  /* store result */
615  This->State = State;
616  return DS_OK;
617  }
618 
619  DPRINT("Failed to stop pin\n");
620  return DSERR_GENERIC;
621 }
622 
623 HRESULT
624 WINAPI
627  LPVOID lpvAudioPtr1,
628  DWORD dwAudioBytes1,
629  LPVOID lpvAudioPtr2,
630  DWORD dwAudioBytes2 )
631 {
632  return DS_OK;
633 }
634 
635 HRESULT
636 WINAPI
639  REFGUID rguidObject,
640  DWORD dwIndex,
641  REFGUID rguidInterface,
642  LPVOID* ppObject )
643 {
645  return DSERR_INVALIDPARAM;
646 }
647 
648 HRESULT
649 WINAPI
652  DWORD dwFXCount,
653  LPDWORD pdwFXStatus )
654 {
656  return DSERR_INVALIDPARAM;
657 }
658 
659 
660 static IDirectSoundCaptureBuffer8Vtbl vt_DirectSoundCaptureBuffer8 =
661 {
662  /* IUnknown methods */
666 
667  /* IDirectSoundCaptureBuffer methods */
677 
678  /* IDirectSoundCaptureBuffer methods */
681 };
682 
683 
684 
685 
686 HRESULT
688  LPDIRECTSOUNDCAPTUREBUFFER8 *OutBuffer,
690  LPCDSCBUFFERDESC lpcDSBufferDesc)
691 {
692  DWORD FormatSize, MixBufferSize;
693  ULONG DeviceId = 0, PinId;
695  WAVEFORMATEX MixFormat;
696 
698 
699  if (!This)
700  {
701  /* not enough memory */
702  return DSERR_OUTOFMEMORY;
703  }
704 
705  /* calculate format size */
706  FormatSize = sizeof(WAVEFORMATEX) + lpcDSBufferDesc->lpwfxFormat->cbSize;
707  /* allocate format struct */
708  This->Format = HeapAlloc(GetProcessHeap(), 0, FormatSize);
709  if (!This->Format)
710  {
711  /* not enough memory */
713  return DSERR_OUTOFMEMORY;
714  }
715 
716  /* sanity check */
717  ASSERT(lpcDSBufferDesc->dwBufferBytes);
718 
719  /* allocate capture buffer */
720  This->Buffer = HeapAlloc(GetProcessHeap(), 0, lpcDSBufferDesc->dwBufferBytes);
721  if (!This->Buffer)
722  {
723  /* not enough memory */
724  HeapFree(GetProcessHeap(), 0, This->Format);
726  return DSERR_OUTOFMEMORY;
727  }
728 
729  /* store buffer size */
730  This->BufferSize = lpcDSBufferDesc->dwBufferBytes;
731  ASSERT(lpcDSBufferDesc->lpwfxFormat->cbSize == 0);
732 
733  do
734  {
735  /* try all available recording pins on that filter */
736  PinId = GetPinIdFromFilter(Filter, TRUE, DeviceId);
737 
738  if (PinId == ULONG_MAX)
739  break;
740 
741  Result = OpenPin(Filter->hFilter, PinId, lpcDSBufferDesc->lpwfxFormat, &This->hPin, TRUE);
742  if (Result == ERROR_SUCCESS)
743  break;
744 
745  DeviceId++;
746  }while(TRUE);
747 
748  if (Result != ERROR_SUCCESS)
749  {
750  /* failed to instantiate the capture pin with the native format
751  * try to compute a compatible format and use that
752  * we could use the mixer api for this purpose but... the kmixer isnt working very good atm
753  */
754 
755  DeviceId = 0;
756  do
757  {
758  /* try all available recording pins on that filter */
759  PinId = GetPinIdFromFilter(Filter, TRUE, DeviceId);
760  DPRINT("PinId %u DeviceId %u\n", PinId, DeviceId);
761 
762  if (PinId == ULONG_MAX)
763  break;
764 
765  if (CreateCompatiblePin(Filter->hFilter, PinId, TRUE, lpcDSBufferDesc->lpwfxFormat, &MixFormat, &This->hPin))
766  {
767  This->bMix = TRUE;
768  CopyMemory(&This->MixFormat, &MixFormat, sizeof(WAVEFORMATEX));
769  break;
770  }
771 
772  DeviceId++;
773  }while(TRUE);
774 
775 
776  if (!This->bMix)
777  {
778  /* FIXME should not happen */
779  DPRINT("failed to compute a compatible format\n");
780  HeapFree(GetProcessHeap(), 0, This->MixBuffer);
781  HeapFree(GetProcessHeap(), 0, This->Buffer);
782  HeapFree(GetProcessHeap(), 0, This->Format);
784  return DSERR_GENERIC;
785  }
786 
787  MixBufferSize = lpcDSBufferDesc->dwBufferBytes;
788  MixBufferSize /= lpcDSBufferDesc->lpwfxFormat->nChannels;
789  MixBufferSize /= (lpcDSBufferDesc->lpwfxFormat->wBitsPerSample/8);
790 
791  MixBufferSize *= This->MixFormat.nChannels;
792  MixBufferSize *= (This->MixFormat.wBitsPerSample/8);
793 
794  /* allocate buffer for mixing */
795  This->MixBuffer = HeapAlloc(GetProcessHeap(), 0, MixBufferSize);
796  if (!This->Buffer)
797  {
798  /* not enough memory */
799  CloseHandle(This->hPin);
800  HeapFree(GetProcessHeap(), 0, This->Buffer);
801  HeapFree(GetProcessHeap(), 0, This->Format);
803  return DSERR_OUTOFMEMORY;
804  }
805  This->MixBufferSize = MixBufferSize;
806  DPRINT1("MixBufferSize %u BufferSize %u\n", MixBufferSize, This->BufferSize);
807  }
808 
809  /* initialize capture buffer */
810  This->ref = 1;
812  This->Filter = Filter;
813  This->State = KSSTATE_STOP;
814  This->bLoop = TRUE;
815 
816  RtlMoveMemory(This->Format, lpcDSBufferDesc->lpwfxFormat, FormatSize);
817 
818  *OutBuffer = (LPDIRECTSOUNDCAPTUREBUFFER8)&This->lpVtbl;
819  return DS_OK;
820 }
#define CreateEvent
Definition: winbase.h:3582
LPWAVEFORMATEX lpwfxFormat
Definition: dsound.h:361
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2343
#define DSERR_GENERIC
Definition: dsound.h:123
VOID DoNotifyPositionEvents(LPDIRECTSOUNDNOTIFY iface, DWORD OldPosition, DWORD NewPosition)
Definition: notify.c:190
#define IOCTL_KS_PROPERTY
Definition: ks.h:127
#define IN
Definition: typedefs.h:38
#define IOCTL_KS_WRITE_STREAM
Definition: ks.h:139
_Must_inspect_result_ _In_ PFILE_OBJECT _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ FLT_IO_OPERATION_FLAGS _Out_opt_ PULONG BytesWritten
Definition: fltkernel.h:1293
#define REFIID
Definition: guiddef.h:118
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:406
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
#define E_NOINTERFACE
Definition: winerror.h:2364
ULONG WINAPI IDirectSoundCaptureBufferImpl_AddRef(LPDIRECTSOUNDCAPTUREBUFFER8 iface)
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:420
#define ERROR_SUCCESS
Definition: deptool.c:10
LPDIRECTSOUNDNOTIFY Notify
Definition: capturebuffer.c:42
HRESULT hr
Definition: shlfolder.c:183
Definition: scsiwmi.h:51
REFIID riid
Definition: precomp.h:44
#define KSPROPSETID_Audio
Definition: ksmedia.h:951
static COORD Position
Definition: mouse.c:34
unsigned char * PUCHAR
Definition: retypes.h:3
WORD nChannels
Definition: mmreg.h:79
#define DSERR_ALREADYINITIALIZED
Definition: dsound.h:129
HRESULT WINAPI IDirectSoundCaptureBufferImpl_Start(LPDIRECTSOUNDCAPTUREBUFFER8 iface, DWORD dwFlags)
const GUID KSPROPSETID_Connection
Definition: capturebuffer.c:17
struct CDirectSoundCaptureBufferImpl * LPCDirectSoundCaptureBufferImpl
#define InterlockedCompareExchange
Definition: interlocked.h:104
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define ZeroMemory
Definition: winbase.h:1642
DWORD dwBufferBytes
Definition: dsound.h:359
struct tWAVEFORMATEX WAVEFORMATEX
Definition: austream.idl:23
static LPOLESTR
Definition: stg_prop.c:27
#define DWORD
Definition: nt_native.h:44
Definition: send.c:47
#define KSPROPERTY_TYPE_GET
Definition: dmksctrl.h:42
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
_In_ DWORD _In_ DWORD dwOffset
Definition: ntgdi.h:2032
HRESULT WINAPI IDirectSoundCaptureBufferImpl_Initialize(LPDIRECTSOUNDCAPTUREBUFFER8 iface, LPDIRECTSOUNDCAPTURE lpDSC, LPCDSCBUFFERDESC lpcDSCBDesc)
_In_ NDIS_HANDLE _In_ PNDIS_REQUEST Request
Definition: ndis.h:5173
HRESULT WINAPI IDirectSoundCaptureBufferImpl_GetFXStatus(LPDIRECTSOUNDCAPTUREBUFFER8 iface, DWORD dwFXCount, LPDWORD pdwFXStatus)
DWORD dwBufferBytes
Definition: dsound.h:380
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define DSERR_OUTOFMEMORY
Definition: dsound.h:125
#define DSERR_INVALIDPARAM
Definition: dsound.h:121
Definition: Header.h:8
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
_In_ ULONG BufferLength
Definition: usbdlib.h:225
_Must_inspect_result_ _In_opt_ PFLT_FILTER Filter
Definition: fltkernel.h:1802
GLenum GLint ref
Definition: glext.h:6028
DWORD dwSize
Definition: dsound.h:378
HANDLE hEvent
Definition: winbase.h:792
const GUID KSEVENTSETID_LoopedStreaming
Definition: capturebuffer.c:18
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:136
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
void DPRINT(...)
Definition: polytest.cpp:61
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
_Check_return_ HRESULT WINAPI StringFromIID(_In_ REFIID rclsid, _Outptr_ LPOLESTR *lplpsz)
HRESULT WINAPI IDirectSoundCaptureBufferImpl_GetStatus(LPDIRECTSOUNDCAPTUREBUFFER8 iface, LPDWORD lpdwStatus)
ULONG GetPinIdFromFilter(LPFILTERINFO Filter, BOOL bCapture, ULONG Offset)
Definition: devicelist.c:13
DWORD OpenPin(HANDLE hFilter, ULONG PinId, LPWAVEFORMATEX WaveFormatEx, PHANDLE hPin, BOOL bLoop)
Definition: misc.c:212
#define IDirectSoundNotify_AddRef(p)
Definition: dsound.h:893
const GUID KSINTERFACESETID_Standard
Definition: capturebuffer.c:13
#define DS_OK
Definition: dsound.h:116
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
HRESULT NewDirectSoundCaptureBuffer(LPDIRECTSOUNDCAPTUREBUFFER8 *OutBuffer, LPFILTERINFO Filter, LPCDSCBUFFERDESC lpcDSBufferDesc)
if(!(yy_init))
Definition: macro.lex.yy.c:714
LONG HRESULT
Definition: typedefs.h:77
#define DSCBSTATUS_CAPTURING
Definition: dsound.h:396
const GUID IID_IUnknown
#define WINAPI
Definition: msvc.h:8
#define CopyMemory
Definition: winbase.h:1640
#define BufferSize
Definition: classpnp.h:419
BOOL CreateCompatiblePin(IN HANDLE hFilter, IN DWORD PinId, IN BOOL bLoop, IN LPWAVEFORMATEX WaveFormatEx, OUT LPWAVEFORMATEX WaveFormatOut, OUT PHANDLE hPin)
Definition: misc.c:517
unsigned long DWORD
Definition: ntddk_ex.h:95
HRESULT WINAPI IDirectSoundCaptureBufferImpl_GetCurrentPosition(LPDIRECTSOUNDCAPTUREBUFFER8 iface, LPDWORD lpdwCapturePosition, LPDWORD lpdwReadPosition)
#define LPVOID
Definition: nt_native.h:45
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define DSERR_UNSUPPORTED
Definition: dsound.h:127
static const WCHAR L[]
Definition: oid.c:1250
#define DSCBSTART_LOOPING
Definition: dsound.h:393
#define InterlockedDecrement
Definition: armddk.h:52
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
LPVOID lpParameter
Definition: kernel32.h:241
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
HRESULT WINAPI IDirectSoundCaptureBufferImpl_Stop(LPDIRECTSOUNDCAPTUREBUFFER8 iface)
#define InterlockedExchange
Definition: armddk.h:54
struct IDirectSoundCapture * LPDIRECTSOUNDCAPTURE
Definition: dsound.h:92
struct IDirectSoundNotify * LPDIRECTSOUNDNOTIFY
Definition: dsound.h:82
_In_ DWORD Property
Definition: setupapi.h:1545
IDirectSoundCaptureBuffer8Vtbl * lpVtbl
Definition: capturebuffer.c:24
#define S_OK
Definition: intsafe.h:59
DWORD dwReserved
Definition: dsound.h:381
enum State_ State
Definition: pofuncs.h:54
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: deviceio.c:136
#define InterlockedIncrement
Definition: armddk.h:53
ULONG WINAPI IDirectSoundCaptureBufferImpl_Release(LPDIRECTSOUNDCAPTUREBUFFER8 iface)
KSSTATE
Definition: ks.h:1214
const GUID KSDATAFORMAT_TYPE_AUDIO
Definition: capturebuffer.c:15
HRESULT WINAPI IDirectSoundCaptureBufferImpl_GetObjectInPath(LPDIRECTSOUNDCAPTUREBUFFER8 iface, REFGUID rguidObject, DWORD dwIndex, REFGUID rguidInterface, LPVOID *ppObject)
WORD cbSize
Definition: mmreg.h:84
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
DWORD WINAPI MixerThreadRoutine(LPVOID lpParameter)
Definition: capturebuffer.c:48
HANDLE hThread
Definition: wizard.c:27
BOOL WINAPI DECLSPEC_HOTPATCH ResetEvent(IN HANDLE hEvent)
Definition: synch.c:714
#define DPRINT1
Definition: precomp.h:8
HRESULT NewDirectSoundNotify(LPDIRECTSOUNDNOTIFY *Notify, BOOL bLoop, BOOL bMix, HANDLE hPin, DWORD BufferSize)
Definition: notify.c:232
uint32_t * LPDWORD
Definition: typedefs.h:57
WORD wBitsPerSample
Definition: mmreg.h:83
HRESULT WINAPI IDirectSoundCaptureBufferImpl_GetFormat(LPDIRECTSOUNDCAPTUREBUFFER8 iface, LPWAVEFORMATEX lpwfxFormat, DWORD dwSizeAllocated, LPDWORD lpdwSizeWritten)
const GUID KSDATAFORMAT_SPECIFIER_WAVEFORMATEX
Definition: capturebuffer.c:16
unsigned int ULONG
Definition: retypes.h:1
#define UNIMPLEMENTED
Definition: debug.h:114
HRESULT WINAPI IDirectSoundCaptureBufferImpl_QueryInterface(LPDIRECTSOUNDCAPTUREBUFFER8 iface, IN REFIID riid, LPVOID *ppobj)
static IDirectSoundCaptureBuffer8Vtbl vt_DirectSoundCaptureBuffer8
struct IDirectSoundCaptureBuffer8 * LPDIRECTSOUNDCAPTUREBUFFER8
Definition: dsound.h:100
#define INFINITE
Definition: serial.h:102
const GUID KSMEDIUMSETID_Standard
Definition: capturebuffer.c:14
#define DSCBSTATUS_LOOPING
Definition: dsound.h:397
#define KSPROPERTY_TYPE_SET
Definition: dmksctrl.h:43
HRESULT WINAPI IDirectSoundCaptureBufferImpl_GetCaps(LPDIRECTSOUNDCAPTUREBUFFER8 iface, LPDSCBCAPS lpDSCBCaps)
#define DSBLOCK_ENTIREBUFFER
Definition: dsound.h:204
#define HeapFree(x, y, z)
Definition: compat.h:402
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
_Must_inspect_result_ _In_ PFILE_OBJECT _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ FLT_IO_OPERATION_FLAGS _Out_opt_ PULONG BytesRead
Definition: fltkernel.h:1255
HRESULT WINAPI IDirectSoundCaptureBufferImpl_Unlock(LPDIRECTSOUNDCAPTUREBUFFER8 iface, LPVOID lpvAudioPtr1, DWORD dwAudioBytes1, LPVOID lpvAudioPtr2, DWORD dwAudioBytes2)
#define ULONG_MAX
Definition: limits.h:44
#define SUCCEEDED(hr)
Definition: intsafe.h:57
HRESULT WINAPI IDirectSoundCaptureBufferImpl_Lock(LPDIRECTSOUNDCAPTUREBUFFER8 iface, DWORD dwOffset, DWORD dwBytes, LPVOID *ppvAudioPtr1, LPDWORD pdwAudioBytes1, LPVOID *ppvAudioPtr2, LPDWORD pdwAudioBytes2, DWORD dwFlags)
VOID PerformChannelConversion(PUCHAR Buffer, ULONG BufferLength, PULONG BytesRead, ULONG OldChannels, ULONG NewChannels, ULONG BitsPerSample, PUCHAR Result, ULONG ResultLength, PULONG BytesWritten)
Definition: misc.c:18