ReactOS  0.4.14-dev-608-gd495a4f
dsound.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS Configuration of network devices
4  * FILE: dll/directx/dsound_new/dsound.c
5  * PURPOSE: Handles DSound initialization
6  *
7  * PROGRAMMERS: Johannes Anderwald (johannes.anderwald@reactos.org)
8  */
9 
10 #include "precomp.h"
11 
14 
16 {
17  {
18  &CLSID_DirectSoundPrivate,
20  },
21  {
22  &CLSID_DirectSoundCapture,
24  },
25  {
26  &CLSID_DirectSoundCapture8,
28  },
29  {
30  &CLSID_DirectSound,
32  },
33  {
34  &CLSID_DirectSound8,
36  },
37  {
38  NULL,
39  NULL
40  }
41 };
42 
43 
44 HRESULT
45 WINAPI
47 {
48  return S_FALSE;
49 }
50 
51 HRESULT
52 WINAPI
53 GetDeviceID(LPCGUID pGuidSrc, LPGUID pGuidDest)
54 {
58 
59  if (!pGuidSrc || !pGuidDest)
60  {
61  /* invalid param */
62  return DSERR_INVALIDPARAM;
63  }
64 
65  /* sanity check */
66  ASSERT(!IsEqualGUID(pGuidSrc, &GUID_NULL));
67 
68  if (IsEqualGUID(&DSDEVID_DefaultPlayback, pGuidSrc) ||
69  IsEqualGUID(&DSDEVID_DefaultVoicePlayback, pGuidSrc))
70  {
73  {
74  /* hack */
75  DPRINT1("Failed to get DRVM_MAPPER_PREFERRED_GET, using device 0\n");
76  DeviceID = 0;
77  }
78 
80  {
81  /* device not found */
82  return DSERR_INVALIDPARAM;
83  }
84 
85  /* copy device guid */
86  RtlMoveMemory(pGuidDest, &Filter->DeviceGuid[1], sizeof(GUID));
87  return DS_OK;
88  }
89  else if (IsEqualGUID(&DSDEVID_DefaultCapture, pGuidSrc) ||
90  IsEqualGUID(&DSDEVID_DefaultVoiceCapture, pGuidSrc))
91  {
94  {
95  /* hack */
96  DPRINT1("Failed to get DRVM_MAPPER_PREFERRED_GET, for record using device 0\n");
97  DeviceID = 0;
98  }
99 
101  {
102  /* device not found */
103  return DSERR_INVALIDPARAM;
104  }
105 
106  /* copy device guid */
107  RtlMoveMemory(pGuidDest, &Filter->DeviceGuid[0], sizeof(GUID));
108  return DS_OK;
109  }
110 
111  if (!FindDeviceByGuid(pGuidSrc, &Filter))
112  {
113  /* unknown guid */
114  return DSERR_INVALIDPARAM;
115  }
116 
117  /* done */
118  return DS_OK;
119 }
120 
121 
122 HRESULT
123 WINAPI
125  REFCLSID rclsid,
126  REFIID riid,
127  LPVOID* ppv)
128 {
129  LPOLESTR pStr, pStr2;
130  UINT i;
132  IClassFactory * pcf = NULL;
133 
134  if (!ppv)
135  return E_INVALIDARG;
136 
137  *ppv = NULL;
138 
139  for (i = 0; InterfaceTable[i].riid; i++)
140  {
141  if (IsEqualIID(InterfaceTable[i].riid, rclsid))
142  {
144  break;
145  }
146  }
147 
148  if (!pcf)
149  {
150  StringFromIID(rclsid, &pStr);
151  StringFromIID(riid, &pStr2);
152  DPRINT("No Class Available for %ws IID %ws\n", pStr, pStr2);
153  CoTaskMemFree(pStr);
154  CoTaskMemFree(pStr2);
155  //ASSERT(0);
157  }
158 
159  hres = IClassFactory_QueryInterface(pcf, riid, ppv);
160  IClassFactory_Release(pcf);
161 
162  return hres;
163 }
164 
165 
166 
167 BOOL
168 WINAPI
170  HINSTANCE hInstDLL,
171  DWORD fdwReason,
173 {
174  switch (fdwReason)
175  {
176  case DLL_PROCESS_ATTACH:
177  dsound_hInstance = hInstDLL;
178 #if 1
179  DPRINT("NumDevs %u\n", waveOutGetNumDevs());
181  {
182  DPRINT("EnumAudioDeviceInterfaces failed\n");
183  RootInfo = NULL;
184  }
185 DPRINT1("EnumAudioDeviceInterfaces %p %u\n", RootInfo, waveOutGetNumDevs());
186 #endif
188  break;
189  default:
190  break;
191  }
192 
193  return TRUE;
194 }
195 
HRESULT EnumAudioDeviceInterfaces(LPFILTERINFO *OutRootInfo)
Definition: devicelist.c:384
#define REFIID
Definition: guiddef.h:118
#define TRUE
Definition: types.h:120
HRESULT WINAPI GetDeviceID(LPCGUID pGuidSrc, LPGUID pGuidDest)
Definition: dsound.c:53
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:420
BOOL FindDeviceByGuid(LPCGUID pGuidSrc, LPFILTERINFO *Filter)
Definition: devicelist.c:470
#define DRVM_MAPPER_PREFERRED_GET
Definition: mmsys.h:37
UINT WINAPI waveOutMessage(HWAVEOUT hWaveOut, UINT uMessage, DWORD_PTR dwParam1, DWORD_PTR dwParam2)
Definition: winmm.c:2541
REFIID riid
Definition: precomp.h:44
#define REFCLSID
Definition: guiddef.h:117
_In_ USHORT DeviceID
Definition: iotypes.h:860
REFIID LPVOID * ppv
Definition: atlbase.h:39
LPFNCREATEINSTANCE lpfnCI
Definition: shellole.c:61
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
UINT MMRESULT
Definition: mmsystem.h:962
#define DLL_PROCESS_ATTACH
Definition: compat.h:120
static LPOLESTR
Definition: stg_prop.c:27
#define CLASS_E_CLASSNOTAVAILABLE
Definition: winerror.h:2663
static IN DWORD IN LPVOID lpvReserved
UINT WINAPI waveInMessage(HWAVEIN hWaveIn, UINT uMessage, DWORD_PTR dwParam1, DWORD_PTR dwParam2)
Definition: winmm.c:2816
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
const GUID * riid
Definition: precomp.h:26
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define DSERR_INVALIDPARAM
Definition: dsound.h:121
unsigned int BOOL
Definition: ntddk_ex.h:94
_Must_inspect_result_ _In_opt_ PFLT_FILTER Filter
Definition: fltkernel.h:1802
BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved)
Definition: dsound.c:169
#define S_FALSE
Definition: winerror.h:2357
#define E_INVALIDARG
Definition: ddrawi.h:101
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
UINT WINAPI waveOutGetNumDevs(void)
Definition: winmm.c:2140
_Check_return_ HRESULT WINAPI StringFromIID(_In_ REFIID rclsid, _Outptr_ LPOLESTR *lplpsz)
#define DS_OK
Definition: dsound.h:116
HRESULT hres
Definition: protocol.c:465
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
#define WAVE_MAPPER
Definition: mmsystem.h:187
LONG HRESULT
Definition: typedefs.h:77
#define UlongToHandle(ul)
Definition: basetsd.h:97
#define WINAPI
Definition: msvc.h:6
unsigned long DWORD
Definition: ntddk_ex.h:95
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define GUID_NULL
Definition: ks.h:106
HRESULT CALLBACK NewDirectSound(IUnknown *pUnkOuter, REFIID riid, LPVOID *ppvObject)
Definition: directsound.c:449
uint32_t DWORD_PTR
Definition: typedefs.h:63
IClassFactory * IClassFactory_fnConstructor(LPFNCREATEINSTANCE lpfnCI, PLONG pcRefDll, REFIID riidInst)
Definition: classfactory.c:125
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
Definition: dsound.c:124
LPFILTERINFO RootInfo
Definition: dsound.c:13
#define S_OK
Definition: intsafe.h:59
HINSTANCE dsound_hInstance
Definition: dsound.c:12
static INTERFACE_TABLE InterfaceTable[]
Definition: dsound.c:15
HRESULT CALLBACK NewKsPropertySet(IUnknown *pUnkOuter, REFIID riid, LPVOID *ppvObject)
Definition: property.c:244
unsigned int UINT
Definition: ndis.h:50
HRESULT WINAPI DllCanUnloadNow()
Definition: dsound.c:46
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
HRESULT CALLBACK NewDirectSoundCapture(IUnknown *pUnkOuter, REFIID riid, LPVOID *ppvObject)
Definition: capture.c:284
BOOL FindDeviceByMappedId(IN ULONG DeviceID, LPFILTERINFO *Filter, BOOL bPlayback)
Definition: devicelist.c:442
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define ULONG_MAX
Definition: limits.h:44