1 /* PROJECT: ReactOS sndrec32
2 * LICENSE: GPL - See COPYING in the top level directory
3 * FILE: base/applications/sndrec32/audio_waveout.hpp
4 * PURPOSE: Windows MM wave out abstraction
5 * PROGRAMMERS: Marco Pagliaricci (irc: rendar)
8 #ifndef _AUDIOWAVEOUT__H_
9 #define _AUDIOWAVEOUT__H_
11 #include "audio_format.hpp"
12 #include "audio_producer.hpp"
14 _AUDIO_NAMESPACE_START_
16 enum audio_waveout_status
29 friend class audio_buffer;
32 static DWORD WINAPI playing_procedure(LPVOID);
33 HANDLE wakeup_playthread;
36 WAVEFORMATEX wave_format;
37 WAVEHDR *wave_headers;
38 HWAVEOUT waveout_handle;
40 const audio_format &aud_info;
41 audio_producer &audio_buf;
43 /* Audio Playing Thread id */
46 audio_waveout_status status;
49 /* The temporary buffers for the audio data outgoing to the waveout
50 device and its size, and its total number */
52 /* base address for entire memory */
55 /* size in bytes for the entire memory */
58 /* number of little buffers */
61 /* Protected Functions */
64 void alloc_buffers_mem_(unsigned int, float);
65 void free_buffers_mem_(void);
67 void init_headers_(void);
68 void prep_headers_(void);
69 void unprep_headers_(void);
73 audio_waveout(const audio_format &aud_fmt,
74 audio_producer &a_buf) : wave_headers(0),
77 status(WAVEOUT_NOTREADY),
80 buffers(_AUDIO_DEFAULT_WAVEOUTBUFFERS)
82 /* Initializing internal wavein data */
91 /* Public Functions */
99 audio_waveout_status current_status(void)
109 unsigned int bufsz(void)
114 unsigned int samplevalue_max(void)
116 if (aud_info.bits() == 16)
117 return (unsigned int)65535;
118 else if (aud_info.bits() == 8)
119 return (unsigned int)255;
124 unsigned tot_samples_buf(void)
126 return aud_info.samples_in_bytes(mb_size);
129 unsigned int nsample(unsigned int nsamp)
133 if (aud_info.bits() == 16)
134 svalue = (unsigned int)abs(*((short *)(main_buffer + aud_info.bytes_in_samples(nsamp))));
135 else if (aud_info.bits() == 8)
136 svalue = (unsigned int)((ptrdiff_t) *(main_buffer + aud_info.bytes_in_samples(nsamp)));
144 _AUDIO_NAMESPACE_END_
146 #endif /* _AUDIOWAVEOUT__H_ */