ReactOS  0.4.14-dev-114-gc8cbd56
precomp.h File Reference
#include <windows.h>
#include <setupapi.h>
#include <mmddk.h>
#include <objbase.h>
#include <olectl.h>
#include <unknwn.h>
#include <dsound.h>
#include <dsconf.h>
#include <vfwmsgs.h>
#include <debug.h>
#include <ks.h>
#include <ksmedia.h>
#include <limits.h>
#include <stdio.h>
#include "resource.h"
Include dependency graph for precomp.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  INTERFACE_TABLE
 
struct  tagFILTERINFO
 

Macros

#define COBJMACROS
 
#define NONAMELESSUNION
 
#define NONAMELESSSTRUCT
 
#define YDEBUG
 
#define INIT_GUID(guid, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8)
 

Typedefs

typedef HRESULT(CALLBACKLPFNCREATEINSTANCE) (IUnknown *pUnkOuter, REFIID riid, LPVOID *ppvObject)
 
typedef struct tagFILTERINFO FILTERINFO
 
typedef struct tagFILTERINFOLPFILTERINFO
 

Enumerations

enum  PIN_TYPE { PIN_TYPE_NONE = 0, PIN_TYPE_PLAYBACK = 1, PIN_TYPE_RECORDING = 2 }
 

Functions

IClassFactoryIClassFactory_fnConstructor (LPFNCREATEINSTANCE lpfnCI, PLONG pcRefDll, REFIID riidInst)
 
HRESULT EnumAudioDeviceInterfaces (LPFILTERINFO *OutRootInfo)
 
BOOL FindDeviceByGuid (LPCGUID pGuidSrc, LPFILTERINFO *Filter)
 
BOOL FindDeviceByMappedId (IN ULONG DeviceID, LPFILTERINFO *Filter, BOOL bPlayback)
 
ULONG GetPinIdFromFilter (LPFILTERINFO Filter, BOOL bCapture, ULONG Offset)
 
HRESULT CALLBACK NewDirectSound (IUnknown *pUnkOuter, REFIID riid, LPVOID *ppvObject)
 
VOID PerformChannelConversion (PUCHAR Buffer, ULONG BufferLength, PULONG BytesRead, ULONG OldChannels, ULONG NewChannels, ULONG BitsPerSample, PUCHAR Result, ULONG ResultLength, PULONG BytesWritten)
 
BOOL SetPinFormat (IN HANDLE hPin, IN LPWAVEFORMATEX WaveFormatEx)
 
BOOL CreateCompatiblePin (IN HANDLE hFilter, IN DWORD PinId, IN BOOL bLoop, IN LPWAVEFORMATEX WaveFormatEx, OUT LPWAVEFORMATEX WaveFormatOut, OUT PHANDLE hPin)
 
DWORD SyncOverlappedDeviceIoControl (IN HANDLE Handle, IN DWORD IoControlCode, IN LPVOID InBuffer, IN DWORD InBufferSize, OUT LPVOID OutBuffer, IN DWORD OutBufferSize, OUT LPDWORD BytesTransferred OPTIONAL)
 
DWORD PrimaryDirectSoundBuffer_Write (LPDIRECTSOUNDBUFFER8 iface, LPVOID Buffer, DWORD BufferSize)
 
DWORD OpenPin (HANDLE hFilter, ULONG PinId, LPWAVEFORMATEX WaveFormatEx, PHANDLE hPin, BOOL bLoop)
 
DWORD OpenFilter (IN LPCWSTR lpFileName, IN PHANDLE OutHandle)
 
DWORD GetFilterPinCount (IN HANDLE hFilter, OUT PULONG NumPins)
 
DWORD GetFilterPinCommunication (IN HANDLE hFilter, IN ULONG PinId, OUT PKSPIN_COMMUNICATION Communication)
 
DWORD GetFilterPinDataFlow (IN HANDLE hFilter, IN ULONG PinId, OUT PKSPIN_DATAFLOW DataFlow)
 
HRESULT PrimaryDirectSoundBuffer_GetPosition (LPDIRECTSOUNDBUFFER8 iface, LPDWORD pdwCurrentPlayCursor, LPDWORD pdwCurrentWriteCursor)
 
VOID PrimaryDirectSoundBuffer_SetState (LPDIRECTSOUNDBUFFER8 iface, KSSTATE State)
 
HRESULT NewPrimarySoundBuffer (LPDIRECTSOUNDBUFFER8 *OutBuffer, LPFILTERINFO Filter, DWORD dwLevel, DWORD dwFlags)
 
HRESULT PrimaryDirectSoundBuffer_SetFormat (LPDIRECTSOUNDBUFFER8 iface, LPWAVEFORMATEX pcfxFormat, BOOL bLooped)
 
VOID PrimaryDirectSoundBuffer_AcquireLock (LPDIRECTSOUNDBUFFER8 iface)
 
VOID PrimaryDirectSoundBuffer_ReleaseLock (LPDIRECTSOUNDBUFFER8 iface)
 
HRESULT NewSecondarySoundBuffer (LPDIRECTSOUNDBUFFER8 *OutBuffer, LPFILTERINFO Filter, DWORD dwLevel, LPCDSBUFFERDESC lpcDSBufferDesc, LPDIRECTSOUNDBUFFER8 PrimaryBuffer)
 
HRESULT CALLBACK NewKsPropertySet (IUnknown *pUnkOuter, REFIID riid, LPVOID *ppvObject)
 
HRESULT CALLBACK NewDirectSoundCapture (IUnknown *pUnkOuter, REFIID riid, LPVOID *ppvObject)
 
HRESULT NewDirectSoundCaptureBuffer (LPDIRECTSOUNDCAPTUREBUFFER8 *OutBuffer, LPFILTERINFO Filter, LPCDSCBUFFERDESC lpcDSBufferDesc)
 
VOID DoNotifyPositionEvents (LPDIRECTSOUNDNOTIFY iface, DWORD OldPosition, DWORD NewPosition)
 
HRESULT NewDirectSoundNotify (LPDIRECTSOUNDNOTIFY *Notify, BOOL bLoop, BOOL bMix, HANDLE hPin, DWORD BufferSize)
 

Variables

HINSTANCE dsound_hInstance
 
LPFILTERINFO RootInfo
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 4 of file precomp.h.

◆ INIT_GUID

#define INIT_GUID (   guid,
  l,
  w1,
  w2,
  b1,
  b2,
  b3,
  b4,
  b5,
  b6,
  b7,
  b8 
)
Value:
guid.Data1 = l; guid.Data2 = w1; guid.Data3 = w2; \
guid.Data4[0] = b1; guid.Data4[1] = b2; guid.Data4[2] = b3; \
guid.Data4[3] = b4; guid.Data4[4] = b5; guid.Data4[5] = b6; \
guid.Data4[6] = b7; guid.Data4[7] = b8;
const GUID * guid
static CRYPT_DATA_BLOB b1[]
Definition: msg.c:573
r l[0]
Definition: byte_order.h:167
GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint GLdouble GLdouble w2
Definition: glext.h:8308
static CRYPT_DATA_BLOB b3[]
Definition: msg.c:592
static CRYPT_DATA_BLOB b2[]
Definition: msg.c:582
static CRYPT_DATA_BLOB b4
Definition: msg.c:2284
GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint GLdouble w1
Definition: glext.h:8308

Definition at line 52 of file precomp.h.

◆ NONAMELESSSTRUCT

#define NONAMELESSSTRUCT

Definition at line 6 of file precomp.h.

◆ NONAMELESSUNION

#define NONAMELESSUNION

Definition at line 5 of file precomp.h.

◆ YDEBUG

#define YDEBUG

Definition at line 18 of file precomp.h.

Typedef Documentation

