1 // Licensed under the Apache License, Version 2.0
2 // <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
3 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
4 // All files in the project carrying such notice may not be copied, modified, or distributed
5 // except according to those terms.
6 //! MM procedure declarations, constant definitions and macros
7 use shared::basetsd::DWORD_PTR;
8 use shared::minwindef::{BYTE, DWORD, UINT, WORD};
9 use shared::mmreg::WAVEFORMATEX;
10 use um::winnt::{LPSTR, WCHAR};
11 //109 (Win 7 SDK)
12 pub type MMVERSION = UINT;
13 pub type MMRESULT = UINT;
14 STRUCT!{#[repr(packed)] struct MMTIME_smpte {
15     hour: BYTE,
16     min: BYTE,
17     sec: BYTE,
18     frame: BYTE,
19     fps: BYTE,
20     dummy: BYTE,
21     pad: [BYTE; 2],
22 }}
23 STRUCT!{#[repr(packed)] struct MMTIME_midi {
24     songptrpos: DWORD,
25 }}
26 UNION!{#[repr(packed)] union MMTIME_u {
27     [u32; 2],
28     ms ms_mut: DWORD,
29     sample sample_mut: DWORD,
30     cb cb_mut: DWORD,
31     ticks ticks_mut: DWORD,
32     smpte smpte_mut: MMTIME_smpte,
33     midi midi_mut: MMTIME_midi,
34 }}
35 STRUCT!{#[repr(packed)] struct MMTIME {
36     wType: UINT,
37     u: MMTIME_u,
38 }}
39 pub type PMMTIME = *mut MMTIME;
40 pub type NPMMTIME = *mut MMTIME;
41 pub type LPMMTIME = *mut MMTIME;
42 pub const TIME_MS: UINT = 0x0001;
43 pub const TIME_SAMPLES: UINT = 0x0002;
44 pub const TIME_BYTES: UINT = 0x0004;
45 pub const TIME_SMPTE: UINT = 0x0008;
46 pub const TIME_MIDI: UINT = 0x0010;
47 pub const TIME_TICKS: UINT = 0x0020;
48 pub const MM_JOY1MOVE: UINT = 0x3A0;
49 pub const MM_JOY2MOVE: UINT = 0x3A1;
50 pub const MM_JOY1ZMOVE: UINT = 0x3A2;
51 pub const MM_JOY2ZMOVE: UINT = 0x3A3;
52 pub const MM_JOY1BUTTONDOWN: UINT = 0x3B5;
53 pub const MM_JOY2BUTTONDOWN: UINT = 0x3B6;
54 pub const MM_JOY1BUTTONUP: UINT = 0x3B7;
55 pub const MM_JOY2BUTTONUP: UINT = 0x3B8;
56 pub const MM_MCINOTIFY: UINT = 0x3B9;
57 pub const MM_WOM_OPEN: UINT = 0x3BB;
58 pub const MM_WOM_CLOSE: UINT = 0x3BC;
59 pub const MM_WOM_DONE: UINT = 0x3BD;
60 pub const MM_WIM_OPEN: UINT = 0x3BE;
61 pub const MM_WIM_CLOSE: UINT = 0x3BF;
62 pub const MM_WIM_DATA: UINT = 0x3C0;
63 pub const MM_MIM_OPEN: UINT = 0x3C1;
64 pub const MM_MIM_CLOSE: UINT = 0x3C2;
65 pub const MM_MIM_DATA: UINT = 0x3C3;
66 pub const MM_MIM_LONGDATA: UINT = 0x3C4;
67 pub const MM_MIM_ERROR: UINT = 0x3C5;
68 pub const MM_MIM_LONGERROR: UINT = 0x3C6;
69 pub const MM_MOM_OPEN: UINT = 0x3C7;
70 pub const MM_MOM_CLOSE: UINT = 0x3C8;
71 pub const MM_MOM_DONE: UINT = 0x3C9;
72 pub const MMSYSERR_BASE: MMRESULT = 0;
73 pub const WAVERR_BASE: MMRESULT = 32;
74 pub const MIDIERR_BASE: MMRESULT = 64;
75 pub const TIMERR_BASE: MMRESULT = 96;
76 pub const JOYERR_BASE: MMRESULT = 160;
77 pub const MCIERR_BASE: MMRESULT = 256;
78 pub const MIXERR_BASE: MMRESULT = 1024;
79 pub const MMSYSERR_NOERROR: MMRESULT = 0;
80 pub const MMSYSERR_ERROR: MMRESULT = MMSYSERR_BASE + 1;
81 pub const MMSYSERR_BADDEVICEID: MMRESULT = MMSYSERR_BASE + 2;
82 pub const MMSYSERR_NOTENABLED: MMRESULT = MMSYSERR_BASE + 3;
83 pub const MMSYSERR_ALLOCATED: MMRESULT = MMSYSERR_BASE + 4;
84 pub const MMSYSERR_INVALHANDLE: MMRESULT = MMSYSERR_BASE + 5;
85 pub const MMSYSERR_NODRIVER: MMRESULT = MMSYSERR_BASE + 6;
86 pub const MMSYSERR_NOMEM: MMRESULT = MMSYSERR_BASE + 7;
87 pub const MMSYSERR_NOTSUPPORTED: MMRESULT = MMSYSERR_BASE + 8;
88 pub const MMSYSERR_BADERRNUM: MMRESULT = MMSYSERR_BASE + 9;
89 pub const MMSYSERR_INVALFLAG: MMRESULT = MMSYSERR_BASE + 10;
90 pub const MMSYSERR_INVALPARAM: MMRESULT = MMSYSERR_BASE + 11;
91 pub const MMSYSERR_HANDLEBUSY: MMRESULT = MMSYSERR_BASE + 12;
92 pub const MMSYSERR_INVALIDALIAS: MMRESULT = MMSYSERR_BASE + 13;
93 pub const MMSYSERR_BADDB: MMRESULT = MMSYSERR_BASE + 14;
94 pub const MMSYSERR_KEYNOTFOUND: MMRESULT = MMSYSERR_BASE + 15;
95 pub const MMSYSERR_READERROR: MMRESULT = MMSYSERR_BASE + 16;
96 pub const MMSYSERR_WRITEERROR: MMRESULT = MMSYSERR_BASE + 17;
97 pub const MMSYSERR_DELETEERROR: MMRESULT = MMSYSERR_BASE + 18;
98 pub const MMSYSERR_VALNOTFOUND: MMRESULT = MMSYSERR_BASE + 19;
99 pub const MMSYSERR_NODRIVERCB: MMRESULT = MMSYSERR_BASE + 20;
100 pub const MMSYSERR_MOREDATA: MMRESULT = MMSYSERR_BASE + 21;
101 pub const MMSYSERR_LASTERROR: MMRESULT = MMSYSERR_BASE + 21;
102 pub const MIDIERR_UNPREPARED: MMRESULT = MIDIERR_BASE + 0;
103 pub const MIDIERR_STILLPLAYING: MMRESULT = MIDIERR_BASE + 1;
104 pub const MIDIERR_NOMAP: MMRESULT = MIDIERR_BASE + 2;
105 pub const MIDIERR_NOTREADY: MMRESULT = MIDIERR_BASE + 3;
106 pub const MIDIERR_NODEVICE: MMRESULT = MIDIERR_BASE + 4;
107 pub const MIDIERR_INVALIDSETUP: MMRESULT = MIDIERR_BASE + 5;
108 pub const MIDIERR_BADOPENMODE: MMRESULT = MIDIERR_BASE + 6;
109 pub const MIDIERR_DONT_CONTINUE: MMRESULT = MIDIERR_BASE + 7;
110 pub const MIDIERR_LASTERROR: MMRESULT = MIDIERR_BASE + 7;
111 pub const CALLBACK_TYPEMASK: DWORD = 0x00070000;
112 pub const CALLBACK_NULL: DWORD = 0x00000000;
113 pub const CALLBACK_WINDOW: DWORD = 0x00010000;
114 pub const CALLBACK_TASK: DWORD = 0x00020000;
115 pub const CALLBACK_FUNCTION: DWORD = 0x00030000;
116 pub const CALLBACK_THREAD: DWORD = CALLBACK_TASK;
117 pub const CALLBACK_EVENT: DWORD = 0x00050000;
118 //497 (Win 7 SDK)
119 pub const WAVERR_BADFORMAT: MMRESULT = WAVERR_BASE + 0;
120 pub const WAVERR_STILLPLAYING: MMRESULT = WAVERR_BASE + 1;
121 pub const WAVERR_UNPREPARED: MMRESULT = WAVERR_BASE + 2;
122 pub const WAVERR_SYNC: MMRESULT = WAVERR_BASE + 3;
123 pub const WAVERR_LASTERROR: MMRESULT = WAVERR_BASE + 3;
124 DECLARE_HANDLE!{HWAVEIN, HWAVEIN__}
125 DECLARE_HANDLE!{HWAVEOUT, HWAVEOUT__}
126 pub type LPHWAVEIN = *mut HWAVEIN;
127 pub type LPHWAVEOUT = *mut HWAVEOUT;
128 pub const WOM_OPEN: UINT = MM_WOM_OPEN;
129 pub const WOM_CLOSE: UINT = MM_WOM_CLOSE;
130 pub const WOM_DONE: UINT = MM_WOM_DONE;
131 pub const WIM_OPEN: UINT = MM_WIM_OPEN;
132 pub const WIM_CLOSE: UINT = MM_WIM_CLOSE;
133 pub const WIM_DATA: UINT = MM_WIM_DATA;
134 pub const WAVE_MAPPER: UINT = 0xFFFFFFFF;
135 pub const WAVE_FORMAT_QUERY: DWORD = 0x0001;
136 pub const WAVE_ALLOWSYNC: DWORD = 0x0002;
137 pub const WAVE_MAPPED: DWORD = 0x0004;
138 pub const WAVE_FORMAT_DIRECT: DWORD = 0x0008;
139 pub const WAVE_FORMAT_DIRECT_QUERY: DWORD = WAVE_FORMAT_QUERY | WAVE_FORMAT_DIRECT;
140 pub const WAVE_MAPPED_DEFAULT_COMMUNICATION_DEVICE: DWORD = 0x0010;
141 STRUCT!{#[repr(packed)] struct WAVEHDR {
142     lpData: LPSTR,
143     dwBufferLength: DWORD,
144     dwBytesRecorded: DWORD,
145     dwUser: DWORD_PTR,
146     dwFlags: DWORD,
147     dwLoops: DWORD,
148     lpNext: *mut WAVEHDR,
149     reserved: DWORD_PTR,
150 }}
151 pub type PWAVEHDR = *mut WAVEHDR;
152 pub type NPWAVEHDR = *mut WAVEHDR;
153 pub type LPWAVEHDR = *mut WAVEHDR;
154 STRUCT!{#[repr(packed)] struct WAVEOUTCAPSW {
155     wMid: WORD,
156     wPid: WORD,
157     vDriverVersion: MMVERSION,
158     szPname: [WCHAR; 32],
159     dwFormats: DWORD,
160     wChannels: WORD,
161     wReserved1: WORD,
162     dwSupport: DWORD,
163 }}
164 pub type PWAVEOUTCAPSW = *mut WAVEOUTCAPSW;
165 pub type NPWAVEOUTCAPSW = *mut WAVEOUTCAPSW;
166 pub type LPWAVEOUTCAPSW = *mut WAVEOUTCAPSW;
167 STRUCT!{#[repr(packed)] struct WAVEINCAPSW {
168     wMid: WORD,
169     wPid: WORD,
170     vDriverVersion: MMVERSION,
171     szPname: [WCHAR; 32],
172     dwFormats: DWORD,
173     wChannels: WORD,
174     wReserved1: WORD,
175 }}
176 pub type PWAVEINCAPSW = *mut WAVEINCAPSW;
177 pub type NPWAVEINCAPSW = *mut WAVEINCAPSW;
178 pub type LPWAVEINCAPSW = *mut WAVEINCAPSW;
179 pub const WAVE_INVALIDFORMAT: DWORD = 0x00000000;
180 pub const WAVE_FORMAT_1M08: DWORD = 0x00000001;
181 pub const WAVE_FORMAT_1S08: DWORD = 0x00000002;
182 pub const WAVE_FORMAT_1M16: DWORD = 0x00000004;
183 pub const WAVE_FORMAT_1S16: DWORD = 0x00000008;
184 pub const WAVE_FORMAT_2M08: DWORD = 0x00000010;
185 pub const WAVE_FORMAT_2S08: DWORD = 0x00000020;
186 pub const WAVE_FORMAT_2M16: DWORD = 0x00000040;
187 pub const WAVE_FORMAT_2S16: DWORD = 0x00000080;
188 pub const WAVE_FORMAT_4M08: DWORD = 0x00000100;
189 pub const WAVE_FORMAT_4S08: DWORD = 0x00000200;
190 pub const WAVE_FORMAT_4M16: DWORD = 0x00000400;
191 pub const WAVE_FORMAT_4S16: DWORD = 0x00000800;
192 pub const WAVE_FORMAT_44M08: DWORD = 0x00000100;
193 pub const WAVE_FORMAT_44S08: DWORD = 0x00000200;
194 pub const WAVE_FORMAT_44M16: DWORD = 0x00000400;
195 pub const WAVE_FORMAT_44S16: DWORD = 0x00000800;
196 pub const WAVE_FORMAT_48M08: DWORD = 0x00001000;
197 pub const WAVE_FORMAT_48S08: DWORD = 0x00002000;
198 pub const WAVE_FORMAT_48M16: DWORD = 0x00004000;
199 pub const WAVE_FORMAT_48S16: DWORD = 0x00008000;
200 pub const WAVE_FORMAT_96M08: DWORD = 0x00010000;
201 pub const WAVE_FORMAT_96S08: DWORD = 0x00020000;
202 pub const WAVE_FORMAT_96M16: DWORD = 0x00040000;
203 pub const WAVE_FORMAT_96S16: DWORD = 0x00080000;
204 //782 (Win 7 SDK)
205 pub type PWAVEFORMATEX = *mut WAVEFORMATEX;
206 pub type NPWAVEFORMATEX = *mut WAVEFORMATEX;
207 pub type LPWAVEFORMATEX = *mut WAVEFORMATEX;
208 pub type LPCWAVEFORMATEX = *const WAVEFORMATEX;
209 //2170 (Win 7 SDK)
210 pub const TIMERR_NOERROR: MMRESULT = 0;
211 pub const TIMERR_NOCANDO: MMRESULT = TIMERR_BASE + 1;
212 pub const TIMERR_STRUCT: MMRESULT = TIMERR_BASE + 33;
213 //2198 (Win 7 SDK)
214 STRUCT!{#[repr(packed)] struct TIMECAPS {
215     wPeriodMin: UINT,
216     wPeriodMax: UINT,
217 }}
218 pub type PTIMECAPS = *mut TIMECAPS;
219 pub type NPTIMECAPS = *mut TIMECAPS;
220 pub type LPTIMECAPS = *mut TIMECAPS;
221 STRUCT!{#[repr(packed)] struct MIDIHDR {
222     lpData: LPSTR,
223     dwBufferLength: DWORD,
224     dwBytesRecorded: DWORD,
225     dwUser: DWORD_PTR,
226     dwFlags: DWORD,
227     lpNext: *mut MIDIHDR,
228     reserved: DWORD_PTR,
229     dwOffset: DWORD,
230     dwReserved: [DWORD_PTR; 8],
231 }}
232 pub type PMIDIHDR = *mut MIDIHDR;
233 pub type NPMIDIHDR = *mut MIDIHDR;
234 pub type LPMIDIHDR = *mut MIDIHDR;
235 STRUCT!{#[repr(packed)] struct MIDIINCAPSW {
236     wMid: WORD,
237     wPid: WORD,
238     vDriverVersion: MMVERSION,
239     szPname: [WCHAR; 32],
240     dwSupport: DWORD,
241 }}
242 pub type PMIDIINCAPSW = *mut MIDIINCAPSW;
243 pub type NPMIDIINCAPSW = *mut MIDIINCAPSW;
244 pub type LPMIDIINCAPSW = *mut MIDIINCAPSW;
245 STRUCT!{#[repr(packed)] struct MIDIOUTCAPSW {
246     wMid: WORD,
247     wPid: WORD,
248     vDriverVersion: MMVERSION,
249     szPname: [WCHAR; 32],
250     wTechnology: WORD,
251     wVoices: WORD,
252     wNotes: WORD,
253     wChannelMask: WORD,
254     dwSupport: DWORD,
255 }}
256 pub type PMIDIOUTCAPSW = *mut MIDIOUTCAPSW;
257 pub type NPMIDIOUTCAPSW = *mut MIDIOUTCAPSW;
258 pub type LPMIDIOUTCAPSW = *mut MIDIOUTCAPSW;
259 DECLARE_HANDLE!{HMIDIIN, HMIDIIN__}
260 DECLARE_HANDLE!{HMIDIOUT, HMIDIOUT__}
261 pub type LPHMIDIIN = *mut HMIDIIN;
262 pub type LPHMIDIOUT = *mut HMIDIOUT;
263 DECLARE_HANDLE!{HMIDISTRM, HMIDISTRM__}
264 DECLARE_HANDLE!{HMIDI, HMIDI__}
265 pub type LPHMIDISTRM = *mut HMIDISTRM;
266 pub type LPHMIDI = *mut HMIDI;
267