| 1 | /* $Id: DAudioBuffer.cpp,v 1.1 2001-04-27 17:39:48 sandervl Exp $ */
|
|---|
| 2 |
|
|---|
| 3 | /*
|
|---|
| 4 | * DirectSound SoundBuffer (secondary) class (DirectAudio)
|
|---|
| 5 | *
|
|---|
| 6 | * Copyright 1998-2001 Sander van Leeuwen (sandervl@xs4all.nl)
|
|---|
| 7 | * Copyright 2001 Michal Necasek
|
|---|
| 8 | *
|
|---|
| 9 | * Project Odin Software License can be found in LICENSE.TXT
|
|---|
| 10 | *
|
|---|
| 11 | */
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 | /*@Header***********************************************************************
|
|---|
| 15 | * Header Files *
|
|---|
| 16 | *******************************************************************************/
|
|---|
| 17 | #include <os2win.h>
|
|---|
| 18 |
|
|---|
| 19 | #include <stdlib.h>
|
|---|
| 20 | #include <string.h>
|
|---|
| 21 |
|
|---|
| 22 | #define INITGUID
|
|---|
| 23 | #include <dsound.h>
|
|---|
| 24 |
|
|---|
| 25 | #include "OS2DSound.h"
|
|---|
| 26 | #include "DAudioBuffer.h"
|
|---|
| 27 | #include "OS2PrimBuff.h"
|
|---|
| 28 | #include "OS23DListener.h"
|
|---|
| 29 | #include "OS23DBuffer.h"
|
|---|
| 30 | #include "DAudioNotify.h"
|
|---|
| 31 | #include <misc.h>
|
|---|
| 32 |
|
|---|
| 33 | extern BYTE VolTable[1000];
|
|---|
| 34 |
|
|---|
| 35 | IDirectAudioBuffer *IDirectAudioBuffer::dsbroot = NULL;
|
|---|
| 36 |
|
|---|
| 37 | //******************************************************************************
|
|---|
| 38 | //******************************************************************************
|
|---|
| 39 | IDirectAudioBuffer::IDirectAudioBuffer(OS2IDirectSound *DSound, const DSBUFFERDESC *lpDSBufferDesc)
|
|---|
| 40 | : Referenced(0), lastError(DS_OK), daudio(NULL), lpSndBuffer(NULL)
|
|---|
| 41 | {
|
|---|
| 42 | //This is the "normal" constructor
|
|---|
| 43 | lpVtbl = &Vtbl;
|
|---|
| 44 | Vtbl.AddRef = DAudioBufAddRef;
|
|---|
| 45 | Vtbl.Release = DAudioBufRelease;
|
|---|
| 46 | Vtbl.QueryInterface = DAudioBufQueryInterface;
|
|---|
| 47 | Vtbl.GetCaps = DAudioBufGetCaps;
|
|---|
| 48 | Vtbl.GetFormat = DAudioBufGetFormat;
|
|---|
| 49 | Vtbl.GetVolume = DAudioBufGetVolume;
|
|---|
| 50 | Vtbl.GetStatus = DAudioBufGetStatus;
|
|---|
| 51 | Vtbl.GetCurrentPosition = DAudioBufGetCurrentPosition;
|
|---|
| 52 | Vtbl.GetPan = DAudioBufGetPan;
|
|---|
| 53 | Vtbl.GetFrequency = DAudioBufGetFrequency;
|
|---|
| 54 | Vtbl.Initialize = DAudioBufInitialize;
|
|---|
| 55 | Vtbl.Restore = DAudioBufRestore;
|
|---|
| 56 | Vtbl.SetFormat = DAudioBufSetFormat;
|
|---|
| 57 | Vtbl.SetVolume = DAudioBufSetVolume;
|
|---|
| 58 | Vtbl.SetCurrentPosition = DAudioBufSetCurrentPosition;
|
|---|
| 59 | Vtbl.SetPan = DAudioBufSetPan;
|
|---|
| 60 | Vtbl.SetFrequency = DAudioBufSetFrequency;
|
|---|
| 61 | Vtbl.Lock = DAudioBufLock;
|
|---|
| 62 | Vtbl.Unlock = DAudioBufUnlock;
|
|---|
| 63 | Vtbl.Stop = DAudioBufStop;
|
|---|
| 64 | Vtbl.Play = DAudioBufPlay;
|
|---|
| 65 |
|
|---|
| 66 | dprintf(("DSOUND-IDirectAudioBuffer::IDirectAudioBuffer (buf=%X)", this));
|
|---|
| 67 |
|
|---|
| 68 | parentDS = DSound;
|
|---|
| 69 | writepos = 0;
|
|---|
| 70 | playpos = 0;
|
|---|
| 71 | status = 0;
|
|---|
| 72 | fLocked = FALSE;
|
|---|
| 73 | volume = 255;
|
|---|
| 74 | DSvolume = 0;
|
|---|
| 75 | pan = 0;
|
|---|
| 76 | DSpan = 0;
|
|---|
| 77 | lpfxFormat= NULL;
|
|---|
| 78 | fPlaying = FALSE;
|
|---|
| 79 | fLoop = FALSE;
|
|---|
| 80 | notify = NULL;
|
|---|
| 81 | memcpy(&bufferdesc, lpDSBufferDesc, sizeof(DSBUFFERDESC));
|
|---|
| 82 |
|
|---|
| 83 | // frequency has to be set according to the bufer format
|
|---|
| 84 | frequency = bufferdesc.lpwfxFormat->nSamplesPerSec;
|
|---|
| 85 |
|
|---|
| 86 | if (bufferdesc.lpwfxFormat == NULL || bufferdesc.dwBufferBytes == 0) {
|
|---|
| 87 | dprintf(("bufferdesc not valid!"));
|
|---|
| 88 | lastError = DSERR_INVALIDPARAM;
|
|---|
| 89 | return;
|
|---|
| 90 | }
|
|---|
| 91 |
|
|---|
| 92 | // Some apps pass trash in cbSize, can't rely on that!
|
|---|
| 93 | lpfxFormat = (WAVEFORMATEX *)malloc(/*bufferdesc.lpwfxFormat->cbSize +*/ sizeof(WAVEFORMATEX));
|
|---|
| 94 | memcpy(lpfxFormat, bufferdesc.lpwfxFormat, /*bufferdesc.lpwfxFormat->cbSize + */sizeof(WAVEFORMATEX));
|
|---|
| 95 |
|
|---|
| 96 | dprintf((" Buffer format: %dHz, %dbit, %d channels", lpfxFormat->nSamplesPerSec, lpfxFormat->wBitsPerSample, lpfxFormat->nChannels));
|
|---|
| 97 |
|
|---|
| 98 | lpSndBuffer = (SOUNDBUF *)VirtualAlloc(0, bufferdesc.dwBufferBytes + sizeof(DWORD), MEM_COMMIT, PAGE_READWRITE);
|
|---|
| 99 | if (lpSndBuffer == NULL) {
|
|---|
| 100 | dprintf(("VirtualAlloc failed"));
|
|---|
| 101 | lpSndBuffer = NULL;
|
|---|
| 102 | lastError = DSERR_OUTOFMEMORY;
|
|---|
| 103 | return;
|
|---|
| 104 | }
|
|---|
| 105 | lpBuffer = &(lpSndBuffer->pData[0]);
|
|---|
| 106 | lpSndBuffer->dwReferences = 1;
|
|---|
| 107 |
|
|---|
| 108 | daudio = new DAudioWaveOut(lpfxFormat);
|
|---|
| 109 | if(daudio == NULL || daudio->getError()) {
|
|---|
| 110 | dprintf(("DAudioWaveOut ctor failed"));
|
|---|
| 111 | lastError = DSERR_OUTOFMEMORY;
|
|---|
| 112 | return;
|
|---|
| 113 | }
|
|---|
| 114 |
|
|---|
| 115 | wmutex.enter(VMUTEX_WAIT_FOREVER);
|
|---|
| 116 | next = dsbroot;
|
|---|
| 117 | dsbroot = this;
|
|---|
| 118 | wmutex.leave();
|
|---|
| 119 | }
|
|---|
| 120 |
|
|---|
| 121 | //******************************************************************************
|
|---|
| 122 | //******************************************************************************
|
|---|
| 123 | IDirectAudioBuffer::IDirectAudioBuffer(OS2IDirectSound *DSound, IDirectAudioBuffer *srcBuf)
|
|---|
| 124 | : Referenced(0), lastError(DS_OK), daudio(NULL), lpSndBuffer(NULL)
|
|---|
| 125 | {
|
|---|
| 126 | //This is the constructor used for duplicating sound buffers
|
|---|
| 127 | lpVtbl = &Vtbl;
|
|---|
| 128 | Vtbl.AddRef = DAudioBufAddRef;
|
|---|
| 129 | Vtbl.Release = DAudioBufRelease;
|
|---|
| 130 | Vtbl.QueryInterface = DAudioBufQueryInterface;
|
|---|
| 131 | Vtbl.GetCaps = DAudioBufGetCaps;
|
|---|
| 132 | Vtbl.GetFormat = DAudioBufGetFormat;
|
|---|
| 133 | Vtbl.GetVolume = DAudioBufGetVolume;
|
|---|
| 134 | Vtbl.GetStatus = DAudioBufGetStatus;
|
|---|
| 135 | Vtbl.GetCurrentPosition = DAudioBufGetCurrentPosition;
|
|---|
| 136 | Vtbl.GetPan = DAudioBufGetPan;
|
|---|
| 137 | Vtbl.GetFrequency = DAudioBufGetFrequency;
|
|---|
| 138 | Vtbl.Initialize = DAudioBufInitialize;
|
|---|
| 139 | Vtbl.Restore = DAudioBufRestore;
|
|---|
| 140 | Vtbl.SetFormat = DAudioBufSetFormat;
|
|---|
| 141 | Vtbl.SetVolume = DAudioBufSetVolume;
|
|---|
| 142 | Vtbl.SetCurrentPosition = DAudioBufSetCurrentPosition;
|
|---|
| 143 | Vtbl.SetPan = DAudioBufSetPan;
|
|---|
| 144 | Vtbl.SetFrequency = DAudioBufSetFrequency;
|
|---|
| 145 | Vtbl.Lock = DAudioBufLock;
|
|---|
| 146 | Vtbl.Unlock = DAudioBufUnlock;
|
|---|
| 147 | Vtbl.Stop = DAudioBufStop;
|
|---|
| 148 | Vtbl.Play = DAudioBufPlay;
|
|---|
| 149 |
|
|---|
| 150 | dprintf(("DSOUND-IDirectAudioBuffer::OS2IDirectAudioBuffer/Duplicate (buf=%X)", this));
|
|---|
| 151 |
|
|---|
| 152 | parentDS = DSound;
|
|---|
| 153 | writepos = 0;
|
|---|
| 154 | playpos = 0;
|
|---|
| 155 | status = 0;
|
|---|
| 156 | fLocked = FALSE;
|
|---|
| 157 | volume = srcBuf->volume;
|
|---|
| 158 | DSvolume = srcBuf->DSvolume;
|
|---|
| 159 | pan = srcBuf->pan;
|
|---|
| 160 | DSpan = srcBuf->DSpan;
|
|---|
| 161 | lpBuffer = srcBuf->lpBuffer;
|
|---|
| 162 | fPlaying = FALSE;
|
|---|
| 163 | fLoop = srcBuf->fLoop;
|
|---|
| 164 | notify = NULL;
|
|---|
| 165 | memcpy(&bufferdesc, &(srcBuf->bufferdesc), sizeof(DSBUFFERDESC));
|
|---|
| 166 |
|
|---|
| 167 | // frequency has to be set according to the bufer format
|
|---|
| 168 | frequency = srcBuf->frequency;
|
|---|
| 169 |
|
|---|
| 170 | lpfxFormat = (WAVEFORMATEX *)malloc(sizeof(WAVEFORMATEX));
|
|---|
| 171 | memcpy(lpfxFormat,srcBuf->lpfxFormat, sizeof(WAVEFORMATEX));
|
|---|
| 172 |
|
|---|
| 173 | dprintf((" Buffer format: %dHz, %dbit, %d channels", lpfxFormat->nSamplesPerSec, lpfxFormat->wBitsPerSample, lpfxFormat->nChannels));
|
|---|
| 174 |
|
|---|
| 175 | // Increment reference count for the buffer memory
|
|---|
| 176 | lpSndBuffer = srcBuf->lpSndBuffer;
|
|---|
| 177 | lpSndBuffer->dwReferences++;
|
|---|
| 178 |
|
|---|
| 179 | if(daudio) {
|
|---|
| 180 | delete daudio;
|
|---|
| 181 | daudio = 0;
|
|---|
| 182 | }
|
|---|
| 183 | wmutex.enter(VMUTEX_WAIT_FOREVER);
|
|---|
| 184 | next = dsbroot;
|
|---|
| 185 | dsbroot = this;
|
|---|
| 186 | wmutex.leave();
|
|---|
| 187 | }
|
|---|
| 188 |
|
|---|
| 189 | //******************************************************************************
|
|---|
| 190 | //******************************************************************************
|
|---|
| 191 | IDirectAudioBuffer::~IDirectAudioBuffer()
|
|---|
| 192 | {
|
|---|
| 193 | dprintf(("DSOUND-IDirectAudioBuffer::~OS2IDirectAudioBuffer (buf=%X)", this));
|
|---|
| 194 |
|
|---|
| 195 | // free allocted memory - unless it's shared by a duplicated buffer
|
|---|
| 196 | if (lpSndBuffer) {
|
|---|
| 197 | lpSndBuffer->dwReferences--;
|
|---|
| 198 | if (lpSndBuffer->dwReferences == 0)
|
|---|
| 199 | VirtualFree(lpSndBuffer, 0, MEM_RELEASE);
|
|---|
| 200 | }
|
|---|
| 201 |
|
|---|
| 202 | if (lpfxFormat)
|
|---|
| 203 | free(lpfxFormat);
|
|---|
| 204 |
|
|---|
| 205 | // remove ourselves from the linked list
|
|---|
| 206 | IDirectAudioBuffer *cur = dsbroot;
|
|---|
| 207 | IDirectAudioBuffer *prev = NULL;
|
|---|
| 208 |
|
|---|
| 209 | wmutex.enter(VMUTEX_WAIT_FOREVER);
|
|---|
| 210 | if (this == dsbroot) // is this the first DAudioBuffer?
|
|---|
| 211 | dsbroot = next;
|
|---|
| 212 | else { // walk the chain
|
|---|
| 213 | while (cur->next != this)
|
|---|
| 214 | cur = cur->next;
|
|---|
| 215 |
|
|---|
| 216 | cur->next = next;
|
|---|
| 217 | }
|
|---|
| 218 | wmutex.leave();
|
|---|
| 219 | }
|
|---|
| 220 |
|
|---|
| 221 | //******************************************************************************
|
|---|
| 222 | //******************************************************************************
|
|---|
| 223 | void IDirectAudioBuffer::DestroyAllBuffers()
|
|---|
| 224 | {
|
|---|
| 225 | dprintf(("DSOUND-IDirectAudioBuffer::DestroyAllBuffers"));
|
|---|
| 226 |
|
|---|
| 227 | // if any DAudioBuffers still exist when the OS2IDirectSound object is
|
|---|
| 228 | // being closed, just kill them all
|
|---|
| 229 | IDirectAudioBuffer *cur = dsbroot;
|
|---|
| 230 | IDirectAudioBuffer *tmp;
|
|---|
| 231 |
|
|---|
| 232 | while (cur != NULL) {
|
|---|
| 233 | tmp = cur->next;
|
|---|
| 234 | delete cur;
|
|---|
| 235 | cur = tmp;
|
|---|
| 236 | }
|
|---|
| 237 | }
|
|---|
| 238 |
|
|---|
| 239 | //******************************************************************************
|
|---|
| 240 | //******************************************************************************
|
|---|
| 241 | HRESULT IDirectAudioBuffer::QueryInterface(REFIID riid, LPVOID * ppvObj)
|
|---|
| 242 | {
|
|---|
| 243 | dprintf(("DSOUND-IDirectAudioBuffer::QueryInterface %x %x", this, riid));
|
|---|
| 244 | *ppvObj = NULL;
|
|---|
| 245 |
|
|---|
| 246 | if (IsEqualGUID(riid, IID_IDirectSoundBuffer)) {
|
|---|
| 247 | *ppvObj = this;
|
|---|
| 248 |
|
|---|
| 249 | AddRef();
|
|---|
| 250 | return DS_OK;
|
|---|
| 251 | }
|
|---|
| 252 |
|
|---|
| 253 | if (IsEqualGUID(riid, IID_IDirectSoundNotify))
|
|---|
| 254 | {
|
|---|
| 255 | IDirectAudioNotify *notify;
|
|---|
| 256 |
|
|---|
| 257 | notify = new IDirectAudioNotify(this);
|
|---|
| 258 | *ppvObj = notify;
|
|---|
| 259 | notify->Vtbl.AddRef(notify);
|
|---|
| 260 | return DS_OK;
|
|---|
| 261 | }
|
|---|
| 262 | #if 0
|
|---|
| 263 | if (IsEqualGUID(riid, IID_IDirectSound3DBuffer)) {
|
|---|
| 264 | OS2IDirectSound3DBuffer *buffer3D;
|
|---|
| 265 |
|
|---|
| 266 | buffer3D = new OS2IDirectSound3DBuffer(this);
|
|---|
| 267 | *ppvObj = buffer3D;
|
|---|
| 268 | buffer3D->Vtbl.AddRef((IDirectSound3DBuffer *)buffer3D);
|
|---|
| 269 | return DS_OK;
|
|---|
| 270 | }
|
|---|
| 271 | #endif
|
|---|
| 272 | return E_NOINTERFACE;
|
|---|
| 273 | }
|
|---|
| 274 | //******************************************************************************
|
|---|
| 275 | //******************************************************************************
|
|---|
| 276 | ULONG IDirectAudioBuffer::AddRef()
|
|---|
| 277 | {
|
|---|
| 278 | dprintf(("DSOUND-IDirectAudioBuffer::AddRef (buf=%X) %d", this, Referenced+1));
|
|---|
| 279 | return ++Referenced;
|
|---|
| 280 | }
|
|---|
| 281 | //******************************************************************************
|
|---|
| 282 | //******************************************************************************
|
|---|
| 283 | ULONG IDirectAudioBuffer::Release()
|
|---|
| 284 | {
|
|---|
| 285 | dprintf(("DSOUND-IDirectAudioBuffer::Release (buf=%X) %d", this, Referenced-1));
|
|---|
| 286 |
|
|---|
| 287 | if (Referenced) {
|
|---|
| 288 | Referenced--;
|
|---|
| 289 | if (Referenced == 0) {
|
|---|
| 290 | delete this;
|
|---|
| 291 | return 0;
|
|---|
| 292 | }
|
|---|
| 293 | else
|
|---|
| 294 | return Referenced;
|
|---|
| 295 | }
|
|---|
| 296 | else
|
|---|
| 297 | return 0;
|
|---|
| 298 | }
|
|---|
| 299 | //******************************************************************************
|
|---|
| 300 | //******************************************************************************
|
|---|
| 301 | HRESULT IDirectAudioBuffer::GetCaps(LPDSBCAPS lpDSCaps)
|
|---|
| 302 | {
|
|---|
| 303 | dprintf(("DSOUND-IDirectAudioBuffer::DAudioBufGetCaps (buf=%X)", this));
|
|---|
| 304 | if ( lpDSCaps == NULL) {
|
|---|
| 305 | return DSERR_INVALIDPARAM;
|
|---|
| 306 | }
|
|---|
| 307 | /* FIXME: fill with more realistic values */
|
|---|
| 308 | lpDSCaps->dwSize = sizeof(DSBCAPS);
|
|---|
| 309 | lpDSCaps->dwFlags = bufferdesc.dwFlags | DSBCAPS_LOCHARDWARE;
|
|---|
| 310 | lpDSCaps->dwBufferBytes = bufferdesc.dwBufferBytes;
|
|---|
| 311 | lpDSCaps->dwUnlockTransferRate = 0; /* in KB/sec - 0 == no transfer needed */
|
|---|
| 312 | lpDSCaps->dwPlayCpuOverhead = 0; /* % CPU time - let's lie */
|
|---|
| 313 |
|
|---|
| 314 | return DS_OK;
|
|---|
| 315 | }
|
|---|
| 316 | //******************************************************************************
|
|---|
| 317 | //******************************************************************************
|
|---|
| 318 | HRESULT IDirectAudioBuffer::GetCurrentPosition(LPDWORD lpdwCurrentPlayCursor,
|
|---|
| 319 | LPDWORD lpdwCurrentWriteCursor)
|
|---|
| 320 | {
|
|---|
| 321 | dprintf(("DSOUND-IDirectAudioBuffer::DAudioBufGetCurrentPosition (buf=%X)", this));
|
|---|
| 322 | if ( lpdwCurrentPlayCursor == NULL || lpdwCurrentWriteCursor == NULL) {
|
|---|
| 323 | dprintf((" Invalid parameters %d %d %d",this,lpdwCurrentPlayCursor,lpdwCurrentWriteCursor));
|
|---|
| 324 | return DSERR_INVALIDPARAM;
|
|---|
| 325 | }
|
|---|
| 326 |
|
|---|
| 327 | dprintf((" PlayPos %d, WritePos %d", playpos, writepos));
|
|---|
| 328 | *lpdwCurrentPlayCursor = playpos;
|
|---|
| 329 | *lpdwCurrentWriteCursor = writepos;
|
|---|
| 330 | return DS_OK;
|
|---|
| 331 | }
|
|---|
| 332 | //******************************************************************************
|
|---|
| 333 | //******************************************************************************
|
|---|
| 334 | HRESULT IDirectAudioBuffer::SetCurrentPosition(DWORD dwNewPosition)
|
|---|
| 335 | {
|
|---|
| 336 | dprintf(("DSOUND-IDirectAudioBuffer::DAudioBufSetCurrentPosition %x to %d", this, dwNewPosition));
|
|---|
| 337 | playpos = dwNewPosition;
|
|---|
| 338 |
|
|---|
| 339 | return DS_OK;
|
|---|
| 340 | }
|
|---|
| 341 | //******************************************************************************
|
|---|
| 342 | //******************************************************************************
|
|---|
| 343 | HRESULT IDirectAudioBuffer::GetFormat(LPWAVEFORMATEX lpwfxFormat,
|
|---|
| 344 | DWORD ddwSizeAllocated, LPDWORD lpdwSizeWritten)
|
|---|
| 345 | {
|
|---|
| 346 | int copysize;
|
|---|
| 347 |
|
|---|
| 348 | dprintf(("DSOUND-IDirectAudioBuffer::DAudioBufGetFormat (buf=%X)", this));
|
|---|
| 349 | if (lpwfxFormat == NULL || ddwSizeAllocated == 0) {
|
|---|
| 350 | return DSERR_INVALIDPARAM;
|
|---|
| 351 | }
|
|---|
| 352 | copysize = min(ddwSizeAllocated, (lpfxFormat->cbSize + sizeof(WAVEFORMATEX)));
|
|---|
| 353 | memcpy(lpwfxFormat, lpfxFormat, copysize);
|
|---|
| 354 |
|
|---|
| 355 | if (lpdwSizeWritten) {
|
|---|
| 356 | *lpdwSizeWritten = copysize;
|
|---|
| 357 | }
|
|---|
| 358 | return DS_OK;
|
|---|
| 359 | }
|
|---|
| 360 | //******************************************************************************
|
|---|
| 361 | //******************************************************************************
|
|---|
| 362 | HRESULT IDirectAudioBuffer::SetFormat(LPWAVEFORMATEX lpWaveFormatEx)
|
|---|
| 363 | {
|
|---|
| 364 | // Note: this sets the format of the _primary_ buffer;
|
|---|
| 365 | // since this class only handles secondary buffers, we just return error
|
|---|
| 366 | dprintf(("DSOUND-IDirectAudioBuffer::DAudioBufSetFormat %x", this));
|
|---|
| 367 |
|
|---|
| 368 | return DSERR_UNSUPPORTED;
|
|---|
| 369 | }
|
|---|
| 370 | //******************************************************************************
|
|---|
| 371 | //******************************************************************************
|
|---|
| 372 | HRESULT IDirectAudioBuffer::GetVolume(LPLONG lplVolume)
|
|---|
| 373 | {
|
|---|
| 374 | dprintf(("DSOUND-IDirectAudioBuffer::DAudioBufGetVolume (buf=%X)", this));
|
|---|
| 375 | if (lplVolume == NULL) {
|
|---|
| 376 | return DSERR_INVALIDPARAM;
|
|---|
| 377 | }
|
|---|
| 378 | *lplVolume = DSvolume;
|
|---|
| 379 | return DS_OK;
|
|---|
| 380 | }
|
|---|
| 381 | //******************************************************************************
|
|---|
| 382 | //******************************************************************************
|
|---|
| 383 | HRESULT IDirectAudioBuffer::SetVolume(LONG lVolume)
|
|---|
| 384 | {
|
|---|
| 385 | dprintf(("DSOUND-IDirectAudioBuffer::DAudioBufSetVolume %x %d", this, lVolume));
|
|---|
| 386 | if (lVolume < -10000) {
|
|---|
| 387 | return DSERR_INVALIDPARAM;
|
|---|
| 388 | }
|
|---|
| 389 | // some apps pass positive values in lVolume, that's wrong right?!?
|
|---|
| 390 | DSvolume = (lVolume > 0) ? 0 : lVolume;
|
|---|
| 391 |
|
|---|
| 392 | /* = (10 ^ (1/10)) = 1dB - but the formula below gives results _very_ similar */
|
|---|
| 393 | /* to 'real' DirectSound, indistinguishable for all practical purposes */
|
|---|
| 394 | //volume = 255.0 * pow(4, DSvolume / 1000.0);
|
|---|
| 395 |
|
|---|
| 396 | /* Note: for some strange reason the above code sometimes gives erroneous */
|
|---|
| 397 | /* results, hence we now use a simple conversion table (in steps of 4/100 dB) */
|
|---|
| 398 |
|
|---|
| 399 | if (DSvolume < -4000)
|
|---|
| 400 | volume = 0;
|
|---|
| 401 | else
|
|---|
| 402 | volume = VolTable[-DSvolume / 4];
|
|---|
| 403 |
|
|---|
| 404 | dprintf((" New volume: %d", volume));
|
|---|
| 405 |
|
|---|
| 406 | return DS_OK;
|
|---|
| 407 | }
|
|---|
| 408 | //******************************************************************************
|
|---|
| 409 | //******************************************************************************
|
|---|
| 410 | HRESULT IDirectAudioBuffer::GetPan(LPLONG lplPan)
|
|---|
| 411 | {
|
|---|
| 412 | dprintf(("DSOUND-IDirectAudioBuffer::DAudioBufGetPan (buf=%X)", this));
|
|---|
| 413 | if (lplPan == NULL) {
|
|---|
| 414 | return DSERR_INVALIDPARAM;
|
|---|
| 415 | }
|
|---|
| 416 | *lplPan = DSpan;
|
|---|
| 417 | return DS_OK;
|
|---|
| 418 | }
|
|---|
| 419 | //******************************************************************************
|
|---|
| 420 | //******************************************************************************
|
|---|
| 421 | HRESULT IDirectAudioBuffer::SetPan(LONG lPan)
|
|---|
| 422 | {
|
|---|
| 423 | dprintf(("DSOUND-IDirectAudioBuffer::DAudioBufSetPan %x %d", this, lPan));
|
|---|
| 424 | if (lPan < -10000 || lPan > 10000) {
|
|---|
| 425 | return DSERR_INVALIDPARAM;
|
|---|
| 426 | }
|
|---|
| 427 | DSpan = lPan;
|
|---|
| 428 | if (lPan == 0) {
|
|---|
| 429 | pan = 0;
|
|---|
| 430 | return DS_OK;
|
|---|
| 431 | }
|
|---|
| 432 |
|
|---|
| 433 | /* Note: we use very similar code as for volume above */
|
|---|
| 434 | if (lPan < 0)
|
|---|
| 435 | if (lPan < -4000)
|
|---|
| 436 | pan = -255;
|
|---|
| 437 | else
|
|---|
| 438 | pan = VolTable[-lPan / 4] - 255;
|
|---|
| 439 | else
|
|---|
| 440 | if (lPan > 4000)
|
|---|
| 441 | pan = 255;
|
|---|
| 442 | else
|
|---|
| 443 | pan = 255 - VolTable[lPan / 4];
|
|---|
| 444 |
|
|---|
| 445 | dprintf((" New pan: %d", pan));
|
|---|
| 446 |
|
|---|
| 447 | return DS_OK;
|
|---|
| 448 | }
|
|---|
| 449 | //******************************************************************************
|
|---|
| 450 | //******************************************************************************
|
|---|
| 451 | HRESULT IDirectAudioBuffer::GetFrequency(LPDWORD lpdwFrequency)
|
|---|
| 452 | {
|
|---|
| 453 | dprintf(("DSOUND-IDirectAudioBuffer::DAudioBufGetFrequency (buf=%X)", this));
|
|---|
| 454 | if (lpdwFrequency == NULL) {
|
|---|
| 455 | return DSERR_INVALIDPARAM;
|
|---|
| 456 | }
|
|---|
| 457 | *lpdwFrequency = frequency;
|
|---|
| 458 | return DS_OK;
|
|---|
| 459 | }
|
|---|
| 460 | //******************************************************************************
|
|---|
| 461 | //******************************************************************************
|
|---|
| 462 | HRESULT IDirectAudioBuffer::SetFrequency(DWORD dwFrequency)
|
|---|
| 463 | {
|
|---|
| 464 | dprintf(("DSOUND-IDirectAudioBuffer::DAudioBufSetFrequency %x %x", this, dwFrequency));
|
|---|
| 465 |
|
|---|
| 466 | // zero means default (buffer format) frequency
|
|---|
| 467 | if (dwFrequency)
|
|---|
| 468 | frequency = dwFrequency;
|
|---|
| 469 | else
|
|---|
| 470 | frequency = lpfxFormat->nSamplesPerSec;
|
|---|
| 471 |
|
|---|
| 472 | return DS_OK;
|
|---|
| 473 | }
|
|---|
| 474 | //******************************************************************************
|
|---|
| 475 | //******************************************************************************
|
|---|
| 476 | HRESULT IDirectAudioBuffer::GetStatus(LPDWORD lpdwStatus)
|
|---|
| 477 | {
|
|---|
| 478 | dprintf(("DSOUND-IDirectAudioBuffer::DAudioBufGetStatus (buf=%X)", this));
|
|---|
| 479 | if (lpdwStatus == NULL) {
|
|---|
| 480 | return DSERR_INVALIDPARAM;
|
|---|
| 481 | }
|
|---|
| 482 |
|
|---|
| 483 | if (fPlaying)
|
|---|
| 484 | if (fLoop)
|
|---|
| 485 | status |= DSBSTATUS_PLAYING | DSBSTATUS_LOOPING;
|
|---|
| 486 | else
|
|---|
| 487 | status |= DSBSTATUS_PLAYING;
|
|---|
| 488 | else
|
|---|
| 489 | status &= ~(DSBSTATUS_PLAYING | DSBSTATUS_LOOPING);
|
|---|
| 490 |
|
|---|
| 491 | *lpdwStatus = status;
|
|---|
| 492 | return DS_OK;
|
|---|
| 493 | }
|
|---|
| 494 | //******************************************************************************
|
|---|
| 495 | //******************************************************************************
|
|---|
| 496 | HRESULT IDirectAudioBuffer::Initialize(LPDIRECTSOUND, LPDSBUFFERDESC )
|
|---|
| 497 | {
|
|---|
| 498 | dprintf(("DSOUND-DAudioBufInitialize (buf=%X)", this));
|
|---|
| 499 |
|
|---|
| 500 | return DSERR_ALREADYINITIALIZED; //todo: for future extensions (dx5/6 ??)
|
|---|
| 501 | }
|
|---|
| 502 | //******************************************************************************
|
|---|
| 503 | //******************************************************************************
|
|---|
| 504 | HRESULT IDirectAudioBuffer::Lock(DWORD dwWriteCursor, DWORD dwWriteBytes,
|
|---|
| 505 | LPVOID lplpvAudioPtr1, LPDWORD lpdwAudioBytes1,
|
|---|
| 506 | LPVOID lplpvAudioPtr2, LPDWORD lpdwAudioBytes2,
|
|---|
| 507 | DWORD dwFlags)
|
|---|
| 508 | {
|
|---|
| 509 | dprintf(("DSOUND-IDirectAudioBuffer::DAudioBufLock (buf=%X, %d bytes of %d)", this, dwWriteBytes, bufferdesc.dwBufferBytes));
|
|---|
| 510 | if (!lplpvAudioPtr1 || !lpdwAudioBytes1)
|
|---|
| 511 | return DSERR_INVALIDPARAM;
|
|---|
| 512 |
|
|---|
| 513 | //not sure if this is an error, but it's certainly a smart thing to do (cond. == true)
|
|---|
| 514 | if(dwWriteBytes > bufferdesc.dwBufferBytes) {
|
|---|
| 515 | dprintf(("DAudioBufLock: dwWriteBytes > bufferdesc.dwBufferBytes"));
|
|---|
| 516 | return DSERR_INVALIDPARAM;
|
|---|
| 517 | }
|
|---|
| 518 | if (dwFlags & DSBLOCK_FROMWRITECURSOR) {
|
|---|
| 519 | dwWriteCursor = writepos;
|
|---|
| 520 | }
|
|---|
| 521 | if (dwWriteCursor + dwWriteBytes > bufferdesc.dwBufferBytes) {
|
|---|
| 522 | *(DWORD *)lplpvAudioPtr1 = (DWORD)(lpBuffer + dwWriteCursor);
|
|---|
| 523 | *lpdwAudioBytes1 = bufferdesc.dwBufferBytes - dwWriteCursor;
|
|---|
| 524 | if (lplpvAudioPtr2 && lpdwAudioBytes2) {
|
|---|
| 525 | *(DWORD *)lplpvAudioPtr2 = (DWORD)lpBuffer;
|
|---|
| 526 | *lpdwAudioBytes2 = dwWriteBytes - *lpdwAudioBytes1;
|
|---|
| 527 | }
|
|---|
| 528 | }
|
|---|
| 529 | else {
|
|---|
| 530 | *(DWORD *)lplpvAudioPtr1 = (DWORD)(lpBuffer + dwWriteCursor);
|
|---|
| 531 | *lpdwAudioBytes1 = dwWriteBytes;
|
|---|
| 532 | if (lplpvAudioPtr2 && lpdwAudioBytes2) {
|
|---|
| 533 | *(DWORD *)lplpvAudioPtr2 = 0;
|
|---|
| 534 | *lpdwAudioBytes2 = 0;
|
|---|
| 535 | }
|
|---|
| 536 | }
|
|---|
| 537 | fLocked = TRUE;
|
|---|
| 538 | return DS_OK;
|
|---|
| 539 | }
|
|---|
| 540 | //******************************************************************************
|
|---|
| 541 | //******************************************************************************
|
|---|
| 542 | HRESULT IDirectAudioBuffer::Unlock(LPVOID lpvAudioPtr1, DWORD dwAudioBytes1,
|
|---|
| 543 | LPVOID lpvAudioPtr2, DWORD dwAudioBytes2)
|
|---|
| 544 | {
|
|---|
| 545 | dprintf(("DSOUND-IDirectAudioBuffer::DAudioBufUnlock %x", this));
|
|---|
| 546 |
|
|---|
| 547 | fLocked = TRUE;
|
|---|
| 548 | return DS_OK;
|
|---|
| 549 | }
|
|---|
| 550 | //******************************************************************************
|
|---|
| 551 | //******************************************************************************
|
|---|
| 552 | HRESULT IDirectAudioBuffer::Play(DWORD dwRes1, DWORD dwRes2, DWORD dwFlags)
|
|---|
| 553 | {
|
|---|
| 554 | dprintf(("DSOUND-IDirectAudioBuffer::DAudioBufPlay (buf=%X)", this));
|
|---|
| 555 |
|
|---|
| 556 | if (!fPlaying) {
|
|---|
| 557 | frac = 0;
|
|---|
| 558 | fPlaying = TRUE;
|
|---|
| 559 | status = DSBSTATUS_PLAYING;
|
|---|
| 560 | fLoop = dwFlags == DSBPLAY_LOOPING;
|
|---|
| 561 | if (fLoop)
|
|---|
| 562 | status |= DSBSTATUS_LOOPING;
|
|---|
| 563 |
|
|---|
| 564 | dprintf((" Buffer %X: start at pos %d, loop %s",this, playpos, fLoop?"YES":"NO"));
|
|---|
| 565 | }
|
|---|
| 566 | else {
|
|---|
| 567 | fLoop = dwFlags == DSBPLAY_LOOPING;
|
|---|
| 568 | if (fLoop)
|
|---|
| 569 | status |= DSBSTATUS_LOOPING;
|
|---|
| 570 |
|
|---|
| 571 | dprintf((" Buffer %X: already playing, loop %s",this, fLoop?"YES":"NO"));
|
|---|
| 572 | }
|
|---|
| 573 |
|
|---|
| 574 | return DS_OK;
|
|---|
| 575 | }
|
|---|
| 576 | //******************************************************************************
|
|---|
| 577 | //******************************************************************************
|
|---|
| 578 | HRESULT IDirectAudioBuffer::Stop( )
|
|---|
| 579 | {
|
|---|
| 580 | dprintf(("DSOUND-IDirectAudioBuffer::DAudioBufStop %x", this));
|
|---|
| 581 | fPlaying = FALSE;
|
|---|
| 582 | status &= ~(DSBSTATUS_PLAYING | DSBSTATUS_LOOPING);
|
|---|
| 583 |
|
|---|
| 584 | if (notify != NULL)
|
|---|
| 585 | notify->CheckStop();
|
|---|
| 586 |
|
|---|
| 587 | return DS_OK;
|
|---|
| 588 | }
|
|---|
| 589 | //******************************************************************************
|
|---|
| 590 | //******************************************************************************
|
|---|
| 591 | HRESULT IDirectAudioBuffer::Restore( )
|
|---|
| 592 | {
|
|---|
| 593 | dprintf(("DSOUND-IDirectAudioBuffer::DAudioBufRestore %x", this));
|
|---|
| 594 | return DS_OK;
|
|---|
| 595 | }
|
|---|
| 596 | //******************************************************************************
|
|---|
| 597 | //******************************************************************************
|
|---|
| 598 | //Wrapper functions. Can be removed when switching to a compiler that supports
|
|---|
| 599 | //stdcall calling convention for class methods.
|
|---|
| 600 | //******************************************************************************
|
|---|
| 601 | //******************************************************************************
|
|---|
| 602 | HRESULT WINAPI DAudioBufQueryInterface(THIS, REFIID riid, LPVOID * ppvObj)
|
|---|
| 603 | {
|
|---|
| 604 | IDirectAudioBuffer *me = (IDirectAudioBuffer *)This;
|
|---|
| 605 | if(This == NULL) {
|
|---|
| 606 | DebugInt3();
|
|---|
| 607 | return DSERR_INVALIDPARAM;
|
|---|
| 608 | }
|
|---|
| 609 | return me->QueryInterface(riid, ppvObj);
|
|---|
| 610 | }
|
|---|
| 611 | //******************************************************************************
|
|---|
| 612 | //******************************************************************************
|
|---|
| 613 | ULONG WINAPI DAudioBufAddRef(THIS)
|
|---|
| 614 | {
|
|---|
| 615 | IDirectAudioBuffer *me = (IDirectAudioBuffer *)This;
|
|---|
| 616 | if(This == NULL) {
|
|---|
| 617 | DebugInt3();
|
|---|
| 618 | return DSERR_INVALIDPARAM;
|
|---|
| 619 | }
|
|---|
| 620 | return me->AddRef();
|
|---|
| 621 | }
|
|---|
| 622 | //******************************************************************************
|
|---|
| 623 | //******************************************************************************
|
|---|
| 624 | ULONG WINAPI DAudioBufRelease(THIS)
|
|---|
| 625 | {
|
|---|
| 626 | IDirectAudioBuffer *me = (IDirectAudioBuffer *)This;
|
|---|
| 627 | if(This == NULL) {
|
|---|
| 628 | DebugInt3();
|
|---|
| 629 | return DSERR_INVALIDPARAM;
|
|---|
| 630 | }
|
|---|
| 631 | return me->Release();
|
|---|
| 632 | }
|
|---|
| 633 | //******************************************************************************
|
|---|
| 634 | //******************************************************************************
|
|---|
| 635 | HRESULT WINAPI DAudioBufGetCaps(THIS_ LPDSBCAPS lpCaps)
|
|---|
| 636 | {
|
|---|
| 637 | IDirectAudioBuffer *me = (IDirectAudioBuffer *)This;
|
|---|
| 638 | if(This == NULL) {
|
|---|
| 639 | DebugInt3();
|
|---|
| 640 | return DSERR_INVALIDPARAM;
|
|---|
| 641 | }
|
|---|
| 642 | return me->GetCaps(lpCaps);
|
|---|
| 643 | }
|
|---|
| 644 | //******************************************************************************
|
|---|
| 645 | //******************************************************************************
|
|---|
| 646 | HRESULT WINAPI DAudioBufGetCurrentPosition(THIS_ LPDWORD a,LPDWORD b)
|
|---|
| 647 | {
|
|---|
| 648 | IDirectAudioBuffer *me = (IDirectAudioBuffer *)This;
|
|---|
| 649 | if(This == NULL) {
|
|---|
| 650 | DebugInt3();
|
|---|
| 651 | return DSERR_INVALIDPARAM;
|
|---|
| 652 | }
|
|---|
| 653 | return me->GetCurrentPosition(a, b);
|
|---|
| 654 | }
|
|---|
| 655 | //******************************************************************************
|
|---|
| 656 | //******************************************************************************
|
|---|
| 657 | HRESULT WINAPI DAudioBufGetFormat(THIS_ LPWAVEFORMATEX a, DWORD b, LPDWORD c)
|
|---|
| 658 | {
|
|---|
| 659 | IDirectAudioBuffer *me = (IDirectAudioBuffer *)This;
|
|---|
| 660 | if(This == NULL) {
|
|---|
| 661 | DebugInt3();
|
|---|
| 662 | return DSERR_INVALIDPARAM;
|
|---|
| 663 | }
|
|---|
| 664 | return me->GetFormat(a,b,c);
|
|---|
| 665 | }
|
|---|
| 666 | //******************************************************************************
|
|---|
| 667 | //******************************************************************************
|
|---|
| 668 | HRESULT WINAPI DAudioBufGetVolume(THIS_ LPLONG a)
|
|---|
| 669 | {
|
|---|
| 670 | IDirectAudioBuffer *me = (IDirectAudioBuffer *)This;
|
|---|
| 671 | if(This == NULL) {
|
|---|
| 672 | DebugInt3();
|
|---|
| 673 | return DSERR_INVALIDPARAM;
|
|---|
| 674 | }
|
|---|
| 675 | return me->GetVolume(a);
|
|---|
| 676 | }
|
|---|
| 677 | //******************************************************************************
|
|---|
| 678 | //******************************************************************************
|
|---|
| 679 | HRESULT WINAPI DAudioBufGetPan(THIS_ LPLONG a)
|
|---|
| 680 | {
|
|---|
| 681 | IDirectAudioBuffer *me = (IDirectAudioBuffer *)This;
|
|---|
| 682 | if(This == NULL) {
|
|---|
| 683 | DebugInt3();
|
|---|
| 684 | return DSERR_INVALIDPARAM;
|
|---|
| 685 | }
|
|---|
| 686 | return me->GetPan(a);
|
|---|
| 687 | }
|
|---|
| 688 | //******************************************************************************
|
|---|
| 689 | //******************************************************************************
|
|---|
| 690 | HRESULT WINAPI DAudioBufGetFrequency(THIS_ LPDWORD a)
|
|---|
| 691 | {
|
|---|
| 692 | IDirectAudioBuffer *me = (IDirectAudioBuffer *)This;
|
|---|
| 693 | if(This == NULL) {
|
|---|
| 694 | DebugInt3();
|
|---|
| 695 | return DSERR_INVALIDPARAM;
|
|---|
| 696 | }
|
|---|
| 697 | return me->GetFrequency(a);
|
|---|
| 698 | }
|
|---|
| 699 | //******************************************************************************
|
|---|
| 700 | //******************************************************************************
|
|---|
| 701 | HRESULT WINAPI DAudioBufGetStatus(THIS_ LPDWORD a)
|
|---|
| 702 | {
|
|---|
| 703 | IDirectAudioBuffer *me = (IDirectAudioBuffer *)This;
|
|---|
| 704 | if(This == NULL) {
|
|---|
| 705 | DebugInt3();
|
|---|
| 706 | return DSERR_INVALIDPARAM;
|
|---|
| 707 | }
|
|---|
| 708 | return me->GetStatus(a);
|
|---|
| 709 | }
|
|---|
| 710 | //******************************************************************************
|
|---|
| 711 | //******************************************************************************
|
|---|
| 712 | HRESULT WINAPI DAudioBufInitialize(THIS_ LPDIRECTSOUND a, LPDSBUFFERDESC b)
|
|---|
| 713 | {
|
|---|
| 714 | IDirectAudioBuffer *me = (IDirectAudioBuffer *)This;
|
|---|
| 715 | if(This == NULL) {
|
|---|
| 716 | DebugInt3();
|
|---|
| 717 | return DSERR_INVALIDPARAM;
|
|---|
| 718 | }
|
|---|
| 719 | return me->Initialize(a,b);
|
|---|
| 720 | }
|
|---|
| 721 | //******************************************************************************
|
|---|
| 722 | //******************************************************************************
|
|---|
| 723 | HRESULT WINAPI DAudioBufLock(THIS_ DWORD a,DWORD b,LPVOID c,LPDWORD d,LPVOID e,LPDWORD f,DWORD g)
|
|---|
| 724 | {
|
|---|
| 725 | IDirectAudioBuffer *me = (IDirectAudioBuffer *)This;
|
|---|
| 726 | if(This == NULL) {
|
|---|
| 727 | DebugInt3();
|
|---|
| 728 | return DSERR_INVALIDPARAM;
|
|---|
| 729 | }
|
|---|
| 730 | return me->Lock(a,b,c,d,e,f,g);
|
|---|
| 731 | }
|
|---|
| 732 | //******************************************************************************
|
|---|
| 733 | //******************************************************************************
|
|---|
| 734 | HRESULT WINAPI DAudioBufPlay(THIS_ DWORD a, DWORD b,DWORD c)
|
|---|
| 735 | {
|
|---|
| 736 | IDirectAudioBuffer *me = (IDirectAudioBuffer *)This;
|
|---|
| 737 | if(This == NULL) {
|
|---|
| 738 | DebugInt3();
|
|---|
| 739 | return DSERR_INVALIDPARAM;
|
|---|
| 740 | }
|
|---|
| 741 | return me->Play(a,b,c);
|
|---|
| 742 | }
|
|---|
| 743 | //******************************************************************************
|
|---|
| 744 | //******************************************************************************
|
|---|
| 745 | HRESULT WINAPI DAudioBufSetCurrentPosition(THIS_ DWORD a)
|
|---|
| 746 | {
|
|---|
| 747 | IDirectAudioBuffer *me = (IDirectAudioBuffer *)This;
|
|---|
| 748 | if(This == NULL) {
|
|---|
| 749 | DebugInt3();
|
|---|
| 750 | return DSERR_INVALIDPARAM;
|
|---|
| 751 | }
|
|---|
| 752 | return me->SetCurrentPosition(a);
|
|---|
| 753 | }
|
|---|
| 754 | //******************************************************************************
|
|---|
| 755 | //******************************************************************************
|
|---|
| 756 | HRESULT WINAPI DAudioBufSetFormat(THIS_ LPWAVEFORMATEX a)
|
|---|
| 757 | {
|
|---|
| 758 | IDirectAudioBuffer *me = (IDirectAudioBuffer *)This;
|
|---|
| 759 | if(This == NULL) {
|
|---|
| 760 | DebugInt3();
|
|---|
| 761 | return DSERR_INVALIDPARAM;
|
|---|
| 762 | }
|
|---|
| 763 | return me->SetFormat(a);
|
|---|
| 764 | }
|
|---|
| 765 | //******************************************************************************
|
|---|
| 766 | //******************************************************************************
|
|---|
| 767 | HRESULT WINAPI DAudioBufSetVolume(THIS_ LONG a)
|
|---|
| 768 | {
|
|---|
| 769 | IDirectAudioBuffer *me = (IDirectAudioBuffer *)This;
|
|---|
| 770 | if(This == NULL) {
|
|---|
| 771 | DebugInt3();
|
|---|
| 772 | return DSERR_INVALIDPARAM;
|
|---|
| 773 | }
|
|---|
| 774 | return me->SetVolume(a);
|
|---|
| 775 | }
|
|---|
| 776 | //******************************************************************************
|
|---|
| 777 | //******************************************************************************
|
|---|
| 778 | HRESULT WINAPI DAudioBufSetPan(THIS_ LONG a)
|
|---|
| 779 | {
|
|---|
| 780 | IDirectAudioBuffer *me = (IDirectAudioBuffer *)This;
|
|---|
| 781 | if(This == NULL) {
|
|---|
| 782 | DebugInt3();
|
|---|
| 783 | return DSERR_INVALIDPARAM;
|
|---|
| 784 | }
|
|---|
| 785 | return me->SetPan(a);
|
|---|
| 786 | }
|
|---|
| 787 | //******************************************************************************
|
|---|
| 788 | //******************************************************************************
|
|---|
| 789 | HRESULT WINAPI DAudioBufSetFrequency(THIS_ DWORD a)
|
|---|
| 790 | {
|
|---|
| 791 | IDirectAudioBuffer *me = (IDirectAudioBuffer *)This;
|
|---|
| 792 | if(This == NULL) {
|
|---|
| 793 | DebugInt3();
|
|---|
| 794 | return DSERR_INVALIDPARAM;
|
|---|
| 795 | }
|
|---|
| 796 | return me->SetFrequency(a);
|
|---|
| 797 |
|
|---|
| 798 | }
|
|---|
| 799 | //******************************************************************************
|
|---|
| 800 | //******************************************************************************
|
|---|
| 801 | HRESULT WINAPI DAudioBufStop(THIS )
|
|---|
| 802 | {
|
|---|
| 803 | IDirectAudioBuffer *me = (IDirectAudioBuffer *)This;
|
|---|
| 804 | if(This == NULL) {
|
|---|
| 805 | DebugInt3();
|
|---|
| 806 | return DSERR_INVALIDPARAM;
|
|---|
| 807 | }
|
|---|
| 808 | return me->Stop();
|
|---|
| 809 | }
|
|---|
| 810 | //******************************************************************************
|
|---|
| 811 | //******************************************************************************
|
|---|
| 812 | HRESULT WINAPI DAudioBufUnlock(THIS_ LPVOID a,DWORD b,LPVOID c,DWORD d)
|
|---|
| 813 | {
|
|---|
| 814 | IDirectAudioBuffer *me = (IDirectAudioBuffer *)This;
|
|---|
| 815 | if(This == NULL) {
|
|---|
| 816 | DebugInt3();
|
|---|
| 817 | return DSERR_INVALIDPARAM;
|
|---|
| 818 | }
|
|---|
| 819 | return me->Unlock(a,b,c,d);
|
|---|
| 820 | }
|
|---|
| 821 | //******************************************************************************
|
|---|
| 822 | //******************************************************************************
|
|---|
| 823 | HRESULT WINAPI DAudioBufRestore(THIS )
|
|---|
| 824 | {
|
|---|
| 825 | IDirectAudioBuffer *me = (IDirectAudioBuffer *)This;
|
|---|
| 826 | if(This == NULL) {
|
|---|
| 827 | DebugInt3();
|
|---|
| 828 | return DSERR_INVALIDPARAM;
|
|---|
| 829 | }
|
|---|
| 830 | return me->Restore();
|
|---|
| 831 | }
|
|---|
| 832 | //******************************************************************************
|
|---|
| 833 | //******************************************************************************
|
|---|
| 834 |
|
|---|