source: trunk/src/dsound/OS2SNDBUFFER.H@ 5280

Last change on this file since 5280 was 3555, checked in by mike, 25 years ago

Updated and slightly fixed DSOUND

File size: 5.7 KB
Line 
1/* $Id: OS2SNDBUFFER.H,v 1.7 2000-05-18 20:37:09 mike Exp $ */
2
3/*
4 * DirectSound SoundBuffer class
5 *
6 * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl)
7 *
8 * Project Odin Software License can be found in LICENSE.TXT
9 *
10 */
11#ifndef __OS2SNDBUFFER_H__
12#define __OS2SNDBUFFER_H__
13
14#undef THIS
15#define THIS VOID*This
16
17#undef THIS_
18#define THIS_ VOID*This,
19
20// a forward declaration of some classes is needed here!
21class OS2IDirectSoundNotify;
22class OS2IDirectSound3DBuffer;
23class OS2IDirectSound;
24
25class OS2IDirectSoundBuffer
26{
27 public:
28 //this one has to go first!
29 IDirectSoundBufferVtbl *lpVtbl;
30 IDirectSoundBufferVtbl Vtbl;
31
32 OS2IDirectSoundBuffer(OS2IDirectSound *DSound, const DSBUFFERDESC *lpDSBufferDesc);
33 OS2IDirectSoundBuffer() {};
34 ~OS2IDirectSoundBuffer();
35
36 static void OS2IDirectSoundBuffer::DestroyAllBuffers(); // called when DSound is closed
37
38 int Referenced;
39 inline HRESULT GetLastError() { return lastError; };
40 inline void SetNotify(OS2IDirectSoundNotify *_notify) {
41 notify = _notify; };
42 inline void Set3DBuffer(OS2IDirectSound3DBuffer *_buffer3D) {
43 buffer3D = _buffer3D; };
44 private:
45
46 protected:
47 HRESULT lastError;
48
49 ULONG writepos, playpos; // DSound write and play cursors
50 ULONG frequency; // DSB frequency - may differ from source sample
51 WAVEFORMATEX *lpfxFormat; // source sample format
52 ULONG status; // DSB status - playing, looping etc.
53 BOOL fLocked; // is buffer currently locked?
54 BOOL fPrimary; // is this a primary buffer?
55 LONG DSvolume; // DSB volume (in dB)
56 LONG volume; // volume (linear)
57 LONG DSpan; // DSB pan (in dB)
58 LONG pan; // pan (linear)
59 BOOL fPlaying,fLoop; // is buffer playing/looping?
60 DSBUFFERDESC bufferdesc; // DSB description
61 LONG frac; // saved mixer position overflow
62
63 char *lpBuffer; // sound data
64
65 OS2IDirectSoundNotify* notify; // pointer to the associated Notify object (if exists)
66 OS2IDirectSound3DBuffer* buffer3D; // pointer to the associated 3DBuffer object (if exists)
67 OS2IDirectSound* parentDS;
68
69 // Linked list management
70 OS2IDirectSoundBuffer* next; // Next OS2IDirectSoundBuffer
71 static OS2IDirectSoundBuffer* dsbroot; // List of OS2IDirectSoundBuffers
72 static OS2IDirectSoundBuffer* primary; // The primary SoundBuffer
73
74 friend HRESULT __stdcall SoundBufQueryInterface(THIS, REFIID riid, LPVOID * ppvObj);
75 friend ULONG __stdcall SoundBufAddRef(THIS);
76 friend ULONG __stdcall SoundBufRelease(THIS);
77 friend HRESULT __stdcall SoundBufGetCaps(THIS_ LPDSBCAPS );
78 friend HRESULT __stdcall SoundBufGetCurrentPosition(THIS_ LPDWORD,LPDWORD ) ;
79 friend HRESULT __stdcall SoundBufGetFormat(THIS_ LPWAVEFORMATEX, DWORD, LPDWORD ) ;
80 friend HRESULT __stdcall SoundBufGetVolume(THIS_ LPLONG ) ;
81 friend HRESULT __stdcall SoundBufGetPan(THIS_ LPLONG ) ;
82 friend HRESULT __stdcall SoundBufGetFrequency(THIS_ LPDWORD ) ;
83 friend HRESULT __stdcall SoundBufGetStatus(THIS_ LPDWORD ) ;
84 friend HRESULT __stdcall SoundBufInitialize(THIS_ LPDIRECTSOUND, LPDSBUFFERDESC ) ;
85 friend HRESULT __stdcall SoundBufLock(THIS_ DWORD,DWORD,LPVOID,LPDWORD,LPVOID,LPDWORD,DWORD ) ;
86 friend HRESULT __stdcall SoundBufPlay(THIS_ DWORD,DWORD,DWORD ) ;
87 friend HRESULT __stdcall SoundBufSetCurrentPosition(THIS_ DWORD ) ;
88 friend HRESULT __stdcall SoundBufSetFormat(THIS_ LPWAVEFORMATEX ) ;
89 friend HRESULT __stdcall SoundBufSetVolume(THIS_ LONG ) ;
90 friend HRESULT __stdcall SoundBufSetPan(THIS_ LONG ) ;
91 friend HRESULT __stdcall SoundBufSetFrequency(THIS_ DWORD ) ;
92 friend HRESULT __stdcall SoundBufStop(THIS ) ;
93 friend HRESULT __stdcall SoundBufUnlock(THIS_ LPVOID,DWORD,LPVOID,DWORD ) ;
94 friend HRESULT __stdcall SoundBufRestore(THIS ) ;
95
96 friend void MixCallback(ULONG cbMix);
97 friend void MixFunc (OS2IDirectSoundBuffer *firstBuf, OS2IDirectSoundBuffer *outBuf, ULONG cbMix);
98 friend void MixOneBuffer(OS2IDirectSoundBuffer *inBuf, int tomix, int outrate);
99};
100//******************************************************************************
101//******************************************************************************
102HRESULT __stdcall SoundBufQueryInterface(THIS, REFIID riid, LPVOID * ppvObj);
103ULONG __stdcall SoundBufAddRef(THIS);
104ULONG __stdcall SoundBufRelease(THIS);
105HRESULT __stdcall SoundBufGetCaps(THIS_ LPDSBCAPS );
106HRESULT __stdcall SoundBufGetCurrentPosition(THIS_ LPDWORD,LPDWORD ) ;
107HRESULT __stdcall SoundBufGetFormat(THIS_ LPWAVEFORMATEX, DWORD, LPDWORD ) ;
108HRESULT __stdcall SoundBufGetVolume(THIS_ LPLONG ) ;
109HRESULT __stdcall SoundBufGetPan(THIS_ LPLONG ) ;
110HRESULT __stdcall SoundBufGetFrequency(THIS_ LPDWORD ) ;
111HRESULT __stdcall SoundBufGetStatus(THIS_ LPDWORD ) ;
112HRESULT __stdcall SoundBufInitialize(THIS_ LPDIRECTSOUND, LPDSBUFFERDESC ) ;
113HRESULT __stdcall SoundBufLock(THIS_ DWORD,DWORD,LPVOID,LPDWORD,LPVOID,LPDWORD,DWORD ) ;
114HRESULT __stdcall SoundBufPlay(THIS_ DWORD,DWORD,DWORD ) ;
115HRESULT __stdcall SoundBufSetCurrentPosition(THIS_ DWORD ) ;
116HRESULT __stdcall SoundBufSetFormat(THIS_ LPWAVEFORMATEX ) ;
117HRESULT __stdcall SoundBufSetVolume(THIS_ LONG ) ;
118HRESULT __stdcall SoundBufSetPan(THIS_ LONG ) ;
119HRESULT __stdcall SoundBufSetFrequency(THIS_ DWORD ) ;
120HRESULT __stdcall SoundBufStop(THIS ) ;
121HRESULT __stdcall SoundBufUnlock(THIS_ LPVOID,DWORD,LPVOID,DWORD ) ;
122HRESULT __stdcall SoundBufRestore(THIS ) ;
123
124#endif
Note: See TracBrowser for help on using the repository browser.