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

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

underrun changes (pause & restart properly)

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