1 | /* $Id: DSOUND.CPP,v 1.9 2001-11-22 16:08:12 sandervl Exp $ */
|
---|
2 |
|
---|
3 | /*
|
---|
4 | * DirectSound exported APIs
|
---|
5 | *
|
---|
6 | * Copyright 1998 Sander van Leeuwen
|
---|
7 | * Copyright 2000 Michal Necasek
|
---|
8 | *
|
---|
9 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
10 | *
|
---|
11 | */
|
---|
12 |
|
---|
13 | /*@Header***********************************************************************
|
---|
14 | * Header Files *
|
---|
15 | *******************************************************************************/
|
---|
16 | #include <os2win.h>
|
---|
17 | #include <stdlib.h>
|
---|
18 | #include <stdio.h>
|
---|
19 | #include <string.h>
|
---|
20 |
|
---|
21 | #define INITGUID
|
---|
22 | #define ICOM_CINTERFACE 1
|
---|
23 | #define CINTERFACE
|
---|
24 | #include <dsound.h>
|
---|
25 |
|
---|
26 | #include "os2dsound.h"
|
---|
27 |
|
---|
28 | #include <misc.h>
|
---|
29 |
|
---|
30 | OS2IDirectSound *DS = NULL;
|
---|
31 |
|
---|
32 | extern "C" {
|
---|
33 |
|
---|
34 | //******************************************************************************
|
---|
35 | //******************************************************************************
|
---|
36 | HRESULT WIN32API OS2DirectSoundCreate(const GUID *lpGUID,
|
---|
37 | LPDIRECTSOUND * ppDS,
|
---|
38 | IUnknown *pUnkOuter)
|
---|
39 | {
|
---|
40 | OS2IDirectSound *newsound;
|
---|
41 | HRESULT rc;
|
---|
42 |
|
---|
43 | dprintf(("DSOUND:DirectSoundCreate %X %X %X\n", lpGUID, ppDS, pUnkOuter));
|
---|
44 |
|
---|
45 | if (OS2IDirectSound::fDSExists) {
|
---|
46 | *ppDS = (LPDIRECTSOUND)DS;
|
---|
47 | DS->Vtbl.AddRef(DS);
|
---|
48 | return DS_OK;
|
---|
49 | }
|
---|
50 |
|
---|
51 | newsound = new OS2IDirectSound(lpGUID);
|
---|
52 |
|
---|
53 | if (newsound == NULL)
|
---|
54 | return DSERR_OUTOFMEMORY;
|
---|
55 |
|
---|
56 | rc = newsound->GetLastError();
|
---|
57 | if(rc != DS_OK) {
|
---|
58 | *ppDS = NULL;
|
---|
59 | delete newsound;
|
---|
60 | }
|
---|
61 | else {
|
---|
62 | *ppDS = (LPDIRECTSOUND)newsound;
|
---|
63 | newsound->Vtbl.AddRef(newsound);
|
---|
64 | DS = newsound;
|
---|
65 | }
|
---|
66 | return rc;
|
---|
67 | }
|
---|
68 |
|
---|
69 | //******************************************************************************
|
---|
70 | //******************************************************************************
|
---|
71 | HRESULT WIN32API OS2DirectSoundCaptureCreate(const GUID *lpGUID,
|
---|
72 | LPDIRECTSOUNDCAPTURE * ppDS,
|
---|
73 | IUnknown *pUnkOuter)
|
---|
74 | {
|
---|
75 | return DSERR_OUTOFMEMORY;
|
---|
76 | }
|
---|
77 |
|
---|
78 | //******************************************************************************
|
---|
79 | //******************************************************************************
|
---|
80 | HRESULT WIN32API OS2DirectSoundCaptureEnumerateA(LPDSENUMCALLBACKA lpCallback,
|
---|
81 | LPVOID lpContext)
|
---|
82 | {
|
---|
83 | dprintf(("DSOUND:DirectSoundCaptureEnumerateA\n"));
|
---|
84 |
|
---|
85 | lpCallback(NULL, "DART DirectSoundCapture for OS/2",
|
---|
86 | "DirectSoundCapture/2 v0.1", lpContext);
|
---|
87 | return DS_OK;
|
---|
88 | }
|
---|
89 |
|
---|
90 | //******************************************************************************
|
---|
91 | //******************************************************************************
|
---|
92 | HRESULT WIN32API OS2DirectSoundCaptureEnumerateW(LPDSENUMCALLBACKW lpCallback,
|
---|
93 | LPVOID lpContext)
|
---|
94 | {
|
---|
95 | dprintf(("DSOUND:DirectSoundCaptureEnumerateW\n"));
|
---|
96 |
|
---|
97 | lpCallback(NULL, (LPWSTR)L"DART DirectSoundCapture for OS/2",
|
---|
98 | (LPWSTR)L"DirectSoundCapture/2 v0.1", lpContext);
|
---|
99 | return DS_OK;
|
---|
100 | }
|
---|
101 |
|
---|
102 | //******************************************************************************
|
---|
103 | //******************************************************************************
|
---|
104 | HRESULT WIN32API OS2DirectSoundEnumerateA(LPDSENUMCALLBACKA lpCallback,
|
---|
105 | LPVOID lpContext)
|
---|
106 | {
|
---|
107 | dprintf(("DSOUND:DirectSoundEnumerateA\n"));
|
---|
108 |
|
---|
109 | lpCallback(NULL, "DART DirectSound for OS/2", "DirectSound/2 v0.5",
|
---|
110 | lpContext);
|
---|
111 | return DS_OK;
|
---|
112 | }
|
---|
113 |
|
---|
114 | //******************************************************************************
|
---|
115 | //******************************************************************************
|
---|
116 | HRESULT WIN32API OS2DirectSoundEnumerateW(LPDSENUMCALLBACKW lpCallback,
|
---|
117 | LPVOID lpContext)
|
---|
118 | {
|
---|
119 | dprintf(("DSOUND:DirectSoundEnumerateW\n"));
|
---|
120 |
|
---|
121 | lpCallback(NULL, (LPWSTR)L"DART DirectSound for OS/2", (LPWSTR)L"DirectSound/2 v0.5",
|
---|
122 | lpContext);
|
---|
123 | return DS_OK;
|
---|
124 | }
|
---|
125 |
|
---|
126 | //******************************************************************************
|
---|
127 | //******************************************************************************
|
---|
128 |
|
---|
129 |
|
---|
130 | /*******************************************************************************
|
---|
131 | * DirectSound ClassFactory
|
---|
132 | *
|
---|
133 | */
|
---|
134 |
|
---|
135 | typedef struct
|
---|
136 | {
|
---|
137 | /* IUnknown fields */
|
---|
138 | ICOM_VTABLE(IClassFactory) *lpvtbl;
|
---|
139 | DWORD ref;
|
---|
140 | } IClassFactoryImpl;
|
---|
141 |
|
---|
142 | static HRESULT WINAPI
|
---|
143 | DSCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
|
---|
144 | {
|
---|
145 | ICOM_THIS(IClassFactoryImpl,iface);
|
---|
146 | char buf[80];
|
---|
147 |
|
---|
148 | if (HIWORD(riid))
|
---|
149 | WINE_StringFromCLSID(riid,buf);
|
---|
150 | else
|
---|
151 | sprintf(buf,"<guid-0x%04x>",LOWORD(riid));
|
---|
152 | dprintf(("DSOUND:DSCF_QueryInterface(%p)->(%s,%p),stub!\n",This,buf,ppobj));
|
---|
153 | return E_NOINTERFACE;
|
---|
154 | }
|
---|
155 |
|
---|
156 | static ULONG WINAPI
|
---|
157 | DSCF_AddRef(LPCLASSFACTORY iface)
|
---|
158 | {
|
---|
159 | ICOM_THIS(IClassFactoryImpl,iface);
|
---|
160 | return ++(This->ref);
|
---|
161 | }
|
---|
162 |
|
---|
163 | static ULONG WINAPI DSCF_Release(LPCLASSFACTORY iface)
|
---|
164 | {
|
---|
165 | ICOM_THIS(IClassFactoryImpl,iface);
|
---|
166 | /* static class, won't be freed */
|
---|
167 | return --(This->ref);
|
---|
168 | }
|
---|
169 |
|
---|
170 | static HRESULT WINAPI DSCF_CreateInstance( LPCLASSFACTORY iface,
|
---|
171 | LPUNKNOWN pOuter,
|
---|
172 | REFIID riid,
|
---|
173 | LPVOID *ppobj)
|
---|
174 | {
|
---|
175 | ICOM_THIS(IClassFactoryImpl,iface);
|
---|
176 | LPGUID lpGUID;
|
---|
177 | lpGUID = (LPGUID) riid;
|
---|
178 |
|
---|
179 | dprintf(("DSOUND:DSCF_CreateInstance\n"));
|
---|
180 | if( lpGUID && (*lpGUID == IID_IDirectSound )) {
|
---|
181 | return OS2DirectSoundCreate(lpGUID,(LPDIRECTSOUND*)ppobj,pOuter);
|
---|
182 | }
|
---|
183 | return E_NOINTERFACE;
|
---|
184 | }
|
---|
185 |
|
---|
186 | static HRESULT WINAPI DSCF_LockServer(LPCLASSFACTORY iface,BOOL dolock)
|
---|
187 | {
|
---|
188 | ICOM_THIS(IClassFactoryImpl,iface);
|
---|
189 | dprintf(("DSOUND:DSCF_LockServer(%p)->(%d),stub!\n",This,dolock));
|
---|
190 | return S_OK;
|
---|
191 | }
|
---|
192 |
|
---|
193 | static ICOM_VTABLE(IClassFactory) DSCF_Vtbl =
|
---|
194 | {
|
---|
195 | DSCF_QueryInterface,
|
---|
196 | DSCF_AddRef,
|
---|
197 | DSCF_Release,
|
---|
198 | DSCF_CreateInstance,
|
---|
199 | DSCF_LockServer
|
---|
200 | };
|
---|
201 |
|
---|
202 | static IClassFactoryImpl DSOUND_CF = {&DSCF_Vtbl, 1 };
|
---|
203 |
|
---|
204 |
|
---|
205 | HRESULT WINAPI DSOUNDDllGetClassObject( REFCLSID rclsid,
|
---|
206 | REFIID riid,
|
---|
207 | LPVOID *ppv)
|
---|
208 | {
|
---|
209 | char buf[80],xbuf[80];
|
---|
210 |
|
---|
211 | if (HIWORD(rclsid))
|
---|
212 | WINE_StringFromCLSID(rclsid,xbuf);
|
---|
213 | else
|
---|
214 | sprintf(xbuf,"<guid-0x%04x>",LOWORD(rclsid));
|
---|
215 | if (HIWORD(riid))
|
---|
216 | WINE_StringFromCLSID(riid,buf);
|
---|
217 | else
|
---|
218 | sprintf(buf,"<guid-0x%04x>",LOWORD(riid));
|
---|
219 | WINE_StringFromCLSID(riid,xbuf);
|
---|
220 |
|
---|
221 | dprintf(("DSOUND:(%p,%p,%p)\n", xbuf, buf, ppv));
|
---|
222 | if (!memcmp(riid,&IID_IClassFactory,sizeof(IID_IClassFactory)))
|
---|
223 | {
|
---|
224 | *ppv = (LPVOID)&DSOUND_CF;
|
---|
225 | DSOUND_CF.lpvtbl->AddRef((IClassFactory*)&DSOUND_CF);
|
---|
226 | return S_OK;
|
---|
227 | }
|
---|
228 | dprintf(("DSOUND: (%p,%p,%p): no interface found.\n", xbuf, buf, ppv));
|
---|
229 | return E_NOINTERFACE;
|
---|
230 | }
|
---|
231 |
|
---|
232 |
|
---|
233 | /*******************************************************************************
|
---|
234 | * DllCanUnloadNow Determines whether the DLL is in use.
|
---|
235 | *
|
---|
236 | * RETURNS
|
---|
237 | * Success: S_OK
|
---|
238 | * Failure: S_FALSE
|
---|
239 | */
|
---|
240 | HRESULT WINAPI DSOUNDDllCanUnloadNow(void)
|
---|
241 | {
|
---|
242 | dprintf(("DSOUND:DllCanUnloadNow(void) stub\n"));
|
---|
243 | return S_FALSE;
|
---|
244 | }//******************************************************************************
|
---|
245 | }
|
---|