ReactOS 0.4.16-dev-297-gc569aee
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 <ks.h>
#include <ksmedia.h>
#include <limits.h>
#include <stdio.h>
#include "resource.h"
#include <debug.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 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;
r l[0]
Definition: byte_order.h:168
GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint GLdouble GLdouble w2
Definition: glext.h:8308
GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint GLdouble w1
Definition: glext.h:8308
const GUID * guid
static CRYPT_DATA_BLOB b4
Definition: msg.c:2284
static CRYPT_DATA_BLOB b3[]
Definition: msg.c:592
static CRYPT_DATA_BLOB b2[]
Definition: msg.c:582
static CRYPT_DATA_BLOB b1[]
Definition: msg.c:573

Definition at line 51 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.

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 57 of file precomp.h.

58{
59 PIN_TYPE_NONE = 0,
PIN_TYPE
Definition: precomp.h:58
@ PIN_TYPE_PLAYBACK
Definition: precomp.h:60
@ PIN_TYPE_RECORDING
Definition: precomp.h:61
@ PIN_TYPE_NONE
Definition: precomp.h:59

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{
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 */
578 return TRUE;
579 }
580 }
581 AudioRange = (PKSDATARANGE_AUDIO)((PUCHAR)AudioRange + AudioRange->DataRange.FormatSize);
582 }
583
584 /* free buffer */
586 return FALSE;
587}
#define UNIMPLEMENTED
Definition: ntoskrnl.c:15
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
DWORD GetFilterPinDataRanges(IN HANDLE hFilter, IN ULONG PinId, IN OUT PKSMULTIPLE_ITEM *OutMultipleItem)
Definition: misc.c:461
DWORD OpenPin(HANDLE hFilter, ULONG PinId, LPWAVEFORMATEX WaveFormatEx, PHANDLE hPin, BOOL bLoop)
Definition: misc.c:212
#define GetProcessHeap()
Definition: compat.h:736
#define HeapFree(x, y, z)
Definition: compat.h:735
unsigned long DWORD
Definition: ntddk_ex.h:95
struct KSDATARANGE_AUDIO * PKSDATARANGE_AUDIO
int nChannels
Definition: pcmconverter.c:95
#define DPRINT
Definition: sndvol32.h:73
ULONG MaximumChannels
Definition: ksmedia.h:680
ULONG MinimumBitsPerSample
Definition: ksmedia.h:681
ULONG MaximumBitsPerSample
Definition: ksmedia.h:682
ULONG MaximumSampleFrequency
Definition: ksmedia.h:684
KSDATARANGE DataRange
Definition: ksmedia.h:679
ULONG MinimumSampleFrequency
Definition: ksmedia.h:683
unsigned char * PUCHAR
Definition: typedefs.h:53
_In_ WDFCOLLECTION _In_ WDFOBJECT Item
#define CopyMemory
Definition: winbase.h:1735

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)
struct CDirectSoundNotifyImpl * LPCDirectSoundNotifyImpl
struct KSEVENTDATA::@3015::@3017 EventHandle
PLOOPEDSTREAMING_POSITION_EVENT_DATA Notify
Definition: notify.c:16
DWORD NotifyCount
Definition: notify.c:15
struct tagNOTIFYEVENT * lpNext
Definition: notify.c:17
static COORD Position
Definition: mouse.c:34
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
_In_ WDFCOLLECTION _In_ ULONG Index

Referenced by MixerThreadRoutine().

◆ EnumAudioDeviceInterfaces()

HRESULT EnumAudioDeviceInterfaces ( LPFILTERINFO OutRootInfo)

Definition at line 384 of file devicelist.c.

