Changeset 10835

Show
Ignore:
Timestamp:
08/18/11 13:09:19 (21 months ago)
Author:
mcarrick
Message:

pulling in latest changes from joes branch

Location:
ossiedev/branches/mcarrick/ossiedev-trunk/platform/AudioDevice
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • ossiedev/branches/mcarrick/ossiedev-trunk/platform/AudioDevice/Makefile.am

    r9466 r10835  
    1818# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
    1919# 
    20 ACLOCAL_AMFLAGS = -I m4 
    2120 
    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 
     21AM_CXXFLAGS = -Wall 
    2522 
    2623bin_PROGRAMS = AudioDevice 
  • ossiedev/branches/mcarrick/ossiedev-trunk/platform/AudioDevice/configure.ac

    r9466 r10835  
    1919dnl 
    2020 
    21 AC_INIT(AudioDevice, 0.7.3) 
     21AC_INIT(AudioDevice, 0.8.1) 
    2222AM_INIT_AUTOMAKE 
    2323 
     24#  
     25# Autoheader 
     26# 
     27AC_CONFIG_HEADER(config.h) 
     28AH_TOP([ 
     29#ifndef __LIQUID_CONFIG_H__ 
     30#define __LIQUID_CONFIG_H__ 
     31]) 
     32AH_BOTTOM([ 
     33#endif // __LIQUID_CONFIG_H__ 
     34]) 
     35 
    2436AC_PREFIX_DEFAULT("/sdr") 
    25 AC_CONFIG_MACRO_DIR([m4]) 
    26 LT_INIT 
     37 
     38#  
     39# Checks for necessary programs 
     40# 
    2741AC_PROG_CXX 
    2842AC_PROG_INSTALL 
     
    3347AC_FUNC_FORK 
    3448 
     49# push C++ language (omniORB4 complains if this action isn't taken) 
    3550AC_LANG_PUSH([C++]) 
    3651 
     
    4055AC_CHECK_HEADERS([omniORB4/CORBA.h], [], [AC_MSG_ERROR([cannot find omniORB4 header files])]) 
    4156 
    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 
     58AC_CHECK_LIB([ossieidl], [main], [], [AC_MSG_ERROR([cannot find ossieidl])]) 
     59AC_CHECK_LIB([ossieparser], [main], [], [AC_MSG_ERROR([cannot find ossieparser])]) 
     60AC_CHECK_LIB([ossiecf], [main], [], [AC_MSG_ERROR([cannot find ossiecf])]) 
     61AC_CHECK_LIB([standardInterfaces], [main], [], [AC_MSG_ERROR([cannot find standardInterfaces])]) 
     62AC_CHECK_HEADERS([standardinterfaces/complexShort.h], [], [AC_MSG_ERROR([cannot find standardInterfaces header files])]) 
    4463 
    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)])]) 
     64AC_CHECK_LIB([portaudio], [main], [], [AC_MSG_ERROR([cannot find portaudio library (try apt-get install portaudio19-dev)])]) 
     65AC_CHECK_HEADERS([portaudio.h], [], [AC_MSG_ERROR([cannot find portaudio.h header (try apt-get install portaudio19-dev)])]) 
    4766 
    4867AC_LANG_POP 
    4968 
    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# 
     72AC_HEADER_STDBOOL 
     73AC_C_INLINE 
     74AC_TYPE_SIZE_T 
     75AC_TYPE_UINT32_T 
     76AC_TYPE_UINT8_T 
    5377 
    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) 
    6178 
    6279AC_CONFIG_FILES(Makefile) 
  • ossiedev/branches/mcarrick/ossiedev-trunk/platform/AudioDevice/reconf

    r9126 r10835  
    2424aclocal 
    2525autoconf 
     26autoheader 
    2627automake --foreign --add-missing 
  • ossiedev/branches/mcarrick/ossiedev-trunk/platform/AudioDevice/src/AudioDevice.cpp

    r9807 r10835  
    1 /**************************************************************************** 
     1/****************************************************************************  
    22 
    33Copyright 2009 Virginia Polytechnic Institute and State University 
     
    3333 
    3434// 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) 
     35AudioDevice_i::AudioDevice_i(char *uuid, char *label, char *profile, omni_condition *condition)  
     36  : Device_impl(uuid, label, profile), 
     37    component_running(condition) 
    3838{ 
    3939    DEBUG(3, AudioDevice, "constructor invoked") 
    4040 
    41 // 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 
     41    // 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 
    4444    configured = false; 
    4545    configured_prop_samplerate_record   = false; 
     
    4848    configured_prop_buffersize_playback = false; 
    4949 
    50 // Create Port for output sound 
     50    // Create Port for output sound 
    5151    portAudioRecord   = new standardInterfaces_i::complexShort_u("audioRecord"); 
    5252    portAudioPlayback = new standardInterfaces_i::complexShort_p("audioPlayback"); 
    53 // TODO: create port for input sound 
    54  
    55 // initialize portaudio stream 
     53    // TODO: create port for input sound 
     54 
     55    // initialize portaudio stream 
    5656    PaError err = Pa_Initialize(); 
    5757    if (err != paNoError) { 
     
    7474} 
    7575 
    76 void AudioDevice_i::start() 
     76void AudioDevice_i::start()  
    7777throw (CF::Resource::StartError, CORBA::SystemException) 
    7878{ 
    7979    DEBUG(3, AudioDevice, "start() invoked") 
    8080 
    81 // start the streams 
     81    // start the streams 
    8282    StartStreams(); 
    8383} 
     
    8989    DEBUG(3, AudioDevice, "stop() invoked") 
    9090 
    91 // stop the streams 
     91    // stop the streams 
    9292    StopStreams(); 
    9393} 
    9494 
    95 CORBA::Object_ptr AudioDevice_i::getPort(const char* portName) 
     95CORBA::Object_ptr AudioDevice_i::getPort(const char* portName)  
    9696throw(CF::PortSupplier::UnknownPort, CORBA::SystemException) 
    9797 
     
    106106        return u._retn(); 
    107107 
    108 // Port name not found; throw exception 
     108    // Port name not found; throw exception 
    109109    throw CF::PortSupplier::UnknownPort(); 
    110110} 
    111111 
    112 void AudioDevice_i::initialize() 
     112void AudioDevice_i::initialize()  
    113113throw (CF::LifeCycle::InitializeError, CORBA::SystemException) 
    114114{ 
     
    116116} 
    117117 
    118 void AudioDevice_i::configure(const CF::Properties &props) 
    119 throw (CORBA::SystemException, 
    120        CF::PropertySet::InvalidConfiguration, 
     118void AudioDevice_i::configure(const CF::Properties &props)  
     119throw (CORBA::SystemException,  
     120       CF::PropertySet::InvalidConfiguration,  
    121121       CF::PropertySet::PartialConfiguration) 
    122122{ 
    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             ) 
    126126 
    127127    if (configured) { 
     
    132132    } 
    133133 
    134 // read properties from .prf 
    135  
     134    // read properties from .prf 
     135     
    136136    CORBA::Short n; 
    137     for (unsigned int i=0; i<props.length(); i++) { 
     137    for (unsigned int i=0; i<props.length(); i++) 
     138    { 
    138139        DEBUG(3, AudioDevice, "configure property id : " << props[i].id) 
    139140 
     
    176177                configured_prop_samplerate_playback && 
    177178                configured_prop_buffersize_record   && 
    178                 configured_prop_buffersize_playback) { 
     179                configured_prop_buffersize_playback) 
     180        { 
    179181            configured = true; 
    180182            DEBUG(3, AudioDevice, "configured") 
     
    182184    } 
    183185 
    184 // TODO: reconfigure streams 
     186    // TODO: reconfigure streams 
    185187    if (!configured) 
    186188        return; 
    187189 
    188 // configure streams 
     190    // configure streams 
    189191    ConfigureStreams(); 
    190192} 
     
    199201 
    200202void AudioDevice_i::OpenStreams() 
    201 throw (CF::Resource::StartError) 
    202 { 
    203 // ensure properties have been configured 
     203    throw (CF::Resource::StartError) 
     204{ 
     205    // ensure properties have been configured 
    204206    if (!configured) { 
    205207        std::cerr << "ERROR: AudioDevice_i::OpenStreams(), device not configured" << std::endl; 
     
    209211    PaError err; 
    210212 
    211 // open record stream 
     213    // open record stream 
    212214    err = Pa_OpenStream( 
    213               &pa_stream_record, 
    214               NULL,               // no input 
    215               &pa_params_record, 
    216               samplerate_record, 
    217               buffersize_record, 
    218               paClipOff,          // disable clipping 
    219               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); 
    221223 
    222224    if (err != paNoError) { 
     
    225227    } 
    226228 
    227 // open playback stream 
     229    // open playback stream 
    228230    err = Pa_OpenStream( 
    229               &pa_stream_playback, 
    230               &pa_params_playback, 
    231               NULL,               // no output 
    232               samplerate_playback, 
    233               buffersize_playback, 
    234               paClipOff,          // disable clipping 
    235               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); 
    237239 
    238240    if (err != paNoError) { 
     
    243245 
    244246void AudioDevice_i::StartStreams() 
    245 throw (CF::Resource::StartError) 
     247    throw (CF::Resource::StartError) 
    246248{ 
    247249    if (!configured) { 
     
    250252    } 
    251253 
    252 // start record, playback threads 
     254    // start record, playback threads 
    253255    PaError err; 
    254256 
     
    268270 
    269271void AudioDevice_i::StopStreams() 
    270 throw (CF::Resource::StopError) 
     272    throw (CF::Resource::StopError) 
    271273{ 
    272274    PaError err; 
     
    287289 
    288290void AudioDevice_i::CloseStreams() 
    289 throw (CF::Resource::StopError) 
     291    throw (CF::Resource::StopError) 
    290292{ 
    291293    PaError err; 
    292  
     294     
    293295    err = Pa_CloseStream(pa_stream_record); 
    294296    if (err != paNoError) { 
     
    296298        throw CF::Resource::StopError(); 
    297299    } 
    298  
     300     
    299301    err = Pa_CloseStream(pa_stream_playback); 
    300302    if (err != paNoError) { 
     
    306308void AudioDevice_i::ConfigureStreams() 
    307309{ 
    308 // configure parameters: record 
     310    // configure parameters: record 
    309311    pa_params_record.device = Pa_GetDefaultOutputDevice(); 
    310312    pa_params_record.channelCount = AUDIODEVICE_NUMCHANNELS; 
    311313    pa_params_record.sampleFormat = AUDIODEVICE_SAMPLEFORMAT; 
    312     pa_params_record.suggestedLatency = 
     314    pa_params_record.suggestedLatency =  
    313315        Pa_GetDeviceInfo( pa_params_record.device )->defaultLowOutputLatency; 
    314316    pa_params_record.hostApiSpecificStreamInfo = NULL; 
    315317 
    316 // configure parameters: playback 
     318    // configure parameters: playback 
    317319    pa_params_playback.device = Pa_GetDefaultOutputDevice(); 
    318320    pa_params_playback.channelCount = AUDIODEVICE_NUMCHANNELS; 
    319321    pa_params_playback.sampleFormat = AUDIODEVICE_SAMPLEFORMAT; 
    320     pa_params_playback.suggestedLatency = 
     322    pa_params_playback.suggestedLatency =  
    321323        Pa_GetDeviceInfo( pa_params_playback.device )->defaultLowOutputLatency; 
    322324    pa_params_playback.hostApiSpecificStreamInfo = NULL; 
     
    325327void AudioDevice_i::SetRecordData(short int * _data) 
    326328{ 
    327 // copy data to buffer 
     329    // copy data to buffer 
    328330    for (unsigned int i=0; i<buffersize_record; i++) { 
    329331        record_data_L[i] = _data[2*i+0]; 
     
    331333    } 
    332334 
    333 // push data 
     335    // push data 
    334336    portAudioRecord->pushPacket(record_data_L, record_data_R); 
    335337} 
     
    337339void AudioDevice_i::GetPlaybackData(short int * _data) 
    338340{ 
    339 // wait for data 
     341    // wait for data 
    340342    portAudioPlayback->getData(playback_data_L, playback_data_R); 
    341343 
    342 // copy to buffer 
     344    // copy to buffer 
    343345    for (unsigned int i=0; i<buffersize_playback; i++) { 
    344346        _data[2*i+0] = (*playback_data_L)[i]; 
     
    346348    } 
    347349 
    348 // release input buffer 
     350    // release input buffer 
    349351    portAudioPlayback->bufferEmptied(); 
    350352} 
     
    360362    AudioDevice_i * device = (AudioDevice_i*)userData; 
    361363 
    362 // copy data from portaudio playback buffer 
     364    // copy data from portaudio playback buffer 
    363365    device->SetRecordData((short int*)inputBuffer); 
    364366 
     
    377379    short int * data = (short int*)outputBuffer; 
    378380 
    379 // copy data to portaudio playback buffer 
     381    // copy data to portaudio playback buffer 
    380382    device->GetPlaybackData(data); 
    381383 
  • ossiedev/branches/mcarrick/ossiedev-trunk/platform/AudioDevice/src/AudioDevice.h

    r9807 r10835  
    5656 
    5757/// Main sound card device (capture) definition 
    58 class AudioDevice_i : public virtual Device_impl 
     58class AudioDevice_i : public virtual Device_impl  
    5959{ 
    6060public: 
    61 /// Initializing constructor 
     61    /// Initializing constructor 
    6262    AudioDevice_i(char *uuid, char* label, char* profile, omni_condition *condition); 
    6363 
    64 /// Default destructor 
     64    /// Default destructor 
    6565    ~AudioDevice_i(); 
    6666 
    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); 
    7070 
    71 /// Send data recorded from device to port 
     71    /// Send data recorded from device to port 
    7272    void SetRecordData(short int * _data); 
    7373 
    74 /// Receive data from port and send to device 
     74    /// Receive data from port and send to device 
    7575    void GetPlaybackData(short int * _data); 
     76     
     77    void stop()  
     78        throw (CF::Resource::StopError, CORBA::SystemException); 
    7679 
    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); 
    7983 
    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); 
    8387 
    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); 
    87100 
    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); 
    104104 
    105105private: 
    106 /// Disallow default constructor 
     106    /// Disallow default constructor 
    107107    AudioDevice_i(); 
    108108 
    109 /// Disallow copy constructor 
     109    /// Disallow copy constructor 
    110110    AudioDevice_i(AudioDevice_i&); 
    111111 
     
    118118    unsigned int simplesequencelength; 
    119119    CORBA::ShortSeq *simplesequence_ptr; 
    120 //simplesequence_ptr = new short[simplesequencelength]; 
     120    //simplesequence_ptr = new short[simplesequencelength]; 
    121121 
    122 /// Port: output sound samples 
     122    /// Port: output sound samples 
    123123    standardInterfaces_i::complexShort_u *portAudioRecord; 
    124124    standardInterfaces_i::complexShort_p *portAudioPlayback; 
    125125 
    126 // properties configured flags 
     126    // properties configured flags 
    127127    bool configured; 
    128128    bool configured_prop_samplerate_record; 
     
    137137    void CloseStreams() throw (CF::Resource::StopError); 
    138138 
    139 // portaudio: specific properties 
     139    // portaudio: specific properties 
    140140    PaStreamParameters pa_params_record; 
    141141    PaStreamParameters pa_params_playback; 
     
    143143    PaStream *pa_stream_playback; 
    144144 
    145 // 
     145    //  
    146146    unsigned int samplerate_record; 
    147147    unsigned int samplerate_playback; 
  • ossiedev/branches/mcarrick/ossiedev-trunk/platform/AudioDevice/src/main.cpp

    r9807 r10835  
    2626 
    2727#include "AudioDevice.h" 
     28#include "config.h" 
    2829 
    2930using namespace std; 
     
    4647    char *uuid = argv[1]; 
    4748    char *label = argv[2]; 
    48     char *profile = argv[3]; 
     49    char *profile = argv[3];  
    4950 
    50     cout << "Identifier - " << uuid 
    51          << "  Label - " << label 
    52          << "  Profile - " << profile 
     51    cout << "Identifier - " << uuid  
     52         << "  Label - " << label  
     53         << "  Profile - " << profile  
    5354         << endl; 
    5455 
     
    5657    CF::Device_var AudioDevice_var; 
    5758 
    58 // Create the audio device servant and object reference 
     59    // Create the audio device servant and object reference 
    5960 
    6061    AudioDevice_servant = new AudioDevice_i(uuid, label, profile, component_running); 
     
    6667    orb->bind_object_to_name((CORBA::Object_ptr) AudioDevice_var, objName.c_str()); 
    6768 
    68 // This bit is ORB specific 
    69 // omniorb is threaded and the servants are running at this point 
    70 // so we block on the condition 
    71 // The releaseObject method clear the condition and the component exits 
     69    // 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 
    7273 
    7374    component_running->wait();