◆ FILTERINFO

◆ LPFILTERINFO

◆ LPFNCREATEINSTANCE

typedef HRESULT(CALLBACK * LPFNCREATEINSTANCE) (IUnknown *pUnkOuter, REFIID riid, LPVOID *ppvObject)

Definition at line 29 of file precomp.h.

Enumeration Type Documentation

◆ PIN_TYPE

Enumerator
PIN_TYPE_NONE 
PIN_TYPE_PLAYBACK 
PIN_TYPE_RECORDING 

Definition at line 58 of file precomp.h.

Function Documentation

◆ CreateCompatiblePin()

BOOL CreateCompatiblePin ( IN HANDLE  hFilter,
IN DWORD  PinId,
IN BOOL  bLoop,
IN LPWAVEFORMATEX  WaveFormatEx,
OUT LPWAVEFORMATEX  WaveFormatOut,
OUT PHANDLE  hPin 
)

Definition at line 517 of file misc.c.

524 {
525  PKSMULTIPLE_ITEM Item = NULL;
526  PKSDATARANGE_AUDIO AudioRange;
527  DWORD dwResult;
528  DWORD dwIndex, nChannels;
529 
530  dwResult = GetFilterPinDataRanges(hFilter, PinId, &Item);
531 
532  if (dwResult != ERROR_SUCCESS)
533  {
534  /* failed to get data ranges */
535  return FALSE;
536  }
537 
538  CopyMemory(WaveFormatOut, WaveFormatEx, sizeof(WAVEFORMATEX));
539 
540  /* iterate through all dataranges */
541  AudioRange = (PKSDATARANGE_AUDIO)(Item + 1);
542  for(dwIndex = 0; dwIndex < Item->Count; dwIndex++)
543  {
544  if (AudioRange->DataRange.FormatSize != sizeof(KSDATARANGE_AUDIO))
545  {
547  AudioRange = (PKSDATARANGE_AUDIO)((PUCHAR)AudioRange + AudioRange->DataRange.FormatSize);
548  continue;
549  }
550 
551  if (WaveFormatOut->nSamplesPerSec < AudioRange->MinimumSampleFrequency)
552  WaveFormatOut->nSamplesPerSec = AudioRange->MinimumSampleFrequency;
553  else if (WaveFormatOut->nSamplesPerSec > AudioRange->MaximumSampleFrequency)
554  WaveFormatOut->nSamplesPerSec = AudioRange->MaximumSampleFrequency;
555 
556  if (WaveFormatOut->wBitsPerSample < AudioRange->MinimumBitsPerSample)
557  WaveFormatOut->wBitsPerSample = AudioRange->MinimumBitsPerSample;
558  else if (WaveFormatOut->wBitsPerSample > AudioRange->MaximumBitsPerSample)
559  WaveFormatOut->wBitsPerSample = AudioRange->MaximumBitsPerSample;
560 
561  DPRINT("MinimumBitsPerSample %u MaximumBitsPerSample %u MinimumSampleFrequency %u MaximumSampleFrequency %u\n",
562  AudioRange->MinimumBitsPerSample, AudioRange->MaximumBitsPerSample, AudioRange->MinimumSampleFrequency, AudioRange->MaximumSampleFrequency);
563 
564  for(nChannels = 1; nChannels <= AudioRange->MaximumChannels; nChannels++)
565  {
566  WaveFormatOut->nChannels = nChannels;
567 
568  dwResult = OpenPin(hFilter, PinId, WaveFormatOut, hPin, TRUE);
569  if (dwResult == ERROR_SUCCESS)
570  {
571  DPRINT("InFormat nChannels %u wBitsPerSample %u nSamplesPerSec %u\nOutFormat nChannels %u nBitsPerSample %u nSamplesPerSec %u\n",
572  WaveFormatEx->nChannels, WaveFormatEx->wBitsPerSample, WaveFormatEx->nSamplesPerSec,
573  WaveFormatOut->nChannels, WaveFormatOut->wBitsPerSample, WaveFormatOut->nSamplesPerSec);
574 
575 
576  /* free buffer */
577  HeapFree(GetProcessHeap(), 0, Item);
578  return TRUE;
579  }
580  }
581  AudioRange = (PKSDATARANGE_AUDIO)((PUCHAR)AudioRange + AudioRange->DataRange.FormatSize);
582  }
583 
584  /* free buffer */
585  HeapFree(GetProcessHeap(), 0, Item);
586  return FALSE;
587 }
ULONG Count
Definition: ks.h:1980
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
ULONG MaximumBitsPerSample
Definition: ksmedia.h:582
unsigned char * PUCHAR
Definition: retypes.h:3
int nChannels
Definition: pcmconverter.c:96
KSDATARANGE DataRange
Definition: ksmedia.h:579
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
DWORD OpenPin(HANDLE hFilter, ULONG PinId, LPWAVEFORMATEX WaveFormatEx, PHANDLE hPin, BOOL bLoop)
Definition: misc.c:212
#define GetProcessHeap()
Definition: compat.h:395
ULONG MinimumSampleFrequency
Definition: ksmedia.h:583
#define CopyMemory
Definition: winbase.h:1640
unsigned long DWORD
Definition: ntddk_ex.h:95
ULONG MaximumChannels
Definition: ksmedia.h:580
struct KSDATARANGE_AUDIO * PKSDATARANGE_AUDIO
ULONG MaximumSampleFrequency
Definition: ksmedia.h:584
ULONG MinimumBitsPerSample
Definition: ksmedia.h:581
#define UNIMPLEMENTED
Definition: debug.h:114
DWORD GetFilterPinDataRanges(IN HANDLE hFilter, IN ULONG PinId, IN OUT PKSMULTIPLE_ITEM *OutMultipleItem)
Definition: misc.c:461
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by NewDirectSoundCaptureBuffer().

◆ 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 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 KSEVENTDATA::@2894::@2896 EventHandle
struct CDirectSoundNotifyImpl * LPCDirectSoundNotifyImpl

Referenced by MixerThreadRoutine().

◆ EnumAudioDeviceInterfaces()

HRESULT EnumAudioDeviceInterfaces ( LPFILTERINFO OutRootInfo)

Definition at line 384 of file devicelist.c.

