source: branches/gcc-kmk/src/dsound/dsound.cpp@ 21692

Last change on this file since 21692 was 21692, checked in by dmik, 14 years ago

Normalize file case.

Change all uppercase filenames and extensions to lowercase (except well known cases like LICENSE.TXT and so on).

File size: 7.6 KB
Line 
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 CINTERFACE
23#include <dsound.h>
24
25#include "os2dsound.h"
26
27#include <misc.h>
28
29OS2IDirectSound *DS = NULL;
30
31extern "C" {
32
33//******************************************************************************
34//******************************************************************************
35HRESULT WIN32API OS2DirectSoundCreate(const GUID *lpGUID,
36 LPDIRECTSOUND * ppDS,
37 IUnknown *pUnkOuter)
38{
39 OS2IDirectSound *newsound;
40 HRESULT rc;
41
42 dprintf(("DSOUND:DirectSoundCreate %X %X %X\n", lpGUID, ppDS, pUnkOuter));
43
44 if (OS2IDirectSound::fDSExists) {
45 *ppDS = (LPDIRECTSOUND)DS;
46 DS->Vtbl.fnAddRef(DS);
47 return DS_OK;
48 }
49
50 newsound = new OS2IDirectSound(lpGUID);
51
52 if (newsound == NULL)
53 return DSERR_OUTOFMEMORY;
54
55 rc = newsound->GetLastError();
56 if(rc != DS_OK) {
57 *ppDS = NULL;
58 delete newsound;
59 }
60 else {
61 *ppDS = (LPDIRECTSOUND)newsound;
62 newsound->Vtbl.fnAddRef(newsound);
63 DS = newsound;
64 }
65 return rc;
66}
67
68//******************************************************************************
69//******************************************************************************
70HRESULT WIN32API OS2DirectSoundCaptureCreate(const GUID *lpGUID,
71 LPDIRECTSOUNDCAPTURE * ppDS,
72 IUnknown *pUnkOuter)
73{
74 return DSERR_OUTOFMEMORY;
75}
76
77//******************************************************************************
78//******************************************************************************
79HRESULT WIN32API OS2DirectSoundCaptureEnumerateA(LPDSENUMCALLBACKA lpCallback,
80 LPVOID lpContext)
81{
82 dprintf(("DSOUND:DirectSoundCaptureEnumerateA\n"));
83
84 lpCallback(NULL, "DART DirectSoundCapture for OS/2",
85 "DirectSoundCapture/2 v0.1", lpContext);
86 return DS_OK;
87}
88
89//******************************************************************************
90//******************************************************************************
91HRESULT WIN32API OS2DirectSoundCaptureEnumerateW(LPDSENUMCALLBACKW lpCallback,
92 LPVOID lpContext)
93{
94 dprintf(("DSOUND:DirectSoundCaptureEnumerateW\n"));
95
96 lpCallback(NULL, (LPWSTR)L"DART DirectSoundCapture for OS/2",
97 (LPWSTR)L"DirectSoundCapture/2 v0.1", lpContext);
98 return DS_OK;
99}
100
101//******************************************************************************
102//******************************************************************************
103HRESULT WIN32API OS2DirectSoundEnumerateA(LPDSENUMCALLBACKA lpCallback,
104 LPVOID lpContext)
105{
106 dprintf(("DSOUND:DirectSoundEnumerateA\n"));
107
108 // According to MSDN, the default sound device comes twice: first with a
109 // null GUID and second wth its real GUID
110
111 lpCallback(NULL,
112 "DART DirectSound for OS/2", "DirectSound/2 v0.5",
113 lpContext);
114
115 lpCallback((LPGUID)&GUID_DirectSound_DART,
116 "DART DirectSound for OS/2", "DirectSound/2 v0.5",
117 lpContext);
118
119 return DS_OK;
120}
121
122//******************************************************************************
123//******************************************************************************
124HRESULT WIN32API OS2DirectSoundEnumerateW(LPDSENUMCALLBACKW lpCallback,
125 LPVOID lpContext)
126{
127 dprintf(("DSOUND:DirectSoundEnumerateW\n"));
128
129 // According to MSDN, the default sound device comes twice: first with a
130 // null GUID and second wth its real GUID
131
132 lpCallback(NULL,
133 (LPWSTR)L"DART DirectSound for OS/2", (LPWSTR)L"DirectSound/2 v0.5",
134 lpContext);
135
136 lpCallback((LPGUID)&GUID_DirectSound_DART,
137 (LPWSTR)L"DART DirectSound for OS/2", (LPWSTR)L"DirectSound/2 v0.5",
138 lpContext);
139
140 return DS_OK;
141}
142
143//******************************************************************************
144//******************************************************************************
145
146
147/*******************************************************************************
148 * DirectSound ClassFactory
149 *
150 */
151
152typedef struct
153{
154 /* IUnknown fields */
155 ICOM_VTABLE(IClassFactory) *lpvtbl;
156 DWORD ref;
157} IClassFactoryImpl;
158
159static HRESULT WINAPI
160DSCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
161{
162 ICOM_THIS(IClassFactoryImpl,iface);
163 char buf[80];
164
165 if (HIWORD(riid))
166 WINE_StringFromCLSID(riid,buf);
167 else
168 sprintf(buf,"<guid-0x%04x>",LOWORD(riid));
169 dprintf(("DSOUND:DSCF_QueryInterface(%p)->(%s,%p),stub!\n",This,buf,ppobj));
170 return E_NOINTERFACE;
171}
172
173static ULONG WINAPI
174DSCF_AddRef(LPCLASSFACTORY iface)
175{
176 ICOM_THIS(IClassFactoryImpl,iface);
177 return ++(This->ref);
178}
179
180static ULONG WINAPI DSCF_Release(LPCLASSFACTORY iface)
181{
182 ICOM_THIS(IClassFactoryImpl,iface);
183 /* static class, won't be freed */
184 return --(This->ref);
185}
186
187static HRESULT WINAPI DSCF_CreateInstance( LPCLASSFACTORY iface,
188 LPUNKNOWN pOuter,
189 REFIID riid,
190 LPVOID *ppobj)
191{
192 ICOM_THIS(IClassFactoryImpl,iface);
193 LPGUID lpGUID;
194 lpGUID = (LPGUID) riid;
195
196 dprintf(("DSOUND:DSCF_CreateInstance\n"));
197 if(lpGUID && IsEqualGUID(lpGUID, &IID_IDirectSound)) {
198 return OS2DirectSoundCreate(lpGUID,(LPDIRECTSOUND*)ppobj,pOuter);
199 }
200 return E_NOINTERFACE;
201}
202
203static HRESULT WINAPI DSCF_LockServer(LPCLASSFACTORY iface,BOOL dolock)
204{
205 ICOM_THIS(IClassFactoryImpl,iface);
206 dprintf(("DSOUND:DSCF_LockServer(%p)->(%d),stub!\n",This,dolock));
207 return S_OK;
208}
209
210static ICOM_VTABLE(IClassFactory) DSCF_Vtbl =
211{
212 DSCF_QueryInterface,
213 DSCF_AddRef,
214 DSCF_Release,
215 DSCF_CreateInstance,
216 DSCF_LockServer
217};
218
219static IClassFactoryImpl DSOUND_CF = {&DSCF_Vtbl, 1 };
220
221
222HRESULT WINAPI DSOUNDDllGetClassObject( REFCLSID rclsid,
223 REFIID riid,
224 LPVOID *ppv)
225{
226 char buf[80],xbuf[80];
227
228 if (HIWORD(rclsid))
229 WINE_StringFromCLSID(rclsid,xbuf);
230 else
231 sprintf(xbuf,"<guid-0x%04x>",LOWORD(rclsid));
232 if (HIWORD(riid))
233 WINE_StringFromCLSID(riid,buf);
234 else
235 sprintf(buf,"<guid-0x%04x>",LOWORD(riid));
236 WINE_StringFromCLSID(riid,xbuf);
237
238 dprintf(("DSOUND:(%p,%p,%p)\n", xbuf, buf, ppv));
239 if (!memcmp(riid,&IID_IClassFactory,sizeof(IID_IClassFactory)))
240 {
241 *ppv = (LPVOID)&DSOUND_CF;
242 DSOUND_CF.lpvtbl->fnAddRef((IClassFactory*)&DSOUND_CF);
243 return S_OK;
244 }
245 dprintf(("DSOUND: (%p,%p,%p): no interface found.\n", xbuf, buf, ppv));
246 return E_NOINTERFACE;
247}
248
249
250/*******************************************************************************
251 * DllCanUnloadNow Determines whether the DLL is in use.
252 *
253 * RETURNS
254 * Success: S_OK
255 * Failure: S_FALSE
256 */
257HRESULT WINAPI DSOUNDDllCanUnloadNow(void)
258{
259 dprintf(("DSOUND:DllCanUnloadNow(void) stub\n"));
260 return S_FALSE;
261}//******************************************************************************
262}
Note: See TracBrowser for help on using the repository browser.