source: trunk/src/dsound/DAudioBuffer.cpp

Last change on this file was 21479, checked in by dmik, 15 years ago

Get rid of dd_obj_base.h which duplicates obj_base.h creating unnecessary mess (symbol/define duplication) and conflicts when both the DDarw and other COM-related headers are included.

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