386 {
387  HDEVINFO hList;
388  DWORD Status;
389  HRESULT hResult;
390  ULONG WaveOutCount, WaveInCount;
391  GUID AudioDeviceGuid = {STATIC_KSCATEGORY_AUDIO};
392  LPFILTERINFO CurInfo;
393 
394  /* try open the device list */
395  Status = OpenDeviceList(&AudioDeviceGuid, &hList);
396 
397  if (Status != ERROR_SUCCESS)
398  {
399  DPRINT1("OpenDeviceList failed with %lx\n", Status);
400  return E_FAIL;
401  }
402 
403  if (!GetDeviceListInterfaces(hList, &AudioDeviceGuid, OutRootInfo))
404  {
405  DPRINT1("No devices found\n");
407  return S_FALSE;
408  }
409 
410  /* sanity check */
411  ASSERT(*OutRootInfo);
412 
413  CurInfo = *OutRootInfo;
414 
415  WaveOutCount = 0;
416  WaveInCount = 0;
417 
418  /* now check all audio filters */
419  while(CurInfo)
420  {
421  /* now check details of the audio filter */
422  hResult = EnumerateAudioFilter(CurInfo, &WaveInCount, &WaveOutCount);
423 
424  if (hResult != S_OK)
425  {
426  DPRINT1("EnumerateAudioFilter failed with %lx\n", Status);
427  break;
428  }
429 
430  /* move to next filter */
431  CurInfo = CurInfo->lpNext;
432  }
433 
434  /* close device list */
436 
437  /* done */
438  return hResult;
439 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define STATIC_KSCATEGORY_AUDIO
Definition: ksmedia.h:169
struct tagFILTERINFO * lpNext
Definition: precomp.h:49
BOOL GetDeviceListInterfaces(HDEVINFO DeviceHandle, IN LPGUID InterfaceGuid, LPFILTERINFO *OutPath)
Definition: devicelist.c:65
#define E_FAIL
Definition: ddrawi.h:102
#define S_FALSE
Definition: winerror.h:2357
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD OpenDeviceList(IN LPGUID InterfaceGuid, OUT HDEVINFO *OutHandle)
Definition: devicelist.c:33
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Status
Definition: gdiplustypes.h:24
HWND hList
Definition: livecd.c:10
#define S_OK
Definition: intsafe.h:59
BOOL CloseDeviceList(HDEVINFO Handle)
Definition: devicelist.c:58
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
HRESULT EnumerateAudioFilter(LPFILTERINFO CurInfo, OUT PULONG WaveInCount, OUT PULONG WaveOutCount)
Definition: devicelist.c:315

Referenced by DllMain(), DSoundEnumerate(), and IDirectSound8_fnInitialize().

◆ FindDeviceByGuid()

BOOL FindDeviceByGuid ( LPCGUID  pGuidSrc,
LPFILTERINFO Filter 
)

Definition at line 470 of file devicelist.c.

473 {
474  LPFILTERINFO CurInfo;
475  if (!RootInfo)
476  return FALSE;
477 
478  /* get first entry */
479  CurInfo = RootInfo;
480 
481  while(CurInfo)
482  {
483  if (IsEqualGUID(&CurInfo->DeviceGuid[0], pGuidSrc) ||
484  IsEqualGUID(&CurInfo->DeviceGuid[1], pGuidSrc))
485  {
486  /* found filter */
487  *Filter = CurInfo;
488  return TRUE;
489  }
490 
491  CurInfo = CurInfo->lpNext;
492  }
493 
494  return FALSE;
495 }
#define TRUE
Definition: types.h:120
struct tagFILTERINFO * lpNext
Definition: precomp.h:49
_Must_inspect_result_ _In_opt_ PFLT_FILTER Filter
Definition: fltkernel.h:1802
GUID DeviceGuid[2]
Definition: precomp.h:46
LPFILTERINFO RootInfo
Definition: dsound.c:13
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4021

Referenced by CDirectSoundCapture_fnInitialize(), GetDeviceID(), IDirectSound8_fnInitialize(), and KSPropertySetImpl_Get().

◆ FindDeviceByMappedId()

BOOL FindDeviceByMappedId ( IN ULONG  DeviceID,
LPFILTERINFO Filter,
BOOL  bPlayback 
)

Definition at line 442 of file devicelist.c.

446 {
447  LPFILTERINFO CurInfo;
448  if (!RootInfo)
449  return FALSE;
450 
451  /* get first entry */
452  CurInfo = RootInfo;
453 
454  while(CurInfo)
455  {
456  if ((bPlayback && CurInfo->MappedId[1] == DeviceID) ||
457  (!bPlayback && CurInfo->MappedId[0] == DeviceID))
458  {
459  /* found filter */
460  *Filter = CurInfo;
461  return TRUE;
462  }
463 
464  CurInfo = CurInfo->lpNext;
465  }
466  return FALSE;
467 }
#define TRUE
Definition: types.h:120
struct tagFILTERINFO * lpNext
Definition: precomp.h:49
_In_ USHORT DeviceID
Definition: iotypes.h:860
_Must_inspect_result_ _In_opt_ PFLT_FILTER Filter
Definition: fltkernel.h:1802
LPFILTERINFO RootInfo
Definition: dsound.c:13
ULONG MappedId[2]
Definition: precomp.h:47

Referenced by GetDeviceID().

◆ GetFilterPinCommunication()

DWORD GetFilterPinCommunication ( IN HANDLE  hFilter,
IN ULONG  PinId,
OUT PKSPIN_COMMUNICATION  Communication 
)

Definition at line 427 of file misc.c.

431 {
433 
437  Property.PinId = PinId;
438  Property.Reserved = 0;
439 
440  return SyncOverlappedDeviceIoControl(hFilter, IOCTL_KS_PROPERTY, (LPVOID)&Property, sizeof(KSP_PIN), (LPVOID)Communication, sizeof(KSPIN_COMMUNICATION), NULL);
441 }
#define IOCTL_KS_PROPERTY
Definition: ks.h:127
#define KSPROPERTY_TYPE_GET
Definition: dmksctrl.h:42
smooth NULL
Definition: ftsmooth.c:416
Definition: ks.h:642
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
_In_ DWORD Property
Definition: setupapi.h:1545
KSPIN_COMMUNICATION
Definition: ks.h:1253
const GUID KSPROPSETID_Pin
Definition: misc.c:12
Property(long _type, long _tag, INREAL _value)
Definition: reader.h:125

Referenced by FindAudioFilterPins().

◆ GetFilterPinCount()

DWORD GetFilterPinCount ( IN HANDLE  hFilter,
OUT PULONG  NumPins 
)

Definition at line 357 of file misc.c.

360 {
361  KSPROPERTY Pin;
362 
363  *NumPins = 0;
364 
365  /* setup the pin request */
367  Pin.Set = KSPROPSETID_Pin;
369 
370  /* query the device */
371  return SyncOverlappedDeviceIoControl(hFilter, IOCTL_KS_PROPERTY, (LPVOID)&Pin, sizeof(KSPROPERTY), (PVOID)NumPins, sizeof(ULONG), NULL);
372 }
#define IOCTL_KS_PROPERTY
Definition: ks.h:127
#define KSPROPERTY_TYPE_GET
Definition: dmksctrl.h:42
smooth NULL
Definition: ftsmooth.c:416
IN PDCB IN VBO IN ULONG IN BOOLEAN Pin
Definition: fatprocs.h:415
ULONG Flags
Definition: ntfs.h:532
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
const GUID KSPROPSETID_Pin
Definition: misc.c:12
unsigned int ULONG
Definition: retypes.h:1

Referenced by EnumerateAudioFilter().

◆ GetFilterPinDataFlow()

DWORD GetFilterPinDataFlow ( IN HANDLE  hFilter,
IN ULONG  PinId,
OUT PKSPIN_DATAFLOW  DataFlow 
)

Definition at line 444 of file misc.c.

448 {
450 
454  Property.PinId = PinId;
455  Property.Reserved = 0;
456 
458 }
#define IOCTL_KS_PROPERTY
Definition: ks.h:127
#define KSPROPERTY_TYPE_GET
Definition: dmksctrl.h:42
smooth NULL
Definition: ftsmooth.c:416
KSPIN_DATAFLOW
Definition: ks.h:1248
Definition: ks.h:642
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
_In_ DWORD Property
Definition: setupapi.h:1545
const GUID KSPROPSETID_Pin
Definition: misc.c:12
DataFlow
Property(long _type, long _tag, INREAL _value)
Definition: reader.h:125

Referenced by FindAudioFilterPins().

◆ GetPinIdFromFilter()

ULONG GetPinIdFromFilter ( LPFILTERINFO  Filter,
BOOL  bCapture,
ULONG  Offset 
)

Definition at line 13 of file devicelist.c.

17 {
18  ULONG Index;
19 
20  for(Index = Offset; Index < Filter->PinCount; Index++)
21  {
22  if (Filter->Pin[Index] == PIN_TYPE_PLAYBACK && !bCapture)
23  return Index;
24 
25  if (Filter->Pin[Index] == PIN_TYPE_RECORDING && bCapture)
26  return Index;
27  }
28  return ULONG_MAX;
29 }
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
_Must_inspect_result_ _In_opt_ PFLT_FILTER Filter
Definition: fltkernel.h:1802
static const UCHAR Index[8]
Definition: usbohci.c:18
unsigned int ULONG
Definition: retypes.h:1
#define ULONG_MAX
Definition: limits.h:44

Referenced by NewDirectSoundCaptureBuffer(), and PrimaryDirectSoundBuffer_SetFormat().

◆ IClassFactory_fnConstructor()

IClassFactory* IClassFactory_fnConstructor ( LPFNCREATEINSTANCE  lpfnCI,
PLONG  pcRefDll,
REFIID  riidInst 
)

Definition at line 125 of file classfactory.c.

129 {
130  IClassFactoryImpl* lpclf;
131 
132  lpclf = CoTaskMemAlloc(sizeof(IClassFactoryImpl));
133  lpclf->ref = 1;
134  lpclf->lpVtbl = &dclfvt;
135  lpclf->lpfnCI = lpfnCI;
136 
137  if (pcRefDll)
138  InterlockedIncrement(pcRefDll);
139  lpclf->riidInst = riidInst;
140 
141  return (LPCLASSFACTORY)lpclf;
142 }
LPFNCREATEINSTANCE lpfnCI
Definition: classfactory.c:18
const IClassFactoryVtbl * lpVtbl
Definition: classfactory.c:15
LPFNCREATEINSTANCE lpfnCI
Definition: shellole.c:61
const IID * riidInst
Definition: classfactory.c:19
#define InterlockedIncrement
Definition: armddk.h:53
static const IClassFactoryVtbl dclfvt
Definition: classfactory.c:114
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:406

◆ NewDirectSound()

HRESULT CALLBACK NewDirectSound ( IUnknown pUnkOuter,
REFIID  riid,
LPVOID ppvObject 
)

Definition at line 449 of file directsound.c.

453 {
454  LPOLESTR pStr;
456 
457  /* check param */
458  if (!ppvObject)
459  {
460  /* invalid param */
461  return E_INVALIDARG;
462  }
463 
464  /* check requested interface */
465  if (!IsEqualIID(riid, &IID_IUnknown) && !IsEqualIID(riid, &IID_IDirectSound) && !IsEqualIID(riid, &IID_IDirectSound8))
466  {
467  *ppvObject = 0;
468  StringFromIID(riid, &pStr);
469  DPRINT("KsPropertySet does not support Interface %ws\n", pStr);
470  CoTaskMemFree(pStr);
471  return E_NOINTERFACE;
472  }
473 
474  /* allocate CDirectSoundCaptureImpl struct */
476  if (!This)
477  {
478  /* not enough memory */
479  return DSERR_OUTOFMEMORY;
480  }
481 
482  /* initialize object */
483  This->ref = 1;
484  This->lpVtbl = &vt_DirectSound8;
485  This->bInitialized = FALSE;
486  *ppvObject = (LPVOID)&This->lpVtbl;
487 
488  return S_OK;
489 }
#define E_NOINTERFACE
Definition: winerror.h:2364
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:422
REFIID riid
Definition: precomp.h:44
static IDirectSound8Vtbl vt_DirectSound8
Definition: directsound.c:380
static LPOLESTR
Definition: stg_prop.c:27
#define DSERR_OUTOFMEMORY
Definition: dsound.h:125
#define E_INVALIDARG
Definition: ddrawi.h:101
void DPRINT(...)
Definition: polytest.cpp:61
_Check_return_ HRESULT WINAPI StringFromIID(_In_ REFIID rclsid, _Outptr_ LPOLESTR *lplpsz)
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
const GUID IID_IUnknown
#define LPVOID
Definition: nt_native.h:45
REFIID LPVOID * ppvObject
Definition: precomp.h:44
#define S_OK
Definition: intsafe.h:59
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95

◆ NewDirectSoundCapture()

HRESULT CALLBACK NewDirectSoundCapture ( IUnknown pUnkOuter,
REFIID  riid,
LPVOID ppvObject 
)

Definition at line 284 of file capture.c.

288 {
289  LPOLESTR pStr;
291 
292  /* check requested interface */
293  if (!IsEqualIID(riid, &IID_IUnknown) && !IsEqualIID(riid, &IID_IDirectSoundCapture) && !IsEqualIID(riid, &IID_IDirectSoundCapture8))
294  {
295  *ppvObject = 0;
296  StringFromIID(riid, &pStr);
297  DPRINT("NewDirectSoundCapture does not support Interface %ws\n", pStr);
298  CoTaskMemFree(pStr);
299  return E_NOINTERFACE;
300  }
301 
302  /* allocate CDirectSoundCaptureImpl struct */
304  if (!This)
305  {
306  /* not enough memory */
307  return DSERR_OUTOFMEMORY;
308  }
309 
310  /* initialize object */
311  This->ref = 1;
312  This->lpVtbl = &vt_DirectSoundCapture;
313  This->bInitialized = FALSE;
314  *ppvObject = (LPVOID)&This->lpVtbl;
315 
316  return S_OK;
317 }
#define E_NOINTERFACE
Definition: winerror.h:2364
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:422
REFIID riid
Definition: precomp.h:44
static LPOLESTR
Definition: stg_prop.c:27
#define DSERR_OUTOFMEMORY
Definition: dsound.h:125
void DPRINT(...)
Definition: polytest.cpp:61
_Check_return_ HRESULT WINAPI StringFromIID(_In_ REFIID rclsid, _Outptr_ LPOLESTR *lplpsz)
static LPVOID
Definition: capture.c:29
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
const GUID IID_IUnknown
#define IID_IDirectSoundCapture8
Definition: dsound.h:93
static IDirectSoundCaptureVtbl vt_DirectSoundCapture
Definition: capture.c:225
REFIID LPVOID * ppvObject
Definition: precomp.h:44
#define S_OK
Definition: intsafe.h:59
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95

◆ NewDirectSoundCaptureBuffer()

HRESULT NewDirectSoundCaptureBuffer ( LPDIRECTSOUNDCAPTUREBUFFER8 OutBuffer,
LPFILTERINFO  Filter,
LPCDSCBUFFERDESC  lpcDSBufferDesc 
)

Definition at line 687 of file capturebuffer.c.

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 }
LPWAVEFORMATEX lpwfxFormat
Definition: dsound.h:361
#define DSERR_GENERIC
Definition: dsound.h:123
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
#define ERROR_SUCCESS
Definition: deptool.c:10
WORD nChannels
Definition: mmreg.h:79
DWORD dwBufferBytes
Definition: dsound.h:359
struct tWAVEFORMATEX WAVEFORMATEX
Definition: austream.idl:23
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define DSERR_OUTOFMEMORY
Definition: dsound.h:125
_Must_inspect_result_ _In_opt_ PFLT_FILTER Filter
Definition: fltkernel.h:1802
_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
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 DS_OK
Definition: dsound.h:116
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define CopyMemory
Definition: winbase.h:1640
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
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
WORD cbSize
Definition: mmreg.h:84
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define DPRINT1
Definition: precomp.h:8
WORD wBitsPerSample
Definition: mmreg.h:83
unsigned int ULONG
Definition: retypes.h:1
static IDirectSoundCaptureBuffer8Vtbl vt_DirectSoundCaptureBuffer8
struct IDirectSoundCaptureBuffer8 * LPDIRECTSOUNDCAPTUREBUFFER8
Definition: dsound.h:100
#define HeapFree(x, y, z)
Definition: compat.h:394
#define ULONG_MAX
Definition: limits.h:44

