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

Last change on this file since 3348 was 3348, checked in by sandervl, 25 years ago

restart, pause & underrun fixes

File size: 3.3 KB
Line 
1/* $Id: dwaveout.h,v 1.9 2000-04-08 09:16:54 sandervl 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 MMRESULT setVolume(ULONG ulVol);
44 ULONG getVolume() { return volume; };
45 int getState() { return State; };
46 MMRESULT reset();
47 ULONG getPosition();
48
49 ULONG getSampleRate() { return SampleRate; };
50 ULONG getBitsPerSample() { return BitsPerSample; };
51 ULONG getnumChannels() { return nChannels; };
52 ULONG getAvgBytesPerSecond() { return (BitsPerSample/8) * nChannels * SampleRate; };
53
54 static BOOL queryFormat(ULONG formatTag, ULONG nChannels,
55 ULONG nSamplesPerSec, ULONG sampleSize);
56
57 static BOOL find(DartWaveOut *dwave);
58 static int getNumDevices();
59
60protected:
61 static void mciError(ULONG ulError);
62 void Init(LPWAVEFORMATEX pwfx);
63 void handler(ULONG ulStatus, PMCI_MIX_BUFFER pBuffer, ULONG ulFlags);
64
65private:
66 USHORT DeviceId;
67 ULONG ulBufferCount; /* Current file buffer */
68 ULONG ulBufSize;
69
70 ULONG ulError, State;
71 ULONG volume; // Volume state
72
73 MCI_MIX_BUFFER *MixBuffer; /* Device buffers */
74 MCI_MIXSETUP_PARMS *MixSetupParms; /* Mixer parameters */
75 MCI_BUFFER_PARMS *BufferParms; /* Device buffer parms */
76
77 int SampleRate;
78 int BitsPerSample;
79 int nChannels;
80 int curPlayBuf, curFillBuf;
81 int curFillPos, curPlayPos; //fillpos == pos in os2 mix buffer, bufpos == pos in win buffer
82
83 // callback interface
84 LPDRVCALLBACK mthdCallback; // pointer to win32 routine for the callback
85 USHORT selCallback; // the win32 tib selector for the callback (saved at waveOutOpen)
86 void callback(HDRVR h, UINT uMessage, DWORD dwUser, DWORD dw1, DWORD dw2);
87 HWND hwndCallback;
88 DWORD dwInstance;
89
90 WAVEHDR *wavehdr,
91 *curhdr;
92
93 BOOL fMixerSetup;
94 BOOL fUnderrun;
95
96 VMutex *wmutex;
97 // Linked list management
98 DartWaveOut* next; // Next Timer
99 static DartWaveOut* waveout; // List of Timer
100
101#ifndef _OS2WIN_H
102 friend LONG APIENTRY WaveOutHandler(ULONG ulStatus, PMCI_MIX_BUFFER pBuffer, ULONG ulFlags);
103#endif
104};
105
106#endif
Note: See TracBrowser for help on using the repository browser.