Changeset 554

Show
Ignore:
Timestamp:
08/22/07 10:15:34 (16 years ago)
Author:
ppalmers
Message:

Merge echoaudio branch into trunk.

This adds support for the Echo Audiofire devices to FFADO. Possibly also other devices working with the Apple Class Driver will work with this code. It is not fully complete yet, but the main rework is
done.

First of all the IAvDevice class/interface is renamed to FFADODevice, in order to separate the AV/C code from the FFADO API code. A device supported by FFADO implements a FFADODevice.

The BeBoB device has been split up into three groups:
- libavc/* : all code and commands that are specified by AV/C specs. Note that a lot of the code that used to be in BeBoB::AvDevice? now resides in AVC::Unit
- genericavc/* : a FFADODevice that uses AV/C descriptors & commands for discovery and config
- bebob/* : the bebob FFADODevice that inherits from GenericAVC::AvDevice? but that uses BridgeCo? commands for discovery

Everything has been moved as high as possible in the class hierarchy. If necessary, a subclass that uses device specific commands is introduced (e.g. BeBoB::Plug inherits from AVC::Plug and uses the
BridgeCo? extended plug info command to discover it's properties).

There are some other fixes along the way that have been done too.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/configure.ac

    r511 r554  
    2626m4_define(ffado_major_version, 1) 
    2727m4_define(ffado_minor_version, 999) 
    28 m4_define(ffado_micro_version, 5
     28m4_define(ffado_micro_version, 6
    2929 
    3030m4_define(ffado_version, ffado_major_version.ffado_minor_version.ffado_micro_version) 
     
    217217[build_bebob=true]) 
    218218 
     219dnl --- Build Generic AV/C code (Apple class driver compatible)? 
     220 
     221AC_ARG_ENABLE(generic-avc, 
     222    AC_HELP_STRING([--enable-generic-avc], 
     223                   [build Generic AV/C support (default=yes)]), 
     224[case "${enableval}" in 
     225  yes) build_genericavc=true;; 
     226  no)  build_genericavc=false;; 
     227  *) AC_MSG_ERROR(bad value ${enableval} for --enable-generic-avc) ;; 
     228esac], 
     229[build_genericavc=true]) 
     230 
    219231dnl --- Build Motu code? 
    220232 
     
    312324if test "${build_all}" = true; then 
    313325    build_bebob=true 
     326    build_genericavc=true 
    314327    build_motu=true 
    315328    build_dice=true 
     
    328341fi; 
    329342 
     343if test "${build_genericavc}" = true; then 
     344   CFLAGS="$CFLAGS -DENABLE_GENERICAVC" 
     345   CXXFLAGS="$CXXFLAGS -DENABLE_GENERICAVC"  
     346   supported_devices="${supported_devices}GenericAVC  " 
     347   build_amdtp=true 
     348fi; 
     349 
    330350if test "${build_motu}" = true; then 
    331351   CFLAGS="$CFLAGS -DENABLE_MOTU" 
     
    365385 
    366386AM_CONDITIONAL(BUILD_BEBOB,test "${build_bebob}" = true) 
     387AM_CONDITIONAL(BUILD_GENERICAVC,test "${build_genericavc}" = true) 
    367388AM_CONDITIONAL(BUILD_MOTU,test "${build_motu}" = true) 
    368389AM_CONDITIONAL(BUILD_DICE,test "${build_dice}" = true) 
  • trunk/libffado/src/bebob-sync.cpp

    r445 r554  
    2323 
    2424#include "devicemanager.h" 
    25 #include "iavdevice.h" 
     25#include "ffadodevice.h" 
    2626#include "bebob/bebob_avdevice.h" 
    2727 
     
    144144    } 
    145145 
    146     IAvDevice* pAvDevice = pDeviceManager->getAvDevice( node_id ); 
     146    FFADODevice* pAvDevice = pDeviceManager->getAvDevice( node_id ); 
    147147    if ( !pAvDevice ) { 
    148148        printf( "No recognized device found with id %d\n", node_id ); 
  • trunk/libffado/src/bebob/bebob_avdevice.cpp

    r537 r554  
    2929#include "libieee1394/ieee1394service.h" 
    3030 
    31 #include "libavc/avc_plug_info.h" 
    32 #include "libavc/avc_extended_plug_info.h" 
    33 #include "libavc/avc_subunit_info.h" 
    34 #include "libavc/avc_extended_stream_format.h" 
    35 #include "libavc/avc_serialize.h" 
     31#include "libavc/general/avc_plug_info.h" 
     32#include "libavc/general/avc_extended_plug_info.h" 
     33#include "libavc/general/avc_subunit_info.h" 
     34#include "libavc/streamformat/avc_extended_stream_format.h" 
     35#include "libavc/util/avc_serialize.h" 
    3636#include "libavc/avc_definitions.h" 
    3737 
     
    4343#include <sys/stat.h> 
    4444 
     45using namespace AVC; 
     46 
    4547namespace BeBoB { 
    4648 
    47 static VendorModelEntry supportedDeviceList[] = 
     49static GenericAVC::VendorModelEntry supportedDeviceList[] = 
    4850{ 
    4951    {0x00000f, 0x00010065, "Mackie", "Onyx Firewire"}, 
     
    7173    {0x000d6c, 0x00010062, "M-Audio", "FW Solo"}, 
    7274    {0x000d6c, 0x00010081, "M-Audio", "NRV10"}, 
    73  
    7475}; 
    7576 
     
    7778                    Ieee1394Service& ieee1394service, 
    7879                    int nodeId ) 
    79     : IAvDevice( configRom, ieee1394service, nodeId ) 
    80     , m_pPlugManager( new AvPlugManager( DEBUG_LEVEL_NORMAL ) ) 
    81     , m_activeSyncInfo( 0 ) 
    82     , m_model ( NULL ) 
     80    : GenericAVC::AvDevice( configRom, ieee1394service, nodeId ) 
    8381    , m_Mixer ( NULL ) 
    8482{ 
    8583    debugOutput( DEBUG_LEVEL_VERBOSE, "Created BeBoB::AvDevice (NodeID %d)\n", 
    8684                 nodeId ); 
    87     addOption(Util::OptionContainer::Option("snoopMode",false)); 
    8885} 
    8986 
     
    9693        delete m_Mixer; 
    9794    } 
    98  
    99     for ( AvDeviceSubunitVector::iterator it = m_subunits.begin(); 
    100           it != m_subunits.end(); 
    101           ++it ) 
    102     { 
    103         delete *it; 
    104     } 
    105     for ( AvPlugConnectionVector::iterator it = m_plugConnections.begin(); 
    106           it != m_plugConnections.end(); 
    107           ++it ) 
    108     { 
    109         delete *it; 
    110     } 
    111     for ( AvPlugVector::iterator it = m_pcrPlugs.begin(); 
    112           it != m_pcrPlugs.end(); 
    113           ++it ) 
    114     { 
    115         delete *it; 
    116     } 
    117     for ( AvPlugVector::iterator it = m_externalPlugs.begin(); 
    118           it != m_externalPlugs.end(); 
    119           ++it ) 
    120     { 
    121         delete *it; 
    122     } 
    123 
    124  
    125 void 
    126 AvDevice::setVerboseLevel(int l) 
    127 
    128 //     m_pPlugManager->setVerboseLevel(l); 
    129  
    130     IAvDevice::setVerboseLevel(l); 
     95
     96 
     97AVC::Subunit*  
     98AvDevice::createSubunit(AVC::Unit& unit, 
     99                               AVC::ESubunitType type, 
     100                               AVC::subunit_t id )  
     101
     102    switch (type) { 
     103        case AVC::eST_Audio: 
     104            return new BeBoB::SubunitAudio(unit, id ); 
     105        case AVC::eST_Music: 
     106            return new BeBoB::SubunitMusic(unit, id ); 
     107        default: 
     108            return NULL; 
     109    } 
     110
     111 
     112AVC::Plug * 
     113AvDevice::createPlug( AVC::Unit* unit, 
     114                     AVC::Subunit* subunit, 
     115                     AVC::function_block_type_t functionBlockType, 
     116                     AVC::function_block_type_t functionBlockId, 
     117                     AVC::Plug::EPlugAddressType plugAddressType, 
     118                     AVC::Plug::EPlugDirection plugDirection, 
     119                     AVC::plug_id_t plugId ) 
     120
     121 
     122    return new BeBoB::Plug( unit, 
     123                     subunit, 
     124                     functionBlockType, 
     125                     functionBlockId, 
     126                     plugAddressType, 
     127                     plugDirection, 
     128                     plugId ); 
    131129} 
    132130 
     
    140138 
    141139    for ( unsigned int i = 0; 
    142           i < ( sizeof( supportedDeviceList )/sizeof( VendorModelEntry ) ); 
     140          i < ( sizeof( supportedDeviceList )/sizeof( GenericAVC::VendorModelEntry ) ); 
    143141          ++i ) 
    144142    { 
     
    149147        } 
    150148    } 
    151  
    152149    return false; 
    153150} 
     
    160157 
    161158    for ( unsigned int i = 0; 
    162           i < ( sizeof( supportedDeviceList )/sizeof( VendorModelEntry ) ); 
     159          i < ( sizeof( supportedDeviceList )/sizeof( GenericAVC::VendorModelEntry ) ); 
    163160          ++i ) 
    164161    { 
     
    177174    } else return false; 
    178175 
    179     if ( !enumerateSubUnits() ) { 
    180         debugError( "Could not enumarate sub units\n" ); 
    181         return false; 
    182     } 
    183  
    184     if ( !discoverPlugs() ) { 
    185         debugError( "Detecting plugs failed\n" ); 
    186         return false; 
    187     } 
    188  
    189     if ( !discoverPlugConnections() ) { 
    190         debugError( "Detecting plug connections failed\n" ); 
    191         return false; 
    192     } 
    193  
    194     if ( !discoverSubUnitsPlugConnections() ) { 
    195         debugError( "Detecting plug connnection failed\n" ); 
    196         return false; 
    197     } 
    198  
    199     if ( !discoverSyncModes() ) { 
    200         debugError( "Detecting sync modes failed\n" ); 
    201         return false; 
    202     } 
     176    if ( !Unit::discover() ) { 
     177        debugError( "Could not discover unit\n" ); 
     178        return false; 
     179    } 
     180 
     181    if((getAudioSubunit( 0 ) == NULL)) { 
     182        debugError( "Unit doesn't have an Audio subunit.\n"); 
     183        return false; 
     184    } 
     185    if((getMusicSubunit( 0 ) == NULL)) { 
     186        debugError( "Unit doesn't have a Music subunit.\n"); 
     187        return false; 
     188    } 
     189 
     190// replaced by the previous Unit discovery 
     191//     if ( !enumerateSubUnits() ) { 
     192//         debugError( "Could not enumarate sub units\n" ); 
     193//         return false; 
     194//     } 
    203195 
    204196    // create a GenericMixer and add it as an OSC child node 
     
    210202        delete m_Mixer; 
    211203    } 
    212  
     204     
    213205    //  create the mixer & register it 
    214206    if(getAudioSubunit(0) == NULL) { 
     
    225217 
    226218bool 
    227 AvDevice::discoverPlugs() 
    228 
    229     ////////////////////////////////////////////// 
    230     // Get number of available isochronous input 
    231     // and output plugs of unit 
    232  
    233     PlugInfoCmd plugInfoCmd( *m_p1394Service ); 
    234     plugInfoCmd.setNodeId( m_pConfigRom->getNodeId() ); 
    235     plugInfoCmd.setCommandType( AVCCommand::eCT_Status ); 
    236     plugInfoCmd.setVerbose( m_verboseLevel ); 
    237  
    238     if ( !plugInfoCmd.fire() ) { 
    239         debugError( "plug info command failed\n" ); 
    240         return false; 
    241     } 
    242  
    243     debugOutput( DEBUG_LEVEL_NORMAL, "number of iso input plugs = %d\n", 
    244                  plugInfoCmd.m_serialBusIsochronousInputPlugs ); 
    245     debugOutput( DEBUG_LEVEL_NORMAL, "number of iso output plugs = %d\n", 
    246                  plugInfoCmd.m_serialBusIsochronousOutputPlugs ); 
    247     debugOutput( DEBUG_LEVEL_NORMAL, "number of external input plugs = %d\n", 
    248                  plugInfoCmd.m_externalInputPlugs ); 
    249     debugOutput( DEBUG_LEVEL_NORMAL, "number of external output plugs = %d\n", 
    250                  plugInfoCmd.m_externalOutputPlugs ); 
    251  
    252     if ( !discoverPlugsPCR( AvPlug::eAPD_Input, 
    253                             plugInfoCmd.m_serialBusIsochronousInputPlugs ) ) 
    254     { 
    255         debugError( "pcr input plug discovering failed\n" ); 
    256         return false; 
    257     } 
    258  
    259     if ( !discoverPlugsPCR( AvPlug::eAPD_Output, 
    260                             plugInfoCmd.m_serialBusIsochronousOutputPlugs ) ) 
    261     { 
    262         debugError( "pcr output plug discovering failed\n" ); 
    263         return false; 
    264     } 
    265  
    266     if ( !discoverPlugsExternal( AvPlug::eAPD_Input, 
    267                                  plugInfoCmd.m_externalInputPlugs ) ) 
    268     { 
    269         debugError( "external input plug discovering failed\n" ); 
    270         return false; 
    271     } 
    272  
    273     if ( !discoverPlugsExternal( AvPlug::eAPD_Output, 
    274                                  plugInfoCmd.m_externalOutputPlugs ) ) 
    275     { 
    276         debugError( "external output plug discovering failed\n" ); 
    277         return false; 
    278     } 
    279  
     219AvDevice::propagatePlugInfo() { 
     220    // we don't have to propagate since we discover things 
     221    // another way 
     222    debugOutput(DEBUG_LEVEL_VERBOSE, "Skip plug info propagation\n"); 
    280223    return true; 
    281224} 
    282225 
    283 bool 
    284 AvDevice::discoverPlugsPCR( AvPlug::EAvPlugDirection plugDirection, 
    285                             plug_id_t plugMaxId ) 
    286 { 
    287     for ( int plugId = 0; 
    288           plugId < plugMaxId; 
    289           ++plugId ) 
    290     { 
    291         AvPlug* plug  = new AvPlug( *m_p1394Service, 
    292                                     *m_pConfigRom, 
    293                                     *m_pPlugManager, 
    294                                     AVCCommand::eST_Unit, 
    295                                     0xff, 
    296                                     0xff, 
    297                                     0xff, 
    298                                     AvPlug::eAPA_PCR, 
    299                                     plugDirection, 
    300                                     plugId, 
    301                                     m_verboseLevel ); 
    302         if ( !plug || !plug->discover() ) { 
    303             debugError( "plug discovering failed\n" ); 
    304             delete plug; 
    305             return false; 
    306         } 
    307  
    308         debugOutput( DEBUG_LEVEL_NORMAL, "plug '%s' found\n", 
    309                      plug->getName() ); 
    310         m_pcrPlugs.push_back( plug ); 
    311     } 
    312  
    313     return true; 
    314 } 
    315  
    316 bool 
    317 AvDevice::discoverPlugsExternal( AvPlug::EAvPlugDirection plugDirection, 
    318                                  plug_id_t plugMaxId ) 
    319 { 
    320     for ( int plugId = 0; 
    321           plugId < plugMaxId; 
    322           ++plugId ) 
    323     { 
    324         AvPlug* plug  = new AvPlug( *m_p1394Service, 
    325                                     *m_pConfigRom, 
    326                                     *m_pPlugManager, 
    327                                     AVCCommand::eST_Unit, 
    328                                     0xff, 
    329                                     0xff, 
    330                                     0xff, 
    331                                     AvPlug::eAPA_ExternalPlug, 
    332                                     plugDirection, 
    333                                     plugId, 
    334                                     m_verboseLevel ); 
    335         if ( !plug || !plug->discover() ) { 
    336             debugError( "plug discovering failed\n" ); 
    337             return false; 
    338         } 
    339  
    340         debugOutput( DEBUG_LEVEL_NORMAL, "plug '%s' found\n", 
    341                      plug->getName() ); 
    342         m_externalPlugs.push_back( plug ); 
    343     } 
    344  
    345     return true; 
    346 } 
    347  
    348 bool 
    349 AvDevice::discoverPlugConnections() 
    350 { 
    351     for ( AvPlugVector::iterator it = m_pcrPlugs.begin(); 
    352           it != m_pcrPlugs.end(); 
    353           ++it ) 
    354     { 
    355         AvPlug* plug = *it; 
    356         if ( !plug->discoverConnections() ) { 
    357             debugError( "Could not discover plug connections\n" ); 
    358             return false; 
    359         } 
    360     } 
    361     for ( AvPlugVector::iterator it = m_externalPlugs.begin(); 
    362           it != m_externalPlugs.end(); 
    363           ++it ) 
    364     { 
    365         AvPlug* plug = *it; 
    366         if ( !plug->discoverConnections() ) { 
    367             debugError( "Could not discover plug connections\n" ); 
    368             return false; 
    369         } 
    370     } 
    371  
    372     return true; 
    373 } 
    374  
    375 bool 
    376 AvDevice::discoverSubUnitsPlugConnections() 
    377 { 
    378     for ( AvDeviceSubunitVector::iterator it = m_subunits.begin(); 
    379           it != m_subunits.end(); 
    380           ++it ) 
    381     { 
    382         AvDeviceSubunit* subunit = *it; 
    383         if ( !subunit->discoverConnections() ) { 
    384             debugError( "Subunit '%s'  plug connections failed\n", 
    385                         subunit->getName() ); 
    386             return false; 
    387         } 
    388     } 
    389     return true; 
    390 } 
    391  
    392 bool 
    393 AvDevice::discoverSyncModes() 
    394 { 
    395     // Following possible sync plugs exists: 
    396     // - Music subunit sync output plug = internal sync (CSP) 
    397     // - Unit input plug 0 = SYT match 
    398     // - Unit input plut 1 = Sync stream 
    399     // 
    400     // If last sync mode is reported it is mostelikely not 
    401     // implemented *sic* 
    402     // 
    403     // Following sync sources are device specific: 
    404     // - All unit external input plugs which have a 
    405     //   sync information (WS, SPDIF, ...) 
    406  
    407     // First we have to find the sync input and output plug 
    408     // in the music subunit. 
    409  
    410     // Note PCR input means 1394bus-to-device where as 
    411     // MSU input means subunit-to-device 
    412  
    413     AvPlugVector syncPCRInputPlugs = getPlugsByType( m_pcrPlugs, 
    414                                                      AvPlug::eAPD_Input, 
    415                                                      AvPlug::eAPT_Sync ); 
    416     if ( !syncPCRInputPlugs.size() ) { 
    417         debugWarning( "No PCR sync input plug found\n" ); 
    418     } 
    419  
    420     AvPlugVector syncPCROutputPlugs = getPlugsByType( m_pcrPlugs, 
    421                                                       AvPlug::eAPD_Output, 
    422                                                       AvPlug::eAPT_Sync ); 
    423     if ( !syncPCROutputPlugs.size() ) { 
    424         debugWarning( "No PCR sync output plug found\n" ); 
    425     } 
    426  
    427     AvPlugVector isoPCRInputPlugs = getPlugsByType( m_pcrPlugs, 
    428                                                     AvPlug::eAPD_Input, 
    429                                                     AvPlug::eAPT_IsoStream ); 
    430     if ( !isoPCRInputPlugs.size() ) { 
    431         debugWarning( "No PCR iso input plug found\n" ); 
    432  
    433     } 
    434  
    435     AvPlugVector isoPCROutputPlugs = getPlugsByType( m_pcrPlugs, 
    436                                                     AvPlug::eAPD_Output, 
    437                                                     AvPlug::eAPT_IsoStream ); 
    438     if ( !isoPCROutputPlugs.size() ) { 
    439         debugWarning( "No PCR iso output plug found\n" ); 
    440  
    441     } 
    442  
    443     AvPlugVector digitalExternalInputPlugs = getPlugsByType( m_externalPlugs, 
    444                                                     AvPlug::eAPD_Input, 
    445                                                     AvPlug::eAPT_Digital ); 
    446     if ( !digitalExternalInputPlugs.size() ) { 
    447         debugOutput( DEBUG_LEVEL_VERBOSE, "No external digital input plugs found\n" ); 
    448  
    449     } 
    450      
    451     AvPlugVector syncExternalInputPlugs = getPlugsByType( m_externalPlugs, 
    452                                                     AvPlug::eAPD_Input, 
    453                                                     AvPlug::eAPT_Sync ); 
    454     if ( !syncExternalInputPlugs.size() ) { 
    455         debugOutput( DEBUG_LEVEL_VERBOSE, "No external sync input plugs found\n" ); 
    456  
    457     } 
    458  
    459     AvPlugVector syncMSUInputPlugs = m_pPlugManager->getPlugsByType( 
    460         AVCCommand::eST_Music, 
    461         0, 
    462         0xff, 
    463         0xff, 
    464         AvPlug::eAPA_SubunitPlug, 
    465         AvPlug::eAPD_Input, 
    466         AvPlug::eAPT_Sync ); 
    467     if ( !syncMSUInputPlugs.size() ) { 
    468         debugWarning( "No sync input plug for MSU subunit found\n" ); 
    469     } 
    470  
    471     AvPlugVector syncMSUOutputPlugs = m_pPlugManager->getPlugsByType( 
    472         AVCCommand::eST_Music, 
    473         0, 
    474         0xff, 
    475         0xff, 
    476         AvPlug::eAPA_SubunitPlug, 
    477         AvPlug::eAPD_Output, 
    478         AvPlug::eAPT_Sync ); 
    479     if ( !syncMSUOutputPlugs.size() ) { 
    480         debugWarning( "No sync output plug for MSU subunit found\n" ); 
    481     } 
    482  
    483     debugOutput( DEBUG_LEVEL_VERBOSE, "PCR Sync Input Plugs:\n" ); 
    484     showAvPlugs( syncPCRInputPlugs ); 
    485     debugOutput( DEBUG_LEVEL_VERBOSE, "PCR Sync Output Plugs:\n" ); 
    486     showAvPlugs( syncPCROutputPlugs ); 
    487     debugOutput( DEBUG_LEVEL_VERBOSE, "PCR Iso Input Plugs:\n" ); 
    488     showAvPlugs( isoPCRInputPlugs ); 
    489     debugOutput( DEBUG_LEVEL_VERBOSE, "PCR Iso Output Plugs:\n" ); 
    490     showAvPlugs( isoPCROutputPlugs ); 
    491     debugOutput( DEBUG_LEVEL_VERBOSE, "External digital Input Plugs:\n" ); 
    492     showAvPlugs( digitalExternalInputPlugs ); 
    493     debugOutput( DEBUG_LEVEL_VERBOSE, "External sync Input Plugs:\n" ); 
    494     showAvPlugs( syncExternalInputPlugs ); 
    495     debugOutput( DEBUG_LEVEL_VERBOSE, "MSU Sync Input Plugs:\n" ); 
    496     showAvPlugs( syncMSUInputPlugs ); 
    497     debugOutput( DEBUG_LEVEL_VERBOSE, "MSU Sync Output Plugs:\n" ); 
    498     showAvPlugs( syncMSUOutputPlugs ); 
    499  
    500     // Check all possible PCR input to MSU input connections 
    501     // -> sync stream input 
    502     checkSyncConnectionsAndAddToList( syncPCRInputPlugs, 
    503                                       syncMSUInputPlugs, 
    504                                       "Sync Stream Input" ); 
    505  
    506     // Check all possible MSU output to PCR output connections 
    507     // -> sync stream output 
    508     checkSyncConnectionsAndAddToList( syncMSUOutputPlugs, 
    509                                       syncPCROutputPlugs, 
    510                                       "Sync Stream Output" ); 
    511  
    512     // Check all PCR iso input to MSU input connections 
    513     // -> SYT match 
    514     checkSyncConnectionsAndAddToList( isoPCRInputPlugs, 
    515                                       syncMSUInputPlugs, 
    516                                       "Syt Match" ); 
    517  
    518     // Check all MSU sync output to MSU input connections 
    519     // -> CSP 
    520     checkSyncConnectionsAndAddToList( syncMSUOutputPlugs, 
    521                                       syncMSUInputPlugs, 
    522                                       "Internal (CSP)" ); 
    523  
    524     // Check all external digital input to MSU input connections 
    525     // -> SPDIF/ADAT sync 
    526     checkSyncConnectionsAndAddToList( digitalExternalInputPlugs, 
    527                                       syncMSUInputPlugs, 
    528                                       "Digital Input Sync" ); 
    529  
    530     // Check all external sync input to MSU input connections 
    531     // -> SPDIF/ADAT sync 
    532     checkSyncConnectionsAndAddToList( syncExternalInputPlugs, 
    533                                       syncMSUInputPlugs, 
    534                                       "Digital Input Sync" ); 
    535  
    536     // Currently active connection signal source cmd, command type 
    537     // status, source unknown, destination MSU sync input plug 
    538  
    539     for ( AvPlugVector::const_iterator it = syncMSUInputPlugs.begin(); 
    540           it != syncMSUInputPlugs.end(); 
    541           ++it ) 
    542     { 
    543         AvPlug* msuPlug = *it; 
    544         for ( AvPlugVector::const_iterator jt = 
    545                   msuPlug->getInputConnections().begin(); 
    546               jt != msuPlug->getInputConnections().end(); 
    547               ++jt ) 
    548         { 
    549             AvPlug* plug = *jt; 
    550  
    551             for ( SyncInfoVector::iterator it = m_syncInfos.begin(); 
    552                   it != m_syncInfos.end(); 
    553                   ++it ) 
    554             { 
    555                 SyncInfo* pSyncInfo = &*it; 
    556                 if ( ( pSyncInfo->m_source == plug ) 
    557                      && ( pSyncInfo->m_destination == msuPlug ) ) 
    558                 { 
    559                     m_activeSyncInfo = pSyncInfo; 
    560                     break; 
    561                 } 
    562             } 
    563             debugOutput( DEBUG_LEVEL_NORMAL, 
    564                          "Active Sync Connection: '%s' -> '%s'\n", 
    565                          plug->getName(), 
    566                          msuPlug->getName() ); 
    567         } 
    568     } 
    569  
    570     return true; 
    571 } 
    572  
    573 bool 
    574 AvDevice::enumerateSubUnits() 
    575 { 
    576     bool musicSubunitFound=false; 
    577     bool audioSubunitFound=false; 
    578  
    579     SubUnitInfoCmd subUnitInfoCmd( *m_p1394Service ); 
    580     //subUnitInfoCmd.setVerbose( 1 ); 
    581     subUnitInfoCmd.setCommandType( AVCCommand::eCT_Status ); 
    582  
    583     // BeBoB has always exactly one audio and one music subunit. This 
    584     // means is fits into the first page of the SubUnitInfo command. 
    585     // So there is no need to do more than needed 
    586  
    587     subUnitInfoCmd.m_page = 0; 
    588     subUnitInfoCmd.setNodeId( m_pConfigRom->getNodeId() ); 
    589     subUnitInfoCmd.setVerbose( m_verboseLevel ); 
    590     if ( !subUnitInfoCmd.fire() ) { 
    591         debugError( "Subunit info command failed\n" ); 
    592         // shouldn't this be an error situation? 
    593         return false; 
    594     } 
    595  
    596     for ( int i = 0; i < subUnitInfoCmd.getNrOfValidEntries(); ++i ) { 
    597         subunit_type_t subunit_type 
    598             = subUnitInfoCmd.m_table[i].m_subunit_type; 
    599  
    600         unsigned int subunitId = getNrOfSubunits( subunit_type ); 
    601  
    602         debugOutput( DEBUG_LEVEL_VERBOSE, 
    603                      "subunit_id = %2d, subunit_type = %2d (%s)\n", 
    604                      subunitId, 
    605                      subunit_type, 
    606                      subunitTypeToString( subunit_type ) ); 
    607  
    608         AvDeviceSubunit* subunit = 0; 
    609         switch( subunit_type ) { 
    610         case AVCCommand::eST_Audio: 
    611             subunit = new AvDeviceSubunitAudio( *this, 
    612                                                 subunitId, 
    613                                                 m_verboseLevel ); 
    614             if ( !subunit ) { 
    615                 debugFatal( "Could not allocate AvDeviceSubunitAudio\n" ); 
    616                 return false; 
    617             } 
    618  
    619             m_subunits.push_back( subunit ); 
    620             audioSubunitFound=true; 
    621  
    622             break; 
    623         case AVCCommand::eST_Music: 
    624             subunit = new AvDeviceSubunitMusic( *this, 
    625                                                 subunitId, 
    626                                                 m_verboseLevel ); 
    627             if ( !subunit ) { 
    628                 debugFatal( "Could not allocate AvDeviceSubunitMusic\n" ); 
    629                 return false; 
    630             } 
    631  
    632             m_subunits.push_back( subunit ); 
    633             musicSubunitFound=true; 
    634  
    635             break; 
    636         default: 
    637             debugOutput( DEBUG_LEVEL_NORMAL, 
    638                          "Unsupported subunit found, subunit_type = %d (%s)\n", 
    639                          subunit_type, 
    640                          subunitTypeToString( subunit_type ) ); 
    641             continue; 
    642  
    643         } 
    644  
    645         if ( !subunit->discover() ) { 
    646             debugError( "enumerateSubUnits: Could not discover " 
    647                         "subunit_id = %2d, subunit_type = %2d (%s)\n", 
    648                         subunitId, 
    649                         subunit_type, 
    650                         subunitTypeToString( subunit_type ) ); 
    651             delete subunit; 
    652             return false; 
    653         } 
    654  
    655     } 
    656  
    657     // a BeBoB always has an audio and a music subunit 
    658     return (musicSubunitFound && audioSubunitFound); 
    659 } 
    660  
    661  
    662 AvDeviceSubunit* 
    663 AvDevice::getSubunit( subunit_type_t subunitType, 
    664                       subunit_id_t subunitId ) const 
    665 { 
    666     for ( AvDeviceSubunitVector::const_iterator it = m_subunits.begin(); 
    667           it != m_subunits.end(); 
    668           ++it ) 
    669     { 
    670         AvDeviceSubunit* subunit = *it; 
    671         if ( ( subunitType == subunit->getSubunitType() ) 
    672              && ( subunitId == subunit->getSubunitId() ) ) 
    673         { 
    674             return subunit; 
    675         } 
    676     } 
    677  
    678     return 0; 
    679 } 
    680  
    681  
    682 unsigned int 
    683 AvDevice::getNrOfSubunits( subunit_type_t subunitType ) const 
    684 { 
    685     unsigned int nrOfSubunits = 0; 
    686  
    687     for ( AvDeviceSubunitVector::const_iterator it = m_subunits.begin(); 
    688           it != m_subunits.end(); 
    689           ++it ) 
    690     { 
    691         AvDeviceSubunit* subunit = *it; 
    692         if ( subunitType == subunit->getSubunitType() ) { 
    693             nrOfSubunits++; 
    694         } 
    695     } 
    696  
    697     return nrOfSubunits; 
    698 } 
    699  
    700 AvPlugConnection* 
    701 AvDevice::getPlugConnection( AvPlug& srcPlug ) const 
    702 { 
    703     for ( AvPlugConnectionVector::const_iterator it 
    704               = m_plugConnections.begin(); 
    705           it != m_plugConnections.end(); 
    706           ++it ) 
    707     { 
    708         AvPlugConnection* plugConnection = *it; 
    709         if ( &( plugConnection->getSrcPlug() ) == &srcPlug ) { 
    710             return plugConnection; 
    711         } 
    712     } 
    713  
    714     return 0; 
    715 } 
    716  
    717 AvPlug* 
    718 AvDevice::getPlugById( AvPlugVector& plugs, 
    719                        AvPlug::EAvPlugDirection plugDirection, 
    720                        int id ) 
    721 { 
    722     for ( AvPlugVector::iterator it = plugs.begin(); 
    723           it != plugs.end(); 
    724           ++it ) 
    725     { 
    726         AvPlug* plug = *it; 
    727         if ( ( id == plug->getPlugId() ) 
    728              && ( plugDirection == plug->getPlugDirection() ) ) 
    729         { 
    730             return plug; 
    731         } 
    732     } 
    733  
    734     return 0; 
    735 } 
    736  
    737 AvPlugVector 
    738 AvDevice::getPlugsByType( AvPlugVector& plugs, 
    739                           AvPlug::EAvPlugDirection plugDirection, 
    740                           AvPlug::EAvPlugType type) 
    741 { 
    742     AvPlugVector plugVector; 
    743     for ( AvPlugVector::iterator it = plugs.begin(); 
    744           it != plugs.end(); 
    745           ++it ) 
    746     { 
    747         AvPlug* plug = *it; 
    748         if ( ( type == plug->getPlugType() ) 
    749              && ( plugDirection == plug->getPlugDirection() ) ) 
    750         { 
    751             plugVector.push_back( plug ); 
    752         } 
    753     } 
    754  
    755     return plugVector; 
    756 } 
    757  
    758 AvPlug* 
    759 AvDevice::getSyncPlug( int maxPlugId, AvPlug::EAvPlugDirection ) 
    760 { 
    761     return 0; 
    762 } 
    763  
    764 bool 
    765 AvDevice::setSamplingFrequency( ESamplingFrequency samplingFrequency ) 
    766 { 
    767     bool snoopMode=false; 
    768     if(!getOption("snoopMode", snoopMode)) { 
    769         debugWarning("Could not retrieve snoopMode parameter, defauling to false\n"); 
    770     } 
    771  
    772     if(snoopMode) { 
    773         int current_sr=getSamplingFrequency(); 
    774         if (current_sr != convertESamplingFrequency( samplingFrequency ) ) { 
    775             debugError("In snoop mode it is impossible to set the sample rate.\n"); 
    776             debugError("Please start the client with the correct setting.\n"); 
    777             return false; 
    778         } 
    779         return true; 
    780     } else { 
    781         AvPlug* plug = getPlugById( m_pcrPlugs, AvPlug::eAPD_Input, 0 ); 
    782         if ( !plug ) { 
    783             debugError( "setSampleRate: Could not retrieve iso input plug 0\n" ); 
    784             return false; 
    785         } 
    786  
    787         if ( !setSamplingFrequencyPlug( *plug, 
    788                                         AvPlug::eAPD_Input, 
    789                                         samplingFrequency ) ) 
    790         { 
    791             debugError( "setSampleRate: Setting sample rate failed\n" ); 
    792             return false; 
    793         } 
    794  
    795         plug = getPlugById( m_pcrPlugs, AvPlug::eAPD_Output,  0 ); 
    796         if ( !plug ) { 
    797             debugError( "setSampleRate: Could not retrieve iso output plug 0\n" ); 
    798             return false; 
    799         } 
    800  
    801         if ( !setSamplingFrequencyPlug( *plug, 
    802                                         AvPlug::eAPD_Output, 
    803                                         samplingFrequency ) ) 
    804         { 
    805             debugError( "setSampleRate: Setting sample rate failed\n" ); 
    806             return false; 
    807         } 
    808  
    809         debugOutput( DEBUG_LEVEL_VERBOSE, 
    810                      "setSampleRate: Set sample rate to %d\n", 
    811                      convertESamplingFrequency( samplingFrequency ) ); 
    812         return true; 
    813     } 
    814     // not executable 
    815     return false; 
    816 } 
    817  
    818 int 
    819 AvDevice::getSamplingFrequency( ) 
    820 { 
    821     AvPlug* inputPlug = getPlugById( m_pcrPlugs, AvPlug::eAPD_Input, 0 ); 
    822     if ( !inputPlug ) { 
    823         debugError( "setSampleRate: Could not retrieve iso input plug 0\n" ); 
    824         return false; 
    825     } 
    826     AvPlug* outputPlug = getPlugById( m_pcrPlugs, AvPlug::eAPD_Output, 0 ); 
    827     if ( !outputPlug ) { 
    828         debugError( "setSampleRate: Could not retrieve iso output plug 0\n" ); 
    829         return false; 
    830     } 
    831  
    832     int samplerate_playback=inputPlug->getSampleRate(); 
    833     int samplerate_capture=outputPlug->getSampleRate(); 
    834  
    835     if (samplerate_playback != samplerate_capture) { 
    836         debugWarning("Samplerates for capture and playback differ!\n"); 
    837     } 
    838     return samplerate_capture; 
    839 } 
    840226 
    841227int 
     
    916302    signalSourceCmd.setSignalDestination( signalUnitAddr ); 
    917303    signalSourceCmd.setNodeId( m_nodeId ); 
    918     signalSourceCmd.setSubunitType( AVCCommand::eST_Unit  ); 
     304    signalSourceCmd.setSubunitType( eST_Unit  ); 
    919305    signalSourceCmd.setSubunitId( 0xff ); 
    920306 
     
    957343} 
    958344 
    959 bool 
    960 AvDevice::setSamplingFrequencyPlug( AvPlug& plug, 
    961                                     AvPlug::EAvPlugDirection direction, 
    962                                     ESamplingFrequency samplingFrequency ) 
    963 { 
    964  
    965     ExtendedStreamFormatCmd extStreamFormatCmd( 
    966         *m_p1394Service, 
    967         ExtendedStreamFormatCmd::eSF_ExtendedStreamFormatInformationCommandList ); 
    968     UnitPlugAddress unitPlugAddress( UnitPlugAddress::ePT_PCR, 
    969                                      plug.getPlugId() ); 
    970  
    971     extStreamFormatCmd.setPlugAddress( 
    972         PlugAddress( 
    973             AvPlug::convertPlugDirection(direction ), 
    974             PlugAddress::ePAM_Unit, 
    975             unitPlugAddress ) ); 
    976  
    977     extStreamFormatCmd.setNodeId( m_pConfigRom->getNodeId() ); 
    978     extStreamFormatCmd.setCommandType( AVCCommand::eCT_Status ); 
    979  
    980     int i = 0; 
    981     bool cmdSuccess = false; 
    982     bool correctFormatFound = false; 
    983  
    984     do { 
    985         extStreamFormatCmd.setIndexInStreamFormat( i ); 
    986         extStreamFormatCmd.setCommandType( AVCCommand::eCT_Status ); 
    987         extStreamFormatCmd.setVerbose( m_verboseLevel ); 
    988  
    989         cmdSuccess = extStreamFormatCmd.fire(); 
    990  
    991         if ( cmdSuccess 
    992              && ( extStreamFormatCmd.getResponse() == 
    993                   AVCCommand::eR_Implemented ) ) 
    994         { 
    995             ESamplingFrequency foundFreq = eSF_DontCare; 
    996  
    997             FormatInformation* formatInfo = 
    998                 extStreamFormatCmd.getFormatInformation(); 
    999             FormatInformationStreamsCompound* compoundStream 
    1000                 = dynamic_cast< FormatInformationStreamsCompound* > ( 
    1001                     formatInfo->m_streams ); 
    1002             if ( compoundStream ) { 
    1003                 foundFreq = 
    1004                     static_cast< ESamplingFrequency >( 
    1005                         compoundStream->m_samplingFrequency ); 
    1006             } 
    1007  
    1008             FormatInformationStreamsSync* syncStream 
    1009                 = dynamic_cast< FormatInformationStreamsSync* > ( 
    1010                     formatInfo->m_streams ); 
    1011             if ( syncStream ) { 
    1012                 foundFreq = 
    1013                     static_cast< ESamplingFrequency >( 
    1014                         syncStream->m_samplingFrequency ); 
    1015             } 
    1016  
    1017             if ( foundFreq == samplingFrequency ) 
    1018             { 
    1019                 correctFormatFound = true; 
    1020                 break; 
    1021             } 
    1022         } 
    1023  
    1024         ++i; 
    1025     } while ( cmdSuccess 
    1026               && ( extStreamFormatCmd.getResponse() == 
    1027                    ExtendedStreamFormatCmd::eR_Implemented ) ); 
    1028  
    1029     if ( !cmdSuccess ) { 
    1030         debugError( "setSampleRatePlug: Failed to retrieve format info\n" ); 
    1031         return false; 
    1032     } 
    1033  
    1034     if ( !correctFormatFound ) { 
    1035         debugError( "setSampleRatePlug: %s plug %d does not support " 
    1036                     "sample rate %d\n", 
    1037                     plug.getName(), 
    1038                     plug.getPlugId(), 
    1039                     convertESamplingFrequency( samplingFrequency ) ); 
    1040         return false; 
    1041     } 
    1042  
    1043     extStreamFormatCmd.setSubFunction( 
    1044         ExtendedStreamFormatCmd::eSF_ExtendedStreamFormatInformationCommand ); 
    1045     extStreamFormatCmd.setCommandType( AVCCommand::eCT_Control ); 
    1046     extStreamFormatCmd.setVerbose( m_verboseLevel ); 
    1047  
    1048     if ( !extStreamFormatCmd.fire() ) { 
    1049         debugError( "setSampleRate: Could not set sample rate %d " 
    1050                     "to %s plug %d\n", 
    1051                     convertESamplingFrequency( samplingFrequency ), 
    1052                     plug.getName(), 
    1053                     plug.getPlugId() ); 
    1054         return false; 
    1055     } 
    1056  
    1057     return true; 
    1058 } 
    1059  
    1060 void 
    1061 AvDevice::showDevice() 
    1062 { 
    1063     debugOutput(DEBUG_LEVEL_VERBOSE, 
    1064         "%s %s at node %d\n", m_model->vendor_name, m_model->model_name, 
    1065         m_nodeId); 
    1066  
    1067     m_pPlugManager->showPlugs(); 
    1068 } 
    1069  
    1070 void 
    1071 AvDevice::showAvPlugs( AvPlugVector& plugs ) const 
    1072 { 
    1073     int i = 0; 
    1074     for ( AvPlugVector::const_iterator it = plugs.begin(); 
    1075           it != plugs.end(); 
    1076           ++it, ++i ) 
    1077     { 
    1078         AvPlug* plug = *it; 
    1079         debugOutput( DEBUG_LEVEL_VERBOSE, "Plug %d\n", i ); 
    1080         plug->showPlug(); 
    1081     } 
    1082 } 
    1083  
    1084 bool 
    1085 AvDevice::checkSyncConnectionsAndAddToList( AvPlugVector& plhs, 
    1086                                             AvPlugVector& prhs, 
    1087                                             std::string syncDescription ) 
    1088 { 
    1089     for ( AvPlugVector::iterator plIt = plhs.begin(); 
    1090           plIt != plhs.end(); 
    1091           ++plIt ) 
    1092     { 
    1093         AvPlug* pl = *plIt; 
    1094         for ( AvPlugVector::iterator prIt = prhs.begin(); 
    1095               prIt != prhs.end(); 
    1096               ++prIt ) 
    1097         { 
    1098             AvPlug* pr = *prIt; 
    1099             if ( pl->inquireConnnection( *pr ) ) { 
    1100                 m_syncInfos.push_back( SyncInfo( *pl, *pr, syncDescription ) ); 
    1101                 debugOutput( DEBUG_LEVEL_NORMAL, 
    1102                              "Sync connection '%s' -> '%s'\n", 
    1103                              pl->getName(), 
    1104                              pr->getName() ); 
    1105             } 
    1106         } 
    1107     } 
    1108     return true; 
    1109 } 
    1110  
    1111 bool AvDevice::setActiveSync(const SyncInfo& syncInfo) 
    1112 { 
    1113     return syncInfo.m_source->setConnection( *syncInfo.m_destination ); 
    1114 } 
    1115  
    1116 bool 
    1117 AvDevice::lock() { 
    1118     bool snoopMode=false; 
    1119     if(!getOption("snoopMode", snoopMode)) { 
    1120         debugWarning("Could not retrieve snoopMode parameter, defauling to false\n"); 
    1121     } 
    1122  
    1123     if (snoopMode) { 
    1124         // don't lock 
    1125     } else { 
    1126  
    1127     } 
    1128  
    1129     return true; 
    1130 } 
    1131  
    1132 bool 
    1133 AvDevice::unlock() { 
    1134     bool snoopMode=false; 
    1135     if(!getOption("snoopMode", snoopMode)) { 
    1136         debugWarning("Could not retrieve snoopMode parameter, defauling to false\n"); 
    1137     } 
    1138  
    1139     if (snoopMode) { 
    1140         // don't unlock 
    1141     } else { 
    1142  
    1143     } 
    1144     return true; 
    1145 } 
    1146  
    1147 bool 
    1148 AvDevice::prepare() { 
    1149     bool snoopMode=false; 
    1150     if(!getOption("snoopMode", snoopMode)) { 
    1151         debugWarning("Could not retrieve snoopMode parameter, defauling to false\n"); 
    1152     } 
    1153  
    1154     /////////// 
    1155     // get plugs 
    1156  
    1157     AvPlug* inputPlug = getPlugById( m_pcrPlugs, AvPlug::eAPD_Input, 0 ); 
    1158     if ( !inputPlug ) { 
    1159         debugError( "setSampleRate: Could not retrieve iso input plug 0\n" ); 
    1160         return false; 
    1161     } 
    1162     AvPlug* outputPlug = getPlugById( m_pcrPlugs, AvPlug::eAPD_Output, 0 ); 
    1163     if ( !outputPlug ) { 
    1164         debugError( "setSampleRate: Could not retrieve iso output plug 0\n" ); 
    1165         return false; 
    1166     } 
    1167  
    1168     int samplerate=outputPlug->getSampleRate(); 
    1169  
    1170     debugOutput( DEBUG_LEVEL_VERBOSE, "Initializing receive processor...\n"); 
    1171     // create & add streamprocessors 
    1172     Streaming::StreamProcessor *p; 
    1173  
    1174     p=new Streaming::AmdtpReceiveStreamProcessor( 
    1175                              m_p1394Service->getPort(), 
    1176                              samplerate, 
    1177                              outputPlug->getNrOfChannels()); 
    1178  
    1179     if(!p->init()) { 
    1180         debugFatal("Could not initialize receive processor!\n"); 
    1181         delete p; 
    1182         return false; 
    1183     } 
    1184      
    1185     if (!addPlugToProcessor(*outputPlug,p, 
    1186         Streaming::Port::E_Capture)) { 
    1187         debugFatal("Could not add plug to processor!\n"); 
    1188         delete p; 
    1189         return false; 
    1190     } 
    1191  
    1192     m_receiveProcessors.push_back(p); 
    1193  
    1194     // do the transmit processor 
    1195     debugOutput( DEBUG_LEVEL_VERBOSE, "Initializing transmit processor%s...\n", 
    1196             (snoopMode?" in snoop mode":"")); 
    1197     if (snoopMode) { 
    1198         // we are snooping, so this is receive too. 
    1199         p=new Streaming::AmdtpReceiveStreamProcessor( 
    1200                                   m_p1394Service->getPort(), 
    1201                                   samplerate, 
    1202                                   inputPlug->getNrOfChannels()); 
    1203     } else { 
    1204         p=new Streaming::AmdtpTransmitStreamProcessor( 
    1205                                 m_p1394Service->getPort(), 
    1206                                 samplerate, 
    1207                                 inputPlug->getNrOfChannels()); 
    1208     } 
    1209  
    1210     if(!p->init()) { 
    1211         debugFatal("Could not initialize transmit processor %s!\n", 
    1212             (snoopMode?" in snoop mode":"")); 
    1213         delete p; 
    1214         return false; 
    1215     } 
    1216  
    1217     if (snoopMode) { 
    1218         if (!addPlugToProcessor(*inputPlug,p, 
    1219             Streaming::Port::E_Capture)) { 
    1220             debugFatal("Could not add plug to processor!\n"); 
    1221             return false; 
    1222         } 
    1223     } else { 
    1224         if (!addPlugToProcessor(*inputPlug,p, 
    1225             Streaming::Port::E_Playback)) { 
    1226             debugFatal("Could not add plug to processor!\n"); 
    1227             return false; 
    1228         } 
    1229     } 
    1230  
    1231     // we put this SP into the transmit SP vector, 
    1232     // no matter if we are in snoop mode or not 
    1233     // this allows us to find out what direction 
    1234     // a certain stream should have. 
    1235     m_transmitProcessors.push_back(p); 
    1236  
    1237     return true; 
    1238 } 
    1239  
    1240 bool 
    1241 AvDevice::addPlugToProcessor( 
    1242     AvPlug& plug, 
    1243     Streaming::StreamProcessor *processor, 
    1244     Streaming::AmdtpAudioPort::E_Direction direction) { 
    1245  
    1246     std::string id=std::string("dev?"); 
    1247     if(!getOption("id", id)) { 
    1248         debugWarning("Could not retrieve id parameter, defauling to 'dev?'\n"); 
    1249     } 
    1250  
    1251     AvPlug::ClusterInfoVector& clusterInfos = plug.getClusterInfos(); 
    1252     for ( AvPlug::ClusterInfoVector::const_iterator it = clusterInfos.begin(); 
    1253           it != clusterInfos.end(); 
    1254           ++it ) 
    1255     { 
    1256         const AvPlug::ClusterInfo* clusterInfo = &( *it ); 
    1257  
    1258         AvPlug::ChannelInfoVector channelInfos = clusterInfo->m_channelInfos; 
    1259         for ( AvPlug::ChannelInfoVector::const_iterator it = channelInfos.begin(); 
    1260               it != channelInfos.end(); 
    1261               ++it ) 
    1262         { 
    1263             const AvPlug::ChannelInfo* channelInfo = &( *it ); 
    1264             std::ostringstream portname; 
    1265  
    1266             portname << id << "_" << channelInfo->m_name; 
    1267  
    1268             Streaming::Port *p=NULL; 
    1269             switch(clusterInfo->m_portType) { 
    1270             case ExtendedPlugInfoClusterInfoSpecificData::ePT_Speaker: 
    1271             case ExtendedPlugInfoClusterInfoSpecificData::ePT_Headphone: 
    1272             case ExtendedPlugInfoClusterInfoSpecificData::ePT_Microphone: 
    1273             case ExtendedPlugInfoClusterInfoSpecificData::ePT_Line: 
    1274             case ExtendedPlugInfoClusterInfoSpecificData::ePT_Analog: 
    1275                 p=new Streaming::AmdtpAudioPort( 
    1276                         portname.str(), 
    1277                         direction, 
    1278                         // \todo: streaming backend expects indexing starting from 0 
    1279                         // but bebob reports it starting from 1. Decide where 
    1280                         // and how to handle this (pp: here) 
    1281                         channelInfo->m_streamPosition - 1, 
    1282                         channelInfo->m_location - 1, 
    1283                         Streaming::AmdtpPortInfo::E_MBLA 
    1284                 ); 
    1285                 break; 
    1286  
    1287             case ExtendedPlugInfoClusterInfoSpecificData::ePT_MIDI: 
    1288                 p=new Streaming::AmdtpMidiPort( 
    1289                         portname.str(), 
    1290                         direction, 
    1291                         // \todo: streaming backend expects indexing starting from 0 
    1292                         // but bebob reports it starting from 1. Decide where 
    1293                         // and how to handle this (pp: here) 
    1294                         channelInfo->m_streamPosition - 1, 
    1295                         channelInfo->m_location - 1, 
    1296                         Streaming::AmdtpPortInfo::E_Midi 
    1297                 ); 
    1298  
    1299                 break; 
    1300             case ExtendedPlugInfoClusterInfoSpecificData::ePT_SPDIF: 
    1301             case ExtendedPlugInfoClusterInfoSpecificData::ePT_ADAT: 
    1302             case ExtendedPlugInfoClusterInfoSpecificData::ePT_TDIF: 
    1303             case ExtendedPlugInfoClusterInfoSpecificData::ePT_MADI: 
    1304             case ExtendedPlugInfoClusterInfoSpecificData::ePT_Digital: 
    1305                 p=new Streaming::AmdtpAudioPort( 
    1306                         portname.str(), 
    1307                         direction, 
    1308                         // \todo: streaming backend expects indexing starting from 0 
    1309                         // but bebob reports it starting from 1. Decide where 
    1310                         // and how to handle this (pp: here) 
    1311                         channelInfo->m_streamPosition - 1, 
    1312                         channelInfo->m_location - 1, 
    1313                         Streaming::AmdtpPortInfo::E_MBLA 
    1314                 ); 
    1315                 break; 
    1316             case ExtendedPlugInfoClusterInfoSpecificData::ePT_NoType: 
    1317             default: 
    1318             // unsupported 
    1319                 break; 
    1320             } 
    1321  
    1322             if (!p) { 
    1323                 debugOutput(DEBUG_LEVEL_VERBOSE, "Skipped port %s\n",channelInfo->m_name.c_str()); 
    1324             } else { 
    1325  
    1326                 if (!processor->addPort(p)) { 
    1327                     debugWarning("Could not register port with stream processor\n"); 
    1328                     return false; 
    1329                 } 
    1330             } 
    1331          } 
    1332     } 
    1333     return true; 
    1334 } 
    1335  
    1336 int 
    1337 AvDevice::getStreamCount() { 
    1338     return m_receiveProcessors.size() + m_transmitProcessors.size(); 
    1339 } 
    1340  
    1341 Streaming::StreamProcessor * 
    1342 AvDevice::getStreamProcessorByIndex(int i) { 
    1343  
    1344     if (i<(int)m_receiveProcessors.size()) { 
    1345         return m_receiveProcessors.at(i); 
    1346     } else if (i<(int)m_receiveProcessors.size() + (int)m_transmitProcessors.size()) { 
    1347         return m_transmitProcessors.at(i-m_receiveProcessors.size()); 
    1348     } 
    1349  
    1350     return NULL; 
    1351 } 
    1352  
    1353 bool 
    1354 AvDevice::startStreamByIndex(int i) { 
    1355     int iso_channel=-1; 
    1356     bool snoopMode=false; 
    1357     if(!getOption("snoopMode", snoopMode)) { 
    1358         debugWarning("Could not retrieve snoopMode parameter, defauling to false\n"); 
    1359     } 
    1360  
    1361     if (i<(int)m_receiveProcessors.size()) { 
    1362         int n=i; 
    1363         Streaming::StreamProcessor *p=m_receiveProcessors.at(n); 
    1364  
    1365         if(snoopMode) { // a stream from the device to another host 
    1366             // FIXME: put this into a decent framework! 
    1367             // we should check the oPCR[n] on the device 
    1368             struct iec61883_oPCR opcr; 
    1369             if (iec61883_get_oPCRX( 
    1370                     m_p1394Service->getHandle(), 
    1371                     m_pConfigRom->getNodeId() | 0xffc0, 
    1372                     (quadlet_t *)&opcr, 
    1373                     n)) { 
    1374  
    1375                 debugWarning("Error getting the channel for SP %d\n",i); 
    1376                 return false; 
    1377             } 
    1378  
    1379             iso_channel=opcr.channel; 
    1380         } else { 
    1381             iso_channel=m_p1394Service->allocateIsoChannelCMP( 
    1382                 m_pConfigRom->getNodeId() | 0xffc0, n, 
    1383                 m_p1394Service->getLocalNodeId()| 0xffc0, -1); 
    1384         } 
    1385         if (iso_channel<0) { 
    1386             debugError("Could not allocate ISO channel for SP %d\n",i); 
    1387             return false; 
    1388         } 
    1389  
    1390         debugOutput(DEBUG_LEVEL_VERBOSE, "Started SP %d on channel %d\n",i,iso_channel); 
    1391  
    1392         p->setChannel(iso_channel); 
    1393         return true; 
    1394  
    1395     } else if (i<(int)m_receiveProcessors.size() + (int)m_transmitProcessors.size()) { 
    1396         int n=i-m_receiveProcessors.size(); 
    1397         Streaming::StreamProcessor *p=m_transmitProcessors.at(n); 
    1398  
    1399         if(snoopMode) { // a stream from another host to the device 
    1400             // FIXME: put this into a decent framework! 
    1401             // we should check the iPCR[n] on the device 
    1402             struct iec61883_iPCR ipcr; 
    1403             if (iec61883_get_iPCRX( 
    1404                     m_p1394Service->getHandle(), 
    1405                     m_pConfigRom->getNodeId() | 0xffc0, 
    1406                     (quadlet_t *)&ipcr, 
    1407                     n)) { 
    1408  
    1409                 debugWarning("Error getting the channel for SP %d\n",i); 
    1410                 return false; 
    1411             } 
    1412  
    1413             iso_channel=ipcr.channel; 
    1414  
    1415         } else { 
    1416             iso_channel=m_p1394Service->allocateIsoChannelCMP( 
    1417                 m_p1394Service->getLocalNodeId()| 0xffc0, -1, 
    1418                 m_pConfigRom->getNodeId() | 0xffc0, n); 
    1419         } 
    1420  
    1421         if (iso_channel<0) { 
    1422             debugError("Could not allocate ISO channel for SP %d\n",i); 
    1423             return false; 
    1424         } 
    1425  
    1426         debugOutput(DEBUG_LEVEL_VERBOSE, "Started SP %d on channel %d\n",i,iso_channel); 
    1427  
    1428         p->setChannel(iso_channel); 
    1429         return true; 
    1430     } 
    1431  
    1432     debugError("SP index %d out of range!\n",i); 
    1433     return false; 
    1434 } 
    1435  
    1436 bool 
    1437 AvDevice::stopStreamByIndex(int i) { 
    1438     bool snoopMode=false; 
    1439     if(!getOption("snoopMode", snoopMode)) { 
    1440         debugWarning("Could not retrieve snoopMode parameter, defauling to false\n"); 
    1441     } 
    1442  
    1443     if (i<(int)m_receiveProcessors.size()) { 
    1444         int n=i; 
    1445         Streaming::StreamProcessor *p=m_receiveProcessors.at(n); 
    1446  
    1447         if(snoopMode) { 
    1448  
    1449         } else { 
    1450             // deallocate ISO channel 
    1451             if(!m_p1394Service->freeIsoChannel(p->getChannel())) { 
    1452                 debugError("Could not deallocate iso channel for SP %d\n",i); 
    1453                 return false; 
    1454             } 
    1455         } 
    1456         p->setChannel(-1); 
    1457  
    1458         return true; 
    1459  
    1460     } else if (i<(int)m_receiveProcessors.size() + (int)m_transmitProcessors.size()) { 
    1461         int n=i-m_receiveProcessors.size(); 
    1462         Streaming::StreamProcessor *p=m_transmitProcessors.at(n); 
    1463  
    1464         if(snoopMode) { 
    1465  
    1466         } else { 
    1467             // deallocate ISO channel 
    1468             if(!m_p1394Service->freeIsoChannel(p->getChannel())) { 
    1469                 debugError("Could not deallocate iso channel for SP %d\n",i); 
    1470                 return false; 
    1471             } 
    1472         } 
    1473         p->setChannel(-1); 
    1474  
    1475         return true; 
    1476     } 
    1477  
    1478     debugError("SP index %d out of range!\n",i); 
    1479     return false; 
    1480 } 
    1481345 
    1482346template <typename T> bool serializeVector( Glib::ustring path, 
     
    1497361template <typename T, typename VT> bool deserializeVector( Glib::ustring path, 
    1498362                                                           Util::IODeserialize& deser, 
    1499                                                            AvDevice& avDevice, 
     363                                                           Unit& avDevice, 
    1500364                                                           VT& vec ) 
    1501365{ 
     
    1520384 
    1521385bool 
    1522 AvDevice::serializeSyncInfoVector( Glib::ustring basePath, 
    1523                                    Util::IOSerialize& ser, 
    1524                                    const SyncInfoVector& vec ) const 
    1525 { 
    1526     bool result = true; 
    1527     int i = 0; 
    1528  
    1529     for ( SyncInfoVector::const_iterator it = vec.begin(); 
    1530           it != vec.end(); 
    1531           ++it ) 
    1532     { 
    1533         const SyncInfo& info = *it; 
    1534  
    1535         std::ostringstream strstrm; 
    1536         strstrm << basePath << i << "/"; 
    1537  
    1538         result &= ser.write( strstrm.str() + "m_source", info.m_source->getGlobalId() ); 
    1539         result &= ser.write( strstrm.str() + "m_destination", info.m_destination->getGlobalId() ); 
    1540         result &= ser.write( strstrm.str() + "m_description", Glib::ustring( info.m_description ) ); 
    1541  
    1542         i++; 
    1543     } 
    1544  
    1545     return result; 
    1546 } 
    1547  
    1548 bool 
    1549 AvDevice::deserializeSyncInfoVector( Glib::ustring basePath, 
    1550                                      Util::IODeserialize& deser, 
    1551                                      SyncInfoVector& vec ) 
    1552 { 
    1553     int i = 0; 
    1554     bool bFinished = false; 
    1555     do { 
    1556         bool result; 
    1557         std::ostringstream strstrm; 
    1558         strstrm << basePath << i << "/"; 
    1559  
    1560         plug_id_t sourceId; 
    1561         plug_id_t destinationId; 
    1562         Glib::ustring description; 
    1563  
    1564         if ( deser.isExisting( strstrm.str() + "m_source" ) ) { 
    1565             result  = deser.read( strstrm.str() + "m_source", sourceId ); 
    1566             result &= deser.read( strstrm.str() + "m_destination", destinationId ); 
    1567             result &= deser.read( strstrm.str() + "m_description", description ); 
    1568         } else { 
    1569             result = false; 
    1570         } 
    1571  
    1572         if ( result ) { 
    1573             SyncInfo syncInfo; 
    1574             syncInfo.m_source = m_pPlugManager->getPlug( sourceId ); 
    1575             syncInfo.m_destination = m_pPlugManager->getPlug( destinationId ); 
    1576             syncInfo.m_description = description; 
    1577  
    1578             vec.push_back( syncInfo ); 
    1579             i++; 
    1580         } else { 
    1581             bFinished = true; 
    1582         } 
    1583     } while ( !bFinished ); 
    1584  
    1585     return true; 
    1586 } 
    1587  
    1588 static bool 
    1589 deserializeAvPlugUpdateConnections( Glib::ustring path, 
    1590                                     Util::IODeserialize& deser, 
    1591                                     AvPlugVector& vec ) 
    1592 { 
    1593     bool result = true; 
    1594     for ( AvPlugVector::iterator it = vec.begin(); 
    1595           it != vec.end(); 
    1596           ++it ) 
    1597     { 
    1598         AvPlug* pPlug = *it; 
    1599         result &= pPlug->deserializeUpdate( path, deser ); 
    1600     } 
    1601     return result; 
    1602 } 
    1603  
    1604 bool 
    1605386AvDevice::serialize( Glib::ustring basePath, 
    1606387                     Util::IOSerialize& ser ) const 
     
    1609390    bool result; 
    1610391    result  = m_pConfigRom->serialize( basePath + "m_pConfigRom/", ser ); 
    1611     result &= ser.write( basePath + "m_verboseLevel", m_verboseLevel ); 
    1612     result &= m_pPlugManager->serialize( basePath + "AvPlug", ser ); // serialize all av plugs 
     392    result &= ser.write( basePath + "m_verboseLevel", getDebugLevel() ); 
     393    result &= m_pPlugManager->serialize( basePath + "Plug", ser ); // serialize all av plugs 
    1613394    result &= serializeVector( basePath + "PlugConnection", ser, m_plugConnections ); 
    1614395    result &= serializeVector( basePath + "Subunit", ser, m_subunits ); 
    1615     result &= serializeSyncInfoVector( basePath + "SyncInfo", ser, m_syncInfos ); 
     396    #warning broken at echoaudio merge 
     397    //result &= serializeSyncInfoVector( basePath + "SyncInfo", ser, m_syncInfos ); 
    1616398 
    1617399    int i = 0; 
     
    1630412    result &= serializeOptions( basePath + "Options", ser ); 
    1631413 
    1632     // result &= ser.write( basePath + "m_id", id ); 
     414//    result &= ser.write( basePath + "m_id", id ); 
    1633415 
    1634416    return result; 
    1635417} 
    1636418 
    1637 bool 
     419AvDevice* 
    1638420AvDevice::deserialize( Glib::ustring basePath, 
    1639                        Util::IODeserialize& deser ) 
    1640 
    1641     bool result; 
    1642     result  = deser.read( basePath + "m_verboseLevel", m_verboseLevel ); 
    1643  
    1644     delete m_pPlugManager; 
    1645     m_pPlugManager = AvPlugManager::deserialize( basePath + "AvPlug", deser, *this ); 
    1646     if ( !m_pPlugManager ) { 
    1647         return false; 
    1648     } 
    1649     result &= deserializeAvPlugUpdateConnections( basePath + "AvPlug", deser, m_pcrPlugs ); 
    1650     result &= deserializeAvPlugUpdateConnections( basePath + "AvPlug", deser, m_externalPlugs ); 
    1651     result &= deserializeVector<AvPlugConnection>( basePath + "PlugConnnection", deser, *this, m_plugConnections ); 
    1652     result &= deserializeVector<AvDeviceSubunit>( basePath + "Subunit",  deser, *this, m_subunits ); 
    1653     result &= deserializeSyncInfoVector( basePath + "SyncInfo", deser, m_syncInfos ); 
    1654  
    1655     unsigned int i; 
    1656     result &= deser.read( basePath + "m_activeSyncInfo", i ); 
    1657  
    1658     if ( result ) { 
    1659         if ( i < m_syncInfos.size() ) { 
    1660             m_activeSyncInfo = &m_syncInfos[i]; 
    1661         } 
    1662     } 
    1663  
    1664     result &= deserializeOptions( basePath + "Options", deser, *this ); 
    1665  
    1666     return result; 
    1667 
    1668  
     421                       Util::IODeserialize& deser, 
     422                       Ieee1394Service& ieee1394Service ) 
     423
     424 
     425//     ConfigRom *configRom = 
     426//         ConfigRom::deserialize( basePath + "m_pConfigRom/", deser, ieee1394Service ); 
     427//  
     428//     if ( !configRom ) { 
     429//         return NULL; 
     430//     } 
     431//  
     432//     AvDevice* pDev = new AvDevice( 
     433//         std::auto_ptr<ConfigRom>(configRom), 
     434//         ieee1394Service, configRom->getNodeId()); 
     435//  
     436//     if ( pDev ) { 
     437//         bool result; 
     438//         int verboseLevel; 
     439//         result  = deser.read( basePath + "m_verboseLevel", verboseLevel ); 
     440//         setDebugLevel( verboseLevel ); 
     441//          
     442//         result &= AVC::Unit::deserialize(basePath, pDev, deser, ieee1394Service); 
     443//  
     444//         result &= deserializeOptions( basePath + "Options", deser, *pDev ); 
     445//     } 
     446//  
     447//     return pDev; 
     448    return NULL; 
     449
    1669450 
    1670451Glib::ustring 
     
    1686467AvDevice::loadFromCache() 
    1687468{ 
    1688     Glib::ustring sDevicePath = getCachePath() + m_pConfigRom->getGuidString(); 
     469/*    Glib::ustring sDevicePath = getCachePath() + m_pConfigRom->getGuidString(); 
    1689470 
    1690471    char* configId; 
     
    1707488    } 
    1708489 
    1709     return result; 
     490    return result;*/ 
     491    return false; 
    1710492} 
    1711493 
     
    1713495AvDevice::saveCache() 
    1714496{ 
    1715     // the path looks like this: 
    1716     // PATH_TO_CACHE + GUID + CONFIGURATION_ID 
    1717  
    1718     Glib::ustring sDevicePath = getCachePath() + m_pConfigRom->getGuidString(); 
    1719     struct stat buf; 
    1720     if ( stat( sDevicePath.c_str(), &buf ) == 0 ) { 
    1721         if ( !S_ISDIR( buf.st_mode ) ) { 
    1722             debugError( "\"%s\" is not a directory\n",  sDevicePath.c_str() ); 
    1723             return false; 
    1724         } 
    1725     } else { 
    1726         if (  mkdir( sDevicePath.c_str(), S_IRWXU | S_IRWXG ) != 0 ) { 
    1727             debugError( "Could not create \"%s\" directory\n", sDevicePath.c_str() ); 
    1728             return false; 
    1729         } 
    1730     } 
    1731  
    1732     char* configId; 
    1733     asprintf(&configId, "%08x", BeBoB::AvDevice::getConfigurationId() ); 
    1734     if ( !configId ) { 
    1735         debugError( "Could not create id string\n" ); 
    1736         return false; 
    1737     } 
    1738     Glib::ustring sFileName = sDevicePath + "/" + configId + ".xml"; 
    1739     free( configId ); 
    1740     debugOutput( DEBUG_LEVEL_NORMAL, "filename %s\n", sFileName.c_str() ); 
    1741  
    1742     Util::XMLSerialize ser( sFileName ); 
    1743     return serialize( "", ser ); 
     497//     // the path looks like this: 
     498//     // PATH_TO_CACHE + GUID + CONFIGURATION_ID 
     499//  
     500//     Glib::ustring sDevicePath = getCachePath() + m_pConfigRom->getGuidString(); 
     501//     struct stat buf; 
     502//     if ( stat( sDevicePath.c_str(), &buf ) == 0 ) { 
     503//         if ( !S_ISDIR( buf.st_mode ) ) { 
     504//             debugError( "\"%s\" is not a directory\n",  sDevicePath.c_str() ); 
     505//             return false; 
     506//         } 
     507//     } else { 
     508//         if (  mkdir( sDevicePath.c_str(), S_IRWXU | S_IRWXG ) != 0 ) { 
     509//             debugError( "Could not create \"%s\" directory\n", sDevicePath.c_str() ); 
     510//             return false; 
     511//         } 
     512//     } 
     513//  
     514//     char* configId; 
     515//     asprintf(&configId, "%08x", BeBoB::AvDevice::getConfigurationId() ); 
     516//     if ( !configId ) { 
     517//         debugError( "Could not create id string\n" ); 
     518//         return false; 
     519//     } 
     520//     Glib::ustring sFileName = sDevicePath + "/" + configId + ".xml"; 
     521//     free( configId ); 
     522//     debugOutput( DEBUG_LEVEL_NORMAL, "filename %s\n", sFileName.c_str() ); 
     523//  
     524//     Util::XMLSerialize ser( sFileName ); 
     525//     return serialize( "", ser ); 
     526    return false; 
    1744527} 
    1745528 
  • trunk/libffado/src/bebob/bebob_avdevice.h

    r529 r554  
    2929#include "debugmodule/debugmodule.h" 
    3030#include "libavc/avc_definitions.h" 
    31 #include "libavc/avc_extended_cmd_generic.h" 
     31#include "libavc/general/avc_extended_cmd_generic.h" 
     32#include "libavc/general/avc_unit.h" 
     33#include "libavc/general/avc_subunit.h" 
     34#include "libavc/general/avc_plug.h" 
    3235 
    33 #include "bebob/bebob_configparser.h" 
    3436#include "bebob/bebob_avplug.h" 
    3537#include "bebob/bebob_avdevice_subunit.h" 
     
    4244#include "libutil/serialize.h" 
    4345 
    44 #include "iavdevice.h" 
     46#include "genericavc/avc_avdevice.h" 
     47 
     48#include "ffadodevice.h" 
    4549 
    4650#include <sstream> 
     
    4953class ConfigRom; 
    5054class Ieee1394Service; 
    51 class SubunitPlugSpecificDataPlugAddress; 
    5255 
    5356namespace BeBoB { 
    5457 
    55 class AvDevice : public IAvDevice { 
     58class AvDevice : public GenericAVC::AvDevice { 
    5659public: 
    5760    AvDevice( std::auto_ptr<ConfigRom>( configRom ), 
     
    6063    virtual ~AvDevice(); 
    6164 
    62     void setVerboseLevel(int l); 
    63  
    6465    static bool probe( ConfigRom& configRom ); 
    6566    virtual bool loadFromCache(); 
     
    6768    virtual bool discover(); 
    6869 
    69     virtual bool setSamplingFrequency( ESamplingFrequency samplingFrequency ); 
    70     virtual int getSamplingFrequency( ); 
    71  
    72     virtual int getStreamCount(); 
    73     virtual Streaming::StreamProcessor *getStreamProcessorByIndex(int i); 
    74  
    75     virtual bool prepare(); 
    76     virtual bool lock(); 
    77     virtual bool unlock(); 
    78  
    79     virtual bool startStreamByIndex(int i); 
    80     virtual bool stopStreamByIndex(int i); 
    81  
    82     virtual void showDevice(); 
    83  
    84     Ieee1394Service& get1394Service() 
    85         { return *m_p1394Service; } 
    86  
    87     AvPlugManager& getPlugManager() 
    88         { return *m_pPlugManager; } 
    89  
    90     struct SyncInfo { 
    91         SyncInfo( AvPlug& source, 
    92                   AvPlug& destination, 
    93                   std::string description ) 
    94             : m_source( &source ) 
    95             , m_destination( &destination ) 
    96             , m_description( description ) 
    97             {} 
    98         SyncInfo() 
    99             : m_source( 0 ) 
    100             , m_destination( 0 ) 
    101             , m_description( "" ) 
    102             {} 
    103         AvPlug*     m_source; 
    104         AvPlug*     m_destination; 
    105         std::string m_description; 
    106     }; 
    107  
    108     typedef std::vector<SyncInfo> SyncInfoVector; 
    109     const SyncInfoVector& getSyncInfos() const 
    110         { return m_syncInfos; } 
    111     const SyncInfo* getActiveSyncInfo() const 
    112         { return m_activeSyncInfo; } 
    113     bool setActiveSync( const SyncInfo& syncInfo ); 
    114  
    115     AvDeviceSubunitAudio* getAudioSubunit( subunit_id_t subunitId ) 
    116         { return dynamic_cast<AvDeviceSubunitAudio*>( 
    117                    getSubunit( AVC1394_SUBUNIT_AUDIO , subunitId ));}; 
     70    virtual AVC::Subunit* createSubunit(AVC::Unit& unit, 
     71                                        AVC::ESubunitType type, 
     72                                        AVC::subunit_t id ); 
     73    virtual AVC::Plug *createPlug( AVC::Unit* unit, 
     74                                   AVC::Subunit* subunit, 
     75                                   AVC::function_block_type_t functionBlockType, 
     76                                   AVC::function_block_type_t functionBlockId, 
     77                                   AVC::Plug::EPlugAddressType plugAddressType, 
     78                                   AVC::Plug::EPlugDirection plugDirection, 
     79                                   AVC::plug_id_t plugId ); 
    11880 
    11981protected: 
     82    virtual bool propagatePlugInfo(); 
    12083 
    121     bool enumerateSubUnits(); 
    122  
    123     bool discoverPlugs(); 
    124     bool discoverPlugsPCR( AvPlug::EAvPlugDirection plugDirection, 
    125                            plug_id_t plugMaxId ); 
    126     bool discoverPlugsExternal( AvPlug::EAvPlugDirection plugDirection, 
    127                                 plug_id_t plugMaxId ); 
    128     bool discoverPlugConnections(); 
    129     bool discoverSyncModes(); 
    130     bool discoverSubUnitsPlugConnections(); 
    131  
    132     AvDeviceSubunit* getSubunit( subunit_type_t subunitType, 
    133                                  subunit_id_t subunitId ) const; 
    134  
    135     unsigned int getNrOfSubunits( subunit_type_t subunitType ) const; 
    136     AvPlugConnection* getPlugConnection( AvPlug& srcPlug ) const; 
    137  
    138     AvPlug* getSyncPlug( int maxPlugId, AvPlug::EAvPlugDirection ); 
    139  
    140     AvPlug* getPlugById( AvPlugVector& plugs, 
    141                          AvPlug::EAvPlugDirection plugDireciton, 
    142                          int id ); 
    143     AvPlugVector getPlugsByType( AvPlugVector& plugs, 
    144                  AvPlug::EAvPlugDirection plugDirection, 
    145                  AvPlug::EAvPlugType type); 
    146  
    147     bool addPlugToProcessor( AvPlug& plug, Streaming::StreamProcessor *processor, 
    148                              Streaming::AmdtpAudioPort::E_Direction direction); 
    149  
    150     bool setSamplingFrequencyPlug( AvPlug& plug, 
    151                                    AvPlug::EAvPlugDirection direction, 
    152                                    ESamplingFrequency samplingFrequency ); 
    153  
    154     void showAvPlugs( AvPlugVector& plugs ) const; 
    155  
    156     bool checkSyncConnectionsAndAddToList( AvPlugVector& plhs, 
    157                                            AvPlugVector& prhs, 
    158                                            std::string syncDescription ); 
    159  
    160  
     84public: 
    16185    bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const; 
    162     bool deserialize( Glib::ustring basePath, 
    163                       Util::IODeserialize& deser ); 
    164     bool serializeSyncInfoVector( Glib::ustring basePath, 
    165                                   Util::IOSerialize& ser, 
    166                                   const SyncInfoVector& vec ) const; 
    167     bool deserializeSyncInfoVector( Glib::ustring basePath, 
    168                                     Util::IODeserialize& deser, 
    169                                     SyncInfoVector& vec ); 
     86    static AvDevice* deserialize( Glib::ustring basePath, 
     87                                  Util::IODeserialize& deser, 
     88                                  Ieee1394Service& ieee1394Service ); 
    17089    int getConfigurationIdSampleRate(); 
    171     int getConfigurationIdNumberOfChannel( PlugAddress::EPlugDirection ePlugDirection ); 
     90    int getConfigurationIdNumberOfChannel( AVC::PlugAddress::EPlugDirection ePlugDirection ); 
    17291    int getConfigurationIdSyncMode(); 
    17392    int getConfigurationId(); 
     
    17695 
    17796protected: 
    178     AvPlugVector              m_pcrPlugs; 
    179     AvPlugVector              m_externalPlugs; 
    180     AvPlugConnectionVector    m_plugConnections; 
    181     AvDeviceSubunitVector     m_subunits; 
    182     AvPlugManager*            m_pPlugManager; 
    183     SyncInfoVector            m_syncInfos; 
    184     SyncInfo*                 m_activeSyncInfo; 
    185     VendorModelEntry*         m_model; 
    18697    GenericMixer*             m_Mixer; 
    18798 
    188     // streaming stuff 
    189     typedef std::vector< Streaming::StreamProcessor * > StreamProcessorVector; 
    190     StreamProcessorVector m_receiveProcessors; 
    191     StreamProcessorVector m_transmitProcessors; 
    19299}; 
    193100 
  • trunk/libffado/src/bebob/bebob_avdevice_subunit.cpp

    r516 r554  
    2828#include "libieee1394/configrom.h" 
    2929 
    30 #include "libavc/avc_plug_info.h" 
    31 #include "libavc/avc_extended_stream_format.h" 
    32 #include "libavc/avc_serialize.h" 
     30#include "libavc/general/avc_plug_info.h" 
     31#include "libavc/streamformat/avc_extended_stream_format.h" 
     32#include "libavc/util/avc_serialize.h" 
    3333 
    3434#include <sstream> 
    3535 
    36 IMPL_DEBUG_MODULE( BeBoB::AvDeviceSubunit, BeBoB::AvDeviceSubunit, DEBUG_LEVEL_VERBOSE ); 
    37  
    38 //////////////////////////////////////////// 
    39  
    40 BeBoB::AvDeviceSubunit::AvDeviceSubunit( AvDevice& avDevice, 
    41                                          AVCCommand::ESubunitType type, 
    42                                          subunit_t id, 
    43                                          int verboseLevel ) 
    44     : m_avDevice( &avDevice ) 
    45     , m_sbType( type ) 
    46     , m_sbId( id ) 
    47     , m_verboseLevel( verboseLevel ) 
    48 
    49     setDebugLevel( m_verboseLevel ); 
    50 
    51  
    52 BeBoB::AvDeviceSubunit::AvDeviceSubunit() 
    53 
    54 
    55  
    56 BeBoB::AvDeviceSubunit::~AvDeviceSubunit() 
    57 
    58     for ( AvPlugVector::iterator it = m_plugs.begin(); 
    59           it != m_plugs.end(); 
    60           ++it ) 
    61     { 
    62         delete *it; 
    63     } 
    64 
    65  
    66 bool 
    67 BeBoB::AvDeviceSubunit::discover() 
    68 
    69     if ( !discoverPlugs() ) { 
    70         debugError( "plug discovering failed\n" ); 
    71         return false; 
    72     } 
    73  
    74     return true; 
    75 
    76  
    77 bool 
    78 BeBoB::AvDeviceSubunit::discoverPlugs() 
    79 
    80     PlugInfoCmd plugInfoCmd( m_avDevice->get1394Service(), 
    81                              PlugInfoCmd::eSF_SerialBusIsochronousAndExternalPlug ); 
    82     plugInfoCmd.setNodeId( m_avDevice->getConfigRom().getNodeId() ); 
    83     plugInfoCmd.setCommandType( AVCCommand::eCT_Status ); 
    84     plugInfoCmd.setSubunitType( m_sbType ); 
    85     plugInfoCmd.setSubunitId( m_sbId ); 
    86     plugInfoCmd.setVerbose( m_verboseLevel ); 
    87  
    88     if ( !plugInfoCmd.fire() ) { 
    89         debugError( "plug info command failed\n" ); 
    90         return false; 
    91     } 
    92  
    93     debugOutput( DEBUG_LEVEL_NORMAL, "number of source plugs = %d\n", 
    94                  plugInfoCmd.m_sourcePlugs ); 
    95     debugOutput( DEBUG_LEVEL_NORMAL, "number of destination output " 
    96                  "plugs = %d\n", plugInfoCmd.m_destinationPlugs ); 
    97  
    98     if ( !discoverPlugs( AvPlug::eAPD_Input, 
    99                          plugInfoCmd.m_destinationPlugs ) ) 
    100     { 
    101         debugError( "destination plug discovering failed\n" ); 
    102         return false; 
    103     } 
    104  
    105     if ( !discoverPlugs(  AvPlug::eAPD_Output, 
    106                           plugInfoCmd.m_sourcePlugs ) ) 
    107     { 
    108         debugError( "source plug discovering failed\n" ); 
    109         return false; 
    110     } 
    111  
    112     return true; 
    113 
    114  
    115 bool 
    116 BeBoB::AvDeviceSubunit::discoverConnections() 
    117 
    118     for ( AvPlugVector::iterator it = m_plugs.begin(); 
    119           it != m_plugs.end(); 
    120           ++it ) 
    121     { 
    122         AvPlug* plug = *it; 
    123         if ( !plug->discoverConnections() ) { 
    124             debugError( "plug connection discovering failed ('%s')\n", 
    125                         plug->getName() ); 
    126             return false; 
    127         } 
    128     } 
    129  
    130     return true; 
    131 
    132  
    133 bool 
    134 BeBoB::AvDeviceSubunit::discoverPlugs(AvPlug::EAvPlugDirection plugDirection, 
    135                                       plug_id_t plugMaxId ) 
    136 
    137     for ( int plugIdx = 0; 
    138           plugIdx < plugMaxId; 
    139           ++plugIdx ) 
    140     { 
    141         AVCCommand::ESubunitType subunitType = 
    142             static_cast<AVCCommand::ESubunitType>( getSubunitType() ); 
    143         AvPlug* plug = new AvPlug( m_avDevice->get1394Service(), 
    144                                    m_avDevice->getConfigRom(), 
    145                                    m_avDevice->getPlugManager(), 
    146                                    subunitType, 
    147                                    getSubunitId(), 
    148                                    0xff, 
    149                                    0xff, 
    150                                    AvPlug::eAPA_SubunitPlug, 
    151                                    plugDirection, 
    152                                    plugIdx, 
    153                                    m_verboseLevel ); 
    154         if ( !plug || !plug->discover() ) { 
    155             debugError( "plug discover failed\n" ); 
    156             return false; 
    157         } 
    158  
    159         debugOutput( DEBUG_LEVEL_NORMAL, "plug '%s' found\n", 
    160                      plug->getName() ); 
    161         m_plugs.push_back( plug ); 
    162     } 
    163     return true; 
    164 
    165  
    166 bool 
    167 BeBoB::AvDeviceSubunit::addPlug( AvPlug& plug ) 
    168 
    169     m_plugs.push_back( &plug ); 
    170     return true; 
    171 
    172  
    173  
    174 BeBoB::AvPlug* 
    175 BeBoB::AvDeviceSubunit::getPlug(AvPlug::EAvPlugDirection direction, plug_id_t plugId) 
    176 
    177     for ( AvPlugVector::iterator it = m_plugs.begin(); 
    178           it != m_plugs.end(); 
    179           ++it ) 
    180     { 
    181         AvPlug* plug = *it; 
    182         if ( ( plug->getPlugId() == plugId ) 
    183             && ( plug->getDirection() == direction ) ) 
    184         { 
    185             return plug; 
    186         } 
    187     } 
    188     return 0; 
    189 
    190  
    191  
    192 bool 
    193 BeBoB::AvDeviceSubunit::serialize( Glib::ustring basePath, 
    194                                    Util::IOSerialize& ser ) const 
    195 
    196     bool result; 
    197  
    198     result  = ser.write( basePath + "m_sbType", m_sbType ); 
    199     result &= ser.write( basePath + "m_sbId", m_sbId ); 
    200     result &= ser.write( basePath + "m_verboseLevel", m_verboseLevel ); 
    201     result &= serializeChild( basePath, ser ); 
    202  
    203     return result; 
    204 
    205  
    206 BeBoB::AvDeviceSubunit* 
    207 BeBoB::AvDeviceSubunit::deserialize( Glib::ustring basePath, 
    208                                      Util::IODeserialize& deser, 
    209                                      AvDevice& avDevice ) 
    210 
    211     bool result; 
    212     AVCCommand::ESubunitType sbType; 
    213  
    214     if ( !deser.isExisting( basePath + "m_sbType" ) ) { 
    215         return 0; 
    216     } 
    217  
    218     result  = deser.read( basePath + "m_sbType", sbType ); 
    219  
    220     AvDeviceSubunit* pSubunit = 0; 
    221     switch( sbType ) { 
    222     case AVCCommand::eST_Audio: 
    223         pSubunit = new AvDeviceSubunitAudio; 
    224         break; 
    225     case AVCCommand::eST_Music: 
    226         pSubunit = new AvDeviceSubunitMusic; 
    227         break; 
    228     default: 
    229         pSubunit = 0; 
    230     } 
    231  
    232     if ( !pSubunit ) { 
    233         return 0; 
    234     } 
    235  
    236     pSubunit->m_avDevice = &avDevice; 
    237     pSubunit->m_sbType = sbType; 
    238     result &= deser.read( basePath + "m_sbId", pSubunit->m_sbId ); 
    239     result &= deser.read( basePath + "m_verboseLevel", pSubunit->m_verboseLevel ); 
    240     result &= pSubunit->deserializeChild( basePath, deser, avDevice ); 
    241  
    242     if ( !result ) { 
    243         delete pSubunit; 
    244         return 0; 
    245     } 
    246  
    247     return pSubunit; 
    248 
    249  
    250 //////////////////////////////////////////// 
    251  
    252 BeBoB::AvDeviceSubunitAudio::AvDeviceSubunitAudio( AvDevice& avDevice, 
    253                                                    subunit_t id, 
    254                                                    int verboseLevel ) 
    255     : AvDeviceSubunit( avDevice, AVCCommand::eST_Audio, id, verboseLevel ) 
    256 
    257 
    258  
    259 BeBoB::AvDeviceSubunitAudio::AvDeviceSubunitAudio() 
    260     : AvDeviceSubunit() 
    261 
    262 
    263  
    264 BeBoB::AvDeviceSubunitAudio::~AvDeviceSubunitAudio() 
    265 
    266     for ( FunctionBlockVector::iterator it = m_functions.begin(); 
    267           it != m_functions.end(); 
    268           ++it ) 
    269     { 
    270         delete *it; 
    271     } 
    272 
    273  
    274 bool 
    275 BeBoB::AvDeviceSubunitAudio::discover() 
    276 
    277     debugOutput(DEBUG_LEVEL_NORMAL, "Discovering Audio Subunit...\n"); 
    278  
    279     if ( !AvDeviceSubunit::discover() ) { 
    280         return false; 
    281     } 
    282  
     36using namespace AVC; 
     37 
     38////////////////////////// 
     39 
     40BeBoB::SubunitAudio::SubunitAudio( AVC::Unit& avDevice, 
     41                                   subunit_t id ) 
     42    : AVC::SubunitAudio( avDevice, id ) 
     43
     44
     45 
     46BeBoB::SubunitAudio::SubunitAudio() 
     47    : AVC::SubunitAudio() 
     48
     49
     50 
     51BeBoB::SubunitAudio::~SubunitAudio() 
     52
     53 
     54
     55 
     56AVC::Plug * 
     57BeBoB::SubunitAudio::createPlug( AVC::Unit* unit, 
     58                     AVC::Subunit* subunit, 
     59                     AVC::function_block_type_t functionBlockType, 
     60                     AVC::function_block_type_t functionBlockId, 
     61                     AVC::Plug::EPlugAddressType plugAddressType, 
     62                     AVC::Plug::EPlugDirection plugDirection, 
     63                     AVC::plug_id_t plugId ) 
     64
     65 
     66    return new BeBoB::Plug( unit, 
     67                     subunit, 
     68                     functionBlockType, 
     69                     functionBlockId, 
     70                     plugAddressType, 
     71                     plugDirection, 
     72                     plugId ); 
     73
     74 
     75bool 
     76BeBoB::SubunitAudio::discover() 
     77
     78    debugOutput(DEBUG_LEVEL_NORMAL, "Discovering %s...\n", getName()); 
     79     
     80    // discover the AV/C generic part 
     81    if ( !AVC::SubunitAudio::discover() ) { 
     82        return false; 
     83    } 
     84 
     85    // do the remaining BeBoB audio subunit discovery 
    28386    if ( !discoverFunctionBlocks() ) { 
    28487        debugError( "function block discovering failed\n" ); 
     
    29093 
    29194bool 
    292 BeBoB::AvDeviceSubunitAudio::discoverConnections() 
     95BeBoB::SubunitAudio::discoverConnections() 
    29396{ 
    29497    debugOutput(DEBUG_LEVEL_NORMAL, "Discovering connections...\n"); 
    295     if ( !AvDeviceSubunit::discoverConnections() ) { 
     98    if ( !Subunit::discoverConnections() ) { 
    29699        return false; 
    297100    } 
     
    313116 
    314117const char* 
    315 BeBoB::AvDeviceSubunitAudio::getName() 
    316 { 
    317     return "AudioSubunit"; 
    318 } 
    319  
    320 bool 
    321 BeBoB::AvDeviceSubunitAudio::discoverFunctionBlocks() 
     118BeBoB::SubunitAudio::getName() 
     119{ 
     120    return "BeBoB::AudioSubunit"; 
     121} 
     122 
     123bool 
     124BeBoB::SubunitAudio::discoverFunctionBlocks() 
    322125{ 
    323126    debugOutput( DEBUG_LEVEL_NORMAL, 
     
    351154    // print a function block list 
    352155#ifdef DEBUG 
    353     if (getDebugLevel() >= DEBUG_LEVEL_NORMAL) { 
    354  
     156    if ((int)getDebugLevel() >= DEBUG_LEVEL_NORMAL) { 
     157     
    355158        for ( FunctionBlockVector::iterator it = m_functions.begin(); 
    356159            it != m_functions.end(); 
     
    369172 
    370173bool 
    371 BeBoB::AvDeviceSubunitAudio::discoverFunctionBlocksDo( 
     174BeBoB::SubunitAudio::discoverFunctionBlocksDo( 
    372175    ExtendedSubunitInfoCmd::EFunctionBlockType fbType ) 
    373176{ 
     
    378181    do { 
    379182        ExtendedSubunitInfoCmd 
    380             extSubunitInfoCmd( m_avDevice->get1394Service() ); 
    381         extSubunitInfoCmd.setNodeId( m_avDevice->getConfigRom().getNodeId() ); 
     183        extSubunitInfoCmd( m_unit->get1394Service() ); 
     184        extSubunitInfoCmd.setNodeId( m_unit->getConfigRom().getNodeId() ); 
    382185        extSubunitInfoCmd.setCommandType( AVCCommand::eCT_Status ); 
    383186        extSubunitInfoCmd.setSubunitId( getSubunitId() ); 
    384187        extSubunitInfoCmd.setSubunitType( getSubunitType() ); 
    385         extSubunitInfoCmd.setVerbose( m_verboseLevel ); 
     188        extSubunitInfoCmd.setVerbose( (int)getDebugLevel() ); 
    386189 
    387190        extSubunitInfoCmd.m_fbType = fbType; 
     
    417220 
    418221bool 
    419 BeBoB::AvDeviceSubunitAudio::createFunctionBlock( 
     222BeBoB::SubunitAudio::createFunctionBlock( 
    420223    ExtendedSubunitInfoCmd::EFunctionBlockType fbType, 
    421224    ExtendedSubunitInfoPageData& data ) 
     
    434237                                        data.m_noOfInputPlugs, 
    435238                                        data.m_noOfOutputPlugs, 
    436                                         m_verboseLevel ); 
     239                                        (int)getDebugLevel() ); 
    437240    } 
    438241    break; 
     
    444247                                       data.m_noOfInputPlugs, 
    445248                                       data.m_noOfOutputPlugs, 
    446                                        m_verboseLevel ); 
     249                                       (int)getDebugLevel() ); 
    447250    } 
    448251    break; 
     
    457260                                                 data.m_noOfInputPlugs, 
    458261                                                 data.m_noOfOutputPlugs, 
    459                                                  m_verboseLevel ); 
     262                                                 (int)getDebugLevel() ); 
    460263        } 
    461264        break; 
     
    474277                                              data.m_noOfInputPlugs, 
    475278                                              data.m_noOfOutputPlugs, 
    476                                               m_verboseLevel ); 
     279                                              (int)getDebugLevel() ); 
    477280            debugWarning( "Dummy function block processing created. " 
    478281                          "Implementation is missing\n" ); 
     
    487290                                     data.m_noOfInputPlugs, 
    488291                                     data.m_noOfOutputPlugs, 
    489                                      m_verboseLevel ); 
     292                                     (int)getDebugLevel() ); 
    490293        debugWarning( "Dummy function block codec created. " 
    491294                      "Implementation is missing\n" ); 
     
    513316 
    514317BeBoB::FunctionBlock::ESpecialPurpose 
    515 BeBoB::AvDeviceSubunitAudio::convertSpecialPurpose( 
     318BeBoB::SubunitAudio::convertSpecialPurpose( 
    516319    function_block_special_purpose_t specialPurpose ) 
    517320{ 
     
    531334 
    532335bool 
    533 BeBoB::AvDeviceSubunitAudio::serializeChild( Glib::ustring basePath, 
     336BeBoB::SubunitAudio::serializeChild( Glib::ustring basePath, 
    534337                                             Util::IOSerialize& ser ) const 
    535338{ 
     
    554357 
    555358bool 
    556 BeBoB::AvDeviceSubunitAudio::deserializeChild( Glib::ustring basePath, 
     359BeBoB::SubunitAudio::deserializeChild( Glib::ustring basePath, 
    557360                                               Util::IODeserialize& deser, 
    558                                                AvDevice& avDevice ) 
     361                                               AVC::Unit& avDevice ) 
    559362{ 
    560363    int i = 0; 
     
    580383//////////////////////////////////////////// 
    581384 
    582 BeBoB::AvDeviceSubunitMusic::AvDeviceSubunitMusic( AvDevice& avDevice, 
    583                                                    subunit_t id, 
    584                                                    int verboseLevel ) 
    585     : AvDeviceSubunit( avDevice, AVCCommand::eST_Music, id, verboseLevel ) 
    586 
    587 
    588  
    589 BeBoB::AvDeviceSubunitMusic::AvDeviceSubunitMusic() 
    590     : AvDeviceSubunit() 
    591 
    592 
    593  
    594 BeBoB::AvDeviceSubunitMusic::~AvDeviceSubunitMusic() 
    595 
     385BeBoB::SubunitMusic::SubunitMusic( AVC::Unit& avDevice, 
     386                                   subunit_t id ) 
     387    : AVC::SubunitMusic( avDevice, id ) 
     388
     389
     390 
     391BeBoB::SubunitMusic::SubunitMusic() 
     392    : AVC::SubunitMusic() 
     393
     394
     395 
     396BeBoB::SubunitMusic::~SubunitMusic() 
     397
     398
     399 
     400AVC::Plug * 
     401BeBoB::SubunitMusic::createPlug( AVC::Unit* unit, 
     402                     AVC::Subunit* subunit, 
     403                     AVC::function_block_type_t functionBlockType, 
     404                     AVC::function_block_type_t functionBlockId, 
     405                     AVC::Plug::EPlugAddressType plugAddressType, 
     406                     AVC::Plug::EPlugDirection plugDirection, 
     407                     AVC::plug_id_t plugId ) 
     408
     409 
     410    return new BeBoB::Plug( unit, 
     411                     subunit, 
     412                     functionBlockType, 
     413                     functionBlockId, 
     414                     plugAddressType, 
     415                     plugDirection, 
     416                     plugId ); 
     417
     418 
     419bool 
     420BeBoB::SubunitMusic::discover() 
     421
     422    debugOutput(DEBUG_LEVEL_NORMAL, "Discovering %s...\n", getName()); 
     423     
     424    // discover the AV/C generic part 
     425    if ( !AVC::SubunitMusic::discover() ) { 
     426        return false; 
     427    } 
     428 
     429    // do the remaining BeBoB music subunit discovery 
     430    // which is nothing 
     431 
     432    return true; 
    596433} 
    597434 
    598435const char* 
    599 BeBoB::AvDeviceSubunitMusic::getName() 
    600 { 
    601     return "MusicSubunit"; 
    602 } 
    603  
    604 bool 
    605 BeBoB::AvDeviceSubunitMusic::serializeChild( Glib::ustring basePath, 
     436BeBoB::SubunitMusic::getName() 
     437{ 
     438    return "BeBoB::MusicSubunit"; 
     439} 
     440 
     441bool 
     442BeBoB::SubunitMusic::serializeChild( Glib::ustring basePath, 
    606443                                             Util::IOSerialize& ser ) const 
    607444{ 
     
    610447 
    611448bool 
    612 BeBoB::AvDeviceSubunitMusic::deserializeChild( Glib::ustring basePath, 
     449BeBoB::SubunitMusic::deserializeChild( Glib::ustring basePath, 
    613450                                               Util::IODeserialize& deser, 
    614                                                AvDevice& avDevice ) 
    615 { 
    616     return true; 
    617 } 
     451                                               AVC::Unit& avDevice ) 
     452{ 
     453    return true; 
     454} 
  • trunk/libffado/src/bebob/bebob_avdevice_subunit.h

    r451 r554  
    2929 
    3030#include "debugmodule/debugmodule.h" 
    31 #include "libavc/avc_extended_subunit_info.h" 
     31#include "libavc/general/avc_extended_subunit_info.h" 
    3232#include "libavc/avc_definitions.h" 
    33 #include "libavc/avc_generic.h" 
     33#include "libavc/general/avc_generic.h" 
    3434 
    3535#include <vector> 
    3636 
     37#include "libavc/general/avc_subunit.h" 
     38#include "libavc/musicsubunit/avc_musicsubunit.h" 
     39#include "libavc/audiosubunit/avc_audiosubunit.h" 
     40#include "libavc/general/avc_plug.h" 
     41 
    3742namespace BeBoB { 
    38  
    39 class AvDevice; 
    40  
    41 class AvDeviceSubunit { 
    42  public: 
    43     AvDeviceSubunit( AvDevice& avDevice, 
    44              AVCCommand::ESubunitType type, 
    45              subunit_t id, 
    46              int verboseLevel ); 
    47     virtual ~AvDeviceSubunit(); 
    48  
    49     virtual bool discover(); 
    50     virtual bool discoverConnections(); 
    51     virtual const char* getName() = 0; 
    52  
    53     bool addPlug( AvPlug& plug ); 
    54  
    55     subunit_t getSubunitId() 
    56     { return m_sbId; } 
    57     AVCCommand::ESubunitType getSubunitType() 
    58     { return m_sbType; } 
    59  
    60     AvPlugVector& getPlugs() 
    61     { return m_plugs; } 
    62     AvPlug* getPlug(AvPlug::EAvPlugDirection direction, plug_id_t plugId); 
    63  
    64  
    65     AvDevice& getAvDevice() const 
    66         { return *m_avDevice; } 
    67  
    68  
    69     bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const; 
    70     static AvDeviceSubunit* deserialize( Glib::ustring basePath, 
    71                      Util::IODeserialize& deser, 
    72                                          AvDevice& avDevice ); 
    73  protected: 
    74     AvDeviceSubunit(); 
    75  
    76     bool discoverPlugs(); 
    77     bool discoverPlugs(AvPlug::EAvPlugDirection plugDirection, 
    78                        plug_id_t plugMaxId ); 
    79  
    80     virtual bool serializeChild( Glib::ustring basePath, 
    81                                  Util::IOSerialize& ser ) const = 0; 
    82     virtual bool deserializeChild( Glib::ustring basePath, 
    83                                    Util::IODeserialize& deser, 
    84                                    AvDevice& avDevice ) = 0; 
    85  
    86  protected: 
    87     AvDevice*                m_avDevice; 
    88     AVCCommand::ESubunitType m_sbType; 
    89     subunit_t                m_sbId; 
    90     int                      m_verboseLevel; 
    91  
    92     AvPlugVector             m_plugs; 
    93  
    94     DECLARE_DEBUG_MODULE; 
    95 }; 
    96  
    97 typedef std::vector<AvDeviceSubunit*> AvDeviceSubunitVector; 
    9843 
    9944///////////////////////////// 
    10045 
    101 class AvDeviceSubunitAudio: public AvDeviceSubunit { 
    102  public: 
    103     AvDeviceSubunitAudio( AvDevice& avDevice, 
    104               subunit_t id
    105               int verboseLevel ); 
    106     AvDeviceSubunitAudio(); 
    107     virtual ~AvDeviceSubunitAudio(); 
     46class SubunitAudio : public AVC::SubunitAudio 
     47
     48public: 
     49    SubunitAudio( AVC::Unit& avDevice
     50                  AVC::subunit_t id ); 
     51    SubunitAudio(); 
     52    virtual ~SubunitAudio(); 
    10853 
    10954    virtual bool discover(); 
    11055    virtual bool discoverConnections(); 
    11156 
     57    virtual AVC::Plug *createPlug( AVC::Unit* unit, 
     58                                   AVC::Subunit* subunit, 
     59                                   AVC::function_block_type_t functionBlockType, 
     60                                   AVC::function_block_type_t functionBlockId, 
     61                                   AVC::Plug::EPlugAddressType plugAddressType, 
     62                                   AVC::Plug::EPlugDirection plugDirection, 
     63                                   AVC::plug_id_t plugId ); 
     64 
    11265    virtual const char* getName(); 
    11366 
    114     FunctionBlockVector getFunctionBlocks() { return m_functions; }; 
    115      
    11667protected: 
    11768    bool discoverFunctionBlocks(); 
    11869    bool discoverFunctionBlocksDo( 
    119         ExtendedSubunitInfoCmd::EFunctionBlockType fbType ); 
     70        AVC::ExtendedSubunitInfoCmd::EFunctionBlockType fbType ); 
    12071    bool createFunctionBlock( 
    121         ExtendedSubunitInfoCmd::EFunctionBlockType fbType, 
    122         ExtendedSubunitInfoPageData& data ); 
     72        AVC::ExtendedSubunitInfoCmd::EFunctionBlockType fbType, 
     73        AVC::ExtendedSubunitInfoPageData& data ); 
    12374 
    12475    FunctionBlock::ESpecialPurpose convertSpecialPurpose( 
    125         function_block_special_purpose_t specialPurpose ); 
     76        AVC::function_block_special_purpose_t specialPurpose ); 
    12677 
    12778    virtual bool serializeChild( Glib::ustring basePath, 
     
    12980    virtual bool deserializeChild( Glib::ustring basePath, 
    13081                                   Util::IODeserialize& deser, 
    131                                    AvDevice& avDevice ); 
     82                                   AVC::Unit& unit ); 
    13283 
    133 protected: 
    134     FunctionBlockVector m_functions; 
    13584}; 
    13685 
    13786///////////////////////////// 
    13887 
    139 class AvDeviceSubunitMusic: public AvDeviceSubunit { 
     88class SubunitMusic : public AVC::SubunitMusic 
     89
    14090 public: 
    141     AvDeviceSubunitMusic( AvDevice& avDevice, 
    142               subunit_t id, 
    143               int verboseLevel ); 
    144     AvDeviceSubunitMusic(); 
    145     virtual ~AvDeviceSubunitMusic(); 
     91    SubunitMusic( AVC::Unit& avDevice, 
     92              AVC::subunit_t id ); 
     93    SubunitMusic(); 
     94    virtual ~SubunitMusic(); 
     95 
     96    virtual bool discover(); 
     97     
     98    virtual AVC::Plug *createPlug( AVC::Unit* unit, 
     99                                   AVC::Subunit* subunit, 
     100                                   AVC::function_block_type_t functionBlockType, 
     101                                   AVC::function_block_type_t functionBlockId, 
     102                                   AVC::Plug::EPlugAddressType plugAddressType, 
     103                                   AVC::Plug::EPlugDirection plugDirection, 
     104                                   AVC::plug_id_t plugId ); 
    146105 
    147106    virtual const char* getName(); 
     
    152111    virtual bool deserializeChild( Glib::ustring basePath, 
    153112                                   Util::IODeserialize& deser, 
    154                                    AvDevice& avDevice ); 
     113                                   AVC::Unit& unit ); 
     114 
    155115}; 
    156116 
  • trunk/libffado/src/bebob/bebob_avplug.cpp

    r516 r554  
    2727 
    2828#include "libieee1394/ieee1394service.h" 
    29 #include "libavc/avc_serialize.h" 
     29#include "libavc/util/avc_serialize.h" 
    3030 
    3131#include <sstream> 
    3232 
     33using namespace AVC; 
     34 
    3335namespace BeBoB { 
    3436 
    35 int AvPlug::m_globalIdCounter = 0; 
    36  
    37 IMPL_DEBUG_MODULE( AvPlug, AvPlug, DEBUG_LEVEL_NORMAL ); 
    38 IMPL_DEBUG_MODULE( AvPlugManager, AvPlugManager, DEBUG_LEVEL_NORMAL ); 
    39  
    40 AvPlug::AvPlug( Ieee1394Service& ieee1394Service, 
    41                 ConfigRom& configRom, 
    42                 AvPlugManager& plugManager, 
    43                 AVCCommand::ESubunitType subunitType, 
    44                 subunit_id_t subunitId, 
    45                 function_block_type_t functionBlockType, 
    46                 function_block_id_t functionBlockId, 
    47                 EAvPlugAddressType plugAddressType, 
    48                 EAvPlugDirection plugDirection, 
    49                 plug_id_t plugId, 
    50                 int verboseLevel ) 
    51     : m_p1394Service( &ieee1394Service ) 
    52     , m_pConfigRom( &configRom ) 
    53     , m_subunitType( subunitType ) 
    54     , m_subunitId( subunitId ) 
    55     , m_functionBlockType( functionBlockType ) 
    56     , m_functionBlockId( functionBlockId ) 
    57     , m_addressType( plugAddressType ) 
    58     , m_direction( plugDirection ) 
    59     , m_id( plugId ) 
    60     , m_infoPlugType( eAPT_Unknown ) 
    61     , m_nrOfChannels( 0 ) 
    62     , m_plugManager( &plugManager ) 
    63     , m_verboseLevel( verboseLevel ) 
    64     , m_globalId( m_globalIdCounter++ ) 
    65 
    66     setDebugLevel( m_verboseLevel ); 
     37Plug::Plug( AVC::Unit* unit, 
     38            AVC::Subunit* subunit, 
     39            AVC::function_block_type_t functionBlockType, 
     40            AVC::function_block_type_t functionBlockId, 
     41            AVC::Plug::EPlugAddressType plugAddressType, 
     42            AVC::Plug::EPlugDirection plugDirection, 
     43            AVC::plug_id_t plugId ) 
     44    : AVC::Plug( unit, 
     45                 subunit, 
     46                 functionBlockType, 
     47                 functionBlockId, 
     48                 plugAddressType, 
     49                 plugDirection, 
     50                 plugId ) 
     51
    6752    debugOutput( DEBUG_LEVEL_VERBOSE, 
    6853                 "nodeId = %d, subunitType = %d, " 
     
    7055                 "functionBlockId = %d, addressType = %d, " 
    7156                 "direction = %d, id = %d\n", 
    72                  m_pConfigRom->getNodeId(), 
    73                  m_subunitType, 
    74                  m_subunitId, 
    75                  m_functionBlockType, 
    76                  m_functionBlockId, 
    77                  m_addressType, 
    78                  m_direction, 
    79                  m_id ); 
    80 
    81  
    82 AvPlug::AvPlug( const AvPlug& rhs ) 
    83     : m_p1394Service( rhs.m_p1394Service ) 
    84     , m_pConfigRom( rhs.m_pConfigRom ) 
    85     , m_subunitType( rhs.m_subunitType ) 
    86     , m_subunitId( rhs.m_subunitId ) 
    87     , m_functionBlockType( rhs.m_functionBlockType ) 
    88     , m_functionBlockId( rhs.m_functionBlockId ) 
    89     , m_addressType( rhs.m_addressType ) 
    90     , m_direction( rhs.m_direction ) 
    91     , m_id( rhs.m_id ) 
    92     , m_infoPlugType( rhs.m_infoPlugType ) 
    93     , m_nrOfChannels( rhs.m_nrOfChannels ) 
    94     , m_name( rhs.m_name ) 
    95     , m_clusterInfos( rhs.m_clusterInfos ) 
    96     , m_formatInfos( rhs.m_formatInfos ) 
    97     , m_plugManager( rhs.m_plugManager ) 
    98     , m_verboseLevel( rhs.m_verboseLevel ) 
    99 
    100     if ( m_verboseLevel ) { 
    101         setDebugLevel( DEBUG_LEVEL_VERBOSE ); 
    102      } 
    103 
    104  
    105 AvPlug::AvPlug() 
    106     : m_p1394Service( 0 ) 
    107     , m_pConfigRom( 0 ) 
    108     , m_subunitType( AVCCommand::eST_Reserved ) // a good value for unknown/undefined? 
    109     , m_subunitId( 0 ) 
    110     , m_functionBlockType( 0 ) 
    111     , m_functionBlockId( 0 ) 
    112     , m_addressType( eAPA_Undefined ) 
    113     , m_direction( eAPD_Unknown ) 
    114     , m_id( 0 ) 
    115     , m_infoPlugType( eAPT_Unknown ) 
    116     , m_nrOfChannels( 0 ) 
    117     , m_plugManager( 0 ) 
    118     , m_verboseLevel( 0 ) 
    119     , m_globalId( 0 ) 
    120 
    121 
    122  
    123 AvPlug::~AvPlug() 
    124 
    125     if ( m_plugManager ) { 
    126         m_plugManager->remPlug( *this ); 
    127     } 
    128 
    129  
    130 bool 
    131 AvPlug::discover() 
     57                 unit->getConfigRom().getNodeId(), 
     58                 getSubunitType(), 
     59                 getSubunitId(), 
     60                 functionBlockType, 
     61                 functionBlockId, 
     62                 plugAddressType, 
     63                 plugDirection, 
     64                 plugId ); 
     65
     66 
     67Plug::Plug( const Plug& rhs ) 
     68    : AVC::Plug( rhs ) 
     69
     70 
     71
     72 
     73Plug::Plug() 
     74    : AVC::Plug() 
     75
     76
     77 
     78Plug::~Plug() 
     79
     80 
     81
     82 
     83bool 
     84Plug::discover() 
    13285{ 
    13386    if ( !discoverPlugType() ) { 
    13487        debugError( "discover: Could not discover plug type (%d,%d,%d,%d,%d)\n", 
    135                     m_pConfigRom->getNodeId(), m_subunitType, m_subunitId, m_direction, m_id ); 
     88                    m_unit->getConfigRom().getNodeId(), getSubunitType(), getSubunitId(), m_direction, m_id ); 
    13689        return false; 
    13790    } 
     
    13992    if ( !discoverName() ) { 
    14093        debugError( "Could not discover name (%d,%d,%d,%d,%d)\n", 
    141                     m_pConfigRom->getNodeId(), m_subunitType, m_subunitId, m_direction, m_id ); 
     94                    m_unit->getConfigRom().getNodeId(), getSubunitType(), getSubunitId(), m_direction, m_id ); 
    14295        return false; 
    14396    } 
     
    14699        debugError( "Could not discover number of channels " 
    147100                    "(%d,%d,%d,%d,%d)\n", 
    148                     m_pConfigRom->getNodeId(), m_subunitType, m_subunitId, m_direction, m_id ); 
     101                    m_unit->getConfigRom().getNodeId(), getSubunitType(), getSubunitId(), m_direction, m_id ); 
    149102        return false; 
    150103    } 
     
    153106        debugError( "Could not discover channel positions " 
    154107                    "(%d,%d,%d,%d,%d)\n", 
    155                     m_pConfigRom->getNodeId(), m_subunitType, m_subunitId, m_direction, m_id ); 
     108                    m_unit->getConfigRom().getNodeId(), getSubunitType(), getSubunitId(), m_direction, m_id ); 
    156109        return false; 
    157110    } 
     
    160113        debugError( "Could not discover channel name " 
    161114                    "(%d,%d,%d,%d,%d)\n", 
    162                     m_pConfigRom->getNodeId(), m_subunitType, m_subunitId, m_direction, m_id ); 
     115                    m_unit->getConfigRom().getNodeId(), getSubunitType(), getSubunitId(), m_direction, m_id ); 
    163116        return false; 
    164117    } 
     
    167120        debugError( "Could not discover channel name " 
    168121                    "(%d,%d,%d,%d,%d)\n", 
    169                     m_pConfigRom->getNodeId(), m_subunitType, m_subunitId, m_direction, m_id ); 
     122                    m_unit->getConfigRom().getNodeId(), getSubunitType(), getSubunitId(), m_direction, m_id ); 
    170123        return false; 
    171124    } 
     
    174127        debugError( "Could not discover stream format " 
    175128                    "(%d,%d,%d,%d,%d)\n", 
    176                     m_pConfigRom->getNodeId(), m_subunitType, m_subunitId, m_direction, m_id ); 
     129                    m_unit->getConfigRom().getNodeId(), getSubunitType(), getSubunitId(), m_direction, m_id ); 
    177130        return false; 
    178131    } 
     
    181134        debugError( "Could not discover supported stream formats " 
    182135                    "(%d,%d,%d,%d,%d)\n", 
    183                     m_pConfigRom->getNodeId(), m_subunitType, m_subunitId, m_direction, m_id ); 
    184         return false; 
    185     } 
    186  
    187     return m_plugManager->addPlug( *this ); 
    188 } 
    189  
    190 bool 
    191 AvPlug::discoverConnections() 
     136                    m_unit->getConfigRom().getNodeId(), getSubunitType(), getSubunitId(), m_direction, m_id ); 
     137        return false; 
     138    } 
     139 
     140    return m_unit->getPlugManager().addPlug( *this ); 
     141} 
     142 
     143bool 
     144Plug::discoverConnections() 
    192145{ 
    193146    return discoverConnectionsInput() && discoverConnectionsOutput(); 
     
    195148 
    196149bool 
    197 AvPlug::inquireConnnection( AvPlug& plug ) 
    198 
    199     SignalSourceCmd signalSourceCmd = setSrcPlugAddrToSignalCmd(); 
    200     setDestPlugAddrToSignalCmd( signalSourceCmd, plug ); 
    201     signalSourceCmd.setCommandType( AVCCommand::eCT_SpecificInquiry ); 
    202     signalSourceCmd.setVerbose( m_verboseLevel ); 
    203  
    204     if ( !signalSourceCmd.fire() ) { 
    205         debugError( "Could not inquire connection between '%s' and '%s'\n", 
    206                     getName(), plug.getName() ); 
    207         return false; 
    208     } 
    209  
    210     if ( signalSourceCmd.getResponse() == AVCCommand::eR_Implemented ) { 
    211         debugOutput( DEBUG_LEVEL_VERBOSE, 
    212                      "Connection possible between '%s' and '%s'\n", 
    213                      getName(),  plug.getName() ); 
    214         return true; 
    215     } 
    216     debugOutput( DEBUG_LEVEL_VERBOSE, 
    217                  "Connection not possible between '%s' and '%s'\n", 
    218                  getName(),  plug.getName() ); 
    219     return false; 
    220 
    221  
    222 bool 
    223 AvPlug::setConnection( AvPlug& plug ) 
    224 
    225     SignalSourceCmd signalSourceCmd = setSrcPlugAddrToSignalCmd(); 
    226     setDestPlugAddrToSignalCmd( signalSourceCmd, plug ); 
    227     signalSourceCmd.setCommandType( AVCCommand::eCT_Control ); 
    228     signalSourceCmd.setVerbose( m_verboseLevel ); 
    229  
    230     if ( !signalSourceCmd.fire() ) { 
    231         debugError( "Could not set connection between '%s' and '%s'\n", 
    232                     getName(), plug.getName() ); 
    233         return false; 
    234     } 
    235  
    236     if ( signalSourceCmd.getResponse() == AVCCommand::eR_Accepted ) { 
    237         debugOutput( DEBUG_LEVEL_VERBOSE, 
    238                      "Could set connection between '%s' and '%s'\n", 
    239                      getName(), plug.getName() ); 
    240         return true; 
    241     } 
    242     debugOutput( DEBUG_LEVEL_VERBOSE, 
    243                  "Could not set connection between '%s' and '%s'\n", 
    244                  getName(),  plug.getName() ); 
    245     return false; 
    246 
    247  
    248 int 
    249 AvPlug::getNrOfStreams() const 
    250 
    251     int nrOfChannels = 0; 
    252     for ( ClusterInfoVector::const_iterator it = m_clusterInfos.begin(); 
    253           it != m_clusterInfos.end(); 
    254           ++it ) 
    255     { 
    256         const ClusterInfo* clusterInfo = &( *it ); 
    257         nrOfChannels += clusterInfo->m_nrOfChannels; 
    258     } 
    259     return nrOfChannels; 
    260 
    261  
    262 int 
    263 AvPlug::getNrOfChannels() const 
    264 
    265     return m_nrOfChannels; 
    266 
    267  
    268 int 
    269 AvPlug::getSampleRate() const 
    270 
    271     return convertESamplingFrequency( static_cast<ESamplingFrequency>( m_samplingFrequency ) ); 
    272 
    273  
    274 bool 
    275 AvPlug::discoverPlugType() 
     150Plug::discoverPlugType() 
    276151{ 
    277152    ExtendedPlugInfoCmd extPlugInfoCmd = setPlugAddrToPlugInfoCmd(); 
     
    280155    extendedPlugInfoInfoType.initialize(); 
    281156    extPlugInfoCmd.setInfoType( extendedPlugInfoInfoType ); 
    282     extPlugInfoCmd.setVerbose( m_verboseLevel ); 
     157    extPlugInfoCmd.setVerbose( getDebugLevel() ); 
    283158 
    284159    if ( !extPlugInfoCmd.fire() ) { 
     
    336211 
    337212bool 
    338 AvPlug::discoverName() 
     213Plug::discoverName() 
    339214{ 
    340215    ExtendedPlugInfoCmd extPlugInfoCmd = setPlugAddrToPlugInfoCmd(); 
     
    343218    extendedPlugInfoInfoType.initialize(); 
    344219    extPlugInfoCmd.setInfoType( extendedPlugInfoInfoType ); 
    345     extPlugInfoCmd.setVerbose( m_verboseLevel ); 
     220    extPlugInfoCmd.setVerbose( getDebugLevel() ); 
    346221 
    347222    if ( !extPlugInfoCmd.fire() ) { 
     
    368243 
    369244bool 
    370 AvPlug::discoverNoOfChannels() 
     245Plug::discoverNoOfChannels() 
    371246{ 
    372247    ExtendedPlugInfoCmd extPlugInfoCmd = setPlugAddrToPlugInfoCmd(); 
     
    376251    extendedPlugInfoInfoType.initialize(); 
    377252    extPlugInfoCmd.setInfoType( extendedPlugInfoInfoType ); 
    378     extPlugInfoCmd.setVerbose( m_verboseLevel ); 
     253    extPlugInfoCmd.setVerbose( getDebugLevel() ); 
    379254 
    380255    if ( !extPlugInfoCmd.fire() ) { 
     
    401276 
    402277bool 
    403 AvPlug::discoverChannelPosition() 
     278Plug::discoverChannelPosition() 
    404279{ 
    405280    ExtendedPlugInfoCmd extPlugInfoCmd = setPlugAddrToPlugInfoCmd(); 
     
    408283    extendedPlugInfoInfoType.initialize(); 
    409284    extPlugInfoCmd.setInfoType( extendedPlugInfoInfoType ); 
    410     extPlugInfoCmd.setVerbose( m_verboseLevel ); 
     285    extPlugInfoCmd.setVerbose( getDebugLevel() ); 
    411286 
    412287    if ( !extPlugInfoCmd.fire() ) { 
     
    437312 
    438313bool 
    439 AvPlug::discoverChannelName() 
     314Plug::copyClusterInfo(ExtendedPlugInfoPlugChannelPositionSpecificData& 
     315                        channelPositionData ) 
     316
     317    int index = 1; 
     318    for ( ExtendedPlugInfoPlugChannelPositionSpecificData::ClusterInfoVector::const_iterator it 
     319              = channelPositionData.m_clusterInfos.begin(); 
     320          it != channelPositionData.m_clusterInfos.end(); 
     321          ++it ) 
     322    { 
     323        const ExtendedPlugInfoPlugChannelPositionSpecificData::ClusterInfo* 
     324            extPlugSpClusterInfo = &( *it ); 
     325 
     326        ClusterInfo clusterInfo; 
     327        clusterInfo.m_nrOfChannels = extPlugSpClusterInfo->m_nrOfChannels; 
     328        clusterInfo.m_index = index; 
     329        index++; 
     330 
     331        for (  ExtendedPlugInfoPlugChannelPositionSpecificData::ChannelInfoVector::const_iterator cit 
     332                  = extPlugSpClusterInfo->m_channelInfos.begin(); 
     333              cit != extPlugSpClusterInfo->m_channelInfos.end(); 
     334              ++cit ) 
     335        { 
     336            const ExtendedPlugInfoPlugChannelPositionSpecificData::ChannelInfo* 
     337                extPlugSpChannelInfo = &( *cit ); 
     338 
     339            ChannelInfo channelInfo; 
     340            channelInfo.m_streamPosition = 
     341                extPlugSpChannelInfo->m_streamPosition-1; 
     342            // FIXME: this can only become a mess with the two meanings 
     343            //        of the location parameter. the audio style meaning 
     344            //        starts from 1, the midi style meaning from 0 
     345            //        lucky for us we recalculate this for the midi channels 
     346            //        and don't use this value. 
     347            channelInfo.m_location = 
     348                extPlugSpChannelInfo->m_location; 
     349 
     350            clusterInfo.m_channelInfos.push_back( channelInfo ); 
     351        } 
     352        m_clusterInfos.push_back( clusterInfo ); 
     353    } 
     354 
     355    return true; 
     356
     357 
     358bool 
     359Plug::discoverChannelName() 
    440360{ 
    441361    for ( ClusterInfoVector::iterator clit = m_clusterInfos.begin(); 
     
    456376            extendedPlugInfoInfoType.initialize(); 
    457377            extPlugInfoCmd.setInfoType( extendedPlugInfoInfoType ); 
    458             extPlugInfoCmd.setVerbose( m_verboseLevel ); 
     378            extPlugInfoCmd.setVerbose( getDebugLevel() ); 
    459379 
    460380            ExtendedPlugInfoInfoType* infoType = 
     
    489409 
    490410bool 
    491 AvPlug::discoverClusterInfo() 
     411Plug::discoverClusterInfo() 
    492412{ 
    493413    if ( m_infoPlugType == eAPT_Sync ) 
     
    516436        extendedPlugInfoInfoType.initialize(); 
    517437        extPlugInfoCmd.setInfoType( extendedPlugInfoInfoType ); 
    518         extPlugInfoCmd.setVerbose( m_verboseLevel ); 
     438        extPlugInfoCmd.setVerbose( getDebugLevel() ); 
    519439 
    520440        extPlugInfoCmd.getInfoType()->m_plugClusterInfo->m_clusterIndex = 
     
    549469 
    550470bool 
    551 AvPlug::discoverStreamFormat() 
    552 
    553     ExtendedStreamFormatCmd extStreamFormatCmd = 
    554         setPlugAddrToStreamFormatCmd( ExtendedStreamFormatCmd::eSF_ExtendedStreamFormatInformationCommand ); 
    555     extStreamFormatCmd.setVerbose( m_verboseLevel ); 
    556  
    557     if ( !extStreamFormatCmd.fire() ) { 
    558         debugError( "stream format command failed\n" ); 
    559         return false; 
    560     } 
    561  
    562     if ( ( extStreamFormatCmd.getStatus() ==  ExtendedStreamFormatCmd::eS_NoStreamFormat ) 
    563          || ( extStreamFormatCmd.getStatus() ==  ExtendedStreamFormatCmd::eS_NotUsed ) ) 
    564     { 
    565         debugOutput( DEBUG_LEVEL_VERBOSE, 
    566                      "No stream format information available\n" ); 
    567         return true; 
    568     } 
    569  
    570     if ( !extStreamFormatCmd.getFormatInformation() ) { 
    571         debugWarning( "No stream format information for plug found -> skip\n" ); 
    572         return true; 
    573     } 
    574  
    575     if ( extStreamFormatCmd.getFormatInformation()->m_root 
    576            != FormatInformation::eFHR_AudioMusic  ) 
    577     { 
    578         debugWarning( "Format hierarchy root is not Audio&Music -> skip\n" ); 
    579         return true; 
    580     } 
    581  
    582     FormatInformation* formatInfo = 
    583         extStreamFormatCmd.getFormatInformation(); 
    584     FormatInformationStreamsCompound* compoundStream 
    585         = dynamic_cast< FormatInformationStreamsCompound* > ( 
    586             formatInfo->m_streams ); 
    587     if ( compoundStream ) { 
    588         m_samplingFrequency = 
    589             compoundStream->m_samplingFrequency; 
    590         debugOutput( DEBUG_LEVEL_VERBOSE, 
    591                      "%s plug %d uses " 
    592                      "sampling frequency %d, nr of stream infos = %d\n", 
    593                      getName(), 
    594                      m_id, 
    595                      m_samplingFrequency, 
    596                      compoundStream->m_numberOfStreamFormatInfos ); 
    597  
    598         for ( int i = 1; 
    599               i <= compoundStream->m_numberOfStreamFormatInfos; 
    600               ++i ) 
    601         { 
    602             ClusterInfo* clusterInfo = 
    603                 const_cast<ClusterInfo*>( getClusterInfoByIndex( i ) ); 
    604  
    605             if ( !clusterInfo ) { 
    606                 debugError( "No matching cluster " 
    607                             "info found for index %d\n",  i ); 
    608                     return false; 
    609             } 
    610             StreamFormatInfo* streamFormatInfo = 
    611                 compoundStream->m_streamFormatInfos[ i - 1 ]; 
    612  
    613             debugOutput( DEBUG_LEVEL_VERBOSE, 
    614                          "number of channels = %d, stream format = %d\n", 
    615                          streamFormatInfo->m_numberOfChannels, 
    616                          streamFormatInfo->m_streamFormat ); 
    617  
    618             int nrOfChannels = clusterInfo->m_nrOfChannels; 
    619             if ( streamFormatInfo->m_streamFormat == 
    620                  FormatInformation::eFHL2_AM824_MIDI_CONFORMANT ) 
    621             { 
    622                 // 8 logical midi channels fit into 1 channel 
    623                 nrOfChannels = ( ( nrOfChannels + 7 ) / 8 ); 
    624             } 
    625             // sanity check 
    626             if ( nrOfChannels != streamFormatInfo->m_numberOfChannels ) 
    627             { 
    628                 debugWarning( "Number of channels " 
    629                               "mismatch: '%s' plug discovering reported " 
    630                               "%d channels for cluster '%s', while stream " 
    631                               "format reported %d\n", 
    632                               getName(), 
    633                               nrOfChannels, 
    634                               clusterInfo->m_name.c_str(), 
    635                               streamFormatInfo->m_numberOfChannels); 
    636             } 
    637             clusterInfo->m_streamFormat = streamFormatInfo->m_streamFormat; 
    638  
    639             debugOutput( DEBUG_LEVEL_VERBOSE, 
    640                          "%s plug %d cluster info %d ('%s'): " 
    641                          "stream format %d\n", 
    642                          getName(), 
    643                          m_id, 
    644                          i, 
    645                          clusterInfo->m_name.c_str(), 
    646                          clusterInfo->m_streamFormat ); 
    647         } 
    648     } 
    649  
    650     FormatInformationStreamsSync* syncStream 
    651         = dynamic_cast< FormatInformationStreamsSync* > ( 
    652             formatInfo->m_streams ); 
    653     if ( syncStream ) { 
    654         m_samplingFrequency = 
    655             syncStream->m_samplingFrequency; 
    656         debugOutput( DEBUG_LEVEL_VERBOSE, 
    657                      "%s plug %d is sync stream with sampling frequency %d\n", 
    658                      getName(), 
    659                      m_id, 
    660                      m_samplingFrequency ); 
    661     } 
    662  
    663  
    664     if ( !compoundStream && !syncStream ) 
    665     { 
    666         debugError( "Unsupported stream format\n" ); 
    667         return false; 
    668     } 
    669  
    670     return true; 
    671 
    672  
    673 bool 
    674 AvPlug::discoverSupportedStreamFormats() 
    675 
    676     ExtendedStreamFormatCmd extStreamFormatCmd = 
    677         setPlugAddrToStreamFormatCmd( 
    678             ExtendedStreamFormatCmd::eSF_ExtendedStreamFormatInformationCommandList); 
    679     extStreamFormatCmd.setVerbose( m_verboseLevel ); 
    680  
    681     int i = 0; 
    682     bool cmdSuccess = false; 
    683  
    684     do { 
    685         extStreamFormatCmd.setIndexInStreamFormat( i ); 
    686         extStreamFormatCmd.setCommandType( AVCCommand::eCT_Status ); 
    687         cmdSuccess = extStreamFormatCmd.fire(); 
    688         if ( cmdSuccess 
    689              && ( extStreamFormatCmd.getResponse() 
    690                   == AVCCommand::eR_Implemented ) ) 
    691         { 
    692             FormatInfo formatInfo; 
    693             formatInfo.m_index = i; 
    694             bool formatInfoIsValid = true; 
    695  
    696             FormatInformationStreamsSync* syncStream 
    697                 = dynamic_cast< FormatInformationStreamsSync* > 
    698                 ( extStreamFormatCmd.getFormatInformation()->m_streams ); 
    699             if ( syncStream ) { 
    700                 formatInfo.m_samplingFrequency = 
    701                     syncStream->m_samplingFrequency; 
    702                 formatInfo.m_isSyncStream = true ; 
    703             } 
    704  
    705             FormatInformationStreamsCompound* compoundStream 
    706                 = dynamic_cast< FormatInformationStreamsCompound* > 
    707                 ( extStreamFormatCmd.getFormatInformation()->m_streams ); 
    708             if ( compoundStream ) { 
    709                 formatInfo.m_samplingFrequency = 
    710                     compoundStream->m_samplingFrequency; 
    711                 formatInfo.m_isSyncStream = false; 
    712                 for ( int j = 0; 
    713                       j < compoundStream->m_numberOfStreamFormatInfos; 
    714                       ++j ) 
    715                 { 
    716                     switch ( compoundStream->m_streamFormatInfos[j]->m_streamFormat ) { 
    717                     case AVC1394_STREAM_FORMAT_AM824_IEC60968_3: 
    718                         formatInfo.m_audioChannels += 
    719                             compoundStream->m_streamFormatInfos[j]->m_numberOfChannels; 
    720                         break; 
    721                     case AVC1394_STREAM_FORMAT_AM824_MULTI_BIT_LINEAR_AUDIO_RAW: 
    722                         formatInfo.m_audioChannels += 
    723                             compoundStream->m_streamFormatInfos[j]->m_numberOfChannels; 
    724                         break; 
    725                     case AVC1394_STREAM_FORMAT_AM824_MIDI_CONFORMANT: 
    726                         formatInfo.m_midiChannels += 
    727                             compoundStream->m_streamFormatInfos[j]->m_numberOfChannels; 
    728                         break; 
    729                     default: 
    730                         formatInfoIsValid = false; 
    731                         debugWarning("unknown stream format (0x%02x) for channel " 
    732                                       "(%d)\n", 
    733                                      compoundStream->m_streamFormatInfos[j]->m_streamFormat, 
    734                                      j ); 
    735                     } 
    736                 } 
    737             } 
    738  
    739             if ( formatInfoIsValid ) { 
    740                 debugOutput( DEBUG_LEVEL_VERBOSE, 
    741                              "[%s:%d] formatInfo[%d].m_samplingFrequency " 
    742                              "= %d\n", 
    743                              getName(), m_id, 
    744                              i, formatInfo.m_samplingFrequency ); 
    745                 debugOutput( DEBUG_LEVEL_VERBOSE, 
    746                              "[%s:%d] formatInfo[%d].m_isSyncStream = %d\n", 
    747                              getName(), m_id, 
    748                              i, formatInfo.m_isSyncStream ); 
    749                 debugOutput( DEBUG_LEVEL_VERBOSE, 
    750                              "[%s:%d] formatInfo[%d].m_audioChannels = %d\n", 
    751                              getName(), m_id, 
    752                              i, formatInfo.m_audioChannels ); 
    753                 debugOutput( DEBUG_LEVEL_VERBOSE, 
    754                              "[%s:%d] formatInfo[%d].m_midiChannels = %d\n", 
    755                              getName(), m_id, 
    756                              i, formatInfo.m_midiChannels ); 
    757                 m_formatInfos.push_back( formatInfo ); 
    758             } 
    759         } 
    760  
    761         ++i; 
    762     } while ( cmdSuccess && ( extStreamFormatCmd.getResponse() 
    763                               == ExtendedStreamFormatCmd::eR_Implemented ) ); 
    764  
    765     return true; 
    766 
    767  
    768  
    769 bool 
    770 AvPlug::discoverConnectionsInput() 
     471Plug::discoverConnectionsInput() 
    771472{ 
    772473    ExtendedPlugInfoCmd extPlugInfoCmd = setPlugAddrToPlugInfoCmd(); 
     
    775476    extendedPlugInfoInfoType.initialize(); 
    776477    extPlugInfoCmd.setInfoType( extendedPlugInfoInfoType ); 
    777     extPlugInfoCmd.setVerbose( m_verboseLevel ); 
     478    extPlugInfoCmd.setVerbose( getDebugLevel() ); 
    778479 
    779480    if ( !extPlugInfoCmd.fire() ) { 
     
    820521 
    821522bool 
    822 AvPlug::discoverConnectionsOutput() 
     523Plug::discoverConnectionsOutput() 
    823524{ 
    824525    ExtendedPlugInfoCmd extPlugInfoCmd = setPlugAddrToPlugInfoCmd(); 
     
    827528    extendedPlugInfoInfoType.initialize(); 
    828529    extPlugInfoCmd.setInfoType( extendedPlugInfoInfoType ); 
    829     extPlugInfoCmd.setVerbose( m_verboseLevel ); 
     530    extPlugInfoCmd.setVerbose( getDebugLevel() ); 
    830531 
    831532    if ( !extPlugInfoCmd.fire() ) { 
     
    883584} 
    884585 
    885 bool 
    886 AvPlug::discoverConnectionsFromSpecificData( 
    887     EAvPlugDirection discoverDirection, 
    888     PlugAddressSpecificData* plugAddress, 
    889     AvPlugVector& connections ) 
    890 { 
    891     UnitPlugSpecificDataPlugAddress* pUnitPlugAddress = 
    892         dynamic_cast<UnitPlugSpecificDataPlugAddress*> 
    893         ( plugAddress->m_plugAddressData ); 
    894  
    895     SubunitPlugSpecificDataPlugAddress* pSubunitPlugAddress = 
    896         dynamic_cast<SubunitPlugSpecificDataPlugAddress*> 
    897         ( plugAddress->m_plugAddressData ); 
    898  
    899     FunctionBlockPlugSpecificDataPlugAddress* 
    900         pFunctionBlockPlugAddress = 
    901         dynamic_cast<FunctionBlockPlugSpecificDataPlugAddress*> 
    902         ( plugAddress->m_plugAddressData ); 
    903  
    904     AvPlug* plug = getPlugDefinedBySpecificData( 
    905         pUnitPlugAddress, 
    906         pSubunitPlugAddress, 
    907         pFunctionBlockPlugAddress ); 
    908  
    909     if ( plug ) { 
    910         debugOutput( DEBUG_LEVEL_VERBOSE, 
    911                      "'(%d) %s' has a connection to '(%d) %s'\n", 
    912                      getGlobalId(), 
    913                      getName(), 
    914                      plug->getGlobalId(), 
    915                      plug->getName() ); 
    916         addPlugConnection( connections, *plug ); 
    917     } else { 
    918         debugError( "no corresponding plug found for '(%d) %s'\n", 
    919                     getGlobalId(), 
    920                     getName() ); 
    921         return false; 
    922     } 
    923  
    924     return true; 
    925 } 
    926  
    927 bool 
    928 AvPlug::addPlugConnection( AvPlugVector& connections, 
    929                            AvPlug& plug ) 
    930  
    931 { 
    932     for ( AvPlugVector::iterator it = connections.begin(); 
    933           it != connections.end(); 
    934           ++it ) 
    935     { 
    936         AvPlug* cPlug = *it; 
    937         if ( cPlug == &plug ) { 
    938             debugOutput( DEBUG_LEVEL_VERBOSE, 
    939                          "plug '%s' already in connection list\n", 
    940                          plug.getName() ); 
    941             return true; 
    942         } 
    943     } 
    944  
    945     connections.push_back( &plug ); 
    946     return true; 
    947 } 
    948  
    949586ExtendedPlugInfoCmd 
    950 AvPlug::setPlugAddrToPlugInfoCmd() 
    951 { 
    952     ExtendedPlugInfoCmd extPlugInfoCmd( *m_p1394Service ); 
    953  
    954     switch( m_subunitType ) { 
    955     case AVCCommand::eST_Unit: 
     587Plug::setPlugAddrToPlugInfoCmd() 
     588{ 
     589    ExtendedPlugInfoCmd extPlugInfoCmd( m_unit->get1394Service() ); 
     590 
     591    switch( getSubunitType() ) { 
     592    case eST_Unit: 
    956593        { 
    957594            UnitPlugAddress::EPlugType ePlugType = 
     
    978615        } 
    979616        break; 
    980     case AVCCommand::eST_Music: 
    981     case AVCCommand::eST_Audio: 
     617    case eST_Music: 
     618    case eST_Audio: 
    982619        { 
    983620            switch( m_addressType ) { 
     
    1014651    } 
    1015652 
    1016     extPlugInfoCmd.setNodeId( m_pConfigRom->getNodeId() ); 
     653    extPlugInfoCmd.setNodeId( m_unit->getConfigRom().getNodeId() ); 
    1017654    extPlugInfoCmd.setCommandType( AVCCommand::eCT_Status ); 
    1018     extPlugInfoCmd.setSubunitId( m_subunitId ); 
    1019     extPlugInfoCmd.setSubunitType( m_subunitType ); 
     655    extPlugInfoCmd.setSubunitId( getSubunitId() ); 
     656    extPlugInfoCmd.setSubunitType( getSubunitType() ); 
    1020657 
    1021658    return extPlugInfoCmd; 
    1022659} 
    1023660 
    1024 ExtendedStreamFormatCmd 
    1025 AvPlug::setPlugAddrToStreamFormatCmd( 
    1026     ExtendedStreamFormatCmd::ESubFunction subFunction) 
    1027 
    1028     ExtendedStreamFormatCmd extStreamFormatInfoCmd( 
    1029         *m_p1394Service, 
    1030         subFunction ); 
    1031     switch( m_subunitType ) { 
    1032     case AVCCommand::eST_Unit: 
    1033     { 
    1034             UnitPlugAddress::EPlugType ePlugType = 
    1035                 UnitPlugAddress::ePT_Unknown; 
    1036             switch ( m_addressType ) { 
    1037                 case eAPA_PCR: 
    1038                     ePlugType = UnitPlugAddress::ePT_PCR; 
    1039                     break; 
    1040                 case eAPA_ExternalPlug: 
    1041                     ePlugType = UnitPlugAddress::ePT_ExternalPlug; 
    1042                     break; 
    1043                 case eAPA_AsynchronousPlug: 
    1044                     ePlugType = UnitPlugAddress::ePT_AsynchronousPlug; 
    1045                     break; 
    1046                 default: 
    1047                     ePlugType = UnitPlugAddress::ePT_Unknown; 
    1048             } 
    1049         UnitPlugAddress unitPlugAddress( ePlugType, 
    1050                                          m_id ); 
    1051         extStreamFormatInfoCmd.setPlugAddress( 
    1052             PlugAddress( convertPlugDirection( getPlugDirection() ), 
    1053                          PlugAddress::ePAM_Unit, 
    1054                          unitPlugAddress ) ); 
    1055         } 
    1056         break; 
    1057     case AVCCommand::eST_Music: 
    1058     case AVCCommand::eST_Audio: 
    1059     { 
    1060         switch( m_addressType ) { 
    1061         case eAPA_SubunitPlug: 
    1062         { 
    1063             SubunitPlugAddress subunitPlugAddress( m_id ); 
    1064             extStreamFormatInfoCmd.setPlugAddress( 
    1065                 PlugAddress( convertPlugDirection( getPlugDirection() ), 
    1066                              PlugAddress::ePAM_Subunit, 
    1067                              subunitPlugAddress ) ); 
    1068         } 
    1069         break; 
    1070         case eAPA_FunctionBlockPlug: 
    1071         { 
    1072             FunctionBlockPlugAddress functionBlockPlugAddress( 
    1073                 m_functionBlockType, 
    1074                 m_functionBlockId, 
    1075                 m_id ); 
    1076             extStreamFormatInfoCmd.setPlugAddress( 
    1077                 PlugAddress( convertPlugDirection( getPlugDirection() ), 
    1078                              PlugAddress::ePAM_FunctionBlock, 
    1079                              functionBlockPlugAddress ) ); 
    1080         } 
    1081         break; 
    1082         default: 
    1083             extStreamFormatInfoCmd.setPlugAddress(PlugAddress()); 
    1084         } 
    1085     } 
    1086     break; 
    1087     default: 
    1088         debugError( "Unknown subunit type\n" ); 
    1089     } 
    1090  
    1091     extStreamFormatInfoCmd.setNodeId( m_pConfigRom->getNodeId() ); 
    1092     extStreamFormatInfoCmd.setCommandType( AVCCommand::eCT_Status ); 
    1093     extStreamFormatInfoCmd.setSubunitId( m_subunitId ); 
    1094     extStreamFormatInfoCmd.setSubunitType( m_subunitType ); 
    1095  
    1096     return extStreamFormatInfoCmd; 
    1097 
    1098  
    1099 SignalSourceCmd 
    1100 AvPlug::setSrcPlugAddrToSignalCmd() 
    1101 
    1102     SignalSourceCmd signalSourceCmd( *m_p1394Service ); 
    1103  
    1104     switch( m_subunitType ) { 
    1105     case AVCCommand::eST_Unit: 
    1106     { 
    1107         SignalUnitAddress signalUnitAddr; 
    1108         if ( getPlugAddressType() == eAPA_ExternalPlug ) { 
    1109             signalUnitAddr.m_plugId = m_id + 0x80; 
    1110         } else { 
    1111             signalUnitAddr.m_plugId = m_id; 
    1112         } 
    1113         signalSourceCmd.setSignalSource( signalUnitAddr ); 
    1114     } 
    1115     break; 
    1116     case AVCCommand::eST_Music: 
    1117     case AVCCommand::eST_Audio: 
    1118     { 
    1119         SignalSubunitAddress signalSubunitAddr; 
    1120         signalSubunitAddr.m_subunitType = m_subunitType; 
    1121         signalSubunitAddr.m_subunitId = m_subunitId; 
    1122         signalSubunitAddr.m_plugId = m_id; 
    1123         signalSourceCmd.setSignalSource( signalSubunitAddr ); 
    1124     } 
    1125     break; 
    1126     default: 
    1127         debugError( "Unknown subunit type\n" ); 
    1128     } 
    1129  
    1130     signalSourceCmd.setNodeId( m_pConfigRom->getNodeId() ); 
    1131     signalSourceCmd.setSubunitType( AVCCommand::eST_Unit  ); 
    1132     signalSourceCmd.setSubunitId( 0xff ); 
    1133  
    1134     return signalSourceCmd; 
    1135 
    1136  
    1137 void 
    1138 AvPlug::setDestPlugAddrToSignalCmd(SignalSourceCmd& signalSourceCmd, 
    1139                                    AvPlug& plug) 
    1140 
    1141     switch( plug.m_subunitType ) { 
    1142     case AVCCommand::eST_Unit: 
    1143     { 
    1144         SignalUnitAddress signalUnitAddr; 
    1145         if ( plug.getPlugAddressType() == eAPA_ExternalPlug ) { 
    1146             signalUnitAddr.m_plugId = plug.m_id + 0x80; 
    1147         } else { 
    1148             signalUnitAddr.m_plugId = plug.m_id; 
    1149         } 
    1150         signalSourceCmd.setSignalDestination( signalUnitAddr ); 
    1151     } 
    1152     break; 
    1153     case AVCCommand::eST_Music: 
    1154     case AVCCommand::eST_Audio: 
    1155     { 
    1156         SignalSubunitAddress signalSubunitAddr; 
    1157         signalSubunitAddr.m_subunitType = plug.m_subunitType; 
    1158         signalSubunitAddr.m_subunitId = plug.m_subunitId; 
    1159         signalSubunitAddr.m_plugId = plug.m_id; 
    1160         signalSourceCmd.setSignalDestination( signalSubunitAddr ); 
    1161     } 
    1162     break; 
    1163     default: 
    1164         debugError( "Unknown subunit type\n" ); 
    1165     } 
    1166 
    1167  
    1168  
    1169 bool 
    1170 AvPlug::copyClusterInfo(ExtendedPlugInfoPlugChannelPositionSpecificData& 
    1171                         channelPositionData ) 
    1172 
    1173     int index = 1; 
    1174     for ( ExtendedPlugInfoPlugChannelPositionSpecificData::ClusterInfoVector::const_iterator it 
    1175               = channelPositionData.m_clusterInfos.begin(); 
    1176           it != channelPositionData.m_clusterInfos.end(); 
    1177           ++it ) 
    1178     { 
    1179         const ExtendedPlugInfoPlugChannelPositionSpecificData::ClusterInfo* 
    1180             extPlugSpClusterInfo = &( *it ); 
    1181  
    1182         ClusterInfo clusterInfo; 
    1183         clusterInfo.m_nrOfChannels = extPlugSpClusterInfo->m_nrOfChannels; 
    1184         clusterInfo.m_index = index; 
    1185         index++; 
    1186  
    1187         for (  ExtendedPlugInfoPlugChannelPositionSpecificData::ChannelInfoVector::const_iterator cit 
    1188                   = extPlugSpClusterInfo->m_channelInfos.begin(); 
    1189               cit != extPlugSpClusterInfo->m_channelInfos.end(); 
    1190               ++cit ) 
    1191         { 
    1192             const ExtendedPlugInfoPlugChannelPositionSpecificData::ChannelInfo* 
    1193                 extPlugSpChannelInfo = &( *cit ); 
    1194  
    1195             ChannelInfo channelInfo; 
    1196             channelInfo.m_streamPosition = 
    1197                 extPlugSpChannelInfo->m_streamPosition; 
    1198             channelInfo.m_location = 
    1199                 extPlugSpChannelInfo->m_location; 
    1200  
    1201             clusterInfo.m_channelInfos.push_back( channelInfo ); 
    1202         } 
    1203         m_clusterInfos.push_back( clusterInfo ); 
    1204     } 
    1205  
    1206     return true; 
    1207 
    1208  
    1209 void 
    1210 AvPlug::debugOutputClusterInfos( int debugLevel ) 
    1211 
    1212     for ( ClusterInfoVector::const_iterator it = m_clusterInfos.begin(); 
    1213           it != m_clusterInfos.end(); 
    1214           ++it ) 
    1215     { 
    1216         const ClusterInfo* clusterInfo = &( *it ); 
    1217  
    1218         debugOutput( debugLevel, "number of channels: %d\n", 
    1219                      clusterInfo->m_nrOfChannels ); 
    1220  
    1221         for ( ChannelInfoVector::const_iterator cit 
    1222                   = clusterInfo->m_channelInfos.begin(); 
    1223               cit != clusterInfo->m_channelInfos.end(); 
    1224               ++cit ) 
    1225         { 
    1226             const ChannelInfo* channelInfo = &( *cit ); 
    1227             channelInfo = channelInfo; 
    1228             debugOutput( debugLevel, 
    1229                          "stream position: %d\n", 
    1230                          channelInfo->m_streamPosition ); 
    1231             debugOutput( debugLevel, 
    1232                          "location: %d\n", 
    1233                          channelInfo->m_location ); 
    1234         } 
    1235     } 
    1236 
    1237  
    1238 const AvPlug::ClusterInfo* 
    1239 AvPlug::getClusterInfoByIndex(int index) const 
    1240 
    1241     for ( AvPlug::ClusterInfoVector::const_iterator clit = 
    1242               m_clusterInfos.begin(); 
    1243           clit != m_clusterInfos.end(); 
    1244           ++clit ) 
    1245     { 
    1246         const ClusterInfo* info = &*clit; 
    1247         if ( info->m_index == index ) { 
    1248             return info; 
    1249         } 
    1250     } 
    1251     return 0; 
    1252 
    1253  
    1254 PlugAddress::EPlugDirection 
    1255 AvPlug::convertPlugDirection( EAvPlugDirection direction ) 
    1256 
    1257     PlugAddress::EPlugDirection dir; 
    1258     switch ( direction ) { 
    1259     case AvPlug::eAPD_Input: 
    1260         dir = PlugAddress::ePD_Input; 
    1261         break; 
    1262     case AvPlug::eAPD_Output: 
    1263         dir = PlugAddress::ePD_Output; 
    1264         break; 
    1265     default: 
    1266         dir = PlugAddress::ePD_Undefined; 
    1267     } 
    1268     return dir; 
    1269 
    1270  
    1271 void 
    1272 AvPlug::showPlug() const 
    1273 
    1274     debugOutput( DEBUG_LEVEL_VERBOSE, "\tName               = %s\n", 
    1275                  getName() ); 
    1276     debugOutput( DEBUG_LEVEL_VERBOSE, "\tType               = %s\n", 
    1277                  extendedPlugInfoPlugTypeToString( getPlugType() ) ); 
    1278     debugOutput( DEBUG_LEVEL_VERBOSE, "\tAddress Type       = %s\n", 
    1279                  avPlugAddressTypeToString( getPlugAddressType() ) ); 
    1280     debugOutput( DEBUG_LEVEL_VERBOSE, "\tId                 = %d\n", 
    1281                  getPlugId() ); 
    1282     debugOutput( DEBUG_LEVEL_VERBOSE, "\tSubunitType        = %d\n", 
    1283                  getSubunitType() ); 
    1284     debugOutput( DEBUG_LEVEL_VERBOSE, "\tSubunitId          = %d\n", 
    1285                  getSubunitId() ); 
    1286     debugOutput( DEBUG_LEVEL_VERBOSE, "\tDirection          = %s\n", 
    1287                  avPlugDirectionToString( getPlugDirection() ) ); 
    1288     debugOutput( DEBUG_LEVEL_VERBOSE, "\tSampling Rate      = %d\n", 
    1289                  getSampleRate() ); 
    1290     debugOutput( DEBUG_LEVEL_VERBOSE, "\tNumber of Channels = %d\n", 
    1291                  getNrOfChannels() ); 
    1292     debugOutput( DEBUG_LEVEL_VERBOSE, "\tNumber of Streams  = %d\n", 
    1293                  getNrOfStreams() ); 
    1294 
    1295  
    1296  
    1297 AvPlug* 
    1298 AvPlug::getPlugDefinedBySpecificData( 
    1299     UnitPlugSpecificDataPlugAddress* pUnitPlugAddress, 
    1300     SubunitPlugSpecificDataPlugAddress* pSubunitPlugAddress, 
    1301     FunctionBlockPlugSpecificDataPlugAddress* pFunctionBlockPlugAddress ) 
    1302 
    1303     subunit_type_t        subunitType       = 0xff; 
    1304     subunit_id_t          subunitId         = 0xff; 
    1305     function_block_type_t functionBlockType = 0xff; 
    1306     function_block_id_t   functionBlockId   = 0xff; 
    1307     EAvPlugAddressType    addressType       = eAPA_Undefined; 
    1308     EAvPlugDirection      direction         = eAPD_Unknown; 
    1309     plug_id_t             plugId            = 0xff; 
    1310  
    1311     if ( !pUnitPlugAddress 
    1312          && !pSubunitPlugAddress 
    1313          && !pFunctionBlockPlugAddress ) 
    1314     { 
    1315         debugError( "No correct specific data found\n" ); 
    1316         return 0; 
    1317     } 
    1318  
    1319     if ( pUnitPlugAddress ) { 
    1320         subunitType = AVCCommand::eST_Unit; 
    1321         switch ( pUnitPlugAddress->m_plugType ) { 
    1322         case UnitPlugSpecificDataPlugAddress::ePT_PCR: 
    1323             addressType = eAPA_PCR; 
    1324             break; 
    1325         case UnitPlugSpecificDataPlugAddress::ePT_ExternalPlug: 
    1326             addressType = eAPA_ExternalPlug; 
    1327             break; 
    1328         case UnitPlugSpecificDataPlugAddress::ePT_AsynchronousPlug: 
    1329             addressType = eAPA_AsynchronousPlug; 
    1330             break; 
    1331         } 
    1332         // unit plug have only connections to subunits 
    1333         if ( getPlugAddressType() == eAPA_SubunitPlug ) { 
    1334             direction = getDirection(); 
    1335         } else { 
    1336             debugError( "Function block has connection from/to unknown " 
    1337                         "plug type\n" ); 
    1338             direction = eAPD_Unknown; 
    1339         } 
    1340         plugId = pUnitPlugAddress->m_plugId; 
    1341  
    1342         debugOutput( DEBUG_LEVEL_VERBOSE, 
    1343                      "'(%d) %s': Remote plug is a unit plug " 
    1344                      "(%s, %s, %d)\n", 
    1345                      getGlobalId(), 
    1346                      getName(), 
    1347                      avPlugAddressTypeToString( addressType ), 
    1348                      avPlugDirectionToString( direction ), 
    1349                      plugId ); 
    1350     } 
    1351  
    1352     if ( pSubunitPlugAddress ) { 
    1353         subunitType = pSubunitPlugAddress->m_subunitType; 
    1354         subunitId = pSubunitPlugAddress->m_subunitId; 
    1355         addressType = eAPA_SubunitPlug; 
    1356  
    1357         if ( getPlugAddressType() == eAPA_FunctionBlockPlug ) { 
    1358             direction = getDirection(); 
    1359         } else if ( getPlugAddressType() == eAPA_SubunitPlug ) { 
    1360             direction = toggleDirection( getDirection() ); 
    1361         } else { 
    1362             // unit 
    1363             direction = getDirection(); 
    1364         } 
    1365  
    1366         plugId = pSubunitPlugAddress->m_plugId; 
    1367         debugOutput( DEBUG_LEVEL_VERBOSE, 
    1368                      "'(%d) %s': Remote plug is a subunit plug " 
    1369                      "(%d, %d, %s, %d)\n", 
    1370                      getGlobalId(), 
    1371                      getName(), 
    1372                      subunitType, 
    1373                      subunitId, 
    1374                      avPlugDirectionToString( direction ), 
    1375                      plugId ); 
    1376     } 
    1377  
    1378     if ( pFunctionBlockPlugAddress ) { 
    1379         subunitType = pFunctionBlockPlugAddress->m_subunitType; 
    1380         subunitId = pFunctionBlockPlugAddress->m_subunitId; 
    1381         functionBlockType = pFunctionBlockPlugAddress->m_functionBlockType; 
    1382         functionBlockId = pFunctionBlockPlugAddress->m_functionBlockId; 
    1383         addressType = eAPA_FunctionBlockPlug; 
    1384  
    1385         if ( getPlugAddressType() == eAPA_FunctionBlockPlug ) { 
    1386             direction = toggleDirection( getDirection() ); 
    1387         } else if ( getPlugAddressType() == eAPA_SubunitPlug ){ 
    1388             direction = getDirection(); 
    1389         } else { 
    1390             debugError( "Function block has connection from/to unknown " 
    1391                         "plug type\n" ); 
    1392             direction = eAPD_Unknown; 
    1393         } 
    1394  
    1395         plugId = pFunctionBlockPlugAddress->m_plugId; 
    1396  
    1397         debugOutput( DEBUG_LEVEL_VERBOSE, 
    1398                      "'(%d) %s': Remote plug is a functionblock plug " 
    1399                      "(%d, %d, %d, %d, %s, %d)\n", 
    1400                      getGlobalId(), 
    1401                      getName(), 
    1402                      subunitType, 
    1403                      subunitId, 
    1404                      functionBlockType, 
    1405                      functionBlockId, 
    1406                      avPlugDirectionToString( direction ), 
    1407                      plugId ); 
    1408     } 
    1409  
    1410     AVCCommand::ESubunitType enumSubunitType = 
    1411         static_cast<AVCCommand::ESubunitType>( subunitType ); 
    1412  
    1413     return m_plugManager->getPlug( 
    1414         enumSubunitType, 
    1415         subunitId, 
    1416         functionBlockType, 
    1417         functionBlockId, 
    1418         addressType, 
    1419         direction, 
    1420         plugId ); 
    1421 
    1422  
    1423 AvPlug::EAvPlugDirection 
    1424 AvPlug::toggleDirection( EAvPlugDirection direction ) const 
    1425 
    1426     EAvPlugDirection newDirection; 
    1427     switch ( direction ) { 
    1428     case eAPD_Output: 
    1429         newDirection = eAPD_Input; 
    1430         break; 
    1431     case eAPD_Input: 
    1432         newDirection = eAPD_Output; 
    1433         break; 
    1434     default: 
    1435         newDirection = direction; 
    1436     } 
    1437  
    1438     return newDirection; 
    1439 
    1440  
    1441 bool 
    1442 AvPlug::serializeChannelInfos( Glib::ustring basePath, 
    1443                                Util::IOSerialize& ser, 
    1444                                const ClusterInfo& clusterInfo ) const 
    1445 
    1446     bool result = true; 
    1447     int i = 0; 
    1448     for ( ChannelInfoVector::const_iterator it = clusterInfo.m_channelInfos.begin(); 
    1449           it != clusterInfo.m_channelInfos.end(); 
    1450           ++it ) 
    1451     { 
    1452         const ChannelInfo& info = *it; 
    1453         std::ostringstream strstrm; 
    1454         strstrm << basePath << i; 
    1455  
    1456         result &= ser.write( strstrm.str() + "/m_streamPosition", info.m_streamPosition ); 
    1457         result &= ser.write( strstrm.str() + "/m_location", info.m_location ); 
    1458         result &= ser.write( strstrm.str() + "/m_name", info.m_name ); 
    1459     } 
    1460  
    1461     return result; 
    1462 
    1463  
    1464 bool 
    1465 AvPlug::deserializeChannelInfos( Glib::ustring basePath, 
    1466                                  Util::IODeserialize& deser, 
    1467                                  ClusterInfo& clusterInfo ) 
    1468 
    1469     int i = 0; 
    1470     bool bFinished = false; 
    1471     bool result = true; 
    1472     do { 
    1473         std::ostringstream strstrm; 
    1474         strstrm << basePath << i; 
    1475  
    1476         // check for one element to exist. when one exist the other elements 
    1477         // must also be there. otherwise just return (last) result. 
    1478         if ( deser.isExisting( strstrm.str() + "/m_streamPosition" ) ) { 
    1479             ChannelInfo info; 
    1480  
    1481             result &= deser.read( strstrm.str() + "/m_streamPosition", info.m_streamPosition ); 
    1482             result &= deser.read( strstrm.str() + "/m_location", info.m_location ); 
    1483             result &= deser.read( strstrm.str() + "/m_name", info.m_name ); 
    1484  
    1485             if ( result ) { 
    1486                 clusterInfo.m_channelInfos.push_back( info ); 
    1487                 i++; 
    1488             } else { 
    1489                 bFinished = true; 
    1490             } 
    1491         } else { 
    1492             bFinished = true; 
    1493         } 
    1494     } while ( !bFinished ); 
    1495  
    1496     return result; 
    1497 
    1498  
    1499  
    1500 bool 
    1501 AvPlug::serializeClusterInfos( Glib::ustring basePath, 
    1502                                Util::IOSerialize& ser ) const 
    1503 
    1504     bool result = true; 
    1505     int i = 0; 
    1506     for ( ClusterInfoVector::const_iterator it = m_clusterInfos.begin(); 
    1507           it != m_clusterInfos.end(); 
    1508           ++it ) 
    1509     { 
    1510         const ClusterInfo& info = *it; 
    1511         std::ostringstream strstrm; 
    1512         strstrm << basePath << i; 
    1513  
    1514         result &= ser.write( strstrm.str() + "/m_index", info.m_index ); 
    1515         result &= ser.write( strstrm.str() + "/m_portType", info.m_portType ); 
    1516         result &= ser.write( strstrm.str() + "/m_name", info.m_name ); 
    1517         result &= ser.write( strstrm.str() + "/m_nrOfChannels", info.m_nrOfChannels ); 
    1518         result &= serializeChannelInfos( strstrm.str() + "/m_channelInfo", ser, info ); 
    1519         result &= ser.write( strstrm.str() + "/m_streamFormat", info.m_streamFormat ); 
    1520  
    1521     } 
    1522  
    1523     return result; 
    1524 
    1525  
    1526 bool 
    1527 AvPlug::deserializeClusterInfos( Glib::ustring basePath, 
    1528                                  Util::IODeserialize& deser ) 
    1529 
    1530     int i = 0; 
    1531     bool bFinished = false; 
    1532     bool result = true; 
    1533     do { 
    1534         std::ostringstream strstrm; 
    1535         strstrm << basePath << i; 
    1536  
    1537         // check for one element to exist. when one exist the other elements 
    1538         // must also be there. otherwise just return (last) result. 
    1539         if ( deser.isExisting( strstrm.str() + "/m_index" ) ) { 
    1540             ClusterInfo info; 
    1541  
    1542             result &= deser.read( strstrm.str() + "/m_index", info.m_index ); 
    1543             result &= deser.read( strstrm.str() + "/m_portType", info.m_portType ); 
    1544             result &= deser.read( strstrm.str() + "/m_name", info.m_name ); 
    1545             result &= deser.read( strstrm.str() + "/m_nrOfChannels", info.m_nrOfChannels ); 
    1546             result &= deserializeChannelInfos( strstrm.str() + "/m_channelInfo", deser, info ); 
    1547             result &= deser.read( strstrm.str() + "/m_streamFormat", info.m_streamFormat ); 
    1548  
    1549             if ( result ) { 
    1550                 m_clusterInfos.push_back( info ); 
    1551                 i++; 
    1552             } else { 
    1553                 bFinished = true; 
    1554             } 
    1555         } else { 
    1556             bFinished = true; 
    1557         } 
    1558     } while ( !bFinished ); 
    1559  
    1560     return result; 
    1561 
    1562  
    1563  
    1564 bool 
    1565 AvPlug::serializeFormatInfos( Glib::ustring basePath, 
    1566                               Util::IOSerialize& ser ) const 
    1567 
    1568     bool result = true; 
    1569     int i = 0; 
    1570     for ( FormatInfoVector::const_iterator it = m_formatInfos.begin(); 
    1571           it != m_formatInfos.end(); 
    1572           ++it ) 
    1573     { 
    1574         const FormatInfo& info = *it; 
    1575         std::ostringstream strstrm; 
    1576         strstrm << basePath << i; 
    1577  
    1578         result &= ser.write( strstrm.str() + "/m_samplingFrequency", info.m_samplingFrequency ); 
    1579         result &= ser.write( strstrm.str() + "/m_isSyncStream", info.m_isSyncStream ); 
    1580         result &= ser.write( strstrm.str() + "/m_audioChannels", info.m_audioChannels ); 
    1581         result &= ser.write( strstrm.str() + "/m_midiChannels", info.m_midiChannels ); 
    1582         result &= ser.write( strstrm.str() + "/m_index", info.m_index ); 
    1583     } 
    1584     return result; 
    1585 
    1586  
    1587 bool 
    1588 AvPlug::deserializeFormatInfos( Glib::ustring basePath, 
    1589                                 Util::IODeserialize& deser ) 
    1590 
    1591     int i = 0; 
    1592     bool bFinished = false; 
    1593     bool result = true; 
    1594     do { 
    1595         std::ostringstream strstrm; 
    1596         strstrm << basePath << i; 
    1597  
    1598         // check for one element to exist. when one exist the other elements 
    1599         // must also be there. otherwise just return (last) result. 
    1600         if ( deser.isExisting( strstrm.str() + "/m_samplingFrequency" ) ) { 
    1601             FormatInfo info; 
    1602  
    1603             result &= deser.read( strstrm.str() + "/m_samplingFrequency", info.m_samplingFrequency ); 
    1604             result &= deser.read( strstrm.str() + "/m_isSyncStream", info.m_isSyncStream ); 
    1605             result &= deser.read( strstrm.str() + "/m_audioChannels", info.m_audioChannels ); 
    1606             result &= deser.read( strstrm.str() + "/m_midiChannels", info.m_midiChannels ); 
    1607             result &= deser.read( strstrm.str() + "/m_index", info.m_index ); 
    1608  
    1609             if ( result ) { 
    1610                 m_formatInfos.push_back( info ); 
    1611                 i++; 
    1612             } else { 
    1613                 bFinished = true; 
    1614             } 
    1615         } else { 
    1616             bFinished = true; 
    1617         } 
    1618     } while ( !bFinished ); 
    1619  
    1620     return result; 
    1621 
    1622  
    1623  
    1624 bool 
    1625 AvPlug::serializeAvPlugVector( Glib::ustring basePath, 
    1626                                Util::IOSerialize& ser, 
    1627                                const AvPlugVector& vec) const 
    1628 
    1629     bool result = true; 
    1630     int i = 0; 
    1631     for ( AvPlugVector::const_iterator it = vec.begin(); 
    1632           it != vec.end(); 
    1633           ++it ) 
    1634     { 
    1635         const AvPlug* pPlug = *it; 
    1636         std::ostringstream strstrm; 
    1637         strstrm << basePath << i; 
    1638  
    1639         result &= ser.write( strstrm.str() + "/global_id", pPlug->getGlobalId() ); 
    1640         i++; 
    1641     } 
    1642     return result; 
    1643 
    1644  
    1645 bool 
    1646 AvPlug::deserializeAvPlugVector( Glib::ustring basePath, 
    1647                                  Util::IODeserialize& deser, 
    1648                                  AvPlugVector& vec ) 
    1649 
    1650     int i = 0; 
    1651     bool bFinished = false; 
    1652     bool result = true; 
    1653     do { 
    1654         std::ostringstream strstrm; 
    1655         strstrm << basePath << i; 
    1656  
    1657         // check for one element to exist. when one exist the other elements 
    1658         // must also be there. otherwise just return (last) result. 
    1659         if ( deser.isExisting( strstrm.str() + "/global_id" ) ) { 
    1660             unsigned int iPlugId; 
    1661             result &= deser.read( strstrm.str() + "/global_id", iPlugId ); 
    1662  
    1663             if ( result ) { 
    1664                 AvPlug* pPlug = m_plugManager->getPlug( iPlugId ); 
    1665                 if ( pPlug ) { 
    1666                     vec.push_back( pPlug ); 
    1667                 } else { 
    1668                     result = false; 
    1669                     bFinished = true; 
    1670                 } 
    1671                 i++; 
    1672             } else { 
    1673                 bFinished = true; 
    1674             } 
    1675         } else { 
    1676             bFinished = true; 
    1677         } 
    1678     } while ( !bFinished ); 
    1679  
    1680     return result; 
    1681 
    1682  
    1683 bool 
    1684 AvPlug::serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const 
    1685 
    1686     bool result; 
    1687     result  = ser.write( basePath + "m_subunitType", m_subunitType ); 
    1688     result &= ser.write( basePath + "m_subunitId", m_subunitId ); 
    1689     result &= ser.write( basePath + "m_functionBlockType", m_functionBlockType); 
    1690     result &= ser.write( basePath + "m_functionBlockId", m_functionBlockId); 
    1691     result &= ser.write( basePath + "m_addressType", m_addressType ); 
    1692     result &= ser.write( basePath + "m_direction", m_direction); 
    1693     result &= ser.write( basePath + "m_id", m_id); 
    1694     result &= ser.write( basePath + "m_infoPlugType", m_infoPlugType); 
    1695     result &= ser.write( basePath + "m_nrOfChannels", m_nrOfChannels); 
    1696     result &= ser.write( basePath + "m_name", m_name); 
    1697     result &= serializeClusterInfos( basePath + "m_clusterInfos", ser ); 
    1698     result &= ser.write( basePath + "m_samplingFrequency", m_samplingFrequency); 
    1699     result &= serializeFormatInfos( basePath + "m_formatInfo", ser ); 
    1700     result &= serializeAvPlugVector( basePath + "m_inputConnections", ser, m_inputConnections ); 
    1701     result &= serializeAvPlugVector( basePath + "m_outputConnections", ser, m_outputConnections ); 
    1702     result &= ser.write( basePath + "m_verboseLevel", m_verboseLevel); 
    1703     result &= ser.write( basePath + "m_globalId", m_globalId); 
    1704     result &= ser.write( basePath + "m_globalIdCounter", m_globalIdCounter ); 
    1705  
    1706     return result; 
    1707 
    1708  
    1709 AvPlug* 
    1710 AvPlug::deserialize( Glib::ustring basePath, 
    1711                      Util::IODeserialize& deser, 
    1712                      AvDevice& avDevice, 
    1713                      AvPlugManager& plugManager ) 
    1714 
    1715     if ( !deser.isExisting( basePath + "m_subunitType" ) ) { 
    1716         return 0; 
    1717     } 
    1718  
    1719     AvPlug* pPlug = new AvPlug; 
    1720     if ( !pPlug ) { 
    1721         return 0; 
    1722     } 
    1723  
    1724     pPlug->m_p1394Service = &avDevice.get1394Service(); 
    1725     pPlug->m_pConfigRom   = &avDevice.getConfigRom(); 
    1726     pPlug->m_plugManager  = &plugManager; 
    1727     bool result; 
    1728     result  = deser.read( basePath + "m_subunitType", pPlug->m_subunitType ); 
    1729     result &= deser.read( basePath + "m_subunitId", pPlug->m_subunitId ); 
    1730     result &= deser.read( basePath + "m_functionBlockType", pPlug->m_functionBlockType ); 
    1731     result &= deser.read( basePath + "m_functionBlockId", pPlug->m_functionBlockId ); 
    1732     result &= deser.read( basePath + "m_addressType", pPlug->m_addressType ); 
    1733     result &= deser.read( basePath + "m_direction", pPlug->m_direction ); 
    1734     result &= deser.read( basePath + "m_id", pPlug->m_id ); 
    1735     result &= deser.read( basePath + "m_infoPlugType", pPlug->m_infoPlugType ); 
    1736     result &= deser.read( basePath + "m_nrOfChannels", pPlug->m_nrOfChannels ); 
    1737     result &= deser.read( basePath + "m_name", pPlug->m_name ); 
    1738     result &= pPlug->deserializeClusterInfos( basePath + "m_clusterInfos", deser ); 
    1739     result &= deser.read( basePath + "m_samplingFrequency", pPlug->m_samplingFrequency ); 
    1740     result &= pPlug->deserializeFormatInfos( basePath + "m_formatInfos", deser ); 
    1741     // input and output connections can't be processed here because not all plugs might 
    1742     // deserialized at this point. so we do that in deserializeUpdate. 
    1743     result &= deser.read( basePath + "m_verboseLevel", pPlug->m_verboseLevel ); 
    1744     result &= deser.read( basePath + "m_globalId", pPlug->m_globalId ); 
    1745     result &= deser.read( basePath + "m_globalIdCounter", pPlug->m_globalIdCounter ); 
    1746  
    1747     if ( !result ) { 
    1748         delete pPlug; 
    1749         return 0; 
    1750     } 
    1751  
    1752     return pPlug; 
    1753 
    1754  
    1755 bool 
    1756 AvPlug::deserializeUpdate( Glib::ustring basePath, 
    1757                            Util::IODeserialize& deser ) 
    1758 
    1759     bool result; 
    1760  
    1761     result  = deserializeAvPlugVector( basePath + "m_inputConnections", deser, m_inputConnections ); 
    1762     result &= deserializeAvPlugVector( basePath + "m_outputConnections", deser, m_outputConnections ); 
    1763  
    1764     return result; 
    1765 
    1766  
    1767 ///////////////////////////////////////// 
    1768 ///////////////////////////////////////// 
    1769  
    1770 const char* avPlugAddressTypeStrings[] = 
    1771 
    1772     "PCR", 
    1773     "external", 
    1774     "asynchronous", 
    1775     "subunit", 
    1776     "functionblock", 
    1777     "undefined", 
    1778 }; 
    1779  
    1780 const char* avPlugAddressTypeToString( AvPlug::EAvPlugAddressType type ) 
    1781 
    1782     if ( type > ( int )( sizeof( avPlugAddressTypeStrings ) 
    1783                          / sizeof( avPlugAddressTypeStrings[0] ) ) ) 
    1784     { 
    1785         type = AvPlug::eAPA_Undefined; 
    1786     } 
    1787     return avPlugAddressTypeStrings[type]; 
    1788 
    1789  
    1790 const char* avPlugTypeStrings[] = 
    1791 
    1792     "IsoStream", 
    1793     "AsyncStream", 
    1794     "MIDI", 
    1795     "Sync", 
    1796     "Analog", 
    1797     "Digital", 
    1798     "Unknown", 
    1799 }; 
    1800  
    1801 const char* avPlugTypeToString( AvPlug::EAvPlugType type ) 
    1802 
    1803     if ( type > ( int )( sizeof( avPlugTypeStrings ) 
    1804                          / sizeof( avPlugTypeStrings[0] ) ) ) 
    1805     { 
    1806         type = AvPlug::eAPT_Unknown; 
    1807     } 
    1808     return avPlugTypeStrings[type]; 
    1809 
    1810  
    1811 const char* avPlugDirectionStrings[] = 
    1812 
    1813     "Input", 
    1814     "Output", 
    1815     "Unknown", 
    1816 }; 
    1817  
    1818 const char* avPlugDirectionToString( AvPlug::EAvPlugDirection type ) 
    1819 
    1820     if ( type > ( int )( sizeof( avPlugDirectionStrings ) 
    1821                          / sizeof( avPlugDirectionStrings[0] ) ) ) 
    1822     { 
    1823         type = AvPlug::eAPD_Unknown; 
    1824     } 
    1825     return avPlugDirectionStrings[type]; 
    1826 
    1827  
    1828 ///////////////////////////////////// 
    1829  
    1830  
    1831 AvPlugManager::AvPlugManager( int verboseLevel ) 
    1832     : m_verboseLevel( verboseLevel ) 
    1833 
    1834     setDebugLevel( m_verboseLevel ); 
    1835 
    1836  
    1837 AvPlugManager::AvPlugManager() 
    1838     : m_verboseLevel( 0 ) 
    1839 
    1840     setDebugLevel( 0 ); 
    1841 
    1842  
    1843 AvPlugManager::AvPlugManager( const AvPlugManager& rhs ) 
    1844     : m_verboseLevel( rhs.m_verboseLevel ) 
    1845 
    1846     setDebugLevel( m_verboseLevel ); 
    1847 
    1848  
    1849 AvPlugManager::~AvPlugManager() 
    1850 
    1851 
    1852  
    1853 bool 
    1854 AvPlugManager::addPlug( AvPlug& plug ) 
    1855 
    1856     m_plugs.push_back( &plug ); 
    1857     return true; 
    1858 
    1859  
    1860 bool 
    1861 AvPlugManager::remPlug( AvPlug& plug ) 
    1862 
    1863     for ( AvPlugVector::iterator it = m_plugs.begin(); 
    1864           it !=  m_plugs.end(); 
    1865           ++it ) 
    1866     { 
    1867         AvPlug* plugIt = *it; 
    1868         if ( plugIt == &plug ) { 
    1869             m_plugs.erase( it ); 
    1870             return true; 
    1871         } 
    1872     } 
    1873     return false; 
    1874 
    1875  
    1876 // helper function 
    1877 static void addConnection( AvPlugConnectionOwnerVector& connections, 
    1878                            AvPlug& srcPlug, 
    1879                            AvPlug& destPlug ) 
    1880 
    1881     for ( AvPlugConnectionOwnerVector::iterator it = connections.begin(); 
    1882           it != connections.end(); 
    1883           ++it ) 
    1884     { 
    1885         AvPlugConnection& con = *it; 
    1886         if ( ( &( con.getSrcPlug() ) == &srcPlug ) 
    1887              && ( &( con.getDestPlug() ) == &destPlug ) ) 
    1888         { 
    1889             return; 
    1890         } 
    1891     } 
    1892     connections.push_back( AvPlugConnection( srcPlug, destPlug ) ); 
    1893 
    1894  
    1895 void 
    1896 AvPlugManager::showPlugs() const 
    1897 
    1898     // \todo The information provided here could be better arranged. For a start it is ok, but 
    1899     // there is room for improvement. Something for a lazy sunday afternoon (tip: maybe drink some 
    1900     // beer to get into the mood) 
    1901  
    1902     printf( "\nSummary\n" ); 
    1903     printf( "-------\n\n" ); 
    1904     printf( "Nr | AddressType     | Direction | SubUnitType | SubUnitId | FunctionBlockType | FunctionBlockId | Id   | Type         |Name\n" ); 
    1905     printf( "---+-----------------+-----------+-------------+-----------+-------------------+-----------------+------+--------------+------\n" ); 
    1906  
    1907     for ( AvPlugVector::const_iterator it = m_plugs.begin(); 
    1908           it !=  m_plugs.end(); 
    1909           ++it ) 
    1910     { 
    1911         AvPlug* plug = *it; 
    1912  
    1913         printf( "%2d | %15s | %9s | %11s |      0x%02x |              0x%02x |            0x%02x | 0x%02x | %12s | %s\n", 
    1914                 plug->getGlobalId(), 
    1915                 avPlugAddressTypeToString( plug->getPlugAddressType() ), 
    1916                 avPlugDirectionToString( plug->getDirection() ), 
    1917                 subunitTypeToString( plug->getSubunitType() ), 
    1918                 plug->getSubunitId(), 
    1919                 plug->getFunctionBlockType(), 
    1920                 plug->getFunctionBlockId(), 
    1921                 plug->getPlugId(), 
    1922                 avPlugTypeToString( plug->getPlugType() ), 
    1923                 plug->getName() ); 
    1924     } 
    1925  
    1926     printf( "\nConnections\n" ); 
    1927     printf( "-----------\n" ); 
    1928  
    1929     AvPlugConnectionOwnerVector connections; 
    1930  
    1931     for ( AvPlugVector::const_iterator it = m_plugs.begin(); 
    1932           it !=  m_plugs.end(); 
    1933           ++it ) 
    1934     { 
    1935         AvPlug* plug = *it; 
    1936         for ( AvPlugVector::const_iterator it = 
    1937                   plug->getInputConnections().begin(); 
    1938             it != plug->getInputConnections().end(); 
    1939             ++it ) 
    1940         { 
    1941             addConnection( connections, *( *it ), *plug ); 
    1942         } 
    1943         for ( AvPlugVector::const_iterator it = 
    1944                   plug->getOutputConnections().begin(); 
    1945             it != plug->getOutputConnections().end(); 
    1946             ++it ) 
    1947         { 
    1948             addConnection( connections, *plug, *( *it ) ); 
    1949         } 
    1950     } 
    1951  
    1952     printf( "digraph avcconnections {\n" ); 
    1953     for ( AvPlugConnectionOwnerVector::iterator it = connections.begin(); 
    1954           it != connections.end(); 
    1955           ++it ) 
    1956     { 
    1957         AvPlugConnection& con = *it; 
    1958         printf( "\t\"(%d) %s\" -> \"(%d) %s\"\n", 
    1959                 con.getSrcPlug().getGlobalId(), 
    1960                 con.getSrcPlug().getName(), 
    1961                 con.getDestPlug().getGlobalId(), 
    1962                 con.getDestPlug().getName() ); 
    1963     } 
    1964     for ( AvPlugVector::const_iterator it = m_plugs.begin(); 
    1965           it != m_plugs.end(); 
    1966           ++it ) 
    1967     { 
    1968         AvPlug* plug = *it; 
    1969         if ( plug->getFunctionBlockType() != 0xff ) { 
    1970             std::ostringstream strstrm; 
    1971             switch(plug->getFunctionBlockType()) { 
    1972                 case 0x80: 
    1973                     strstrm << "Selector FB"; 
    1974                     break; 
    1975                 case 0x81: 
    1976                     strstrm << "Feature FB"; 
    1977                     break; 
    1978                 case 0x82: 
    1979                     strstrm << "Processing FB"; 
    1980                     break; 
    1981                 case 0x83: 
    1982                     strstrm << "CODEC FB"; 
    1983                     break; 
    1984                 default: 
    1985                     strstrm << plug->getFunctionBlockType(); 
    1986             } 
    1987  
    1988             if ( plug->getPlugDirection() == AvPlug::eAPD_Input ) { 
    1989                 printf( "\t\"(%d) %s\" -> \"(%s, ID %d)\"\n", 
    1990                         plug->getGlobalId(), 
    1991                         plug->getName(), 
    1992                         strstrm.str().c_str(), 
    1993                         plug->getFunctionBlockId() ); 
    1994             } else { 
    1995                 printf( "\t\"(%s, ID %d)\" -> \t\"(%d) %s\"\n", 
    1996                         strstrm.str().c_str(), 
    1997                         plug->getFunctionBlockId(), 
    1998                         plug->getGlobalId(), 
    1999                         plug->getName() ); 
    2000             } 
    2001         } 
    2002     } 
    2003  
    2004     const char* colorStrings[] = { 
    2005         "coral", 
    2006         "slateblue", 
    2007         "white", 
    2008         "green", 
    2009         "yellow", 
    2010         "grey", 
    2011     }; 
    2012  
    2013     for ( AvPlugVector::const_iterator it = m_plugs.begin(); 
    2014           it !=  m_plugs.end(); 
    2015           ++it ) 
    2016     { 
    2017         AvPlug* plug = *it; 
    2018         printf( "\t\"(%d) %s\" [color=%s,style=filled];\n", 
    2019                 plug->getGlobalId(), plug->getName(), 
    2020                 colorStrings[plug->getPlugAddressType() ] ); 
    2021     } 
    2022  
    2023     printf("}\n" ); 
    2024     printf( "Use \"dot -Tps FILENAME.dot -o FILENAME.ps\" " 
    2025             "to generate graph\n"); 
    2026  
    2027     debugOutput( DEBUG_LEVEL_VERBOSE, "Plug details\n" ); 
    2028     debugOutput( DEBUG_LEVEL_VERBOSE, "------------\n" ); 
    2029     for ( AvPlugVector::const_iterator it = m_plugs.begin(); 
    2030           it !=  m_plugs.end(); 
    2031           ++it ) 
    2032     { 
    2033         AvPlug* plug = *it; 
    2034         debugOutput( DEBUG_LEVEL_VERBOSE, "Plug %d:\n", plug->getGlobalId() ); 
    2035         plug->showPlug(); 
    2036  
    2037     } 
    2038 
    2039  
    2040 AvPlug* 
    2041 AvPlugManager::getPlug( AVCCommand::ESubunitType subunitType, 
    2042                         subunit_id_t subunitId, 
    2043                         function_block_type_t functionBlockType, 
    2044                         function_block_id_t functionBlockId, 
    2045                         AvPlug::EAvPlugAddressType plugAddressType, 
    2046                         AvPlug::EAvPlugDirection plugDirection, 
    2047                         plug_id_t plugId ) const 
    2048 
    2049     debugOutput( DEBUG_LEVEL_VERBOSE, "SBT, SBID, FBT, FBID, AT, PD, ID = " 
    2050                  "(0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x)\n", 
    2051                  subunitType, 
    2052                  subunitId, 
    2053                  functionBlockType, 
    2054                  functionBlockId, 
    2055                  plugAddressType, 
    2056                  plugDirection, 
    2057                  plugId ); 
    2058  
    2059     for ( AvPlugVector::const_iterator it = m_plugs.begin(); 
    2060           it !=  m_plugs.end(); 
    2061           ++it ) 
    2062     { 
    2063         AvPlug* plug = *it; 
    2064  
    2065         if (    ( subunitType == plug->getSubunitType() ) 
    2066              && ( subunitId == plug->getSubunitId() ) 
    2067              && ( functionBlockType == plug->getFunctionBlockType() ) 
    2068              && ( functionBlockId == plug->getFunctionBlockId() ) 
    2069              && ( plugAddressType == plug->getPlugAddressType() ) 
    2070              && ( plugDirection == plug->getPlugDirection() ) 
    2071              && ( plugId == plug->getPlugId() ) ) 
    2072         { 
    2073             return plug; 
    2074         } 
    2075     } 
    2076  
    2077     return 0; 
    2078 
    2079  
    2080 AvPlug* 
    2081 AvPlugManager::getPlug( int iGlobalId ) const 
    2082 
    2083     for ( AvPlugVector::const_iterator it = m_plugs.begin(); 
    2084           it !=  m_plugs.end(); 
    2085           ++it ) 
    2086     { 
    2087         AvPlug* pPlug = *it; 
    2088         if ( pPlug->getGlobalId() == iGlobalId ) { 
    2089             return pPlug; 
    2090         } 
    2091     } 
    2092  
    2093     return 0; 
    2094 
    2095  
    2096 AvPlugVector 
    2097 AvPlugManager::getPlugsByType( AVCCommand::ESubunitType subunitType, 
    2098                                subunit_id_t subunitId, 
    2099                                function_block_type_t functionBlockType, 
    2100                                function_block_id_t functionBlockId, 
    2101                                AvPlug::EAvPlugAddressType plugAddressType, 
    2102                                AvPlug::EAvPlugDirection plugDirection, 
    2103                                AvPlug::EAvPlugType type) const 
    2104 
    2105     debugOutput( DEBUG_LEVEL_VERBOSE, "SBT, SBID, FBT, FBID, AT, PD, T = " 
    2106                  "(0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x)\n", 
    2107                  subunitType, 
    2108                  subunitId, 
    2109                  functionBlockType, 
    2110                  functionBlockId, 
    2111                  plugAddressType, 
    2112                  plugDirection, 
    2113                  type ); 
    2114  
    2115     AvPlugVector plugVector; 
    2116     for ( AvPlugVector::const_iterator it = m_plugs.begin(); 
    2117           it !=  m_plugs.end(); 
    2118           ++it ) 
    2119     { 
    2120         AvPlug* pPlug = *it; 
    2121  
    2122         if (    ( subunitType == pPlug->getSubunitType() ) 
    2123              && ( subunitId == pPlug->getSubunitId() ) 
    2124              && ( functionBlockType == pPlug->getFunctionBlockType() ) 
    2125              && ( functionBlockId == pPlug->getFunctionBlockId() ) 
    2126              && ( plugAddressType == pPlug->getPlugAddressType() ) 
    2127              && ( plugDirection == pPlug->getPlugDirection() ) 
    2128              && ( type == pPlug->getPlugType() ) ) 
    2129         { 
    2130             plugVector.push_back( pPlug ); 
    2131         } 
    2132     } 
    2133  
    2134     return plugVector; 
    2135 
    2136  
    2137 bool 
    2138 AvPlugManager::serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const 
    2139 
    2140     bool result = true; 
    2141     int i = 0; 
    2142     for ( AvPlugVector::const_iterator it = m_plugs.begin(); 
    2143           it !=  m_plugs.end(); 
    2144           ++it ) 
    2145     { 
    2146         AvPlug* pPlug = *it; 
    2147         std::ostringstream strstrm; 
    2148         strstrm << basePath << i; 
    2149         result &= pPlug->serialize( strstrm.str() + "/", ser ); 
    2150         i++; 
    2151     } 
    2152  
    2153     return result; 
    2154 
    2155  
    2156 AvPlugManager* 
    2157 AvPlugManager::deserialize( Glib::ustring basePath, 
    2158                             Util::IODeserialize& deser, 
    2159                             AvDevice& avDevice ) 
    2160  
    2161 
    2162     AvPlugManager* pMgr = new AvPlugManager; 
    2163  
    2164     if ( !pMgr ) { 
    2165         return 0; 
    2166     } 
    2167  
    2168     int i = 0; 
    2169     bool bFinished = false; 
    2170     do { 
    2171         std::ostringstream strstrm; 
    2172         strstrm << basePath << i; 
    2173         // avDevice still holds a null pointer for the plug manager 
    2174         // therefore we have to *this as additional argument 
    2175         AvPlug* pPlug = AvPlug::deserialize( strstrm.str() + "/", 
    2176                                              deser, 
    2177                                              avDevice, 
    2178                                              *pMgr ); 
    2179         if ( pPlug ) { 
    2180             pMgr->m_plugs.push_back( pPlug ); 
    2181             i++; 
    2182         } else { 
    2183             bFinished = true; 
    2184         } 
    2185     } while ( !bFinished ); 
    2186  
    2187     return pMgr; 
    2188 
    2189  
    2190  
    2191 //////////////////////////////////// 
    2192  
    2193 AvPlugConnection::AvPlugConnection( AvPlug& srcPlug, AvPlug& destPlug ) 
    2194     : m_srcPlug( &srcPlug ) 
    2195     , m_destPlug( &destPlug ) 
    2196 
    2197 
    2198  
    2199 AvPlugConnection::AvPlugConnection() 
    2200     : m_srcPlug( 0 ) 
    2201     , m_destPlug( 0 ) 
    2202 
    2203 
    2204  
    2205 bool 
    2206 AvPlugConnection::serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const 
    2207 
    2208     bool result; 
    2209     result  = ser.write( basePath + "m_srcPlug", m_srcPlug->getGlobalId() ); 
    2210     result &= ser.write( basePath + "m_destPlug", m_destPlug->getGlobalId() ); 
    2211     return result; 
    2212 
    2213  
    2214 AvPlugConnection* 
    2215 AvPlugConnection::deserialize( Glib::ustring basePath, 
    2216                                Util::IODeserialize& deser, 
    2217                                AvDevice& avDevice ) 
    2218 
    2219     if ( !deser.isExisting( basePath + "m_srcPlug" ) ) { 
    2220         return 0; 
    2221     } 
    2222  
    2223     AvPlugConnection* pConnection = new AvPlugConnection; 
    2224     if ( !pConnection ) { 
    2225         return 0; 
    2226     } 
    2227  
    2228     bool result; 
    2229     int iSrcPlugId; 
    2230     int iDestPlugId; 
    2231     result  = deser.read( basePath + "m_srcPlug", iSrcPlugId ); 
    2232     result &= deser.read( basePath + "m_destPlug",  iDestPlugId ); 
    2233  
    2234     if ( !result ) { 
    2235         delete pConnection; 
    2236         return 0; 
    2237     } 
    2238  
    2239     pConnection->m_srcPlug  = avDevice.getPlugManager().getPlug( iSrcPlugId ); 
    2240     pConnection->m_destPlug = avDevice.getPlugManager().getPlug( iDestPlugId ); 
    2241  
    2242     if ( !pConnection->m_srcPlug || !pConnection->m_destPlug ) { 
    2243         delete pConnection; 
    2244         return 0; 
    2245     } 
    2246  
    2247     return pConnection; 
    2248 
    2249  
    2250 
     661
  • trunk/libffado/src/bebob/bebob_avplug.h

    r445 r554  
    2525#define BEBOB_AVPLUG_H 
    2626 
    27 #include "libavc/avc_signal_source.h" 
    28 #include "libavc/avc_extended_stream_format.h" 
    29 #include "libavc/avc_extended_plug_info.h" 
    30 #include "libavc/avc_extended_cmd_generic.h" 
     27#include "libavc/ccm/avc_signal_source.h" 
     28#include "libavc/streamformat/avc_extended_stream_format.h" 
     29#include "libavc/general/avc_extended_plug_info.h" 
     30#include "libavc/general/avc_extended_cmd_generic.h" 
    3131#include "libavc/avc_definitions.h" 
    32 #include "libavc/avc_generic.h" 
     32#include "libavc/general/avc_generic.h" 
     33#include "libavc/general/avc_plug.h" 
    3334 
    3435#include "libutil/serialize.h" 
     
    4445 
    4546class AvDevice; 
    46 class AvPlugManager; 
    47 class AvPlug; 
    4847 
    49 typedef std::vector<AvPlug*> AvPlugVector; 
    50  
    51 class AvPlug { 
     48class Plug : public AVC::Plug { 
    5249public: 
    5350 
    54     enum EAvPlugAddressType { 
    55     eAPA_PCR, 
    56     eAPA_ExternalPlug, 
    57     eAPA_AsynchronousPlug, 
    58     eAPA_SubunitPlug, 
    59     eAPA_FunctionBlockPlug, 
    60     eAPA_Undefined, 
    61     }; 
    62  
    63     enum EAvPlugType { 
    64         eAPT_IsoStream, 
    65         eAPT_AsyncStream, 
    66         eAPT_Midi, 
    67         eAPT_Sync, 
    68         eAPT_Analog, 
    69         eAPT_Digital, 
    70         eAPT_Unknown, 
    71     }; 
    72  
    73     enum EAvPlugDirection { 
    74     eAPD_Input, 
    75     eAPD_Output, 
    76     eAPD_Unknown, 
    77     }; 
    78  
    7951    // \todo This constructors sucks. too many parameters. fix it. 
    80     AvPlug( Ieee1394Service& ieee1394Service, 
    81         ConfigRom& configRom, 
    82             AvPlugManager& plugManager, 
    83         AVCCommand::ESubunitType subunitType, 
    84         subunit_id_t subunitId, 
    85         function_block_type_t functionBlockType, 
    86         function_block_type_t functionBlockId, 
    87         EAvPlugAddressType plugAddressType, 
    88         EAvPlugDirection plugDirection, 
    89         plug_id_t plugId, 
    90         int verboseLevel ); 
    91     AvPlug( const AvPlug& rhs ); 
    92     virtual ~AvPlug(); 
     52    Plug( AVC::Unit* unit, 
     53          AVC::Subunit* subunit, 
     54          AVC::function_block_type_t functionBlockType, 
     55          AVC::function_block_type_t functionBlockId, 
     56          AVC::Plug::EPlugAddressType plugAddressType, 
     57          AVC::Plug::EPlugDirection plugDirection, 
     58          AVC::plug_id_t plugId ); 
     59    Plug( const Plug& rhs ); 
     60    virtual ~Plug(); 
    9361 
    9462    bool discover(); 
    9563    bool discoverConnections(); 
    9664 
    97     bool inquireConnnection( AvPlug& plug ); 
    98     bool setConnection( AvPlug& plug ); 
    99  
    100     int getGlobalId() const 
    101         { return m_globalId; } 
    102     plug_id_t getPlugId() const 
    103         { return m_id; } 
    104     AVCCommand::ESubunitType getSubunitType() const 
    105         { return m_subunitType; } 
    106     subunit_id_t getSubunitId() const 
    107         { return m_subunitId; } 
    108     const char* getName() const 
    109         { return m_name.c_str(); } 
    110     EAvPlugDirection getPlugDirection() const 
    111         { return m_direction; } 
    112     sampling_frequency_t getSamplingFrequency() const 
    113         { return m_samplingFrequency; } 
    114     int getSampleRate() const; // 22050, 24000, 32000, ... 
    115     int getNrOfChannels() const; 
    116     int getNrOfStreams() const; 
    117  
    118     EAvPlugDirection getDirection() const 
    119         { return m_direction; } 
    120     EAvPlugAddressType getPlugAddressType() const 
    121         { return m_addressType; } 
    122     EAvPlugType getPlugType() const 
    123         { return m_infoPlugType; } 
    124  
    125     function_block_type_t getFunctionBlockType() const 
    126         { return m_functionBlockType; } 
    127     function_block_id_t getFunctionBlockId() const 
    128         { return m_functionBlockId; } 
    129  
    130     const AvPlugVector& getInputConnections() const 
    131         { return m_inputConnections; } 
    132     const AvPlugVector& getOutputConnections() const 
    133         { return m_outputConnections; } 
    134  
    135     static PlugAddress::EPlugDirection convertPlugDirection( 
    136     EAvPlugDirection direction); 
    137  
    138     void showPlug() const; 
    139  
    140     bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const; 
    141     static AvPlug* deserialize( Glib::ustring basePath, 
    142                                 Util::IODeserialize& deser, 
    143                                 AvDevice& avDevice, 
    144                                 AvPlugManager& plugManager ); 
    145  
    146     bool deserializeUpdate( Glib::ustring basePath, 
    147                             Util::IODeserialize& deser ); 
    148  
    14965 public: 
    150     struct ChannelInfo { 
    151         stream_position_t          m_streamPosition; 
    152         stream_position_location_t m_location; 
    153     Glib::ustring              m_name; 
    154     }; 
    155     typedef std::vector<ChannelInfo> ChannelInfoVector; 
    156  
    157     struct ClusterInfo { 
    158     int                      m_index; 
    159     port_type_t              m_portType; 
    160     Glib::ustring            m_name; 
    161  
    162         nr_of_channels_t         m_nrOfChannels; 
    163         ChannelInfoVector        m_channelInfos; 
    164     stream_format_t          m_streamFormat; 
    165     }; 
    166     typedef std::vector<ClusterInfo> ClusterInfoVector; 
    167  
    168     ClusterInfoVector& getClusterInfos() 
    169         { return m_clusterInfos; } 
    17066 
    17167protected: 
    172     AvPlug(); 
     68    Plug(); 
    17369 
    17470    bool discoverPlugType(); 
     
    17874    bool discoverChannelName(); 
    17975    bool discoverClusterInfo(); 
    180     bool discoverStreamFormat(); 
    181     bool discoverSupportedStreamFormats(); 
    18276    bool discoverConnectionsInput(); 
    18377    bool discoverConnectionsOutput(); 
    18478 
    185     ExtendedPlugInfoCmd setPlugAddrToPlugInfoCmd(); 
    186  
    187     ExtendedStreamFormatCmd setPlugAddrToStreamFormatCmd( 
    188     ExtendedStreamFormatCmd::ESubFunction subFunction); 
    189  
    190     SignalSourceCmd setSrcPlugAddrToSignalCmd(); 
    191  
    192     void setDestPlugAddrToSignalCmd( 
    193     SignalSourceCmd& signalSourceCmd, AvPlug& plug ); 
    194  
    195     void debugOutputClusterInfos( int debugLevel ); 
    196  
    197     bool copyClusterInfo(ExtendedPlugInfoPlugChannelPositionSpecificData& 
     79private: 
     80    bool copyClusterInfo(AVC::ExtendedPlugInfoPlugChannelPositionSpecificData& 
    19881                         channelPositionData ); 
    199  
    200     bool addPlugConnection( AvPlugVector& connections, AvPlug& plug ); 
    201  
    202     bool discoverConnectionsFromSpecificData( 
    203         EAvPlugDirection discoverDirection, 
    204         PlugAddressSpecificData* plugAddress, 
    205         AvPlugVector& connections ); 
    206  
    207     AvPlug* getPlugDefinedBySpecificData( 
    208         UnitPlugSpecificDataPlugAddress* pUnitPlugAddress, 
    209         SubunitPlugSpecificDataPlugAddress* pSubunitPlugAddress, 
    210         FunctionBlockPlugSpecificDataPlugAddress* pFunctionBlockPlugAddress ); 
    211  
    212     EAvPlugDirection toggleDirection( EAvPlugDirection direction ) const; 
    213  
    214     const ClusterInfo* getClusterInfoByIndex( int index ) const; 
    215  
    216     bool serializeChannelInfos( Glib::ustring basePath, 
    217                                 Util::IOSerialize& ser, 
    218                                 const ClusterInfo& clusterInfo ) const; 
    219     bool deserializeChannelInfos( Glib::ustring basePath, 
    220                                   Util::IODeserialize& deser, 
    221                                   ClusterInfo& clusterInfo ); 
    222  
    223     bool serializeClusterInfos( Glib::ustring basePath, 
    224                                 Util::IOSerialize& ser ) const; 
    225     bool deserializeClusterInfos( Glib::ustring basePath, 
    226                                   Util::IODeserialize& deser ); 
    227  
    228     bool serializeFormatInfos( Glib::ustring basePath, 
    229                                Util::IOSerialize& ser ) const; 
    230     bool deserializeFormatInfos( Glib::ustring basePath, 
    231                                  Util::IODeserialize& deser ); 
    232  
    233     bool serializeAvPlugVector( Glib::ustring basePath, 
    234                                 Util::IOSerialize& ser, 
    235                                 const AvPlugVector& vec) const; 
    236     bool deserializeAvPlugVector( Glib::ustring basePath, 
    237                                   Util::IODeserialize& deser, 
    238                                   AvPlugVector& vec ); 
    239  
    240 private: 
    241     // Supported stream formats 
    242     struct FormatInfo { 
    243         FormatInfo() 
    244             : m_samplingFrequency( eSF_DontCare ) 
    245             , m_isSyncStream( false ) 
    246             , m_audioChannels( 0 ) 
    247             , m_midiChannels( 0 ) 
    248             , m_index( 0xff ) 
    249             {} 
    250     sampling_frequency_t  m_samplingFrequency; 
    251     bool                  m_isSyncStream; 
    252     number_of_channels_t  m_audioChannels; 
    253     number_of_channels_t  m_midiChannels; 
    254     byte_t                m_index; 
    255     }; 
    256     typedef std::vector<FormatInfo> FormatInfoVector; 
     82    AVC::ExtendedPlugInfoCmd setPlugAddrToPlugInfoCmd(); 
    25783 
    25884 
    259     Ieee1394Service*             m_p1394Service; 
    260     ConfigRom*                   m_pConfigRom; 
    261     AVCCommand::ESubunitType     m_subunitType; 
    262     subunit_id_t                 m_subunitId; 
    263     function_block_type_t        m_functionBlockType; 
    264     function_block_id_t          m_functionBlockId; 
    265     EAvPlugAddressType           m_addressType; 
    266     EAvPlugDirection             m_direction; 
    267     plug_id_t                    m_id; 
    268     EAvPlugType                  m_infoPlugType; 
    269     nr_of_channels_t             m_nrOfChannels; 
    270     Glib::ustring                m_name; 
    271     ClusterInfoVector            m_clusterInfos; 
    272     sampling_frequency_t         m_samplingFrequency; 
    273     FormatInfoVector             m_formatInfos; 
    274     AvPlugVector                 m_inputConnections; 
    275     AvPlugVector                 m_outputConnections; 
    276     AvPlugManager*               m_plugManager; 
    277     int                          m_verboseLevel; 
    278     int                          m_globalId; 
    279     static int                   m_globalIdCounter; 
    280  
    281     DECLARE_DEBUG_MODULE; 
    28285}; 
    283  
    284 const char* avPlugAddressTypeToString( AvPlug::EAvPlugAddressType addressType ); 
    285 const char* avPlugTypeToString( AvPlug::EAvPlugType type ); 
    286 const char* avPlugDirectionToString( AvPlug::EAvPlugDirection direction ); 
    287  
    288 class AvPlugManager 
    289 { 
    290 public: 
    291     AvPlugManager( int verboseLevel ); 
    292     AvPlugManager( const AvPlugManager& rhs ); 
    293     ~AvPlugManager(); 
    294  
    295     bool addPlug( AvPlug& plug ); 
    296     bool remPlug( AvPlug& plug ); 
    297  
    298     void showPlugs() const; 
    299  
    300     AvPlug* getPlug( AVCCommand::ESubunitType subunitType, 
    301                      subunit_id_t subunitId, 
    302              function_block_type_t functionBlockType, 
    303              function_block_id_t functionBlockId, 
    304                      AvPlug::EAvPlugAddressType plugAddressType, 
    305                      AvPlug::EAvPlugDirection plugDirection, 
    306                      plug_id_t plugId ) const; 
    307     AvPlug* getPlug( int iGlobalId ) const; 
    308     AvPlugVector getPlugsByType( AVCCommand::ESubunitType subunitType, 
    309                  subunit_id_t subunitId, 
    310                  function_block_type_t functionBlockType, 
    311                  function_block_id_t functionBlockId, 
    312                  AvPlug::EAvPlugAddressType plugAddressType, 
    313                  AvPlug::EAvPlugDirection plugDirection, 
    314                  AvPlug::EAvPlugType type) const; 
    315  
    316     bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const; 
    317     static  AvPlugManager* deserialize( Glib::ustring basePath, 
    318                                         Util::IODeserialize& deser, 
    319                                         AvDevice& avDevice ); 
    320  
    321 private: 
    322     AvPlugManager(); 
    323  
    324     int          m_verboseLevel; 
    325     AvPlugVector m_plugs; 
    326  
    327     DECLARE_DEBUG_MODULE; 
    328 }; 
    329  
    330 class AvPlugConnection { 
    331 public: 
    332     AvPlugConnection( AvPlug& srcPlug, AvPlug& destPlug ); 
    333  
    334     AvPlug& getSrcPlug() const 
    335         { return *m_srcPlug; } 
    336     AvPlug& getDestPlug() const 
    337         { return *m_destPlug; } 
    338  
    339     bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const; 
    340     static AvPlugConnection* deserialize( Glib::ustring basePath, 
    341                                           Util::IODeserialize& deser, 
    342                                           AvDevice& avDevice ); 
    343 private: 
    344     AvPlugConnection(); 
    345  
    346 private: 
    347     AvPlug* m_srcPlug; 
    348     AvPlug* m_destPlug; 
    349 }; 
    350  
    351 typedef std::vector<AvPlugConnection*> AvPlugConnectionVector; 
    352 typedef std::vector<AvPlugConnection> AvPlugConnectionOwnerVector; 
    35386 
    35487} 
  • trunk/libffado/src/bebob/bebob_dl_codes.cpp

    r445 r554  
    2424#include "bebob/bebob_dl_codes.h" 
    2525#include "bebob/bebob_dl_bcd.h" 
     26 
     27using namespace AVC; 
    2628 
    2729unsigned short BeBoB::CommandCodes::m_gCommandId = 0; 
  • trunk/libffado/src/bebob/bebob_dl_codes.h

    r445 r554  
    2929#include "fbtypes.h" 
    3030 
    31 #include "libavc/avc_serialize.h" 
     31#include "libavc/util/avc_serialize.h" 
    3232 
    3333namespace BeBoB { 
     
    6969    virtual ~CommandCodes(); 
    7070 
    71         virtual bool serialize( IOSSerialize& se ); 
    72         virtual bool deserialize( IISDeserialize& de ); 
     71        virtual bool serialize( AVC::IOSSerialize& se ); 
     72        virtual bool deserialize( AVC::IISDeserialize& de ); 
    7373 
    7474        virtual size_t getMaxSize(); 
     
    127127        virtual ~CommandCodesReset(); 
    128128 
    129         virtual bool serialize( IOSSerialize& se ); 
    130         virtual bool deserialize( IISDeserialize& de ); 
     129        virtual bool serialize( AVC::IOSSerialize& se ); 
     130        virtual bool deserialize( AVC::IISDeserialize& de ); 
    131131 
    132132        EStartMode getStartMode() const 
     
    147147        virtual ~CommandCodesProgramGUID(); 
    148148 
    149         virtual bool serialize( IOSSerialize& se ); 
    150         virtual bool deserialize( IISDeserialize& de ); 
     149        virtual bool serialize( AVC::IOSSerialize& se ); 
     150        virtual bool deserialize( AVC::IISDeserialize& de ); 
    151151 
    152152        fb_octlet_t getGUID() const 
     
    177177        virtual ~CommandCodesDownloadStart(); 
    178178 
    179         virtual bool serialize( IOSSerialize& se ); 
    180         virtual bool deserialize( IISDeserialize& de ); 
     179        virtual bool serialize( AVC::IOSSerialize& se ); 
     180        virtual bool deserialize( AVC::IISDeserialize& de ); 
    181181 
    182182        bool setDate( fb_octlet_t date ) 
     
    218218        virtual ~CommandCodesDownloadBlock(); 
    219219 
    220         virtual bool serialize( IOSSerialize& se ); 
    221         virtual bool deserialize( IISDeserialize& de ); 
     220        virtual bool serialize( AVC::IOSSerialize& se ); 
     221        virtual bool deserialize( AVC::IISDeserialize& de ); 
    222222 
    223223    bool setSeqNumber( fb_quadlet_t seqNumber ) 
     
    247247        virtual ~CommandCodesDownloadEnd(); 
    248248 
    249         virtual bool serialize( IOSSerialize& se ); 
    250         virtual bool deserialize( IISDeserialize& de ); 
     249        virtual bool serialize( AVC::IOSSerialize& se ); 
     250        virtual bool deserialize( AVC::IISDeserialize& de ); 
    251251 
    252252        fb_quadlet_t getRespCrc32() const 
     
    268268        virtual ~CommandCodesInitializePersParam(); 
    269269 
    270         virtual bool serialize( IOSSerialize& se ); 
    271         virtual bool deserialize( IISDeserialize& de ); 
     270        virtual bool serialize( AVC::IOSSerialize& se ); 
     271        virtual bool deserialize( AVC::IISDeserialize& de ); 
    272272    }; 
    273273 
     
    280280        virtual ~CommandCodesInitializeConfigToFactorySetting(); 
    281281 
    282         virtual bool serialize( IOSSerialize& se ); 
    283         virtual bool deserialize( IISDeserialize& de ); 
     282        virtual bool serialize( AVC::IOSSerialize& se ); 
     283        virtual bool deserialize( AVC::IISDeserialize& de ); 
    284284    }; 
    285285 
     
    296296        virtual ~CommandCodesGo(); 
    297297 
    298         virtual bool serialize( IOSSerialize& se ); 
    299         virtual bool deserialize( IISDeserialize& de ); 
     298        virtual bool serialize( AVC::IOSSerialize& se ); 
     299        virtual bool deserialize( AVC::IISDeserialize& de ); 
    300300 
    301301        EStartMode getStartMode() const 
  • trunk/libffado/src/bebob/bebob_dl_mgr.cpp

    r445 r554  
    2929#include "libieee1394/ieee1394service.h" 
    3030 
    31 #include "libavc/avc_serialize.h" 
     31#include "libavc/util/avc_serialize.h" 
    3232 
    3333#include <netinet/in.h> 
    3434 
    3535#include <cstdio> 
     36 
     37using namespace AVC; 
    3638 
    3739namespace BeBoB { 
  • trunk/libffado/src/bebob/bebob_functionblock.cpp

    r516 r554  
    2727#include "libieee1394/configrom.h" 
    2828 
    29 IMPL_DEBUG_MODULE( BeBoB::FunctionBlock, BeBoB::FunctionBlock, DEBUG_LEVEL_NORMAL ); 
    30  
    31 BeBoB::FunctionBlock::FunctionBlock( 
    32     AvDeviceSubunit& subunit, 
     29using namespace AVC; 
     30 
     31namespace BeBoB { 
     32 
     33IMPL_DEBUG_MODULE( FunctionBlock, FunctionBlock, DEBUG_LEVEL_NORMAL ); 
     34 
     35FunctionBlock::FunctionBlock( 
     36    AVC::Subunit& subunit, 
    3337    function_block_type_t type, 
    3438    function_block_type_t subtype, 
     
    5054} 
    5155 
    52 BeBoB::FunctionBlock::FunctionBlock( const FunctionBlock& rhs ) 
     56FunctionBlock::FunctionBlock( const FunctionBlock& rhs ) 
    5357    : m_subunit( rhs.m_subunit ) 
    5458    , m_type( rhs.m_type ) 
     
    6266} 
    6367 
    64 BeBoB::FunctionBlock::FunctionBlock() 
    65 { 
    66 } 
    67  
    68 BeBoB::FunctionBlock::~FunctionBlock() 
    69 { 
    70     for ( AvPlugVector::iterator it = m_plugs.begin(); 
     68FunctionBlock::FunctionBlock() 
     69{ 
     70} 
     71 
     72FunctionBlock::~FunctionBlock() 
     73{ 
     74    for ( PlugVector::iterator it = m_plugs.begin(); 
    7175          it != m_plugs.end(); 
    7276          ++it ) 
     
    7882 
    7983bool 
    80 BeBoB::FunctionBlock::discover() 
     84FunctionBlock::discover() 
    8185{ 
    8286    debugOutput( DEBUG_LEVEL_NORMAL, 
     
    8791                 m_nrOfOutputPlugs ); 
    8892 
    89     if ( !discoverPlugs( AvPlug::eAPD_Input, m_nrOfInputPlugs ) ) { 
     93    if ( !discoverPlugs( AVC::Plug::eAPD_Input, m_nrOfInputPlugs ) ) { 
    9094        debugError( "Could not discover input plug for '%s'\n", 
    9195                    getName() ); 
     
    9397    } 
    9498 
    95     if ( !discoverPlugs( AvPlug::eAPD_Output, m_nrOfOutputPlugs ) ) { 
     99    if ( !discoverPlugs( AVC::Plug::eAPD_Output, m_nrOfOutputPlugs ) ) { 
    96100        debugError( "Could not discover output plugs for '%s'\n", 
    97101                    getName() ); 
     
    103107 
    104108bool 
    105 BeBoB::FunctionBlock::discoverPlugs( AvPlug::EAvPlugDirection plugDirection, 
     109FunctionBlock::discoverPlugs( AVC::Plug::EPlugDirection plugDirection, 
    106110                                     plug_id_t plugMaxId ) 
    107111{ 
    108112    for ( int plugId = 0; plugId < plugMaxId; ++plugId ) { 
    109         AvPlug* plug = new AvPlug( 
    110             m_subunit->getAvDevice().get1394Service(), 
    111             m_subunit->getAvDevice().getConfigRom(), 
    112             m_subunit->getAvDevice().getPlugManager(), 
    113             m_subunit->getSubunitType(), 
    114             m_subunit->getSubunitId(), 
     113        AVC::Plug* plug = new BeBoB::Plug( 
     114            &m_subunit->getUnit(), 
     115            m_subunit, 
    115116            m_type, 
    116117            m_id, 
    117             AvPlug::eAPA_FunctionBlockPlug, 
     118            AVC::Plug::eAPA_FunctionBlockPlug, 
    118119            plugDirection, 
    119             plugId, 
    120             m_verbose ); 
     120            plugId); 
    121121 
    122122        if ( !plug || !plug->discover() ) { 
     
    136136 
    137137bool 
    138 BeBoB::FunctionBlock::discoverConnections() 
     138FunctionBlock::discoverConnections() 
    139139{ 
    140140    debugOutput( DEBUG_LEVEL_VERBOSE, 
     
    142142                 getName() ); 
    143143 
    144     for ( AvPlugVector::iterator it = m_plugs.begin(); 
     144    for ( PlugVector::iterator it = m_plugs.begin(); 
    145145          it != m_plugs.end(); 
    146146          ++it ) 
    147147    { 
    148         AvPlug* plug = *it; 
     148        BeBoB::Plug* plug = dynamic_cast<BeBoB::Plug*>(*it); 
     149        if(!plug) { 
     150            debugError("BUG: not a bebob plug\n"); 
     151            return false; 
     152        } 
    149153        if ( !plug->discoverConnections() ) { 
    150154            debugError( "Could not discover plug connections\n" ); 
     
    156160 
    157161bool 
    158 serializeAvPlugVector( Glib::ustring basePath, 
     162serializePlugVector( Glib::ustring basePath, 
    159163                       Util::IOSerialize& ser, 
    160                        const BeBoB::AvPlugVector& vec ) 
     164                       const PlugVector& vec ) 
    161165{ 
    162166    bool result = true; 
    163167    int i = 0; 
    164     for ( BeBoB::AvPlugVector::const_iterator it = vec.begin(); 
     168    for ( PlugVector::const_iterator it = vec.begin(); 
    165169          it != vec.end(); 
    166170          ++it ) 
     
    175179 
    176180bool 
    177 deserializeAvPlugVector( Glib::ustring basePath, 
     181deserializePlugVector( Glib::ustring basePath, 
    178182                         Util::IODeserialize& deser, 
    179                          BeBoB::AvDevice& avDevice
    180                          BeBoB::AvPlugVector& vec ) 
     183                         AVC::Unit& unit
     184                         PlugVector& vec ) 
    181185{ 
    182186    int i = 0; 
     
    190194        if ( deser.isExisting( strstrm.str() ) ) { 
    191195            result &= deser.read( strstrm.str(), plugId ); 
    192             BeBoB::AvPlug* pPlug = avDevice.getPlugManager().getPlug( plugId ); 
     196            AVC::Plug* pPlug = unit.getPlugManager().getPlug( plugId ); 
    193197 
    194198            if ( result && pPlug ) { 
     
    207211 
    208212bool 
    209 BeBoB::FunctionBlock::serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const 
     213FunctionBlock::serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const 
    210214{ 
    211215    bool result; 
     
    218222    result &= ser.write( basePath + "m_nrOfOutputPlugs", m_nrOfOutputPlugs ); 
    219223    result &= ser.write( basePath + "m_verbose", m_verbose ); 
    220     result &= serializeAvPlugVector( basePath + "m_plugs", ser, m_plugs ); 
     224    result &= serializePlugVector( basePath + "m_plugs", ser, m_plugs ); 
    221225 
    222226    return result; 
    223227} 
    224228 
    225 BeBoB::FunctionBlock* 
    226 BeBoB::FunctionBlock::deserialize( Glib::ustring basePath, 
     229FunctionBlock* 
     230FunctionBlock::deserialize( Glib::ustring basePath, 
    227231                                   Util::IODeserialize& deser, 
    228                                    AvDevice& avDevice
    229                                    AvDeviceSubunit& subunit ) 
     232                                   AVC::Unit& unit
     233                                   AVC::Subunit& subunit ) 
    230234{ 
    231235    bool result; 
     
    274278    result &= deser.read( basePath + "m_nrOfOutputPlugs", pFB->m_nrOfOutputPlugs ); 
    275279    result &= deser.read( basePath + "m_verbose", pFB->m_verbose ); 
    276     result &= deserializeAvPlugVector( basePath + "m_plugs", deser, avDevice, pFB->m_plugs ); 
     280    result &= deserializePlugVector( basePath + "m_plugs", deser, unit, pFB->m_plugs ); 
    277281 
    278282    return 0; 
     
    281285/////////////////////// 
    282286 
    283 BeBoB::FunctionBlockSelector::FunctionBlockSelector( 
    284     AvDeviceSubunit& subunit, 
     287FunctionBlockSelector::FunctionBlockSelector( 
     288    AVC::Subunit& subunit, 
    285289    function_block_id_t id, 
    286290    ESpecialPurpose purpose, 
     
    299303} 
    300304 
    301 BeBoB::FunctionBlockSelector::FunctionBlockSelector( 
     305FunctionBlockSelector::FunctionBlockSelector( 
    302306    const FunctionBlockSelector& rhs ) 
    303307    : FunctionBlock( rhs ) 
     
    305309} 
    306310 
    307 BeBoB::FunctionBlockSelector::FunctionBlockSelector() 
     311FunctionBlockSelector::FunctionBlockSelector() 
    308312    : FunctionBlock() 
    309313{ 
    310314} 
    311315 
    312 BeBoB::FunctionBlockSelector::~FunctionBlockSelector() 
     316FunctionBlockSelector::~FunctionBlockSelector() 
    313317{ 
    314318} 
    315319 
    316320const char* 
    317 BeBoB::FunctionBlockSelector::getName() 
     321FunctionBlockSelector::getName() 
    318322{ 
    319323    return "Selector"; 
     
    321325 
    322326bool 
    323 BeBoB::FunctionBlockSelector::serializeChild( Glib::ustring basePath, 
     327FunctionBlockSelector::serializeChild( Glib::ustring basePath, 
    324328                                              Util::IOSerialize& ser ) const 
    325329{ 
     
    328332 
    329333bool 
    330 BeBoB::FunctionBlockSelector::deserializeChild( Glib::ustring basePath, 
     334FunctionBlockSelector::deserializeChild( Glib::ustring basePath, 
    331335                                                Util::IODeserialize& deser, 
    332                                                 AvDevice& avDevice
     336                                                AvDevice& unit
    333337{ 
    334338    return true; 
     
    337341/////////////////////// 
    338342 
    339 BeBoB::FunctionBlockFeature::FunctionBlockFeature( 
    340     AvDeviceSubunit& subunit, 
     343FunctionBlockFeature::FunctionBlockFeature( 
     344    AVC::Subunit& subunit, 
    341345    function_block_id_t id, 
    342346    ESpecialPurpose purpose, 
     
    355359} 
    356360 
    357 BeBoB::FunctionBlockFeature::FunctionBlockFeature( 
     361FunctionBlockFeature::FunctionBlockFeature( 
    358362    const FunctionBlockFeature& rhs ) 
    359363    : FunctionBlock( rhs ) 
     
    361365} 
    362366 
    363 BeBoB::FunctionBlockFeature::FunctionBlockFeature() 
     367FunctionBlockFeature::FunctionBlockFeature() 
    364368    : FunctionBlock() 
    365369{ 
    366370} 
    367371 
    368 BeBoB::FunctionBlockFeature::~FunctionBlockFeature() 
     372FunctionBlockFeature::~FunctionBlockFeature() 
    369373{ 
    370374} 
    371375 
    372376const char* 
    373 BeBoB::FunctionBlockFeature::getName() 
     377FunctionBlockFeature::getName() 
    374378{ 
    375379    return "Feature"; 
     
    377381 
    378382bool 
    379 BeBoB::FunctionBlockFeature::serializeChild( Glib::ustring basePath, 
     383FunctionBlockFeature::serializeChild( Glib::ustring basePath, 
    380384                                             Util::IOSerialize& ser ) const 
    381385{ 
     
    384388 
    385389bool 
    386 BeBoB::FunctionBlockFeature::deserializeChild( Glib::ustring basePath, 
     390FunctionBlockFeature::deserializeChild( Glib::ustring basePath, 
    387391                                               Util::IODeserialize& deser, 
    388                                                AvDevice& avDevice
     392                                               AvDevice& unit
    389393{ 
    390394    return true; 
     
    393397/////////////////////// 
    394398 
    395 BeBoB::FunctionBlockEnhancedMixer::FunctionBlockEnhancedMixer( 
    396     AvDeviceSubunit& subunit, 
     399FunctionBlockEnhancedMixer::FunctionBlockEnhancedMixer( 
     400    AVC::Subunit& subunit, 
    397401    function_block_id_t id, 
    398402    ESpecialPurpose purpose, 
     
    411415} 
    412416 
    413 BeBoB::FunctionBlockEnhancedMixer::FunctionBlockEnhancedMixer( 
     417FunctionBlockEnhancedMixer::FunctionBlockEnhancedMixer( 
    414418    const FunctionBlockEnhancedMixer& rhs ) 
    415419    : FunctionBlock( rhs ) 
     
    417421} 
    418422 
    419 BeBoB::FunctionBlockEnhancedMixer::FunctionBlockEnhancedMixer() 
     423FunctionBlockEnhancedMixer::FunctionBlockEnhancedMixer() 
    420424    : FunctionBlock() 
    421425{ 
    422426} 
    423427 
    424 BeBoB::FunctionBlockEnhancedMixer::~FunctionBlockEnhancedMixer() 
     428FunctionBlockEnhancedMixer::~FunctionBlockEnhancedMixer() 
    425429{ 
    426430} 
    427431 
    428432const char* 
    429 BeBoB::FunctionBlockEnhancedMixer::getName() 
     433FunctionBlockEnhancedMixer::getName() 
    430434{ 
    431435    return "EnhancedMixer"; 
     
    433437 
    434438bool 
    435 BeBoB::FunctionBlockEnhancedMixer::serializeChild( Glib::ustring basePath, 
     439FunctionBlockEnhancedMixer::serializeChild( Glib::ustring basePath, 
    436440                                                   Util::IOSerialize& ser ) const 
    437441{ 
     
    440444 
    441445bool 
    442 BeBoB::FunctionBlockEnhancedMixer::deserializeChild( Glib::ustring basePath, 
     446FunctionBlockEnhancedMixer::deserializeChild( Glib::ustring basePath, 
    443447                                                     Util::IODeserialize& deser, 
    444                                                      AvDevice& avDevice
     448                                                     AvDevice& unit
    445449{ 
    446450    return true; 
     
    449453/////////////////////// 
    450454 
    451 BeBoB::FunctionBlockProcessing::FunctionBlockProcessing( 
    452     AvDeviceSubunit& subunit, 
     455FunctionBlockProcessing::FunctionBlockProcessing( 
     456    AVC::Subunit& subunit, 
    453457    function_block_id_t id, 
    454458    ESpecialPurpose purpose, 
     
    467471} 
    468472 
    469 BeBoB::FunctionBlockProcessing::FunctionBlockProcessing( 
     473FunctionBlockProcessing::FunctionBlockProcessing( 
    470474    const FunctionBlockProcessing& rhs ) 
    471475    : FunctionBlock( rhs ) 
     
    473477} 
    474478 
    475 BeBoB::FunctionBlockProcessing::FunctionBlockProcessing() 
     479FunctionBlockProcessing::FunctionBlockProcessing() 
    476480    : FunctionBlock() 
    477481{ 
    478482} 
    479483 
    480 BeBoB::FunctionBlockProcessing::~FunctionBlockProcessing() 
     484FunctionBlockProcessing::~FunctionBlockProcessing() 
    481485{ 
    482486} 
    483487 
    484488const char* 
    485 BeBoB::FunctionBlockProcessing::getName() 
     489FunctionBlockProcessing::getName() 
    486490{ 
    487491    return "Dummy Processing"; 
     
    489493 
    490494bool 
    491 BeBoB::FunctionBlockProcessing::serializeChild( Glib::ustring basePath, 
     495FunctionBlockProcessing::serializeChild( Glib::ustring basePath, 
    492496                                                Util::IOSerialize& ser ) const 
    493497{ 
     
    496500 
    497501bool 
    498 BeBoB::FunctionBlockProcessing::deserializeChild( Glib::ustring basePath, 
     502FunctionBlockProcessing::deserializeChild( Glib::ustring basePath, 
    499503                                                  Util::IODeserialize& deser, 
    500                                                   AvDevice& avDevice
     504                                                  AvDevice& unit
    501505{ 
    502506    return true; 
     
    505509/////////////////////// 
    506510 
    507 BeBoB::FunctionBlockCodec::FunctionBlockCodec( 
    508     AvDeviceSubunit& subunit, 
     511FunctionBlockCodec::FunctionBlockCodec( 
     512    AVC::Subunit& subunit, 
    509513    function_block_id_t id, 
    510514    ESpecialPurpose purpose, 
     
    523527} 
    524528 
    525 BeBoB::FunctionBlockCodec::FunctionBlockCodec( const FunctionBlockCodec& rhs ) 
     529FunctionBlockCodec::FunctionBlockCodec( const FunctionBlockCodec& rhs ) 
    526530    : FunctionBlock( rhs ) 
    527531{ 
    528532} 
    529533 
    530 BeBoB::FunctionBlockCodec::FunctionBlockCodec() 
     534FunctionBlockCodec::FunctionBlockCodec() 
    531535    : FunctionBlock() 
    532536{ 
    533537} 
    534538 
    535 BeBoB::FunctionBlockCodec::~FunctionBlockCodec() 
     539FunctionBlockCodec::~FunctionBlockCodec() 
    536540{ 
    537541} 
    538542 
    539543const char* 
    540 BeBoB::FunctionBlockCodec::getName() 
     544FunctionBlockCodec::getName() 
    541545{ 
    542546    return "Dummy Codec"; 
     
    544548 
    545549bool 
    546 BeBoB::FunctionBlockCodec::serializeChild( Glib::ustring basePath, 
     550FunctionBlockCodec::serializeChild( Glib::ustring basePath, 
    547551                                           Util::IOSerialize& ser ) const 
    548552{ 
     
    551555 
    552556bool 
    553 BeBoB::FunctionBlockCodec::deserializeChild( Glib::ustring basePath, 
     557FunctionBlockCodec::deserializeChild( Glib::ustring basePath, 
    554558                                             Util::IODeserialize& deser, 
    555                                              AvDevice& avDevice ) 
    556 
    557     return true; 
    558 
     559                                             AvDevice& unit ) 
     560
     561    return true; 
     562
     563 
     564
  • trunk/libffado/src/bebob/bebob_functionblock.h

    r455 r554  
    2828 
    2929#include "libavc/avc_definitions.h" 
     30// #include "libavc/general/avc_subunit.h" 
     31 
    3032#include "debugmodule/debugmodule.h" 
    3133 
     34namespace AVC { 
     35    class Subunit; 
     36} 
     37 
    3238namespace BeBoB { 
    33  
    34 class AvDeviceSubunit; 
    3539 
    3640class FunctionBlock { 
     
    5054    }; 
    5155 
    52     FunctionBlock( AvDeviceSubunit& subunit, 
    53            function_block_type_t type, 
    54                    function_block_type_t subtype, 
    55                    function_block_id_t id, 
     56    FunctionBlock( AVC::Subunit& subunit, 
     57                   AVC::function_block_type_t type, 
     58                   AVC::function_block_type_t subtype, 
     59                   AVC::function_block_id_t id, 
    5660                   ESpecialPurpose purpose, 
    57                    no_of_input_plugs_t nrOfInputPlugs, 
    58                    no_of_output_plugs_t nrOfOutputPlugs, 
     61                   AVC::no_of_input_plugs_t nrOfInputPlugs, 
     62                   AVC::no_of_output_plugs_t nrOfOutputPlugs, 
    5963                   int verbose ); 
    6064    FunctionBlock( const FunctionBlock& rhs ); 
     
    6771    virtual const char* getName() = 0; 
    6872     
    69     function_block_type_t getType() {return m_type;}; 
    70     function_block_type_t getSubtype() {return m_subtype;}; 
    71     function_block_id_t getId() {return m_id;}; 
     73    AVC::function_block_type_t getType() {return m_type;}; 
     74    AVC::function_block_type_t getSubtype() {return m_subtype;}; 
     75    AVC::function_block_id_t getId() {return m_id;}; 
    7276 
    7377    bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const; 
    7478    static FunctionBlock* deserialize( Glib::ustring basePath, 
    7579                       Util::IODeserialize& deser, 
    76                        AvDevice& avDevice
    77                                        AvDeviceSubunit& subunit); 
    78 protected: 
    79     bool discoverPlugs( AvPlug::EAvPlugDirection plugDirection, 
    80                         plug_id_t plugMaxId ); 
    81  
    82 protected: 
    83     AvDeviceSubunit*      m_subunit; 
    84     function_block_type_t m_type; 
    85     function_block_type_t m_subtype; 
    86     function_block_id_t   m_id; 
     80                       AVC::Unit& unit
     81                       AVC::Subunit& subunit); 
     82protected: 
     83    bool discoverPlugs( AVC::Plug::EPlugDirection plugDirection, 
     84                        AVC::plug_id_t plugMaxId ); 
     85 
     86protected: 
     87    AVC::Subunit*      m_subunit; 
     88    AVC::function_block_type_t m_type; 
     89    AVC::function_block_type_t m_subtype; 
     90    AVC::function_block_id_t   m_id; 
    8791    ESpecialPurpose       m_purpose; 
    88     no_of_input_plugs_t   m_nrOfInputPlugs; 
    89     no_of_output_plugs_t  m_nrOfOutputPlugs; 
     92    AVC::no_of_input_plugs_t   m_nrOfInputPlugs; 
     93    AVC::no_of_output_plugs_t  m_nrOfOutputPlugs; 
    9094    int                   m_verbose; 
    91     AvPlugVector          m_plugs; 
     95    AVC::PlugVector          m_plugs; 
    9296 
    9397    DECLARE_DEBUG_MODULE; 
     
    102106{ 
    103107public: 
    104     FunctionBlockSelector(AvDeviceSubunit& subunit, 
    105                           function_block_id_t id, 
     108    FunctionBlockSelector(AVC::Subunit& subunit, 
     109                          AVC::function_block_id_t id, 
    106110                          ESpecialPurpose purpose, 
    107                           no_of_input_plugs_t nrOfInputPlugs, 
    108                           no_of_output_plugs_t nrOfOutputPlugs, 
     111                          AVC::no_of_input_plugs_t nrOfInputPlugs, 
     112                          AVC::no_of_output_plugs_t nrOfOutputPlugs, 
    109113                          int verbose); 
    110114    FunctionBlockSelector( const FunctionBlockSelector& rhs ); 
     
    127131{ 
    128132public: 
    129     FunctionBlockFeature(AvDeviceSubunit& subunit, 
    130                          function_block_id_t id, 
     133    FunctionBlockFeature(AVC::Subunit& subunit, 
     134                         AVC::function_block_id_t id, 
    131135                         ESpecialPurpose purpose, 
    132                          no_of_input_plugs_t nrOfInputPlugs, 
    133                          no_of_output_plugs_t nrOfOutputPlugs, 
     136                         AVC::no_of_input_plugs_t nrOfInputPlugs, 
     137                         AVC::no_of_output_plugs_t nrOfOutputPlugs, 
    134138                         int verbose); 
    135139    FunctionBlockFeature( const FunctionBlockFeature& rhs ); 
     
    169173{ 
    170174public: 
    171     FunctionBlockEnhancedMixer( AvDeviceSubunit& subunit, 
    172                                 function_block_id_t id, 
     175    FunctionBlockEnhancedMixer( AVC::Subunit& subunit, 
     176                                AVC::function_block_id_t id, 
    173177                                ESpecialPurpose purpose, 
    174                                 no_of_input_plugs_t nrOfInputPlugs, 
    175                                 no_of_output_plugs_t nrOfOutputPlugs, 
     178                                AVC::no_of_input_plugs_t nrOfInputPlugs, 
     179                                AVC::no_of_output_plugs_t nrOfOutputPlugs, 
    176180                                int verbose ); 
    177181    FunctionBlockEnhancedMixer(); 
     
    194198{ 
    195199public: 
    196     FunctionBlockProcessing( AvDeviceSubunit& subunit, 
    197                              function_block_id_t id, 
     200    FunctionBlockProcessing( AVC::Subunit& subunit, 
     201                             AVC::function_block_id_t id, 
    198202                             ESpecialPurpose purpose, 
    199                              no_of_input_plugs_t nrOfInputPlugs, 
    200                              no_of_output_plugs_t nrOfOutputPlugs, 
     203                             AVC::no_of_input_plugs_t nrOfInputPlugs, 
     204                             AVC::no_of_output_plugs_t nrOfOutputPlugs, 
    201205                             int verbose ); 
    202206    FunctionBlockProcessing( const FunctionBlockProcessing& rhs ); 
     
    219223{ 
    220224public: 
    221     FunctionBlockCodec(AvDeviceSubunit& subunit, 
    222                        function_block_id_t id, 
     225    FunctionBlockCodec(AVC::Subunit& subunit, 
     226                       AVC::function_block_id_t id, 
    223227                       ESpecialPurpose purpose, 
    224                        no_of_input_plugs_t nrOfInputPlugs, 
    225                        no_of_output_plugs_t nrOfOutputPlugs, 
     228                       AVC::no_of_input_plugs_t nrOfInputPlugs, 
     229                       AVC::no_of_output_plugs_t nrOfOutputPlugs, 
    226230                       int verbose); 
    227231    FunctionBlockCodec( const FunctionBlockCodec& rhs ); 
  • trunk/libffado/src/bebob/GenericMixer.cpp

    r462 r554  
    3131#include "libosc/OscResponse.h" 
    3232 
    33 #include "libavc/avc_function_block.h" 
    34 #include "libavc/avc_serialize.h" 
     33#include "libavc/audiosubunit/avc_function_block.h" 
     34#include "libavc/util/avc_serialize.h" 
    3535 
    3636#include "libieee1394/ieee1394service.h" 
     
    4343 
    4444using namespace OSC; 
     45using namespace AVC; 
    4546 
    4647namespace BeBoB { 
  • trunk/libffado/src/bounce/bounce_avdevice.cpp

    r479 r554  
    2828#include "libieee1394/ieee1394service.h" 
    2929 
    30 #include "libavc/avc_plug_info.h" 
    31 #include "libavc/avc_extended_plug_info.h" 
    32 #include "libavc/avc_subunit_info.h" 
    33 #include "libavc/avc_extended_stream_format.h" 
    34 #include "libavc/avc_serialize.h" 
     30#include "libavc/general/avc_plug_info.h" 
     31#include "libavc/general/avc_extended_plug_info.h" 
     32#include "libavc/general/avc_subunit_info.h" 
     33#include "libavc/streamformat/avc_extended_stream_format.h" 
     34#include "libavc/util/avc_serialize.h" 
    3535#include "libavc/avc_definitions.h" 
    3636 
     
    5555                            Ieee1394Service& ieee1394service, 
    5656                            int nodeId ) 
    57     : IAvDevice( configRom, ieee1394service, nodeId ) 
     57    : FFADODevice( configRom, ieee1394service, nodeId ) 
    5858    , m_samplerate (44100) 
    5959    , m_model( NULL ) 
     
    132132} 
    133133 
     134bool BounceDevice::setSamplingFrequency( int s ) { 
     135    if (s) { 
     136        m_samplerate=s; 
     137        return true; 
     138    } else return false; 
     139} 
     140 
    134141int BounceDevice::getConfigurationId( ) { 
    135142    return 0; 
    136143} 
    137144 
    138 bool BounceDevice::setSamplingFrequency( ESamplingFrequency samplingFrequency ) { 
    139     int retval=convertESamplingFrequency( samplingFrequency ); 
    140     if (retval) { 
    141         m_samplerate=retval; 
    142         return true; 
    143     } else return false; 
    144 } 
    145145 
    146146bool 
  • trunk/libffado/src/bounce/bounce_avdevice.h

    r516 r554  
    2828#include "debugmodule/debugmodule.h" 
    2929#include "libavc/avc_definitions.h" 
    30 #include "libavc/avc_extended_cmd_generic.h" 
     30#include "libavc/general/avc_extended_cmd_generic.h" 
    3131 
    3232#include "libstreaming/AmdtpStreamProcessor.h" 
     
    3636#include "libieee1394/ARMHandler.h" 
    3737 
    38 #include "iavdevice.h" 
     38#include "ffadodevice.h" 
    3939 
    4040#include <vector> 
     
    6565}; 
    6666 
    67 class BounceDevice : public IAvDevice { 
     67class BounceDevice : public FFADODevice { 
    6868private: 
    6969    class BounceNotifier; 
     
    7878    virtual bool discover(); 
    7979 
    80     virtual bool setSamplingFrequency( ESamplingFrequency samplingFrequency ); 
     80    virtual bool setSamplingFrequency( int samplingFrequency ); 
    8181    virtual int getSamplingFrequency( ); 
    8282 
  • trunk/libffado/src/debugmodule/debugmodule.cpp

    r494 r554  
    3030#include <iostream> 
    3131 
     32#include <time.h> 
     33 
     34//#define DO_MESSAGE_BUFFER_PRINT 
     35 
     36#ifndef DO_MESSAGE_BUFFER_PRINT 
     37        #warning Printing debug info without ringbuffer, not RT-safe! 
     38#endif 
     39 
    3240using namespace std; 
    3341 
     
    111119        fname=f; 
    112120    } 
    113  
    114     DebugModuleManager::instance()->print( "%s (%s)[%4d] %s: ", getPreSequence( level ), 
     121     
     122    // add a timing timestamp 
     123    struct timespec ts; 
     124    clock_gettime(CLOCK_MONOTONIC, &ts); 
     125    uint32_t ts_usec=(uint32_t)(ts.tv_sec * 1000000LL + ts.tv_nsec / 1000LL); 
     126     
     127    DebugModuleManager::instance()->print( "%010lu: %s (%s)[%4d] %s: ",  
     128                 ts_usec, getPreSequence( level ), 
    115129                 fname,  line,  function ); 
    116130    DebugModuleManager::instance()->va_print( format, arg ); 
     
    195209 
    196210    pthread_mutex_init(&mb_write_lock, NULL); 
     211    pthread_mutex_init(&mb_flush_lock, NULL); 
    197212    pthread_cond_init(&mb_ready_cond, NULL); 
    198213 
     
    284299 
    285300void 
    286 DebugModuleManager::sync() 
    287 { 
    288     mb_flush(); 
     301DebugModuleManager::flush() 
     302{ 
     303//     mb_flush(); 
    289304} 
    290305 
     
    293308{ 
    294309    /* called WITHOUT the mb_write_lock */ 
     310     
     311    /* the flush lock is to allow a flush from multiple threads  
     312     * this allows a code section that outputs a lot of debug messages 
     313     * and that can be blocked to flush the buffer itself such that it  
     314     * does not overflow. 
     315     */ 
     316    DebugModuleManager *m=DebugModuleManager::instance(); 
     317    pthread_mutex_lock(&m->mb_flush_lock); 
    295318    while (mb_outbuffer != mb_inbuffer) { 
    296319        fputs(mb_buffers[mb_outbuffer], stderr); 
    297320        mb_outbuffer = MB_NEXT(mb_outbuffer); 
    298321    } 
     322    pthread_mutex_unlock(&m->mb_flush_lock); 
    299323} 
    300324 
     
    346370    } 
    347371     
     372#ifdef DO_MESSAGE_BUFFER_PRINT 
    348373    while (ntries) { // try a few times 
    349374        if (pthread_mutex_trylock(&mb_write_lock) == 0) { 
     
    358383        } 
    359384    } 
    360      
    361385    if (ntries==0) {  /* lock collision */ 
    362 //         atomic_add(&mb_overruns, 1); 
     386       //         atomic_add(&mb_overruns, 1); 
    363387        // FIXME: atomicity 
    364388        mb_overruns++; // skip the atomicness for now 
    365389    } 
    366 
    367  
     390#else 
     391    fprintf(stderr,msg); 
     392#endif 
     393
    368394 
    369395void 
     
    386412        return; 
    387413    } 
    388  
     414     
     415#ifdef DO_MESSAGE_BUFFER_PRINT 
    389416    while (ntries) { // try a few times 
    390417        if (pthread_mutex_trylock(&mb_write_lock) == 0) { 
     
    405432        mb_overruns++; // skip the atomicness for now 
    406433    } 
     434#else 
     435    fprintf(stderr,msg); 
     436#endif 
    407437} 
    408438 
  • trunk/libffado/src/debugmodule/debugmodule.h

    r494 r554  
    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 */ 
    3739#define MB_BUFFERS    (1<<16) 
     40 
    3841#define MB_NEXT(index) ((index+1) & (MB_BUFFERS-1)) 
    39 #define MB_BUFFERSIZE    256        /* message length limit */ 
     42#define MB_BUFFERSIZE    DEBUG_MAX_MESSAGE_LENGTH        /* message length limit */ 
    4043 
    4144#define debugFatal( format, args... )                               \ 
     
    99102                m_debugModule.getLevel( ) 
    100103 
     104#define flushDebugOutput()      DebugModuleManager::instance()->flush() 
    101105 
    102106#ifdef DEBUG 
     
    203207    bool setMgrDebugLevel( std::string name, debug_level_t level ); 
    204208 
    205     void sync(); 
     209    void flush(); 
    206210 
    207211protected: 
     
    227231    pthread_t mb_writer_thread; 
    228232    pthread_mutex_t mb_write_lock; 
     233    pthread_mutex_t mb_flush_lock; 
    229234    pthread_cond_t mb_ready_cond; 
    230235 
  • trunk/libffado/src/devicemanager.cpp

    r529 r554  
    2626 
    2727#include "devicemanager.h" 
    28 #include "iavdevice.h" 
     28#include "ffadodevice.h" 
    2929 
    3030#include "libieee1394/configrom.h" 
     
    3838#include "bebob/bebob_avdevice.h" 
    3939#include "maudio/maudio_avdevice.h" 
     40#endif 
     41 
     42#ifdef ENABLE_GENERICAVC 
     43    #include "genericavc/avc_avdevice.h" 
    4044#endif 
    4145 
     
    7276    , m_1394Service( 0 ) 
    7377    , m_oscServer( NULL ) 
    74     , m_verboseLevel( DEBUG_LEVEL_NORMAL ) 
    7578{ 
    7679    addOption(Util::OptionContainer::Option("slaveMode",false)); 
     
    8588    } 
    8689 
    87     for ( IAvDeviceVectorIterator it = m_avDevices.begin(); 
     90    for ( FFADODeviceVectorIterator it = m_avDevices.begin(); 
    8891          it != m_avDevices.end(); 
    8992          ++it ) 
     
    98101DeviceManager::setVerboseLevel(int l) 
    99102{ 
    100     m_verboseLevel=l
     103    debugOutput( DEBUG_LEVEL_NORMAL, "Setting verbose level to %d...\n", l )
    101104    setDebugLevel(l); 
    102105 
     
    105108    OscNode::setVerboseLevel(l); 
    106109 
    107     for ( IAvDeviceVectorIterator it = m_avDevices.begin(); 
     110    for ( FFADODeviceVectorIterator it = m_avDevices.begin(); 
    108111          it != m_avDevices.end(); 
    109112          ++it ) 
     
    129132    } 
    130133 
    131     m_oscServer = new OSC::OscServer("17820"); 
    132  
    133     if (!m_oscServer) { 
    134         debugFatal("failed to create osc server\n"); 
    135         delete m_1394Service; 
    136         m_1394Service = 0; 
    137         return false; 
    138     } 
    139  
    140     if (!m_oscServer->init()) { 
    141         debugFatal("failed to init osc server\n"); 
    142         delete m_oscServer; 
    143         m_oscServer = NULL; 
    144         delete m_1394Service; 
    145         m_1394Service = 0; 
    146         return false; 
    147     } 
    148  
    149     if (!m_oscServer->registerAtRootNode(this)) { 
    150         debugFatal("failed to register devicemanager at server\n"); 
    151         delete m_oscServer; 
    152         m_oscServer = NULL; 
    153         delete m_1394Service; 
    154         m_1394Service = 0; 
    155         return false; 
    156     } 
    157  
    158     if (!m_oscServer->start()) { 
    159         debugFatal("failed to start osc server\n"); 
    160         delete m_oscServer; 
    161         m_oscServer = NULL; 
    162         delete m_1394Service; 
    163         m_1394Service = 0; 
    164         return false; 
    165     } 
    166  
    167     setVerboseLevel(m_verboseLevel); 
     134//     m_oscServer = new OSC::OscServer("17820"); 
     135//  
     136//     if (!m_oscServer) { 
     137//         debugFatal("failed to create osc server\n"); 
     138//         delete m_1394Service; 
     139//         m_1394Service = 0; 
     140//         return false; 
     141//     } 
     142//  
     143//     if (!m_oscServer->init()) { 
     144//         debugFatal("failed to init osc server\n"); 
     145//         delete m_oscServer; 
     146//         m_oscServer = NULL; 
     147//         delete m_1394Service; 
     148//         m_1394Service = 0; 
     149//         return false; 
     150//     } 
     151//  
     152//     if (!m_oscServer->registerAtRootNode(this)) { 
     153//         debugFatal("failed to register devicemanager at server\n"); 
     154//         delete m_oscServer; 
     155//         m_oscServer = NULL; 
     156//         delete m_1394Service; 
     157//         m_1394Service = 0; 
     158//         return false; 
     159//     } 
     160//  
     161//     if (!m_oscServer->start()) { 
     162//         debugFatal("failed to start osc server\n"); 
     163//         delete m_oscServer; 
     164//         m_oscServer = NULL; 
     165//         delete m_1394Service; 
     166//         m_1394Service = 0; 
     167//         return false; 
     168//     } 
     169 
     170    setVerboseLevel(getDebugLevel()); 
    168171    return true; 
    169172} 
     
    181184    } 
    182185 
    183     setVerboseLevel(m_verboseLevel); 
    184  
    185     for ( IAvDeviceVectorIterator it = m_avDevices.begin(); 
     186    setVerboseLevel(getDebugLevel()); 
     187 
     188    for ( FFADODeviceVectorIterator it = m_avDevices.begin(); 
    186189          it != m_avDevices.end(); 
    187190          ++it ) 
     
    222225            } 
    223226 
    224             IAvDevice*avDevice = getDriverForDevice( configRom, nodeId ); 
     227            FFADODevice* avDevice = getDriverForDevice( configRom, 
     228                                                        nodeId ); 
     229 
    225230            if ( avDevice ) { 
    226231                debugOutput( DEBUG_LEVEL_NORMAL, 
     
    234239                } else if ( avDevice->discover() ) { 
    235240                    debugOutput( DEBUG_LEVEL_VERBOSE, "discovering successful\n" ); 
    236                     avDevice->setVerboseLevel( m_verboseLevel ); 
     241                    avDevice->setVerboseLevel( getDebugLevel() ); 
    237242                } else { 
    238243                    debugError( "could not discover device\n" ); 
     
    256261                } 
    257262 
    258                 if ( m_verboseLevel >= DEBUG_LEVEL_VERBOSE ) { 
     263                if ( getDebugLevel() >= DEBUG_LEVEL_VERBOSE ) { 
    259264                    avDevice->showDevice(); 
    260265                } 
     
    269274                    debugWarning("failed to register AvDevice at OSC server\n"); 
    270275                } 
     276                 
     277                debugOutput( DEBUG_LEVEL_NORMAL, "discovery of node %d done...\n", nodeId ); 
    271278 
    272279            } 
    273280        } 
     281 
     282        debugOutput( DEBUG_LEVEL_NORMAL, "discovery finished...\n" ); 
     283 
    274284        return true; 
    275285 
     
    294304        } 
    295305 
    296         IAvDevice* avDevice = getSlaveDriver( configRom ); 
     306        FFADODevice* avDevice = getSlaveDriver( configRom ); 
    297307        if ( avDevice ) { 
    298308            debugOutput( DEBUG_LEVEL_NORMAL, 
     
    300310                         nodeId ); 
    301311 
    302             avDevice->setVerboseLevel( m_verboseLevel ); 
     312            avDevice->setVerboseLevel( getDebugLevel() ); 
    303313 
    304314            if ( !avDevice->discover() ) { 
     
    311321                debugError( "setting Id failed\n" ); 
    312322            } 
    313             if ( m_verboseLevel >= DEBUG_LEVEL_VERBOSE ) { 
     323            if ( getDebugLevel() >= DEBUG_LEVEL_VERBOSE ) { 
    314324                avDevice->showDevice(); 
    315325            } 
    316326 
    317327            m_avDevices.push_back( avDevice ); 
     328 
     329            debugOutput( DEBUG_LEVEL_NORMAL, "discovery of node %d done...\n", nodeId ); 
    318330        } 
    319331 
     332        debugOutput( DEBUG_LEVEL_NORMAL, "discovery finished...\n" ); 
     333 
    320334        return true; 
    321335    } 
     
    323337 
    324338 
    325 IAvDevice* 
     339FFADODevice* 
    326340DeviceManager::getDriverForDevice( std::auto_ptr<ConfigRom>( configRom ), 
    327341                                   int id ) 
     
    334348#endif 
    335349 
     350#ifdef ENABLE_GENERICAVC 
     351    debugOutput( DEBUG_LEVEL_VERBOSE, "Trying Generic AV/C...\n" ); 
     352    if ( GenericAVC::AvDevice::probe( *configRom.get() ) ) { 
     353        return new GenericAVC::AvDevice( configRom, *m_1394Service, id ); 
     354    } 
     355#endif 
     356 
    336357#ifdef ENABLE_BEBOB 
    337358    debugOutput( DEBUG_LEVEL_VERBOSE, "Trying M-Audio...\n" ); 
     
    379400} 
    380401 
    381 IAvDevice* 
     402FFADODevice* 
    382403DeviceManager::getSlaveDriver( std::auto_ptr<ConfigRom>( configRom ) ) 
    383404{ 
     
    395416DeviceManager::isValidNode(int node) 
    396417{ 
    397     for ( IAvDeviceVectorIterator it = m_avDevices.begin(); 
     418    for ( FFADODeviceVectorIterator it = m_avDevices.begin(); 
    398419          it != m_avDevices.end(); 
    399420          ++it ) 
    400421    { 
    401         IAvDevice* avDevice = *it; 
     422        FFADODevice* avDevice = *it; 
    402423 
    403424        if (avDevice->getConfigRom().getNodeId() == node) { 
     
    422443    } 
    423444 
    424     IAvDevice* avDevice = m_avDevices.at( deviceNr ); 
     445    FFADODevice* avDevice = m_avDevices.at( deviceNr ); 
    425446 
    426447    if ( !avDevice ) { 
     
    431452} 
    432453 
    433 IAvDevice* 
     454FFADODevice* 
    434455DeviceManager::getAvDevice( int nodeId ) 
    435456{ 
    436     for ( IAvDeviceVectorIterator it = m_avDevices.begin(); 
     457    for ( FFADODeviceVectorIterator it = m_avDevices.begin(); 
    437458          it != m_avDevices.end(); 
    438459          ++it ) 
    439460    { 
    440         IAvDevice* avDevice = *it; 
     461        FFADODevice* avDevice = *it; 
    441462        if ( avDevice->getConfigRom().getNodeId() == nodeId ) { 
    442463            return avDevice; 
     
    447468} 
    448469 
    449 IAvDevice* 
     470FFADODevice* 
    450471DeviceManager::getAvDeviceByIndex( int idx ) 
    451472{ 
     
    469490Streaming::StreamProcessor * 
    470491DeviceManager::getSyncSource() { 
    471     IAvDevice* device = getAvDeviceByIndex(0); 
     492    FFADODevice* device = getAvDeviceByIndex(0); 
    472493 
    473494    bool slaveMode=false; 
  • trunk/libffado/src/devicemanager.h

    r529 r554  
    4040 
    4141class Ieee1394Service; 
    42 class IAvDevice; 
     42class FFADODevice; 
    4343namespace Streaming { 
    4444    class StreamProcessor; 
    4545} 
    4646 
    47 typedef std::vector< IAvDevice* > IAvDeviceVector; 
    48 typedef std::vector< IAvDevice* >::iterator IAvDeviceVectorIterator; 
     47typedef std::vector< FFADODevice* > FFADODeviceVector; 
     48typedef std::vector< FFADODevice* >::iterator FFADODeviceVectorIterator; 
    4949 
    5050class DeviceManager 
     
    6565    int getDeviceNodeId( int deviceNr ); 
    6666 
    67     IAvDevice* getAvDevice( int nodeId ); 
    68     IAvDevice* getAvDeviceByIndex( int idx ); 
     67    FFADODevice* getAvDevice( int nodeId ); 
     68    FFADODevice* getAvDeviceByIndex( int idx ); 
    6969    unsigned int getAvDeviceCount(); 
    7070 
     
    7272 
    7373protected: 
    74     IAvDevice* getDriverForDevice( std::auto_ptr<ConfigRom>( configRom ), 
     74    FFADODevice* getDriverForDevice( std::auto_ptr<ConfigRom>( configRom ), 
    7575                                   int id ); 
    76     IAvDevice* getSlaveDriver( std::auto_ptr<ConfigRom>( configRom ) ); 
     76    FFADODevice* getSlaveDriver( std::auto_ptr<ConfigRom>( configRom ) ); 
    7777 
    7878protected: 
    7979    Ieee1394Service* m_1394Service; 
    80     IAvDeviceVector  m_avDevices; 
     80    FFADODeviceVector  m_avDevices; 
    8181 
    8282    OSC::OscServer*  m_oscServer; 
     
    8686    void setVerboseLevel(int l); 
    8787private: 
    88     int m_verboseLevel; 
    8988    DECLARE_DEBUG_MODULE; 
    9089}; 
  • trunk/libffado/src/dice/dice_avdevice.cpp

    r479 r554  
    5454                    Ieee1394Service& ieee1394service, 
    5555                    int nodeId ) 
    56     : IAvDevice( configRom, ieee1394service, nodeId ) 
     56    : FFADODevice( configRom, ieee1394service, nodeId ) 
    5757    , m_model( NULL ) 
    5858    , m_global_reg_offset (0xFFFFFFFFLU) 
     
    143143int 
    144144DiceAvDevice::getSamplingFrequency( ) { 
    145     ESamplingFrequency samplingFrequency; 
     145    int samplingFrequency; 
    146146 
    147147    fb_quadlet_t clockreg; 
     
    154154 
    155155    switch (clockreg) { 
    156         case DICE_RATE_32K:      samplingFrequency = eSF_32000Hz;  break; 
    157         case DICE_RATE_44K1:     samplingFrequency = eSF_44100Hz;  break; 
    158         case DICE_RATE_48K:      samplingFrequency = eSF_48000Hz;  break; 
    159         case DICE_RATE_88K2:     samplingFrequency = eSF_88200Hz;  break; 
    160         case DICE_RATE_96K:      samplingFrequency = eSF_96000Hz;  break; 
    161         case DICE_RATE_176K4:    samplingFrequency = eSF_176400Hz; break; 
    162         case DICE_RATE_192K:     samplingFrequency = eSF_192000Hz; break; 
    163         case DICE_RATE_ANY_LOW:  samplingFrequency = eSF_AnyLow;   break; 
    164         case DICE_RATE_ANY_MID:  samplingFrequency = eSF_AnyMid;   break; 
    165         case DICE_RATE_ANY_HIGH: samplingFrequency = eSF_AnyHigh;  break; 
    166         case DICE_RATE_NONE:     samplingFrequency = eSF_None;     break; 
    167         default:                 samplingFrequency = eSF_DontCare; break; 
    168     } 
    169  
    170     return convertESamplingFrequency(samplingFrequency)
     156        case DICE_RATE_32K:      samplingFrequency = 32000;  break; 
     157        case DICE_RATE_44K1:     samplingFrequency = 44100;  break; 
     158        case DICE_RATE_48K:      samplingFrequency = 48000;  break; 
     159        case DICE_RATE_88K2:     samplingFrequency = 88200;  break; 
     160        case DICE_RATE_96K:      samplingFrequency = 96000;  break; 
     161        case DICE_RATE_176K4:    samplingFrequency = 176400; break; 
     162        case DICE_RATE_192K:     samplingFrequency = 192000; break; 
     163        case DICE_RATE_ANY_LOW:  samplingFrequency = 0;   break; 
     164        case DICE_RATE_ANY_MID:  samplingFrequency = 0;   break; 
     165        case DICE_RATE_ANY_HIGH: samplingFrequency = 0;  break; 
     166        case DICE_RATE_NONE:     samplingFrequency = 0;     break; 
     167        default:                 samplingFrequency = 0; break; 
     168    } 
     169 
     170    return samplingFrequency
    171171} 
    172172 
     
    178178 
    179179bool 
    180 DiceAvDevice::setSamplingFrequency( ESamplingFrequency samplingFrequency ) 
     180DiceAvDevice::setSamplingFrequency( int samplingFrequency ) 
    181181{ 
    182182    debugOutput(DEBUG_LEVEL_VERBOSE, "Setting sample rate: %d\n", 
    183         convertESamplingFrequency(samplingFrequency)); 
     183        (samplingFrequency)); 
    184184 
    185185    bool supported=false; 
     
    188188    switch ( samplingFrequency ) { 
    189189    default: 
    190     case eSF_22050Hz
    191     case eSF_24000Hz
     190    case 22050
     191    case 24000
    192192        supported=false; 
    193193        break; 
    194     case eSF_32000Hz
     194    case 32000
    195195        supported=maskedCheckNotZeroGlobalReg( 
    196196                    DICE_REGISTER_GLOBAL_CLOCKCAPABILITIES, 
     
    198198        select=DICE_RATE_32K; 
    199199        break; 
    200     case eSF_44100Hz
     200    case 44100
    201201        supported=maskedCheckNotZeroGlobalReg( 
    202202                    DICE_REGISTER_GLOBAL_CLOCKCAPABILITIES, 
     
    204204        select=DICE_RATE_44K1; 
    205205        break; 
    206     case eSF_48000Hz
     206    case 48000
    207207        supported=maskedCheckNotZeroGlobalReg( 
    208208                    DICE_REGISTER_GLOBAL_CLOCKCAPABILITIES, 
     
    210210        select=DICE_RATE_48K; 
    211211        break; 
    212     case eSF_88200Hz
     212    case 88200
    213213        supported=maskedCheckNotZeroGlobalReg( 
    214214                    DICE_REGISTER_GLOBAL_CLOCKCAPABILITIES, 
     
    216216        select=DICE_RATE_88K2; 
    217217        break; 
    218     case eSF_96000Hz
     218    case 96000
    219219        supported=maskedCheckNotZeroGlobalReg( 
    220220                    DICE_REGISTER_GLOBAL_CLOCKCAPABILITIES, 
     
    222222        select=DICE_RATE_96K; 
    223223        break; 
    224     case eSF_176400Hz
     224    case 176400
    225225        supported=maskedCheckNotZeroGlobalReg( 
    226226                    DICE_REGISTER_GLOBAL_CLOCKCAPABILITIES, 
     
    228228        select=DICE_RATE_176K4; 
    229229        break; 
    230     case eSF_192000Hz
     230    case 192000
    231231        supported=maskedCheckNotZeroGlobalReg( 
    232232                    DICE_REGISTER_GLOBAL_CLOCKCAPABILITIES, 
     
    237237 
    238238    if (!supported) { 
    239         debugWarning("Unsupported sample rate: %d\n", convertESamplingFrequency(samplingFrequency)); 
     239        debugWarning("Unsupported sample rate: %d\n", (samplingFrequency)); 
    240240        return false; 
    241241    } 
  • trunk/libffado/src/dice/dice_avdevice.h

    r516 r554  
    2525#define DICEDEVICE_H 
    2626 
    27 #include "iavdevice.h" 
     27#include "ffadodevice.h" 
    2828 
    2929#include "debugmodule/debugmodule.h" 
     
    5252}; 
    5353 
    54 class DiceAvDevice : public IAvDevice { 
     54class DiceAvDevice : public FFADODevice { 
    5555private: 
    5656    class DiceNotifier; 
     
    6767    virtual void showDevice(); 
    6868 
    69     virtual bool setSamplingFrequency( ESamplingFrequency samplingFrequency ); 
     69    virtual bool setSamplingFrequency( int samplingFrequency ); 
    7070    virtual int getSamplingFrequency( ); 
    7171 
     
    189189        DiceAvDevice *m_dicedevice; 
    190190    }; 
    191  
    192191}; 
    193192 
  • trunk/libffado/src/ffado.cpp

    r454 r554  
    3030#include "fbtypes.h" 
    3131#include "devicemanager.h" 
    32 #include "iavdevice.h" 
    33  
    34 #include "libavc/avc_generic.h" 
     32#include "ffadodevice.h" 
    3533 
    3634#include <stdio.h> 
     
    133131ffado_set_samplerate( ffado_handle_t ffado_handle, int node_id, int samplerate ) 
    134132{ 
    135     IAvDevice* avDevice = ffado_handle->m_deviceManager->getAvDevice( node_id ); 
     133    FFADODevice* avDevice = ffado_handle->m_deviceManager->getAvDevice( node_id ); 
    136134    if ( avDevice ) { 
    137         if ( avDevice->setSamplingFrequency( parseSampleRate( samplerate ) ) ) { 
     135        if ( avDevice->setSamplingFrequency( samplerate ) ) { 
    138136            return ffado_handle->m_deviceManager->discover()? 0 : -1; 
    139137        } 
     
    142140} 
    143141 
     142#warning this should be cleaned up 
     143#include "libavc/general/avc_generic.h" 
    144144void ffado_sleep_after_avc_command( int time ) 
    145145{ 
    146     AVCCommand::setSleepAfterAVCCommand( time ); 
     146    AVC::AVCCommand::setSleepAfterAVCCommand( time ); 
    147147} 
  • trunk/libffado/src/ffadodevice.cpp

    r504 r554  
    6060 
    6161bool 
     62FFADODevice::loadFromCache() 
     63{ 
     64    return false; 
     65} 
     66 
     67bool 
     68FFADODevice::saveCache() 
     69{ 
     70    return false; 
     71} 
     72 
     73bool 
    6274FFADODevice::setId( unsigned int id) 
    6375{ 
  • trunk/libffado/src/ffadodevice.h

    r509 r554  
    5959    /// Returns the ConfigRom object of the device node. 
    6060    virtual ConfigRom& getConfigRom() const; 
     61     
     62    /** 
     63     * @brief Called by DeviceManager to load device model from cache. 
     64     * 
     65     * This function is called before discover in order to speed up 
     66     * system initializing. 
     67     * 
     68     * @returns true if device was cached and successfully loaded from cache 
     69     */ 
     70    virtual bool loadFromCache(); 
     71 
     72    /** 
     73     * @brief Called by DeviceManager to allow device driver to save a cache version 
     74     * of the current configuration. 
     75     * 
     76     * @returns true if caching was successful. False doesn't mean an error just, 
     77     * the driver was unable to store the configuration 
     78     */ 
     79    virtual bool saveCache(); 
    6180 
    6281    /** 
  • trunk/libffado/src/ffado_streaming.cpp

    r494 r554  
    2828#include "../libffado/ffado.h" 
    2929#include "devicemanager.h" 
    30 #include "iavdevice.h" 
     30#include "ffadodevice.h" 
    3131 
    3232#include "libstreaming/StreamProcessorManager.h" 
     
    139139    // add the stream processors of the devices to the managers 
    140140    for(i=0;i<dev->m_deviceManager->getAvDeviceCount();i++) { 
    141         IAvDevice *device=dev->m_deviceManager->getAvDeviceByIndex(i); 
     141        FFADODevice *device=dev->m_deviceManager->getAvDeviceByIndex(i); 
    142142        assert(device); 
    143143 
     
    154154        // Set the device's sampling rate to that requested 
    155155        // FIXME: does this really belong here?  If so we need to handle errors. 
    156         if (!device->setSamplingFrequency(parseSampleRate(dev->options.sample_rate))) { 
     156        if (!device->setSamplingFrequency(dev->options.sample_rate)) { 
    157157            debugOutput(DEBUG_LEVEL_VERBOSE, " => Retry setting samplerate to %d for (%p)\n", 
    158158                        dev->options.sample_rate, device); 
    159159 
    160160            // try again: 
    161             if (!device->setSamplingFrequency(parseSampleRate(dev->options.sample_rate))) { 
     161            if (!device->setSamplingFrequency(dev->options.sample_rate)) { 
    162162                delete dev->processorManager; 
    163163                delete dev->m_deviceManager; 
     
    211211    // iterate over the found devices 
    212212    for(i=0;i<dev->m_deviceManager->getAvDeviceCount();i++) { 
    213         IAvDevice *device=dev->m_deviceManager->getAvDeviceByIndex(i); 
     213        FFADODevice *device=dev->m_deviceManager->getAvDeviceByIndex(i); 
    214214        assert(device); 
    215215 
     
    236236    // add the stream processors of the devices to the managers 
    237237    for(i=0;i<dev->m_deviceManager->getAvDeviceCount();i++) { 
    238         IAvDevice *device=dev->m_deviceManager->getAvDeviceByIndex(i); 
     238        FFADODevice *device=dev->m_deviceManager->getAvDeviceByIndex(i); 
    239239        assert(device); 
    240240 
     
    272272    // add the stream processors of the devices to the managers 
    273273    for(i=0;i<dev->m_deviceManager->getAvDeviceCount();i++) { 
    274         IAvDevice *device=dev->m_deviceManager->getAvDeviceByIndex(i); 
     274        FFADODevice *device=dev->m_deviceManager->getAvDeviceByIndex(i); 
    275275        assert(device); 
    276276 
  • trunk/libffado/src/libavc/avc_definitions.cpp

    r445 r554  
    2323 
    2424#include "avc_definitions.h" 
    25  
     25#include <libiec61883/iec61883.h> 
     26 
     27namespace AVC { 
    2628 
    2729int 
     
    151153    return stream << str; 
    152154}; 
     155 
     156enum ESubunitType byteToSubunitType(byte_t s) { 
     157    switch (s) { 
     158    case eST_Monitor: 
     159        return eST_Monitor; 
     160    case eST_Audio: 
     161        return eST_Audio; 
     162    case eST_Printer: 
     163        return eST_Printer; 
     164    case eST_Disc: 
     165        return eST_Disc; 
     166    case eST_VCR: 
     167        return eST_VCR; 
     168    case eST_Tuner: 
     169        return eST_Tuner; 
     170    case eST_CA: 
     171        return eST_CA; 
     172    case eST_Camera: 
     173        return eST_Camera; 
     174    case eST_Panel: 
     175        return eST_Panel; 
     176    case eST_BulltinBoard: 
     177        return eST_BulltinBoard; 
     178    case eST_CameraStorage: 
     179        return eST_CameraStorage; 
     180    case eST_Music: 
     181        return eST_Music; 
     182    case eST_VendorUnique: 
     183        return eST_VendorUnique; 
     184    case eST_Reserved: 
     185        return eST_Reserved; 
     186    case eST_Extended: 
     187        return eST_Extended; 
     188    default: 
     189    case eST_Unit: 
     190        return eST_Unit; 
     191    } 
     192} 
     193 
     194unsigned int fdfSfcToSampleRate(byte_t fdf) { 
     195    switch(fdf & 0x07) { 
     196        default:                       return 0; 
     197        case IEC61883_FDF_SFC_32KHZ:   return 32000; 
     198        case IEC61883_FDF_SFC_44K1HZ:  return 44100; 
     199        case IEC61883_FDF_SFC_48KHZ:   return 48000; 
     200        case IEC61883_FDF_SFC_88K2HZ:  return 88200; 
     201        case IEC61883_FDF_SFC_96KHZ:   return 96000; 
     202        case IEC61883_FDF_SFC_176K4HZ: return 176400; 
     203        case IEC61883_FDF_SFC_192KHZ:  return 192000; 
     204    } 
     205} 
     206 
     207byte_t sampleRateToFdfSfc(unsigned int rate) { 
     208    switch(rate) { 
     209        default:      return 0x07; 
     210        case 32000:   return IEC61883_FDF_SFC_32KHZ; 
     211        case 44100:   return IEC61883_FDF_SFC_44K1HZ; 
     212        case 48000:   return IEC61883_FDF_SFC_48KHZ; 
     213        case 88200:   return IEC61883_FDF_SFC_88K2HZ; 
     214        case 96000:   return IEC61883_FDF_SFC_96KHZ; 
     215        case 176400:  return IEC61883_FDF_SFC_176K4HZ; 
     216        case 192000:  return IEC61883_FDF_SFC_192KHZ; 
     217    } 
     218} 
     219 
     220} 
  • trunk/libffado/src/libavc/avc_definitions.h

    r445 r554  
    2222 */ 
    2323 
    24 #ifndef AVDDEFINITIONS_H 
    25 #define AVDDEFINITIONS_H 
     24#ifndef AVCDEFINITIONS_H 
     25#define AVCDEFINITIONS_H 
    2626 
    2727#include <libavc1394/avc1394.h> 
    2828#include <ostream> 
     29 
     30 
     31namespace AVC { 
    2932 
    3033typedef byte_t ctype_t; 
     
    8386typedef quadlet_t company_id_t; 
    8487 
     88#define AVC1394_SUBUNIT_AUDIO 1 
     89#define AVC1394_SUBUNIT_PRINTER 2 
     90#define AVC1394_SUBUNIT_CA 6 
     91#define AVC1394_SUBUNIT_PANEL 9 
     92#define AVC1394_SUBUNIT_BULLETIN_BOARD 0xA 
     93#define AVC1394_SUBUNIT_CAMERA_STORAGE 0xB 
     94#define AVC1394_SUBUNIT_MUSIC 0xC 
     95#define AVC1394_SUBUNIT_RESERVED 0x1D 
     96 
     97#define AVC1394_SUBUNIT_ID_RESERVED 0x06 
     98 
     99enum ESubunitType { 
     100    eST_Monitor       = AVC1394_SUBUNIT_VIDEO_MONITOR, 
     101    eST_Audio         = AVC1394_SUBUNIT_AUDIO, 
     102    eST_Printer       = AVC1394_SUBUNIT_PRINTER, 
     103    eST_Disc          = AVC1394_SUBUNIT_DISC_RECORDER, 
     104    eST_VCR           = AVC1394_SUBUNIT_VCR, 
     105    eST_Tuner         = AVC1394_SUBUNIT_TUNER, 
     106    eST_CA            = AVC1394_SUBUNIT_CA, 
     107    eST_Camera        = AVC1394_SUBUNIT_VIDEO_CAMERA, 
     108    eST_Panel         = AVC1394_SUBUNIT_PANEL, 
     109    eST_BulltinBoard  = AVC1394_SUBUNIT_BULLETIN_BOARD, 
     110    eST_CameraStorage = AVC1394_SUBUNIT_CAMERA_STORAGE, 
     111    eST_Music         = AVC1394_SUBUNIT_MUSIC, 
     112    eST_VendorUnique  = AVC1394_SUBUNIT_VENDOR_UNIQUE, 
     113    eST_Reserved      = AVC1394_SUBUNIT_RESERVED, 
     114    eST_Extended      = AVC1394_SUBUNIT_EXTENDED, 
     115    eST_Unit          = AVC1394_SUBUNIT_UNIT, 
     116}; 
     117 
     118enum ESubunitType byteToSubunitType(byte_t s); 
     119 
    85120/** 
    86121 * \brief the possible sampling frequencies 
     
    118153std::ostream& operator<<( std::ostream& stream, ESamplingFrequency samplingFrequency ); 
    119154 
    120 #define AVC1394_SUBUNIT_AUDIO 1 
    121 #define AVC1394_SUBUNIT_PRINTER 2 
    122 #define AVC1394_SUBUNIT_CA 6 
    123 #define AVC1394_SUBUNIT_PANEL 9 
    124 #define AVC1394_SUBUNIT_BULLETIN_BOARD 0xA 
    125 #define AVC1394_SUBUNIT_CAMERA_STORAGE 0xB 
    126 #define AVC1394_SUBUNIT_MUSIC 0xC 
    127 #define AVC1394_SUBUNIT_RESERVED 0x1D 
     155/** 
     156 * \brief Convert from a FDF SFC field value to an integer sample rate 
     157 * @param fdf fdf sfc field value 
     158 * @return sample rate 
     159 */ 
     160unsigned int fdfSfcToSampleRate(byte_t fdf); 
    128161 
    129 #define AVC1394_SUBUNIT_ID_RESERVED 0x06 
     162/** 
     163 * \brief Convert from an integer sample rate to a78 FDF SFC field value 
     164 * @param rate integer sample rate 
     165 * @return fdf sfc field value 
     166 */ 
     167byte_t sampleRateToFdfSfc(unsigned int rate); 
    130168 
    131 #endif // AVDDEFINITIONS_H 
     169
     170 
     171#endif // AVCDEFINITIONS_H 
  • trunk/libffado/src/libavc/general/avc_plug.cpp

    r548 r554  
    16631663    // FIXME: The derived class should be creating these, such that discover() can become pure virtual 
    16641664 
     1665    if ( !deser.isExisting( basePath + "m_subunitType" ) ) { 
     1666        return 0; 
     1667    } 
    16651668    Plug* pPlug = new Plug; 
    16661669    if ( !pPlug ) { 
     
    22212224                               Unit& unit ) 
    22222225{ 
     2226    if ( !deser.isExisting( basePath + "m_srcPlug" ) ) { 
     2227        return 0; 
     2228    } 
    22232229    PlugConnection* pConnection = new PlugConnection; 
    22242230    if ( !pConnection ) { 
  • trunk/libffado/src/libavc/general/avc_subunit.cpp

    r524 r554  
    242242    bool result; 
    243243    ESubunitType sbType; 
     244 
     245    if ( !deser.isExisting( basePath + "m_sbType" ) ) { 
     246        return 0; 
     247    } 
     248 
    244249    result  = deser.read( basePath + "m_sbType", sbType ); 
    245250 
  • trunk/libffado/src/libavc/general/avc_unit.cpp

    r548 r554  
    603603    } 
    604604 
    605     PlugVector digitalPCRInputPlugs = getPlugsByType( m_externalPlugs, 
     605    PlugVector digitalExternalInputPlugs = getPlugsByType( m_externalPlugs, 
    606606                                                    Plug::eAPD_Input, 
    607607                                                    Plug::eAPT_Digital ); 
     608    if ( !digitalExternalInputPlugs.size() ) { 
     609        debugOutput( DEBUG_LEVEL_VERBOSE, "No external digital input plugs found\n" ); 
     610 
     611    } 
     612     
     613    PlugVector syncExternalInputPlugs = getPlugsByType( m_externalPlugs, 
     614                                                    Plug::eAPD_Input, 
     615                                                    Plug::eAPT_Sync ); 
     616    if ( !syncExternalInputPlugs.size() ) { 
     617        debugOutput( DEBUG_LEVEL_VERBOSE, "No external sync input plugs found\n" ); 
     618 
     619    } 
    608620 
    609621    PlugVector syncMSUInputPlugs = m_pPlugManager->getPlugsByType( 
     
    639651    debugOutput( DEBUG_LEVEL_VERBOSE, "PCR Iso Output Plugs:\n" ); 
    640652    showPlugs( isoPCROutputPlugs ); 
    641     debugOutput( DEBUG_LEVEL_VERBOSE, "PCR digital Input Plugs:\n" ); 
    642     showPlugs( digitalPCRInputPlugs ); 
     653    debugOutput( DEBUG_LEVEL_VERBOSE, "External digital Input Plugs:\n" ); 
     654    showPlugs( digitalExternalInputPlugs ); 
     655    debugOutput( DEBUG_LEVEL_VERBOSE, "External sync Input Plugs:\n" ); 
     656    showPlugs( syncExternalInputPlugs ); 
    643657    debugOutput( DEBUG_LEVEL_VERBOSE, "MSU Sync Input Plugs:\n" ); 
    644658    showPlugs( syncMSUInputPlugs ); 
     
    670684                                      "Internal (CSP)" ); 
    671685 
    672     // Check all external PCR digital input to MSU input connections 
     686    // Check all external digital input to MSU input connections 
    673687    // -> SPDIF/ADAT sync 
    674     checkSyncConnectionsAndAddToList( digitalPCRInputPlugs, 
     688    checkSyncConnectionsAndAddToList( digitalExternalInputPlugs, 
     689                                      syncMSUInputPlugs, 
     690                                      "Digital Input Sync" ); 
     691 
     692    // Check all external sync input to MSU input connections 
     693    // -> SPDIF/ADAT sync 
     694    checkSyncConnectionsAndAddToList( syncExternalInputPlugs, 
    675695                                      syncMSUInputPlugs, 
    676696                                      "Digital Input Sync" ); 
     
    835855Unit::deserializeSyncInfoVector( Glib::ustring basePath, 
    836856                                     Util::IODeserialize& deser, 
    837                                      Unit& unit, 
    838857                                     SyncInfoVector& vec ) 
    839858{ 
     
    849868        Glib::ustring description; 
    850869 
    851         result  = deser.read( strstrm.str() + "m_source", sourceId ); 
    852         result &= deser.read( strstrm.str() + "m_destination", destinationId ); 
    853         result &= deser.read( strstrm.str() + "m_description", description ); 
     870        if ( deser.isExisting( strstrm.str() + "m_source" ) ) { 
     871            result  = deser.read( strstrm.str() + "m_source", sourceId ); 
     872            result &= deser.read( strstrm.str() + "m_destination", destinationId ); 
     873            result &= deser.read( strstrm.str() + "m_description", description ); 
     874        } else { 
     875            result = false; 
     876        } 
    854877 
    855878        if ( result ) { 
    856879            SyncInfo syncInfo; 
    857             syncInfo.m_source = unit.getPlugManager().getPlug( sourceId ); 
    858             syncInfo.m_destination = unit.getPlugManager().getPlug( destinationId ); 
     880            syncInfo.m_source = m_pPlugManager->getPlug( sourceId ); 
     881            syncInfo.m_destination = m_pPlugManager->getPlug( destinationId ); 
    859882            syncInfo.m_description = description; 
    860883 
     
    895918    result &= serializeVector( basePath + "PlugConnection", ser, m_plugConnections ); 
    896919    result &= serializeVector( basePath + "Subunit", ser, m_subunits ); 
    897     result &= serializeSyncInfoVector( basePath + "SyncInfo", ser, m_syncInfos ); 
     920#warning this fails after the echoaudio merge 
     921//     result &= serializeSyncInfoVector( basePath + "SyncInfo", ser, m_syncInfos ); 
    898922     
    899923    int i = 0; 
     
    915939bool 
    916940Unit::deserialize( Glib::ustring basePath, 
    917                    Unit* pDev, 
    918941                   Util::IODeserialize& deser, 
    919942                   Ieee1394Service& ieee1394Service ) 
     
    925948    setDebugLevel( verboseLevel ); 
    926949     
    927     if (pDev->m_pPlugManager) delete pDev->m_pPlugManager; 
    928     pDev->m_pPlugManager = PlugManager::deserialize( basePath + "Plug", deser, *pDev ); 
    929     if ( !pDev->m_pPlugManager ) { 
     950    if (m_pPlugManager) delete m_pPlugManager; 
     951    m_pPlugManager = PlugManager::deserialize( basePath + "Plug", deser, *this ); 
     952    if ( !m_pPlugManager ) { 
    930953        return false; 
    931954    } 
    932955     
    933     result &= deserializePlugUpdateConnections( basePath + "Plug", deser, pDev->m_pcrPlugs ); 
    934     result &= deserializePlugUpdateConnections( basePath + "Plug", deser, pDev->m_externalPlugs ); 
    935     result &= deserializeVector<PlugConnection>( basePath + "PlugConnnection", deser, *pDev, pDev->m_plugConnections ); 
    936     result &= deserializeVector<Subunit>( basePath + "Subunit",  deser, *pDev, pDev->m_subunits ); 
    937     result &= deserializeSyncInfoVector( basePath + "SyncInfo", deser, *pDev, pDev->m_syncInfos ); 
     956    result &= deserializePlugUpdateConnections( basePath + "Plug", deser, m_pcrPlugs ); 
     957    result &= deserializePlugUpdateConnections( basePath + "Plug", deser, m_externalPlugs ); 
     958    result &= deserializeVector<PlugConnection>( basePath + "PlugConnnection", deser, *this, m_plugConnections ); 
     959    result &= deserializeVector<Subunit>( basePath + "Subunit",  deser, *this, m_subunits ); 
     960    result &= deserializeSyncInfoVector( basePath + "SyncInfo", deser, m_syncInfos ); 
     961 
    938962 
    939963    unsigned int i; 
     
    941965 
    942966    if ( result ) { 
    943         if ( i < pDev->m_syncInfos.size() ) { 
    944             pDev->m_activeSyncInfo = &pDev->m_syncInfos[i]; 
     967        if ( i < m_syncInfos.size() ) { 
     968            m_activeSyncInfo = &m_syncInfos[i]; 
    945969        } 
    946970    } 
  • trunk/libffado/src/libavc/general/avc_unit.h

    r548 r554  
    9494 
    9595    bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const; 
    96     static bool deserialize( Glib::ustring basePath, Unit*
     96    bool deserialize( Glib::ustring basePath
    9797                                 Util::IODeserialize& deser, 
    9898                                 Ieee1394Service& ieee1394Service ); 
     
    151151 
    152152 
    153     static bool serializeSyncInfoVector( Glib::ustring basePath, 
     153    bool serializeSyncInfoVector( Glib::ustring basePath, 
    154154                                         Util::IOSerialize& ser, 
    155155                                         const SyncInfoVector& vec ); 
    156     static bool deserializeSyncInfoVector( Glib::ustring basePath, 
     156    bool deserializeSyncInfoVector( Glib::ustring basePath, 
    157157                                           Util::IODeserialize& deser, 
    158                                            Unit& avDevice, 
    159158                                           SyncInfoVector& vec ); 
    160159protected: 
  • trunk/libffado/src/libosc/OscClient.cpp

    r456 r554  
    7373    debugOutput(DEBUG_LEVEL_VERBOSE, "Message on: %s\n", path); 
    7474 
     75    return 0; 
    7576} 
    7677 
  • trunk/libffado/src/libstreaming/AmdtpPort.h

    r445 r554  
    5353                   enum E_Formats format) 
    5454    : AudioPort(name, direction), 
    55       AmdtpPortInfo(name, position, location, format) 
     55      AmdtpPortInfo(position, location, format) 
    5656    {}; 
    5757 
     
    8080                   enum E_Formats format) 
    8181        : MidiPort(name, direction), 
    82           AmdtpPortInfo(name, position, location, format) 
     82          AmdtpPortInfo(position, location, format) 
    8383    {}; 
    8484 
  • trunk/libffado/src/libstreaming/AmdtpPortInfo.h

    r445 r554  
    5454    }; 
    5555 
    56     AmdtpPortInfo(std::string name, int position, int location, enum E_Formats format) 
    57       : m_name(name), m_position(position), m_location(location), m_format(format) 
     56    AmdtpPortInfo( int position, int location, enum E_Formats format) 
     57      : m_position(position), m_location(location), m_format(format) 
    5858    {}; 
    5959    virtual ~AmdtpPortInfo() {}; 
    6060 
    6161 
    62     std::string getName() {return m_name;}; 
    6362    int getLocation()     {return m_location;}; 
    6463    int getPosition()     {return m_position;}; 
     
    6665 
    6766protected: 
    68     std::string m_name; 
    69  
    7067    int m_position; 
    7168    int m_location; 
  • trunk/libffado/src/libstreaming/AmdtpStreamProcessor.cpp

    r535 r554  
    756756{ 
    757757    bool ok=true; 
    758     char byte; 
     758    quadlet_t byte; 
    759759 
    760760    quadlet_t *target_event=NULL; 
     
    788788 
    789789        for(j = (dbc & 0x07)+mp->getLocation(); j < nevents; j += 8) { 
    790  
     790             
     791            quadlet_t tmpval; 
     792             
    791793            target_event=(quadlet_t *)(data + ((j * m_dimension) + mp->getPosition())); 
    792  
     794             
    793795            if(mp->canRead()) { // we can send a byte 
    794796                mp->readEvent(&byte); 
    795                 *target_event=htonl( 
     797                byte &= 0xFF; 
     798                tmpval=htonl( 
    796799                    IEC61883_AM824_SET_LABEL((byte)<<16, 
    797800                                             IEC61883_AM824_LABEL_MIDI_1X)); 
     801 
     802                debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "MIDI port %s, pos=%d, loc=%d, dbc=%d, nevents=%d, dim=%d\n", 
     803                    mp->getName().c_str(), mp->getPosition(), mp->getLocation(), dbc, nevents, m_dimension); 
     804                debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "base=%p, target=%p, value=%08X\n", 
     805                    data, target_event, tmpval); 
     806                     
    798807            } else { 
    799808                // can't send a byte, either because there is no byte, 
    800809                // or because this would exceed the maximum rate 
    801                 *target_event=htonl( 
     810                tmpval=htonl( 
    802811                    IEC61883_AM824_SET_LABEL(0,IEC61883_AM824_LABEL_MIDI_NO_DATA)); 
    803812            } 
     813             
     814            *target_event=tmpval; 
    804815        } 
    805816 
  • trunk/libffado/src/libstreaming/MotuPort.h

    r445 r554  
    5252                   int size) 
    5353    : AudioPort(name, direction), 
    54       MotuPortInfo(name, position, size) // TODO: add more port information parameters here if nescessary 
     54      MotuPortInfo( position, size) // TODO: add more port information parameters here if nescessary 
    5555    {}; 
    5656 
     
    7676                   int position) 
    7777        : MidiPort(name, direction), 
    78           MotuPortInfo(name, position, 0)  // TODO: add more port information parameters here if nescessary 
     78          MotuPortInfo(position, 0)  // TODO: add more port information parameters here if nescessary 
    7979    {}; 
    8080 
     
    101101                   int position) 
    102102        : ControlPort(name, direction), 
    103           MotuPortInfo(name, position, 2) // TODO: add more port information parameters here if nescessary 
     103          MotuPortInfo(position, 2) // TODO: add more port information parameters here if nescessary 
    104104    {}; 
    105105 
  • trunk/libffado/src/libstreaming/MotuPortInfo.h

    r445 r554  
    6060     * the name parameter is mandatory 
    6161     * 
    62      * @param name Port name 
    6362     * @param position Start position of port's data in iso event 
    6463     * @param format Format of data in iso event 
     
    6665     * @return 
    6766     */ 
    68     MotuPortInfo(std::string name, int position, int size) 
    69       : m_name(name), m_position(position), m_size(size) 
     67    MotuPortInfo( int position, int size) 
     68      : m_position(position), m_size(size) 
    7069    {}; 
    7170    virtual ~MotuPortInfo() {}; 
    7271 
    7372 
    74     std::string getName() {return m_name;}; 
    7573    int getPosition()     {return m_position;}; 
    7674    int getSize()         {return m_size;}; 
    7775 
    7876protected: 
    79     std::string m_name; 
    8077 
    8178    int m_position; 
  • trunk/libffado/src/libstreaming/Port.cpp

    r445 r554  
    3535    m_BufferType(E_PointerBuffer), 
    3636    m_disabled(true), 
    37     m_initialized(false), 
    3837    m_buffersize(0), 
    3938    m_eventsize(0), 
     
    4948    m_rate_counter(0), 
    5049    m_rate_counter_minimum(0), 
    51     m_average_ratecontrol(false) 
    52  
     50    m_average_ratecontrol(false), 
     51    m_State(E_Created) 
    5352{ 
    5453 
     
    6362 */ 
    6463bool Port::init() { 
    65     if (m_initialized) { 
    66         debugFatal("Port already initialized... (%s)\n",m_Name.c_str()); 
     64    if (m_State != E_Created) { 
     65        debugFatal("Port (%s) not in E_Created state: %d\n",m_Name.c_str(),m_State); 
    6766        return false; 
    6867    } 
     
    9897    } 
    9998 
    100     m_initialized=true; 
    101  
    10299    m_eventsize=getEventSize(); // this won't change, so cache it 
    103  
    104     return m_initialized; 
     100     
     101    m_State = E_Initialized; 
     102    return true; 
    105103} 
    106104 
     
    112110}; 
    113111 
     112void Port::show() { 
     113    debugOutput(DEBUG_LEVEL_VERBOSE,"Name          : %s\n", m_Name.c_str()); 
     114    debugOutput(DEBUG_LEVEL_VERBOSE,"Signal Type   : %d\n", m_SignalType); 
     115    debugOutput(DEBUG_LEVEL_VERBOSE,"Buffer Type   : %d\n", m_BufferType); 
     116    debugOutput(DEBUG_LEVEL_VERBOSE,"Enabled?      : %d\n", m_disabled); 
     117    debugOutput(DEBUG_LEVEL_VERBOSE,"State?        : %d\n", m_State); 
     118    debugOutput(DEBUG_LEVEL_VERBOSE,"Buffer Size   : %d\n", m_buffersize); 
     119    debugOutput(DEBUG_LEVEL_VERBOSE,"Event Size    : %d\n", m_eventsize); 
     120    debugOutput(DEBUG_LEVEL_VERBOSE,"Data Type     : %d\n", m_DataType); 
     121    debugOutput(DEBUG_LEVEL_VERBOSE,"Port Type     : %d\n", m_PortType); 
     122    debugOutput(DEBUG_LEVEL_VERBOSE,"Direction     : %d\n", m_Direction); 
     123    debugOutput(DEBUG_LEVEL_VERBOSE,"Rate Control? : %d\n", m_do_ratecontrol); 
     124} 
    114125 
    115126void Port::setVerboseLevel(int l) { 
     
    120131    debugOutput( DEBUG_LEVEL_VERBOSE, "Setting name to %s for port %s\n",name.c_str(),m_Name.c_str()); 
    121132 
    122     if (m_initialized) { 
    123         debugFatal("Port already initialized... (%s)\n",m_Name.c_str()); 
     133    if (m_State != E_Created) { 
     134        debugFatal("Port (%s) not in E_Created state: %d\n",m_Name.c_str(),m_State); 
    124135        return false; 
    125136    } 
     
    132143bool Port::setBufferSize(unsigned int newsize) { 
    133144    debugOutput( DEBUG_LEVEL_VERBOSE, "Setting buffersize to %d for port %s\n",newsize,m_Name.c_str()); 
    134     if (m_initialized) { 
    135         debugFatal("Port already initialized... (%s)\n",m_Name.c_str()); 
     145    if (m_State != E_Created) { 
     146        debugFatal("Port (%s) not in E_Created state: %d\n",m_Name.c_str(),m_State); 
    136147        return false; 
    137148    } 
     
    157168bool Port::setDataType(enum E_DataType d) { 
    158169    debugOutput( DEBUG_LEVEL_VERBOSE, "Setting datatype to %d for port %s\n",(int) d,m_Name.c_str()); 
    159     if (m_initialized) { 
    160         debugFatal("Port already initialized... (%s)\n",m_Name.c_str()); 
     170    if (m_State != E_Created) { 
     171        debugFatal("Port (%s) not in E_Created state: %d\n",m_Name.c_str(),m_State); 
    161172        return false; 
    162173    } 
     
    190201bool Port::setSignalType(enum E_SignalType s) { 
    191202    debugOutput( DEBUG_LEVEL_VERBOSE, "Setting signaltype to %d for port %s\n",(int)s,m_Name.c_str()); 
    192     if (m_initialized) { 
    193         debugFatal("Port already initialized... (%s)\n",m_Name.c_str()); 
     203    if (m_State != E_Created) { 
     204        debugFatal("Port (%s) not in E_Created state: %d\n",m_Name.c_str(),m_State); 
    194205        return false; 
    195206    } 
     
    223234bool Port::setBufferType(enum E_BufferType b) { 
    224235    debugOutput( DEBUG_LEVEL_VERBOSE, "Setting buffer type to %d for port %s\n",(int)b,m_Name.c_str()); 
    225     if (m_initialized) { 
    226         debugFatal("Port already initialized... (%s)\n",m_Name.c_str()); 
     236    if (m_State != E_Created) { 
     237        debugFatal("Port (%s) not in E_Created state: %d\n",m_Name.c_str(),m_State); 
    227238        return false; 
    228239    } 
     
    257268    // If called on an initialised stream but the request isn't for a change silently 
    258269    // allow it (relied on by C API as used by jack backend driver) 
    259     if (m_initialized && m_use_external_buffer==b) 
     270    if (m_State==E_Initialized && m_use_external_buffer==b) 
    260271        return true; 
    261272 
    262273    debugOutput( DEBUG_LEVEL_VERBOSE, "Setting external buffer use to %d for port %s\n",(int)b,m_Name.c_str()); 
    263274 
    264     if (m_initialized) { 
    265         debugFatal("Port already initialized... (%s)\n",m_Name.c_str()); 
     275    if (m_State != E_Created) { 
     276        debugFatal("Port (%s) not in E_Created state: %d\n",m_Name.c_str(),m_State); 
    266277        return false; 
    267278    } 
     
    284295/** 
    285296 * Set the external buffer address. 
    286  * only call this when specifying an external buffer before init() 
     297 * only call this when you have specified that you will use 
     298 * an external buffer before doing the init() 
    287299 * 
    288300 * @param buff 
     
    296308// buffer handling api's for ringbuffers 
    297309bool Port::writeEvent(void *event) { 
    298     assert(m_BufferType==E_RingBuffer); 
     310 
     311#ifdef DEBUG 
     312    if (m_State != E_Initialized) { 
     313        debugFatal("Port (%s) not in E_Initialized state: %d\n",m_Name.c_str(),m_State); 
     314        return false; 
     315    } 
     316     
     317    if(m_BufferType!=E_RingBuffer) { 
     318        debugError("operation not allowed on non E_RingBuffer ports\n"); 
     319        show(); 
     320        return false; 
     321    } 
    299322    assert(m_ringbuffer); 
     323#endif 
    300324 
    301325    debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "Writing event %08X with size %d to port %s\n",*((quadlet_t *)event),m_eventsize, m_Name.c_str()); 
     
    305329 
    306330bool Port::readEvent(void *event) { 
     331 
     332#ifdef DEBUG 
     333    if (m_State != E_Initialized) { 
     334        debugFatal("Port (%s) not in E_Initialized state: %d\n",m_Name.c_str(),m_State); 
     335        return false; 
     336    } 
     337     
     338    if(m_BufferType!=E_RingBuffer) { 
     339        debugError("operation not allowed on non E_RingBuffer ports\n"); 
     340        show(); 
     341        return false; 
     342    } 
    307343    assert(m_ringbuffer); 
    308  
     344#endif 
     345 
     346     
    309347    unsigned int read=ffado_ringbuffer_read(m_ringbuffer, (char *)event, m_eventsize); 
    310  
     348     
    311349    debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "Reading event %X with size %d from port %s\n",*((quadlet_t *)event),m_eventsize,m_Name.c_str()); 
     350 
     351 
    312352    return (read==m_eventsize); 
    313353} 
    314354 
    315355int Port::writeEvents(void *event, unsigned int nevents) { 
    316     assert(m_BufferType==E_RingBuffer); 
     356 
     357#ifdef DEBUG 
     358    if (m_State != E_Initialized) { 
     359        debugFatal("Port (%s) not in E_Initialized state: %d\n",m_Name.c_str(),m_State); 
     360        return false; 
     361    } 
     362     
     363    if(m_BufferType!=E_RingBuffer) { 
     364        debugError("operation not allowed on non E_RingBuffer ports\n"); 
     365        show(); 
     366        return false; 
     367    } 
    317368    assert(m_ringbuffer); 
     369#endif 
     370 
    318371 
    319372    unsigned int bytes2write=m_eventsize*nevents; 
     
    338391 
    339392int Port::readEvents(void *event, unsigned int nevents) { 
     393 
     394#ifdef DEBUG 
     395    if (m_State != E_Initialized) { 
     396        debugFatal("Port (%s) not in E_Initialized state: %d\n",m_Name.c_str(),m_State); 
     397        return false; 
     398    } 
     399    if(m_BufferType!=E_RingBuffer) { 
     400        debugError("operation not allowed on non E_RingBuffer ports\n"); 
     401        show(); 
     402        return false; 
     403    } 
    340404    assert(m_ringbuffer); 
     405#endif 
     406 
    341407 
    342408    unsigned int bytes2read=m_eventsize*nevents; 
  • trunk/libffado/src/libstreaming/Port.h

    r445 r554  
    270270    int readEvents(void *event, unsigned int nevents); ///< read multiple events 
    271271 
    272      virtual void setVerboseLevel(int l); 
    273  
     272    virtual void setVerboseLevel(int l); 
     273    virtual void show(); 
     274     
    274275protected: 
    275276    std::string m_Name; ///< Port name, [at construction] 
     
    279280 
    280281    bool m_disabled; ///< is the port disabled?, [anytime] 
    281     bool m_initialized; ///< is the port initialized? [after init()] 
    282282 
    283283    unsigned int m_buffersize; 
     
    306306 
    307307    DECLARE_DEBUG_MODULE; 
    308  
     308     
     309    // the state machine 
     310    protected: 
     311        enum EStates { 
     312            E_Created, 
     313            E_Initialized, 
     314            E_Prepared, 
     315            E_Running, 
     316            E_Error 
     317        }; 
     318 
     319        enum EStates m_State; 
    309320}; 
    310321 
  • trunk/libffado/src/libstreaming/PortManager.cpp

    r445 r554  
    2525#include "Port.h" 
    2626#include <assert.h> 
     27 
     28#include <iostream> 
     29#include <sstream> 
    2730 
    2831 
     
    5760// } 
    5861 
     62bool PortManager::makeNameUnique(Port *port) 
     63{ 
     64    bool done=false; 
     65    int idx=0; 
     66    std::string portname_orig=port->getName(); 
     67     
     68    while(!done && idx<10000) { 
     69        bool is_unique=true; 
     70         
     71        for ( PortVectorIterator it = m_Ports.begin(); 
     72        it != m_Ports.end(); 
     73        ++it ) 
     74        { 
     75            is_unique &= !((*it)->getName() == port->getName()); 
     76        } 
     77         
     78        if (is_unique) { 
     79            done=true; 
     80        } else { 
     81            std::ostringstream portname; 
     82            portname << portname_orig << idx++; 
     83             
     84            port->setName(portname.str()); 
     85        } 
     86    } 
     87     
     88    if(idx<10000) return true; 
     89    else return false; 
     90} 
     91 
    5992/** 
    6093 * 
     
    6699    assert(port); 
    67100 
    68     debugOutput( DEBUG_LEVEL_VERBOSE, "Adding port %s\n",port->getName().c_str()); 
    69     m_Ports.push_back(port); 
    70  
    71     return true; 
     101    debugOutput( DEBUG_LEVEL_VERBOSE, "Adding port %s, type: %d, dir: %d, dtype: %d\n", 
     102        port->getName().c_str(), port->getPortType(), port->getDirection(), port->getDataType()); 
     103     
     104    if (makeNameUnique(port)) { 
     105        m_Ports.push_back(port); 
     106        return true; 
     107    } else { 
     108        return false; 
     109    } 
    72110} 
    73111 
  • trunk/libffado/src/libstreaming/PortManager.h

    r445 r554  
    4848    virtual ~PortManager(); 
    4949 
     50    virtual bool makeNameUnique(Port *port); 
    5051    virtual bool addPort(Port *port); 
    5152    virtual bool deletePort(Port *port); 
  • trunk/libffado/src/libutil/TimestampedBuffer.h

    r512 r554  
    1 /* $Id$ */ 
    2  
    31/* 
    42 *   FFADO Streaming API 
  • trunk/libffado/src/Makefile.am

    r529 r554  
    4949        libieee1394/IEC61883.h \ 
    5050        debugmodule/debugmodule.h \ 
    51         devicemanager.h fbtypes.h iavdevice.h threads.h bebob/bebob_avdevice.h \ 
     51        devicemanager.h fbtypes.h ffadodevice.h threads.h bebob/bebob_avdevice.h \ 
    5252        bebob/bebob_avdevice_subunit.h bebob/bebob_avplug.h bebob/bebob_dl_bcd.h bebob/bebob_dl_codes.h \ 
    5353        bebob/bebob_dl_mgr.h bebob/bebob_functionblock.h bounce/bounce_avdevice.h bounce/bounce_slave_avdevice.h bebob/bebob_configparser.h \ 
     
    5555        maudio/maudio_avdevice.h motu/motu_avdevice.h rme/rme_avdevice.h \ 
    5656        metrichalo/mh_avdevice.h dice/dice_avdevice.h \ 
    57         libavc/avc_connect.h \ 
    58         libavc/avc_definitions.h libavc/avc_extended_cmd_generic.h \ 
    59         libavc/avc_extended_plug_info.h libavc/avc_extended_stream_format.h \ 
    60         libavc/avc_extended_subunit_info.h libavc/avc_function_block.h libavc/avc_generic.h \ 
    61         libavc/avc_plug_info.h libavc/avc_serialize.h libavc/avc_signal_source.h \ 
    62         libavc/avc_subunit_info.h libavc/avc_unit_info.h \ 
     57        genericavc/avc_avdevice.h \ 
     58        libavc/streamformat/avc_extended_stream_format.h \ 
     59        libavc/util/avc_serialize.h \ 
     60        libavc/musicsubunit/avc_descriptor_music.h \ 
     61        libavc/musicsubunit/avc_musicsubunit.h \ 
     62        libavc/audiosubunit/avc_audiosubunit.h \ 
     63        libavc/audiosubunit/avc_function_block.h \ 
     64        libavc/descriptors/avc_descriptor_cmd.h \ 
     65        libavc/descriptors/avc_descriptor.h \ 
     66        libavc/general/avc_plug_info.h \ 
     67        libavc/general/avc_subunit_info.h \ 
     68        libavc/general/avc_extended_cmd_generic.h \ 
     69        libavc/general/avc_extended_subunit_info.h \ 
     70        libavc/general/avc_unit_info.h \ 
     71        libavc/general/avc_generic.h \ 
     72        libavc/general/avc_connect.h \ 
     73        libavc/general/avc_signal_format.h \ 
     74        libavc/general/avc_extended_plug_info.h \ 
     75        libavc/general/avc_unit.h \ 
     76        libavc/general/avc_subunit.h \ 
     77        libavc/general/avc_plug.h \ 
     78        libavc/avc_definitions.h \ 
     79        libavc/ccm/avc_signal_source.h \ 
    6380        libosc/OscArgument.h libosc/OscNode.h libosc/OscResponse.h libosc/OscServer.h libosc/OscMessage.h \ 
    6481        libosc/OscClient.h \ 
     
    7895# common sources 
    7996libffado_la_SOURCES = \ 
    80             devicemanager.cpp \ 
    81             ffado.cpp \ 
    82             ffado_streaming.cpp \ 
    83             iavdevice.cpp \ 
    84             debugmodule/debugmodule.cpp \ 
    85             libavc/avc_connect.cpp \ 
    86             libavc/avc_definitions.cpp \ 
    87             libavc/avc_extended_cmd_generic.cpp \ 
    88             libavc/avc_extended_plug_info.cpp \ 
    89             libavc/avc_extended_stream_format.cpp \ 
    90             libavc/avc_extended_subunit_info.cpp \ 
    91             libavc/avc_function_block.cpp \ 
    92             libavc/avc_generic.cpp \ 
    93             libavc/avc_plug_info.cpp \ 
    94             libavc/avc_serialize.cpp \ 
    95             libavc/avc_signal_source.cpp \ 
    96             libavc/avc_subunit_info.cpp \ 
    97             libavc/avc_unit_info.cpp \ 
    98             libieee1394/ARMHandler.cpp \ 
    99             libieee1394/configrom.cpp \ 
    100             libieee1394/csr1212.c \ 
    101             libieee1394/ieee1394service.cpp \ 
    102             libieee1394/IEC61883.cpp \ 
    103             libosc/OscArgument.cpp \ 
    104             libosc/OscClient.cpp \ 
    105             libosc/OscMessage.cpp \ 
    106             libosc/OscNode.cpp \ 
    107             libosc/OscResponse.cpp \ 
    108             libosc/OscServer.cpp \ 
    109             libstreaming/cip.c \ 
    110             libstreaming/IsoHandler.cpp \ 
    111             libstreaming/IsoHandlerManager.cpp \ 
    112             libstreaming/IsoStream.cpp \ 
    113             libstreaming/Port.cpp \ 
    114             libstreaming/PortManager.cpp \ 
    115             libstreaming/StreamProcessor.cpp \ 
    116             libstreaming/StreamProcessorManager.cpp \ 
    117             libutil/DelayLockedLoop.cpp \ 
    118             libutil/PacketBuffer.cpp \ 
    119             libutil/OptionContainer.cpp \ 
    120             libutil/PosixThread.cpp \ 
    121             libutil/ringbuffer.c \ 
    122             libutil/serialize.cpp \ 
    123             libutil/StreamStatistics.cpp \ 
    124             libutil/SystemTimeSource.cpp \ 
    125             libutil/Time.c \ 
    126             libutil/TimeSource.cpp \ 
    127             libutil/TimestampedBuffer.cpp 
     97        devicemanager.cpp \ 
     98        ffado.cpp \ 
     99        ffado_streaming.cpp \ 
     100        ffadodevice.cpp \ 
     101        debugmodule/debugmodule.cpp \ 
     102        libavc/streamformat/avc_extended_stream_format.cpp \ 
     103        libavc/util/avc_serialize.cpp \ 
     104        libavc/musicsubunit/avc_descriptor_music.cpp \ 
     105        libavc/musicsubunit/avc_musicsubunit.cpp \ 
     106        libavc/audiosubunit/avc_audiosubunit.cpp \ 
     107        libavc/audiosubunit/avc_function_block.cpp \ 
     108        libavc/descriptors/avc_descriptor_cmd.cpp \ 
     109        libavc/descriptors/avc_descriptor.cpp \ 
     110        libavc/general/avc_extended_subunit_info.cpp \ 
     111        libavc/general/avc_unit_info.cpp \ 
     112        libavc/general/avc_generic.cpp \ 
     113        libavc/general/avc_subunit_info.cpp \ 
     114        libavc/general/avc_connect.cpp \ 
     115        libavc/general/avc_signal_format.cpp \ 
     116        libavc/general/avc_extended_cmd_generic.cpp \ 
     117        libavc/general/avc_extended_plug_info.cpp \ 
     118        libavc/general/avc_plug_info.cpp \ 
     119        libavc/general/avc_unit.cpp \ 
     120        libavc/general/avc_subunit.cpp \ 
     121        libavc/general/avc_plug.cpp \ 
     122        libavc/avc_definitions.cpp \ 
     123        libavc/ccm/avc_signal_source.cpp \ 
     124        libieee1394/ARMHandler.cpp \ 
     125        libieee1394/configrom.cpp \ 
     126        libieee1394/csr1212.c \ 
     127        libieee1394/ieee1394service.cpp \ 
     128        libieee1394/IEC61883.cpp \ 
     129        libosc/OscArgument.cpp \ 
     130        libosc/OscClient.cpp \ 
     131        libosc/OscMessage.cpp \ 
     132        libosc/OscNode.cpp \ 
     133        libosc/OscResponse.cpp \ 
     134        libosc/OscServer.cpp \ 
     135        libstreaming/cip.c \ 
     136        libstreaming/IsoHandler.cpp \ 
     137        libstreaming/IsoHandlerManager.cpp \ 
     138        libstreaming/IsoStream.cpp \ 
     139        libstreaming/Port.cpp \ 
     140        libstreaming/PortManager.cpp \ 
     141        libstreaming/StreamProcessor.cpp \ 
     142        libstreaming/StreamProcessorManager.cpp \ 
     143        libutil/DelayLockedLoop.cpp \ 
     144        libutil/PacketBuffer.cpp \ 
     145        libutil/OptionContainer.cpp \ 
     146        libutil/PosixThread.cpp \ 
     147        libutil/ringbuffer.c \ 
     148        libutil/serialize.cpp \ 
     149        libutil/StreamStatistics.cpp \ 
     150        libutil/SystemTimeSource.cpp \ 
     151        libutil/Time.c \ 
     152        libutil/TimeSource.cpp \ 
     153        libutil/TimestampedBuffer.cpp 
    128154 
    129155# class specific sources 
     
    140166            maudio/maudio_avdevice.cpp 
    141167 
     168genericavc_src = \ 
     169            genericavc/avc_avdevice.cpp 
     170 
    142171motu_src = \ 
    143172            motu/motu_avdevice.cpp \ 
     
    216245endif 
    217246 
     247if BUILD_GENERICAVC 
     248libffado_la_SOURCES += $(genericavc_src) 
     249bin_PROGRAMS += $(genericavc_bin) 
     250noinst_PROGRAMS += $(genericavc_noinst) 
     251nobase_dist_pkgdata_DATA += $(genericavc_pkgdata) 
     252endif 
     253 
    218254if BUILD_BOUNCE 
    219255libffado_la_SOURCES += $(bounce_src) 
  • trunk/libffado/src/maudio/maudio_avdevice.cpp

    r479 r554  
    112112 
    113113bool 
    114 AvDevice::setSamplingFrequency( ESamplingFrequency eSamplingFrequency ) 
     114AvDevice::setSamplingFrequency( int eSamplingFrequency ) 
    115115{ 
    116116    // not supported 
  • trunk/libffado/src/maudio/maudio_avdevice.h

    r516 r554  
    2828#include "debugmodule/debugmodule.h" 
    2929#include "libavc/avc_definitions.h" 
    30 #include "libavc/avc_extended_cmd_generic.h" 
     30#include "libavc/general/avc_extended_cmd_generic.h" 
    3131 
    3232#include "bebob/bebob_avdevice.h" 
     
    3636#include "libstreaming/AmdtpPortInfo.h" 
    3737 
    38 #include "iavdevice.h" 
     38#include "ffadodevice.h" 
    3939 
    4040class ConfigRom; 
     
    6464    virtual void showDevice(); 
    6565 
    66     virtual bool setSamplingFrequency( ESamplingFrequency samplingFrequency ); 
     66    virtual bool setSamplingFrequency( int ); 
    6767    virtual int getSamplingFrequency( ); 
    6868 
  • trunk/libffado/src/metrichalo/mh_avdevice.cpp

    r479 r554  
    5353                    Ieee1394Service& ieee1394service, 
    5454                    int nodeId ) 
    55     :  IAvDevice( configRom, ieee1394service, nodeId ) 
     55    :  FFADODevice( configRom, ieee1394service, nodeId ) 
    5656    , m_model( NULL ) 
    5757 
     
    125125 
    126126bool 
    127 MHAvDevice::setSamplingFrequency( ESamplingFrequency samplingFrequency ) 
     127MHAvDevice::setSamplingFrequency( int samplingFrequency ) 
    128128{ 
    129129 
  • trunk/libffado/src/metrichalo/mh_avdevice.h

    r516 r554  
    2525#define MHDEVICE_H 
    2626 
    27 #include "iavdevice.h" 
     27#include "ffadodevice.h" 
    2828 
    2929#include "debugmodule/debugmodule.h" 
     
    4545}; 
    4646 
    47 class MHAvDevice : public IAvDevice { 
     47class MHAvDevice : public FFADODevice { 
    4848public: 
    4949    MHAvDevice( std::auto_ptr<ConfigRom>( configRom ), 
     
    5858    virtual void showDevice(); 
    5959 
    60     virtual bool setSamplingFrequency( ESamplingFrequency samplingFrequency ); 
     60    virtual bool setSamplingFrequency( int ); 
    6161    virtual int getSamplingFrequency( ); 
    6262 
  • trunk/libffado/src/motu/motu_avdevice.cpp

    r480 r554  
    5959                    Ieee1394Service& ieee1394service, 
    6060                    int nodeId) 
    61     : IAvDevice( configRom, ieee1394service, nodeId ) 
     61    : FFADODevice( configRom, ieee1394service, nodeId ) 
    6262    , m_motu_model( MOTUFW_MODEL_NONE ) 
    6363    , m_iso_recv_channel ( -1 ) 
     
    177177 
    178178bool 
    179 MotuDevice::setSamplingFrequency( ESamplingFrequency samplingFrequency ) 
     179MotuDevice::setSamplingFrequency( int samplingFrequency ) 
    180180{ 
    181181/* 
     
    187187 
    188188    switch ( samplingFrequency ) { 
    189         case eSF_22050Hz
     189        case 22050
    190190            supported=false; 
    191191            break; 
    192         case eSF_24000Hz
     192        case 24000
    193193            supported=false; 
    194194            break; 
    195         case eSF_32000Hz
     195        case 32000
    196196            supported=false; 
    197197            break; 
    198         case eSF_44100Hz
     198        case 44100
    199199            new_rate = MOTUFW_RATE_BASE_44100 | MOTUFW_RATE_MULTIPLIER_1X; 
    200200            break; 
    201         case eSF_48000Hz
     201        case 48000
    202202            new_rate = MOTUFW_RATE_BASE_48000 | MOTUFW_RATE_MULTIPLIER_1X; 
    203203            break; 
    204         case eSF_88200Hz
     204        case 88200
    205205            new_rate = MOTUFW_RATE_BASE_44100 | MOTUFW_RATE_MULTIPLIER_2X; 
    206206            break; 
    207         case eSF_96000Hz
     207        case 96000
    208208            new_rate = MOTUFW_RATE_BASE_48000 | MOTUFW_RATE_MULTIPLIER_2X; 
    209209            break; 
    210         case eSF_176400Hz
     210        case 176400
    211211            // Currently only the Traveler supports 4x sample rates 
    212212            if (m_motu_model == MOTUFW_MODEL_TRAVELER) { 
     
    216216                supported=false; 
    217217            break; 
    218         case eSF_192000Hz
     218        case 192000
    219219            // Currently only the Traveler supports 4x sample rates 
    220220            if (m_motu_model == MOTUFW_MODEL_TRAVELER) { 
  • trunk/libffado/src/motu/motu_avdevice.h

    r516 r554  
    2626#define MOTUDEVICE_H 
    2727 
    28 #include "iavdevice.h" 
     28#include "ffadodevice.h" 
    2929 
    3030#include "debugmodule/debugmodule.h" 
     
    9191}; 
    9292 
    93 class MotuDevice : public IAvDevice { 
     93class MotuDevice : public FFADODevice { 
    9494public: 
    9595 
     
    105105    virtual void showDevice(); 
    106106 
    107     virtual bool setSamplingFrequency( ESamplingFrequency samplingFrequency ); 
     107    virtual bool setSamplingFrequency( int samplingFrequency ); 
    108108    virtual int getSamplingFrequency( ); 
    109109 
  • trunk/libffado/src/rme/rme_avdevice.cpp

    r479 r554  
    5353                    Ieee1394Service& ieee1394service, 
    5454                    int nodeId ) 
    55     : IAvDevice( configRom, ieee1394service, nodeId ) 
     55    : FFADODevice( configRom, ieee1394service, nodeId ) 
    5656    , m_model( NULL ) 
    5757{ 
     
    128128 
    129129bool 
    130 RmeDevice::setSamplingFrequency( ESamplingFrequency samplingFrequency ) 
     130RmeDevice::setSamplingFrequency( int samplingFrequency ) 
    131131{ 
    132132/* 
    133133 * Set the RME device's samplerate. 
    134134 */ 
    135         if (samplingFrequency == eSF_48000Hz
     135        if (samplingFrequency == 48000
    136136                return true; 
    137137        return false; 
  • trunk/libffado/src/rme/rme_avdevice.h

    r516 r554  
    2626#define RMEDEVICE_H 
    2727 
    28 #include "iavdevice.h" 
     28#include "ffadodevice.h" 
    2929 
    3030#include "debugmodule/debugmodule.h" 
     
    4646}; 
    4747 
    48 class RmeDevice : public IAvDevice { 
     48class RmeDevice : public FFADODevice { 
    4949public: 
    5050 
     
    6060    virtual void showDevice(); 
    6161 
    62     virtual bool setSamplingFrequency( ESamplingFrequency samplingFrequency ); 
     62    virtual bool setSamplingFrequency( int samplingFrequency ); 
    6363    virtual int getSamplingFrequency( ); 
    6464 
  • trunk/libffado/tests/Makefile.am

    r532 r554  
    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 
  • trunk/libffado/tests/streaming/testmidistreaming1.c

    r532 r554  
    128128 
    129129int encode_midi_bytes(ffado_midi_port_t *port, unsigned char *byte_buff, int len) { 
    130         return 0; 
     130    static int cnt=0; 
     131    cnt++; 
     132    if (cnt>64) { 
     133        *byte_buff=0xFF; 
     134        return 1; 
     135    } 
     136    return 0; 
    131137} 
    132138 
     
    134140{ 
    135141 
    136         #define PERIOD_SIZE 512 
     142        #define PERIOD_SIZE 1024 
    137143 
    138144        int samplesread=0, sampleswritten=0; 
     
    387393                                break; 
    388394                        case ffado_stream_type_midi: 
    389                                 samplesread=ffado_streaming_read(dev, i, audiobuffers_in[i], PERIOD_SIZE); 
     395                                samplesread=ffado_streaming_read(dev, i, audiobuffers_in[i], 64); 
    390396                                quadlet_t *buff=(quadlet_t *)audiobuffers_in[i]; 
     397                                if (samplesread) printf("RECV (CH %02X): ", i); 
    391398                                for (s=0;s<samplesread;s++) { 
    392399                                        quadlet_t *byte=(buff+s) ; 
    393 //                                    printf("%08X ",*byte); 
     400                                      printf("%08X ",*byte); 
    394401                                        decode_midi_byte (midi_in_portmap[i], (*byte) & 0xFF); 
    395402                                } 
     403                                if (samplesread) printf("\n"); 
    396404                                if(samplesread>0) { 
    397405                                        fprintf(fid_in[i], "---- Period read (%d samples) ----\n",samplesread); 
     
    428436                                 
    429437                                sampleswritten=encode_midi_bytes(midi_out_portmap[i], byte_buff, max_midi_bytes_to_write); 
    430                                  
     438                                if (sampleswritten) printf("SEND (CH %02X): ", i); 
    431439                                for(b=0;b<sampleswritten;b++) { 
    432440                                        ffado_sample_t tmp_event=*(byte_buff+b); 
     441                                        printf("%08X ",*(byte_buff+b)); 
    433442                                        ffado_streaming_write(dev, i, &tmp_event, 1); 
    434443                                } 
    435                                  
    436                                  
     444                                if (sampleswritten) printf("\n"); 
     445 
    437446                                fprintf(fid_out[i], "---- Period write (%d samples) ----\n",sampleswritten); 
    438447                                hexDumpToFile(fid_out[i],(unsigned char*)buff,sampleswritten*sizeof(ffado_sample_t)); 
  • trunk/libffado/tests/streaming/teststreaming.c

    r532 r554  
    8484        dev_options.realtime=1; 
    8585        dev_options.packetizer_priority=60; 
    86          
     86 
    8787        dev_options.directions=0; 
    8888         
     
    9393     
    9494        ffado_device_t *dev=ffado_streaming_init(&device_info, dev_options); 
     95 
    9596        if (!dev) { 
    9697                fprintf(stderr,"Could not init FFADO Streaming layer\n"); 
     
    173174                } 
    174175 
    175               ffado_streaming_transfer_buffers(dev); 
     176//            ffado_streaming_transfer_buffers(dev); 
    176177                ffado_streaming_transfer_capture_buffers(dev); 
    177178                ffado_streaming_transfer_playback_buffers(dev); 
  • trunk/libffado/tests/streaming/teststreaming2.c

    r532 r554  
    282282 
    283283        ffado_streaming_finish(dev); 
    284 fclose(of); 
     284       fclose(of); 
    285285 
    286286        for (i=0;i<nb_out_channels;i++) { 
  • trunk/libffado/tests/streaming/teststreaming3.c

    r532 r554  
    9999         
    100100        ffado_device_t *dev=ffado_streaming_init(&device_info, dev_options); 
     101 
    101102        if (!dev) { 
    102103                fprintf(stderr,"Could not init Ffado Streaming layer\n"); 
  • trunk/libffado/tests/test-ffado.cpp

    r445 r554  
    3434#include "fbtypes.h" 
    3535#include "devicemanager.h" 
    36 #include "iavdevice.h" 
     36#include "ffadodevice.h" 
    3737 
    3838#include <signal.h> 
     
    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); 
     234        } 
     235        if ( arguments.verbose ) { 
     236            m_deviceManager->setVerboseLevel(arguments.verbose); 
    225237        } 
    226238        if ( !m_deviceManager->initialize( arguments.port ) ) { 
    227239            fprintf( stderr, "Could not initialize device manager\n" ); 
    228240            delete m_deviceManager; 
    229             return -1
     241            return exitfunction(-1)
    230242        } 
    231243        if ( arguments.verbose ) { 
     
    235247            fprintf( stderr, "Could not discover devices\n" ); 
    236248            delete m_deviceManager; 
    237             return -1
     249            return exitfunction(-1)
    238250        } 
    239251        delete m_deviceManager; 
    240         return 0
     252        return exitfunction(0)
    241253    } else if ( strcmp( arguments.args[0], "SetSamplerate" ) == 0 ) { 
    242254        char* tail; 
     
    244256        if ( errno ) { 
    245257            fprintf( stderr,  "Could not parse samplerate argument\n" ); 
    246             return -1
     258            return exitfunction(-1)
    247259        } 
    248260 
     
    250262        if ( !m_deviceManager ) { 
    251263            fprintf( stderr, "Could not allocate device manager\n" ); 
    252             return -1; 
     264            return exitfunction(-1); 
     265        } 
     266        if ( arguments.verbose ) { 
     267            m_deviceManager->setVerboseLevel(arguments.verbose); 
    253268        } 
    254269        if ( !m_deviceManager->initialize( arguments.port ) ) { 
    255270            fprintf( stderr, "Could not initialize device manager\n" ); 
    256271            delete m_deviceManager; 
    257             return -1
     272            return exitfunction(-1)
    258273        } 
    259274        if ( arguments.verbose ) { 
     
    263278            fprintf( stderr, "Could not discover devices\n" ); 
    264279            delete m_deviceManager; 
    265             return -1
     280            return exitfunction(-1)
    266281        } 
    267282 
    268283        if(arguments.node_id_set) { 
    269             IAvDevice* avDevice = m_deviceManager->getAvDevice( arguments.node_id ); 
     284            FFADODevice* avDevice = m_deviceManager->getAvDevice( arguments.node_id ); 
    270285            if ( avDevice ) { 
    271                 if ( avDevice->setSamplingFrequency( parseSampleRate( samplerate ) ) ) { 
     286                if ( avDevice->setSamplingFrequency( samplerate ) ) { 
    272287                    m_deviceManager->discover(); 
    273288                } else { 
     
    284299                int node_id=m_deviceManager->getDeviceNodeId(i); 
    285300                printf("  set samplerate for device = %d, node = %d\n", i, node_id); 
    286                 IAvDevice* avDevice = m_deviceManager->getAvDevice( node_id ); 
     301                FFADODevice* avDevice = m_deviceManager->getAvDevice( node_id ); 
    287302                if ( avDevice ) { 
    288                     if ( !avDevice->setSamplingFrequency( parseSampleRate( samplerate ) ) ) { 
     303                    if ( !avDevice->setSamplingFrequency( samplerate ) ) { 
    289304                        fprintf( stderr, "Could not set samplerate\n" ); 
    290305                    } 
     
    293308        } 
    294309        delete m_deviceManager; 
    295         return 0
     310        return exitfunction(0)
    296311    } else if ( strcmp( arguments.args[0], "ListOscSpace" ) == 0 ) { 
    297312        // list osc space by using OSC messages 
     
    314329        if ( !m_deviceManager ) { 
    315330            fprintf( stderr, "Could not allocate device manager\n" ); 
    316             return -1
     331            return exitfunction(-1)
    317332        } 
    318333        if ( !m_deviceManager->initialize( arguments.port ) ) { 
    319334            fprintf( stderr, "Could not initialize device manager\n" ); 
    320335            delete m_deviceManager; 
    321             return -1
     336            return exitfunction(-1)
    322337        } 
    323338        if ( arguments.verbose ) { 
     
    327342            fprintf( stderr, "Could not discover devices\n" ); 
    328343            delete m_deviceManager; 
    329             return -1
     344            return exitfunction(-1)
    330345        } 
    331346 
     
    345360        printf("server stopped\n"); 
    346361        delete m_deviceManager; 
    347         return 0
     362        return exitfunction(0)
    348363 
    349364    } else {