Referenced by CDirectSoundCapture_fnCreateCaptureBuffer().

◆ 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:395
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().

◆ NewKsPropertySet()

HRESULT CALLBACK NewKsPropertySet ( IUnknown pUnkOuter,
REFIID  riid,
LPVOID ppvObject 
)

Definition at line 244 of file property.c.

248 {
249  LPOLESTR pStr;
251 
252  /* check requested interface */
254  {
255  *ppvObject = 0;
256  StringFromIID(riid, &pStr);
257  DPRINT("KsPropertySet does not support Interface %ws\n", pStr);
258  CoTaskMemFree(pStr);
259  return E_NOINTERFACE;
260  }
261 
262  /* allocate object */
264  if (!This)
265  return E_OUTOFMEMORY;
266 
267  /* initialize object */
268  This->ref = 1;
269  This->lpVtbl = &vt_KsPropertySet;
270  *ppvObject = (LPVOID)&This->lpVtbl;
271 
272  return S_OK;
273 }
#define E_NOINTERFACE
Definition: winerror.h:2364
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:422
REFIID riid
Definition: precomp.h:44
static LPOLESTR
Definition: stg_prop.c:27
static IKsPropertySetVtbl vt_KsPropertySet
Definition: property.c:230
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
void DPRINT(...)
Definition: polytest.cpp:61
_Check_return_ HRESULT WINAPI StringFromIID(_In_ REFIID rclsid, _Outptr_ LPOLESTR *lplpsz)
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
const GUID IID_IUnknown
#define LPVOID
Definition: nt_native.h:45
REFIID LPVOID * ppvObject
Definition: precomp.h:44
const GUID IID_IKsPropertySet
Definition: controlnode.cpp:13
#define S_OK
Definition: intsafe.h:59
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95