386{
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 DPRINT1
Definition: precomp.h:8
#define E_FAIL
Definition: ddrawi.h:102
HRESULT EnumerateAudioFilter(LPFILTERINFO CurInfo, OUT PULONG WaveInCount, OUT PULONG WaveOutCount)
Definition: devicelist.c:315
DWORD OpenDeviceList(IN LPGUID InterfaceGuid, OUT HDEVINFO *OutHandle)
Definition: devicelist.c:33
BOOL GetDeviceListInterfaces(HDEVINFO DeviceHandle, IN LPGUID InterfaceGuid, LPFILTERINFO *OutPath)
Definition: devicelist.c:65
BOOL CloseDeviceList(HDEVINFO Handle)
Definition: devicelist.c:58
Status
Definition: gdiplustypes.h:25
#define S_OK
Definition: intsafe.h:52
#define STATIC_KSCATEGORY_AUDIO
Definition: ksmedia.h:169
HWND hList
Definition: livecd.c:10
#define ASSERT(a)
Definition: mode.c:44
struct tagFILTERINFO * lpNext
Definition: precomp.h:48
uint32_t ULONG
Definition: typedefs.h:59
#define S_FALSE
Definition: winerror.h:2357

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}
LPFILTERINFO RootInfo
Definition: dsound.c:13
_Must_inspect_result_ _In_opt_ PFLT_FILTER Filter
Definition: fltkernel.h:1801
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
GUID DeviceGuid[2]
Definition: precomp.h:45

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}
ULONG MappedId[2]
Definition: precomp.h:46
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ PCUNICODE_STRING DeviceID
Definition: wdfpdo.h:278

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}
const GUID KSPROPSETID_Pin
Definition: misc.c:12
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 KSPROPERTY_TYPE_GET
Definition: dmksctrl.h:42
#define IOCTL_KS_PROPERTY
Definition: ks.h:127
@ KSPROPERTY_PIN_COMMUNICATION
Definition: ks.h:632
KSPIN_COMMUNICATION
Definition: ks.h:1253
Definition: ks.h:642
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{
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}
IN PDCB IN VBO IN ULONG IN BOOLEAN Pin
Definition: fatprocs.h:428
@ KSPROPERTY_PIN_CTYPES
Definition: ks.h:626
ULONG Flags
Definition: ntfs.h:536

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}
DataFlow
@ KSPROPERTY_PIN_DATAFLOW
Definition: ks.h:627
KSPIN_DATAFLOW
Definition: ks.h:1248

Referenced by FindAudioFilterPins().

◆ GetPinIdFromFilter()

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

Definition at line 13 of file devicelist.c.

17{
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}
#define ULONG_MAX
Definition: intsafe.h:155
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101

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}
#define InterlockedIncrement
Definition: armddk.h:53
static const IClassFactoryVtbl dclfvt
Definition: classfactory.c:114
LPFNCREATEINSTANCE lpfnCI
Definition: shellole.c:61
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426
LPFNCREATEINSTANCE lpfnCI
Definition: classfactory.c:18
const IID * riidInst
Definition: classfactory.c:19
const IClassFactoryVtbl * lpVtbl
Definition: classfactory.c:15

◆ 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}
const GUID IID_IUnknown
#define E_INVALIDARG
Definition: ddrawi.h:101
static IDirectSound8Vtbl vt_DirectSound8
Definition: directsound.c:380
#define HeapAlloc
Definition: compat.h:733
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define DSERR_OUTOFMEMORY
Definition: dsound.h:125
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
REFIID riid
Definition: atlbase.h:39
static LPOLESTR
Definition: stg_prop.c:27
#define LPVOID
Definition: nt_native.h:45
_Check_return_ HRESULT WINAPI StringFromIID(_In_ REFIID rclsid, _Outptr_ LPOLESTR *lplpsz)
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
_In_ void _In_ PCCERT_CONTEXT _In_opt_ LPFILETIME _In_ DWORD _In_ DWORD _Outptr_opt_ void ** ppvObject
Definition: wincrypt.h:6082
#define E_NOINTERFACE
Definition: winerror.h:2364

◆ 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}
static IDirectSoundCaptureVtbl vt_DirectSoundCapture
Definition: capture.c:225
#define IID_IDirectSoundCapture8
Definition: dsound.h:93

◆ 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
819 return DS_OK;
820}
static IDirectSoundCaptureBuffer8Vtbl vt_DirectSoundCaptureBuffer8
ULONG GetPinIdFromFilter(LPFILTERINFO Filter, BOOL bCapture, ULONG Offset)
Definition: devicelist.c:13
BOOL CreateCompatiblePin(IN HANDLE hFilter, IN DWORD PinId, IN BOOL bLoop, IN LPWAVEFORMATEX WaveFormatEx, OUT LPWAVEFORMATEX WaveFormatOut, OUT PHANDLE hPin)
Definition: misc.c:517
#define CloseHandle
Definition: compat.h:739
struct IDirectSoundCaptureBuffer8 * LPDIRECTSOUNDCAPTUREBUFFER8
Definition: dsound.h:100
#define DS_OK
Definition: dsound.h:116
#define DSERR_GENERIC
Definition: dsound.h:123
@ KSSTATE_STOP
Definition: ks.h:1215
_In_ UCHAR _In_ ULONG _Out_ PUCHAR _Outptr_result_bytebuffer_ OutBufferLength PVOID * OutBuffer
Definition: scsi.h:4071
DWORD dwBufferBytes
Definition: dsound.h:359
LPWAVEFORMATEX lpwfxFormat
Definition: dsound.h:361
WORD cbSize
Definition: mmreg.h:84
WORD nChannels
Definition: mmreg.h:79
WORD wBitsPerSample
Definition: mmreg.h:83
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
_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:409

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}
#define BufferSize
Definition: mmc.h:75
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}
const GUID IID_IKsPropertySet
Definition: controlnode.cpp:13
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static IKsPropertySetVtbl vt_KsPropertySet
Definition: property.c:230

