- Timestamp:
- Mar 13, 2000, 1:47:54 PM (25 years ago)
- Location:
- trunk/src/dsound
- Files:
-
- 14 added
- 4 deleted
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/dsound/DSOUND.CPP
r1744 r3099 1 /* $Id: DSOUND.CPP,v 1. 6 1999-11-14 22:12:14 hughExp $ */1 /* $Id: DSOUND.CPP,v 1.7 2000-03-13 12:47:44 sandervl Exp $ */ 2 2 3 3 /* 4 4 * DirectSound exported APIs 5 5 * 6 * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl) 6 * Copyright 1998 Sander van Leeuwen 7 * Copyright 2000 Michal Necasek 7 8 * 8 9 * Project Odin Software License can be found in LICENSE.TXT … … 15 16 #include <os2win.h> 16 17 #include <stdlib.h> 18 #include <stdio.h> 17 19 #include <string.h> 18 20 19 21 #define INITGUID 22 #define ICOM_CINTERFACE 1 23 #define CINTERFACE 20 24 #include <dsound.h> 25 21 26 #include "os2dsound.h" 22 27 23 28 #include <misc.h> 29 30 OS2IDirectSound *DS = NULL; 24 31 25 32 //****************************************************************************** … … 29 36 IUnknown *pUnkOuter) 30 37 { 31 OS2IDirectSound *newsound = new OS2IDirectSound(lpGUID); 32 HRESULT rc; 33 34 dprintf(("DirectSoundCreate %X %X %X\n", lpGUID, ppDS, pUnkOuter)); 35 if(newsound == NULL) 36 return(DSERR_OUTOFMEMORY); 37 38 rc = newsound->GetLastError(); 39 if(rc != DS_OK) { 40 *ppDS = NULL; 41 delete newsound; 42 } 43 else 44 *ppDS = (LPDIRECTSOUND)newsound; 45 return(rc); 46 } 38 OS2IDirectSound *newsound; 39 HRESULT rc; 40 41 dprintf(("DSOUND:DirectSoundCreate %X %X %X\n", lpGUID, ppDS, pUnkOuter)); 42 43 if (OS2IDirectSound::fDSExists) { 44 *ppDS = (LPDIRECTSOUND)DS; 45 DS->Vtbl.AddRef(DS); 46 return DS_OK; 47 } 48 49 newsound = new OS2IDirectSound(lpGUID); 50 51 if (newsound == NULL) 52 return DSERR_OUTOFMEMORY; 53 54 rc = newsound->GetLastError(); 55 if(rc != DS_OK) { 56 *ppDS = NULL; 57 delete newsound; 58 } 59 else { 60 *ppDS = (LPDIRECTSOUND)newsound; 61 newsound->Vtbl.AddRef(newsound); 62 DS = newsound; 63 } 64 return rc; 65 } 66 67 //****************************************************************************** 68 //****************************************************************************** 69 HRESULT WIN32API OS2DirectSoundCaptureCreate(const GUID *lpGUID, 70 LPDIRECTSOUNDCAPTURE * ppDS, 71 IUnknown *pUnkOuter) 72 { 73 return DSERR_OUTOFMEMORY; 74 } 75 76 //****************************************************************************** 77 //****************************************************************************** 78 HRESULT WIN32API OS2DirectSoundCaptureEnumerateA(LPDSENUMCALLBACKA lpCallback, 79 LPVOID lpContext) 80 { 81 dprintf(("DSOUND:DirectSoundCaptureEnumerateA\n")); 82 83 lpCallback(NULL, "DART DirectSoundCapture for OS/2", 84 "DirectSoundCapture/2 v0.1", lpContext); 85 return DS_OK; 86 } 87 88 //****************************************************************************** 89 //****************************************************************************** 90 HRESULT WIN32API OS2DirectSoundCaptureEnumerateW(LPDSENUMCALLBACKW lpCallback, 91 LPVOID lpContext) 92 { 93 dprintf(("DSOUND:DirectSoundCaptureEnumerateW\n")); 94 95 lpCallback(NULL, (LPWSTR)L"DART DirectSoundCapture for OS/2", 96 (LPWSTR)L"DirectSoundCapture/2 v0.1", lpContext); 97 return DS_OK; 98 } 99 47 100 //****************************************************************************** 48 101 //****************************************************************************** … … 50 103 LPVOID lpContext) 51 104 { 52 dprintf(("DirectSoundEnumerateA\n")); 53 54 lpCallback(NULL, "DART DirectSound for OS/2", "DirectSound/2 v0.1", 55 lpContext); 56 return(DS_OK); 57 } 58 //****************************************************************************** 59 //****************************************************************************** 105 dprintf(("DSOUND:DirectSoundEnumerateA\n")); 106 107 lpCallback(NULL, "DART DirectSound for OS/2", "DirectSound/2 v0.5", 108 lpContext); 109 return DS_OK; 110 } 111 112 //****************************************************************************** 113 //****************************************************************************** 114 HRESULT WIN32API OS2DirectSoundEnumerateW(LPDSENUMCALLBACKW lpCallback, 115 LPVOID lpContext) 116 { 117 dprintf(("DSOUND:DirectSoundEnumerateW\n")); 118 119 lpCallback(NULL, (LPWSTR)L"DART DirectSound for OS/2", (LPWSTR)L"DirectSound/2 v0.5", 120 lpContext); 121 return DS_OK; 122 } 123 124 //****************************************************************************** 125 //****************************************************************************** 126 127 128 /******************************************************************************* 129 * DirectSound ClassFactory 130 * 131 */ 132 133 typedef struct 134 { 135 /* IUnknown fields */ 136 ICOM_VTABLE(IClassFactory) *lpvtbl; 137 DWORD ref; 138 } IClassFactoryImpl; 139 140 static HRESULT WINAPI 141 DSCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) 142 { 143 ICOM_THIS(IClassFactoryImpl,iface); 144 char buf[80]; 145 146 if (HIWORD(riid)) 147 WINE_StringFromCLSID(riid,buf); 148 else 149 sprintf(buf,"<guid-0x%04x>",LOWORD(riid)); 150 dprintf(("DSOUND:DSCF_QueryInterface(%p)->(%s,%p),stub!\n",This,buf,ppobj)); 151 return E_NOINTERFACE; 152 } 153 154 static ULONG WINAPI 155 DSCF_AddRef(LPCLASSFACTORY iface) 156 { 157 ICOM_THIS(IClassFactoryImpl,iface); 158 return ++(This->ref); 159 } 160 161 static ULONG WINAPI DSCF_Release(LPCLASSFACTORY iface) 162 { 163 ICOM_THIS(IClassFactoryImpl,iface); 164 /* static class, won't be freed */ 165 return --(This->ref); 166 } 167 168 static HRESULT WINAPI DSCF_CreateInstance( LPCLASSFACTORY iface, 169 LPUNKNOWN pOuter, 170 REFIID riid, 171 LPVOID *ppobj) 172 { 173 ICOM_THIS(IClassFactoryImpl,iface); 174 LPGUID lpGUID; 175 lpGUID = (LPGUID) riid; 176 177 dprintf(("DSOUND:DSCF_CreateInstance\n")); 178 if( lpGUID && (*lpGUID == IID_IDirectSound )) { 179 return OS2DirectSoundCreate(lpGUID,(LPDIRECTSOUND*)ppobj,pOuter); 180 } 181 return E_NOINTERFACE; 182 } 183 184 static HRESULT WINAPI DSCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) 185 { 186 ICOM_THIS(IClassFactoryImpl,iface); 187 dprintf(("DSOUND:DSCF_LockServer(%p)->(%d),stub!\n",This,dolock)); 188 return S_OK; 189 } 190 191 static ICOM_VTABLE(IClassFactory) DSCF_Vtbl = 192 { 193 DSCF_QueryInterface, 194 DSCF_AddRef, 195 DSCF_Release, 196 DSCF_CreateInstance, 197 DSCF_LockServer 198 }; 199 200 static IClassFactoryImpl DSOUND_CF = {&DSCF_Vtbl, 1 }; 201 202 203 HRESULT WINAPI DllGetClassObject( REFCLSID rclsid, 204 REFIID riid, 205 LPVOID *ppv) 206 { 207 char buf[80],xbuf[80]; 208 209 if (HIWORD(rclsid)) 210 WINE_StringFromCLSID(rclsid,xbuf); 211 else 212 sprintf(xbuf,"<guid-0x%04x>",LOWORD(rclsid)); 213 if (HIWORD(riid)) 214 WINE_StringFromCLSID(riid,buf); 215 else 216 sprintf(buf,"<guid-0x%04x>",LOWORD(riid)); 217 WINE_StringFromCLSID(riid,xbuf); 218 219 dprintf(("DSOUND:(%p,%p,%p)\n", xbuf, buf, ppv)); 220 if (!memcmp(riid,&IID_IClassFactory,sizeof(IID_IClassFactory))) 221 { 222 *ppv = (LPVOID)&DSOUND_CF; 223 DSOUND_CF.lpvtbl->AddRef((IClassFactory*)&DSOUND_CF); 224 return S_OK; 225 } 226 dprintf(("DSOUND: (%p,%p,%p): no interface found.\n", xbuf, buf, ppv)); 227 return E_NOINTERFACE; 228 } 229 230 231 /******************************************************************************* 232 * DllCanUnloadNow Determines whether the DLL is in use. 233 * 234 * RETURNS 235 * Success: S_OK 236 * Failure: S_FALSE 237 */ 238 HRESULT WINAPI DllCanUnloadNow(void) 239 { 240 dprintf(("DSOUND:DllCanUnloadNow(void) stub\n")); 241 return S_FALSE; 242 }//****************************************************************************** 243 -
trunk/src/dsound/DSOUND.DEF
r97 r3099 1 ; $Id: DSOUND.DEF,v 1. 2 1999-06-10 17:09:29 phallerExp $1 ; $Id: DSOUND.DEF,v 1.3 2000-03-13 12:47:44 sandervl Exp $ 2 2 3 3 LIBRARY DSOUND INITINSTANCE TERMINSTANCE … … 6 6 CODE LOADONCALL 7 7 EXPORTS 8 DirectSoundCreate = _OS2DirectSoundCreate@12 @1 9 DirectSoundEnumerateA = _OS2DirectSoundEnumerateA@8 @2 8 9 DirectSoundCreate = _OS2DirectSoundCreate@12 @1 10 DirectSoundEnumerateA = _OS2DirectSoundEnumerateA@8 @2 11 DirectSoundEnumerateW = _OS2DirectSoundEnumerateW@8 @3 12 DirectSoundCaptureCreate = _OS2DirectSoundCreate@12 @6 13 DirectSoundCaptureEnumerateA = _OS2DirectSoundEnumerateA@8 @7 14 DirectSoundCaptureEnumerateW = _OS2DirectSoundEnumerateW@8 @8 15 16 DllCanUnloadNow = _DllCanUnloadNow@0 @4 17 DllGetClassObject = _DllGetClassObject@12 @5 18 -
trunk/src/dsound/OS2DSOUND.CPP
r1744 r3099 1 /* $Id: OS2DSOUND.CPP,v 1. 5 1999-11-14 22:12:15 hughExp $ */1 /* $Id: OS2DSOUND.CPP,v 1.6 2000-03-13 12:47:46 sandervl Exp $ */ 2 2 3 3 /* 4 4 * DirectSound main class 5 5 * 6 * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl) 6 * Copyright 1998 Sander van Leeuwen 7 * Copyright 2000 Michal Necasek 7 8 * 8 9 * Project Odin Software License can be found in LICENSE.TXT … … 20 21 #include <dsound.h> 21 22 22 #include "os2dsound.h" 23 #include "os2sndbuffer.h" 23 #include "OS2DSound.h" 24 #include "OS2SndBuffer.h" 25 #include "OS2PrimBuff.h" 26 #include "OS23DListener.h" 27 #include "OS2Notify.h" 24 28 #include <misc.h> 29 30 // TODO: primary buffer should probably created right away when creating the DSound 31 // object 32 // TODO: handle cooperative levels properly!! 33 34 // this flag is set if the OS2IDirectObject exists 35 BOOL OS2IDirectSound::fDSExists = FALSE; 25 36 26 37 //****************************************************************************** … … 29 40 lastError(DS_OK), hwndClient(0) 30 41 { 31 lpVtbl = &Vtbl; 32 Vtbl.AddRef = SoundAddRef; 33 Vtbl.Release = SoundRelease; 34 Vtbl.QueryInterface = SoundQueryInterface; 35 Vtbl.Compact = SoundCompact; 36 Vtbl.CreateSoundBuffer = SoundCreateSoundBuffer; 37 Vtbl.GetCaps = SoundGetCaps; 38 Vtbl.DuplicateSoundBuffer = SoundDuplicateSoundBuffer; 39 Vtbl.SetCooperativeLevel = SoundSetCooperativeLevel; 40 Vtbl.Compact = SoundCompact; 41 Vtbl.GetSpeakerConfig = SoundGetSpeakerConfig; 42 Vtbl.SetSpeakerConfig = SoundSetSpeakerConfig; 43 Vtbl.Initialize = SoundInitialize; 44 45 speakerConfig = DSSPEAKER_STEREO; 46 CoopLevel = DSSCL_EXCLUSIVE; //default 42 lpVtbl = &Vtbl; 43 Vtbl.AddRef = SoundAddRef; 44 Vtbl.Release = SoundRelease; 45 Vtbl.QueryInterface = SoundQueryInterface; 46 Vtbl.Compact = SoundCompact; 47 Vtbl.CreateSoundBuffer = SoundCreateSoundBuffer; 48 Vtbl.GetCaps = SoundGetCaps; 49 Vtbl.DuplicateSoundBuffer = SoundDuplicateSoundBuffer; 50 Vtbl.SetCooperativeLevel = SoundSetCooperativeLevel; 51 Vtbl.Compact = SoundCompact; 52 Vtbl.GetSpeakerConfig = SoundGetSpeakerConfig; 53 Vtbl.SetSpeakerConfig = SoundSetSpeakerConfig; 54 Vtbl.Initialize = SoundInitialize; 55 56 dprintf(("DSOUND-OS2IDirectSound::OS2IDirectSound\n")); 57 58 speakerConfig = DSSPEAKER_STEREO; 59 CoopLevel = DSSCL_EXCLUSIVE; //default 60 61 OS2IDirectSound::fDSExists = TRUE; 62 63 dprintf(("Sound init OK\n")); 47 64 } 48 65 //****************************************************************************** … … 50 67 OS2IDirectSound::~OS2IDirectSound() 51 68 { 52 69 // TODO: Close all SoundBuffers here 70 OS2IDirectSoundBuffer::DestroyAllBuffers(); 71 OS2IDirectSound::fDSExists = FALSE; 53 72 } 54 73 //****************************************************************************** … … 56 75 HRESULT WIN32API SoundQueryInterface(THIS, REFIID riid, LPVOID * ppvObj) 57 76 { 58 dprintf(("OS2IDirectSound::QueryInterface\n"));59 if(This == NULL)60 {61 return DSERR_INVALIDPARAM;62 }63 *ppvObj = NULL; 64 65 if(!IsEqualGUID(riid, CLSID_DirectSound) &&66 !IsEqualGUID(riid, IID_IDirectSound))67 return E_NOINTERFACE; 68 69 *ppvObj = This; 70 71 SoundAddRef(This);72 return(DS_OK); 73 } 77 dprintf(("DSOUND-OS2IDirectSound::QueryInterface\n")); 78 if (This == NULL) { 79 return DSERR_INVALIDPARAM; 80 } 81 *ppvObj = NULL; 82 83 if (!IsEqualGUID(riid, CLSID_DirectSound) && 84 !IsEqualGUID(riid, IID_IDirectSound)) 85 return E_NOINTERFACE; 86 87 *ppvObj = This; 88 89 SoundAddRef(This); 90 return DS_OK; 91 } 92 74 93 //****************************************************************************** 75 94 //****************************************************************************** 76 95 ULONG WIN32API SoundAddRef(THIS) 77 96 { 78 OS2IDirectSound *me = (OS2IDirectSound *)This; 79 80 dprintf(("OS2IDirectSound::AddRef %d\n", me->Referenced+1)); 81 return ++me->Referenced; 82 } 97 OS2IDirectSound *me = (OS2IDirectSound *)This; 98 99 dprintf(("DSOUND-OS2IDirectSound::AddRef %d\n", me->Referenced+1)); 100 return ++me->Referenced; 101 } 102 83 103 //****************************************************************************** 84 104 //****************************************************************************** 85 105 ULONG WIN32API SoundRelease(THIS) 86 106 { 87 OS2IDirectSound *me = (OS2IDirectSound *)This; 88 89 dprintf(("OS2IDirectSound::Release %d\n", me->Referenced-1)); 90 if(me->Referenced) { 91 me->Referenced--; 92 if(me->Referenced == 0) { 93 delete me; 94 return(0); 95 } 96 else return me->Referenced; 97 } 98 else return(0); 99 } 107 OS2IDirectSound *me = (OS2IDirectSound *)This; 108 109 dprintf(("DSOUND-OS2IDirectSound::Release %d\n", me->Referenced-1)); 110 if (me->Referenced) { 111 me->Referenced--; 112 if (me->Referenced == 0) { 113 delete me; 114 return 0; 115 } 116 else 117 return me->Referenced; 118 } 119 else 120 return 0; 121 } 122 100 123 //****************************************************************************** 101 124 //****************************************************************************** 102 125 HRESULT WIN32API SoundCompact(THIS) 103 126 { 104 dprintf(("OS2IDirectSound::Compact\n")); 105 return(DS_OK); 106 } 127 dprintf(("DSOUND-OS2IDirectSound::Compact\n")); 128 return DS_OK; 129 } 130 107 131 //****************************************************************************** 108 132 //****************************************************************************** … … 112 136 LPUNKNOWN pUnkOuter) 113 137 { 114 OS2IDirectSound *me = (OS2IDirectSound *)This; 115 OS2IDirectSoundBuffer *sndbuf; 116 117 dprintf(("OS2IDirectSound::CreateSoundBuffer\n")); 118 if(me == NULL || lpDSBufferDesc == NULL || lplpDirectSoundBuffer == NULL) 119 { 120 return(DSERR_INVALIDPARAM); 121 } 122 123 sndbuf = new OS2IDirectSoundBuffer(lpDSBufferDesc); 124 if(sndbuf == NULL) 125 { 126 return(DSERR_OUTOFMEMORY); 127 } 128 if(sndbuf->GetLastError() != DS_OK) 129 { 130 ULONG lastErr = sndbuf->GetLastError(); 131 delete sndbuf; 132 return lastErr; 133 } 134 *lplpDirectSoundBuffer = (LPDIRECTSOUNDBUFFER)sndbuf; 135 return(DS_OK); 136 } 138 OS2IDirectSound *me = (OS2IDirectSound *)This; 139 OS2IDirectSoundBuffer *sndbuf; 140 141 dprintf(("DSOUND-OS2IDirectSound::CreateSoundBuffer\n")); 142 if (me == NULL || lpDSBufferDesc == NULL || lplpDirectSoundBuffer == NULL) { 143 return DSERR_INVALIDPARAM; 144 } 145 146 if ((lpDSBufferDesc->dwFlags & DSBCAPS_PRIMARYBUFFER) && (lpDSBufferDesc->lpwfxFormat != NULL)) { 147 // Primary buffers must be created without format info! 148 return DSERR_INVALIDPARAM; 149 } 150 151 if (lpDSBufferDesc->dwFlags & DSBCAPS_PRIMARYBUFFER) { 152 OS2PrimBuff *primbuff; 153 primbuff = new OS2PrimBuff(me, lpDSBufferDesc); 154 155 if (primbuff == NULL) 156 return DSERR_OUTOFMEMORY; 157 158 if ( primbuff->GetLastError() != DS_OK ){ 159 ULONG lastErr = primbuff->GetLastError(); 160 161 dprintf(("LastErr = %d\n", lastErr)); 162 delete primbuff; 163 return lastErr; 164 } 165 *lplpDirectSoundBuffer = (LPDIRECTSOUNDBUFFER)primbuff; 166 primbuff->Vtbl.AddRef(primbuff); 167 dprintf(("Created PrimBuff... Exiting Create Buffer function\n")); 168 169 return DS_OK; 170 } 171 172 sndbuf = new OS2IDirectSoundBuffer(me, lpDSBufferDesc); 173 if (sndbuf == NULL) { 174 return DSERR_OUTOFMEMORY; 175 } 176 if(sndbuf->GetLastError() != DS_OK) { 177 ULONG lastErr = sndbuf->GetLastError(); 178 delete sndbuf; 179 return lastErr; 180 } 181 sndbuf->Vtbl.AddRef(sndbuf); 182 183 *lplpDirectSoundBuffer = (LPDIRECTSOUNDBUFFER)sndbuf; 184 185 return DS_OK; 186 } 187 137 188 //****************************************************************************** 138 189 //****************************************************************************** 139 190 HRESULT WIN32API SoundGetCaps(THIS_ LPDSCAPS lpCaps) 140 191 { 141 dprintf(("OS2IDirectSound::GetCaps\n")); 142 return(DS_OK); 143 } 192 dprintf(("DSOUND-OS2IDirectSound::GetCaps\n")); 193 194 if (lpCaps == NULL) 195 return DSERR_INVALIDPARAM; 196 197 lpCaps->dwSize = sizeof(DSCAPS); 198 lpCaps->dwFlags = DSCAPS_SECONDARY8BIT | DSCAPS_SECONDARY16BIT | 199 DSCAPS_SECONDARYMONO | DSCAPS_SECONDARYSTEREO | 200 DSCAPS_PRIMARY8BIT | DSCAPS_PRIMARY16BIT | 201 /* DSCAPS_PRIMARYMONO |*/ DSCAPS_PRIMARYSTEREO; 202 lpCaps->dwMinSecondarySampleRate = 100; 203 lpCaps->dwMaxSecondarySampleRate = 100000; 204 lpCaps->dwPrimaryBuffers = 1; 205 lpCaps->dwMaxHwMixingAllBuffers = 0; // no HW support, no HW buffers... 206 lpCaps->dwMaxHwMixingStaticBuffers = 0; 207 lpCaps->dwMaxHwMixingStreamingBuffers = 0; 208 lpCaps->dwFreeHwMixingAllBuffers = 0; 209 lpCaps->dwFreeHwMixingStaticBuffers = 0; 210 lpCaps->dwFreeHwMixingStreamingBuffers = 0; 211 lpCaps->dwMaxHw3DAllBuffers = 0; 212 lpCaps->dwMaxHw3DStaticBuffers = 0; 213 lpCaps->dwMaxHw3DStreamingBuffers = 0; 214 lpCaps->dwFreeHw3DAllBuffers = 0; 215 lpCaps->dwFreeHw3DStaticBuffers = 0; 216 lpCaps->dwFreeHw3DStreamingBuffers = 0; 217 lpCaps->dwTotalHwMemBytes = 0; 218 lpCaps->dwFreeHwMemBytes = 0; 219 lpCaps->dwMaxContigFreeHwMemBytes = 0; 220 lpCaps->dwUnlockTransferRateHwBuffers = 0; // no transfer needed 221 lpCaps->dwPlayCpuOverheadSwBuffers = 0; // we lie here... 222 lpCaps->dwReserved1 = 0; 223 lpCaps->dwReserved2 = 0; 224 225 return DS_OK; 226 } 227 144 228 //****************************************************************************** 145 229 //****************************************************************************** 146 230 HRESULT WIN32API SoundDuplicateSoundBuffer(THIS_ LPDIRECTSOUNDBUFFER, LPLPDIRECTSOUNDBUFFER ) 147 231 { 148 dprintf(("OS2IDirectSound::DuplicateSoundBuffer\n")); 149 return(DSERR_OUTOFMEMORY); 150 } 232 dprintf(("DSOUND-OS2IDirectSound::DuplicateSoundBuffer\n")); 233 return DSERR_OUTOFMEMORY; 234 } 235 151 236 //****************************************************************************** 152 237 //****************************************************************************** 153 238 HRESULT WIN32API SoundSetCooperativeLevel(THIS_ HWND hwndClient, DWORD level) 154 239 { 155 OS2IDirectSound *me = (OS2IDirectSound *)This;156 157 dprintf(("OS2IDirectSound::SetCooperativeLevel\n"));158 if(me == NULL) {159 return(DSERR_INVALIDPARAM);160 }161 me->hwndClient = (HWND)hwndClient;162 me->CoopLevel = level;163 return(DS_OK);240 OS2IDirectSound *me = (OS2IDirectSound *)This; 241 242 dprintf(("DSOUND-OS2IDirectSound::SetCooperativeLevel (to %d)\n", level)); 243 if (me == NULL) { 244 return DSERR_INVALIDPARAM; 245 } 246 me->hwndClient = (HWND)hwndClient; 247 me->CoopLevel = level; 248 return DS_OK; 164 249 } 165 250 //****************************************************************************** … … 167 252 HRESULT WIN32API SoundGetSpeakerConfig(THIS_ LPDWORD lpSpeakerCfg) 168 253 { 169 OS2IDirectSound *me = (OS2IDirectSound *)This; 170 171 dprintf(("OS2IDirectSound::GetSpeakerConfig\n")); 172 if(me == NULL) { 173 return(DSERR_INVALIDPARAM); 174 } 175 *lpSpeakerCfg = me->speakerConfig; 176 177 return(DS_OK); 178 } 254 OS2IDirectSound *me = (OS2IDirectSound *)This; 255 256 dprintf(("DSOUND-OS2IDirectSound::GetSpeakerConfig\n")); 257 if (me == NULL) { 258 return(DSERR_INVALIDPARAM); 259 } 260 *lpSpeakerCfg = me->speakerConfig; 261 262 return DS_OK; 263 } 264 179 265 //****************************************************************************** 180 266 //****************************************************************************** 181 267 HRESULT WIN32API SoundSetSpeakerConfig(THIS_ DWORD speakerCfg) 182 268 { 183 OS2IDirectSound *me = (OS2IDirectSound *)This; 184 185 dprintf(("OS2IDirectSound::SetSpeakerConfig %X\n", speakerCfg)); 186 if(me == NULL) { 187 return(DSERR_INVALIDPARAM); 188 } 189 me->speakerConfig = speakerCfg; 190 return(DS_OK); 191 } 269 OS2IDirectSound *me = (OS2IDirectSound *)This; 270 271 dprintf(("DSOUND-OS2IDirectSound::SetSpeakerConfig %X\n", speakerCfg)); 272 if (me == NULL) { 273 return DSERR_INVALIDPARAM; 274 } 275 me->speakerConfig = speakerCfg; 276 return DS_OK; 277 } 278 192 279 //****************************************************************************** 193 280 //****************************************************************************** 194 281 HRESULT WIN32API SoundInitialize(THIS_ LPGUID) 195 282 { 196 dprintf(("OS2IDirectSound::Initialize UNSUPPORTED\n"));197 return(DS_OK);198 } 199 //****************************************************************************** 200 //****************************************************************************** 283 dprintf(("DSOUND-OS2IDirectSound::Initialize NOP\n")); 284 return DS_OK; 285 } 286 //****************************************************************************** 287 //****************************************************************************** -
trunk/src/dsound/OS2DSOUND.H
r1421 r3099 1 /* $Id: OS2DSOUND.H,v 1. 4 1999-10-23 23:00:49sandervl Exp $ */1 /* $Id: OS2DSOUND.H,v 1.5 2000-03-13 12:47:46 sandervl Exp $ */ 2 2 3 3 /* … … 26 26 27 27 OS2IDirectSound(const GUID *lpGUID); 28 28 ~OS2IDirectSound(); 29 29 30 int Referenced; 31 inline HRESULT GetLastError() { return lastError; }; 30 int Referenced; 31 32 static BOOL fDSExists; 33 inline HRESULT GetLastError() { return lastError; }; 34 inline DWORD GetCoopLevel() { return CoopLevel; }; 32 35 33 36 private: 34 37 35 38 protected: 36 39 HRESULT lastError; 37 40 38 41 DWORD speakerConfig; 39 42 DWORD CoopLevel; 40 43 HWND hwndClient; 44 41 45 42 46 // Linked list management -
trunk/src/dsound/OS2SNDBUFFER.CPP
r2637 r3099 1 /* $Id: OS2SNDBUFFER.CPP,v 1. 6 2000-02-04 19:29:16 hughExp $ */1 /* $Id: OS2SNDBUFFER.CPP,v 1.7 2000-03-13 12:47:48 sandervl Exp $ */ 2 2 3 3 /* … … 5 5 * 6 6 * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl) 7 * Copyright 2000 Michal Necasek 7 8 * 8 9 * Project Odin Software License can be found in LICENSE.TXT … … 16 17 #define INCL_DOSMISC 17 18 #include <os2win.h> 19 18 20 #include <stdlib.h> 19 21 #include <string.h> … … 22 24 #include <dsound.h> 23 25 24 #include "os2dsound.h" 25 #include "os2sndbuffer.h" 26 #include "OS2DSound.h" 27 #include "OS2SndBuffer.h" 28 #include "OS2PrimBuff.h" 29 #include "OS23DListener.h" 30 #include "OS23DBuffer.h" 31 #include "OS2Notify.h" 26 32 #include <misc.h> 27 33 28 29 extern DWORD GetTickCountOS2(); 34 #include "DSVolume.h" 30 35 31 36 WAVEFORMATEX wfxDefaultPrimaryBuf = { WAVE_FORMAT_PCM, … … 37 42 0}; 38 43 39 //****************************************************************************** 40 //****************************************************************************** 41 OS2IDirectSoundBuffer::OS2IDirectSoundBuffer(const DSBUFFERDESC *lpDSBufferDesc) //KSO Apr 13 1999: const, SDK changes 44 OS2IDirectSoundBuffer *OS2IDirectSoundBuffer::dsbroot = NULL; 45 OS2IDirectSoundBuffer *OS2IDirectSoundBuffer::primary = NULL; 46 47 //****************************************************************************** 48 //****************************************************************************** 49 OS2IDirectSoundBuffer::OS2IDirectSoundBuffer(OS2IDirectSound *DSound, const DSBUFFERDESC *lpDSBufferDesc) 42 50 : Referenced(0), lastError(DS_OK) 43 51 { 44 lpVtbl = &Vtbl; 45 Vtbl.AddRef = SoundBufAddRef; 46 Vtbl.Release = SoundBufRelease; 47 Vtbl.QueryInterface = SoundBufQueryInterface; 48 Vtbl.GetCaps = SoundBufGetCaps; 49 Vtbl.GetFormat = SoundBufGetFormat; 50 Vtbl.GetVolume = SoundBufGetVolume; 51 Vtbl.GetStatus = SoundBufGetStatus; 52 Vtbl.GetCurrentPosition = SoundBufGetCurrentPosition; 53 Vtbl.GetPan = SoundBufGetPan; 54 Vtbl.Initialize = SoundBufInitialize; 55 Vtbl.Restore = SoundBufRestore; 56 Vtbl.SetFormat = SoundBufSetFormat; 57 Vtbl.SetVolume = SoundBufSetVolume; 58 Vtbl.SetCurrentPosition = SoundBufSetCurrentPosition; 59 Vtbl.SetPan = SoundBufSetPan; 60 Vtbl.Lock = SoundBufLock; 61 Vtbl.Unlock = SoundBufUnlock; 62 Vtbl.Stop = SoundBufStop; 63 Vtbl.Play = SoundBufPlay; 64 65 pan = 0; 66 writepos = 0; 67 playpos = 0; 68 frequency = 22050; 69 status = 0;; 70 fLocked = FALSE; 71 volume = 0; 72 lpfxFormat= NULL; 73 lpBuffer = NULL; 74 fPlaying = FALSE; 75 fLoop = FALSE; 76 newWritePos = 0; 77 LastTickCnt = 0; 78 memcpy(&bufferdesc, lpDSBufferDesc, sizeof(DSBUFFERDESC)); 79 80 if(bufferdesc.dwFlags & DSBCAPS_PRIMARYBUFFER) 81 { 82 // Primary Buffer 83 // Fake this for now and setup the default values for it 84 //todo: Do the primary buffer right 85 bufferdesc.dwBufferBytes = 4096; 86 bufferdesc.lpwfxFormat = &wfxDefaultPrimaryBuf; 87 88 } 89 90 if(bufferdesc.lpwfxFormat == NULL || bufferdesc.dwBufferBytes == 0) 91 { 52 lpVtbl = &Vtbl; 53 Vtbl.AddRef = SoundBufAddRef; 54 Vtbl.Release = SoundBufRelease; 55 Vtbl.QueryInterface = SoundBufQueryInterface; 56 Vtbl.GetCaps = SoundBufGetCaps; 57 Vtbl.GetFormat = SoundBufGetFormat; 58 Vtbl.GetVolume = SoundBufGetVolume; 59 Vtbl.GetStatus = SoundBufGetStatus; 60 Vtbl.GetCurrentPosition = SoundBufGetCurrentPosition; 61 Vtbl.GetPan = SoundBufGetPan; 62 Vtbl.GetFrequency = SoundBufGetFrequency; 63 Vtbl.Initialize = SoundBufInitialize; 64 Vtbl.Restore = SoundBufRestore; 65 Vtbl.SetFormat = SoundBufSetFormat; 66 Vtbl.SetVolume = SoundBufSetVolume; 67 Vtbl.SetCurrentPosition = SoundBufSetCurrentPosition; 68 Vtbl.SetPan = SoundBufSetPan; 69 Vtbl.SetFrequency = SoundBufSetFrequency; 70 Vtbl.Lock = SoundBufLock; 71 Vtbl.Unlock = SoundBufUnlock; 72 Vtbl.Stop = SoundBufStop; 73 Vtbl.Play = SoundBufPlay; 74 75 dprintf(("DSOUND-OS2IDirectSoundBuffer::OS2IDirectSoundBuffer (buf=%X)", this)); 76 77 // If the primary SoundBuffer doesn't exist by now, we have to create it! 78 if (primary == NULL) { 79 OS2PrimBuff *primbuff; 80 primbuff = new OS2PrimBuff(DSound, lpDSBufferDesc); 81 82 if (primary == NULL) { 83 lastError = DSERR_OUTOFMEMORY; 84 return; 85 } 86 } 87 // Add a reference to the primary buffer for _every_ secondary buffer; this makes 88 // sure that as long as a secondary buffer exists the primary buffer won't get 89 // destroyed; moreover if the user didn't create a primary buffer himself/herself, 90 // it will automatically get created and destroyed with the last secondary buffer 91 primary->Vtbl.AddRef(primary); 92 93 // Start playing the primary buffer 94 // TODO: only start playing the primary buffer when necessary! 95 OS2IDirectSoundBuffer::primary->Vtbl.Play(OS2IDirectSoundBuffer::primary, 0, 0, DSBPLAY_LOOPING); 96 97 parentDS = DSound; 98 writepos = 0; 99 playpos = 0; 100 status = 0; 101 fLocked = FALSE; 102 fPrimary = FALSE; 103 volume = 255; 104 DSvolume = 0; 105 pan = 0; 106 DSpan = 0; 107 lpfxFormat= NULL; 108 lpBuffer = NULL; 109 fPlaying = FALSE; 110 fLoop = FALSE; 111 notify = NULL; 112 memcpy(&bufferdesc, lpDSBufferDesc, sizeof(DSBUFFERDESC)); 113 114 // Note: this cannot be a primary buffer - those take a different route 115 116 // frequency has to be set according to the bufer format 117 frequency = bufferdesc.lpwfxFormat->nSamplesPerSec; 118 119 if (bufferdesc.lpwfxFormat == NULL || bufferdesc.dwBufferBytes == 0) { 92 120 dprintf(("bufferdesc not valid!")); 93 121 lastError = DSERR_INVALIDPARAM; 94 122 return; 95 } 96 97 lpfxFormat = (WAVEFORMATEX *)malloc(bufferdesc.lpwfxFormat->cbSize + sizeof(WAVEFORMATEX)); 98 memcpy( lpfxFormat, 123 } 124 125 // Some apps pass trash in cbSize, can't rely on that! 126 lpfxFormat = (WAVEFORMATEX *)malloc(/*bufferdesc.lpwfxFormat->cbSize +*/ sizeof(WAVEFORMATEX)); 127 memcpy(lpfxFormat, 99 128 bufferdesc.lpwfxFormat, 100 bufferdesc.lpwfxFormat->cbSize + sizeof(WAVEFORMATEX)); 101 102 bufferdesc.lpwfxFormat = lpfxFormat; 103 104 lpBuffer = (LPSTR)VirtualAlloc( 0, bufferdesc.dwBufferBytes, MEM_COMMIT, PAGE_READWRITE); 105 if(lpBuffer == NULL) 106 { 129 /*bufferdesc.lpwfxFormat->cbSize + */sizeof(WAVEFORMATEX)); 130 131 dprintf((" Buffer format: %dHz, %dbit, %d channels", lpfxFormat->nSamplesPerSec, lpfxFormat->wBitsPerSample, lpfxFormat->nChannels)); 132 133 lpBuffer = (LPSTR)VirtualAlloc(0, bufferdesc.dwBufferBytes, MEM_COMMIT, PAGE_READWRITE); 134 if (lpBuffer == NULL) { 107 135 dprintf(("VirtualAlloc failed")); 108 136 lpBuffer = NULL; 109 137 lastError = DSERR_OUTOFMEMORY; 110 138 return; 111 } 112 113 } 139 } 140 141 next = dsbroot; 142 dsbroot = this; 143 } 144 114 145 //****************************************************************************** 115 146 //****************************************************************************** 116 147 OS2IDirectSoundBuffer::~OS2IDirectSoundBuffer() 117 148 { 118 if(lpBuffer) 119 VirtualFree(lpBuffer, 0, MEM_RELEASE); 120 if(lpfxFormat) 121 free(lpfxFormat); 122 123 } 149 /* We must not run this destructor on the primary buffer! */ 150 if (fPrimary) 151 return; 152 153 dprintf(("DSOUND-OS2IDirectSoundBuffer::~OS2IDirectSoundBuffer (buf=%X)", this)); 154 155 // free allocted memory 156 if (lpBuffer) 157 VirtualFree(lpBuffer, 0, MEM_RELEASE); 158 159 if (lpfxFormat) 160 free(lpfxFormat); 161 162 // remove ourselves from the linked list 163 OS2IDirectSoundBuffer *cur = dsbroot; 164 OS2IDirectSoundBuffer *prev = NULL; 165 166 // release the primary buffer too 167 primary->Vtbl.Release(primary); 168 169 if (this == dsbroot) // is this the first SoundBuffer? 170 dsbroot = next; 171 else { // walk the chain 172 while (cur->next != this) 173 cur = cur->next; 174 175 cur->next = next; 176 } 177 178 } 179 180 //****************************************************************************** 181 //****************************************************************************** 182 void OS2IDirectSoundBuffer::DestroyAllBuffers() 183 { 184 dprintf(("DSOUND-OS2IDirectSoundBuffer::DestroyAllBuffers")); 185 186 // if any SoundBuffers still exist when the OS2IDirectSound object is 187 // being closed, just kill them all 188 OS2IDirectSoundBuffer *cur = dsbroot; 189 OS2IDirectSoundBuffer *tmp; 190 191 if (primary != NULL) 192 primary->Vtbl.Stop(primary); 193 194 while (cur != NULL) { 195 tmp = cur->next; 196 delete cur; 197 cur = tmp; 198 } 199 dprintf(("DSOUND-OS2IDirectSoundBuffer::DestroyAllBuffers - %X", primary)); 200 if (primary != NULL) 201 primary->Vtbl.Release(primary); 202 } 203 124 204 //****************************************************************************** 125 205 //****************************************************************************** 126 206 HRESULT WIN32API SoundBufQueryInterface(THIS, REFIID riid, LPVOID * ppvObj) 127 207 { 128 dprintf(("OS2IDirectSoundBuffer::QueryInterface\n")); 129 if(This == NULL) 130 { 131 return DSERR_INVALIDPARAM; 132 } 133 *ppvObj = NULL; 134 135 if(!IsEqualGUID(riid, IID_IDirectSoundBuffer)) 136 return E_NOINTERFACE; 137 138 *ppvObj = This; 139 140 SoundBufAddRef(This); 141 return(DS_OK); 208 dprintf(("DSOUND-OS2IDirectSoundBuffer::QueryInterface")); 209 if (This == NULL) { 210 return DSERR_INVALIDPARAM; 211 } 212 *ppvObj = NULL; 213 214 if (IsEqualGUID(riid, IID_IDirectSoundBuffer)) { 215 *ppvObj = This; 216 217 SoundBufAddRef(This); 218 return DS_OK; 219 } 220 221 if (IsEqualGUID(riid, IID_IDirectSoundNotify)) { 222 OS2IDirectSoundBuffer *me = (OS2IDirectSoundBuffer *)This; 223 OS2IDirectSoundNotify *notify; 224 225 notify = new OS2IDirectSoundNotify(me); 226 *ppvObj = notify; 227 notify->Vtbl.AddRef(notify); 228 return DS_OK; 229 } 230 231 if (IsEqualGUID(riid, IID_IDirectSound3DBuffer)) { 232 OS2IDirectSoundBuffer *me = (OS2IDirectSoundBuffer *)This; 233 OS2IDirectSound3DBuffer *buffer3D; 234 235 buffer3D = new OS2IDirectSound3DBuffer(me); 236 *ppvObj = buffer3D; 237 buffer3D->Vtbl.AddRef((IDirectSound3DBuffer *)buffer3D); 238 return DS_OK; 239 } 240 241 return E_NOINTERFACE; 142 242 } 143 243 //****************************************************************************** … … 145 245 ULONG WIN32API SoundBufAddRef(THIS) 146 246 { 147 OS2IDirectSoundBuffer *me = (OS2IDirectSoundBuffer *)This; 148 149 dprintf(("OS2IDirectSoundBuffer::AddRef %d\n", me->Referenced+1)); 150 if(me == NULL) 151 { 152 return 0; 153 } 154 return ++me->Referenced; 247 OS2IDirectSoundBuffer *me = (OS2IDirectSoundBuffer *)This; 248 249 dprintf(("DSOUND-OS2IDirectSoundBuffer::AddRef (buf=%X) %d", me, me->Referenced+1)); 250 if (me == NULL) { 251 return 0; 252 } 253 return ++me->Referenced; 155 254 } 156 255 //****************************************************************************** … … 158 257 ULONG WIN32API SoundBufRelease(THIS) 159 258 { 160 OS2IDirectSoundBuffer *me = (OS2IDirectSoundBuffer *)This; 161 162 dprintf(("OS2IDirectSoundBuffer::Release %d\n", me->Referenced-1)); 163 if(me == NULL) 164 { 165 return 0; 166 } 167 if(me->Referenced) 168 { 169 me->Referenced--; 170 if(me->Referenced == 0) 171 { 172 delete me; 173 return(0); 174 } 175 else 176 return me->Referenced; 177 } 178 else 179 return(0); 259 OS2IDirectSoundBuffer *me = (OS2IDirectSoundBuffer *)This; 260 261 dprintf(("DSOUND-OS2IDirectSoundBuffer::Release (buf=%X) %d", me, me->Referenced-1)); 262 if (me == NULL) { 263 return 0; 264 } 265 if (me->Referenced) { 266 me->Referenced--; 267 if (me->Referenced == 0) { 268 delete me; 269 return 0; 270 } 271 else 272 return me->Referenced; 273 } 274 else 275 return 0; 180 276 } 181 277 //****************************************************************************** … … 183 279 HRESULT __stdcall SoundBufGetCaps(THIS_ LPDSBCAPS lpDSCaps) 184 280 { 185 OS2IDirectSoundBuffer *me = (OS2IDirectSoundBuffer *)This; 186 187 dprintf(("OS2IDirectSoundBuffer::SoundBufGetCaps")); 188 if(me == NULL || lpDSCaps == NULL) 189 { 190 return DSERR_INVALIDPARAM; 191 } 192 return DS_OK; 281 OS2IDirectSoundBuffer *me = (OS2IDirectSoundBuffer *)This; 282 283 dprintf(("DSOUND-OS2IDirectSoundBuffer::SoundBufGetCaps (buf=%X)", me)); 284 if (me == NULL || lpDSCaps == NULL) { 285 return DSERR_INVALIDPARAM; 286 } 287 /* FIXME: fill with more realistic values */ 288 lpDSCaps->dwSize = sizeof(DSBCAPS); 289 lpDSCaps->dwFlags = me->bufferdesc.dwFlags | DSBCAPS_LOCSOFTWARE; 290 lpDSCaps->dwBufferBytes = me->bufferdesc.dwBufferBytes; 291 lpDSCaps->dwUnlockTransferRate = 0; /* in KB/sec - 0 == no transfer needed */ 292 lpDSCaps->dwPlayCpuOverhead = 0; /* % CPU time - let's lie */ 293 294 return DS_OK; 193 295 } 194 296 //****************************************************************************** … … 197 299 LPDWORD lpdwCurrentWriteCursor) 198 300 { 199 OS2IDirectSoundBuffer *me = (OS2IDirectSoundBuffer *)This; 200 201 dprintf(("OS2IDirectSoundBuffer::SoundBufGetCurrentPosition")); 202 if( me == NULL || lpdwCurrentPlayCursor == NULL || lpdwCurrentWriteCursor == NULL) 203 { 204 dprintf((" Invalid parameters %d %d %d",me,lpdwCurrentPlayCursor,lpdwCurrentWriteCursor)); 205 return DSERR_INVALIDPARAM; 206 } 207 208 // Simply advance the bufferpointer according to time; 209 if(me->fPlaying) 210 { 211 ULONG CurrentTicks, Ticks, NewPos; 212 CurrentTicks = GetTickCountOS2(); 213 Ticks = CurrentTicks-me->LastTickCnt; 214 dprintf((" Is Playing, Ticks: Last %d Current %d Difference %d",me->LastTickCnt, CurrentTicks,Ticks)); 215 dprintf((" Frequency: %d Bits per Sample %d",me->frequency,me->lpfxFormat->wBitsPerSample)); 216 217 NewPos = ((me->frequency*Ticks)/1000)*(me->lpfxFormat->wBitsPerSample/8); 218 dprintf((" advance pos by %d bytes",NewPos)); 219 220 if(NewPos) 221 me->LastTickCnt = CurrentTicks; 222 223 if(me->playpos+NewPos >= me->bufferdesc.dwBufferBytes) 224 { 225 if(me->fLoop) 226 { 227 me->playpos = (me->playpos+NewPos) % me->bufferdesc.dwBufferBytes; 228 } 229 else 230 { 231 me->playpos = me->bufferdesc.dwBufferBytes; 232 me->fPlaying = FALSE; 233 } 234 235 } 236 else 237 { 238 me->playpos += NewPos; 239 } 240 me->writepos = me->playpos + 2048; 241 if(me->writepos >= me->bufferdesc.dwBufferBytes) 242 me->writepos = me->writepos % me->bufferdesc.dwBufferBytes; 243 dprintf((" new Pos Write: %d Play: %d",me->writepos,me->playpos)); 244 } 245 else 246 { 247 dprintf((" Buffer Not playing")); 248 } 249 dprintf((" Buffer %d: PlayPos %d, WritePos %d\n",me, me->playpos,me->writepos)); 250 *lpdwCurrentPlayCursor = me->playpos; 251 *lpdwCurrentWriteCursor = me->writepos; 252 return DS_OK; 301 OS2IDirectSoundBuffer *me = (OS2IDirectSoundBuffer *)This; 302 303 dprintf(("DSOUND-OS2IDirectSoundBuffer::SoundBufGetCurrentPosition (buf=%X)", me)); 304 if ( me == NULL || lpdwCurrentPlayCursor == NULL || lpdwCurrentWriteCursor == NULL) { 305 dprintf((" Invalid parameters %d %d %d",me,lpdwCurrentPlayCursor,lpdwCurrentWriteCursor)); 306 return DSERR_INVALIDPARAM; 307 } 308 309 dprintf((" PlayPos %d, WritePos %d", me->playpos, me->writepos)); 310 *lpdwCurrentPlayCursor = me->playpos; 311 *lpdwCurrentWriteCursor = me->writepos; 312 return DS_OK; 253 313 } 254 314 //****************************************************************************** … … 257 317 DWORD ddwSizeAllocated, LPDWORD lpdwSizeWritten) 258 318 { 259 OS2IDirectSoundBuffer *me = (OS2IDirectSoundBuffer *)This; 260 int copysize; 261 262 dprintf(("OS2IDirectSoundBuffer::SoundBufGetFormat")); 263 if( me == NULL || lpwfxFormat == NULL || ddwSizeAllocated == 0) 264 { 265 return DSERR_INVALIDPARAM; 266 } 267 copysize = min(ddwSizeAllocated, (me->lpfxFormat->cbSize + sizeof(WAVEFORMATEX))); 268 memcpy(lpwfxFormat, me->lpfxFormat, copysize); 269 270 if(lpdwSizeWritten) 271 { 272 *lpdwSizeWritten = copysize; 273 } 274 return DS_OK; 319 OS2IDirectSoundBuffer *me = (OS2IDirectSoundBuffer *)This; 320 int copysize; 321 322 dprintf(("DSOUND-OS2IDirectSoundBuffer::SoundBufGetFormat (buf=%X)", me)); 323 if (me == NULL || lpwfxFormat == NULL || ddwSizeAllocated == 0) { 324 return DSERR_INVALIDPARAM; 325 } 326 copysize = min(ddwSizeAllocated, (me->lpfxFormat->cbSize + sizeof(WAVEFORMATEX))); 327 memcpy(lpwfxFormat, me->lpfxFormat, copysize); 328 329 if (lpdwSizeWritten) { 330 *lpdwSizeWritten = copysize; 331 } 332 return DS_OK; 275 333 } 276 334 //****************************************************************************** … … 278 336 HRESULT __stdcall SoundBufGetVolume(THIS_ LPLONG lplVolume) 279 337 { 280 OS2IDirectSoundBuffer *me = (OS2IDirectSoundBuffer *)This; 281 282 dprintf(("OS2IDirectSoundBuffer::SoundBufGetVolume")); 283 if(me == NULL || lplVolume == NULL) 284 { 285 return DSERR_INVALIDPARAM; 286 } 287 *lplVolume = me->volume; 288 return DS_OK; 338 OS2IDirectSoundBuffer *me = (OS2IDirectSoundBuffer *)This; 339 340 dprintf(("DSOUND-OS2IDirectSoundBuffer::SoundBufGetVolume (buf=%X)", me)); 341 if (me == NULL || lplVolume == NULL) { 342 return DSERR_INVALIDPARAM; 343 } 344 *lplVolume = me->DSvolume; 345 return DS_OK; 289 346 } 290 347 //****************************************************************************** … … 292 349 HRESULT __stdcall SoundBufGetPan(THIS_ LPLONG lplPan) 293 350 { 294 OS2IDirectSoundBuffer *me = (OS2IDirectSoundBuffer *)This; 295 296 dprintf(("OS2IDirectSoundBuffer::SoundBufGetPan")); 297 if(me == NULL || lplPan == NULL) 298 { 299 return DSERR_INVALIDPARAM; 300 } 301 *lplPan = me->pan; 302 return DS_OK; 351 OS2IDirectSoundBuffer *me = (OS2IDirectSoundBuffer *)This; 352 353 dprintf(("DSOUND-OS2IDirectSoundBuffer::SoundBufGetPan (buf=%X)", me)); 354 if (me == NULL || lplPan == NULL) { 355 return DSERR_INVALIDPARAM; 356 } 357 *lplPan = me->DSpan; 358 return DS_OK; 303 359 } 304 360 //****************************************************************************** … … 306 362 HRESULT __stdcall SoundBufGetFrequency(THIS_ LPDWORD lpdwFrequency) 307 363 { 308 OS2IDirectSoundBuffer *me = (OS2IDirectSoundBuffer *)This; 309 310 dprintf(("OS2IDirectSoundBuffer::SoundBufGetFrequency")); 311 if(me == NULL || lpdwFrequency == NULL) 312 { 313 return DSERR_INVALIDPARAM; 314 } 315 *lpdwFrequency = me->frequency; 316 return DS_OK; 364 OS2IDirectSoundBuffer *me = (OS2IDirectSoundBuffer *)This; 365 366 dprintf(("DSOUND-OS2IDirectSoundBuffer::SoundBufGetFrequency (buf=%X)", me)); 367 if (me == NULL || lpdwFrequency == NULL) { 368 return DSERR_INVALIDPARAM; 369 } 370 *lpdwFrequency = me->frequency; 371 return DS_OK; 317 372 } 318 373 //****************************************************************************** … … 320 375 HRESULT __stdcall SoundBufGetStatus(THIS_ LPDWORD lpdwStatus) 321 376 { 322 OS2IDirectSoundBuffer *me = (OS2IDirectSoundBuffer *)This; 323 324 dprintf(("OS2IDirectSoundBuffer::SoundBufGetStatus")); 325 if(me == NULL || lpdwStatus == NULL) 326 { 327 return DSERR_INVALIDPARAM; 328 } 329 *lpdwStatus = me->status; 330 return DS_OK; 377 OS2IDirectSoundBuffer *me = (OS2IDirectSoundBuffer *)This; 378 379 dprintf(("DSOUND-OS2IDirectSoundBuffer::SoundBufGetStatus (buf=%X)", me)); 380 if (me == NULL || lpdwStatus == NULL) { 381 return DSERR_INVALIDPARAM; 382 } 383 384 if (me->fPlaying) 385 if (me->fLoop) 386 me->status |= DSBSTATUS_PLAYING | DSBSTATUS_LOOPING; 387 else 388 me->status |= DSBSTATUS_PLAYING; 389 else 390 me->status &= ~(DSBSTATUS_PLAYING | DSBSTATUS_LOOPING); 391 392 *lpdwStatus = me->status; 393 return DS_OK; 331 394 } 332 395 //****************************************************************************** … … 334 397 HRESULT __stdcall SoundBufInitialize(THIS_ LPDIRECTSOUND, LPDSBUFFERDESC ) 335 398 { 336 OS2IDirectSoundBuffer *me = (OS2IDirectSoundBuffer *)This; 337 338 dprintf(("SoundBufInitialize")); 339 if(me == NULL) 340 { 341 return DSERR_INVALIDPARAM; 342 } 343 return DSERR_ALREADYINITIALIZED; //todo: for future extensions (dx5/6 ??) 399 OS2IDirectSoundBuffer *me = (OS2IDirectSoundBuffer *)This; 400 401 dprintf(("DSOUND-SoundBufInitialize (buf=%X)", me)); 402 if (me == NULL) { 403 return DSERR_INVALIDPARAM; 404 } 405 return DSERR_ALREADYINITIALIZED; //todo: for future extensions (dx5/6 ??) 344 406 } 345 407 //****************************************************************************** … … 350 412 DWORD dwFlags) 351 413 { 352 OS2IDirectSoundBuffer *me = (OS2IDirectSoundBuffer *)This; 353 354 dprintf(("OS2IDirectSoundBuffer::SoundBufLock")); 355 if(me == NULL || !lplpvAudioPtr1 || !lpdwAudioBytes1) 356 { 357 return(DSERR_INVALIDPARAM); 358 } 359 //not sure if this is an error, but it's certainly a smart thing to do (cond. == true) 360 if(dwWriteBytes > me->bufferdesc.dwBufferBytes) 361 { 362 dprintf(("SoundBufLock: dwWriteBytes > me->bufferdesc.dwBufferBytes")); 363 return(DSERR_INVALIDPARAM); 364 } 365 if(dwFlags & DSBLOCK_FROMWRITECURSOR) 366 { 367 dwWriteCursor = me->writepos; 368 } 369 dprintf((" Buffer at 0x%08X Size %d",me->lpBuffer,me->bufferdesc.dwBufferBytes)); 370 if(dwWriteCursor + dwWriteBytes > me->bufferdesc.dwBufferBytes ) 371 { 372 *(DWORD *)lplpvAudioPtr1 = (DWORD)(me->lpBuffer + dwWriteCursor); 373 *lpdwAudioBytes1 = me->bufferdesc.dwBufferBytes - dwWriteCursor; 374 dprintf((" Lock1 at 0x%08X Size %d",*(DWORD *)lplpvAudioPtr1,*lpdwAudioBytes1)); 375 if(lplpvAudioPtr2 && lpdwAudioBytes2) 376 { 377 *(DWORD *)lplpvAudioPtr2 = (DWORD)me->lpBuffer; 378 *lpdwAudioBytes2 = dwWriteBytes - *lpdwAudioBytes1; 379 dprintf((" Lock2 at 0x%08X Size %d",*(DWORD *)lplpvAudioPtr2,*lpdwAudioBytes2)); 380 } 381 } 382 else 383 { 384 *(DWORD *)lplpvAudioPtr1 = (DWORD)(me->lpBuffer + dwWriteCursor); 385 *lpdwAudioBytes1 = dwWriteBytes; 386 dprintf((" Lock1 at 0x%08X Size %d",*(DWORD *)lplpvAudioPtr1,*lpdwAudioBytes1)); 387 if(lplpvAudioPtr2 && lpdwAudioBytes2) 388 { 389 *(DWORD *)lplpvAudioPtr2 = 0; 390 *lpdwAudioBytes2 = 0; 391 dprintf((" Lock2 at 0x%08X Size %d",*(DWORD *)lplpvAudioPtr2,*lpdwAudioBytes2)); 392 } 393 } 394 me->fLocked = TRUE; 395 return DS_OK; 396 } 397 //****************************************************************************** 398 //****************************************************************************** 399 HRESULT __stdcall SoundBufPlay(THIS_ DWORD dwRes1,DWORD dwRes2,DWORD dwFlags) 400 { 401 OS2IDirectSoundBuffer *me = (OS2IDirectSoundBuffer *)This; 402 403 dprintf(("OS2IDirectSoundBuffer::SoundBufPlay")); 404 if(me == NULL) 405 { 406 dprintf((" Invalid parms me is NULL\n")); 407 return DSERR_INVALIDPARAM; 408 } 409 me->fPlaying = TRUE; 410 me->fLoop = dwFlags == DSBPLAY_LOOPING; 411 me->LastTickCnt = GetTickCountOS2(); 412 dprintf((" Buffer %d: Start at Tick %d Loop %s",me,me->LastTickCnt,me->fLoop?"YES":"NO")); 413 return DS_OK; 414 } 414 OS2IDirectSoundBuffer *me = (OS2IDirectSoundBuffer *)This; 415 416 dprintf(("DSOUND-OS2IDirectSoundBuffer::SoundBufLock (buf=%X, %d bytes of %d)", me, dwWriteBytes, me->bufferdesc.dwBufferBytes)); 417 if (me == NULL || !lplpvAudioPtr1 || !lpdwAudioBytes1) 418 return DSERR_INVALIDPARAM; 419 420 //not sure if this is an error, but it's certainly a smart thing to do (cond. == true) 421 if(dwWriteBytes > me->bufferdesc.dwBufferBytes) { 422 dprintf(("SoundBufLock: dwWriteBytes > me->bufferdesc.dwBufferBytes")); 423 return DSERR_INVALIDPARAM; 424 } 425 if (dwFlags & DSBLOCK_FROMWRITECURSOR) { 426 dwWriteCursor = me->writepos; 427 } 428 if (dwWriteCursor + dwWriteBytes > me->bufferdesc.dwBufferBytes) { 429 *(DWORD *)lplpvAudioPtr1 = (DWORD)(me->lpBuffer + dwWriteCursor); 430 *lpdwAudioBytes1 = me->bufferdesc.dwBufferBytes - dwWriteCursor; 431 if (lplpvAudioPtr2 && lpdwAudioBytes2) { 432 *(DWORD *)lplpvAudioPtr2 = (DWORD)me->lpBuffer; 433 *lpdwAudioBytes2 = dwWriteBytes - *lpdwAudioBytes1; 434 } 435 } 436 else { 437 *(DWORD *)lplpvAudioPtr1 = (DWORD)(me->lpBuffer + dwWriteCursor); 438 *lpdwAudioBytes1 = dwWriteBytes; 439 if (lplpvAudioPtr2 && lpdwAudioBytes2) { 440 *(DWORD *)lplpvAudioPtr2 = 0; 441 *lpdwAudioBytes2 = 0; 442 } 443 } 444 445 me->fLocked = TRUE; 446 447 return DS_OK; 448 } 449 450 //****************************************************************************** 451 //****************************************************************************** 452 HRESULT __stdcall SoundBufPlay(THIS_ DWORD dwRes1, DWORD dwRes2, DWORD dwFlags) 453 { 454 OS2IDirectSoundBuffer *me = (OS2IDirectSoundBuffer *)This; 455 456 ULONG ulBytesToPlay; 457 458 dprintf(("DSOUND-OS2IDirectSoundBuffer::SoundBufPlay (buf=%X)", me)); 459 if (me == NULL) { 460 dprintf((" Invalid parms - me is NULL")); 461 return DSERR_INVALIDPARAM; 462 } 463 464 if (!me->fPlaying) { 465 me->frac = 0; 466 me->fPlaying = TRUE; 467 me->status = DSBSTATUS_PLAYING; 468 me->fLoop = dwFlags == DSBPLAY_LOOPING; 469 if (me->fLoop) 470 me->status |= DSBSTATUS_LOOPING; 471 472 dprintf((" Buffer %X: start at pos %d, loop %s",me, me->playpos, me->fLoop?"YES":"NO")); 473 } 474 else { 475 me->fLoop = dwFlags == DSBPLAY_LOOPING; 476 if (me->fLoop) 477 me->status |= DSBSTATUS_LOOPING; 478 479 dprintf((" Buffer %X: already playing, loop %s",me, me->fLoop?"YES":"NO")); 480 } 481 482 return DS_OK; 483 } 484 415 485 //****************************************************************************** 416 486 //****************************************************************************** 417 487 HRESULT __stdcall SoundBufSetCurrentPosition(THIS_ DWORD dwNewPosition) 418 488 { 419 OS2IDirectSoundBuffer *me = (OS2IDirectSoundBuffer *)This; 420 421 dprintf(("OS2IDirectSoundBuffer::SoundBufSetCurrentPosition")); 422 if(me == NULL) 423 { 424 return DSERR_INVALIDPARAM; 425 } 426 //todo: check for primary buffer (can't do it with those) 427 me->playpos = dwNewPosition; 428 me->writepos = dwNewPosition; 429 return DS_OK; 430 } 431 //****************************************************************************** 432 //****************************************************************************** 433 HRESULT __stdcall SoundBufSetFormat(THIS_ LPWAVEFORMATEX ) 434 { 435 OS2IDirectSoundBuffer *me = (OS2IDirectSoundBuffer *)This; 436 437 dprintf(("OS2IDirectSoundBuffer::SoundBufSetFormat")); 438 if(me == NULL) 439 { 440 return DSERR_INVALIDPARAM; 441 } 442 return DS_OK; 443 } 489 OS2IDirectSoundBuffer *me = (OS2IDirectSoundBuffer *)This; 490 491 dprintf(("DSOUND-OS2IDirectSoundBuffer::SoundBufSetCurrentPosition (buf=%X) to %d", me, dwNewPosition)); 492 if (me == NULL) { 493 return DSERR_INVALIDPARAM; 494 } 495 me->playpos = dwNewPosition; 496 497 return DS_OK; 498 } 499 500 //****************************************************************************** 501 //****************************************************************************** 502 HRESULT __stdcall SoundBufSetFormat(THIS_ LPWAVEFORMATEX lpWaveFormatEx) 503 { 504 OS2IDirectSoundBuffer *me = (OS2IDirectSoundBuffer *)This; 505 506 // Note: this sets the format of the _primary_ buffer; 507 // since this class only handles secondary buffers, we just return error 508 dprintf(("DSOUND-OS2IDirectSoundBuffer::SoundBufSetFormat (buf=%X)", me)); 509 510 return DSERR_UNSUPPORTED; 511 } 512 444 513 //****************************************************************************** 445 514 //****************************************************************************** 446 515 HRESULT __stdcall SoundBufSetVolume(THIS_ LONG lVolume) 447 516 { 448 OS2IDirectSoundBuffer *me = (OS2IDirectSoundBuffer *)This; 449 450 dprintf(("OS2IDirectSoundBuffer::SoundBufSetVolume")); 451 if(me == NULL) 452 { 453 return DSERR_INVALIDPARAM; 454 } 455 me->volume = lVolume; 456 return DS_OK; 517 OS2IDirectSoundBuffer *me = (OS2IDirectSoundBuffer *)This; 518 519 dprintf(("DSOUND-OS2IDirectSoundBuffer::SoundBufSetVolume (%d, buf=%X)", lVolume, me)); 520 if (me == NULL || lVolume < -10000) { 521 return DSERR_INVALIDPARAM; 522 } 523 // some apps pass positive values in lVolume, that's wrong right?!? 524 me->DSvolume = (lVolume > 0) ? 0 : lVolume; 525 526 /* = (10 ^ (1/10)) = 1dB - but the formula below gives results _very_ similar */ 527 /* to 'real' DirectSound, indistinguishable for all practical purposes */ 528 //me->volume = 255.0 * pow(4, me->DSvolume / 1000.0); 529 530 /* Note: for some strange reason the above code sometimes gives erroneous */ 531 /* results, hence we now use a simple conversion table (in steps of 4/100 dB) */ 532 533 if (me->DSvolume < -4000) 534 me->volume = 0; 535 else 536 me->volume = VolTable[-me->DSvolume / 4]; 537 538 dprintf((" New volume: %d", me->volume)); 539 540 return DS_OK; 457 541 } 458 542 //****************************************************************************** … … 460 544 HRESULT __stdcall SoundBufSetPan(THIS_ LONG lPan) 461 545 { 462 OS2IDirectSoundBuffer *me = (OS2IDirectSoundBuffer *)This; 463 464 dprintf(("OS2IDirectSoundBuffer::SoundBufSetPan")); 465 if(me == NULL) 466 { 467 return DSERR_INVALIDPARAM; 468 } 469 me->pan = lPan; 470 return DS_OK; 471 } 546 OS2IDirectSoundBuffer *me = (OS2IDirectSoundBuffer *)This; 547 548 dprintf(("DSOUND-OS2IDirectSoundBuffer::SoundBufSetPan (%d, buf=%X)", lPan, me)); 549 if (me == NULL || lPan < -10000 || lPan > 10000) { 550 return DSERR_INVALIDPARAM; 551 } 552 me->DSpan = lPan; 553 if (lPan == 0) { 554 me->pan = 0; 555 return DS_OK; 556 } 557 558 /* Note: we use very similar code as for volume above */ 559 if (lPan < 0) 560 if (lPan < -4000) 561 me->pan = -255; 562 else 563 me->pan = VolTable[-lPan / 4] - 255; 564 else 565 if (lPan > 4000) 566 me->pan = 255; 567 else 568 me->pan = 255 - VolTable[lPan / 4]; 569 570 dprintf((" New pan: %d", me->pan)); 571 572 return DS_OK; 573 } 574 472 575 //****************************************************************************** 473 576 //****************************************************************************** 474 577 HRESULT __stdcall SoundBufSetFrequency(THIS_ DWORD dwFrequency) 475 578 { 476 OS2IDirectSoundBuffer *me = (OS2IDirectSoundBuffer *)This; 477 478 dprintf(("OS2IDirectSoundBuffer::SoundBufSetFrequency")); 479 if(me == NULL) 480 { 481 return DSERR_INVALIDPARAM; 482 } 483 me->frequency = dwFrequency; 484 return DS_OK; 485 } 579 OS2IDirectSoundBuffer *me = (OS2IDirectSoundBuffer *)This; 580 581 dprintf(("DSOUND-OS2IDirectSoundBuffer::SoundBufSetFrequency (buf=%X)", me)); 582 if (me == NULL) { 583 return DSERR_INVALIDPARAM; 584 } 585 586 // zero means default (buffer format) frequency 587 if (dwFrequency) 588 me->frequency = dwFrequency; 589 else 590 me->frequency = me->lpfxFormat->nSamplesPerSec; 591 592 return DS_OK; 593 } 594 486 595 //****************************************************************************** 487 596 //****************************************************************************** 488 597 HRESULT __stdcall SoundBufStop(THIS ) 489 598 { 490 OS2IDirectSoundBuffer *me = (OS2IDirectSoundBuffer *)This; 491 492 dprintf(("OS2IDirectSoundBuffer::SoundBufStop")); 493 if(me == NULL) 494 { 495 return DSERR_INVALIDPARAM; 496 } 497 // Simply advance the bufferpointer according to time; 498 if(me->fPlaying) 499 { 500 ULONG CurrentTicks, Ticks, NewPos; 501 CurrentTicks = GetTickCountOS2(); 502 503 Ticks = CurrentTicks - me->LastTickCnt; 504 me->LastTickCnt = CurrentTicks; 505 506 NewPos = ((me->frequency*Ticks)/1000)*(me->lpfxFormat->wBitsPerSample>>8); 507 if(me->playpos+NewPos >= me->bufferdesc.dwBufferBytes) 508 { 509 if(me->fLoop) 510 { 511 me->playpos = (me->playpos+NewPos % me->bufferdesc.dwBufferBytes); 512 } 513 else 514 { 515 me->playpos = me->bufferdesc.dwBufferBytes; 516 me->fPlaying = FALSE; 517 } 518 519 } 520 else 521 { 522 me->playpos += NewPos; 523 } 524 me->writepos = me->playpos + 2048; 525 if(me->writepos >= me->bufferdesc.dwBufferBytes) 526 me->writepos = me->writepos % me->bufferdesc.dwBufferBytes; 527 528 me->fPlaying = FALSE; 529 530 } 531 return DS_OK; 532 } 533 //****************************************************************************** 534 //****************************************************************************** 535 HRESULT __stdcall SoundBufUnlock(THIS_ LPVOID,DWORD,LPVOID,DWORD ) 536 { 537 OS2IDirectSoundBuffer *me = (OS2IDirectSoundBuffer *)This; 538 539 dprintf(("OS2IDirectSoundBuffer::SoundBufUnlock")); 540 if(me == NULL) 541 { 542 return DSERR_INVALIDPARAM; 543 } 544 545 return DS_OK; 546 } 599 OS2IDirectSoundBuffer *me = (OS2IDirectSoundBuffer *)This; 600 601 dprintf(("DSOUND-OS2IDirectSoundBuffer::SoundBufStop (buf=%X)", me)); 602 if (me == NULL) { 603 return DSERR_INVALIDPARAM; 604 } 605 606 me->fPlaying = FALSE; 607 me->status &= ~(DSBSTATUS_PLAYING | DSBSTATUS_LOOPING); 608 609 if (me->notify != NULL) 610 me->notify->CheckStop(); 611 612 return DS_OK; 613 } 614 615 //****************************************************************************** 616 //****************************************************************************** 617 HRESULT __stdcall SoundBufUnlock(THIS_ 618 LPVOID lpvAudioPtr1, DWORD dwAudioBytes1, 619 LPVOID lpvAudioPtr2, DWORD dwAudioBytes2) 620 { 621 OS2IDirectSoundBuffer *me = (OS2IDirectSoundBuffer *)This; 622 623 dprintf(("DSOUND-OS2IDirectSoundBuffer::SoundBufUnlock (buf=%X)", me)); 624 if (me == NULL) { 625 return DSERR_INVALIDPARAM; 626 } 627 628 me->fLocked = TRUE; 629 630 return DS_OK; 631 } 632 547 633 //****************************************************************************** 548 634 //****************************************************************************** 549 635 HRESULT __stdcall SoundBufRestore(THIS ) 550 636 { 551 OS2IDirectSoundBuffer *me = (OS2IDirectSoundBuffer *)This; 552 553 dprintf(("OS2IDirectSoundBuffer::SoundBufRestore")); 554 if(me == NULL) 555 { 556 return DSERR_INVALIDPARAM; 557 } 558 return DS_OK; 559 } 560 //****************************************************************************** 561 //****************************************************************************** 637 OS2IDirectSoundBuffer *me = (OS2IDirectSoundBuffer *)This; 638 639 dprintf(("DSOUND-OS2IDirectSoundBuffer::SoundBufRestore (buf=%X)", me)); 640 if (me == NULL) { 641 return DSERR_INVALIDPARAM; 642 } 643 return DS_OK; 644 } 645 //****************************************************************************** 646 //****************************************************************************** -
trunk/src/dsound/OS2SNDBUFFER.H
r1744 r3099 1 /* $Id: OS2SNDBUFFER.H,v 1. 5 1999-11-14 22:12:15 hughExp $ */1 /* $Id: OS2SNDBUFFER.H,v 1.6 2000-03-13 12:47:48 sandervl Exp $ */ 2 2 3 3 /* … … 12 12 #define __OS2SNDBUFFER_H__ 13 13 14 #include <mmsystem.h>15 16 14 #undef THIS 17 15 #define THIS VOID*This … … 19 17 #undef THIS_ 20 18 #define THIS_ VOID*This, 19 20 // a forward declaration of some classes is needed here! 21 class OS2IDirectSoundNotify; 22 class OS2IDirectSound3DBuffer; 21 23 22 24 class OS2IDirectSoundBuffer … … 27 29 IDirectSoundBufferVtbl Vtbl; 28 30 29 OS2IDirectSoundBuffer(const DSBUFFERDESC *lpDSBufferDesc);//KSO Apr 13 1999: const, SDK changes 31 OS2IDirectSoundBuffer(OS2IDirectSound *DSound, const DSBUFFERDESC *lpDSBufferDesc); 32 OS2IDirectSoundBuffer() {}; 30 33 ~OS2IDirectSoundBuffer(); 34 35 static void OS2IDirectSoundBuffer::DestroyAllBuffers(); // called when DSound is closed 31 36 32 37 int Referenced; 33 38 inline HRESULT GetLastError() { return lastError; }; 34 39 inline void SetNotify(OS2IDirectSoundNotify *_notify) { 40 notify = _notify; }; 41 inline void Set3DBuffer(OS2IDirectSound3DBuffer *_buffer3D) { 42 buffer3D = _buffer3D; }; 35 43 private: 36 44 … … 38 46 HRESULT lastError; 39 47 40 LONG pan; 41 ULONG writepos, playpos; 42 ULONG frequency; 43 WAVEFORMATEX *lpfxFormat; 44 ULONG status; 45 ULONG fLocked; 46 LONG volume; 47 BOOL fPlaying,fLoop; 48 DSBUFFERDESC bufferdesc; 49 // for NIL Emulation 50 ULONG newWritePos; 51 DWORD LastTickCnt; 48 ULONG writepos, playpos; // DSound write and play cursors 49 ULONG frequency; // DSB frequency - may differ from source sample 50 WAVEFORMATEX *lpfxFormat; // source sample format 51 ULONG status; // DSB status - playing, looping etc. 52 BOOL fLocked; // is buffer currently locked? 53 BOOL fPrimary; // is this a primary buffer? 54 LONG DSvolume; // DSB volume (in dB) 55 LONG volume; // volume (linear) 56 LONG DSpan; // DSB pan (in dB) 57 LONG pan; // pan (linear) 58 BOOL fPlaying,fLoop; // is buffer playing/looping? 59 DSBUFFERDESC bufferdesc; // DSB description 60 LONG frac; // saved mixer position overflow 52 61 53 char *lpBuffer; 62 char *lpBuffer; // sound data 63 64 OS2IDirectSoundNotify* notify; // pointer to the associated Notify object (if exists) 65 OS2IDirectSound3DBuffer* buffer3D; // pointer to the associated 3DBuffer object (if exists) 66 OS2IDirectSound* parentDS; 54 67 55 68 // Linked list management 56 OS2IDirectSoundBuffer* next; // Next OS2IDirectSound 57 static OS2IDirectSoundBuffer* dsound; // List of OS2IDirectSound 69 OS2IDirectSoundBuffer* next; // Next OS2IDirectSoundBuffer 70 static OS2IDirectSoundBuffer* dsbroot; // List of OS2IDirectSoundBuffers 71 static OS2IDirectSoundBuffer* primary; // The primary SoundBuffer 58 72 59 73 friend HRESULT __stdcall SoundBufQueryInterface(THIS, REFIID riid, LPVOID * ppvObj); … … 78 92 friend HRESULT __stdcall SoundBufUnlock(THIS_ LPVOID,DWORD,LPVOID,DWORD ) ; 79 93 friend HRESULT __stdcall SoundBufRestore(THIS ) ; 94 95 friend void MixCallback(ULONG cbMix); 96 friend void MixFunc (OS2IDirectSoundBuffer *firstBuf, OS2IDirectSoundBuffer *outBuf, ULONG cbMix); 97 friend void MixOneBuffer(OS2IDirectSoundBuffer *inBuf, int tomix, int outrate); 80 98 }; 81 99 //****************************************************************************** -
trunk/src/dsound/dsoundrsrc.orc
r3031 r3099 1 /* $Id: dsoundrsrc.orc,v 1. 1 2000-03-06 23:38:37 birdExp $ */1 /* $Id: dsoundrsrc.orc,v 1.2 2000-03-13 12:47:52 sandervl Exp $ */ 2 2 3 3 #include "winuser.h" -
trunk/src/dsound/initterm.cpp
r2650 r3099 1 /* $Id: initterm.cpp,v 1. 9 2000-02-05 01:58:50sandervl Exp $ */1 /* $Id: initterm.cpp,v 1.10 2000-03-13 12:47:52 sandervl Exp $ */ 2 2 3 3 /* -
trunk/src/dsound/initterm.h
r1456 r3099 1 /* $Id: initterm.h,v 1. 1 1999-10-26 17:53:43sandervl Exp $ */1 /* $Id: initterm.h,v 1.2 2000-03-13 12:47:52 sandervl Exp $ */ 2 2 /* 3 3 * KERNEL32 DLL entry point header -
trunk/src/dsound/makefile
r3031 r3099 1 # $Id: makefile,v 1.1 7 2000-03-06 23:38:37 birdExp $1 # $Id: makefile,v 1.18 2000-03-13 12:47:53 sandervl Exp $ 2 2 3 3 # … … 28 28 $(OBJDIR)\initterm.obj \ 29 29 $(OBJDIR)\os2sndbuffer.obj \ 30 $(OBJDIR)\os2helper.obj \ 30 $(OBJDIR)\os2primbuff.obj \ 31 $(OBJDIR)\os2notify.obj \ 32 $(OBJDIR)\os23dlistener.obj \ 33 $(OBJDIR)\os23dbuffer.obj \ 34 $(OBJDIR)\dart.obj \ 35 $(OBJDIR)\dsmixer.obj \ 31 36 $(OBJDIR)\dsoundrsrc.obj 32 37 … … 61 66 $(PDWIN32_LIB)/kernel32.lib 62 67 $(PDWIN32_LIB)/odincrt.lib 68 $(PDWIN32_LIB)/ole32.lib 69 mmpm2.lib 63 70 OS2386.LIB 64 71 $(RTLLIB_O)
Note:
See TracChangeset
for help on using the changeset viewer.