◆ NewPrimarySoundBuffer()

HRESULT NewPrimarySoundBuffer ( LPDIRECTSOUNDBUFFER8 OutBuffer,
LPFILTERINFO  Filter,
DWORD  dwLevel,
DWORD  dwFlags 
)

Definition at line 768 of file primary.c.

773 {
775 
776  if (!This)
777  {
778  /* not enough memory */
779  return DSERR_OUTOFMEMORY;
780  }
781 
782  This->ref = 1;
783  This->lpVtbl = &vt_DirectSoundBuffer8;
784  This->Filter = Filter;
785  This->dwLevel = dwLevel;
786  This->dwFlags = dwFlags;
787  This->dwFrequency = 0;
788  This->Volume = DSBVOLUME_MAX;
789  This->VolumePan = DSBPAN_CENTER;
790  This->hPin = NULL;
791 
792  /* FIXME: determine default format for audio device */
793  This->Format.cbSize = sizeof(WAVEFORMATEX);
794  This->Format.nChannels = 2;
795  This->Format.nSamplesPerSec = 44100;
796  This->Format.wBitsPerSample = 16;
797  This->Format.wFormatTag = WAVE_FORMAT_PCM;
798  This->Format.nBlockAlign = (This->Format.nChannels * This->Format.wBitsPerSample) / 8;
799  This->Format.nAvgBytesPerSec = (This->Format.nChannels * This->Format.nSamplesPerSec * This->Format.wBitsPerSample) / 8;
800 
802 
803  *OutBuffer = (LPDIRECTSOUNDBUFFER8)&This->lpVtbl;
804  return DS_OK;
805 }
struct IDirectSoundBuffer8 * LPDIRECTSOUNDBUFFER8
Definition: dsound.h:79
static IDirectSoundBuffer8Vtbl vt_DirectSoundBuffer8
Definition: primary.c:555
#define DSBPAN_CENTER
Definition: dsound.h:227
struct tWAVEFORMATEX WAVEFORMATEX
Definition: austream.idl:23
#define DSBVOLUME_MAX
Definition: dsound.h:229
#define DSERR_OUTOFMEMORY
Definition: dsound.h:125
#define WAVE_FORMAT_PCM
Definition: constants.h:425
_Must_inspect_result_ _In_opt_ PFLT_FILTER Filter
Definition: fltkernel.h:1802
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:751
smooth NULL
Definition: ftsmooth.c:416
#define DS_OK
Definition: dsound.h:116
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define HEAP_ZERO_MEMORY
Definition: compat.h:123

Referenced by IDirectSound8_fnCreateSoundBuffer().

◆ NewSecondarySoundBuffer()

HRESULT NewSecondarySoundBuffer ( LPDIRECTSOUNDBUFFER8 OutBuffer,
LPFILTERINFO  Filter,
DWORD  dwLevel,
LPCDSBUFFERDESC  lpcDSBufferDesc,
LPDIRECTSOUNDBUFFER8  PrimaryBuffer 
)

Definition at line 611 of file secondary.c.

617 {
618  ULONG FormatSize;
620 
621  if (!This)
622  {
623  /* not enough memory */
624  return DSERR_OUTOFMEMORY;
625  }
626 
627  FormatSize = sizeof(WAVEFORMATEX) + lpcDSBufferDesc->lpwfxFormat->cbSize;
628 
629  This->Format = HeapAlloc(GetProcessHeap(), 0, FormatSize);
630  if (!This->Format)
631  {
632  /* not enough memory */
634  return DSERR_OUTOFMEMORY;
635  }
636 
637  /* sanity check */
638  ASSERT(lpcDSBufferDesc->dwBufferBytes);
639 
640  /* allocate sound buffer */
641  This->Buffer = HeapAlloc(GetProcessHeap(), 0, lpcDSBufferDesc->dwBufferBytes);
642  if (!This->Buffer)
643  {
644  /* not enough memory */
645  HeapFree(GetProcessHeap(), 0, This->Format);
647  return DSERR_OUTOFMEMORY;
648  }
649 
650  /* fill buffer with silence */
651  FillMemory(This->Buffer, lpcDSBufferDesc->dwBufferBytes, lpcDSBufferDesc->lpwfxFormat->wBitsPerSample == 8 ? 0x80 : 0);
652 
653  This->ref = 1;
654  This->lpVtbl = &vt_DirectSoundBuffer8;
655  This->Filter = Filter;
656  This->dwLevel = dwLevel;
657  This->dwFlags = lpcDSBufferDesc->dwFlags;
658  This->dwFrequency = lpcDSBufferDesc->lpwfxFormat->nSamplesPerSec;
659  This->State = KSSTATE_STOP;
660  This->Volume = DSBVOLUME_MAX;
661  This->VolumePan = DSBPAN_CENTER;
662  This->Flags = 0;
663  This->Position = 0;
664  This->BufferSize = lpcDSBufferDesc->dwBufferBytes;
665  This->PrimaryBuffer = PrimaryBuffer;
666 
667  CopyMemory(This->Format, lpcDSBufferDesc->lpwfxFormat, FormatSize);
668 
669  *OutBuffer = (LPDIRECTSOUNDBUFFER8)&This->lpVtbl;
670  return DS_OK;
671 }
struct IDirectSoundBuffer8 * LPDIRECTSOUNDBUFFER8
Definition: dsound.h:79
#define DSBPAN_CENTER
Definition: dsound.h:227
static IDirectSoundBuffer8Vtbl vt_DirectSoundBuffer8
Definition: secondary.c:579
struct tWAVEFORMATEX WAVEFORMATEX
Definition: austream.idl:23
#define DSBVOLUME_MAX
Definition: dsound.h:229
#define DSERR_OUTOFMEMORY
Definition: dsound.h:125
_Must_inspect_result_ _In_opt_ PFLT_FILTER Filter
Definition: fltkernel.h:1802
#define DS_OK
Definition: dsound.h:116
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define CopyMemory
Definition: winbase.h:1640
#define FillMemory(BUF, SIZ, MASK)
Definition: strucsup.c:31
LPWAVEFORMATEX lpwfxFormat
Definition: dsound.h:292
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
WORD cbSize
Definition: mmreg.h:84
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
DWORD nSamplesPerSec
Definition: mmreg.h:80
WORD wBitsPerSample
Definition: mmreg.h:83
DWORD dwBufferBytes
Definition: dsound.h:290
unsigned int ULONG
Definition: retypes.h:1
DWORD dwFlags
Definition: dsound.h:289
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by IDirectSound8_fnCreateSoundBuffer().

