1 #ifndef _AUDIOWAVEIN_H_
2 #define _AUDIOWAVEIN_H_
6 #include "audio_def.hpp"
7 #include "audio_format.hpp"
8 #include "audio_receiver.hpp"
12 _AUDIO_NAMESPACE_START_
17 enum audio_wavein_status { WAVEIN_NOTREADY, WAVEIN_READY,
18 WAVEIN_RECORDING, WAVEIN_ERR,
19 WAVEIN_STOP, WAVEIN_FLUSHING
34 // The new recording thread sends message to this procedure
35 // about open recording, close, and sound data recorded
38 static DWORD WINAPI recording_procedure( LPVOID );
41 // When this event is signaled, then the previsiously created
42 // recording thread will wake up and start recording audio
43 // and will pass audio data to an `audio_receiver' object.
46 HANDLE wakeup_recthread;
47 HANDLE data_flushed_event;
55 //TODO: puts these structs in private?!
61 // Audio wavein device stuff
64 WAVEFORMATEX wave_format;
65 WAVEHDR * wave_headers;
66 HWAVEIN wavein_handle;
72 audio_format aud_info;
74 audio_receiver & audio_rcvd;
79 // Audio Recorder Thread id
91 audio_wavein_status status;
100 // How many seconds of audio
101 // can record the internal buffer
102 // before flushing audio data
103 // to the `audio_receiver' class?
110 // The temporary buffers for the audio
111 // data incoming from the wavein device
112 // and its size, and its total number.
116 unsigned int mb_size;
118 unsigned int buffers;
125 // Protected Functions
129 //initialize all structures and variables.
132 void alloc_buffers_mem_( unsigned int, float );
133 void free_buffers_mem_( void );
135 void init_headers_( void );
136 void prep_headers_( void );
137 void unprep_headers_( void );
138 void add_buffers_to_driver_( void );
154 const audio_format & a_info, audio_receiver & a_receiver )
157 aud_info( a_info ), audio_rcvd( a_receiver ),
158 status( WAVEIN_NOTREADY ), main_buffer( 0 ), mb_size( 0 ),
159 buffers( _AUDIO_DEFAULT_WAVEINBUFFERS )
163 // Initializing internal wavein data
182 ~audio_wavein( void )
199 void start_recording( void );
200 void stop_recording( void );
204 audio_wavein_status current_status ( void ) const
209 float buffer_secs( void ) const
213 void buffer_secs( float bsecs )
224 // Set seconds lenght for each
232 unsigned int total_buffers( void ) const
237 void total_buffers( unsigned int tot_bufs )
249 // Sets the number of total buffers.
256 audio_format format( void ) const
266 _AUDIO_NAMESPACE_END_
271 #endif //ifdef _AUDIOWAVEIN_H_