Changeset 8803

Show
Ignore:
Timestamp:
02/26/09 10:50:41 (4 years ago)
Author:
jgaeddert
Message:

fleshing out AudioDevice? functionality

Location:
ossiedev/branches/0.7.x/platform/AudioDevice/src
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • ossiedev/branches/0.7.x/platform/AudioDevice/src/AudioDevice.cpp

    r8800 r8803  
    11/****************************************************************************  
     2 
    23Copyright 2009 Virginia Polytechnic Institute and State University 
    34 
     
    2021****************************************************************************/ 
    2122 
    22 /** \file 
    23     The soundCardCapture.cpp file contains definitions for the AudioDevice_i 
    24     class implementation. 
    25 */ 
    26  
    2723#include <iostream> 
    2824#include "AudioDevice.h" 
    2925 
    30 #define AUDIODEVICE_PROPID_SAMPLERATECAPTURE    "DCE:xxx:0" 
     26#define AUDIODEVICE_PROPID_SAMPLERATERECORD     "DCE:xxx:0" 
    3127#define AUDIODEVICE_PROPID_SAMPLERATEPLAYBACK   "DCE:xxx:1" 
    32 #define AUDIODEVICE_PROPID_BUFFERSIZECAPTURE    "DCE:xxx:2" 
     28#define AUDIODEVICE_PROPID_BUFFERSIZERECORD     "DCE:xxx:2" 
    3329#define AUDIODEVICE_PROPID_BUFFERSIZEPLAYBACK   "DCE:xxx:3" 
    3430 
    3531// Initializing constructor 
    3632AudioDevice_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) 
    3836{ 
    3937    DEBUG(3, AudioDevice, "constructor invoked") 
     
    8987 
    9088    if (!CORBA::is_nil(u)) 
    91     return u._retn(); 
     89        return u._retn(); 
    9290 
    93     /// Port name not found; throw exception 
     91    // Port name not found; throw exception 
    9492    throw CF::PortSupplier::UnknownPort(); 
    95  
    9693} 
    9794 
    9895void AudioDevice_i::initialize()  
    9996throw (CF::LifeCycle::InitializeError, CORBA::SystemException) 
    100  
    10197{ 
    10298    DEBUG(3, AudioDevice, "initialize() invoked") 
    103  
    104  
    105     DEBUG(1, AudioDevice, "Initialize (capture) exit") 
    10699} 
    107100 
     
    116109 
    117110    // read properties from .prf 
    118     unsigned int rate(16000); // default sampling rate 
    119111     
     112    CORBA::Short n; 
    120113    for (unsigned int i=0; i<props.length(); i++) 
    121114    { 
    122115        DEBUG(3, AudioDevice, "configure property id : " << props[i].id) 
    123116 
    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 
    127119            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; 
    134140            throw(CF::PropertySet::InvalidConfiguration()); 
    135141        } 
     
    151157    PortTypes::ShortSequence L_out, R_out; 
    152158 
    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); 
    161161    
    162     int rc; 
    163  
    164162    while(1) 
    165163    { 
  • ossiedev/branches/0.7.x/platform/AudioDevice/src/AudioDevice.h

    r8799 r8803  
    2222****************************************************************************/ 
    2323 
    24 /** \file  
    25     The Sound_out.h file contains declarations for the SoundCardPlayback_i 
    26     class. 
    27 */ 
    28  
    29  
    30  
    3124#ifndef __OSSIE_AUDIO_DEVICE_H__ 
    3225#define __OSSIE_AUDIO_DEVICE_H__ 
     
    4134#include "standardinterfaces/complexShort.h" 
    4235#include "standardinterfaces/complexShort_u.h" 
     36 
     37#include "portaudio.h" 
     38 
     39static 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 
     47static 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 ); 
    4354 
    4455/// Main sound card device (capture) definition 
     
    110121    standardInterfaces_i::complexShort_u *dataOut; 
    111122 
    112     // --- Sound capture variables --- 
    113     unsigned int length;           ///<  
    114  
    115123    // Until I look at omni_condition... -TT 
    116124    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; 
    117131 
    118132};