| 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 |
|
|---|
| 29 | OS2IDirectSound *DS = NULL;
|
|---|
| 30 |
|
|---|
| 31 | extern "C" {
|
|---|
| 32 |
|
|---|
| 33 | //******************************************************************************
|
|---|
| 34 | //******************************************************************************
|
|---|
| 35 | HRESULT 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 | //******************************************************************************
|
|---|
| 70 | HRESULT WIN32API OS2DirectSoundCaptureCreate(const GUID *lpGUID,
|
|---|
| 71 | LPDIRECTSOUNDCAPTURE * ppDS,
|
|---|
| 72 | IUnknown *pUnkOuter)
|
|---|
| 73 | {
|
|---|
| 74 | return DSERR_OUTOFMEMORY;
|
|---|
| 75 | }
|
|---|
| 76 |
|
|---|
| 77 | //******************************************************************************
|
|---|
| 78 | //******************************************************************************
|
|---|
| 79 | HRESULT 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 | //******************************************************************************
|
|---|
| 91 | HRESULT 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 | //******************************************************************************
|
|---|
| 103 | HRESULT WIN32API OS2DirectSoundEnumerateA(LPDSENUMCALLBACKA lpCallback,
|
|---|
| 104 | LPVOID lpContext)
|
|---|
| 105 | {
|
|---|
| 106 | dprintf(("DSOUND:DirectSoundEnumerateA\n"));
|
|---|
| 107 |
|
|---|
| 108 | lpCallback(NULL, "DART DirectSound for OS/2", "DirectSound/2 v0.5",
|
|---|
| 109 | lpContext);
|
|---|
| 110 | return DS_OK;
|
|---|
| 111 | }
|
|---|
| 112 |
|
|---|
| 113 | //******************************************************************************
|
|---|
| 114 | //******************************************************************************
|
|---|
| 115 | HRESULT WIN32API OS2DirectSoundEnumerateW(LPDSENUMCALLBACKW lpCallback,
|
|---|
| 116 | LPVOID lpContext)
|
|---|
| 117 | {
|
|---|
| 118 | dprintf(("DSOUND:DirectSoundEnumerateW\n"));
|
|---|
| 119 |
|
|---|
| 120 | lpCallback(NULL, (LPWSTR)L"DART DirectSound for OS/2", (LPWSTR)L"DirectSound/2 v0.5",
|
|---|
| 121 | lpContext);
|
|---|
| 122 | return DS_OK;
|
|---|
| 123 | }
|
|---|
| 124 |
|
|---|
| 125 | //******************************************************************************
|
|---|
| 126 | //******************************************************************************
|
|---|
| 127 |
|
|---|
| 128 |
|
|---|
| 129 | /*******************************************************************************
|
|---|
| 130 | * DirectSound ClassFactory
|
|---|
| 131 | *
|
|---|
| 132 | */
|
|---|
| 133 |
|
|---|
| 134 | typedef struct
|
|---|
| 135 | {
|
|---|
| 136 | /* IUnknown fields */
|
|---|
| 137 | ICOM_VTABLE(IClassFactory) *lpvtbl;
|
|---|
| 138 | DWORD ref;
|
|---|
| 139 | } IClassFactoryImpl;
|
|---|
| 140 |
|
|---|
| 141 | static HRESULT WINAPI
|
|---|
| 142 | DSCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
|
|---|
| 143 | {
|
|---|
| 144 | ICOM_THIS(IClassFactoryImpl,iface);
|
|---|
| 145 | char buf[80];
|
|---|
| 146 |
|
|---|
| 147 | if (HIWORD(riid))
|
|---|
| 148 | WINE_StringFromCLSID(riid,buf);
|
|---|
| 149 | else
|
|---|
| 150 | sprintf(buf,"<guid-0x%04x>",LOWORD(riid));
|
|---|
| 151 | dprintf(("DSOUND:DSCF_QueryInterface(%p)->(%s,%p),stub!\n",This,buf,ppobj));
|
|---|
| 152 | return E_NOINTERFACE;
|
|---|
| 153 | }
|
|---|
| 154 |
|
|---|
| 155 | static ULONG WINAPI
|
|---|
| 156 | DSCF_AddRef(LPCLASSFACTORY iface)
|
|---|
| 157 | {
|
|---|
| 158 | ICOM_THIS(IClassFactoryImpl,iface);
|
|---|
| 159 | return ++(This->ref);
|
|---|
| 160 | }
|
|---|
| 161 |
|
|---|
| 162 | static ULONG WINAPI DSCF_Release(LPCLASSFACTORY iface)
|
|---|
| 163 | {
|
|---|
| 164 | ICOM_THIS(IClassFactoryImpl,iface);
|
|---|
| 165 | /* static class, won't be freed */
|
|---|
| 166 | return --(This->ref);
|
|---|
| 167 | }
|
|---|
| 168 |
|
|---|
| 169 | static HRESULT WINAPI DSCF_CreateInstance( LPCLASSFACTORY iface,
|
|---|
| 170 | LPUNKNOWN pOuter,
|
|---|
| 171 | REFIID riid,
|
|---|
| 172 | LPVOID *ppobj)
|
|---|
| 173 | {
|
|---|
| 174 | ICOM_THIS(IClassFactoryImpl,iface);
|
|---|
| 175 | LPGUID lpGUID;
|
|---|
| 176 | lpGUID = (LPGUID) riid;
|
|---|
| 177 |
|
|---|
| 178 | dprintf(("DSOUND:DSCF_CreateInstance\n"));
|
|---|
| 179 | if(lpGUID && IsEqualGUID(lpGUID, &IID_IDirectSound)) {
|
|---|
| 180 | return OS2DirectSoundCreate(lpGUID,(LPDIRECTSOUND*)ppobj,pOuter);
|
|---|
| 181 | }
|
|---|
| 182 | return E_NOINTERFACE;
|
|---|
| 183 | }
|
|---|
| 184 |
|
|---|
| 185 | static HRESULT WINAPI DSCF_LockServer(LPCLASSFACTORY iface,BOOL dolock)
|
|---|
| 186 | {
|
|---|
| 187 | ICOM_THIS(IClassFactoryImpl,iface);
|
|---|
| 188 | dprintf(("DSOUND:DSCF_LockServer(%p)->(%d),stub!\n",This,dolock));
|
|---|
| 189 | return S_OK;
|
|---|
| 190 | }
|
|---|
| 191 |
|
|---|
| 192 | static ICOM_VTABLE(IClassFactory) DSCF_Vtbl =
|
|---|
| 193 | {
|
|---|
| 194 | DSCF_QueryInterface,
|
|---|
| 195 | DSCF_AddRef,
|
|---|
| 196 | DSCF_Release,
|
|---|
| 197 | DSCF_CreateInstance,
|
|---|
| 198 | DSCF_LockServer
|
|---|
| 199 | };
|
|---|
| 200 |
|
|---|
| 201 | static IClassFactoryImpl DSOUND_CF = {&DSCF_Vtbl, 1 };
|
|---|
| 202 |
|
|---|
| 203 |
|
|---|
| 204 | HRESULT WINAPI DSOUNDDllGetClassObject( REFCLSID rclsid,
|
|---|
| 205 | REFIID riid,
|
|---|
| 206 | LPVOID *ppv)
|
|---|
| 207 | {
|
|---|
| 208 | char buf[80],xbuf[80];
|
|---|
| 209 |
|
|---|
| 210 | if (HIWORD(rclsid))
|
|---|
| 211 | WINE_StringFromCLSID(rclsid,xbuf);
|
|---|
| 212 | else
|
|---|
| 213 | sprintf(xbuf,"<guid-0x%04x>",LOWORD(rclsid));
|
|---|
| 214 | if (HIWORD(riid))
|
|---|
| 215 | WINE_StringFromCLSID(riid,buf);
|
|---|
| 216 | else
|
|---|
| 217 | sprintf(buf,"<guid-0x%04x>",LOWORD(riid));
|
|---|
| 218 | WINE_StringFromCLSID(riid,xbuf);
|
|---|
| 219 |
|
|---|
| 220 | dprintf(("DSOUND:(%p,%p,%p)\n", xbuf, buf, ppv));
|
|---|
| 221 | if (!memcmp(riid,&IID_IClassFactory,sizeof(IID_IClassFactory)))
|
|---|
| 222 | {
|
|---|
| 223 | *ppv = (LPVOID)&DSOUND_CF;
|
|---|
| 224 | DSOUND_CF.lpvtbl->fnAddRef((IClassFactory*)&DSOUND_CF);
|
|---|
| 225 | return S_OK;
|
|---|
| 226 | }
|
|---|
| 227 | dprintf(("DSOUND: (%p,%p,%p): no interface found.\n", xbuf, buf, ppv));
|
|---|
| 228 | return E_NOINTERFACE;
|
|---|
| 229 | }
|
|---|
| 230 |
|
|---|
| 231 |
|
|---|
| 232 | /*******************************************************************************
|
|---|
| 233 | * DllCanUnloadNow Determines whether the DLL is in use.
|
|---|
| 234 | *
|
|---|
| 235 | * RETURNS
|
|---|
| 236 | * Success: S_OK
|
|---|
| 237 | * Failure: S_FALSE
|
|---|
| 238 | */
|
|---|
| 239 | HRESULT WINAPI DSOUNDDllCanUnloadNow(void)
|
|---|
| 240 | {
|
|---|
| 241 | dprintf(("DSOUND:DllCanUnloadNow(void) stub\n"));
|
|---|
| 242 | return S_FALSE;
|
|---|
| 243 | }//******************************************************************************
|
|---|
| 244 | }
|
|---|