Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenaudio_waveout.hpp
Go to the documentation of this file.
00001 /* PROJECT: ReactOS sndrec32 00002 * LICENSE: GPL - See COPYING in the top level directory 00003 * FILE: base/applications/sndrec32/audio_waveout.hpp 00004 * PURPOSE: Windows MM wave out abstraction 00005 * PROGRAMMERS: Marco Pagliaricci (irc: rendar) 00006 */ 00007 00008 00009 00010 00011 #ifndef _AUDIOWAVEOUT__H_ 00012 #define _AUDIOWAVEOUT__H_ 00013 00014 00015 #include "audio_def.hpp" 00016 #include "audio_format.hpp" 00017 00018 00019 #include "audio_producer.hpp" 00020 00021 00022 00023 _AUDIO_NAMESPACE_START_ 00024 00025 00026 00027 00028 00029 enum audio_waveout_status { WAVEOUT_NOTREADY, WAVEOUT_READY, 00030 WAVEOUT_PLAYING, WAVEOUT_FLUSHING, 00031 WAVEOUT_PAUSED, WAVEOUT_STOP, 00032 WAVEOUT_ERR, 00033 00034 }; 00035 00036 00037 00038 00039 00040 class audio_waveout 00041 { 00042 00043 friend class audio_buffer; 00044 00045 00046 00047 private: 00048 00049 00050 static DWORD WINAPI 00051 playing_procedure( LPVOID ); 00052 00053 00054 00055 HANDLE wakeup_playthread; 00056 00057 00058 00059 00060 protected: 00061 00062 00063 WAVEFORMATEX wave_format; 00064 WAVEHDR * wave_headers; 00065 HWAVEOUT waveout_handle; 00066 00067 00068 00069 00070 00071 const audio_format & aud_info; 00072 audio_producer & audio_buf; 00073 00074 00075 00076 00077 00078 00079 // 00080 // Audio Playing Thread id 00081 // 00082 00083 DWORD playthread_id; 00084 00085 00086 00087 00088 00089 audio_waveout_status status; 00090 00091 00092 00093 00094 float buf_secs; 00095 00096 00097 00098 // 00099 // The temporary buffers for the audio 00100 // data outgoing to the waveout device 00101 // and its size, and its total number. 00102 // 00103 00104 00105 //base address for entire memory 00106 BYTE * main_buffer; 00107 00108 //size in bytes for the entire memory 00109 unsigned int mb_size; 00110 00111 //number of little buffers 00112 unsigned int buffers; 00113 00114 00115 00116 00117 00118 00119 // 00120 // Protected Functions 00121 // 00122 00123 void init_( void ); 00124 void alloc_buffers_mem_( unsigned int, float ); 00125 void free_buffers_mem_( void ); 00126 00127 00128 void init_headers_( void ); 00129 void prep_headers_( void ); 00130 void unprep_headers_( void ); 00131 00132 00133 00134 00135 00136 00137 00138 public: 00139 00140 // 00141 // Ctors 00142 // 00143 00144 audio_waveout( const audio_format & aud_fmt, 00145 audio_producer & a_buf ) 00146 00147 : wave_headers( 0 ), aud_info( aud_fmt ), 00148 audio_buf( a_buf ), status( WAVEOUT_NOTREADY ), 00149 main_buffer( 0 ), mb_size( 0 ), 00150 buffers( _AUDIO_DEFAULT_WAVEOUTBUFFERS ) 00151 { 00152 00153 // 00154 // Initializing internal wavein data 00155 // 00156 00157 00158 init_(); 00159 00160 } 00161 00162 00163 00164 00165 00166 00167 // 00168 // Dtor 00169 // 00170 00171 ~audio_waveout( void ) 00172 { } 00173 00174 00175 00176 00177 // 00178 // Public Functions 00179 // 00180 00181 void open ( void ); 00182 void play ( void ); 00183 void pause ( void ); 00184 void stop ( void ); 00185 void close ( void ); 00186 00187 00188 audio_waveout_status current_status( void ) 00189 { return status; } 00190 00191 00192 00193 00194 BYTE * buf( void ) { return main_buffer; } 00195 unsigned int bufsz( void ) { return mb_size; } 00196 00197 00198 unsigned int samplevalue_max( void ) 00199 { 00200 00201 if ( aud_info.bits() == 16 ) 00202 return (unsigned int )65535; 00203 00204 else if ( aud_info.bits() == 8 ) 00205 return (unsigned int)255; 00206 00207 else 00208 return 0; 00209 } 00210 00211 00212 unsigned tot_samples_buf( void ) 00213 { 00214 00215 00216 return aud_info.samples_in_bytes( mb_size ); 00217 00218 00219 } 00220 00221 unsigned int nsample ( unsigned int nsamp ) 00222 { 00223 00224 00225 unsigned int svalue; 00226 00227 00228 00229 if ( aud_info.bits() == 16 ) 00230 svalue = ( unsigned int ) abs( *(( short * ) (main_buffer + aud_info.bytes_in_samples( nsamp )))); 00231 else if ( aud_info.bits() == 8 ) 00232 svalue = (unsigned int)(( ptrdiff_t ) *(main_buffer + aud_info.bytes_in_samples( nsamp ))); 00233 00234 else 00235 svalue = 0; 00236 00237 return svalue; 00238 00239 } 00240 00241 00242 }; 00243 00244 00245 00246 _AUDIO_NAMESPACE_END_ 00247 00248 00249 00250 00251 #endif //ifdef _AUDIOWAVEOUT__H_ Generated on Thu May 24 2012 04:17:43 for ReactOS by
1.7.6.1
|