◆ 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
804 return DS_OK;
805}
#define WAVE_FORMAT_PCM
Definition: constants.h:425
#define DSBPAN_CENTER
Definition: dsound.h:227
#define DSBVOLUME_MAX
Definition: dsound.h:229
struct IDirectSoundBuffer8 * LPDIRECTSOUNDBUFFER8
Definition: dsound.h:79
static IDirectSoundBuffer8Vtbl vt_DirectSoundBuffer8
Definition: primary.c:555
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:751
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176

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
670 return DS_OK;
671}
#define FillMemory(BUF, SIZ, MASK)
Definition: strucsup.c:31
static IDirectSoundBuffer8Vtbl vt_DirectSoundBuffer8
Definition: secondary.c:579
DWORD dwFlags
Definition: dsound.h:289
DWORD dwBufferBytes
Definition: dsound.h:290
LPWAVEFORMATEX lpwfxFormat
Definition: dsound.h:292
DWORD nSamplesPerSec
Definition: mmreg.h:80

Referenced by IDirectSound8_fnCreateSoundBuffer().

◆ OpenFilter()

DWORD OpenFilter ( IN LPCWSTR  lpFileName,
IN PHANDLE  OutHandle 
)

Definition at line 277 of file misc.c.

280{
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 OPEN_EXISTING
Definition: compat.h:775
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define GENERIC_READ
Definition: compat.h:135
#define CreateFileW
Definition: compat.h:741
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
ULONG Handle
Definition: gdb_input.c:15
#define FILE_FLAG_OVERLAPPED
Definition: disk.h:46
#define GENERIC_WRITE
Definition: nt_native.h:90
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
_In_ LPCSTR lpFileName
Definition: winbase.h:3096

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{
220 PKSPIN_CONNECT PinConnect;
222
223 /* calculate request size */
224 Size = sizeof(KSPIN_CONNECT) + sizeof(KSDATAFORMAT_WAVEFORMATEX);
225
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}
#define KSPRIORITY_NORMAL
Definition: ks.h:1386
#define KSMEDIUM_TYPE_ANYINSTANCE
Definition: ks.h:301
#define KSMEDIUMSETID_Standard
Definition: ks.h:306
@ KSINTERFACE_STANDARD_STREAMING
Definition: ks.h:283
@ KSINTERFACE_STANDARD_LOOPED_STREAMING
Definition: ks.h:284
#define KSINTERFACESETID_Standard
Definition: ks.h:280
struct KSDATAFORMAT_WAVEFORMATEX * PKSDATAFORMAT_WAVEFORMATEX
#define KSDATAFORMAT_SUBTYPE_PCM
Definition: ksmedia.h:1021
#define KSDATAFORMAT_TYPE_AUDIO
Definition: ksmedia.h:983
#define KSDATAFORMAT_SPECIFIER_WAVEFORMATEX
Definition: ksmedia.h:1031
KSDDKAPI DWORD NTAPI KsCreatePin(HANDLE FilterHandle, PKSPIN_CONNECT Connect, ACCESS_MASK DesiredAccess, PHANDLE ConnectionHandle)
Definition: ksuser.c:192
ULONG Id
Definition: dmksctrl.h:77
ULONG Flags
Definition: dmksctrl.h:78
GUID Set
Definition: dmksctrl.h:76
ULONG PinId
Definition: ks.h:2603
KSPIN_MEDIUM Medium
Definition: ks.h:2602
KSPRIORITY Priority
Definition: ks.h:2605
KSPIN_INTERFACE Interface
Definition: ks.h:2601
HANDLE PinToHandle
Definition: ks.h:2604
ULONG PriorityClass
Definition: ks.h:1391
ULONG PrioritySubClass
Definition: ks.h:1392
WORD nBlockAlign
Definition: mmreg.h:82
DWORD nAvgBytesPerSec
Definition: mmreg.h:81
WORD wFormatTag
Definition: mmreg.h:78
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533

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}
static USHORT USHORT * NewLength
Definition: bufpool.h:45
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG _Out_ PULONG ResultLength
Definition: wdfdevice.h:3776
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3771
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesWritten
Definition: wdfiotarget.h:960
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesRead
Definition: wdfiotarget.h:870

