source: trunk/src/winmm/dwaveout.h@ 2242

Last change on this file since 2242 was 2242, checked in by phaller, 26 years ago

Fix: memory leak in Dart thread callback functions

File size: 2.8 KB
Line 
1/* $Id: dwaveout.h,v 1.6 1999-12-29 08:33:56 phaller Exp $ */
2
3/*
4 * Wave playback class
5 * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl)
6 * Project Odin Software License can be found in LICENSE.TXT
7 */
8#ifndef __DWAVEOUT_H__
9#define __DWAVEOUT_H__
10
11#define STATE_STOPPED 0
12#define STATE_PLAYING 1
13#define STATE_PAUSED 2
14
15#define PREFILLBUF_DART 4
16#define DART_BUFSIZE 4096
17
18#ifdef OS2_ONLY
19#include "winmmtype.h"
20#endif
21#include "vmutex.h"
22
23#ifdef _OS2WIN_H
24#define MCI_MIX_BUFFER DWORD
25#define PMCI_MIX_BUFFER MCI_MIX_BUFFER *
26#define MCI_MIXSETUP_PARMS DWORD
27#define MCI_BUFFER_PARMS DWORD
28#define MCI_PLAY_PARMS DWORD
29#endif
30
31class DartWaveOut
32{
33public:
34 DartWaveOut(LPWAVEFORMATEX pwfx, ULONG nCallback, ULONG dwInstance, USHORT usSel);
35 DartWaveOut(LPWAVEFORMATEX pwfx, HWND hwndCallback);
36 DartWaveOut(LPWAVEFORMATEX pwfx);
37 ~DartWaveOut();
38
39 MMRESULT getError();
40 MMRESULT write(LPWAVEHDR pwh, UINT cbwh);
41 MMRESULT pause();
42 MMRESULT restart();
43 int getState() { return State; };
44 MMRESULT reset();
45
46 static BOOL queryFormat(ULONG formatTag, ULONG nChannels,
47 ULONG nSamplesPerSec, ULONG sampleSize);
48
49 static BOOL find(DartWaveOut *dwave);
50 static int getNumDevices();
51
52protected:
53 static void mciError(ULONG ulError);
54 void Init(LPWAVEFORMATEX pwfx);
55 void handler(ULONG ulStatus, PMCI_MIX_BUFFER pBuffer, ULONG ulFlags);
56
57private:
58 USHORT DeviceId;
59 ULONG ulBufferCount; /* Current file buffer */
60 ULONG ulBufSize;
61
62 ULONG ulError, State;
63
64 MCI_MIX_BUFFER *MixBuffer; /* Device buffers */
65 MCI_MIXSETUP_PARMS *MixSetupParms; /* Mixer parameters */
66 MCI_BUFFER_PARMS *BufferParms; /* Device buffer parms */
67
68 int SampleRate;
69 int BitsPerSample;
70 int nChannels;
71 int curPlayBuf, curFillBuf;
72 int curFillPos, curPlayPos; //fillpos == pos in os2 mix buffer, bufpos == pos in win buffer
73
74 // callback interface
75 LPDRVCALLBACK mthdCallback; // pointer to win32 routine for the callback
76 USHORT selCallback; // the win32 tib selector for the callback (saved at waveOutOpen)
77 void callback(HDRVR h, UINT uMessage, DWORD dwUser, DWORD dw1, DWORD dw2);
78 HWND hwndCallback;
79 DWORD dwInstance;
80
81 WAVEHDR *wavehdr,
82 *curhdr;
83
84 BOOL fMixerSetup;
85
86 VMutex *wmutex;
87 // Linked list management
88 DartWaveOut* next; // Next Timer
89 static DartWaveOut* waveout; // List of Timer
90
91#ifndef _OS2WIN_H
92 friend LONG APIENTRY WaveOutHandler(ULONG ulStatus, PMCI_MIX_BUFFER pBuffer, ULONG ulFlags);
93#endif
94};
95
96#endif
Note: See TracBrowser for help on using the repository browser.