◆ OpenFilter()

DWORD OpenFilter ( IN LPCWSTR  lpFileName,
IN PHANDLE  OutHandle 
)

Definition at line 277 of file misc.c.

280 {
281  HANDLE Handle;
282 
283  /* open the filter */
285 
286  /* check for success */
288  {
289  DPRINT("Failed to open Filter %ws\n", lpFileName);
290  return GetLastError();
291  }
292 
293  *OutHandle = Handle;
294  return ERROR_SUCCESS;
295 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define GENERIC_WRITE
Definition: nt_native.h:90
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define OPEN_EXISTING
Definition: compat.h:426
_In_ HANDLE Handle
Definition: extypes.h:390
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
#define GENERIC_READ
Definition: compat.h:124
#define CreateFileW
Definition: compat.h:400
#define FILE_FLAG_OVERLAPPED
Definition: disk.h:46
_In_ LPCSTR lpFileName
Definition: winbase.h:3018

Referenced by EnumerateAudioFilter().

◆ OpenPin()

DWORD OpenPin ( HANDLE  hFilter,
ULONG  PinId,
LPWAVEFORMATEX  WaveFormatEx,
PHANDLE  hPin,
BOOL  bLoop 
)

Definition at line 212 of file misc.c.

218 {
219  DWORD Size, Result;
220  PKSPIN_CONNECT PinConnect;
222 
223  /* calculate request size */
224  Size = sizeof(KSPIN_CONNECT) + sizeof(KSDATAFORMAT_WAVEFORMATEX);
225 
226  PinConnect = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, Size);
227  if (!PinConnect)
228  {
229  /* not enough memory */
230  return DSERR_OUTOFMEMORY;
231  }
232  /* build pin request */
234 
235  if (bLoop)
237  else
239 
240  PinConnect->Interface.Flags = 0;
241  PinConnect->Medium.Set = KSMEDIUMSETID_Standard;
242  PinConnect->Medium.Id = KSMEDIUM_TYPE_ANYINSTANCE;
243  PinConnect->Medium.Flags = 0;
244  PinConnect->PinToHandle = NULL;
245  PinConnect->PinId = PinId;
247  PinConnect->Priority.PrioritySubClass = 1;
248 
249  DataFormat = (PKSDATAFORMAT_WAVEFORMATEX) (PinConnect + 1);
250 
251  /* initialize data format */
252  DataFormat->WaveFormatEx.wFormatTag = WaveFormatEx->wFormatTag;
253  DataFormat->WaveFormatEx.nChannels = WaveFormatEx->nChannels;
254  DataFormat->WaveFormatEx.nSamplesPerSec = WaveFormatEx->nSamplesPerSec;
255  DataFormat->WaveFormatEx.nBlockAlign = WaveFormatEx->nBlockAlign;
256  DataFormat->WaveFormatEx.nAvgBytesPerSec = WaveFormatEx->nAvgBytesPerSec;
257  DataFormat->WaveFormatEx.wBitsPerSample = WaveFormatEx->wBitsPerSample;
258  DataFormat->WaveFormatEx.cbSize = 0;
259  DataFormat->DataFormat.FormatSize = sizeof(KSDATAFORMAT) + sizeof(WAVEFORMATEX);
260  DataFormat->DataFormat.Flags = 0;
261  DataFormat->DataFormat.Reserved = 0;
262  DataFormat->DataFormat.MajorFormat = KSDATAFORMAT_TYPE_AUDIO;
263 
264  DataFormat->DataFormat.SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
265  DataFormat->DataFormat.Specifier = KSDATAFORMAT_SPECIFIER_WAVEFORMATEX;
266  DataFormat->DataFormat.SampleSize = 4;
267 
268  Result = KsCreatePin(hFilter, PinConnect, GENERIC_READ | GENERIC_WRITE, hPin);
269 
270  HeapFree(GetProcessHeap(), 0, PinConnect);
271 
272  return Result;
273 }
KSPIN_INTERFACE Interface
Definition: ks.h:2601
#define KSDATAFORMAT_SUBTYPE_PCM
Definition: ksmedia.h:921
KSPIN_MEDIUM Medium
Definition: ks.h:2602
KSDDKAPI DWORD NTAPI KsCreatePin(HANDLE FilterHandle, PKSPIN_CONNECT Connect, ACCESS_MASK DesiredAccess, PHANDLE ConnectionHandle)
Definition: ksuser.c:192
#define KSPRIORITY_NORMAL
Definition: ks.h:1386
DWORD nAvgBytesPerSec
Definition: mmreg.h:81
WORD nChannels
Definition: mmreg.h:79
#define KSINTERFACESETID_Standard
Definition: ks.h:280
ULONG PriorityClass
Definition: ks.h:1391
#define KSMEDIUMSETID_Standard
Definition: ks.h:306
GUID Set
Definition: dmksctrl.h:76
#define KSDATAFORMAT_SPECIFIER_WAVEFORMATEX
Definition: ksmedia.h:931
#define DSERR_OUTOFMEMORY
Definition: dsound.h:125
ULONG PinId
Definition: ks.h:2603
HANDLE PinToHandle
Definition: ks.h:2604
#define GENERIC_WRITE
Definition: nt_native.h:90
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
ULONG PrioritySubClass
Definition: ks.h:1392
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
ULONG Id
Definition: dmksctrl.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
WORD wFormatTag
Definition: mmreg.h:78
ULONG Flags
Definition: dmksctrl.h:78
#define GENERIC_READ
Definition: compat.h:124
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
#define KSDATAFORMAT_TYPE_AUDIO
Definition: ksmedia.h:883
struct KSDATAFORMAT_WAVEFORMATEX * PKSDATAFORMAT_WAVEFORMATEX
#define KSMEDIUM_TYPE_ANYINSTANCE
Definition: ks.h:301
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
DWORD nSamplesPerSec
Definition: mmreg.h:80
WORD nBlockAlign
Definition: mmreg.h:82
WORD wBitsPerSample
Definition: mmreg.h:83
KSPRIORITY Priority
Definition: ks.h:2605
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by CreateCompatiblePin(), NewDirectSoundCaptureBuffer(), and PrimaryDirectSoundBuffer_SetFormat().

◆ PerformChannelConversion()

VOID PerformChannelConversion ( PUCHAR  Buffer,
ULONG  BufferLength,
PULONG  BytesRead,
ULONG  OldChannels,
ULONG  NewChannels,
ULONG  BitsPerSample,
PUCHAR  Result,
ULONG  ResultLength,
PULONG  BytesWritten 
)

Definition at line 18 of file misc.c.

28 {
29  DWORD NewIndex, OldIndex;
30  DWORD NewLength, Skip;
31 
32  if (NewChannels > OldChannels)
33  {
35  ASSERT(0);
36  }
37 
38  /* setup index */
39  NewIndex = 0;
40  OldIndex = 0;
41 
42  /* calculate offsets */
43  NewLength = NewChannels * (BitsPerSample/8);
44  Skip = OldChannels * (BitsPerSample/8);
45 
46  do
47  {
48  if (NewIndex + NewLength>= ResultLength)
49  {
50  NewIndex = ResultLength;
51  break;
52  }
53 
54  if (OldIndex + Skip >= BufferLength)
55  {
56  OldIndex = BufferLength;
57  break;
58  }
59 
60  /* copy first channel */
61  RtlMoveMemory(&Result[NewIndex], &Buffer[OldIndex], NewLength);
62 
63  /* skip other channels */
64  OldIndex += Skip;
65 
66  /* increment offset */
67  NewIndex += NewLength;
68 
69  }while(TRUE);
70 
71  *BytesRead = OldIndex;
72  *BytesWritten = NewIndex;
73 }
IN CINT OUT PVOID IN ULONG OUT PULONG ResultLength
Definition: conport.c:47
_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 TRUE
Definition: types.h:120
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
static USHORT USHORT * NewLength
_In_ ULONG BufferLength
Definition: usbdlib.h:225
_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
Definition: bufpool.h:45
unsigned long DWORD
Definition: ntddk_ex.h:95
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define UNIMPLEMENTED
Definition: debug.h:114
_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

