Changeset 8803
- Timestamp:
- 02/26/09 10:50:41 (4 years ago)
- Location:
- ossiedev/branches/0.7.x/platform/AudioDevice/src
- Files:
-
- 2 modified
-
AudioDevice.cpp (modified) (5 diffs)
-
AudioDevice.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ossiedev/branches/0.7.x/platform/AudioDevice/src/AudioDevice.cpp
r8800 r8803 1 1 /**************************************************************************** 2 2 3 Copyright 2009 Virginia Polytechnic Institute and State University 3 4 … … 20 21 ****************************************************************************/ 21 22 22 /** \file23 The soundCardCapture.cpp file contains definitions for the AudioDevice_i24 class implementation.25 */26 27 23 #include <iostream> 28 24 #include "AudioDevice.h" 29 25 30 #define AUDIODEVICE_PROPID_SAMPLERATE CAPTURE"DCE:xxx:0"26 #define AUDIODEVICE_PROPID_SAMPLERATERECORD "DCE:xxx:0" 31 27 #define AUDIODEVICE_PROPID_SAMPLERATEPLAYBACK "DCE:xxx:1" 32 #define AUDIODEVICE_PROPID_BUFFERSIZE CAPTURE"DCE:xxx:2"28 #define AUDIODEVICE_PROPID_BUFFERSIZERECORD "DCE:xxx:2" 33 29 #define AUDIODEVICE_PROPID_BUFFERSIZEPLAYBACK "DCE:xxx:3" 34 30 35 31 // Initializing constructor 36 32 AudioDevice_i::AudioDevice_i(char *uuid, char *label, char *profile, omni_condition *condition) 37 : Device_impl(uuid, label, profile), component_running(condition), isRunning(false) 33 : Device_impl(uuid, label, profile), 34 component_running(condition), 35 isRunning(false) 38 36 { 39 37 DEBUG(3, AudioDevice, "constructor invoked") … … 89 87 90 88 if (!CORBA::is_nil(u)) 91 return u._retn();89 return u._retn(); 92 90 93 // /Port name not found; throw exception91 // Port name not found; throw exception 94 92 throw CF::PortSupplier::UnknownPort(); 95 96 93 } 97 94 98 95 void AudioDevice_i::initialize() 99 96 throw (CF::LifeCycle::InitializeError, CORBA::SystemException) 100 101 97 { 102 98 DEBUG(3, AudioDevice, "initialize() invoked") 103 104 105 DEBUG(1, AudioDevice, "Initialize (capture) exit")106 99 } 107 100 … … 116 109 117 110 // read properties from .prf 118 unsigned int rate(16000); // default sampling rate119 111 112 CORBA::Short n; 120 113 for (unsigned int i=0; i<props.length(); i++) 121 114 { 122 115 DEBUG(3, AudioDevice, "configure property id : " << props[i].id) 123 116 124 if (strcmp(props[i].id, AUDIODEVICE_PROPID_SAMPLERATECAPTURE)==0) 125 { 126 CORBA::Short n; 117 if (strcmp(props[i].id, AUDIODEVICE_PROPID_SAMPLERATERECORD)==0) { 118 // sample rate: record 127 119 props[i].value >>= n; 128 rate = n; 129 DEBUG(3, AudioDevice, "sample rate: " << rate << " Hz") 130 } 131 else 132 { 133 DEBUG(1, AudioDevice, "ERROR: unkown configure() property id " << props[i].id) 120 samplerate_record = n; 121 DEBUG(3, AudioDevice, "sample rate (record): " << samplerate_record << " Hz") 122 } else if (strcmp(props[i].id, AUDIODEVICE_PROPID_SAMPLERATEPLAYBACK)==0) { 123 // sample rate: playback 124 props[i].value >>= n; 125 samplerate_playback = n; 126 DEBUG(3, AudioDevice, "sample rate (playback): " << samplerate_playback << " Hz") 127 } else if (strcmp(props[i].id, AUDIODEVICE_PROPID_BUFFERSIZERECORD)==0) { 128 // buffer size: record 129 props[i].value >>= n; 130 buffersize_record = n; 131 DEBUG(3, AudioDevice, "buffer size (record): " << buffersize_record) 132 } else if (strcmp(props[i].id, AUDIODEVICE_PROPID_BUFFERSIZEPLAYBACK)==0) { 133 // buffer size: playback 134 props[i].value >>= n; 135 buffersize_playback = n; 136 DEBUG(3, AudioDevice, "buffer size (playback): " << buffersize_playback) 137 } else { 138 std::cerr << "ERROR AudioDevice_i::configure(): unkown property id " 139 << props[i].id << std::endl; 134 140 throw(CF::PropertySet::InvalidConfiguration()); 135 141 } … … 151 157 PortTypes::ShortSequence L_out, R_out; 152 158 153 const int buf_size = 512; 154 155 short buf[buf_size]; 156 157 int buf_length = buf_size / 2; 158 159 L_out.length(buf_length); 160 R_out.length(buf_length); 159 L_out.length(1); 160 R_out.length(1); 161 161 162 int rc;163 164 162 while(1) 165 163 { -
ossiedev/branches/0.7.x/platform/AudioDevice/src/AudioDevice.h
r8799 r8803 22 22 ****************************************************************************/ 23 23 24 /** \file25 The Sound_out.h file contains declarations for the SoundCardPlayback_i26 class.27 */28 29 30 31 24 #ifndef __OSSIE_AUDIO_DEVICE_H__ 32 25 #define __OSSIE_AUDIO_DEVICE_H__ … … 41 34 #include "standardinterfaces/complexShort.h" 42 35 #include "standardinterfaces/complexShort_u.h" 36 37 #include "portaudio.h" 38 39 static int portaudio_playback_callback( 40 const void *inputBuffer, 41 void *outputBuffer, 42 unsigned long framesPerBuffer, 43 const PaStreamCallbackTimeInfo* timeInfo, 44 PaStreamCallbackFlags statusFlags, 45 void *userData ); 46 47 static int portaudio_record_callback( 48 const void *inputBuffer, 49 void *outputBuffer, 50 unsigned long framesPerBuffer, 51 const PaStreamCallbackTimeInfo* timeInfo, 52 PaStreamCallbackFlags statusFlags, 53 void *userData ); 43 54 44 55 /// Main sound card device (capture) definition … … 110 121 standardInterfaces_i::complexShort_u *dataOut; 111 122 112 // --- Sound capture variables ---113 unsigned int length; ///<114 115 123 // Until I look at omni_condition... -TT 116 124 bool isRunning; ///< starts/stops loop in capture_sound() 125 126 // 127 unsigned int samplerate_record; 128 unsigned int samplerate_playback; 129 unsigned int buffersize_record; 130 unsigned int buffersize_playback; 117 131 118 132 };