Referenced by MixerThreadRoutine().

◆ PrimaryDirectSoundBuffer_AcquireLock()

VOID PrimaryDirectSoundBuffer_AcquireLock ( LPDIRECTSOUNDBUFFER8  iface)

Definition at line 746 of file primary.c.

748{
750
752
753
754}
struct CDirectSoundBuffer * LPCDirectSoundBuffer
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)

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{
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 DSERR_UNSUPPORTED
Definition: dsound.h:127
@ KSPROPERTY_AUDIO_POSITION
Definition: ksmedia.h:1058
#define KSPROPSETID_Audio
Definition: ksmedia.h:1051
if(dx< 0)
Definition: linetemp.h:194
#define DWORD
Definition: nt_native.h:44
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547

Referenced by SecondaryDirectSoundBuffer8Impl_fnGetCurrentPosition().

◆ PrimaryDirectSoundBuffer_ReleaseLock()

VOID PrimaryDirectSoundBuffer_ReleaseLock ( LPDIRECTSOUNDBUFFER8  iface)

Definition at line 757 of file primary.c.

759{
761
763
764}
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}
BOOL SetPinFormat(IN HANDLE hPin, IN LPWAVEFORMATEX WaveFormatEx)
Definition: misc.c:77
#define DSERR_INVALIDPARAM
Definition: dsound.h:121

Referenced by SecondaryDirectSoundBuffer8Impl_fnPlay().

◆ PrimaryDirectSoundBuffer_SetState()

VOID PrimaryDirectSoundBuffer_SetState ( LPDIRECTSOUNDBUFFER8  iface,
KSSTATE  State 
)

Definition at line 621 of file primary.c.

624{
628
629 if (This->State == State)
630 return;
631
635
637 if (Result == ERROR_SUCCESS)
638 {
639 This->State = State;
640 }
641}
#define KSPROPERTY_TYPE_SET
Definition: dmksctrl.h:43
@ KSPROPERTY_CONNECTION_STATE
Definition: ks.h:349
KSSTATE
Definition: ks.h:1214
#define KSPROPSETID_Connection
Definition: ks.h:346
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_SEND_OPTIONS _In_ PWDF_USB_CONTROL_SETUP_PACKET _In_opt_ PWDF_MEMORY_DESCRIPTOR _Out_opt_ PULONG BytesTransferred
Definition: wdfusb.h:1342

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{
594 OVERLAPPED Overlapped;
595
597
598 ZeroMemory(&Overlapped, sizeof(OVERLAPPED));
599 Overlapped.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
600
601
602 ASSERT(This->hPin);
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
613
614 if (Result != ERROR_SUCCESS)
615 return 0;
616
617 return BytesTransferred;
618}
Definition: Header.h:9
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 IOCTL_KS_WRITE_STREAM
Definition: ks.h:139
HANDLE hEvent
Definition: winbase.h:845
#define ZeroMemory
Definition: winbase.h:1737
#define CreateEvent
Definition: winbase.h:3773

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}
@ KSPROPERTY_CONNECTION_DATAFORMAT
Definition: ks.h:351

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,
323 OutBuffer,
326 &Overlapped);
327
328 /* If failure occurs, make sure it's not just due to the overlapped I/O */
329 if (!IoResult)
330 {
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}
unsigned char BOOLEAN
#define ERROR_IO_PENDING
Definition: dderror.h:15
BOOL WINAPI GetOverlappedResult(IN HANDLE hFile, IN LPOVERLAPPED lpOverlapped, OUT LPDWORD lpNumberOfBytesTransferred, IN BOOL bWait)
Definition: iocompl.c:221
_In_ WDFREQUEST _In_ size_t _In_ size_t _In_ ULONG IoControlCode
Definition: wdfio.h:325
_In_ ULONG OutBufferSize
Definition: wdfwmi.h:87
_In_ ULONG InBufferSize
Definition: wdfwmi.h:106

Variable Documentation

◆ dsound_hInstance

HINSTANCE dsound_hInstance
extern

Definition at line 12 of file dsound.c.

Referenced by DllMain(), and LoadResourceString().

◆ RootInfo