source: trunk/src/dsound/DAudioBuffer.cpp@ 5643

Last change on this file since 5643 was 5643, checked in by sandervl, 24 years ago

DirectAudio interface updates

File size: 29.3 KB
Line 
1/* $Id: DAudioBuffer.cpp,v 1.2 2001-04-30 21:06:37 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
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(VMUTEX_WAIT_FOREVER);
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(VMUTEX_WAIT_FOREVER);
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(VMUTEX_WAIT_FOREVER);
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.AddRef = DAudioBufAddRef;
189 Vtbl.Release = DAudioBufRelease;
190 Vtbl.QueryInterface = DAudioBufQueryInterface;
191 Vtbl.GetCaps = DAudioBufGetCaps;
192 Vtbl.GetFormat = DAudioBufGetFormat;
193 Vtbl.GetVolume = DAudioBufGetVolume;
194 Vtbl.GetStatus = DAudioBufGetStatus;
195 Vtbl.GetCurrentPosition = DAudioBufGetCurrentPosition;
196 Vtbl.GetPan = DAudioBufGetPan;
197 Vtbl.GetFrequency = DAudioBufGetFrequency;
198 Vtbl.Initialize = DAudioBufInitialize;
199 Vtbl.Restore = DAudioBufRestore;
200 Vtbl.SetFormat = DAudioBufSetFormat;
201 Vtbl.SetVolume = DAudioBufSetVolume;
202 Vtbl.SetCurrentPosition = DAudioBufSetCurrentPosition;
203 Vtbl.SetPan = DAudioBufSetPan;
204 Vtbl.SetFrequency = DAudioBufSetFrequency;
205 Vtbl.Lock = DAudioBufLock;
206 Vtbl.Unlock = DAudioBufUnlock;
207 Vtbl.Stop = DAudioBufStop;
208 Vtbl.Play = 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.AddRef(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.AddRef((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 dprintf((" PlayPos %d, WritePos %d", *lpdwCurrentPlayCursor, *lpdwCurrentWriteCursor));
318 return DS_OK;
319}
320//******************************************************************************
321//******************************************************************************
322HRESULT IDirectAudioBuffer::SetCurrentPosition(DWORD dwNewPosition)
323{
324 dprintf(("DSOUND-IDirectAudioBuffer::DAudioBufSetCurrentPosition %x to %d", this, dwNewPosition));
325 playpos = dwNewPosition;
326
327 //TODO:
328 return DS_OK;
329}
330//******************************************************************************
331//******************************************************************************
332HRESULT IDirectAudioBuffer::GetFormat(LPWAVEFORMATEX lpwfxFormat,
333 DWORD ddwSizeAllocated, LPDWORD lpdwSizeWritten)
334{
335 int copysize;
336
337 dprintf(("DSOUND-IDirectAudioBuffer::DAudioBufGetFormat (buf=%X)", this));
338 if (lpwfxFormat == NULL || ddwSizeAllocated == 0) {
339 return DSERR_INVALIDPARAM;
340 }
341 copysize = min(ddwSizeAllocated, (lpfxFormat->cbSize + sizeof(WAVEFORMATEX)));
342 memcpy(lpwfxFormat, lpfxFormat, copysize);
343
344 if (lpdwSizeWritten) {
345 *lpdwSizeWritten = copysize;
346 }
347 return DS_OK;
348}
349//******************************************************************************
350//******************************************************************************
351HRESULT IDirectAudioBuffer::SetFormat(LPWAVEFORMATEX lpWaveFormatEx)
352{
353 // Note: this sets the format of the _primary_ buffer;
354 // since this class only handles secondary buffers, we just return error
355 dprintf(("DSOUND-IDirectAudioBuffer::DAudioBufSetFormat %x", this));
356
357 return DSERR_UNSUPPORTED;
358}
359//******************************************************************************
360//******************************************************************************
361HRESULT IDirectAudioBuffer::GetVolume(LPLONG lplVolume)
362{
363 dprintf(("DSOUND-IDirectAudioBuffer::DAudioBufGetVolume (buf=%X)", this));
364 if (lplVolume == NULL) {
365 return DSERR_INVALIDPARAM;
366 }
367 *lplVolume = DSvolume;
368 return DS_OK;
369}
370//******************************************************************************
371//******************************************************************************
372HRESULT IDirectAudioBuffer::SetVolume(LONG lVolume)
373{
374 dprintf(("DSOUND-IDirectAudioBuffer::DAudioBufSetVolume %x %d", this, lVolume));
375 if (lVolume < -10000) {
376 return DSERR_INVALIDPARAM;
377 }
378 // some apps pass positive values in lVolume, that's wrong right?!?
379 DSvolume = (lVolume > 0) ? 0 : lVolume;
380
381 /* = (10 ^ (1/10)) = 1dB - but the formula below gives results _very_ similar */
382 /* to 'real' DirectSound, indistinguishable for all practical purposes */
383 //volume = 255.0 * pow(4, DSvolume / 1000.0);
384
385 /* Note: for some strange reason the above code sometimes gives erroneous */
386 /* results, hence we now use a simple conversion table (in steps of 4/100 dB) */
387
388 if (DSvolume < -4000)
389 volume = 0;
390 else
391 volume = VolTable[-DSvolume / 4];
392
393 dprintf((" New volume: %d", volume));
394
395 return DS_OK;
396}
397//******************************************************************************
398//******************************************************************************
399HRESULT IDirectAudioBuffer::GetPan(LPLONG lplPan)
400{
401 dprintf(("DSOUND-IDirectAudioBuffer::DAudioBufGetPan (buf=%X)", this));
402 if (lplPan == NULL) {
403 return DSERR_INVALIDPARAM;
404 }
405 *lplPan = DSpan;
406 return DS_OK;
407}
408//******************************************************************************
409//******************************************************************************
410HRESULT IDirectAudioBuffer::SetPan(LONG lPan)
411{
412 dprintf(("DSOUND-IDirectAudioBuffer::DAudioBufSetPan %x %d", this, lPan));
413 if (lPan < -10000 || lPan > 10000) {
414 return DSERR_INVALIDPARAM;
415 }
416 DSpan = lPan;
417 if (lPan == 0) {
418 pan = 0;
419 return DS_OK;
420 }
421
422 /* Note: we use very similar code as for volume above */
423 if (lPan < 0)
424 if (lPan < -4000)
425 pan = -255;
426 else
427 pan = VolTable[-lPan / 4] - 255;
428 else
429 if (lPan > 4000)
430 pan = 255;
431 else
432 pan = 255 - VolTable[lPan / 4];
433
434 dprintf((" New pan: %d", pan));
435
436 return DS_OK;
437}
438//******************************************************************************
439//******************************************************************************
440HRESULT IDirectAudioBuffer::GetFrequency(LPDWORD lpdwFrequency)
441{
442 dprintf(("DSOUND-IDirectAudioBuffer::DAudioBufGetFrequency (buf=%X)", this));
443 if (lpdwFrequency == NULL) {
444 return DSERR_INVALIDPARAM;
445 }
446 *lpdwFrequency = frequency;
447 return DS_OK;
448}
449//******************************************************************************
450//******************************************************************************
451HRESULT IDirectAudioBuffer::SetFrequency(DWORD dwFrequency)
452{
453 DWORD oldfrequency = frequency;
454
455 dprintf(("DSOUND-IDirectAudioBuffer::DAudioBufSetFrequency %x %d (old %d)", this, dwFrequency, oldfrequency));
456
457 // zero means default (buffer format) frequency
458 if (dwFrequency)
459 frequency = dwFrequency;
460 else
461 frequency = lpfxFormat->nSamplesPerSec;
462
463 if(frequency != oldfrequency) {
464 daudio->setProperty(PROPERTY_FREQUENCY, frequency);
465 }
466 return DS_OK;
467}
468//******************************************************************************
469//******************************************************************************
470HRESULT IDirectAudioBuffer::GetStatus(LPDWORD lpdwStatus)
471{
472 dprintf(("DSOUND-IDirectAudioBuffer::DAudioBufGetStatus (buf=%X)", this));
473 if (lpdwStatus == NULL) {
474 return DSERR_INVALIDPARAM;
475 }
476
477 if (fPlaying)
478 if (fLoop)
479 status |= DSBSTATUS_PLAYING | DSBSTATUS_LOOPING;
480 else
481 status |= DSBSTATUS_PLAYING;
482 else
483 status &= ~(DSBSTATUS_PLAYING | DSBSTATUS_LOOPING);
484
485 *lpdwStatus = status;
486 return DS_OK;
487}
488//******************************************************************************
489//******************************************************************************
490HRESULT IDirectAudioBuffer::Initialize(LPDIRECTSOUND, LPDSBUFFERDESC )
491{
492 dprintf(("DSOUND-DAudioBufInitialize (buf=%X)", this));
493
494 return DSERR_ALREADYINITIALIZED; //todo: for future extensions (dx5/6 ??)
495}
496//******************************************************************************
497//******************************************************************************
498HRESULT IDirectAudioBuffer::Lock(DWORD dwWriteCursor, DWORD dwWriteBytes,
499 LPVOID lplpvAudioPtr1, LPDWORD lpdwAudioBytes1,
500 LPVOID lplpvAudioPtr2, LPDWORD lpdwAudioBytes2,
501 DWORD dwFlags)
502{
503 dprintf(("DSOUND-IDirectAudioBuffer::DAudioBufLock (buf=%X, %d bytes of %d)", this, dwWriteBytes, bufferdesc.dwBufferBytes));
504 if (!lplpvAudioPtr1 || !lpdwAudioBytes1)
505 return DSERR_INVALIDPARAM;
506
507 //not sure if this is an error, but it's certainly a smart thing to do (cond. == true)
508 if(dwWriteBytes > bufferdesc.dwBufferBytes) {
509 dprintf(("DAudioBufLock: dwWriteBytes > bufferdesc.dwBufferBytes"));
510 return DSERR_INVALIDPARAM;
511 }
512 if (dwFlags & DSBLOCK_FROMWRITECURSOR) {
513 dwWriteCursor = writepos;
514 }
515 if (dwWriteCursor + dwWriteBytes > bufferdesc.dwBufferBytes) {
516 *(DWORD *)lplpvAudioPtr1 = (DWORD)(lpBuffer + dwWriteCursor);
517 *lpdwAudioBytes1 = bufferdesc.dwBufferBytes - dwWriteCursor;
518 if (lplpvAudioPtr2 && lpdwAudioBytes2) {
519 *(DWORD *)lplpvAudioPtr2 = (DWORD)lpBuffer;
520 *lpdwAudioBytes2 = dwWriteBytes - *lpdwAudioBytes1;
521 }
522 }
523 else {
524 *(DWORD *)lplpvAudioPtr1 = (DWORD)(lpBuffer + dwWriteCursor);
525 *lpdwAudioBytes1 = dwWriteBytes;
526 if (lplpvAudioPtr2 && lpdwAudioBytes2) {
527 *(DWORD *)lplpvAudioPtr2 = 0;
528 *lpdwAudioBytes2 = 0;
529 }
530 }
531 fLocked = TRUE;
532 return DS_OK;
533}
534//******************************************************************************
535//******************************************************************************
536HRESULT IDirectAudioBuffer::Unlock(LPVOID lpvAudioPtr1, DWORD dwAudioBytes1,
537 LPVOID lpvAudioPtr2, DWORD dwAudioBytes2)
538{
539 dprintf(("DSOUND-IDirectAudioBuffer::DAudioBufUnlock %x", this));
540
541 fLocked = TRUE;
542 return DS_OK;
543}
544//******************************************************************************
545//******************************************************************************
546HRESULT IDirectAudioBuffer::Play(DWORD dwRes1, DWORD dwRes2, DWORD dwFlags)
547{
548 dprintf(("DSOUND-IDirectAudioBuffer::DAudioBufPlay (buf=%X)", this));
549
550 if (!fPlaying) {
551 frac = 0;
552 fPlaying = TRUE;
553 status = DSBSTATUS_PLAYING;
554 fLoop = dwFlags == DSBPLAY_LOOPING;
555 if (fLoop) {
556 status |= DSBSTATUS_LOOPING;
557 daudio->setProperty(PROPERTY_LOOPING, TRUE);
558 }
559 dprintf(("Buffer %X: start at pos %d, loop %s",this, playpos, fLoop?"YES":"NO"));
560 }
561 else {
562 fLoop = dwFlags == DSBPLAY_LOOPING;
563 if (fLoop)
564 status |= DSBSTATUS_LOOPING;
565
566 daudio->setProperty(PROPERTY_LOOPING, fLoop);
567 dprintf((" Buffer %X: already playing, loop %s",this, fLoop?"YES":"NO"));
568 }
569
570 return DS_OK;
571}
572//******************************************************************************
573//******************************************************************************
574HRESULT IDirectAudioBuffer::Stop( )
575{
576 dprintf(("DSOUND-IDirectAudioBuffer::DAudioBufStop %x", this));
577 fPlaying = FALSE;
578 status &= ~(DSBSTATUS_PLAYING | DSBSTATUS_LOOPING);
579
580 daudio->stop();
581
582 if (notify != NULL)
583 notify->CheckStop();
584
585 return DS_OK;
586}
587//******************************************************************************
588//******************************************************************************
589HRESULT IDirectAudioBuffer::Restore( )
590{
591 dprintf(("DSOUND-IDirectAudioBuffer::DAudioBufRestore %x", this));
592 return DS_OK;
593}
594//******************************************************************************
595//******************************************************************************
596//Wrapper functions. Can be removed when switching to a compiler that supports
597//stdcall calling convention for class methods.
598//******************************************************************************
599//******************************************************************************
600HRESULT WINAPI DAudioBufQueryInterface(THIS, REFIID riid, LPVOID * ppvObj)
601{
602 IDirectAudioBuffer *me = (IDirectAudioBuffer *)This;
603 if(This == NULL) {
604 DebugInt3();
605 return DSERR_INVALIDPARAM;
606 }
607 return me->QueryInterface(riid, ppvObj);
608}
609//******************************************************************************
610//******************************************************************************
611ULONG WINAPI DAudioBufAddRef(THIS)
612{
613 IDirectAudioBuffer *me = (IDirectAudioBuffer *)This;
614 if(This == NULL) {
615 DebugInt3();
616 return DSERR_INVALIDPARAM;
617 }
618 return me->AddRef();
619}
620//******************************************************************************
621//******************************************************************************
622ULONG WINAPI DAudioBufRelease(THIS)
623{
624 IDirectAudioBuffer *me = (IDirectAudioBuffer *)This;
625 if(This == NULL) {
626 DebugInt3();
627 return DSERR_INVALIDPARAM;
628 }
629 return me->Release();
630}
631//******************************************************************************
632//******************************************************************************
633HRESULT WINAPI DAudioBufGetCaps(THIS_ LPDSBCAPS lpCaps)
634{
635 IDirectAudioBuffer *me = (IDirectAudioBuffer *)This;
636 if(This == NULL) {
637 DebugInt3();
638 return DSERR_INVALIDPARAM;
639 }
640 return me->GetCaps(lpCaps);
641}
642//******************************************************************************
643//******************************************************************************
644HRESULT WINAPI DAudioBufGetCurrentPosition(THIS_ LPDWORD a,LPDWORD b)
645{
646 IDirectAudioBuffer *me = (IDirectAudioBuffer *)This;
647 if(This == NULL) {
648 DebugInt3();
649 return DSERR_INVALIDPARAM;
650 }
651 return me->GetCurrentPosition(a, b);
652}
653//******************************************************************************
654//******************************************************************************
655HRESULT WINAPI DAudioBufGetFormat(THIS_ LPWAVEFORMATEX a, DWORD b, LPDWORD c)
656{
657 IDirectAudioBuffer *me = (IDirectAudioBuffer *)This;
658 if(This == NULL) {
659 DebugInt3();
660 return DSERR_INVALIDPARAM;
661 }
662 return me->GetFormat(a,b,c);
663}
664//******************************************************************************
665//******************************************************************************
666HRESULT WINAPI DAudioBufGetVolume(THIS_ LPLONG a)
667{
668 IDirectAudioBuffer *me = (IDirectAudioBuffer *)This;
669 if(This == NULL) {
670 DebugInt3();
671 return DSERR_INVALIDPARAM;
672 }
673 return me->GetVolume(a);
674}
675//******************************************************************************
676//******************************************************************************
677HRESULT WINAPI DAudioBufGetPan(THIS_ LPLONG a)
678{
679 IDirectAudioBuffer *me = (IDirectAudioBuffer *)This;
680 if(This == NULL) {
681 DebugInt3();
682 return DSERR_INVALIDPARAM;
683 }
684 return me->GetPan(a);
685}
686//******************************************************************************
687//******************************************************************************
688HRESULT WINAPI DAudioBufGetFrequency(THIS_ LPDWORD a)
689{
690 IDirectAudioBuffer *me = (IDirectAudioBuffer *)This;
691 if(This == NULL) {
692 DebugInt3();
693 return DSERR_INVALIDPARAM;
694 }
695 return me->GetFrequency(a);
696}
697//******************************************************************************
698//******************************************************************************
699HRESULT WINAPI DAudioBufGetStatus(THIS_ LPDWORD a)
700{
701 IDirectAudioBuffer *me = (IDirectAudioBuffer *)This;
702 if(This == NULL) {
703 DebugInt3();
704 return DSERR_INVALIDPARAM;
705 }
706 return me->GetStatus(a);
707}
708//******************************************************************************
709//******************************************************************************
710HRESULT WINAPI DAudioBufInitialize(THIS_ LPDIRECTSOUND a, LPDSBUFFERDESC b)
711{
712 IDirectAudioBuffer *me = (IDirectAudioBuffer *)This;
713 if(This == NULL) {
714 DebugInt3();
715 return DSERR_INVALIDPARAM;
716 }
717 return me->Initialize(a,b);
718}
719//******************************************************************************
720//******************************************************************************
721HRESULT WINAPI DAudioBufLock(THIS_ DWORD a,DWORD b,LPVOID c,LPDWORD d,LPVOID e,LPDWORD f,DWORD g)
722{
723 IDirectAudioBuffer *me = (IDirectAudioBuffer *)This;
724 if(This == NULL) {
725 DebugInt3();
726 return DSERR_INVALIDPARAM;
727 }
728 return me->Lock(a,b,c,d,e,f,g);
729}
730//******************************************************************************
731//******************************************************************************
732HRESULT WINAPI DAudioBufPlay(THIS_ DWORD a, DWORD b,DWORD c)
733{
734 IDirectAudioBuffer *me = (IDirectAudioBuffer *)This;
735 if(This == NULL) {
736 DebugInt3();
737 return DSERR_INVALIDPARAM;
738 }
739 return me->Play(a,b,c);
740}
741//******************************************************************************
742//******************************************************************************
743HRESULT WINAPI DAudioBufSetCurrentPosition(THIS_ DWORD a)
744{
745 IDirectAudioBuffer *me = (IDirectAudioBuffer *)This;
746 if(This == NULL) {
747 DebugInt3();
748 return DSERR_INVALIDPARAM;
749 }
750 return me->SetCurrentPosition(a);
751}
752//******************************************************************************
753//******************************************************************************
754HRESULT WINAPI DAudioBufSetFormat(THIS_ LPWAVEFORMATEX a)
755{
756 IDirectAudioBuffer *me = (IDirectAudioBuffer *)This;
757 if(This == NULL) {
758 DebugInt3();
759 return DSERR_INVALIDPARAM;
760 }
761 return me->SetFormat(a);
762}
763//******************************************************************************
764//******************************************************************************
765HRESULT WINAPI DAudioBufSetVolume(THIS_ LONG a)
766{
767 IDirectAudioBuffer *me = (IDirectAudioBuffer *)This;
768 if(This == NULL) {
769 DebugInt3();
770 return DSERR_INVALIDPARAM;
771 }
772 return me->SetVolume(a);
773}
774//******************************************************************************
775//******************************************************************************
776HRESULT WINAPI DAudioBufSetPan(THIS_ LONG a)
777{
778 IDirectAudioBuffer *me = (IDirectAudioBuffer *)This;
779 if(This == NULL) {
780 DebugInt3();
781 return DSERR_INVALIDPARAM;
782 }
783 return me->SetPan(a);
784}
785//******************************************************************************
786//******************************************************************************
787HRESULT WINAPI DAudioBufSetFrequency(THIS_ DWORD a)
788{
789 IDirectAudioBuffer *me = (IDirectAudioBuffer *)This;
790 if(This == NULL) {
791 DebugInt3();
792 return DSERR_INVALIDPARAM;
793 }
794 return me->SetFrequency(a);
795
796}
797//******************************************************************************
798//******************************************************************************
799HRESULT WINAPI DAudioBufStop(THIS )
800{
801 IDirectAudioBuffer *me = (IDirectAudioBuffer *)This;
802 if(This == NULL) {
803 DebugInt3();
804 return DSERR_INVALIDPARAM;
805 }
806 return me->Stop();
807}
808//******************************************************************************
809//******************************************************************************
810HRESULT WINAPI DAudioBufUnlock(THIS_ LPVOID a,DWORD b,LPVOID c,DWORD d)
811{
812 IDirectAudioBuffer *me = (IDirectAudioBuffer *)This;
813 if(This == NULL) {
814 DebugInt3();
815 return DSERR_INVALIDPARAM;
816 }
817 return me->Unlock(a,b,c,d);
818}
819//******************************************************************************
820//******************************************************************************
821HRESULT WINAPI DAudioBufRestore(THIS )
822{
823 IDirectAudioBuffer *me = (IDirectAudioBuffer *)This;
824 if(This == NULL) {
825 DebugInt3();
826 return DSERR_INVALIDPARAM;
827 }
828 return me->Restore();
829}
830//******************************************************************************
831//******************************************************************************
832
Note: See TracBrowser for help on using the repository browser.