Referenced by MixerThreadRoutine().

◆ PrimaryDirectSoundBuffer_AcquireLock()

VOID PrimaryDirectSoundBuffer_AcquireLock ( LPDIRECTSOUNDBUFFER8  iface)

Definition at line 746 of file primary.c.

748 {
750 
751  EnterCriticalSection(&This->Lock);
752 
753 
754 }
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
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
struct CDirectSoundBuffer * LPCDirectSoundBuffer

Referenced by PrimaryDirectSoundBuffer8Impl_fnPlay(), PrimaryDirectSoundBuffer8Impl_fnStop(), and SecondaryDirectSoundBuffer8Impl_fnPlay().

◆ PrimaryDirectSoundBuffer_GetPosition()

HRESULT PrimaryDirectSoundBuffer_GetPosition ( LPDIRECTSOUNDBUFFER8  iface,
LPDWORD  pdwCurrentPlayCursor,
LPDWORD  pdwCurrentWriteCursor 
)

Definition at line 644 of file primary.c.

648 {
651  DWORD Result;
653 
654  //DPRINT("PrimaryDirectSoundBuffer_GetPosition\n");
655 
656  if (!This->hPin)
657  {
658  if (pdwCurrentPlayCursor)
659  *pdwCurrentPlayCursor = 0;
660 
661  if (pdwCurrentWriteCursor)
662  *pdwCurrentWriteCursor = 0;
663 
664  DPRINT("No Audio Pin\n");
665  return DS_OK;
666  }
667 
668  /* setup audio position property request */
672 
673 
675 
676  if (Result != ERROR_SUCCESS)
677  {
678  DPRINT("GetPosition failed with %x\n", Result);
679  return DSERR_UNSUPPORTED;
680  }
681 
682  //DPRINT("Play %I64u Write %I64u \n", Position.PlayOffset, Position.WriteOffset);
683 
684  if (pdwCurrentPlayCursor)
685  *pdwCurrentPlayCursor = (DWORD)Position.PlayOffset;
686 
687  if (pdwCurrentWriteCursor)
688  *pdwCurrentWriteCursor = (DWORD)Position.WriteOffset;
689 
690  return DS_OK;
691 }
#define IOCTL_KS_PROPERTY
Definition: ks.h:127
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KSPROPSETID_Audio
Definition: ksmedia.h:951
static COORD Position
Definition: mouse.c:34
#define DWORD
Definition: nt_native.h:44
#define KSPROPERTY_TYPE_GET
Definition: dmksctrl.h:42
_In_ NDIS_HANDLE _In_ PNDIS_REQUEST Request
Definition: ndis.h:5173
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
#define DS_OK
Definition: dsound.h:116
if(!(yy_init))
Definition: macro.lex.yy.c:714
unsigned long DWORD
Definition: ntddk_ex.h:95
#define DSERR_UNSUPPORTED
Definition: dsound.h:127
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 CDirectSoundBuffer * LPCDirectSoundBuffer

Referenced by SecondaryDirectSoundBuffer8Impl_fnGetCurrentPosition().

◆ PrimaryDirectSoundBuffer_ReleaseLock()

VOID PrimaryDirectSoundBuffer_ReleaseLock ( LPDIRECTSOUNDBUFFER8  iface)

Definition at line 757 of file primary.c.

759 {
761 
762  LeaveCriticalSection(&This->Lock);
763 
764 }
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
struct CDirectSoundBuffer * LPCDirectSoundBuffer
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

Referenced by PrimaryDirectSoundBuffer8Impl_fnPlay(), PrimaryDirectSoundBuffer8Impl_fnStop(), and SecondaryDirectSoundBuffer8Impl_fnPlay().

◆ PrimaryDirectSoundBuffer_SetFormat()

HRESULT PrimaryDirectSoundBuffer_SetFormat ( LPDIRECTSOUNDBUFFER8  iface,
LPWAVEFORMATEX  pcfxFormat,
BOOL  bLooped 
)

Definition at line 694 of file primary.c.

698 {
699  ULONG PinId, DeviceId = 0, Result;
701 
702  if (This->hPin)
703  {
704  // FIXME
705  // check if multiple buffers are active
706  // in that case need mixing
707 
708  if (SetPinFormat(This->hPin, pcfxFormat))
709  return DS_OK;
710  else
711  return DSERR_GENERIC;
712  }
713 
714  do
715  {
716  /* try all available recording pins on that filter */
717  PinId = GetPinIdFromFilter(This->Filter, FALSE, DeviceId);
718  DPRINT("PinId %u DeviceId %u\n", PinId, DeviceId);
719 
720  if (PinId == ULONG_MAX)
721  break;
722 
723  Result = OpenPin(This->Filter->hFilter, PinId, (LPWAVEFORMATEX)pcfxFormat, &This->hPin, bLooped);
724  DPRINT("PinId %u Result %u\n", PinId, Result);
725  if (Result == ERROR_SUCCESS)
726  {
727  This->dwFrequency = pcfxFormat->nSamplesPerSec;
728  break;
729  }
730 
731  This->hPin = NULL;
732  DeviceId++;
733  }while(TRUE);
734 
735  if (!This->hPin)
736  {
737  DPRINT("PrimaryDirectSoundBuffer8Impl_fnSetFormat failed\n");
738  return DSERR_INVALIDPARAM;
739  }
740 
741  DPRINT("PrimaryDirectSoundBuffer8Impl_fnSetFormat success\n");
742  return DS_OK;
743 }
#define DSERR_GENERIC
Definition: dsound.h:123
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
#define DSERR_INVALIDPARAM
Definition: dsound.h:121
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
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 DS_OK
Definition: dsound.h:116
struct CDirectSoundBuffer * LPCDirectSoundBuffer
DWORD nSamplesPerSec
Definition: mmreg.h:80
unsigned int ULONG
Definition: retypes.h:1
BOOL SetPinFormat(IN HANDLE hPin, IN LPWAVEFORMATEX WaveFormatEx)
Definition: misc.c:77
#define ULONG_MAX
Definition: limits.h:44

Referenced by SecondaryDirectSoundBuffer8Impl_fnPlay().

◆ PrimaryDirectSoundBuffer_SetState()

VOID PrimaryDirectSoundBuffer_SetState ( LPDIRECTSOUNDBUFFER8  iface,
KSSTATE  State 
)

Definition at line 621 of file primary.c.

624 {
626  DWORD Result, BytesTransferred;
628 
629  if (This->State == State)
630  return;
631 
635 
636  Result = SyncOverlappedDeviceIoControl(This->hPin, IOCTL_KS_PROPERTY, (PVOID)&Property, sizeof(KSPROPERTY), (PVOID)&State, sizeof(KSSTATE), &BytesTransferred);
637  if (Result == ERROR_SUCCESS)
638  {
639  This->State = State;
640  }
641 }
#define IOCTL_KS_PROPERTY
Definition: ks.h:127
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KSPROPSETID_Connection
Definition: ks.h:346
_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
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
unsigned long DWORD
Definition: ntddk_ex.h:95
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
_In_ DWORD Property
Definition: setupapi.h:1545
enum State_ State
Definition: pofuncs.h:54
KSSTATE
Definition: ks.h:1214
struct CDirectSoundBuffer * LPCDirectSoundBuffer
#define KSPROPERTY_TYPE_SET
Definition: dmksctrl.h:43

