source: trunk/src/dsound/dsound.cpp

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

Merge branch gcc-kmk to trunk.

File size: 7.6 KB
RevLine 
[7431]1/* $Id: DSOUND.CPP,v 1.9 2001-11-22 16:08:12 sandervl Exp $ */
[97]2
[4]3/*
4 * DirectSound exported APIs
5 *
[3099]6 * Copyright 1998 Sander van Leeuwen
7 * Copyright 2000 Michal Necasek
[4]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>
[3099]18#include <stdio.h>
[4]19#include <string.h>
20
[1421]21#define INITGUID
[3099]22#define CINTERFACE
[4]23#include <dsound.h>
[3099]24
[1421]25#include "os2dsound.h"
[4]26
[1411]27#include <misc.h>
[4]28
[3099]29OS2IDirectSound *DS = NULL;
30
[5285]31extern "C" {
32
[4]33//******************************************************************************
34//******************************************************************************
35HRESULT WIN32API OS2DirectSoundCreate(const GUID *lpGUID,
36 LPDIRECTSOUND * ppDS,
[1411]37 IUnknown *pUnkOuter)
[4]38{
[3099]39 OS2IDirectSound *newsound;
40 HRESULT rc;
[4]41
[3099]42 dprintf(("DSOUND:DirectSoundCreate %X %X %X\n", lpGUID, ppDS, pUnkOuter));
[4]43
[3099]44 if (OS2IDirectSound::fDSExists) {
45 *ppDS = (LPDIRECTSOUND)DS;
[21479]46 DS->Vtbl.fnAddRef(DS);
[3099]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;
[21479]62 newsound->Vtbl.fnAddRef(newsound);
[3099]63 DS = newsound;
64 }
65 return rc;
[4]66}
[3099]67
[4]68//******************************************************************************
69//******************************************************************************
[3099]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//******************************************************************************
[4]103HRESULT WIN32API OS2DirectSoundEnumerateA(LPDSENUMCALLBACKA lpCallback,
104 LPVOID lpContext)
105{
[3099]106 dprintf(("DSOUND:DirectSoundEnumerateA\n"));
[4]107
[21571]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",
[3099]113 lpContext);
[21571]114
115 lpCallback((LPGUID)&GUID_DirectSound_DART,
116 "DART DirectSound for OS/2", "DirectSound/2 v0.5",
117 lpContext);
118
[3099]119 return DS_OK;
[4]120}
[3099]121
[4]122//******************************************************************************
123//******************************************************************************
[3099]124HRESULT WIN32API OS2DirectSoundEnumerateW(LPDSENUMCALLBACKW lpCallback,
125 LPVOID lpContext)
126{
127 dprintf(("DSOUND:DirectSoundEnumerateW\n"));
128
[21571]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",
[3099]134 lpContext);
[21571]135
136 lpCallback((LPGUID)&GUID_DirectSound_DART,
137 (LPWSTR)L"DART DirectSound for OS/2", (LPWSTR)L"DirectSound/2 v0.5",
138 lpContext);
139
[3099]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"));
[21479]197 if(lpGUID && IsEqualGUID(lpGUID, &IID_IDirectSound)) {
[3099]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
[7431]222HRESULT WINAPI DSOUNDDllGetClassObject( REFCLSID rclsid,
[3099]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;
[21479]242 DSOUND_CF.lpvtbl->fnAddRef((IClassFactory*)&DSOUND_CF);
[3099]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 */
[7431]257HRESULT WINAPI DSOUNDDllCanUnloadNow(void)
[3099]258{
259 dprintf(("DSOUND:DllCanUnloadNow(void) stub\n"));
260 return S_FALSE;
261}//******************************************************************************
[5285]262}
Note: See TracBrowser for help on using the repository browser.