Changeset 499

Show
Ignore:
Timestamp:
07/28/07 01:21:08 (16 years ago)
Author:
ppalmers
Message:

- implement AV/C descriptor and infoblock parsing
- implement AV/C music subunit status descriptor and related infoblocks

- small changes and generalizations

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/echoaudio/src/bebob/bebob_avdevice.cpp

    r472 r499  
    283283                                    *m_pConfigRom, 
    284284                                    *m_pPlugManager, 
    285                                     AVCCommand::eST_Unit, 
     285                                    eST_Unit, 
    286286                                    0xff, 
    287287                                    0xff, 
     
    316316                                    *m_pConfigRom, 
    317317                                    *m_pPlugManager, 
    318                                     AVCCommand::eST_Unit, 
     318                                    eST_Unit, 
    319319                                    0xff, 
    320320                                    0xff, 
     
    437437 
    438438    AvPlugVector syncMSUInputPlugs = m_pPlugManager->getPlugsByType( 
    439         AVCCommand::eST_Music, 
     439        eST_Music, 
    440440        0, 
    441441        0xff, 
     
    449449 
    450450    AvPlugVector syncMSUOutputPlugs = m_pPlugManager->getPlugsByType( 
    451         AVCCommand::eST_Music, 
     451        eST_Music, 
    452452        0, 
    453453        0xff, 
     
    579579        AvDeviceSubunit* subunit = 0; 
    580580        switch( subunit_type ) { 
    581         case AVCCommand::eST_Audio: 
     581        case eST_Audio: 
    582582            subunit = new AvDeviceSubunitAudio( *this, 
    583583                                                subunitId, 
     
    587587                return false; 
    588588            } 
    589  
    590             m_subunits.push_back( subunit ); 
    591             audioSubunitFound=true; 
    592  
     589            if ( !subunit ) { 
     590                debugFatal( "Could not allocate AvDeviceSubunitMusic\n" ); 
     591                return false; 
     592            } 
     593             
     594            if ( !subunit->discover() ) { 
     595                debugError( "enumerateSubUnits: Could not discover " 
     596                            "subunit_id = %2d, subunit_type = %2d (%s)\n", 
     597                            subunitId, 
     598                            subunit_type, 
     599                            subunitTypeToString( subunit_type ) ); 
     600                delete subunit; 
     601                return false; 
     602            } else { 
     603                m_subunits.push_back( subunit ); 
     604                audioSubunitFound=true; 
     605            } 
     606             
    593607            break; 
    594         case AVCCommand::eST_Music: 
     608        case eST_Music: 
    595609            subunit = new AvDeviceSubunitMusic( *this, 
    596610                                                subunitId, 
     
    600614                return false; 
    601615            } 
    602  
    603             m_subunits.push_back( subunit ); 
    604             musicSubunitFound=true; 
     616            if ( !subunit->discover() ) { 
     617                debugError( "enumerateSubUnits: Could not discover " 
     618                            "subunit_id = %2d, subunit_type = %2d (%s)\n", 
     619                            subunitId, 
     620                            subunit_type, 
     621                            subunitTypeToString( subunit_type ) ); 
     622                delete subunit; 
     623                return false; 
     624            } else { 
     625                m_subunits.push_back( subunit ); 
     626                musicSubunitFound=true; 
     627            } 
    605628 
    606629            break; 
     
    612635            continue; 
    613636 
    614         } 
    615  
    616         if ( !subunit->discover() ) { 
    617             debugError( "enumerateSubUnits: Could not discover " 
    618                         "subunit_id = %2d, subunit_type = %2d (%s)\n", 
    619                         subunitId, 
    620                         subunit_type, 
    621                         subunitTypeToString( subunit_type ) ); 
    622             delete subunit; 
    623             return false; 
    624637        } 
    625638 
  • branches/echoaudio/src/bebob/bebob_avdevice_subunit.cpp

    r451 r499  
    3939 
    4040BeBoB::AvDeviceSubunit::AvDeviceSubunit( AvDevice& avDevice, 
    41                                          AVCCommand::ESubunitType type, 
     41                                         ESubunitType type, 
    4242                                         subunit_t id, 
    4343                                         int verboseLevel ) 
     
    139139          ++plugIdx ) 
    140140    { 
    141         AVCCommand::ESubunitType subunitType = 
    142             static_cast<AVCCommand::ESubunitType>( getSubunitType() ); 
     141        ESubunitType subunitType = 
     142            static_cast<ESubunitType>( getSubunitType() ); 
    143143        AvPlug* plug = new AvPlug( m_avDevice->get1394Service(), 
    144144                                   m_avDevice->getConfigRom(), 
     
    210210{ 
    211211    bool result; 
    212     AVCCommand::ESubunitType sbType; 
     212    ESubunitType sbType; 
    213213    result  = deser.read( basePath + "m_sbType", sbType ); 
    214214 
    215215    AvDeviceSubunit* pSubunit = 0; 
    216216    switch( sbType ) { 
    217     case AVCCommand::eST_Audio: 
     217    case eST_Audio: 
    218218        pSubunit = new AvDeviceSubunitAudio; 
    219219        break; 
    220     case AVCCommand::eST_Music: 
     220    case eST_Music: 
    221221        pSubunit = new AvDeviceSubunitMusic; 
    222222        break; 
     
    248248                                                   subunit_t id, 
    249249                                                   int verboseLevel ) 
    250     : AvDeviceSubunit( avDevice, AVCCommand::eST_Audio, id, verboseLevel ) 
     250    : AvDeviceSubunit( avDevice, eST_Audio, id, verboseLevel ) 
    251251{ 
    252252} 
     
    578578                                                   subunit_t id, 
    579579                                                   int verboseLevel ) 
    580     : AvDeviceSubunit( avDevice, AVCCommand::eST_Music, id, verboseLevel ) 
     580    : AvDeviceSubunit( avDevice, eST_Music, id, verboseLevel ) 
    581581{ 
    582582} 
  • branches/echoaudio/src/bebob/bebob_avdevice_subunit.h

    r451 r499  
    4242 public: 
    4343    AvDeviceSubunit( AvDevice& avDevice, 
    44              AVCCommand::ESubunitType type, 
     44             ESubunitType type, 
    4545             subunit_t id, 
    4646             int verboseLevel ); 
     
    5555    subunit_t getSubunitId() 
    5656    { return m_sbId; } 
    57     AVCCommand::ESubunitType getSubunitType() 
     57    ESubunitType getSubunitType() 
    5858    { return m_sbType; } 
    5959 
     
    8686 protected: 
    8787    AvDevice*                m_avDevice; 
    88     AVCCommand::ESubunitType m_sbType; 
     88    ESubunitType m_sbType; 
    8989    subunit_t                m_sbId; 
    9090    int                      m_verboseLevel; 
  • branches/echoaudio/src/bebob/bebob_avplug.cpp

    r447 r499  
    4141                ConfigRom& configRom, 
    4242                AvPlugManager& plugManager, 
    43                 AVCCommand::ESubunitType subunitType, 
     43                ESubunitType subunitType, 
    4444                subunit_id_t subunitId, 
    4545                function_block_type_t functionBlockType, 
     
    106106    : m_p1394Service( 0 ) 
    107107    , m_pConfigRom( 0 ) 
    108     , m_subunitType( AVCCommand::eST_Reserved ) // a good value for unknown/undefined? 
     108    , m_subunitType( eST_Reserved ) // a good value for unknown/undefined? 
    109109    , m_subunitId( 0 ) 
    110110    , m_functionBlockType( 0 ) 
     
    953953 
    954954    switch( m_subunitType ) { 
    955     case AVCCommand::eST_Unit: 
     955    case eST_Unit: 
    956956        { 
    957957            UnitPlugAddress::EPlugType ePlugType = 
     
    978978        } 
    979979        break; 
    980     case AVCCommand::eST_Music: 
    981     case AVCCommand::eST_Audio: 
     980    case eST_Music: 
     981    case eST_Audio: 
    982982        { 
    983983            switch( m_addressType ) { 
     
    10301030        subFunction ); 
    10311031    switch( m_subunitType ) { 
    1032     case AVCCommand::eST_Unit: 
     1032    case eST_Unit: 
    10331033    { 
    10341034            UnitPlugAddress::EPlugType ePlugType = 
     
    10551055        } 
    10561056        break; 
    1057     case AVCCommand::eST_Music: 
    1058     case AVCCommand::eST_Audio: 
     1057    case eST_Music: 
     1058    case eST_Audio: 
    10591059    { 
    10601060        switch( m_addressType ) { 
     
    11031103 
    11041104    switch( m_subunitType ) { 
    1105     case AVCCommand::eST_Unit: 
     1105    case eST_Unit: 
    11061106    { 
    11071107        SignalUnitAddress signalUnitAddr; 
     
    11141114    } 
    11151115    break; 
    1116     case AVCCommand::eST_Music: 
    1117     case AVCCommand::eST_Audio: 
     1116    case eST_Music: 
     1117    case eST_Audio: 
    11181118    { 
    11191119        SignalSubunitAddress signalSubunitAddr; 
     
    11291129 
    11301130    signalSourceCmd.setNodeId( m_pConfigRom->getNodeId() ); 
    1131     signalSourceCmd.setSubunitType( AVCCommand::eST_Unit  ); 
     1131    signalSourceCmd.setSubunitType( eST_Unit  ); 
    11321132    signalSourceCmd.setSubunitId( 0xff ); 
    11331133 
     
    11401140{ 
    11411141    switch( plug.m_subunitType ) { 
    1142     case AVCCommand::eST_Unit: 
     1142    case eST_Unit: 
    11431143    { 
    11441144        SignalUnitAddress signalUnitAddr; 
     
    11511151    } 
    11521152    break; 
    1153     case AVCCommand::eST_Music: 
    1154     case AVCCommand::eST_Audio: 
     1153    case eST_Music: 
     1154    case eST_Audio: 
    11551155    { 
    11561156        SignalSubunitAddress signalSubunitAddr; 
     
    13181318 
    13191319    if ( pUnitPlugAddress ) { 
    1320         subunitType = AVCCommand::eST_Unit; 
     1320        subunitType = eST_Unit; 
    13211321        switch ( pUnitPlugAddress->m_plugType ) { 
    13221322        case UnitPlugSpecificDataPlugAddress::ePT_PCR: 
     
    14081408    } 
    14091409 
    1410     AVCCommand::ESubunitType enumSubunitType = 
    1411         static_cast<AVCCommand::ESubunitType>( subunitType ); 
     1410    ESubunitType enumSubunitType = 
     1411        static_cast<ESubunitType>( subunitType ); 
    14121412 
    14131413    return m_plugManager->getPlug( 
     
    20352035 
    20362036AvPlug* 
    2037 AvPlugManager::getPlug( AVCCommand::ESubunitType subunitType, 
     2037AvPlugManager::getPlug( ESubunitType subunitType, 
    20382038                        subunit_id_t subunitId, 
    20392039                        function_block_type_t functionBlockType, 
     
    20912091 
    20922092AvPlugVector 
    2093 AvPlugManager::getPlugsByType( AVCCommand::ESubunitType subunitType, 
     2093AvPlugManager::getPlugsByType( ESubunitType subunitType, 
    20942094                               subunit_id_t subunitId, 
    20952095                               function_block_type_t functionBlockType, 
  • branches/echoaudio/src/bebob/bebob_avplug.h

    r445 r499  
    8181        ConfigRom& configRom, 
    8282            AvPlugManager& plugManager, 
    83         AVCCommand::ESubunitType subunitType, 
     83        ESubunitType subunitType, 
    8484        subunit_id_t subunitId, 
    8585        function_block_type_t functionBlockType, 
     
    102102    plug_id_t getPlugId() const 
    103103        { return m_id; } 
    104     AVCCommand::ESubunitType getSubunitType() const 
     104    ESubunitType getSubunitType() const 
    105105        { return m_subunitType; } 
    106106    subunit_id_t getSubunitId() const 
     
    259259    Ieee1394Service*             m_p1394Service; 
    260260    ConfigRom*                   m_pConfigRom; 
    261     AVCCommand::ESubunitType     m_subunitType; 
     261    ESubunitType     m_subunitType; 
    262262    subunit_id_t                 m_subunitId; 
    263263    function_block_type_t        m_functionBlockType; 
     
    298298    void showPlugs() const; 
    299299 
    300     AvPlug* getPlug( AVCCommand::ESubunitType subunitType, 
     300    AvPlug* getPlug( ESubunitType subunitType, 
    301301                     subunit_id_t subunitId, 
    302302             function_block_type_t functionBlockType, 
     
    306306                     plug_id_t plugId ) const; 
    307307    AvPlug* getPlug( int iGlobalId ) const; 
    308     AvPlugVector getPlugsByType( AVCCommand::ESubunitType subunitType, 
     308    AvPlugVector getPlugsByType( ESubunitType subunitType, 
    309309                 subunit_id_t subunitId, 
    310310                 function_block_type_t functionBlockType, 
  • branches/echoaudio/src/debugmodule/debugmodule.cpp

    r474 r499  
    286286 
    287287void 
    288 DebugModuleManager::sync() 
     288DebugModuleManager::flush() 
    289289{ 
    290290    mb_flush(); 
  • branches/echoaudio/src/debugmodule/debugmodule.h

    r445 r499  
    3434typedef short debug_level_t; 
    3535 
     36#define DEBUG_MAX_MESSAGE_LENGTH 256 
     37 
    3638/* MB_NEXT() relies on the fact that MB_BUFFERS is a power of two */ 
    37 #define MB_BUFFERS    8192 
     39#define MB_BUFFERS    8192UL 
    3840#define MB_NEXT(index) ((index+1) & (MB_BUFFERS-1)) 
    39 #define MB_BUFFERSIZE    256        /* message length limit */ 
     41#define MB_BUFFERSIZE    DEBUG_MAX_MESSAGE_LENGTH        /* message length limit */ 
    4042 
    4143#define debugFatal( format, args... )                               \ 
     
    99101                m_debugModule.getLevel( ) 
    100102 
     103#define flushDebugOutput()      DebugModuleManager::instance()->flush() 
    101104 
    102105#ifdef DEBUG 
     
    203206    bool setMgrDebugLevel( std::string name, debug_level_t level ); 
    204207 
    205     void sync(); 
     208    void flush(); 
    206209 
    207210protected: 
  • branches/echoaudio/src/devicemanager.cpp

    r475 r499  
    134134    } 
    135135 
    136     m_oscServer = new OSC::OscServer("17820"); 
    137  
    138     if (!m_oscServer) { 
    139         debugFatal("failed to create osc server\n"); 
    140         delete m_1394Service; 
    141         m_1394Service = 0; 
    142         return false; 
    143     } 
    144  
    145     if (!m_oscServer->init()) { 
    146         debugFatal("failed to init osc server\n"); 
    147         delete m_oscServer; 
    148         m_oscServer = NULL; 
    149         delete m_1394Service; 
    150         m_1394Service = 0; 
    151         return false; 
    152     } 
    153  
    154     if (!m_oscServer->registerAtRootNode(this)) { 
    155         debugFatal("failed to register devicemanager at server\n"); 
    156         delete m_oscServer; 
    157         m_oscServer = NULL; 
    158         delete m_1394Service; 
    159         m_1394Service = 0; 
    160         return false; 
    161     } 
    162  
    163     if (!m_oscServer->start()) { 
    164         debugFatal("failed to start osc server\n"); 
    165         delete m_oscServer; 
    166         m_oscServer = NULL; 
    167         delete m_1394Service; 
    168         m_1394Service = 0; 
    169         return false; 
    170     } 
     136//     m_oscServer = new OSC::OscServer("17820"); 
     137//  
     138//     if (!m_oscServer) { 
     139//         debugFatal("failed to create osc server\n"); 
     140//         delete m_1394Service; 
     141//         m_1394Service = 0; 
     142//         return false; 
     143//     } 
     144//  
     145//     if (!m_oscServer->init()) { 
     146//         debugFatal("failed to init osc server\n"); 
     147//         delete m_oscServer; 
     148//         m_oscServer = NULL; 
     149//         delete m_1394Service; 
     150//         m_1394Service = 0; 
     151//         return false; 
     152//     } 
     153//  
     154//     if (!m_oscServer->registerAtRootNode(this)) { 
     155//         debugFatal("failed to register devicemanager at server\n"); 
     156//         delete m_oscServer; 
     157//         m_oscServer = NULL; 
     158//         delete m_1394Service; 
     159//         m_1394Service = 0; 
     160//         return false; 
     161//     } 
     162//  
     163//     if (!m_oscServer->start()) { 
     164//         debugFatal("failed to start osc server\n"); 
     165//         delete m_oscServer; 
     166//         m_oscServer = NULL; 
     167//         delete m_1394Service; 
     168//         m_1394Service = 0; 
     169//         return false; 
     170//     } 
    171171 
    172172    setVerboseLevel(getDebugLevel()); 
  • branches/echoaudio/src/iavdevice.h

    r450 r499  
    9898     *       these ID's are not fixed to a specific physical device. 
    9999     *       At some point, we will replaced this with a GUID based 
    100      *       approach, which is tied to a physiscal device and is 
     100     *       approach, which is tied to a physical device and is 
    101101     *       bus & time independant. 
    102102     * 
  • branches/echoaudio/src/libavc/avc_definitions.h

    r445 r499  
    129129#define AVC1394_SUBUNIT_ID_RESERVED 0x06 
    130130 
     131enum ESubunitType { 
     132    eST_Monitor       = AVC1394_SUBUNIT_VIDEO_MONITOR, 
     133    eST_Audio         = AVC1394_SUBUNIT_AUDIO, 
     134    eST_Printer       = AVC1394_SUBUNIT_PRINTER, 
     135    eST_Disc          = AVC1394_SUBUNIT_DISC_RECORDER, 
     136    eST_VCR           = AVC1394_SUBUNIT_VCR, 
     137    eST_Tuner         = AVC1394_SUBUNIT_TUNER, 
     138    eST_CA            = AVC1394_SUBUNIT_CA, 
     139    eST_Camera        = AVC1394_SUBUNIT_VIDEO_CAMERA, 
     140    eST_Panel         = AVC1394_SUBUNIT_PANEL, 
     141    eST_BulltinBoard  = AVC1394_SUBUNIT_BULLETIN_BOARD, 
     142    eST_CameraStorage = AVC1394_SUBUNIT_CAMERA_STORAGE, 
     143    eST_Music         = AVC1394_SUBUNIT_MUSIC, 
     144    eST_VendorUnique  = AVC1394_SUBUNIT_VENDOR_UNIQUE, 
     145    eST_Reserved      = AVC1394_SUBUNIT_RESERVED, 
     146    eST_Extended      = AVC1394_SUBUNIT_EXTENDED, 
     147    eST_Unit          = AVC1394_SUBUNIT_UNIT, 
     148}; 
     149 
     150 
    131151#endif // AVDDEFINITIONS_H 
  • branches/echoaudio/src/libavc/avc_extended_cmd_generic.cpp

    r445 r499  
    221221 
    222222SubunitPlugSpecificDataPlugAddress::SubunitPlugSpecificDataPlugAddress( 
    223     AVCCommand::ESubunitType subunitType, 
     223    ESubunitType subunitType, 
    224224    subunit_id_t subunitId, 
    225225    plug_id_t plugId ) 
     
    267267 
    268268FunctionBlockPlugSpecificDataPlugAddress::FunctionBlockPlugSpecificDataPlugAddress( 
    269     AVCCommand::ESubunitType subunitType, 
     269    ESubunitType subunitType, 
    270270    subunit_id_t subunitId, 
    271271    function_block_type_t functionBlockType, 
     
    530530        m_plugAddressData = 
    531531            new SubunitPlugSpecificDataPlugAddress( 
    532                 AVCCommand::eST_Reserved, 
     532                eST_Reserved, 
    533533                0xff, 
    534534                0xff ); 
     
    537537        m_plugAddressData = 
    538538            new FunctionBlockPlugSpecificDataPlugAddress( 
    539                 AVCCommand::eST_Reserved, 
     539                eST_Reserved, 
    540540                0xff, 
    541541                0xff, 
  • branches/echoaudio/src/libavc/avc_extended_cmd_generic.h

    r445 r499  
    142142{ 
    143143public: 
    144     SubunitPlugSpecificDataPlugAddress( AVCCommand::ESubunitType subunitType, 
     144    SubunitPlugSpecificDataPlugAddress( ESubunitType subunitType, 
    145145                                        subunit_id_t subunitId, 
    146146                                        plug_id_t plugId ); 
     
    163163{ 
    164164public: 
    165     FunctionBlockPlugSpecificDataPlugAddress( AVCCommand::ESubunitType subunitType, 
     165    FunctionBlockPlugSpecificDataPlugAddress( ESubunitType subunitType, 
    166166                                              subunit_id_t subunitId, 
    167167                                              function_block_type_t functionBlockType, 
  • branches/echoaudio/src/libavc/avc_extended_plug_info.h

    r445 r499  
    288288public: 
    289289    enum ESubFunction { 
    290     eSF_ExtendedPlugInfoCmd                  = AVC1394_PLUG_INFO_SUBFUNCTION_EXTENDED_PLUG_INFO_CMD, 
     290        eSF_ExtendedPlugInfoCmd                  = AVC1394_PLUG_INFO_SUBFUNCTION_EXTENDED_PLUG_INFO_CMD, 
    291291        eSF_NotUsed                              = AVC1394_PLUG_INFO_SUBFUNCTION_SERIAL_BUS_NOT_USED, 
    292292    }; 
     
    302302    bool setPlugAddress( const PlugAddress& plugAddress ); 
    303303    bool setSubFunction( ESubFunction subFunction ); 
     304    subfunction_t getSubFunction( ) {return m_subFunction;}; 
    304305    bool setInfoType( const ExtendedPlugInfoInfoType& infoType ); 
    305306    ExtendedPlugInfoInfoType* getInfoType() 
  • branches/echoaudio/src/libavc/avc_generic.cpp

    r445 r499  
    120120} 
    121121 
    122 AVCCommand::ESubunitType 
     122ESubunitType 
    123123AVCCommand::getSubunitType() 
    124124{ 
     
    150150                          unsigned short frameSize ) const 
    151151{ 
     152    // use an intermediate buffer to avoid a load of very small print's that cause the  
     153    // message ringbuffer to overflow 
     154    char msg[DEBUG_MAX_MESSAGE_LENGTH]; 
     155    int chars_written=0; 
    152156    for ( int i = 0; i < frameSize; ++i ) { 
    153157        if ( ( i % 16 ) == 0 ) { 
    154158            if ( i > 0 ) { 
    155                 debugOutputShort(DEBUG_LEVEL_VERY_VERBOSE, "\n" ); 
     159                debugOutputShort(DEBUG_LEVEL_VERY_VERBOSE, "%s\n", msg); 
     160                chars_written=0; 
    156161            } 
    157             debugOutputShort(DEBUG_LEVEL_VERY_VERBOSE, "  %3d:\t", i )
     162            chars_written+=snprintf(msg+chars_written,DEBUG_MAX_MESSAGE_LENGTH-chars_written,"  %3d:\t", i );
    158163        } else if ( ( i % 4 ) == 0 ) { 
    159             debugOutputShort(DEBUG_LEVEL_VERY_VERBOSE, " " ); 
     164            chars_written+=snprintf(msg+chars_written,DEBUG_MAX_MESSAGE_LENGTH-chars_written," "); 
    160165        } 
    161         debugOutputShort(DEBUG_LEVEL_VERY_VERBOSE, "%02x ", buf[i] ); 
    162     } 
    163     debugOutputShort(DEBUG_LEVEL_VERY_VERBOSE, "\n" ); 
     166        chars_written+=snprintf(msg+chars_written,DEBUG_MAX_MESSAGE_LENGTH-chars_written, "%02x ", buf[i] ); 
     167    } 
     168    if (chars_written != 0) { 
     169        debugOutputShort(DEBUG_LEVEL_VERY_VERBOSE, "%s\n", msg ); 
     170    } else { 
     171        debugOutputShort(DEBUG_LEVEL_VERY_VERBOSE, "\n" ); 
     172    } 
    164173} 
    165174 
     
    171180    BufferSerialize se( m_fcpFrame, sizeof( m_fcpFrame ) ); 
    172181    if ( !serialize( se ) ) { 
    173         debugFatal(  "ExtendedPlugInfoCmd::fire: Could not serialize\n" ); 
     182        debugFatal(  "fire: Could not serialize\n" ); 
    174183        return false; 
    175184    } 
     
    184193        StringSerializer se_dbg; 
    185194        serialize( se_dbg ); 
    186  
    187         debugOutputShort(DEBUG_LEVEL_VERY_VERBOSE, "%s\n", 
    188                          se_dbg.getString().c_str()); 
     195         
     196        // output the debug message in smaller chunks to avoid problems 
     197        // with a max message size 
     198        unsigned int chars_to_write=se_dbg.getString().size(); 
     199        unsigned int chars_written=0; 
     200        while (chars_written<chars_to_write) { 
     201            debugOutputShort(DEBUG_LEVEL_VERY_VERBOSE, "%s\n", 
     202                         se_dbg.getString().substr(chars_written, DEBUG_MAX_MESSAGE_LENGTH).c_str()); 
     203            chars_written += DEBUG_MAX_MESSAGE_LENGTH-1; 
     204        } 
    189205    } 
    190206 
     
    216232            serialize( se_dbg ); 
    217233 
    218             debugOutputShort(DEBUG_LEVEL_VERY_VERBOSE, "%s\n", 
    219                              se_dbg.getString().c_str()); 
     234            // output the debug message in smaller chunks to avoid problems 
     235            // with a max message size 
     236            unsigned int chars_to_write=se_dbg.getString().size(); 
     237            unsigned int chars_written=0; 
     238            while (chars_written<chars_to_write) { 
     239                debugOutputShort(DEBUG_LEVEL_VERY_VERBOSE, "%s\n", 
     240                            se_dbg.getString().substr(chars_written, DEBUG_MAX_MESSAGE_LENGTH).c_str()); 
     241                chars_written += DEBUG_MAX_MESSAGE_LENGTH-1; 
     242            } 
     243 
    220244        } 
    221245        break; 
     
    269293subunitTypeToString( subunit_type_t subunitType ) 
    270294{ 
    271     if ( subunitType == AVCCommand::eST_Unit ) { 
     295    if ( subunitType == eST_Unit ) { 
    272296        return "Unit"; 
    273297    } 
  • branches/echoaudio/src/libavc/avc_generic.h

    r445 r499  
    3939typedef unsigned char fcp_frame_t[fcpFrameMaxLength]; 
    4040 
     41enum EAVCDiscoveryMode { 
     42    eDM_BeBoB        = 0x00, 
     43    eDM_GenericAVC   = 0x01, 
     44    eDM_Invalid      = 0xFF, 
     45}; 
     46 
    4147class IBusData { 
    4248public: 
     
    4854 
    4955    virtual IBusData* clone() const = 0; 
    50      
     56 
    5157protected: 
    5258    DECLARE_DEBUG_MODULE; 
     
    7480        eCT_GeneralInquiry  = AVC1394_CTYP_GENERAL_INQUIRY, 
    7581        eCT_Unknown         = 0xff, 
    76     }; 
    77  
    78     enum ESubunitType { 
    79         eST_Monitor       = AVC1394_SUBUNIT_VIDEO_MONITOR, 
    80         eST_Audio         = AVC1394_SUBUNIT_AUDIO, 
    81         eST_Printer       = AVC1394_SUBUNIT_PRINTER, 
    82         eST_Disc          = AVC1394_SUBUNIT_DISC_RECORDER, 
    83         eST_VCR           = AVC1394_SUBUNIT_VCR, 
    84         eST_Tuner         = AVC1394_SUBUNIT_TUNER, 
    85         eST_CA            = AVC1394_SUBUNIT_CA, 
    86         eST_Camera        = AVC1394_SUBUNIT_VIDEO_CAMERA, 
    87         eST_Panel         = AVC1394_SUBUNIT_PANEL, 
    88         eST_BulltinBoard  = AVC1394_SUBUNIT_BULLETIN_BOARD, 
    89         eST_CameraStorage = AVC1394_SUBUNIT_CAMERA_STORAGE, 
    90         eST_Music         = AVC1394_SUBUNIT_MUSIC, 
    91         eST_VendorUnique  = AVC1394_SUBUNIT_VENDOR_UNIQUE, 
    92         eST_Reserved      = AVC1394_SUBUNIT_RESERVED, 
    93         eST_Extended      = AVC1394_SUBUNIT_EXTENDED, 
    94         eST_Unit          = AVC1394_SUBUNIT_UNIT, 
    9582    }; 
    9683 
     
    139126    ECommandType m_commandType; 
    140127    static int   m_time; 
    141  
     128     
     129protected: 
    142130    DECLARE_DEBUG_MODULE; 
    143131}; 
  • branches/echoaudio/src/libavc/avc_plug_info.cpp

    r445 r499  
    6262PlugInfoCmd::~PlugInfoCmd() 
    6363{ 
     64} 
     65 
     66void 
     67PlugInfoCmd::clear() 
     68{ 
     69    m_serialBusIsochronousInputPlugs=0xff; 
     70    m_serialBusIsochronousOutputPlugs=0xff; 
     71    m_externalInputPlugs=0xff; 
     72    m_externalOutputPlugs=0xff; 
     73    m_serialBusAsynchronousInputPlugs=0xff; 
     74    m_serialBusAsynchronousOuputPlugs=0xff; 
     75    m_destinationPlugs=0xff; 
     76    m_sourcePlugs=0xff; 
    6477} 
    6578 
  • branches/echoaudio/src/libavc/avc_plug_info.h

    r445 r499  
    5353    virtual bool deserialize( IISDeserialize& de ); 
    5454 
     55    virtual void clear(); 
     56 
    5557    virtual const char* getCmdName() const 
    5658    { return "PlugInfoCmd"; } 
  • branches/echoaudio/src/libavc/avc_serialize.cpp

    r445 r499  
    3030 
    3131IMPL_DEBUG_MODULE( CoutSerializer, CoutSerializer, DEBUG_LEVEL_NORMAL ); 
     32IMPL_DEBUG_MODULE( StringSerializer, StringSerializer, DEBUG_LEVEL_NORMAL ); 
     33IMPL_DEBUG_MODULE( BufferSerialize, BufferSerialize, DEBUG_LEVEL_NORMAL ); 
     34IMPL_DEBUG_MODULE( BufferDeserialize, BufferDeserialize, DEBUG_LEVEL_NORMAL ); 
    3235 
    3336bool 
    3437CoutSerializer::write( byte_t d, const char* name ) 
    3538{ 
    36     debugOutput( DEBUG_LEVEL_NORMAL, "  %3d:\t0x%02x\t%s\n", m_cnt, d, name ); 
     39    debugOutput( DEBUG_LEVEL_NORMAL, "  %3d:        0x%02x %40s\n", m_cnt, d, name ); 
    3740    m_cnt += sizeof( byte_t ); 
    3841 
     
    4144 
    4245bool 
     46CoutSerializer::write( uint16_t d, const char* name ) 
     47{ 
     48    debugOutput( DEBUG_LEVEL_NORMAL, "  %3d:    0x%04x %40s\n", m_cnt, d, name ); 
     49    m_cnt += sizeof( uint16_t ); 
     50 
     51    return true; 
     52} 
     53 
     54bool 
    4355CoutSerializer::write( quadlet_t d, const char* name ) 
    4456{ 
    45     debugOutput( DEBUG_LEVEL_NORMAL, "  %3d:\t0x%08x\t%s\n", m_cnt, d, name ); 
     57    debugOutput( DEBUG_LEVEL_NORMAL, "  %3d: 0x%08x %40s\n", m_cnt, d, name ); 
    4658    m_cnt += sizeof( quadlet_t ); 
    4759    return true; 
    4860} 
    4961 
     62bool 
     63CoutSerializer::write( const char * v, size_t len, const char* name ) 
     64{ 
     65    debugOutput( DEBUG_LEVEL_NORMAL, "  %3d: %s %40s\n", m_cnt, v, name ); 
     66    m_cnt += len; 
     67    return true; 
     68} 
    5069////////////////////////////////////////////////// 
    5170 
     
    6584 
    6685bool 
     86StringSerializer::write( uint16_t d, const char* name ) 
     87{ 
     88    char* result; 
     89    asprintf( &result, "  %3d:\t0x%04x\t%s\n", m_cnt, d, name ); 
     90 
     91    m_string += result; 
     92    free( result ); 
     93 
     94    m_cnt += sizeof( uint16_t ); 
     95 
     96    return true; 
     97} 
     98 
     99bool 
    67100StringSerializer::write( quadlet_t d, const char* name ) 
    68101{ 
     
    77110} 
    78111 
     112bool 
     113StringSerializer::write( const char * v, size_t len, const char* name ) 
     114{ 
     115    char* result; 
     116    asprintf( &result, "  %3d:\t%s\t%s\n", m_cnt, v, name ); 
     117 
     118    m_string += result; 
     119    free( result ); 
     120 
     121    m_cnt += len; 
     122    return true; 
     123} 
    79124////////////////////////////////////////////////// 
    80125 
     
    87132        m_curPos += sizeof( byte_t ); 
    88133        result = true; 
     134    } 
     135    return result; 
     136} 
     137 
     138bool 
     139BufferSerialize::write( uint16_t value, const char* name ) 
     140{ 
     141    byte_t hi = (value & 0xFF00) >> 8; 
     142    byte_t lo = value & 0xFF; 
     143     
     144    bool result = false; 
     145    if ( isCurPosValid() ) { 
     146        *m_curPos = hi; 
     147        m_curPos += sizeof( byte_t ); 
     148        if ( isCurPosValid() ) { 
     149            *m_curPos = lo; 
     150            m_curPos += sizeof( byte_t ); 
     151            result = true; 
     152        } 
    89153    } 
    90154    return result; 
     
    104168 
    105169bool 
     170BufferSerialize::write( const char * v, size_t len, const char* name ) 
     171{ 
     172    bool result = false; 
     173    if ( isCurPosValid() ) { 
     174        m_curPos += len; 
     175        // avoid write beyond buffer 
     176        if ( isCurPosValid() ) { 
     177            m_curPos -= len; 
     178            memcpy(m_curPos, v, len); 
     179            m_curPos += len; 
     180            result = true; 
     181        } 
     182    } 
     183    return result; 
     184} 
     185 
     186bool 
    106187BufferSerialize::isCurPosValid() const 
    107188{ 
     
    127208 
    128209bool 
     210BufferDeserialize::read( uint16_t* value ) 
     211{ 
     212    byte_t hi; 
     213    byte_t lo; 
     214    bool result = false; 
     215    if ( isCurPosValid() ) { 
     216        hi = *((byte_t *)m_curPos); 
     217        m_curPos += sizeof( byte_t ); 
     218        if ( isCurPosValid() ) { 
     219            lo = *((byte_t *)m_curPos); 
     220            m_curPos += sizeof( byte_t ); 
     221            *value=(hi << 8) | lo; 
     222            result = true; 
     223        } 
     224    } 
     225    return result; 
     226} 
     227 
     228bool 
    129229BufferDeserialize::read( quadlet_t* value ) 
    130230{ 
     
    144244    if ( isCurPosValid() ) { 
    145245        *value = ( char* )m_curPos; 
    146         m_curPos += length; 
    147         result = true; 
     246 
     247        m_curPos += length-1; 
     248        if ( !isCurPosValid() ) { 
     249            debugError("Read past end of response\n"); 
     250            result=false; 
     251        } else { 
     252            m_curPos++; 
     253            result = true; 
     254        } 
    148255    } 
    149256    return result; 
     
    159266    } 
    160267    return result; 
     268} 
     269 
     270bool 
     271BufferDeserialize::peek( uint16_t* value, size_t offset ) 
     272{ 
     273    byte_t hi; 
     274    byte_t lo; 
     275    bool result = false; 
     276    m_curPos+=offset; 
     277    if ( isCurPosValid() ) { 
     278        hi = *((byte_t *)m_curPos); 
     279        m_curPos += sizeof( byte_t ); 
     280        if ( isCurPosValid() ) { 
     281            lo = *((byte_t *)m_curPos); 
     282            *value=(hi << 8) | lo; 
     283            result = true; 
     284        } 
     285        m_curPos -= sizeof( byte_t ); 
     286    } 
     287    m_curPos-=offset; 
     288    return result; 
     289} 
     290 
     291bool 
     292BufferDeserialize::skip( size_t length ) { 
     293    m_curPos+=length; 
     294    return true; 
    161295} 
    162296 
  • branches/echoaudio/src/libavc/avc_serialize.h

    r445 r499  
    3838 
    3939    virtual bool write( byte_t value, const char* name = "" ) = 0; 
     40    virtual bool write( uint16_t value, const char* name = "" ) = 0; 
    4041    virtual bool write( quadlet_t value, const char* name = "" ) = 0; 
     42    virtual bool write( const char *values, size_t len, const char* name = "" ) = 0; 
    4143}; 
    4244 
     
    4749 
    4850    virtual bool read( byte_t* value ) = 0; 
     51    virtual bool read( uint16_t* value ) = 0; 
    4952    virtual bool read( quadlet_t* value ) = 0; 
    5053    virtual bool read( char** value, size_t length ) = 0; 
    5154    virtual bool peek( byte_t* value ) = 0; 
     55    virtual bool peek( uint16_t* value, size_t offset )=0; 
     56    virtual bool skip( size_t length ) = 0; 
     57    virtual int getNrOfConsumedBytes()  const = 0; 
    5258}; 
    5359 
     
    6369 
    6470    virtual bool write( byte_t value, const char* name = "" ); 
     71    virtual bool write( uint16_t value, const char* name = "" ); 
    6572    virtual bool write( quadlet_t value,  const char* name = "" ); 
     73    virtual bool write( const char *values, size_t len, const char* name = "" ); 
    6674 
    6775private: 
     
    8088 
    8189    virtual bool write( byte_t value, const char* name = "" ); 
     90    virtual bool write( uint16_t value, const char* name = "" ); 
    8291    virtual bool write( quadlet_t value,  const char* name = "" ); 
     92    virtual bool write( const char *values, size_t len, const char* name = "" ); 
    8393    virtual std::string getString( ) { return m_string;}; 
    8494 
     
    8696    unsigned int m_cnt; 
    8797    std::string m_string; 
    88  
     98    DECLARE_DEBUG_MODULE; 
    8999}; 
    90100 
     
    100110 
    101111    virtual bool write( byte_t value, const char* name = "" ); 
     112    virtual bool write( uint16_t value, const char* name = "" ); 
    102113    virtual bool write( quadlet_t value,  const char* name = "" ); 
     114    virtual bool write( const char *values, size_t len, const char* name = "" ); 
    103115 
    104116    int getNrOfProducesBytes() const 
     
    112124    unsigned char* m_curPos; 
    113125    size_t m_length; 
     126    DECLARE_DEBUG_MODULE; 
    114127}; 
    115128 
     
    125138 
    126139    virtual bool read( byte_t* value ); 
     140    virtual bool read( uint16_t* value ); 
    127141    virtual bool read( quadlet_t* value ); 
    128142    virtual bool read( char** value, size_t length ); 
    129143    virtual bool peek( byte_t* value ); 
     144    virtual bool peek( uint16_t* value, size_t offset ); 
     145    virtual bool skip( size_t length ); 
    130146 
    131147    int getNrOfConsumedBytes()  const 
     
    139155    unsigned char* m_curPos; // current read pos 
    140156    size_t m_length;         // size of buffer 
     157    DECLARE_DEBUG_MODULE; 
    141158}; 
    142159 
  • branches/echoaudio/src/Makefile.am

    r475 r499  
    5555        maudio/maudio_avdevice.h motu/motu_avdevice.h rme/rme_avdevice.h \ 
    5656        metrichalo/mh_avdevice.h dice/dice_avdevice.h \ 
     57        genericavc/avc_avdevice.h \ 
    5758        libavc/avc_connect.h \ 
    5859        libavc/avc_definitions.h libavc/avc_extended_cmd_generic.h \ 
     
    6162        libavc/avc_plug_info.h libavc/avc_serialize.h libavc/avc_signal_source.h \ 
    6263        libavc/avc_subunit_info.h libavc/avc_unit_info.h \ 
     64        libavc/avc_descriptor.h libavc/avc_descriptor_cmd.h libavc/avc_descriptor_music.h \ 
    6365        libosc/OscArgument.h libosc/OscNode.h libosc/OscResponse.h libosc/OscServer.h libosc/OscMessage.h \ 
    6466        libosc/OscClient.h \ 
     
    8587            libavc/avc_connect.cpp \ 
    8688            libavc/avc_definitions.cpp \ 
     89            libavc/avc_descriptor.cpp \ 
     90            libavc/avc_descriptor_cmd.cpp \ 
     91            libavc/avc_descriptor_music.cpp \ 
    8792            libavc/avc_extended_cmd_generic.cpp \ 
    8893            libavc/avc_extended_plug_info.cpp \ 
     
    140145 
    141146genericavc_src = \ 
    142             genericavc/avc_avdevice.cpp \ 
    143             genericavc/avc_avdevice.h 
     147            genericavc/avc_avdevice.cpp 
    144148 
    145149motu_src = \ 
  • branches/echoaudio/tests/Makefile.am

    r464 r499  
    3232 
    3333if BUILD_TESTS 
    34 noinst_PROGRAMS += test-ffado test-extplugcmd test-fw410 \ 
    35              test-volume test-mixer test-cycletimer test-sytmonitor \ 
    36              test-timestampedbuffer test-ieee1394service test-streamdump 
     34#noinst_PROGRAMS += test-ffado test-extplugcmd test-fw410 test-echo \ 
     35#            test-volume test-mixer test-cycletimer test-sytmonitor \ 
     36#            test-timestampedbuffer test-ieee1394service test-streamdump 
     37noinst_PROGRAMS += test-ffado test-echo 
    3738endif 
    3839 
     
    4344        $(LIBXML_LIBS) $(LIBAVC1394_LIBS) $(LIBIEC61883_LIBS) 
    4445 
    45 test_extplugcmd_SOURCES = test-extplugcmd.cpp 
    46 test_extplugcmd_LDADD = $(top_builddir)/src/libffado.la \ 
    47         $(LIBAVC1394_LIBS) 
    48  
    49 test_volume_SOURCES = test-volume.cpp 
    50 test_volume_LDADD = $(top_builddir)/src/libffado.la \ 
    51         $(LIBAVC1394_LIBS) 
    52  
    53 test_mixer_SOURCES = test-mixer.cpp 
    54 test_mixer_LDADD = $(top_builddir)/src/libffado.la \ 
    55         $(LIBAVC1394_LIBS) 
    56  
    57 test_fw410_SOURCES = test-fw410.cpp 
    58 test_fw410_LDADD   = $(LIBAVC1394_LIBS) $(LIBIEC61883_LIBS) -lrom1394 
    59  
    60 test_streamdump_SOURCES = test-streamdump.cpp 
    61 test_streamdump_LDADD   = $(LIBAVC1394_LIBS) $(LIBIEC61883_LIBS) -lrom1394 
    62  
    63 test_ieee1394service_SOURCES = test-ieee1394service.cpp 
    64 test_ieee1394service_LDADD   = $(top_builddir)/src/libffado.la \ 
    65                                    $(LIBAVC1394_LIBS) $(LIBIEC61883_LIBS) -lrom1394 
     46# test_extplugcmd_SOURCES = test-extplugcmd.cpp 
     47# test_extplugcmd_LDADD = $(top_builddir)/src/libffado.la \ 
     48#       $(LIBAVC1394_LIBS) 
     49#  
     50# test_volume_SOURCES = test-volume.cpp 
     51# test_volume_LDADD = $(top_builddir)/src/libffado.la \ 
     52#       $(LIBAVC1394_LIBS) 
     53#  
     54# test_mixer_SOURCES = test-mixer.cpp 
     55# test_mixer_LDADD = $(top_builddir)/src/libffado.la \ 
     56#       $(LIBAVC1394_LIBS) 
     57#  
     58# test_fw410_SOURCES = test-fw410.cpp 
     59# test_fw410_LDADD   = $(LIBAVC1394_LIBS) $(LIBIEC61883_LIBS) -lrom1394 
     60#  
     61test_echo_SOURCES = test-echo.cpp 
     62test_echo_LDADD   = $(LIBAVC1394_LIBS) $(LIBIEC61883_LIBS) $(LIBRAW1394_LIBS) -lrom1394 
     63#  
     64# test_streamdump_SOURCES = test-streamdump.cpp 
     65# test_streamdump_LDADD   = $(LIBAVC1394_LIBS) $(LIBIEC61883_LIBS) -lrom1394 
     66#  
     67# test_ieee1394service_SOURCES = test-ieee1394service.cpp 
     68# test_ieee1394service_LDADD   = $(top_builddir)/src/libffado.la \ 
     69#                                  $(LIBAVC1394_LIBS) $(LIBIEC61883_LIBS) -lrom1394 
    6670 
    6771#TESTS_ENVIRONMENT 
    68 TEST = test-ffado 
    69  
    70 test_cycletimer_LDADD = $(top_builddir)/src/libffado.la $(LIBIEC61883_LIBS) \ 
    71       $(LIBRAW1394_LIBS) $(LIBAVC1394_LIBS) 
    72 test_cycletimer_SOURCES = test-cycletimer.cpp 
    73  
    74 test_sytmonitor_LDADD = $(top_builddir)/src/libffado.la $(LIBIEC61883_LIBS) \ 
    75       $(LIBRAW1394_LIBS) $(LIBAVC1394_LIBS) 
    76 test_sytmonitor_SOURCES = test-sytmonitor.cpp SytMonitor.cpp \ 
    77                             SytMonitor.h 
    78  
    79 test_timestampedbuffer_LDADD = $(top_builddir)/src/libffado.la $(LIBIEC61883_LIBS) \ 
    80       $(LIBRAW1394_LIBS) $(LIBAVC1394_LIBS) 
    81 test_timestampedbuffer_SOURCES = test-timestampedbuffer.cpp 
     72TEST = test-ffado test-echo 
     73#  
     74# test_cycletimer_LDADD = $(top_builddir)/src/libffado.la $(LIBIEC61883_LIBS) \ 
     75#     $(LIBRAW1394_LIBS) $(LIBAVC1394_LIBS) 
     76# test_cycletimer_SOURCES = test-cycletimer.cpp 
     77#  
     78# test_sytmonitor_LDADD = $(top_builddir)/src/libffado.la $(LIBIEC61883_LIBS) \ 
     79#     $(LIBRAW1394_LIBS) $(LIBAVC1394_LIBS) 
     80# test_sytmonitor_SOURCES = test-sytmonitor.cpp SytMonitor.cpp \ 
     81#                           SytMonitor.h 
     82#  
     83# test_timestampedbuffer_LDADD = $(top_builddir)/src/libffado.la $(LIBIEC61883_LIBS) \ 
     84#     $(LIBRAW1394_LIBS) $(LIBAVC1394_LIBS) 
     85# test_timestampedbuffer_SOURCES = test-timestampedbuffer.cpp 
  • branches/echoaudio/tests/test-ffado.cpp

    r475 r499  
    193193static struct argp argp = { options, parse_opt, args_doc, doc }; 
    194194 
     195int exitfunction( int retval ) { 
     196    debugOutput( DEBUG_LEVEL_NORMAL, "Debug output flushed...\n" ); 
     197    flushDebugOutput(); 
     198     
     199    return retval; 
     200} 
     201 
    195202int 
    196203main( int argc, char **argv ) 
     
    207214    arguments.args[1]     = ""; 
    208215 
     216    setDebugLevel(arguments.verbose); 
     217 
    209218    // Parse our arguments; every option seen by `parse_opt' will 
    210219    // be reflected in `arguments'. 
    211220    if ( argp_parse ( &argp, argc, argv, 0, 0, &arguments ) ) { 
    212221        fprintf( stderr, "Could not parse command line\n" ); 
    213         return -1
     222        return exitfunction(-1)
    214223    } 
    215224 
     
    222231        if ( !m_deviceManager ) { 
    223232            fprintf( stderr, "Could not allocate device manager\n" ); 
    224             return -1
     233            return exitfunction(-1)
    225234        } 
    226235        if ( arguments.verbose ) { 
     
    230239            fprintf( stderr, "Could not initialize device manager\n" ); 
    231240            delete m_deviceManager; 
    232             return -1
     241            return exitfunction(-1)
    233242        } 
    234243        if ( arguments.verbose ) { 
     
    238247            fprintf( stderr, "Could not discover devices\n" ); 
    239248            delete m_deviceManager; 
    240             return -1
     249            return exitfunction(-1)
    241250        } 
    242251        delete m_deviceManager; 
    243         return 0
     252        return exitfunction(0)
    244253    } else if ( strcmp( arguments.args[0], "SetSamplerate" ) == 0 ) { 
    245254        char* tail; 
     
    247256        if ( errno ) { 
    248257            fprintf( stderr,  "Could not parse samplerate argument\n" ); 
    249             return -1
     258            return exitfunction(-1)
    250259        } 
    251260 
     
    253262        if ( !m_deviceManager ) { 
    254263            fprintf( stderr, "Could not allocate device manager\n" ); 
    255             return -1
     264            return exitfunction(-1)
    256265        } 
    257266        if ( arguments.verbose ) { 
     
    261270            fprintf( stderr, "Could not initialize device manager\n" ); 
    262271            delete m_deviceManager; 
    263             return -1
     272            return exitfunction(-1)
    264273        } 
    265274        if ( arguments.verbose ) { 
     
    269278            fprintf( stderr, "Could not discover devices\n" ); 
    270279            delete m_deviceManager; 
    271             return -1
     280            return exitfunction(-1)
    272281        } 
    273282 
     
    299308        } 
    300309        delete m_deviceManager; 
    301         return 0
     310        return exitfunction(0)
    302311    } else if ( strcmp( arguments.args[0], "ListOscSpace" ) == 0 ) { 
    303312        // list osc space by using OSC messages 
     
    320329        if ( !m_deviceManager ) { 
    321330            fprintf( stderr, "Could not allocate device manager\n" ); 
    322             return -1
     331            return exitfunction(-1)
    323332        } 
    324333        if ( !m_deviceManager->initialize( arguments.port ) ) { 
    325334            fprintf( stderr, "Could not initialize device manager\n" ); 
    326335            delete m_deviceManager; 
    327             return -1
     336            return exitfunction(-1)
    328337        } 
    329338        if ( arguments.verbose ) { 
     
    333342            fprintf( stderr, "Could not discover devices\n" ); 
    334343            delete m_deviceManager; 
    335             return -1
     344            return exitfunction(-1)
    336345        } 
    337346 
     
    351360        printf("server stopped\n"); 
    352361        delete m_deviceManager; 
    353         return 0
     362        return exitfunction(0)
    354363 
    355364    } else {