Referenced by PrimaryDirectSoundBuffer8Impl_fnPlay(), PrimaryDirectSoundBuffer8Impl_fnStop(), SecondaryDirectSoundBuffer8Impl_fnPlay(), and SecondaryDirectSoundBuffer8Impl_fnStop().

◆ PrimaryDirectSoundBuffer_Write()

DWORD PrimaryDirectSoundBuffer_Write ( LPDIRECTSOUNDBUFFER8  iface,
LPVOID  Buffer,
DWORD  BufferSize 
)

Definition at line 587 of file primary.c.

591 {
593  DWORD Result, BytesTransferred;
594  OVERLAPPED Overlapped;
595 
597 
598  ZeroMemory(&Overlapped, sizeof(OVERLAPPED));
599  Overlapped.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
600 
601 
602  ASSERT(This->hPin);
603  ZeroMemory(&Header, sizeof(KSSTREAM_HEADER));
604 
605  Header.FrameExtent = BufferSize;
606  Header.DataUsed = BufferSize;
607  Header.Data = Buffer;
608  Header.Size = sizeof(KSSTREAM_HEADER);
609  Header.PresentationTime.Numerator = 1;
610  Header.PresentationTime.Denominator = 1;
611 
612  Result = DeviceIoControl(This->hPin, IOCTL_KS_WRITE_STREAM, NULL, 0, &Header, sizeof(KSSTREAM_HEADER), &BytesTransferred, &Overlapped);
613 
614  if (Result != ERROR_SUCCESS)
615  return 0;
616 
617  return BytesTransferred;
618 }
#define CreateEvent
Definition: winbase.h:3572
#define IOCTL_KS_WRITE_STREAM
Definition: ks.h:139
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ZeroMemory
Definition: winbase.h:1642
Definition: Header.h:8
HANDLE hEvent
Definition: winbase.h:792
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
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 BufferSize
Definition: classpnp.h:419
unsigned long DWORD
Definition: ntddk_ex.h:95
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
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
struct CDirectSoundBuffer * LPCDirectSoundBuffer
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

Referenced by SecondaryDirectSoundBuffer8Impl_fnPlay().

◆ SetPinFormat()

BOOL SetPinFormat ( IN HANDLE  hPin,
IN LPWAVEFORMATEX  WaveFormatEx 
)

Definition at line 77 of file misc.c.

80 {
81  DWORD dwResult;
84 
85  /* setup connection request */
89 
90  /* setup data format */
91  DataFormat.WaveFormatEx.wFormatTag = WaveFormatEx->wFormatTag;
92  DataFormat.WaveFormatEx.nSamplesPerSec = WaveFormatEx->nSamplesPerSec;
93  DataFormat.WaveFormatEx.nBlockAlign = WaveFormatEx->nBlockAlign;
94  DataFormat.WaveFormatEx.cbSize = 0;
95  DataFormat.DataFormat.FormatSize = sizeof(KSDATAFORMAT) + sizeof(WAVEFORMATEX);
96  DataFormat.DataFormat.Flags = 0;
97  DataFormat.DataFormat.Reserved = 0;
98  DataFormat.DataFormat.MajorFormat = KSDATAFORMAT_TYPE_AUDIO;
99  DataFormat.DataFormat.SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
100  DataFormat.DataFormat.Specifier = KSDATAFORMAT_SPECIFIER_WAVEFORMATEX;
101  DataFormat.DataFormat.SampleSize = 4;
102  DataFormat.WaveFormatEx.nChannels = WaveFormatEx->nChannels;
103  DataFormat.WaveFormatEx.nAvgBytesPerSec = WaveFormatEx->nAvgBytesPerSec;
104  DataFormat.WaveFormatEx.wBitsPerSample = WaveFormatEx->wBitsPerSample;
105 
107 
108  if (dwResult == ERROR_SUCCESS)
109  return TRUE;
110  else
111  return FALSE;
112 }
#define IOCTL_KS_PROPERTY
Definition: ks.h:127
#define TRUE
Definition: types.h:120
#define KSDATAFORMAT_SUBTYPE_PCM
Definition: ksmedia.h:921
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KSPROPSETID_Connection
Definition: ks.h:346
#define KSDATAFORMAT_SPECIFIER_WAVEFORMATEX
Definition: ksmedia.h:931
smooth NULL
Definition: ftsmooth.c:416
unsigned long DWORD
Definition: ntddk_ex.h:95
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
#define KSDATAFORMAT_TYPE_AUDIO
Definition: ksmedia.h:883
_In_ DWORD Property
Definition: setupapi.h:1545
#define KSPROPERTY_TYPE_SET
Definition: dmksctrl.h:43

Referenced by PrimaryDirectSoundBuffer_SetFormat().

◆ SyncOverlappedDeviceIoControl()

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 at line 298 of file misc.c.

306 {
307  OVERLAPPED Overlapped;
308  BOOLEAN IoResult;
309  DWORD Transferred = 0;
310 
311  /* Overlapped I/O is done here - this is used for waiting for completion */
312  ZeroMemory(&Overlapped, sizeof(OVERLAPPED));
313  Overlapped.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
314 
315  if (!Overlapped.hEvent)
316  return GetLastError();
317 
318  /* Talk to the device */
319  IoResult = DeviceIoControl(Handle,
321  InBuffer,
322  InBufferSize,
323  OutBuffer,
325  BytesTransferred,
326  &Overlapped);
327 
328  /* If failure occurs, make sure it's not just due to the overlapped I/O */
329  if (!IoResult)
330  {
331  if ( GetLastError() != ERROR_IO_PENDING )
332  {
333  CloseHandle(Overlapped.hEvent);
334  return GetLastError();
335  }
336  }
337 
338  /* Wait for the I/O to complete */
339  IoResult = GetOverlappedResult(Handle,
340  &Overlapped,
341  &Transferred,
342  TRUE);
343 
344  /* Don't need this any more */
345  CloseHandle(Overlapped.hEvent);
346 
347  if (!IoResult)
348  return GetLastError();
349 
350  if ( BytesTransferred )
351  *BytesTransferred = Transferred;
352 
353  return ERROR_SUCCESS;
354 }
#define CreateEvent
Definition: winbase.h:3572
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG IoControlCode
Definition: fltkernel.h:1383
#define ERROR_SUCCESS
Definition: deptool.c:10
BOOL WINAPI GetOverlappedResult(IN HANDLE hFile, IN LPOVERLAPPED lpOverlapped, OUT LPDWORD lpNumberOfBytesTransferred, IN BOOL bWait)
Definition: iocompl.c:204
_In_ PIRP _In_ ULONG _In_ ULONG _In_ ULONG _In_ ULONG OutBufferSize
Definition: classpnp.h:429
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define ZeroMemory
Definition: winbase.h:1642
#define ERROR_IO_PENDING
Definition: dderror.h:15
HANDLE hEvent
Definition: winbase.h:792
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
_In_ HANDLE Handle
Definition: extypes.h:390
_In_ PIRP _In_ ULONG _In_ ULONG _In_ ULONG InBufferSize
Definition: classpnp.h:429
unsigned long DWORD
Definition: ntddk_ex.h:95
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

Variable Documentation

◆ dsound_hInstance

HINSTANCE dsound_hInstance

Definition at line 12 of file dsound.c.

Referenced by DllMain(), and LoadResourceString().

◆ RootInfo