Changeset 10835
- Timestamp:
- 08/18/11 13:09:19 (21 months ago)
- Location:
- ossiedev/branches/mcarrick/ossiedev-trunk/platform/AudioDevice
- Files:
-
- 6 modified
-
Makefile.am (modified) (1 diff)
-
configure.ac (modified) (3 diffs)
-
reconf (modified) (1 diff)
-
src/AudioDevice.cpp (modified) (25 diffs)
-
src/AudioDevice.h (modified) (4 diffs)
-
src/main.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ossiedev/branches/mcarrick/ossiedev-trunk/platform/AudioDevice/Makefile.am
r9466 r10835 18 18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 # 20 ACLOCAL_AMFLAGS = -I m421 20 22 AM_CXXFLAGS = -Wall -I../../system/ossie/include -I../../system/ossie/include/ossie -I../../system/standardInterfaces/include 23 24 LDADD = ../../system/ossie/parser/libossieparser.la ../../system/ossie/idl/libossieidl.la ../../system/ossie/framework/libossiecf.la ../../system/standardInterfaces/libstandardinterfaces.la 21 AM_CXXFLAGS = -Wall 25 22 26 23 bin_PROGRAMS = AudioDevice -
ossiedev/branches/mcarrick/ossiedev-trunk/platform/AudioDevice/configure.ac
r9466 r10835 19 19 dnl 20 20 21 AC_INIT(AudioDevice, 0. 7.3)21 AC_INIT(AudioDevice, 0.8.1) 22 22 AM_INIT_AUTOMAKE 23 23 24 # 25 # Autoheader 26 # 27 AC_CONFIG_HEADER(config.h) 28 AH_TOP([ 29 #ifndef __LIQUID_CONFIG_H__ 30 #define __LIQUID_CONFIG_H__ 31 ]) 32 AH_BOTTOM([ 33 #endif // __LIQUID_CONFIG_H__ 34 ]) 35 24 36 AC_PREFIX_DEFAULT("/sdr") 25 AC_CONFIG_MACRO_DIR([m4]) 26 LT_INIT 37 38 # 39 # Checks for necessary programs 40 # 27 41 AC_PROG_CXX 28 42 AC_PROG_INSTALL … … 33 47 AC_FUNC_FORK 34 48 49 # push C++ language (omniORB4 complains if this action isn't taken) 35 50 AC_LANG_PUSH([C++]) 36 51 … … 40 55 AC_CHECK_HEADERS([omniORB4/CORBA.h], [], [AC_MSG_ERROR([cannot find omniORB4 header files])]) 41 56 42 # AC_CHECK_LIB([standardInterfaces], [main], [], [AC_MSG_ERROR([cannot find standardInterfaces])]) 43 # AC_CHECK_HEADERS([standardinterfaces/complexShort.h], [], [AC_MSG_ERROR([cannot find standardInterfaces header files])]) 57 # check for OSSIE libraries, headers 58 AC_CHECK_LIB([ossieidl], [main], [], [AC_MSG_ERROR([cannot find ossieidl])]) 59 AC_CHECK_LIB([ossieparser], [main], [], [AC_MSG_ERROR([cannot find ossieparser])]) 60 AC_CHECK_LIB([ossiecf], [main], [], [AC_MSG_ERROR([cannot find ossiecf])]) 61 AC_CHECK_LIB([standardInterfaces], [main], [], [AC_MSG_ERROR([cannot find standardInterfaces])]) 62 AC_CHECK_HEADERS([standardinterfaces/complexShort.h], [], [AC_MSG_ERROR([cannot find standardInterfaces header files])]) 44 63 45 AC_CHECK_LIB([portaudio], [main], [], [AC_MSG_ERROR([cannot find portaudio library (try apt-get install libportaudio-dev)])])46 AC_CHECK_HEADERS([portaudio.h], [], [AC_MSG_ERROR([cannot find portaudio.h header (try apt-get install libportaudio-dev)])])64 AC_CHECK_LIB([portaudio], [main], [], [AC_MSG_ERROR([cannot find portaudio library (try apt-get install portaudio19-dev)])]) 65 AC_CHECK_HEADERS([portaudio.h], [], [AC_MSG_ERROR([cannot find portaudio.h header (try apt-get install portaudio19-dev)])]) 47 66 48 67 AC_LANG_POP 49 68 50 export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig" 51 # PKG_CHECK_MODULES(OSSIE, ossie >= 0.6.0,,exit) 52 CXXFLAGS="$CXXFLAGS $OSSIE_CFLAGS" 69 # 70 # Checks for typedefs, structures, and compiler characteristics. 71 # 72 AC_HEADER_STDBOOL 73 AC_C_INLINE 74 AC_TYPE_SIZE_T 75 AC_TYPE_UINT32_T 76 AC_TYPE_UINT8_T 53 77 54 # IDL_FLAGS="$OSSIE_CFLAGS"55 # AC_SUBST(IDL_FLAGS)56 57 # LIBS="$LIBS $OSSIE_LIBS -lportaudio"58 LIBS="-lportaudio"59 60 AC_SUBST(SI_PATH)61 78 62 79 AC_CONFIG_FILES(Makefile) -
ossiedev/branches/mcarrick/ossiedev-trunk/platform/AudioDevice/reconf
r9126 r10835 24 24 aclocal 25 25 autoconf 26 autoheader 26 27 automake --foreign --add-missing -
ossiedev/branches/mcarrick/ossiedev-trunk/platform/AudioDevice/src/AudioDevice.cpp
r9807 r10835 1 /**************************************************************************** 1 /**************************************************************************** 2 2 3 3 Copyright 2009 Virginia Polytechnic Institute and State University … … 33 33 34 34 // Initializing constructor 35 AudioDevice_i::AudioDevice_i(char *uuid, char *label, char *profile, omni_condition *condition) 36 : Device_impl(uuid, label, profile),37 component_running(condition)35 AudioDevice_i::AudioDevice_i(char *uuid, char *label, char *profile, omni_condition *condition) 36 : Device_impl(uuid, label, profile), 37 component_running(condition) 38 38 { 39 39 DEBUG(3, AudioDevice, "constructor invoked") 40 40 41 // set configured flags to false42 // All properties must be configured before the stream is opened,43 // after which any change in properties will be ignored41 // set configured flags to false 42 // All properties must be configured before the stream is opened, 43 // after which any change in properties will be ignored 44 44 configured = false; 45 45 configured_prop_samplerate_record = false; … … 48 48 configured_prop_buffersize_playback = false; 49 49 50 // Create Port for output sound50 // Create Port for output sound 51 51 portAudioRecord = new standardInterfaces_i::complexShort_u("audioRecord"); 52 52 portAudioPlayback = new standardInterfaces_i::complexShort_p("audioPlayback"); 53 // TODO: create port for input sound54 55 // initialize portaudio stream53 // TODO: create port for input sound 54 55 // initialize portaudio stream 56 56 PaError err = Pa_Initialize(); 57 57 if (err != paNoError) { … … 74 74 } 75 75 76 void AudioDevice_i::start() 76 void AudioDevice_i::start() 77 77 throw (CF::Resource::StartError, CORBA::SystemException) 78 78 { 79 79 DEBUG(3, AudioDevice, "start() invoked") 80 80 81 // start the streams81 // start the streams 82 82 StartStreams(); 83 83 } … … 89 89 DEBUG(3, AudioDevice, "stop() invoked") 90 90 91 // stop the streams91 // stop the streams 92 92 StopStreams(); 93 93 } 94 94 95 CORBA::Object_ptr AudioDevice_i::getPort(const char* portName) 95 CORBA::Object_ptr AudioDevice_i::getPort(const char* portName) 96 96 throw(CF::PortSupplier::UnknownPort, CORBA::SystemException) 97 97 … … 106 106 return u._retn(); 107 107 108 // Port name not found; throw exception108 // Port name not found; throw exception 109 109 throw CF::PortSupplier::UnknownPort(); 110 110 } 111 111 112 void AudioDevice_i::initialize() 112 void AudioDevice_i::initialize() 113 113 throw (CF::LifeCycle::InitializeError, CORBA::SystemException) 114 114 { … … 116 116 } 117 117 118 void AudioDevice_i::configure(const CF::Properties &props) 119 throw (CORBA::SystemException, 120 CF::PropertySet::InvalidConfiguration, 118 void AudioDevice_i::configure(const CF::Properties &props) 119 throw (CORBA::SystemException, 120 CF::PropertySet::InvalidConfiguration, 121 121 CF::PropertySet::PartialConfiguration) 122 122 { 123 DEBUG(3, AudioDevice, "configure() invoked. Number of props = " 124 << props.length()125 )123 DEBUG(3, AudioDevice, "configure() invoked. Number of props = " 124 << props.length() 125 ) 126 126 127 127 if (configured) { … … 132 132 } 133 133 134 // read properties from .prf135 134 // read properties from .prf 135 136 136 CORBA::Short n; 137 for (unsigned int i=0; i<props.length(); i++) { 137 for (unsigned int i=0; i<props.length(); i++) 138 { 138 139 DEBUG(3, AudioDevice, "configure property id : " << props[i].id) 139 140 … … 176 177 configured_prop_samplerate_playback && 177 178 configured_prop_buffersize_record && 178 configured_prop_buffersize_playback) { 179 configured_prop_buffersize_playback) 180 { 179 181 configured = true; 180 182 DEBUG(3, AudioDevice, "configured") … … 182 184 } 183 185 184 // TODO: reconfigure streams186 // TODO: reconfigure streams 185 187 if (!configured) 186 188 return; 187 189 188 // configure streams190 // configure streams 189 191 ConfigureStreams(); 190 192 } … … 199 201 200 202 void AudioDevice_i::OpenStreams() 201 throw (CF::Resource::StartError)202 { 203 // ensure properties have been configured203 throw (CF::Resource::StartError) 204 { 205 // ensure properties have been configured 204 206 if (!configured) { 205 207 std::cerr << "ERROR: AudioDevice_i::OpenStreams(), device not configured" << std::endl; … … 209 211 PaError err; 210 212 211 // open record stream213 // open record stream 212 214 err = Pa_OpenStream( 213 &pa_stream_record,214 NULL, // no input215 &pa_params_record,216 samplerate_record,217 buffersize_record,218 paClipOff, // disable clipping219 portaudio_callback_record,220 (void*)this);215 &pa_stream_record, 216 NULL, // no input 217 &pa_params_record, 218 samplerate_record, 219 buffersize_record, 220 paClipOff, // disable clipping 221 portaudio_callback_record, 222 (void*)this); 221 223 222 224 if (err != paNoError) { … … 225 227 } 226 228 227 // open playback stream229 // open playback stream 228 230 err = Pa_OpenStream( 229 &pa_stream_playback,230 &pa_params_playback,231 NULL, // no output232 samplerate_playback,233 buffersize_playback,234 paClipOff, // disable clipping235 portaudio_callback_playback,236 (void*)this);231 &pa_stream_playback, 232 &pa_params_playback, 233 NULL, // no output 234 samplerate_playback, 235 buffersize_playback, 236 paClipOff, // disable clipping 237 portaudio_callback_playback, 238 (void*)this); 237 239 238 240 if (err != paNoError) { … … 243 245 244 246 void AudioDevice_i::StartStreams() 245 throw (CF::Resource::StartError)247 throw (CF::Resource::StartError) 246 248 { 247 249 if (!configured) { … … 250 252 } 251 253 252 // start record, playback threads254 // start record, playback threads 253 255 PaError err; 254 256 … … 268 270 269 271 void AudioDevice_i::StopStreams() 270 throw (CF::Resource::StopError)272 throw (CF::Resource::StopError) 271 273 { 272 274 PaError err; … … 287 289 288 290 void AudioDevice_i::CloseStreams() 289 throw (CF::Resource::StopError)291 throw (CF::Resource::StopError) 290 292 { 291 293 PaError err; 292 294 293 295 err = Pa_CloseStream(pa_stream_record); 294 296 if (err != paNoError) { … … 296 298 throw CF::Resource::StopError(); 297 299 } 298 300 299 301 err = Pa_CloseStream(pa_stream_playback); 300 302 if (err != paNoError) { … … 306 308 void AudioDevice_i::ConfigureStreams() 307 309 { 308 // configure parameters: record310 // configure parameters: record 309 311 pa_params_record.device = Pa_GetDefaultOutputDevice(); 310 312 pa_params_record.channelCount = AUDIODEVICE_NUMCHANNELS; 311 313 pa_params_record.sampleFormat = AUDIODEVICE_SAMPLEFORMAT; 312 pa_params_record.suggestedLatency = 314 pa_params_record.suggestedLatency = 313 315 Pa_GetDeviceInfo( pa_params_record.device )->defaultLowOutputLatency; 314 316 pa_params_record.hostApiSpecificStreamInfo = NULL; 315 317 316 // configure parameters: playback318 // configure parameters: playback 317 319 pa_params_playback.device = Pa_GetDefaultOutputDevice(); 318 320 pa_params_playback.channelCount = AUDIODEVICE_NUMCHANNELS; 319 321 pa_params_playback.sampleFormat = AUDIODEVICE_SAMPLEFORMAT; 320 pa_params_playback.suggestedLatency = 322 pa_params_playback.suggestedLatency = 321 323 Pa_GetDeviceInfo( pa_params_playback.device )->defaultLowOutputLatency; 322 324 pa_params_playback.hostApiSpecificStreamInfo = NULL; … … 325 327 void AudioDevice_i::SetRecordData(short int * _data) 326 328 { 327 // copy data to buffer329 // copy data to buffer 328 330 for (unsigned int i=0; i<buffersize_record; i++) { 329 331 record_data_L[i] = _data[2*i+0]; … … 331 333 } 332 334 333 // push data335 // push data 334 336 portAudioRecord->pushPacket(record_data_L, record_data_R); 335 337 } … … 337 339 void AudioDevice_i::GetPlaybackData(short int * _data) 338 340 { 339 // wait for data341 // wait for data 340 342 portAudioPlayback->getData(playback_data_L, playback_data_R); 341 343 342 // copy to buffer344 // copy to buffer 343 345 for (unsigned int i=0; i<buffersize_playback; i++) { 344 346 _data[2*i+0] = (*playback_data_L)[i]; … … 346 348 } 347 349 348 // release input buffer350 // release input buffer 349 351 portAudioPlayback->bufferEmptied(); 350 352 } … … 360 362 AudioDevice_i * device = (AudioDevice_i*)userData; 361 363 362 // copy data from portaudio playback buffer364 // copy data from portaudio playback buffer 363 365 device->SetRecordData((short int*)inputBuffer); 364 366 … … 377 379 short int * data = (short int*)outputBuffer; 378 380 379 // copy data to portaudio playback buffer381 // copy data to portaudio playback buffer 380 382 device->GetPlaybackData(data); 381 383 -
ossiedev/branches/mcarrick/ossiedev-trunk/platform/AudioDevice/src/AudioDevice.h
r9807 r10835 56 56 57 57 /// Main sound card device (capture) definition 58 class AudioDevice_i : public virtual Device_impl 58 class AudioDevice_i : public virtual Device_impl 59 59 { 60 60 public: 61 /// Initializing constructor61 /// Initializing constructor 62 62 AudioDevice_i(char *uuid, char* label, char* profile, omni_condition *condition); 63 63 64 /// Default destructor64 /// Default destructor 65 65 ~AudioDevice_i(); 66 66 67 /// Sets isRunning to True (start)68 void start() 69 throw (CF::Resource::StartError, CORBA::SystemException);67 /// Sets isRunning to True (start) 68 void start() 69 throw (CF::Resource::StartError, CORBA::SystemException); 70 70 71 /// Send data recorded from device to port71 /// Send data recorded from device to port 72 72 void SetRecordData(short int * _data); 73 73 74 /// Receive data from port and send to device74 /// Receive data from port and send to device 75 75 void GetPlaybackData(short int * _data); 76 77 void stop() 78 throw (CF::Resource::StopError, CORBA::SystemException); 76 79 77 void stop() 78 throw (CF::Resource::StopError, CORBA::SystemException); 80 /// Returns CORBA object pointer to port 81 CORBA::Object_ptr getPort(const char* portName) 82 throw(CF::PortSupplier::UnknownPort, CORBA::SystemException); 79 83 80 /// Returns CORBA object pointer to port 81 CORBA::Object_ptr getPort(const char* portName)82 throw(CF::PortSupplier::UnknownPort, CORBA::SystemException);84 /// Checks if sound card device (capture) is already in use 85 void initialize() 86 throw (CF::LifeCycle::InitializeError, CORBA::SystemException); 83 87 84 /// Checks if sound card device (capture) is already in use 85 void initialize() 86 throw (CF::LifeCycle::InitializeError, CORBA::SystemException); 88 /// Sets the following properties (currently NOT read from .prf.xml) 89 /// - Access mode 90 /// - Format 91 /// - Number of channels 92 /// - Sampling rate 93 /// - Period size 94 /// - Buffer size 95 /// - Hardware parameters 96 void configure(const CF::Properties &props) 97 throw (CORBA::SystemException, 98 CF::PropertySet::InvalidConfiguration, 99 CF::PropertySet::PartialConfiguration); 87 100 88 /// Sets the following properties (currently NOT read from .prf.xml) 89 /// - Access mode 90 /// - Format 91 /// - Number of channels 92 /// - Sampling rate 93 /// - Period size 94 /// - Buffer size 95 /// - Hardware parameters 96 void configure(const CF::Properties &props) 97 throw (CORBA::SystemException, 98 CF::PropertySet::InvalidConfiguration, 99 CF::PropertySet::PartialConfiguration); 100 101 /// 102 void releaseObject() 103 throw (CF::LifeCycle::ReleaseError, CORBA::SystemException); 101 /// 102 void releaseObject() 103 throw (CF::LifeCycle::ReleaseError, CORBA::SystemException); 104 104 105 105 private: 106 /// Disallow default constructor106 /// Disallow default constructor 107 107 AudioDevice_i(); 108 108 109 /// Disallow copy constructor109 /// Disallow copy constructor 110 110 AudioDevice_i(AudioDevice_i&); 111 111 … … 118 118 unsigned int simplesequencelength; 119 119 CORBA::ShortSeq *simplesequence_ptr; 120 //simplesequence_ptr = new short[simplesequencelength];120 //simplesequence_ptr = new short[simplesequencelength]; 121 121 122 /// Port: output sound samples122 /// Port: output sound samples 123 123 standardInterfaces_i::complexShort_u *portAudioRecord; 124 124 standardInterfaces_i::complexShort_p *portAudioPlayback; 125 125 126 // properties configured flags126 // properties configured flags 127 127 bool configured; 128 128 bool configured_prop_samplerate_record; … … 137 137 void CloseStreams() throw (CF::Resource::StopError); 138 138 139 // portaudio: specific properties139 // portaudio: specific properties 140 140 PaStreamParameters pa_params_record; 141 141 PaStreamParameters pa_params_playback; … … 143 143 PaStream *pa_stream_playback; 144 144 145 // 145 // 146 146 unsigned int samplerate_record; 147 147 unsigned int samplerate_playback; -
ossiedev/branches/mcarrick/ossiedev-trunk/platform/AudioDevice/src/main.cpp
r9807 r10835 26 26 27 27 #include "AudioDevice.h" 28 #include "config.h" 28 29 29 30 using namespace std; … … 46 47 char *uuid = argv[1]; 47 48 char *label = argv[2]; 48 char *profile = argv[3]; 49 char *profile = argv[3]; 49 50 50 cout << "Identifier - " << uuid 51 << " Label - " << label 52 << " Profile - " << profile 51 cout << "Identifier - " << uuid 52 << " Label - " << label 53 << " Profile - " << profile 53 54 << endl; 54 55 … … 56 57 CF::Device_var AudioDevice_var; 57 58 58 // Create the audio device servant and object reference59 // Create the audio device servant and object reference 59 60 60 61 AudioDevice_servant = new AudioDevice_i(uuid, label, profile, component_running); … … 66 67 orb->bind_object_to_name((CORBA::Object_ptr) AudioDevice_var, objName.c_str()); 67 68 68 // This bit is ORB specific69 // omniorb is threaded and the servants are running at this point70 // so we block on the condition71 // The releaseObject method clear the condition and the component exits69 // This bit is ORB specific 70 // omniorb is threaded and the servants are running at this point 71 // so we block on the condition 72 // The releaseObject method clear the condition and the component exits 72 73 73 74 component_running->wait();