ReactOS 0.4.15-dev-8419-g7f0e8a3
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
47{
48 return S_FALSE;
49}
50
53GetDeviceID(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
123WINAPI
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
167BOOL
168WINAPI
170 HINSTANCE hInstDLL,
171 DWORD fdwReason,
173{
174 switch (fdwReason)
175 {
177 dsound_hInstance = hInstDLL;
178#if 1
179 DPRINT("NumDevs %u\n", waveOutGetNumDevs());
181 {
182 DPRINT("EnumAudioDeviceInterfaces failed\n");
183 RootInfo = NULL;
184 }
185DPRINT1("EnumAudioDeviceInterfaces %p %u\n", RootInfo, waveOutGetNumDevs());
186#endif
188 break;
189 default:
190 break;
191 }
192
193 return TRUE;
194}
195
#define DPRINT1
Definition: precomp.h:8
#define UlongToHandle(ul)
Definition: basetsd.h:97
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_INVALIDARG
Definition: ddrawi.h:101
HRESULT CALLBACK NewDirectSound(IUnknown *pUnkOuter, REFIID riid, LPVOID *ppvObject)
Definition: directsound.c:449
IClassFactory * IClassFactory_fnConstructor(LPFNCREATEINSTANCE lpfnCI, PLONG pcRefDll, REFIID riidInst)
Definition: classfactory.c:125
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
HRESULT CALLBACK NewDirectSoundCapture(IUnknown *pUnkOuter, REFIID riid, LPVOID *ppvObject)
Definition: capture.c:284
HRESULT EnumAudioDeviceInterfaces(LPFILTERINFO *OutRootInfo)
Definition: devicelist.c:384
BOOL FindDeviceByMappedId(IN ULONG DeviceID, LPFILTERINFO *Filter, BOOL bPlayback)
Definition: devicelist.c:442
BOOL FindDeviceByGuid(LPCGUID pGuidSrc, LPFILTERINFO *Filter)
Definition: devicelist.c:470
static INTERFACE_TABLE InterfaceTable[]
Definition: dsound.c:15
BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved)
Definition: dsound.c:169
LPFILTERINFO RootInfo
Definition: dsound.c:13
HRESULT WINAPI DllCanUnloadNow()
Definition: dsound.c:46
HRESULT WINAPI GetDeviceID(LPCGUID pGuidSrc, LPGUID pGuidDest)
Definition: dsound.c:53
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
Definition: dsound.c:124
HINSTANCE dsound_hInstance
Definition: dsound.c:12
HRESULT CALLBACK NewKsPropertySet(IUnknown *pUnkOuter, REFIID riid, LPVOID *ppvObject)
Definition: property.c:244
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
LPFNCREATEINSTANCE lpfnCI
Definition: shellole.c:61
#define DS_OK
Definition: dsound.h:116
#define DSERR_INVALIDPARAM
Definition: dsound.h:121
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
_Must_inspect_result_ _In_opt_ PFLT_FILTER Filter
Definition: fltkernel.h:1801
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
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
#define ULONG_MAX
Definition: limits.h:44
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define GUID_NULL
Definition: ks.h:106
static IN DWORD IN LPVOID lpvReserved
#define DRVM_MAPPER_PREFERRED_GET
Definition: mmsys.h:39
UINT MMRESULT
Definition: mmsystem.h:962
#define WAVE_MAPPER
Definition: mmsystem.h:187
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
#define ASSERT(a)
Definition: mode.c:44
HRESULT hres
Definition: protocol.c:465
static LPOLESTR
Definition: stg_prop.c:27
unsigned int UINT
Definition: ndis.h:50
_Check_return_ HRESULT WINAPI StringFromIID(_In_ REFIID rclsid, _Outptr_ LPOLESTR *lplpsz)
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define REFIID
Definition: guiddef.h:118
#define REFCLSID
Definition: guiddef.h:117
#define DPRINT
Definition: sndvol32.h:73
const GUID * riid
Definition: precomp.h:26
uint32_t DWORD_PTR
Definition: typedefs.h:65
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ PCUNICODE_STRING DeviceID
Definition: wdfpdo.h:278
#define WINAPI
Definition: msvc.h:6
#define S_FALSE
Definition: winerror.h:2357
#define CLASS_E_CLASSNOTAVAILABLE
Definition: winerror.h:2663
UINT WINAPI waveOutGetNumDevs(void)
Definition: winmm.c:2137
UINT WINAPI waveInMessage(HWAVEIN hWaveIn, UINT uMessage, DWORD_PTR dwParam1, DWORD_PTR dwParam2)
Definition: winmm.c:2813
UINT WINAPI waveOutMessage(HWAVEOUT hWaveOut, UINT uMessage, DWORD_PTR dwParam1, DWORD_PTR dwParam2)
Definition: winmm.c:2538
_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
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170