Changeset 554
- Timestamp:
- 08/22/07 10:15:34 (16 years ago)
- Files:
-
- trunk/libffado/configure.ac (modified) (5 diffs)
- trunk/libffado/src/bebob-sync.cpp (modified) (2 diffs)
- trunk/libffado/src/bebob/bebob_avdevice.cpp (modified) (20 diffs)
- trunk/libffado/src/bebob/bebob_avdevice.h (modified) (6 diffs)
- trunk/libffado/src/bebob/bebob_avdevice_subunit.cpp (modified) (17 diffs)
- trunk/libffado/src/bebob/bebob_avdevice_subunit.h (modified) (3 diffs)
- trunk/libffado/src/bebob/bebob_avplug.cpp (modified) (28 diffs)
- trunk/libffado/src/bebob/bebob_avplug.h (modified) (3 diffs)
- trunk/libffado/src/bebob/bebob_dl_codes.cpp (modified) (1 diff)
- trunk/libffado/src/bebob/bebob_dl_codes.h (modified) (10 diffs)
- trunk/libffado/src/bebob/bebob_dl_mgr.cpp (modified) (1 diff)
- trunk/libffado/src/bebob/bebob_functionblock.cpp (modified) (39 diffs)
- trunk/libffado/src/bebob/bebob_functionblock.h (modified) (8 diffs)
- trunk/libffado/src/bebob/GenericMixer.cpp (modified) (2 diffs)
- trunk/libffado/src/bounce/bounce_avdevice.cpp (modified) (3 diffs)
- trunk/libffado/src/bounce/bounce_avdevice.h (modified) (4 diffs)
- trunk/libffado/src/debugmodule/debugmodule.cpp (modified) (9 diffs)
- trunk/libffado/src/debugmodule/debugmodule.h (modified) (4 diffs)
- trunk/libffado/src/devicemanager.cpp (modified) (23 diffs)
- trunk/libffado/src/devicemanager.h (modified) (4 diffs)
- trunk/libffado/src/dice/dice_avdevice.cpp (modified) (12 diffs)
- trunk/libffado/src/dice/dice_avdevice.h (modified) (4 diffs)
- trunk/libffado/src/ffado.cpp (modified) (3 diffs)
- trunk/libffado/src/ffadodevice.cpp (copied) (copied from branches/echoaudio/src/ffadodevice.cpp) (1 diff)
- trunk/libffado/src/ffadodevice.h (copied) (copied from branches/echoaudio/src/ffadodevice.h) (1 diff)
- trunk/libffado/src/ffado_streaming.cpp (modified) (6 diffs)
- trunk/libffado/src/genericavc (copied) (copied from branches/echoaudio/src/genericavc)
- trunk/libffado/src/iavdevice.cpp (deleted)
- trunk/libffado/src/iavdevice.h (deleted)
- trunk/libffado/src/libavc/audiosubunit (copied) (copied from branches/echoaudio/src/libavc/audiosubunit)
- trunk/libffado/src/libavc/avc_connect.cpp (deleted)
- trunk/libffado/src/libavc/avc_connect.h (deleted)
- trunk/libffado/src/libavc/avc_definitions.cpp (modified) (2 diffs)
- trunk/libffado/src/libavc/avc_definitions.h (modified) (3 diffs)
- trunk/libffado/src/libavc/avc_extended_cmd_generic.cpp (deleted)
- trunk/libffado/src/libavc/avc_extended_cmd_generic.h (deleted)
- trunk/libffado/src/libavc/avc_extended_plug_info.cpp (deleted)
- trunk/libffado/src/libavc/avc_extended_plug_info.h (deleted)
- trunk/libffado/src/libavc/avc_extended_stream_format.cpp (deleted)
- trunk/libffado/src/libavc/avc_extended_stream_format.h (deleted)
- trunk/libffado/src/libavc/avc_extended_subunit_info.cpp (deleted)
- trunk/libffado/src/libavc/avc_extended_subunit_info.h (deleted)
- trunk/libffado/src/libavc/avc_function_block.cpp (deleted)
- trunk/libffado/src/libavc/avc_function_block.h (deleted)
- trunk/libffado/src/libavc/avc_generic.cpp (deleted)
- trunk/libffado/src/libavc/avc_generic.h (deleted)
- trunk/libffado/src/libavc/avc_plug_info.cpp (deleted)
- trunk/libffado/src/libavc/avc_plug_info.h (deleted)
- trunk/libffado/src/libavc/avc_serialize.cpp (deleted)
- trunk/libffado/src/libavc/avc_serialize.h (deleted)
- trunk/libffado/src/libavc/avc_signal_source.cpp (deleted)
- trunk/libffado/src/libavc/avc_signal_source.h (deleted)
- trunk/libffado/src/libavc/avc_subunit_info.cpp (deleted)
- trunk/libffado/src/libavc/avc_subunit_info.h (deleted)
- trunk/libffado/src/libavc/avc_unit_info.cpp (deleted)
- trunk/libffado/src/libavc/avc_unit_info.h (deleted)
- trunk/libffado/src/libavc/ccm (copied) (copied from branches/echoaudio/src/libavc/ccm)
- trunk/libffado/src/libavc/descriptors (copied) (copied from branches/echoaudio/src/libavc/descriptors)
- trunk/libffado/src/libavc/general (copied) (copied from branches/echoaudio/src/libavc/general)
- trunk/libffado/src/libavc/general/avc_plug.cpp (modified) (2 diffs)
- trunk/libffado/src/libavc/general/avc_subunit.cpp (modified) (1 diff)
- trunk/libffado/src/libavc/general/avc_unit.cpp (modified) (9 diffs)
- trunk/libffado/src/libavc/general/avc_unit.h (modified) (2 diffs)
- trunk/libffado/src/libavc/musicsubunit (copied) (copied from branches/echoaudio/src/libavc/musicsubunit)
- trunk/libffado/src/libavc/streamformat (copied) (copied from branches/echoaudio/src/libavc/streamformat)
- trunk/libffado/src/libavc/util (copied) (copied from branches/echoaudio/src/libavc/util)
- trunk/libffado/src/libosc/OscClient.cpp (modified) (1 diff)
- trunk/libffado/src/libstreaming/AmdtpPort.h (modified) (2 diffs)
- trunk/libffado/src/libstreaming/AmdtpPortInfo.h (modified) (2 diffs)
- trunk/libffado/src/libstreaming/AmdtpStreamProcessor.cpp (modified) (2 diffs)
- trunk/libffado/src/libstreaming/MotuPort.h (modified) (3 diffs)
- trunk/libffado/src/libstreaming/MotuPortInfo.h (modified) (2 diffs)
- trunk/libffado/src/libstreaming/Port.cpp (modified) (15 diffs)
- trunk/libffado/src/libstreaming/Port.h (modified) (3 diffs)
- trunk/libffado/src/libstreaming/PortManager.cpp (modified) (3 diffs)
- trunk/libffado/src/libstreaming/PortManager.h (modified) (1 diff)
- trunk/libffado/src/libutil/TimestampedBuffer.h (modified) (1 diff)
- trunk/libffado/src/Makefile.am (modified) (5 diffs)
- trunk/libffado/src/maudio/maudio_avdevice.cpp (modified) (1 diff)
- trunk/libffado/src/maudio/maudio_avdevice.h (modified) (3 diffs)
- trunk/libffado/src/metrichalo/mh_avdevice.cpp (modified) (2 diffs)
- trunk/libffado/src/metrichalo/mh_avdevice.h (modified) (3 diffs)
- trunk/libffado/src/motu/motu_avdevice.cpp (modified) (4 diffs)
- trunk/libffado/src/motu/motu_avdevice.h (modified) (3 diffs)
- trunk/libffado/src/rme/rme_avdevice.cpp (modified) (2 diffs)
- trunk/libffado/src/rme/rme_avdevice.h (modified) (3 diffs)
- trunk/libffado/tests/Makefile.am (modified) (2 diffs)
- trunk/libffado/tests/streaming/testmidistreaming1.c (modified) (4 diffs)
- trunk/libffado/tests/streaming/teststreaming.c (modified) (3 diffs)
- trunk/libffado/tests/streaming/teststreaming2.c (modified) (1 diff)
- trunk/libffado/tests/streaming/teststreaming3.c (modified) (1 diff)
- trunk/libffado/tests/test-echo.cpp (added)
- trunk/libffado/tests/test-ffado.cpp (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libffado/configure.ac
r511 r554 26 26 m4_define(ffado_major_version, 1) 27 27 m4_define(ffado_minor_version, 999) 28 m4_define(ffado_micro_version, 5)28 m4_define(ffado_micro_version, 6) 29 29 30 30 m4_define(ffado_version, ffado_major_version.ffado_minor_version.ffado_micro_version) … … 217 217 [build_bebob=true]) 218 218 219 dnl --- Build Generic AV/C code (Apple class driver compatible)? 220 221 AC_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) ;; 228 esac], 229 [build_genericavc=true]) 230 219 231 dnl --- Build Motu code? 220 232 … … 312 324 if test "${build_all}" = true; then 313 325 build_bebob=true 326 build_genericavc=true 314 327 build_motu=true 315 328 build_dice=true … … 328 341 fi; 329 342 343 if 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 348 fi; 349 330 350 if test "${build_motu}" = true; then 331 351 CFLAGS="$CFLAGS -DENABLE_MOTU" … … 365 385 366 386 AM_CONDITIONAL(BUILD_BEBOB,test "${build_bebob}" = true) 387 AM_CONDITIONAL(BUILD_GENERICAVC,test "${build_genericavc}" = true) 367 388 AM_CONDITIONAL(BUILD_MOTU,test "${build_motu}" = true) 368 389 AM_CONDITIONAL(BUILD_DICE,test "${build_dice}" = true) trunk/libffado/src/bebob-sync.cpp
r445 r554 23 23 24 24 #include "devicemanager.h" 25 #include " iavdevice.h"25 #include "ffadodevice.h" 26 26 #include "bebob/bebob_avdevice.h" 27 27 … … 144 144 } 145 145 146 IAvDevice* pAvDevice = pDeviceManager->getAvDevice( node_id );146 FFADODevice* pAvDevice = pDeviceManager->getAvDevice( node_id ); 147 147 if ( !pAvDevice ) { 148 148 printf( "No recognized device found with id %d\n", node_id ); trunk/libffado/src/bebob/bebob_avdevice.cpp
r537 r554 29 29 #include "libieee1394/ieee1394service.h" 30 30 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" 36 36 #include "libavc/avc_definitions.h" 37 37 … … 43 43 #include <sys/stat.h> 44 44 45 using namespace AVC; 46 45 47 namespace BeBoB { 46 48 47 static VendorModelEntry supportedDeviceList[] =49 static GenericAVC::VendorModelEntry supportedDeviceList[] = 48 50 { 49 51 {0x00000f, 0x00010065, "Mackie", "Onyx Firewire"}, … … 71 73 {0x000d6c, 0x00010062, "M-Audio", "FW Solo"}, 72 74 {0x000d6c, 0x00010081, "M-Audio", "NRV10"}, 73 74 75 }; 75 76 … … 77 78 Ieee1394Service& ieee1394service, 78 79 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 ) 83 81 , m_Mixer ( NULL ) 84 82 { 85 83 debugOutput( DEBUG_LEVEL_VERBOSE, "Created BeBoB::AvDevice (NodeID %d)\n", 86 84 nodeId ); 87 addOption(Util::OptionContainer::Option("snoopMode",false));88 85 } 89 86 … … 96 93 delete m_Mixer; 97 94 } 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 97 AVC::Subunit* 98 AvDevice::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 112 AVC::Plug * 113 AvDevice::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 ); 131 129 } 132 130 … … 140 138 141 139 for ( unsigned int i = 0; 142 i < ( sizeof( supportedDeviceList )/sizeof( VendorModelEntry ) );140 i < ( sizeof( supportedDeviceList )/sizeof( GenericAVC::VendorModelEntry ) ); 143 141 ++i ) 144 142 { … … 149 147 } 150 148 } 151 152 149 return false; 153 150 } … … 160 157 161 158 for ( unsigned int i = 0; 162 i < ( sizeof( supportedDeviceList )/sizeof( VendorModelEntry ) );159 i < ( sizeof( supportedDeviceList )/sizeof( GenericAVC::VendorModelEntry ) ); 163 160 ++i ) 164 161 { … … 177 174 } else return false; 178 175 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 // } 203 195 204 196 // create a GenericMixer and add it as an OSC child node … … 210 202 delete m_Mixer; 211 203 } 212 204 213 205 // create the mixer & register it 214 206 if(getAudioSubunit(0) == NULL) { … … 225 217 226 218 bool 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 219 AvDevice::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"); 280 223 return true; 281 224 } 282 225 283 bool284 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 bool317 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 bool349 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 bool376 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 bool393 AvDevice::discoverSyncModes()394 {395 // Following possible sync plugs exists:396 // - Music subunit sync output plug = internal sync (CSP)397 // - Unit input plug 0 = SYT match398 // - Unit input plut 1 = Sync stream399 //400 // If last sync mode is reported it is mostelikely not401 // implemented *sic*402 //403 // Following sync sources are device specific:404 // - All unit external input plugs which have a405 // sync information (WS, SPDIF, ...)406 407 // First we have to find the sync input and output plug408 // in the music subunit.409 410 // Note PCR input means 1394bus-to-device where as411 // MSU input means subunit-to-device412 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 connections501 // -> sync stream input502 checkSyncConnectionsAndAddToList( syncPCRInputPlugs,503 syncMSUInputPlugs,504 "Sync Stream Input" );505 506 // Check all possible MSU output to PCR output connections507 // -> sync stream output508 checkSyncConnectionsAndAddToList( syncMSUOutputPlugs,509 syncPCROutputPlugs,510 "Sync Stream Output" );511 512 // Check all PCR iso input to MSU input connections513 // -> SYT match514 checkSyncConnectionsAndAddToList( isoPCRInputPlugs,515 syncMSUInputPlugs,516 "Syt Match" );517 518 // Check all MSU sync output to MSU input connections519 // -> CSP520 checkSyncConnectionsAndAddToList( syncMSUOutputPlugs,521 syncMSUInputPlugs,522 "Internal (CSP)" );523 524 // Check all external digital input to MSU input connections525 // -> SPDIF/ADAT sync526 checkSyncConnectionsAndAddToList( digitalExternalInputPlugs,527 syncMSUInputPlugs,528 "Digital Input Sync" );529 530 // Check all external sync input to MSU input connections531 // -> SPDIF/ADAT sync532 checkSyncConnectionsAndAddToList( syncExternalInputPlugs,533 syncMSUInputPlugs,534 "Digital Input Sync" );535 536 // Currently active connection signal source cmd, command type537 // status, source unknown, destination MSU sync input plug538 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 bool574 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. This584 // means is fits into the first page of the SubUnitInfo command.585 // So there is no need to do more than needed586 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_type598 = 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 subunit658 return (musicSubunitFound && audioSubunitFound);659 }660 661 662 AvDeviceSubunit*663 AvDevice::getSubunit( subunit_type_t subunitType,664 subunit_id_t subunitId ) const665 {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 int683 AvDevice::getNrOfSubunits( subunit_type_t subunitType ) const684 {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 ) const702 {703 for ( AvPlugConnectionVector::const_iterator it704 = 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 AvPlugVector738 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 bool765 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 executable815 return false;816 }817 818 int819 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 }840 226 841 227 int … … 916 302 signalSourceCmd.setSignalDestination( signalUnitAddr ); 917 303 signalSourceCmd.setNodeId( m_nodeId ); 918 signalSourceCmd.setSubunitType( AVCCommand::eST_Unit );304 signalSourceCmd.setSubunitType( eST_Unit ); 919 305 signalSourceCmd.setSubunitId( 0xff ); 920 306 … … 957 343 } 958 344 959 bool960 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 ( cmdSuccess992 && ( extStreamFormatCmd.getResponse() ==993 AVCCommand::eR_Implemented ) )994 {995 ESamplingFrequency foundFreq = eSF_DontCare;996 997 FormatInformation* formatInfo =998 extStreamFormatCmd.getFormatInformation();999 FormatInformationStreamsCompound* compoundStream1000 = dynamic_cast< FormatInformationStreamsCompound* > (1001 formatInfo->m_streams );1002 if ( compoundStream ) {1003 foundFreq =1004 static_cast< ESamplingFrequency >(1005 compoundStream->m_samplingFrequency );1006 }1007 1008 FormatInformationStreamsSync* syncStream1009 = 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 ( cmdSuccess1026 && ( 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 void1061 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 void1071 AvDevice::showAvPlugs( AvPlugVector& plugs ) const1072 {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 bool1085 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 bool1117 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 lock1125 } else {1126 1127 }1128 1129 return true;1130 }1131 1132 bool1133 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 unlock1141 } else {1142 1143 }1144 return true;1145 }1146 1147 bool1148 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 plugs1156 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 streamprocessors1172 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 processor1195 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 not1233 // this allows us to find out what direction1234 // a certain stream should have.1235 m_transmitProcessors.push_back(p);1236 1237 return true;1238 }1239 1240 bool1241 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 01279 // but bebob reports it starting from 1. Decide where1280 // and how to handle this (pp: here)1281 channelInfo->m_streamPosition - 1,1282 channelInfo->m_location - 1,1283 Streaming::AmdtpPortInfo::E_MBLA1284 );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 01292 // but bebob reports it starting from 1. Decide where1293 // and how to handle this (pp: here)1294 channelInfo->m_streamPosition - 1,1295 channelInfo->m_location - 1,1296 Streaming::AmdtpPortInfo::E_Midi1297 );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 01309 // but bebob reports it starting from 1. Decide where1310 // and how to handle this (pp: here)1311 channelInfo->m_streamPosition - 1,1312 channelInfo->m_location - 1,1313 Streaming::AmdtpPortInfo::E_MBLA1314 );1315 break;1316 case ExtendedPlugInfoClusterInfoSpecificData::ePT_NoType:1317 default:1318 // unsupported1319 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 int1337 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 bool1354 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 host1366 // FIXME: put this into a decent framework!1367 // we should check the oPCR[n] on the device1368 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 device1400 // FIXME: put this into a decent framework!1401 // we should check the iPCR[n] on the device1402 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 bool1437 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 channel1451 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 channel1468 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 }1481 345 1482 346 template <typename T> bool serializeVector( Glib::ustring path, … … 1497 361 template <typename T, typename VT> bool deserializeVector( Glib::ustring path, 1498 362 Util::IODeserialize& deser, 1499 AvDevice& avDevice,363 Unit& avDevice, 1500 364 VT& vec ) 1501 365 { … … 1520 384 1521 385 bool 1522 AvDevice::serializeSyncInfoVector( Glib::ustring basePath,1523 Util::IOSerialize& ser,1524 const SyncInfoVector& vec ) const1525 {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 bool1549 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 bool1589 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 bool1605 386 AvDevice::serialize( Glib::ustring basePath, 1606 387 Util::IOSerialize& ser ) const … … 1609 390 bool result; 1610 391 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 plugs392 result &= ser.write( basePath + "m_verboseLevel", getDebugLevel() ); 393 result &= m_pPlugManager->serialize( basePath + "Plug", ser ); // serialize all av plugs 1613 394 result &= serializeVector( basePath + "PlugConnection", ser, m_plugConnections ); 1614 395 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 ); 1616 398 1617 399 int i = 0; … … 1630 412 result &= serializeOptions( basePath + "Options", ser ); 1631 413 1632 //result &= ser.write( basePath + "m_id", id );414 // result &= ser.write( basePath + "m_id", id ); 1633 415 1634 416 return result; 1635 417 } 1636 418 1637 bool 419 AvDevice* 1638 420 AvDevice::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 } 1669 450 1670 451 Glib::ustring … … 1686 467 AvDevice::loadFromCache() 1687 468 { 1688 Glib::ustring sDevicePath = getCachePath() + m_pConfigRom->getGuidString();469 /* Glib::ustring sDevicePath = getCachePath() + m_pConfigRom->getGuidString(); 1689 470 1690 471 char* configId; … … 1707 488 } 1708 489 1709 return result; 490 return result;*/ 491 return false; 1710 492 } 1711 493 … … 1713 495 AvDevice::saveCache() 1714 496 { 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; 1744 527 } 1745 528 trunk/libffado/src/bebob/bebob_avdevice.h
r529 r554 29 29 #include "debugmodule/debugmodule.h" 30 30 #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" 32 35 33 #include "bebob/bebob_configparser.h"34 36 #include "bebob/bebob_avplug.h" 35 37 #include "bebob/bebob_avdevice_subunit.h" … … 42 44 #include "libutil/serialize.h" 43 45 44 #include "iavdevice.h" 46 #include "genericavc/avc_avdevice.h" 47 48 #include "ffadodevice.h" 45 49 46 50 #include <sstream> … … 49 53 class ConfigRom; 50 54 class Ieee1394Service; 51 class SubunitPlugSpecificDataPlugAddress;52 55 53 56 namespace BeBoB { 54 57 55 class AvDevice : public IAvDevice {58 class AvDevice : public GenericAVC::AvDevice { 56 59 public: 57 60 AvDevice( std::auto_ptr<ConfigRom>( configRom ), … … 60 63 virtual ~AvDevice(); 61 64 62 void setVerboseLevel(int l);63 64 65 static bool probe( ConfigRom& configRom ); 65 66 virtual bool loadFromCache(); … … 67 68 virtual bool discover(); 68 69 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 ); 118 80 119 81 protected: 82 virtual bool propagatePlugInfo(); 120 83 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 84 public: 161 85 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 ); 170 89 int getConfigurationIdSampleRate(); 171 int getConfigurationIdNumberOfChannel( PlugAddress::EPlugDirection ePlugDirection );90 int getConfigurationIdNumberOfChannel( AVC::PlugAddress::EPlugDirection ePlugDirection ); 172 91 int getConfigurationIdSyncMode(); 173 92 int getConfigurationId(); … … 176 95 177 96 protected: 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;186 97 GenericMixer* m_Mixer; 187 98 188 // streaming stuff189 typedef std::vector< Streaming::StreamProcessor * > StreamProcessorVector;190 StreamProcessorVector m_receiveProcessors;191 StreamProcessorVector m_transmitProcessors;192 99 }; 193 100 trunk/libffado/src/bebob/bebob_avdevice_subunit.cpp
r516 r554 28 28 #include "libieee1394/configrom.h" 29 29 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" 33 33 34 34 #include <sstream> 35 35 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 36 using namespace AVC; 37 38 ////////////////////////// 39 40 BeBoB::SubunitAudio::SubunitAudio( AVC::Unit& avDevice, 41 subunit_t id ) 42 : AVC::SubunitAudio( avDevice, id ) 43 { 44 } 45 46 BeBoB::SubunitAudio::SubunitAudio() 47 : AVC::SubunitAudio() 48 { 49 } 50 51 BeBoB::SubunitAudio::~SubunitAudio() 52 { 53 54 } 55 56 AVC::Plug * 57 BeBoB::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 75 bool 76 BeBoB::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 283 86 if ( !discoverFunctionBlocks() ) { 284 87 debugError( "function block discovering failed\n" ); … … 290 93 291 94 bool 292 BeBoB:: AvDeviceSubunitAudio::discoverConnections()95 BeBoB::SubunitAudio::discoverConnections() 293 96 { 294 97 debugOutput(DEBUG_LEVEL_NORMAL, "Discovering connections...\n"); 295 if ( ! AvDeviceSubunit::discoverConnections() ) {98 if ( !Subunit::discoverConnections() ) { 296 99 return false; 297 100 } … … 313 116 314 117 const char* 315 BeBoB:: AvDeviceSubunitAudio::getName()316 { 317 return " AudioSubunit";318 } 319 320 bool 321 BeBoB:: AvDeviceSubunitAudio::discoverFunctionBlocks()118 BeBoB::SubunitAudio::getName() 119 { 120 return "BeBoB::AudioSubunit"; 121 } 122 123 bool 124 BeBoB::SubunitAudio::discoverFunctionBlocks() 322 125 { 323 126 debugOutput( DEBUG_LEVEL_NORMAL, … … 351 154 // print a function block list 352 155 #ifdef DEBUG 353 if ( getDebugLevel() >= DEBUG_LEVEL_NORMAL) {354 156 if ((int)getDebugLevel() >= DEBUG_LEVEL_NORMAL) { 157 355 158 for ( FunctionBlockVector::iterator it = m_functions.begin(); 356 159 it != m_functions.end(); … … 369 172 370 173 bool 371 BeBoB:: AvDeviceSubunitAudio::discoverFunctionBlocksDo(174 BeBoB::SubunitAudio::discoverFunctionBlocksDo( 372 175 ExtendedSubunitInfoCmd::EFunctionBlockType fbType ) 373 176 { … … 378 181 do { 379 182 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() ); 382 185 extSubunitInfoCmd.setCommandType( AVCCommand::eCT_Status ); 383 186 extSubunitInfoCmd.setSubunitId( getSubunitId() ); 384 187 extSubunitInfoCmd.setSubunitType( getSubunitType() ); 385 extSubunitInfoCmd.setVerbose( m_verboseLevel);188 extSubunitInfoCmd.setVerbose( (int)getDebugLevel() ); 386 189 387 190 extSubunitInfoCmd.m_fbType = fbType; … … 417 220 418 221 bool 419 BeBoB:: AvDeviceSubunitAudio::createFunctionBlock(222 BeBoB::SubunitAudio::createFunctionBlock( 420 223 ExtendedSubunitInfoCmd::EFunctionBlockType fbType, 421 224 ExtendedSubunitInfoPageData& data ) … … 434 237 data.m_noOfInputPlugs, 435 238 data.m_noOfOutputPlugs, 436 m_verboseLevel);239 (int)getDebugLevel() ); 437 240 } 438 241 break; … … 444 247 data.m_noOfInputPlugs, 445 248 data.m_noOfOutputPlugs, 446 m_verboseLevel);249 (int)getDebugLevel() ); 447 250 } 448 251 break; … … 457 260 data.m_noOfInputPlugs, 458 261 data.m_noOfOutputPlugs, 459 m_verboseLevel);262 (int)getDebugLevel() ); 460 263 } 461 264 break; … … 474 277 data.m_noOfInputPlugs, 475 278 data.m_noOfOutputPlugs, 476 m_verboseLevel);279 (int)getDebugLevel() ); 477 280 debugWarning( "Dummy function block processing created. " 478 281 "Implementation is missing\n" ); … … 487 290 data.m_noOfInputPlugs, 488 291 data.m_noOfOutputPlugs, 489 m_verboseLevel);292 (int)getDebugLevel() ); 490 293 debugWarning( "Dummy function block codec created. " 491 294 "Implementation is missing\n" ); … … 513 316 514 317 BeBoB::FunctionBlock::ESpecialPurpose 515 BeBoB:: AvDeviceSubunitAudio::convertSpecialPurpose(318 BeBoB::SubunitAudio::convertSpecialPurpose( 516 319 function_block_special_purpose_t specialPurpose ) 517 320 { … … 531 334 532 335 bool 533 BeBoB:: AvDeviceSubunitAudio::serializeChild( Glib::ustring basePath,336 BeBoB::SubunitAudio::serializeChild( Glib::ustring basePath, 534 337 Util::IOSerialize& ser ) const 535 338 { … … 554 357 555 358 bool 556 BeBoB:: AvDeviceSubunitAudio::deserializeChild( Glib::ustring basePath,359 BeBoB::SubunitAudio::deserializeChild( Glib::ustring basePath, 557 360 Util::IODeserialize& deser, 558 A vDevice& avDevice )361 AVC::Unit& avDevice ) 559 362 { 560 363 int i = 0; … … 580 383 //////////////////////////////////////////// 581 384 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 { 385 BeBoB::SubunitMusic::SubunitMusic( AVC::Unit& avDevice, 386 subunit_t id ) 387 : AVC::SubunitMusic( avDevice, id ) 388 { 389 } 390 391 BeBoB::SubunitMusic::SubunitMusic() 392 : AVC::SubunitMusic() 393 { 394 } 395 396 BeBoB::SubunitMusic::~SubunitMusic() 397 { 398 } 399 400 AVC::Plug * 401 BeBoB::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 419 bool 420 BeBoB::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; 596 433 } 597 434 598 435 const char* 599 BeBoB:: AvDeviceSubunitMusic::getName()600 { 601 return " MusicSubunit";602 } 603 604 bool 605 BeBoB:: AvDeviceSubunitMusic::serializeChild( Glib::ustring basePath,436 BeBoB::SubunitMusic::getName() 437 { 438 return "BeBoB::MusicSubunit"; 439 } 440 441 bool 442 BeBoB::SubunitMusic::serializeChild( Glib::ustring basePath, 606 443 Util::IOSerialize& ser ) const 607 444 { … … 610 447 611 448 bool 612 BeBoB:: AvDeviceSubunitMusic::deserializeChild( Glib::ustring basePath,449 BeBoB::SubunitMusic::deserializeChild( Glib::ustring basePath, 613 450 Util::IODeserialize& deser, 614 A vDevice& 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 29 29 30 30 #include "debugmodule/debugmodule.h" 31 #include "libavc/ avc_extended_subunit_info.h"31 #include "libavc/general/avc_extended_subunit_info.h" 32 32 #include "libavc/avc_definitions.h" 33 #include "libavc/ avc_generic.h"33 #include "libavc/general/avc_generic.h" 34 34 35 35 #include <vector> 36 36 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 37 42 namespace 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() const66 { 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;98 43 99 44 ///////////////////////////// 100 45 101 class AvDeviceSubunitAudio: public AvDeviceSubunit {102 public: 103 AvDeviceSubunitAudio( AvDevice& avDevice, 104 subunit_t id,105 int verboseLevel);106 AvDeviceSubunitAudio();107 virtual ~ AvDeviceSubunitAudio();46 class SubunitAudio : public AVC::SubunitAudio 47 { 48 public: 49 SubunitAudio( AVC::Unit& avDevice, 50 AVC::subunit_t id ); 51 SubunitAudio(); 52 virtual ~SubunitAudio(); 108 53 109 54 virtual bool discover(); 110 55 virtual bool discoverConnections(); 111 56 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 112 65 virtual const char* getName(); 113 66 114 FunctionBlockVector getFunctionBlocks() { return m_functions; };115 116 67 protected: 117 68 bool discoverFunctionBlocks(); 118 69 bool discoverFunctionBlocksDo( 119 ExtendedSubunitInfoCmd::EFunctionBlockType fbType );70 AVC::ExtendedSubunitInfoCmd::EFunctionBlockType fbType ); 120 71 bool createFunctionBlock( 121 ExtendedSubunitInfoCmd::EFunctionBlockType fbType,122 ExtendedSubunitInfoPageData& data );72 AVC::ExtendedSubunitInfoCmd::EFunctionBlockType fbType, 73 AVC::ExtendedSubunitInfoPageData& data ); 123 74 124 75 FunctionBlock::ESpecialPurpose convertSpecialPurpose( 125 function_block_special_purpose_t specialPurpose );76 AVC::function_block_special_purpose_t specialPurpose ); 126 77 127 78 virtual bool serializeChild( Glib::ustring basePath, … … 129 80 virtual bool deserializeChild( Glib::ustring basePath, 130 81 Util::IODeserialize& deser, 131 A vDevice& avDevice);82 AVC::Unit& unit ); 132 83 133 protected:134 FunctionBlockVector m_functions;135 84 }; 136 85 137 86 ///////////////////////////// 138 87 139 class AvDeviceSubunitMusic: public AvDeviceSubunit { 88 class SubunitMusic : public AVC::SubunitMusic 89 { 140 90 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 ); 146 105 147 106 virtual const char* getName(); … … 152 111 virtual bool deserializeChild( Glib::ustring basePath, 153 112 Util::IODeserialize& deser, 154 AvDevice& avDevice ); 113 AVC::Unit& unit ); 114 155 115 }; 156 116 trunk/libffado/src/bebob/bebob_avplug.cpp
r516 r554 27 27 28 28 #include "libieee1394/ieee1394service.h" 29 #include "libavc/ avc_serialize.h"29 #include "libavc/util/avc_serialize.h" 30 30 31 31 #include <sstream> 32 32 33 using namespace AVC; 34 33 35 namespace BeBoB { 34 36 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 ); 37 Plug::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 { 67 52 debugOutput( DEBUG_LEVEL_VERBOSE, 68 53 "nodeId = %d, subunitType = %d, " … … 70 55 "functionBlockId = %d, addressType = %d, " 71 56 "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 67 Plug::Plug( const Plug& rhs ) 68 : AVC::Plug( rhs ) 69 { 70 71 } 72 73 Plug::Plug() 74 : AVC::Plug() 75 { 76 } 77 78 Plug::~Plug() 79 { 80 81 } 82 83 bool 84 Plug::discover() 132 85 { 133 86 if ( !discoverPlugType() ) { 134 87 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 ); 136 89 return false; 137 90 } … … 139 92 if ( !discoverName() ) { 140 93 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 ); 142 95 return false; 143 96 } … … 146 99 debugError( "Could not discover number of channels " 147 100 "(%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 ); 149 102 return false; 150 103 } … … 153 106 debugError( "Could not discover channel positions " 154 107 "(%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 ); 156 109 return false; 157 110 } … … 160 113 debugError( "Could not discover channel name " 161 114 "(%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 ); 163 116 return false; 164 117 } … … 167 120 debugError( "Could not discover channel name " 168 121 "(%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 ); 170 123 return false; 171 124 } … … 174 127 debugError( "Could not discover stream format " 175 128 "(%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 ); 177 130 return false; 178 131 } … … 181 134 debugError( "Could not discover supported stream formats " 182 135 "(%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 143 bool 144 Plug::discoverConnections() 192 145 { 193 146 return discoverConnectionsInput() && discoverConnectionsOutput(); … … 195 148 196 149 bool 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() 150 Plug::discoverPlugType() 276 151 { 277 152 ExtendedPlugInfoCmd extPlugInfoCmd = setPlugAddrToPlugInfoCmd(); … … 280 155 extendedPlugInfoInfoType.initialize(); 281 156 extPlugInfoCmd.setInfoType( extendedPlugInfoInfoType ); 282 extPlugInfoCmd.setVerbose( m_verboseLevel);157 extPlugInfoCmd.setVerbose( getDebugLevel() ); 283 158 284 159 if ( !extPlugInfoCmd.fire() ) { … … 336 211 337 212 bool 338 AvPlug::discoverName()213 Plug::discoverName() 339 214 { 340 215 ExtendedPlugInfoCmd extPlugInfoCmd = setPlugAddrToPlugInfoCmd(); … … 343 218 extendedPlugInfoInfoType.initialize(); 344 219 extPlugInfoCmd.setInfoType( extendedPlugInfoInfoType ); 345 extPlugInfoCmd.setVerbose( m_verboseLevel);220 extPlugInfoCmd.setVerbose( getDebugLevel() ); 346 221 347 222 if ( !extPlugInfoCmd.fire() ) { … … 368 243 369 244 bool 370 AvPlug::discoverNoOfChannels()245 Plug::discoverNoOfChannels() 371 246 { 372 247 ExtendedPlugInfoCmd extPlugInfoCmd = setPlugAddrToPlugInfoCmd(); … … 376 251 extendedPlugInfoInfoType.initialize(); 377 252 extPlugInfoCmd.setInfoType( extendedPlugInfoInfoType ); 378 extPlugInfoCmd.setVerbose( m_verboseLevel);253 extPlugInfoCmd.setVerbose( getDebugLevel() ); 379 254 380 255 if ( !extPlugInfoCmd.fire() ) { … … 401 276 402 277 bool 403 AvPlug::discoverChannelPosition()278 Plug::discoverChannelPosition() 404 279 { 405 280 ExtendedPlugInfoCmd extPlugInfoCmd = setPlugAddrToPlugInfoCmd(); … … 408 283 extendedPlugInfoInfoType.initialize(); 409 284 extPlugInfoCmd.setInfoType( extendedPlugInfoInfoType ); 410 extPlugInfoCmd.setVerbose( m_verboseLevel);285 extPlugInfoCmd.setVerbose( getDebugLevel() ); 411 286 412 287 if ( !extPlugInfoCmd.fire() ) { … … 437 312 438 313 bool 439 AvPlug::discoverChannelName() 314 Plug::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 358 bool 359 Plug::discoverChannelName() 440 360 { 441 361 for ( ClusterInfoVector::iterator clit = m_clusterInfos.begin(); … … 456 376 extendedPlugInfoInfoType.initialize(); 457 377 extPlugInfoCmd.setInfoType( extendedPlugInfoInfoType ); 458 extPlugInfoCmd.setVerbose( m_verboseLevel);378 extPlugInfoCmd.setVerbose( getDebugLevel() ); 459 379 460 380 ExtendedPlugInfoInfoType* infoType = … … 489 409 490 410 bool 491 AvPlug::discoverClusterInfo()411 Plug::discoverClusterInfo() 492 412 { 493 413 if ( m_infoPlugType == eAPT_Sync ) … … 516 436 extendedPlugInfoInfoType.initialize(); 517 437 extPlugInfoCmd.setInfoType( extendedPlugInfoInfoType ); 518 extPlugInfoCmd.setVerbose( m_verboseLevel);438 extPlugInfoCmd.setVerbose( getDebugLevel() ); 519 439 520 440 extPlugInfoCmd.getInfoType()->m_plugClusterInfo->m_clusterIndex = … … 549 469 550 470 bool 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() 471 Plug::discoverConnectionsInput() 771 472 { 772 473 ExtendedPlugInfoCmd extPlugInfoCmd = setPlugAddrToPlugInfoCmd(); … … 775 476 extendedPlugInfoInfoType.initialize(); 776 477 extPlugInfoCmd.setInfoType( extendedPlugInfoInfoType ); 777 extPlugInfoCmd.setVerbose( m_verboseLevel);478 extPlugInfoCmd.setVerbose( getDebugLevel() ); 778 479 779 480 if ( !extPlugInfoCmd.fire() ) { … … 820 521 821 522 bool 822 AvPlug::discoverConnectionsOutput()523 Plug::discoverConnectionsOutput() 823 524 { 824 525 ExtendedPlugInfoCmd extPlugInfoCmd = setPlugAddrToPlugInfoCmd(); … … 827 528 extendedPlugInfoInfoType.initialize(); 828 529 extPlugInfoCmd.setInfoType( extendedPlugInfoInfoType ); 829 extPlugInfoCmd.setVerbose( m_verboseLevel);530 extPlugInfoCmd.setVerbose( getDebugLevel() ); 830 531 831 532 if ( !extPlugInfoCmd.fire() ) { … … 883 584 } 884 585 885 bool886 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 bool928 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 949 586 ExtendedPlugInfoCmd 950 AvPlug::setPlugAddrToPlugInfoCmd()951 { 952 ExtendedPlugInfoCmd extPlugInfoCmd( *m_p1394Service);953 954 switch( m_subunitType) {955 case AVCCommand::eST_Unit:587 Plug::setPlugAddrToPlugInfoCmd() 588 { 589 ExtendedPlugInfoCmd extPlugInfoCmd( m_unit->get1394Service() ); 590 591 switch( getSubunitType() ) { 592 case eST_Unit: 956 593 { 957 594 UnitPlugAddress::EPlugType ePlugType = … … 978 615 } 979 616 break; 980 case AVCCommand::eST_Music:981 case AVCCommand::eST_Audio:617 case eST_Music: 618 case eST_Audio: 982 619 { 983 620 switch( m_addressType ) { … … 1014 651 } 1015 652 1016 extPlugInfoCmd.setNodeId( m_ pConfigRom->getNodeId() );653 extPlugInfoCmd.setNodeId( m_unit->getConfigRom().getNodeId() ); 1017 654 extPlugInfoCmd.setCommandType( AVCCommand::eCT_Status ); 1018 extPlugInfoCmd.setSubunitId( m_subunitId);1019 extPlugInfoCmd.setSubunitType( m_subunitType);655 extPlugInfoCmd.setSubunitId( getSubunitId() ); 656 extPlugInfoCmd.setSubunitType( getSubunitType() ); 1020 657 1021 658 return extPlugInfoCmd; 1022 659 } 1023 660 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 25 25 #define BEBOB_AVPLUG_H 26 26 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" 31 31 #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" 33 34 34 35 #include "libutil/serialize.h" … … 44 45 45 46 class AvDevice; 46 class AvPlugManager;47 class AvPlug;48 47 49 typedef std::vector<AvPlug*> AvPlugVector; 50 51 class AvPlug { 48 class Plug : public AVC::Plug { 52 49 public: 53 50 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 79 51 // \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(); 93 61 94 62 bool discover(); 95 63 bool discoverConnections(); 96 64 97 bool inquireConnnection( AvPlug& plug );98 bool setConnection( AvPlug& plug );99 100 int getGlobalId() const101 { return m_globalId; }102 plug_id_t getPlugId() const103 { return m_id; }104 AVCCommand::ESubunitType getSubunitType() const105 { return m_subunitType; }106 subunit_id_t getSubunitId() const107 { return m_subunitId; }108 const char* getName() const109 { return m_name.c_str(); }110 EAvPlugDirection getPlugDirection() const111 { return m_direction; }112 sampling_frequency_t getSamplingFrequency() const113 { return m_samplingFrequency; }114 int getSampleRate() const; // 22050, 24000, 32000, ...115 int getNrOfChannels() const;116 int getNrOfStreams() const;117 118 EAvPlugDirection getDirection() const119 { return m_direction; }120 EAvPlugAddressType getPlugAddressType() const121 { return m_addressType; }122 EAvPlugType getPlugType() const123 { return m_infoPlugType; }124 125 function_block_type_t getFunctionBlockType() const126 { return m_functionBlockType; }127 function_block_id_t getFunctionBlockId() const128 { return m_functionBlockId; }129 130 const AvPlugVector& getInputConnections() const131 { return m_inputConnections; }132 const AvPlugVector& getOutputConnections() const133 { 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 149 65 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; }170 66 171 67 protected: 172 AvPlug();68 Plug(); 173 69 174 70 bool discoverPlugType(); … … 178 74 bool discoverChannelName(); 179 75 bool discoverClusterInfo(); 180 bool discoverStreamFormat();181 bool discoverSupportedStreamFormats();182 76 bool discoverConnectionsInput(); 183 77 bool discoverConnectionsOutput(); 184 78 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& 79 private: 80 bool copyClusterInfo(AVC::ExtendedPlugInfoPlugChannelPositionSpecificData& 198 81 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(); 257 83 258 84 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;282 85 }; 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 AvPlugManager289 {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() const335 { return *m_srcPlug; }336 AvPlug& getDestPlug() const337 { 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;353 86 354 87 } trunk/libffado/src/bebob/bebob_dl_codes.cpp
r445 r554 24 24 #include "bebob/bebob_dl_codes.h" 25 25 #include "bebob/bebob_dl_bcd.h" 26 27 using namespace AVC; 26 28 27 29 unsigned short BeBoB::CommandCodes::m_gCommandId = 0; trunk/libffado/src/bebob/bebob_dl_codes.h
r445 r554 29 29 #include "fbtypes.h" 30 30 31 #include "libavc/ avc_serialize.h"31 #include "libavc/util/avc_serialize.h" 32 32 33 33 namespace BeBoB { … … 69 69 virtual ~CommandCodes(); 70 70 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 ); 73 73 74 74 virtual size_t getMaxSize(); … … 127 127 virtual ~CommandCodesReset(); 128 128 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 ); 131 131 132 132 EStartMode getStartMode() const … … 147 147 virtual ~CommandCodesProgramGUID(); 148 148 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 ); 151 151 152 152 fb_octlet_t getGUID() const … … 177 177 virtual ~CommandCodesDownloadStart(); 178 178 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 ); 181 181 182 182 bool setDate( fb_octlet_t date ) … … 218 218 virtual ~CommandCodesDownloadBlock(); 219 219 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 ); 222 222 223 223 bool setSeqNumber( fb_quadlet_t seqNumber ) … … 247 247 virtual ~CommandCodesDownloadEnd(); 248 248 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 ); 251 251 252 252 fb_quadlet_t getRespCrc32() const … … 268 268 virtual ~CommandCodesInitializePersParam(); 269 269 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 ); 272 272 }; 273 273 … … 280 280 virtual ~CommandCodesInitializeConfigToFactorySetting(); 281 281 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 ); 284 284 }; 285 285 … … 296 296 virtual ~CommandCodesGo(); 297 297 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 ); 300 300 301 301 EStartMode getStartMode() const trunk/libffado/src/bebob/bebob_dl_mgr.cpp
r445 r554 29 29 #include "libieee1394/ieee1394service.h" 30 30 31 #include "libavc/ avc_serialize.h"31 #include "libavc/util/avc_serialize.h" 32 32 33 33 #include <netinet/in.h> 34 34 35 35 #include <cstdio> 36 37 using namespace AVC; 36 38 37 39 namespace BeBoB { trunk/libffado/src/bebob/bebob_functionblock.cpp
r516 r554 27 27 #include "libieee1394/configrom.h" 28 28 29 IMPL_DEBUG_MODULE( BeBoB::FunctionBlock, BeBoB::FunctionBlock, DEBUG_LEVEL_NORMAL ); 30 31 BeBoB::FunctionBlock::FunctionBlock( 32 AvDeviceSubunit& subunit, 29 using namespace AVC; 30 31 namespace BeBoB { 32 33 IMPL_DEBUG_MODULE( FunctionBlock, FunctionBlock, DEBUG_LEVEL_NORMAL ); 34 35 FunctionBlock::FunctionBlock( 36 AVC::Subunit& subunit, 33 37 function_block_type_t type, 34 38 function_block_type_t subtype, … … 50 54 } 51 55 52 BeBoB::FunctionBlock::FunctionBlock( const FunctionBlock& rhs )56 FunctionBlock::FunctionBlock( const FunctionBlock& rhs ) 53 57 : m_subunit( rhs.m_subunit ) 54 58 , m_type( rhs.m_type ) … … 62 66 } 63 67 64 BeBoB::FunctionBlock::FunctionBlock()65 { 66 } 67 68 BeBoB::FunctionBlock::~FunctionBlock()69 { 70 for ( AvPlugVector::iterator it = m_plugs.begin();68 FunctionBlock::FunctionBlock() 69 { 70 } 71 72 FunctionBlock::~FunctionBlock() 73 { 74 for ( PlugVector::iterator it = m_plugs.begin(); 71 75 it != m_plugs.end(); 72 76 ++it ) … … 78 82 79 83 bool 80 BeBoB::FunctionBlock::discover()84 FunctionBlock::discover() 81 85 { 82 86 debugOutput( DEBUG_LEVEL_NORMAL, … … 87 91 m_nrOfOutputPlugs ); 88 92 89 if ( !discoverPlugs( A vPlug::eAPD_Input, m_nrOfInputPlugs ) ) {93 if ( !discoverPlugs( AVC::Plug::eAPD_Input, m_nrOfInputPlugs ) ) { 90 94 debugError( "Could not discover input plug for '%s'\n", 91 95 getName() ); … … 93 97 } 94 98 95 if ( !discoverPlugs( A vPlug::eAPD_Output, m_nrOfOutputPlugs ) ) {99 if ( !discoverPlugs( AVC::Plug::eAPD_Output, m_nrOfOutputPlugs ) ) { 96 100 debugError( "Could not discover output plugs for '%s'\n", 97 101 getName() ); … … 103 107 104 108 bool 105 BeBoB::FunctionBlock::discoverPlugs( AvPlug::EAvPlugDirection plugDirection,109 FunctionBlock::discoverPlugs( AVC::Plug::EPlugDirection plugDirection, 106 110 plug_id_t plugMaxId ) 107 111 { 108 112 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, 115 116 m_type, 116 117 m_id, 117 A vPlug::eAPA_FunctionBlockPlug,118 AVC::Plug::eAPA_FunctionBlockPlug, 118 119 plugDirection, 119 plugId, 120 m_verbose ); 120 plugId); 121 121 122 122 if ( !plug || !plug->discover() ) { … … 136 136 137 137 bool 138 BeBoB::FunctionBlock::discoverConnections()138 FunctionBlock::discoverConnections() 139 139 { 140 140 debugOutput( DEBUG_LEVEL_VERBOSE, … … 142 142 getName() ); 143 143 144 for ( AvPlugVector::iterator it = m_plugs.begin();144 for ( PlugVector::iterator it = m_plugs.begin(); 145 145 it != m_plugs.end(); 146 146 ++it ) 147 147 { 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 } 149 153 if ( !plug->discoverConnections() ) { 150 154 debugError( "Could not discover plug connections\n" ); … … 156 160 157 161 bool 158 serialize AvPlugVector( Glib::ustring basePath,162 serializePlugVector( Glib::ustring basePath, 159 163 Util::IOSerialize& ser, 160 const BeBoB::AvPlugVector& vec )164 const PlugVector& vec ) 161 165 { 162 166 bool result = true; 163 167 int i = 0; 164 for ( BeBoB::AvPlugVector::const_iterator it = vec.begin();168 for ( PlugVector::const_iterator it = vec.begin(); 165 169 it != vec.end(); 166 170 ++it ) … … 175 179 176 180 bool 177 deserialize AvPlugVector( Glib::ustring basePath,181 deserializePlugVector( Glib::ustring basePath, 178 182 Util::IODeserialize& deser, 179 BeBoB::AvDevice& avDevice,180 BeBoB::AvPlugVector& vec )183 AVC::Unit& unit, 184 PlugVector& vec ) 181 185 { 182 186 int i = 0; … … 190 194 if ( deser.isExisting( strstrm.str() ) ) { 191 195 result &= deser.read( strstrm.str(), plugId ); 192 BeBoB::AvPlug* pPlug = avDevice.getPlugManager().getPlug( plugId );196 AVC::Plug* pPlug = unit.getPlugManager().getPlug( plugId ); 193 197 194 198 if ( result && pPlug ) { … … 207 211 208 212 bool 209 BeBoB::FunctionBlock::serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const213 FunctionBlock::serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const 210 214 { 211 215 bool result; … … 218 222 result &= ser.write( basePath + "m_nrOfOutputPlugs", m_nrOfOutputPlugs ); 219 223 result &= ser.write( basePath + "m_verbose", m_verbose ); 220 result &= serialize AvPlugVector( basePath + "m_plugs", ser, m_plugs );224 result &= serializePlugVector( basePath + "m_plugs", ser, m_plugs ); 221 225 222 226 return result; 223 227 } 224 228 225 BeBoB::FunctionBlock*226 BeBoB::FunctionBlock::deserialize( Glib::ustring basePath,229 FunctionBlock* 230 FunctionBlock::deserialize( Glib::ustring basePath, 227 231 Util::IODeserialize& deser, 228 A vDevice& avDevice,229 A vDeviceSubunit& subunit )232 AVC::Unit& unit, 233 AVC::Subunit& subunit ) 230 234 { 231 235 bool result; … … 274 278 result &= deser.read( basePath + "m_nrOfOutputPlugs", pFB->m_nrOfOutputPlugs ); 275 279 result &= deser.read( basePath + "m_verbose", pFB->m_verbose ); 276 result &= deserialize AvPlugVector( basePath + "m_plugs", deser, avDevice, pFB->m_plugs );280 result &= deserializePlugVector( basePath + "m_plugs", deser, unit, pFB->m_plugs ); 277 281 278 282 return 0; … … 281 285 /////////////////////// 282 286 283 BeBoB::FunctionBlockSelector::FunctionBlockSelector(284 A vDeviceSubunit& subunit,287 FunctionBlockSelector::FunctionBlockSelector( 288 AVC::Subunit& subunit, 285 289 function_block_id_t id, 286 290 ESpecialPurpose purpose, … … 299 303 } 300 304 301 BeBoB::FunctionBlockSelector::FunctionBlockSelector(305 FunctionBlockSelector::FunctionBlockSelector( 302 306 const FunctionBlockSelector& rhs ) 303 307 : FunctionBlock( rhs ) … … 305 309 } 306 310 307 BeBoB::FunctionBlockSelector::FunctionBlockSelector()311 FunctionBlockSelector::FunctionBlockSelector() 308 312 : FunctionBlock() 309 313 { 310 314 } 311 315 312 BeBoB::FunctionBlockSelector::~FunctionBlockSelector()316 FunctionBlockSelector::~FunctionBlockSelector() 313 317 { 314 318 } 315 319 316 320 const char* 317 BeBoB::FunctionBlockSelector::getName()321 FunctionBlockSelector::getName() 318 322 { 319 323 return "Selector"; … … 321 325 322 326 bool 323 BeBoB::FunctionBlockSelector::serializeChild( Glib::ustring basePath,327 FunctionBlockSelector::serializeChild( Glib::ustring basePath, 324 328 Util::IOSerialize& ser ) const 325 329 { … … 328 332 329 333 bool 330 BeBoB::FunctionBlockSelector::deserializeChild( Glib::ustring basePath,334 FunctionBlockSelector::deserializeChild( Glib::ustring basePath, 331 335 Util::IODeserialize& deser, 332 AvDevice& avDevice)336 AvDevice& unit ) 333 337 { 334 338 return true; … … 337 341 /////////////////////// 338 342 339 BeBoB::FunctionBlockFeature::FunctionBlockFeature(340 A vDeviceSubunit& subunit,343 FunctionBlockFeature::FunctionBlockFeature( 344 AVC::Subunit& subunit, 341 345 function_block_id_t id, 342 346 ESpecialPurpose purpose, … … 355 359 } 356 360 357 BeBoB::FunctionBlockFeature::FunctionBlockFeature(361 FunctionBlockFeature::FunctionBlockFeature( 358 362 const FunctionBlockFeature& rhs ) 359 363 : FunctionBlock( rhs ) … … 361 365 } 362 366 363 BeBoB::FunctionBlockFeature::FunctionBlockFeature()367 FunctionBlockFeature::FunctionBlockFeature() 364 368 : FunctionBlock() 365 369 { 366 370 } 367 371 368 BeBoB::FunctionBlockFeature::~FunctionBlockFeature()372 FunctionBlockFeature::~FunctionBlockFeature() 369 373 { 370 374 } 371 375 372 376 const char* 373 BeBoB::FunctionBlockFeature::getName()377 FunctionBlockFeature::getName() 374 378 { 375 379 return "Feature"; … … 377 381 378 382 bool 379 BeBoB::FunctionBlockFeature::serializeChild( Glib::ustring basePath,383 FunctionBlockFeature::serializeChild( Glib::ustring basePath, 380 384 Util::IOSerialize& ser ) const 381 385 { … … 384 388 385 389 bool 386 BeBoB::FunctionBlockFeature::deserializeChild( Glib::ustring basePath,390 FunctionBlockFeature::deserializeChild( Glib::ustring basePath, 387 391 Util::IODeserialize& deser, 388 AvDevice& avDevice)392 AvDevice& unit ) 389 393 { 390 394 return true; … … 393 397 /////////////////////// 394 398 395 BeBoB::FunctionBlockEnhancedMixer::FunctionBlockEnhancedMixer(396 A vDeviceSubunit& subunit,399 FunctionBlockEnhancedMixer::FunctionBlockEnhancedMixer( 400 AVC::Subunit& subunit, 397 401 function_block_id_t id, 398 402 ESpecialPurpose purpose, … … 411 415 } 412 416 413 BeBoB::FunctionBlockEnhancedMixer::FunctionBlockEnhancedMixer(417 FunctionBlockEnhancedMixer::FunctionBlockEnhancedMixer( 414 418 const FunctionBlockEnhancedMixer& rhs ) 415 419 : FunctionBlock( rhs ) … … 417 421 } 418 422 419 BeBoB::FunctionBlockEnhancedMixer::FunctionBlockEnhancedMixer()423 FunctionBlockEnhancedMixer::FunctionBlockEnhancedMixer() 420 424 : FunctionBlock() 421 425 { 422 426 } 423 427 424 BeBoB::FunctionBlockEnhancedMixer::~FunctionBlockEnhancedMixer()428 FunctionBlockEnhancedMixer::~FunctionBlockEnhancedMixer() 425 429 { 426 430 } 427 431 428 432 const char* 429 BeBoB::FunctionBlockEnhancedMixer::getName()433 FunctionBlockEnhancedMixer::getName() 430 434 { 431 435 return "EnhancedMixer"; … … 433 437 434 438 bool 435 BeBoB::FunctionBlockEnhancedMixer::serializeChild( Glib::ustring basePath,439 FunctionBlockEnhancedMixer::serializeChild( Glib::ustring basePath, 436 440 Util::IOSerialize& ser ) const 437 441 { … … 440 444 441 445 bool 442 BeBoB::FunctionBlockEnhancedMixer::deserializeChild( Glib::ustring basePath,446 FunctionBlockEnhancedMixer::deserializeChild( Glib::ustring basePath, 443 447 Util::IODeserialize& deser, 444 AvDevice& avDevice)448 AvDevice& unit ) 445 449 { 446 450 return true; … … 449 453 /////////////////////// 450 454 451 BeBoB::FunctionBlockProcessing::FunctionBlockProcessing(452 A vDeviceSubunit& subunit,455 FunctionBlockProcessing::FunctionBlockProcessing( 456 AVC::Subunit& subunit, 453 457 function_block_id_t id, 454 458 ESpecialPurpose purpose, … … 467 471 } 468 472 469 BeBoB::FunctionBlockProcessing::FunctionBlockProcessing(473 FunctionBlockProcessing::FunctionBlockProcessing( 470 474 const FunctionBlockProcessing& rhs ) 471 475 : FunctionBlock( rhs ) … … 473 477 } 474 478 475 BeBoB::FunctionBlockProcessing::FunctionBlockProcessing()479 FunctionBlockProcessing::FunctionBlockProcessing() 476 480 : FunctionBlock() 477 481 { 478 482 } 479 483 480 BeBoB::FunctionBlockProcessing::~FunctionBlockProcessing()484 FunctionBlockProcessing::~FunctionBlockProcessing() 481 485 { 482 486 } 483 487 484 488 const char* 485 BeBoB::FunctionBlockProcessing::getName()489 FunctionBlockProcessing::getName() 486 490 { 487 491 return "Dummy Processing"; … … 489 493 490 494 bool 491 BeBoB::FunctionBlockProcessing::serializeChild( Glib::ustring basePath,495 FunctionBlockProcessing::serializeChild( Glib::ustring basePath, 492 496 Util::IOSerialize& ser ) const 493 497 { … … 496 500 497 501 bool 498 BeBoB::FunctionBlockProcessing::deserializeChild( Glib::ustring basePath,502 FunctionBlockProcessing::deserializeChild( Glib::ustring basePath, 499 503 Util::IODeserialize& deser, 500 AvDevice& avDevice)504 AvDevice& unit ) 501 505 { 502 506 return true; … … 505 509 /////////////////////// 506 510 507 BeBoB::FunctionBlockCodec::FunctionBlockCodec(508 A vDeviceSubunit& subunit,511 FunctionBlockCodec::FunctionBlockCodec( 512 AVC::Subunit& subunit, 509 513 function_block_id_t id, 510 514 ESpecialPurpose purpose, … … 523 527 } 524 528 525 BeBoB::FunctionBlockCodec::FunctionBlockCodec( const FunctionBlockCodec& rhs )529 FunctionBlockCodec::FunctionBlockCodec( const FunctionBlockCodec& rhs ) 526 530 : FunctionBlock( rhs ) 527 531 { 528 532 } 529 533 530 BeBoB::FunctionBlockCodec::FunctionBlockCodec()534 FunctionBlockCodec::FunctionBlockCodec() 531 535 : FunctionBlock() 532 536 { 533 537 } 534 538 535 BeBoB::FunctionBlockCodec::~FunctionBlockCodec()539 FunctionBlockCodec::~FunctionBlockCodec() 536 540 { 537 541 } 538 542 539 543 const char* 540 BeBoB::FunctionBlockCodec::getName()544 FunctionBlockCodec::getName() 541 545 { 542 546 return "Dummy Codec"; … … 544 548 545 549 bool 546 BeBoB::FunctionBlockCodec::serializeChild( Glib::ustring basePath,550 FunctionBlockCodec::serializeChild( Glib::ustring basePath, 547 551 Util::IOSerialize& ser ) const 548 552 { … … 551 555 552 556 bool 553 BeBoB::FunctionBlockCodec::deserializeChild( Glib::ustring basePath,557 FunctionBlockCodec::deserializeChild( Glib::ustring basePath, 554 558 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 28 28 29 29 #include "libavc/avc_definitions.h" 30 // #include "libavc/general/avc_subunit.h" 31 30 32 #include "debugmodule/debugmodule.h" 31 33 34 namespace AVC { 35 class Subunit; 36 } 37 32 38 namespace BeBoB { 33 34 class AvDeviceSubunit;35 39 36 40 class FunctionBlock { … … 50 54 }; 51 55 52 FunctionBlock( A vDeviceSubunit& 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, 56 60 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, 59 63 int verbose ); 60 64 FunctionBlock( const FunctionBlock& rhs ); … … 67 71 virtual const char* getName() = 0; 68 72 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;}; 72 76 73 77 bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const; 74 78 static FunctionBlock* deserialize( Glib::ustring basePath, 75 79 Util::IODeserialize& deser, 76 A vDevice& avDevice,77 AvDeviceSubunit& subunit);78 protected: 79 bool discoverPlugs( A vPlug::EAvPlugDirection plugDirection,80 plug_id_t plugMaxId );81 82 protected: 83 A vDeviceSubunit* 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); 82 protected: 83 bool discoverPlugs( AVC::Plug::EPlugDirection plugDirection, 84 AVC::plug_id_t plugMaxId ); 85 86 protected: 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; 87 91 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; 90 94 int m_verbose; 91 A vPlugVector m_plugs;95 AVC::PlugVector m_plugs; 92 96 93 97 DECLARE_DEBUG_MODULE; … … 102 106 { 103 107 public: 104 FunctionBlockSelector(A vDeviceSubunit& subunit,105 function_block_id_t id,108 FunctionBlockSelector(AVC::Subunit& subunit, 109 AVC::function_block_id_t id, 106 110 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, 109 113 int verbose); 110 114 FunctionBlockSelector( const FunctionBlockSelector& rhs ); … … 127 131 { 128 132 public: 129 FunctionBlockFeature(A vDeviceSubunit& subunit,130 function_block_id_t id,133 FunctionBlockFeature(AVC::Subunit& subunit, 134 AVC::function_block_id_t id, 131 135 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, 134 138 int verbose); 135 139 FunctionBlockFeature( const FunctionBlockFeature& rhs ); … … 169 173 { 170 174 public: 171 FunctionBlockEnhancedMixer( A vDeviceSubunit& subunit,172 function_block_id_t id,175 FunctionBlockEnhancedMixer( AVC::Subunit& subunit, 176 AVC::function_block_id_t id, 173 177 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, 176 180 int verbose ); 177 181 FunctionBlockEnhancedMixer(); … … 194 198 { 195 199 public: 196 FunctionBlockProcessing( A vDeviceSubunit& subunit,197 function_block_id_t id,200 FunctionBlockProcessing( AVC::Subunit& subunit, 201 AVC::function_block_id_t id, 198 202 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, 201 205 int verbose ); 202 206 FunctionBlockProcessing( const FunctionBlockProcessing& rhs ); … … 219 223 { 220 224 public: 221 FunctionBlockCodec(A vDeviceSubunit& subunit,222 function_block_id_t id,225 FunctionBlockCodec(AVC::Subunit& subunit, 226 AVC::function_block_id_t id, 223 227 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, 226 230 int verbose); 227 231 FunctionBlockCodec( const FunctionBlockCodec& rhs ); trunk/libffado/src/bebob/GenericMixer.cpp
r462 r554 31 31 #include "libosc/OscResponse.h" 32 32 33 #include "libavc/a vc_function_block.h"34 #include "libavc/ avc_serialize.h"33 #include "libavc/audiosubunit/avc_function_block.h" 34 #include "libavc/util/avc_serialize.h" 35 35 36 36 #include "libieee1394/ieee1394service.h" … … 43 43 44 44 using namespace OSC; 45 using namespace AVC; 45 46 46 47 namespace BeBoB { trunk/libffado/src/bounce/bounce_avdevice.cpp
r479 r554 28 28 #include "libieee1394/ieee1394service.h" 29 29 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" 35 35 #include "libavc/avc_definitions.h" 36 36 … … 55 55 Ieee1394Service& ieee1394service, 56 56 int nodeId ) 57 : IAvDevice( configRom, ieee1394service, nodeId )57 : FFADODevice( configRom, ieee1394service, nodeId ) 58 58 , m_samplerate (44100) 59 59 , m_model( NULL ) … … 132 132 } 133 133 134 bool BounceDevice::setSamplingFrequency( int s ) { 135 if (s) { 136 m_samplerate=s; 137 return true; 138 } else return false; 139 } 140 134 141 int BounceDevice::getConfigurationId( ) { 135 142 return 0; 136 143 } 137 144 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 }145 145 146 146 bool trunk/libffado/src/bounce/bounce_avdevice.h
r516 r554 28 28 #include "debugmodule/debugmodule.h" 29 29 #include "libavc/avc_definitions.h" 30 #include "libavc/ avc_extended_cmd_generic.h"30 #include "libavc/general/avc_extended_cmd_generic.h" 31 31 32 32 #include "libstreaming/AmdtpStreamProcessor.h" … … 36 36 #include "libieee1394/ARMHandler.h" 37 37 38 #include " iavdevice.h"38 #include "ffadodevice.h" 39 39 40 40 #include <vector> … … 65 65 }; 66 66 67 class BounceDevice : public IAvDevice {67 class BounceDevice : public FFADODevice { 68 68 private: 69 69 class BounceNotifier; … … 78 78 virtual bool discover(); 79 79 80 virtual bool setSamplingFrequency( ESamplingFrequencysamplingFrequency );80 virtual bool setSamplingFrequency( int samplingFrequency ); 81 81 virtual int getSamplingFrequency( ); 82 82 trunk/libffado/src/debugmodule/debugmodule.cpp
r494 r554 30 30 #include <iostream> 31 31 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 32 40 using namespace std; 33 41 … … 111 119 fname=f; 112 120 } 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 ), 115 129 fname, line, function ); 116 130 DebugModuleManager::instance()->va_print( format, arg ); … … 195 209 196 210 pthread_mutex_init(&mb_write_lock, NULL); 211 pthread_mutex_init(&mb_flush_lock, NULL); 197 212 pthread_cond_init(&mb_ready_cond, NULL); 198 213 … … 284 299 285 300 void 286 DebugModuleManager:: sync()287 { 288 mb_flush();301 DebugModuleManager::flush() 302 { 303 // mb_flush(); 289 304 } 290 305 … … 293 308 { 294 309 /* 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); 295 318 while (mb_outbuffer != mb_inbuffer) { 296 319 fputs(mb_buffers[mb_outbuffer], stderr); 297 320 mb_outbuffer = MB_NEXT(mb_outbuffer); 298 321 } 322 pthread_mutex_unlock(&m->mb_flush_lock); 299 323 } 300 324 … … 346 370 } 347 371 372 #ifdef DO_MESSAGE_BUFFER_PRINT 348 373 while (ntries) { // try a few times 349 374 if (pthread_mutex_trylock(&mb_write_lock) == 0) { … … 358 383 } 359 384 } 360 361 385 if (ntries==0) { /* lock collision */ 362 // atomic_add(&mb_overruns, 1);386 // atomic_add(&mb_overruns, 1); 363 387 // FIXME: atomicity 364 388 mb_overruns++; // skip the atomicness for now 365 389 } 366 } 367 390 #else 391 fprintf(stderr,msg); 392 #endif 393 } 368 394 369 395 void … … 386 412 return; 387 413 } 388 414 415 #ifdef DO_MESSAGE_BUFFER_PRINT 389 416 while (ntries) { // try a few times 390 417 if (pthread_mutex_trylock(&mb_write_lock) == 0) { … … 405 432 mb_overruns++; // skip the atomicness for now 406 433 } 434 #else 435 fprintf(stderr,msg); 436 #endif 407 437 } 408 438 trunk/libffado/src/debugmodule/debugmodule.h
r494 r554 34 34 typedef short debug_level_t; 35 35 36 #define DEBUG_MAX_MESSAGE_LENGTH 256 37 36 38 /* MB_NEXT() relies on the fact that MB_BUFFERS is a power of two */ 37 39 #define MB_BUFFERS (1<<16) 40 38 41 #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 */ 40 43 41 44 #define debugFatal( format, args... ) \ … … 99 102 m_debugModule.getLevel( ) 100 103 104 #define flushDebugOutput() DebugModuleManager::instance()->flush() 101 105 102 106 #ifdef DEBUG … … 203 207 bool setMgrDebugLevel( std::string name, debug_level_t level ); 204 208 205 void sync();209 void flush(); 206 210 207 211 protected: … … 227 231 pthread_t mb_writer_thread; 228 232 pthread_mutex_t mb_write_lock; 233 pthread_mutex_t mb_flush_lock; 229 234 pthread_cond_t mb_ready_cond; 230 235 trunk/libffado/src/devicemanager.cpp
r529 r554 26 26 27 27 #include "devicemanager.h" 28 #include " iavdevice.h"28 #include "ffadodevice.h" 29 29 30 30 #include "libieee1394/configrom.h" … … 38 38 #include "bebob/bebob_avdevice.h" 39 39 #include "maudio/maudio_avdevice.h" 40 #endif 41 42 #ifdef ENABLE_GENERICAVC 43 #include "genericavc/avc_avdevice.h" 40 44 #endif 41 45 … … 72 76 , m_1394Service( 0 ) 73 77 , m_oscServer( NULL ) 74 , m_verboseLevel( DEBUG_LEVEL_NORMAL )75 78 { 76 79 addOption(Util::OptionContainer::Option("slaveMode",false)); … … 85 88 } 86 89 87 for ( IAvDeviceVectorIterator it = m_avDevices.begin();90 for ( FFADODeviceVectorIterator it = m_avDevices.begin(); 88 91 it != m_avDevices.end(); 89 92 ++it ) … … 98 101 DeviceManager::setVerboseLevel(int l) 99 102 { 100 m_verboseLevel=l;103 debugOutput( DEBUG_LEVEL_NORMAL, "Setting verbose level to %d...\n", l ); 101 104 setDebugLevel(l); 102 105 … … 105 108 OscNode::setVerboseLevel(l); 106 109 107 for ( IAvDeviceVectorIterator it = m_avDevices.begin();110 for ( FFADODeviceVectorIterator it = m_avDevices.begin(); 108 111 it != m_avDevices.end(); 109 112 ++it ) … … 129 132 } 130 133 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()); 168 171 return true; 169 172 } … … 181 184 } 182 185 183 setVerboseLevel( m_verboseLevel);184 185 for ( IAvDeviceVectorIterator it = m_avDevices.begin();186 setVerboseLevel(getDebugLevel()); 187 188 for ( FFADODeviceVectorIterator it = m_avDevices.begin(); 186 189 it != m_avDevices.end(); 187 190 ++it ) … … 222 225 } 223 226 224 IAvDevice*avDevice = getDriverForDevice( configRom, nodeId ); 227 FFADODevice* avDevice = getDriverForDevice( configRom, 228 nodeId ); 229 225 230 if ( avDevice ) { 226 231 debugOutput( DEBUG_LEVEL_NORMAL, … … 234 239 } else if ( avDevice->discover() ) { 235 240 debugOutput( DEBUG_LEVEL_VERBOSE, "discovering successful\n" ); 236 avDevice->setVerboseLevel( m_verboseLevel);241 avDevice->setVerboseLevel( getDebugLevel() ); 237 242 } else { 238 243 debugError( "could not discover device\n" ); … … 256 261 } 257 262 258 if ( m_verboseLevel>= DEBUG_LEVEL_VERBOSE ) {263 if ( getDebugLevel() >= DEBUG_LEVEL_VERBOSE ) { 259 264 avDevice->showDevice(); 260 265 } … … 269 274 debugWarning("failed to register AvDevice at OSC server\n"); 270 275 } 276 277 debugOutput( DEBUG_LEVEL_NORMAL, "discovery of node %d done...\n", nodeId ); 271 278 272 279 } 273 280 } 281 282 debugOutput( DEBUG_LEVEL_NORMAL, "discovery finished...\n" ); 283 274 284 return true; 275 285 … … 294 304 } 295 305 296 IAvDevice* avDevice = getSlaveDriver( configRom );306 FFADODevice* avDevice = getSlaveDriver( configRom ); 297 307 if ( avDevice ) { 298 308 debugOutput( DEBUG_LEVEL_NORMAL, … … 300 310 nodeId ); 301 311 302 avDevice->setVerboseLevel( m_verboseLevel);312 avDevice->setVerboseLevel( getDebugLevel() ); 303 313 304 314 if ( !avDevice->discover() ) { … … 311 321 debugError( "setting Id failed\n" ); 312 322 } 313 if ( m_verboseLevel>= DEBUG_LEVEL_VERBOSE ) {323 if ( getDebugLevel() >= DEBUG_LEVEL_VERBOSE ) { 314 324 avDevice->showDevice(); 315 325 } 316 326 317 327 m_avDevices.push_back( avDevice ); 328 329 debugOutput( DEBUG_LEVEL_NORMAL, "discovery of node %d done...\n", nodeId ); 318 330 } 319 331 332 debugOutput( DEBUG_LEVEL_NORMAL, "discovery finished...\n" ); 333 320 334 return true; 321 335 } … … 323 337 324 338 325 IAvDevice*339 FFADODevice* 326 340 DeviceManager::getDriverForDevice( std::auto_ptr<ConfigRom>( configRom ), 327 341 int id ) … … 334 348 #endif 335 349 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 336 357 #ifdef ENABLE_BEBOB 337 358 debugOutput( DEBUG_LEVEL_VERBOSE, "Trying M-Audio...\n" ); … … 379 400 } 380 401 381 IAvDevice*402 FFADODevice* 382 403 DeviceManager::getSlaveDriver( std::auto_ptr<ConfigRom>( configRom ) ) 383 404 { … … 395 416 DeviceManager::isValidNode(int node) 396 417 { 397 for ( IAvDeviceVectorIterator it = m_avDevices.begin();418 for ( FFADODeviceVectorIterator it = m_avDevices.begin(); 398 419 it != m_avDevices.end(); 399 420 ++it ) 400 421 { 401 IAvDevice* avDevice = *it;422 FFADODevice* avDevice = *it; 402 423 403 424 if (avDevice->getConfigRom().getNodeId() == node) { … … 422 443 } 423 444 424 IAvDevice* avDevice = m_avDevices.at( deviceNr );445 FFADODevice* avDevice = m_avDevices.at( deviceNr ); 425 446 426 447 if ( !avDevice ) { … … 431 452 } 432 453 433 IAvDevice*454 FFADODevice* 434 455 DeviceManager::getAvDevice( int nodeId ) 435 456 { 436 for ( IAvDeviceVectorIterator it = m_avDevices.begin();457 for ( FFADODeviceVectorIterator it = m_avDevices.begin(); 437 458 it != m_avDevices.end(); 438 459 ++it ) 439 460 { 440 IAvDevice* avDevice = *it;461 FFADODevice* avDevice = *it; 441 462 if ( avDevice->getConfigRom().getNodeId() == nodeId ) { 442 463 return avDevice; … … 447 468 } 448 469 449 IAvDevice*470 FFADODevice* 450 471 DeviceManager::getAvDeviceByIndex( int idx ) 451 472 { … … 469 490 Streaming::StreamProcessor * 470 491 DeviceManager::getSyncSource() { 471 IAvDevice* device = getAvDeviceByIndex(0);492 FFADODevice* device = getAvDeviceByIndex(0); 472 493 473 494 bool slaveMode=false; trunk/libffado/src/devicemanager.h
r529 r554 40 40 41 41 class Ieee1394Service; 42 class IAvDevice;42 class FFADODevice; 43 43 namespace Streaming { 44 44 class StreamProcessor; 45 45 } 46 46 47 typedef std::vector< IAvDevice* > IAvDeviceVector;48 typedef std::vector< IAvDevice* >::iterator IAvDeviceVectorIterator;47 typedef std::vector< FFADODevice* > FFADODeviceVector; 48 typedef std::vector< FFADODevice* >::iterator FFADODeviceVectorIterator; 49 49 50 50 class DeviceManager … … 65 65 int getDeviceNodeId( int deviceNr ); 66 66 67 IAvDevice* getAvDevice( int nodeId );68 IAvDevice* getAvDeviceByIndex( int idx );67 FFADODevice* getAvDevice( int nodeId ); 68 FFADODevice* getAvDeviceByIndex( int idx ); 69 69 unsigned int getAvDeviceCount(); 70 70 … … 72 72 73 73 protected: 74 IAvDevice* getDriverForDevice( std::auto_ptr<ConfigRom>( configRom ),74 FFADODevice* getDriverForDevice( std::auto_ptr<ConfigRom>( configRom ), 75 75 int id ); 76 IAvDevice* getSlaveDriver( std::auto_ptr<ConfigRom>( configRom ) );76 FFADODevice* getSlaveDriver( std::auto_ptr<ConfigRom>( configRom ) ); 77 77 78 78 protected: 79 79 Ieee1394Service* m_1394Service; 80 IAvDeviceVector m_avDevices;80 FFADODeviceVector m_avDevices; 81 81 82 82 OSC::OscServer* m_oscServer; … … 86 86 void setVerboseLevel(int l); 87 87 private: 88 int m_verboseLevel;89 88 DECLARE_DEBUG_MODULE; 90 89 }; trunk/libffado/src/dice/dice_avdevice.cpp
r479 r554 54 54 Ieee1394Service& ieee1394service, 55 55 int nodeId ) 56 : IAvDevice( configRom, ieee1394service, nodeId )56 : FFADODevice( configRom, ieee1394service, nodeId ) 57 57 , m_model( NULL ) 58 58 , m_global_reg_offset (0xFFFFFFFFLU) … … 143 143 int 144 144 DiceAvDevice::getSamplingFrequency( ) { 145 ESamplingFrequencysamplingFrequency;145 int samplingFrequency; 146 146 147 147 fb_quadlet_t clockreg; … … 154 154 155 155 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; 171 171 } 172 172 … … 178 178 179 179 bool 180 DiceAvDevice::setSamplingFrequency( ESamplingFrequencysamplingFrequency )180 DiceAvDevice::setSamplingFrequency( int samplingFrequency ) 181 181 { 182 182 debugOutput(DEBUG_LEVEL_VERBOSE, "Setting sample rate: %d\n", 183 convertESamplingFrequency(samplingFrequency));183 (samplingFrequency)); 184 184 185 185 bool supported=false; … … 188 188 switch ( samplingFrequency ) { 189 189 default: 190 case eSF_22050Hz:191 case eSF_24000Hz:190 case 22050: 191 case 24000: 192 192 supported=false; 193 193 break; 194 case eSF_32000Hz:194 case 32000: 195 195 supported=maskedCheckNotZeroGlobalReg( 196 196 DICE_REGISTER_GLOBAL_CLOCKCAPABILITIES, … … 198 198 select=DICE_RATE_32K; 199 199 break; 200 case eSF_44100Hz:200 case 44100: 201 201 supported=maskedCheckNotZeroGlobalReg( 202 202 DICE_REGISTER_GLOBAL_CLOCKCAPABILITIES, … … 204 204 select=DICE_RATE_44K1; 205 205 break; 206 case eSF_48000Hz:206 case 48000: 207 207 supported=maskedCheckNotZeroGlobalReg( 208 208 DICE_REGISTER_GLOBAL_CLOCKCAPABILITIES, … … 210 210 select=DICE_RATE_48K; 211 211 break; 212 case eSF_88200Hz:212 case 88200: 213 213 supported=maskedCheckNotZeroGlobalReg( 214 214 DICE_REGISTER_GLOBAL_CLOCKCAPABILITIES, … … 216 216 select=DICE_RATE_88K2; 217 217 break; 218 case eSF_96000Hz:218 case 96000: 219 219 supported=maskedCheckNotZeroGlobalReg( 220 220 DICE_REGISTER_GLOBAL_CLOCKCAPABILITIES, … … 222 222 select=DICE_RATE_96K; 223 223 break; 224 case eSF_176400Hz:224 case 176400: 225 225 supported=maskedCheckNotZeroGlobalReg( 226 226 DICE_REGISTER_GLOBAL_CLOCKCAPABILITIES, … … 228 228 select=DICE_RATE_176K4; 229 229 break; 230 case eSF_192000Hz:230 case 192000: 231 231 supported=maskedCheckNotZeroGlobalReg( 232 232 DICE_REGISTER_GLOBAL_CLOCKCAPABILITIES, … … 237 237 238 238 if (!supported) { 239 debugWarning("Unsupported sample rate: %d\n", convertESamplingFrequency(samplingFrequency));239 debugWarning("Unsupported sample rate: %d\n", (samplingFrequency)); 240 240 return false; 241 241 } trunk/libffado/src/dice/dice_avdevice.h
r516 r554 25 25 #define DICEDEVICE_H 26 26 27 #include " iavdevice.h"27 #include "ffadodevice.h" 28 28 29 29 #include "debugmodule/debugmodule.h" … … 52 52 }; 53 53 54 class DiceAvDevice : public IAvDevice {54 class DiceAvDevice : public FFADODevice { 55 55 private: 56 56 class DiceNotifier; … … 67 67 virtual void showDevice(); 68 68 69 virtual bool setSamplingFrequency( ESamplingFrequencysamplingFrequency );69 virtual bool setSamplingFrequency( int samplingFrequency ); 70 70 virtual int getSamplingFrequency( ); 71 71 … … 189 189 DiceAvDevice *m_dicedevice; 190 190 }; 191 192 191 }; 193 192 trunk/libffado/src/ffado.cpp
r454 r554 30 30 #include "fbtypes.h" 31 31 #include "devicemanager.h" 32 #include "iavdevice.h" 33 34 #include "libavc/avc_generic.h" 32 #include "ffadodevice.h" 35 33 36 34 #include <stdio.h> … … 133 131 ffado_set_samplerate( ffado_handle_t ffado_handle, int node_id, int samplerate ) 134 132 { 135 IAvDevice* avDevice = ffado_handle->m_deviceManager->getAvDevice( node_id );133 FFADODevice* avDevice = ffado_handle->m_deviceManager->getAvDevice( node_id ); 136 134 if ( avDevice ) { 137 if ( avDevice->setSamplingFrequency( parseSampleRate( samplerate )) ) {135 if ( avDevice->setSamplingFrequency( samplerate ) ) { 138 136 return ffado_handle->m_deviceManager->discover()? 0 : -1; 139 137 } … … 142 140 } 143 141 142 #warning this should be cleaned up 143 #include "libavc/general/avc_generic.h" 144 144 void ffado_sleep_after_avc_command( int time ) 145 145 { 146 AVC Command::setSleepAfterAVCCommand( time );146 AVC::AVCCommand::setSleepAfterAVCCommand( time ); 147 147 } trunk/libffado/src/ffadodevice.cpp
r504 r554 60 60 61 61 bool 62 FFADODevice::loadFromCache() 63 { 64 return false; 65 } 66 67 bool 68 FFADODevice::saveCache() 69 { 70 return false; 71 } 72 73 bool 62 74 FFADODevice::setId( unsigned int id) 63 75 { trunk/libffado/src/ffadodevice.h
r509 r554 59 59 /// Returns the ConfigRom object of the device node. 60 60 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(); 61 80 62 81 /** trunk/libffado/src/ffado_streaming.cpp
r494 r554 28 28 #include "../libffado/ffado.h" 29 29 #include "devicemanager.h" 30 #include " iavdevice.h"30 #include "ffadodevice.h" 31 31 32 32 #include "libstreaming/StreamProcessorManager.h" … … 139 139 // add the stream processors of the devices to the managers 140 140 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); 142 142 assert(device); 143 143 … … 154 154 // Set the device's sampling rate to that requested 155 155 // 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)) { 157 157 debugOutput(DEBUG_LEVEL_VERBOSE, " => Retry setting samplerate to %d for (%p)\n", 158 158 dev->options.sample_rate, device); 159 159 160 160 // try again: 161 if (!device->setSamplingFrequency( parseSampleRate(dev->options.sample_rate))) {161 if (!device->setSamplingFrequency(dev->options.sample_rate)) { 162 162 delete dev->processorManager; 163 163 delete dev->m_deviceManager; … … 211 211 // iterate over the found devices 212 212 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); 214 214 assert(device); 215 215 … … 236 236 // add the stream processors of the devices to the managers 237 237 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); 239 239 assert(device); 240 240 … … 272 272 // add the stream processors of the devices to the managers 273 273 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); 275 275 assert(device); 276 276 trunk/libffado/src/libavc/avc_definitions.cpp
r445 r554 23 23 24 24 #include "avc_definitions.h" 25 25 #include <libiec61883/iec61883.h> 26 27 namespace AVC { 26 28 27 29 int … … 151 153 return stream << str; 152 154 }; 155 156 enum 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 194 unsigned 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 207 byte_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 22 22 */ 23 23 24 #ifndef AV DDEFINITIONS_H25 #define AV DDEFINITIONS_H24 #ifndef AVCDEFINITIONS_H 25 #define AVCDEFINITIONS_H 26 26 27 27 #include <libavc1394/avc1394.h> 28 28 #include <ostream> 29 30 31 namespace AVC { 29 32 30 33 typedef byte_t ctype_t; … … 83 86 typedef quadlet_t company_id_t; 84 87 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 99 enum 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 118 enum ESubunitType byteToSubunitType(byte_t s); 119 85 120 /** 86 121 * \brief the possible sampling frequencies … … 118 153 std::ostream& operator<<( std::ostream& stream, ESamplingFrequency samplingFrequency ); 119 154 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 */ 160 unsigned int fdfSfcToSampleRate(byte_t fdf); 128 161 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 */ 167 byte_t sampleRateToFdfSfc(unsigned int rate); 130 168 131 #endif // AVDDEFINITIONS_H 169 } 170 171 #endif // AVCDEFINITIONS_H trunk/libffado/src/libavc/general/avc_plug.cpp
r548 r554 1663 1663 // FIXME: The derived class should be creating these, such that discover() can become pure virtual 1664 1664 1665 if ( !deser.isExisting( basePath + "m_subunitType" ) ) { 1666 return 0; 1667 } 1665 1668 Plug* pPlug = new Plug; 1666 1669 if ( !pPlug ) { … … 2221 2224 Unit& unit ) 2222 2225 { 2226 if ( !deser.isExisting( basePath + "m_srcPlug" ) ) { 2227 return 0; 2228 } 2223 2229 PlugConnection* pConnection = new PlugConnection; 2224 2230 if ( !pConnection ) { trunk/libffado/src/libavc/general/avc_subunit.cpp
r524 r554 242 242 bool result; 243 243 ESubunitType sbType; 244 245 if ( !deser.isExisting( basePath + "m_sbType" ) ) { 246 return 0; 247 } 248 244 249 result = deser.read( basePath + "m_sbType", sbType ); 245 250 trunk/libffado/src/libavc/general/avc_unit.cpp
r548 r554 603 603 } 604 604 605 PlugVector digital PCRInputPlugs = getPlugsByType( m_externalPlugs,605 PlugVector digitalExternalInputPlugs = getPlugsByType( m_externalPlugs, 606 606 Plug::eAPD_Input, 607 607 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 } 608 620 609 621 PlugVector syncMSUInputPlugs = m_pPlugManager->getPlugsByType( … … 639 651 debugOutput( DEBUG_LEVEL_VERBOSE, "PCR Iso Output Plugs:\n" ); 640 652 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 ); 643 657 debugOutput( DEBUG_LEVEL_VERBOSE, "MSU Sync Input Plugs:\n" ); 644 658 showPlugs( syncMSUInputPlugs ); … … 670 684 "Internal (CSP)" ); 671 685 672 // Check all external PCRdigital input to MSU input connections686 // Check all external digital input to MSU input connections 673 687 // -> 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, 675 695 syncMSUInputPlugs, 676 696 "Digital Input Sync" ); … … 835 855 Unit::deserializeSyncInfoVector( Glib::ustring basePath, 836 856 Util::IODeserialize& deser, 837 Unit& unit,838 857 SyncInfoVector& vec ) 839 858 { … … 849 868 Glib::ustring description; 850 869 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 } 854 877 855 878 if ( result ) { 856 879 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 ); 859 882 syncInfo.m_description = description; 860 883 … … 895 918 result &= serializeVector( basePath + "PlugConnection", ser, m_plugConnections ); 896 919 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 ); 898 922 899 923 int i = 0; … … 915 939 bool 916 940 Unit::deserialize( Glib::ustring basePath, 917 Unit* pDev,918 941 Util::IODeserialize& deser, 919 942 Ieee1394Service& ieee1394Service ) … … 925 948 setDebugLevel( verboseLevel ); 926 949 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 ) { 930 953 return false; 931 954 } 932 955 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 938 962 939 963 unsigned int i; … … 941 965 942 966 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]; 945 969 } 946 970 } trunk/libffado/src/libavc/general/avc_unit.h
r548 r554 94 94 95 95 bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const; 96 static bool deserialize( Glib::ustring basePath, Unit*,96 bool deserialize( Glib::ustring basePath, 97 97 Util::IODeserialize& deser, 98 98 Ieee1394Service& ieee1394Service ); … … 151 151 152 152 153 staticbool serializeSyncInfoVector( Glib::ustring basePath,153 bool serializeSyncInfoVector( Glib::ustring basePath, 154 154 Util::IOSerialize& ser, 155 155 const SyncInfoVector& vec ); 156 staticbool deserializeSyncInfoVector( Glib::ustring basePath,156 bool deserializeSyncInfoVector( Glib::ustring basePath, 157 157 Util::IODeserialize& deser, 158 Unit& avDevice,159 158 SyncInfoVector& vec ); 160 159 protected: trunk/libffado/src/libosc/OscClient.cpp
r456 r554 73 73 debugOutput(DEBUG_LEVEL_VERBOSE, "Message on: %s\n", path); 74 74 75 return 0; 75 76 } 76 77 trunk/libffado/src/libstreaming/AmdtpPort.h
r445 r554 53 53 enum E_Formats format) 54 54 : AudioPort(name, direction), 55 AmdtpPortInfo( name,position, location, format)55 AmdtpPortInfo(position, location, format) 56 56 {}; 57 57 … … 80 80 enum E_Formats format) 81 81 : MidiPort(name, direction), 82 AmdtpPortInfo( name,position, location, format)82 AmdtpPortInfo(position, location, format) 83 83 {}; 84 84 trunk/libffado/src/libstreaming/AmdtpPortInfo.h
r445 r554 54 54 }; 55 55 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) 58 58 {}; 59 59 virtual ~AmdtpPortInfo() {}; 60 60 61 61 62 std::string getName() {return m_name;};63 62 int getLocation() {return m_location;}; 64 63 int getPosition() {return m_position;}; … … 66 65 67 66 protected: 68 std::string m_name;69 70 67 int m_position; 71 68 int m_location; trunk/libffado/src/libstreaming/AmdtpStreamProcessor.cpp
r535 r554 756 756 { 757 757 bool ok=true; 758 charbyte;758 quadlet_t byte; 759 759 760 760 quadlet_t *target_event=NULL; … … 788 788 789 789 for(j = (dbc & 0x07)+mp->getLocation(); j < nevents; j += 8) { 790 790 791 quadlet_t tmpval; 792 791 793 target_event=(quadlet_t *)(data + ((j * m_dimension) + mp->getPosition())); 792 794 793 795 if(mp->canRead()) { // we can send a byte 794 796 mp->readEvent(&byte); 795 *target_event=htonl( 797 byte &= 0xFF; 798 tmpval=htonl( 796 799 IEC61883_AM824_SET_LABEL((byte)<<16, 797 800 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 798 807 } else { 799 808 // can't send a byte, either because there is no byte, 800 809 // or because this would exceed the maximum rate 801 *target_event=htonl(810 tmpval=htonl( 802 811 IEC61883_AM824_SET_LABEL(0,IEC61883_AM824_LABEL_MIDI_NO_DATA)); 803 812 } 813 814 *target_event=tmpval; 804 815 } 805 816 trunk/libffado/src/libstreaming/MotuPort.h
r445 r554 52 52 int size) 53 53 : AudioPort(name, direction), 54 MotuPortInfo( name,position, size) // TODO: add more port information parameters here if nescessary54 MotuPortInfo( position, size) // TODO: add more port information parameters here if nescessary 55 55 {}; 56 56 … … 76 76 int position) 77 77 : MidiPort(name, direction), 78 MotuPortInfo( name,position, 0) // TODO: add more port information parameters here if nescessary78 MotuPortInfo(position, 0) // TODO: add more port information parameters here if nescessary 79 79 {}; 80 80 … … 101 101 int position) 102 102 : ControlPort(name, direction), 103 MotuPortInfo( name,position, 2) // TODO: add more port information parameters here if nescessary103 MotuPortInfo(position, 2) // TODO: add more port information parameters here if nescessary 104 104 {}; 105 105 trunk/libffado/src/libstreaming/MotuPortInfo.h
r445 r554 60 60 * the name parameter is mandatory 61 61 * 62 * @param name Port name63 62 * @param position Start position of port's data in iso event 64 63 * @param format Format of data in iso event … … 66 65 * @return 67 66 */ 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) 70 69 {}; 71 70 virtual ~MotuPortInfo() {}; 72 71 73 72 74 std::string getName() {return m_name;};75 73 int getPosition() {return m_position;}; 76 74 int getSize() {return m_size;}; 77 75 78 76 protected: 79 std::string m_name;80 77 81 78 int m_position; trunk/libffado/src/libstreaming/Port.cpp
r445 r554 35 35 m_BufferType(E_PointerBuffer), 36 36 m_disabled(true), 37 m_initialized(false),38 37 m_buffersize(0), 39 38 m_eventsize(0), … … 49 48 m_rate_counter(0), 50 49 m_rate_counter_minimum(0), 51 m_average_ratecontrol(false) 52 50 m_average_ratecontrol(false), 51 m_State(E_Created) 53 52 { 54 53 … … 63 62 */ 64 63 bool 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); 67 66 return false; 68 67 } … … 98 97 } 99 98 100 m_initialized=true;101 102 99 m_eventsize=getEventSize(); // this won't change, so cache it 103 104 return m_initialized; 100 101 m_State = E_Initialized; 102 return true; 105 103 } 106 104 … … 112 110 }; 113 111 112 void 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 } 114 125 115 126 void Port::setVerboseLevel(int l) { … … 120 131 debugOutput( DEBUG_LEVEL_VERBOSE, "Setting name to %s for port %s\n",name.c_str(),m_Name.c_str()); 121 132 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); 124 135 return false; 125 136 } … … 132 143 bool Port::setBufferSize(unsigned int newsize) { 133 144 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); 136 147 return false; 137 148 } … … 157 168 bool Port::setDataType(enum E_DataType d) { 158 169 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); 161 172 return false; 162 173 } … … 190 201 bool Port::setSignalType(enum E_SignalType s) { 191 202 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); 194 205 return false; 195 206 } … … 223 234 bool Port::setBufferType(enum E_BufferType b) { 224 235 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); 227 238 return false; 228 239 } … … 257 268 // If called on an initialised stream but the request isn't for a change silently 258 269 // 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) 260 271 return true; 261 272 262 273 debugOutput( DEBUG_LEVEL_VERBOSE, "Setting external buffer use to %d for port %s\n",(int)b,m_Name.c_str()); 263 274 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); 266 277 return false; 267 278 } … … 284 295 /** 285 296 * 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() 287 299 * 288 300 * @param buff … … 296 308 // buffer handling api's for ringbuffers 297 309 bool 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 } 299 322 assert(m_ringbuffer); 323 #endif 300 324 301 325 debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "Writing event %08X with size %d to port %s\n",*((quadlet_t *)event),m_eventsize, m_Name.c_str()); … … 305 329 306 330 bool 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 } 307 343 assert(m_ringbuffer); 308 344 #endif 345 346 309 347 unsigned int read=ffado_ringbuffer_read(m_ringbuffer, (char *)event, m_eventsize); 310 348 311 349 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 312 352 return (read==m_eventsize); 313 353 } 314 354 315 355 int 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 } 317 368 assert(m_ringbuffer); 369 #endif 370 318 371 319 372 unsigned int bytes2write=m_eventsize*nevents; … … 338 391 339 392 int 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 } 340 404 assert(m_ringbuffer); 405 #endif 406 341 407 342 408 unsigned int bytes2read=m_eventsize*nevents; trunk/libffado/src/libstreaming/Port.h
r445 r554 270 270 int readEvents(void *event, unsigned int nevents); ///< read multiple events 271 271 272 virtual void setVerboseLevel(int l); 273 272 virtual void setVerboseLevel(int l); 273 virtual void show(); 274 274 275 protected: 275 276 std::string m_Name; ///< Port name, [at construction] … … 279 280 280 281 bool m_disabled; ///< is the port disabled?, [anytime] 281 bool m_initialized; ///< is the port initialized? [after init()]282 282 283 283 unsigned int m_buffersize; … … 306 306 307 307 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; 309 320 }; 310 321 trunk/libffado/src/libstreaming/PortManager.cpp
r445 r554 25 25 #include "Port.h" 26 26 #include <assert.h> 27 28 #include <iostream> 29 #include <sstream> 27 30 28 31 … … 57 60 // } 58 61 62 bool 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 59 92 /** 60 93 * … … 66 99 assert(port); 67 100 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 } 72 110 } 73 111 trunk/libffado/src/libstreaming/PortManager.h
r445 r554 48 48 virtual ~PortManager(); 49 49 50 virtual bool makeNameUnique(Port *port); 50 51 virtual bool addPort(Port *port); 51 52 virtual bool deletePort(Port *port); trunk/libffado/src/libutil/TimestampedBuffer.h
r512 r554 1 /* $Id$ */2 3 1 /* 4 2 * FFADO Streaming API trunk/libffado/src/Makefile.am
r529 r554 49 49 libieee1394/IEC61883.h \ 50 50 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 \ 52 52 bebob/bebob_avdevice_subunit.h bebob/bebob_avplug.h bebob/bebob_dl_bcd.h bebob/bebob_dl_codes.h \ 53 53 bebob/bebob_dl_mgr.h bebob/bebob_functionblock.h bounce/bounce_avdevice.h bounce/bounce_slave_avdevice.h bebob/bebob_configparser.h \ … … 55 55 maudio/maudio_avdevice.h motu/motu_avdevice.h rme/rme_avdevice.h \ 56 56 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 \ 63 80 libosc/OscArgument.h libosc/OscNode.h libosc/OscResponse.h libosc/OscServer.h libosc/OscMessage.h \ 64 81 libosc/OscClient.h \ … … 78 95 # common sources 79 96 libffado_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 128 154 129 155 # class specific sources … … 140 166 maudio/maudio_avdevice.cpp 141 167 168 genericavc_src = \ 169 genericavc/avc_avdevice.cpp 170 142 171 motu_src = \ 143 172 motu/motu_avdevice.cpp \ … … 216 245 endif 217 246 247 if BUILD_GENERICAVC 248 libffado_la_SOURCES += $(genericavc_src) 249 bin_PROGRAMS += $(genericavc_bin) 250 noinst_PROGRAMS += $(genericavc_noinst) 251 nobase_dist_pkgdata_DATA += $(genericavc_pkgdata) 252 endif 253 218 254 if BUILD_BOUNCE 219 255 libffado_la_SOURCES += $(bounce_src) trunk/libffado/src/maudio/maudio_avdevice.cpp
r479 r554 112 112 113 113 bool 114 AvDevice::setSamplingFrequency( ESamplingFrequencyeSamplingFrequency )114 AvDevice::setSamplingFrequency( int eSamplingFrequency ) 115 115 { 116 116 // not supported trunk/libffado/src/maudio/maudio_avdevice.h
r516 r554 28 28 #include "debugmodule/debugmodule.h" 29 29 #include "libavc/avc_definitions.h" 30 #include "libavc/ avc_extended_cmd_generic.h"30 #include "libavc/general/avc_extended_cmd_generic.h" 31 31 32 32 #include "bebob/bebob_avdevice.h" … … 36 36 #include "libstreaming/AmdtpPortInfo.h" 37 37 38 #include " iavdevice.h"38 #include "ffadodevice.h" 39 39 40 40 class ConfigRom; … … 64 64 virtual void showDevice(); 65 65 66 virtual bool setSamplingFrequency( ESamplingFrequency samplingFrequency);66 virtual bool setSamplingFrequency( int ); 67 67 virtual int getSamplingFrequency( ); 68 68 trunk/libffado/src/metrichalo/mh_avdevice.cpp
r479 r554 53 53 Ieee1394Service& ieee1394service, 54 54 int nodeId ) 55 : IAvDevice( configRom, ieee1394service, nodeId )55 : FFADODevice( configRom, ieee1394service, nodeId ) 56 56 , m_model( NULL ) 57 57 … … 125 125 126 126 bool 127 MHAvDevice::setSamplingFrequency( ESamplingFrequencysamplingFrequency )127 MHAvDevice::setSamplingFrequency( int samplingFrequency ) 128 128 { 129 129 trunk/libffado/src/metrichalo/mh_avdevice.h
r516 r554 25 25 #define MHDEVICE_H 26 26 27 #include " iavdevice.h"27 #include "ffadodevice.h" 28 28 29 29 #include "debugmodule/debugmodule.h" … … 45 45 }; 46 46 47 class MHAvDevice : public IAvDevice {47 class MHAvDevice : public FFADODevice { 48 48 public: 49 49 MHAvDevice( std::auto_ptr<ConfigRom>( configRom ), … … 58 58 virtual void showDevice(); 59 59 60 virtual bool setSamplingFrequency( ESamplingFrequency samplingFrequency);60 virtual bool setSamplingFrequency( int ); 61 61 virtual int getSamplingFrequency( ); 62 62 trunk/libffado/src/motu/motu_avdevice.cpp
r480 r554 59 59 Ieee1394Service& ieee1394service, 60 60 int nodeId) 61 : IAvDevice( configRom, ieee1394service, nodeId )61 : FFADODevice( configRom, ieee1394service, nodeId ) 62 62 , m_motu_model( MOTUFW_MODEL_NONE ) 63 63 , m_iso_recv_channel ( -1 ) … … 177 177 178 178 bool 179 MotuDevice::setSamplingFrequency( ESamplingFrequencysamplingFrequency )179 MotuDevice::setSamplingFrequency( int samplingFrequency ) 180 180 { 181 181 /* … … 187 187 188 188 switch ( samplingFrequency ) { 189 case eSF_22050Hz:189 case 22050: 190 190 supported=false; 191 191 break; 192 case eSF_24000Hz:192 case 24000: 193 193 supported=false; 194 194 break; 195 case eSF_32000Hz:195 case 32000: 196 196 supported=false; 197 197 break; 198 case eSF_44100Hz:198 case 44100: 199 199 new_rate = MOTUFW_RATE_BASE_44100 | MOTUFW_RATE_MULTIPLIER_1X; 200 200 break; 201 case eSF_48000Hz:201 case 48000: 202 202 new_rate = MOTUFW_RATE_BASE_48000 | MOTUFW_RATE_MULTIPLIER_1X; 203 203 break; 204 case eSF_88200Hz:204 case 88200: 205 205 new_rate = MOTUFW_RATE_BASE_44100 | MOTUFW_RATE_MULTIPLIER_2X; 206 206 break; 207 case eSF_96000Hz:207 case 96000: 208 208 new_rate = MOTUFW_RATE_BASE_48000 | MOTUFW_RATE_MULTIPLIER_2X; 209 209 break; 210 case eSF_176400Hz:210 case 176400: 211 211 // Currently only the Traveler supports 4x sample rates 212 212 if (m_motu_model == MOTUFW_MODEL_TRAVELER) { … … 216 216 supported=false; 217 217 break; 218 case eSF_192000Hz:218 case 192000: 219 219 // Currently only the Traveler supports 4x sample rates 220 220 if (m_motu_model == MOTUFW_MODEL_TRAVELER) { trunk/libffado/src/motu/motu_avdevice.h
r516 r554 26 26 #define MOTUDEVICE_H 27 27 28 #include " iavdevice.h"28 #include "ffadodevice.h" 29 29 30 30 #include "debugmodule/debugmodule.h" … … 91 91 }; 92 92 93 class MotuDevice : public IAvDevice {93 class MotuDevice : public FFADODevice { 94 94 public: 95 95 … … 105 105 virtual void showDevice(); 106 106 107 virtual bool setSamplingFrequency( ESamplingFrequencysamplingFrequency );107 virtual bool setSamplingFrequency( int samplingFrequency ); 108 108 virtual int getSamplingFrequency( ); 109 109 trunk/libffado/src/rme/rme_avdevice.cpp
r479 r554 53 53 Ieee1394Service& ieee1394service, 54 54 int nodeId ) 55 : IAvDevice( configRom, ieee1394service, nodeId )55 : FFADODevice( configRom, ieee1394service, nodeId ) 56 56 , m_model( NULL ) 57 57 { … … 128 128 129 129 bool 130 RmeDevice::setSamplingFrequency( ESamplingFrequencysamplingFrequency )130 RmeDevice::setSamplingFrequency( int samplingFrequency ) 131 131 { 132 132 /* 133 133 * Set the RME device's samplerate. 134 134 */ 135 if (samplingFrequency == eSF_48000Hz)135 if (samplingFrequency == 48000) 136 136 return true; 137 137 return false; trunk/libffado/src/rme/rme_avdevice.h
r516 r554 26 26 #define RMEDEVICE_H 27 27 28 #include " iavdevice.h"28 #include "ffadodevice.h" 29 29 30 30 #include "debugmodule/debugmodule.h" … … 46 46 }; 47 47 48 class RmeDevice : public IAvDevice {48 class RmeDevice : public FFADODevice { 49 49 public: 50 50 … … 60 60 virtual void showDevice(); 61 61 62 virtual bool setSamplingFrequency( ESamplingFrequencysamplingFrequency );62 virtual bool setSamplingFrequency( int samplingFrequency ); 63 63 virtual int getSamplingFrequency( ); 64 64 trunk/libffado/tests/Makefile.am
r532 r554 32 32 33 33 if 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 37 noinst_PROGRAMS += test-ffado test-echo 37 38 endif 38 39 … … 43 44 $(LIBXML_LIBS) $(LIBAVC1394_LIBS) $(LIBIEC61883_LIBS) 44 45 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 # 61 test_echo_SOURCES = test-echo.cpp 62 test_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 66 70 67 71 #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.cpp73 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.h78 79 test_timestampedbuffer_LDADD = $(top_builddir)/src/libffado.la $(LIBIEC61883_LIBS) \80 $(LIBRAW1394_LIBS) $(LIBAVC1394_LIBS)81 test_timestampedbuffer_SOURCES = test-timestampedbuffer.cpp72 TEST = 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 128 128 129 129 int 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; 131 137 } 132 138 … … 134 140 { 135 141 136 #define PERIOD_SIZE 512142 #define PERIOD_SIZE 1024 137 143 138 144 int samplesread=0, sampleswritten=0; … … 387 393 break; 388 394 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); 390 396 quadlet_t *buff=(quadlet_t *)audiobuffers_in[i]; 397 if (samplesread) printf("RECV (CH %02X): ", i); 391 398 for (s=0;s<samplesread;s++) { 392 399 quadlet_t *byte=(buff+s) ; 393 //printf("%08X ",*byte);400 printf("%08X ",*byte); 394 401 decode_midi_byte (midi_in_portmap[i], (*byte) & 0xFF); 395 402 } 403 if (samplesread) printf("\n"); 396 404 if(samplesread>0) { 397 405 fprintf(fid_in[i], "---- Period read (%d samples) ----\n",samplesread); … … 428 436 429 437 sampleswritten=encode_midi_bytes(midi_out_portmap[i], byte_buff, max_midi_bytes_to_write); 430 438 if (sampleswritten) printf("SEND (CH %02X): ", i); 431 439 for(b=0;b<sampleswritten;b++) { 432 440 ffado_sample_t tmp_event=*(byte_buff+b); 441 printf("%08X ",*(byte_buff+b)); 433 442 ffado_streaming_write(dev, i, &tmp_event, 1); 434 443 } 435 436 444 if (sampleswritten) printf("\n"); 445 437 446 fprintf(fid_out[i], "---- Period write (%d samples) ----\n",sampleswritten); 438 447 hexDumpToFile(fid_out[i],(unsigned char*)buff,sampleswritten*sizeof(ffado_sample_t)); trunk/libffado/tests/streaming/teststreaming.c
r532 r554 84 84 dev_options.realtime=1; 85 85 dev_options.packetizer_priority=60; 86 86 87 87 dev_options.directions=0; 88 88 … … 93 93 94 94 ffado_device_t *dev=ffado_streaming_init(&device_info, dev_options); 95 95 96 if (!dev) { 96 97 fprintf(stderr,"Could not init FFADO Streaming layer\n"); … … 173 174 } 174 175 175 ffado_streaming_transfer_buffers(dev);176 // ffado_streaming_transfer_buffers(dev); 176 177 ffado_streaming_transfer_capture_buffers(dev); 177 178 ffado_streaming_transfer_playback_buffers(dev); trunk/libffado/tests/streaming/teststreaming2.c
r532 r554 282 282 283 283 ffado_streaming_finish(dev); 284 fclose(of);284 fclose(of); 285 285 286 286 for (i=0;i<nb_out_channels;i++) { trunk/libffado/tests/streaming/teststreaming3.c
r532 r554 99 99 100 100 ffado_device_t *dev=ffado_streaming_init(&device_info, dev_options); 101 101 102 if (!dev) { 102 103 fprintf(stderr,"Could not init Ffado Streaming layer\n"); trunk/libffado/tests/test-ffado.cpp
r445 r554 34 34 #include "fbtypes.h" 35 35 #include "devicemanager.h" 36 #include " iavdevice.h"36 #include "ffadodevice.h" 37 37 38 38 #include <signal.h> … … 193 193 static struct argp argp = { options, parse_opt, args_doc, doc }; 194 194 195 int exitfunction( int retval ) { 196 debugOutput( DEBUG_LEVEL_NORMAL, "Debug output flushed...\n" ); 197 flushDebugOutput(); 198 199 return retval; 200 } 201 195 202 int 196 203 main( int argc, char **argv ) … … 207 214 arguments.args[1] = ""; 208 215 216 setDebugLevel(arguments.verbose); 217 209 218 // Parse our arguments; every option seen by `parse_opt' will 210 219 // be reflected in `arguments'. 211 220 if ( argp_parse ( &argp, argc, argv, 0, 0, &arguments ) ) { 212 221 fprintf( stderr, "Could not parse command line\n" ); 213 return -1;222 return exitfunction(-1); 214 223 } 215 224 … … 222 231 if ( !m_deviceManager ) { 223 232 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); 225 237 } 226 238 if ( !m_deviceManager->initialize( arguments.port ) ) { 227 239 fprintf( stderr, "Could not initialize device manager\n" ); 228 240 delete m_deviceManager; 229 return -1;241 return exitfunction(-1); 230 242 } 231 243 if ( arguments.verbose ) { … … 235 247 fprintf( stderr, "Could not discover devices\n" ); 236 248 delete m_deviceManager; 237 return -1;249 return exitfunction(-1); 238 250 } 239 251 delete m_deviceManager; 240 return 0;252 return exitfunction(0); 241 253 } else if ( strcmp( arguments.args[0], "SetSamplerate" ) == 0 ) { 242 254 char* tail; … … 244 256 if ( errno ) { 245 257 fprintf( stderr, "Could not parse samplerate argument\n" ); 246 return -1;258 return exitfunction(-1); 247 259 } 248 260 … … 250 262 if ( !m_deviceManager ) { 251 263 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); 253 268 } 254 269 if ( !m_deviceManager->initialize( arguments.port ) ) { 255 270 fprintf( stderr, "Could not initialize device manager\n" ); 256 271 delete m_deviceManager; 257 return -1;272 return exitfunction(-1); 258 273 } 259 274 if ( arguments.verbose ) { … … 263 278 fprintf( stderr, "Could not discover devices\n" ); 264 279 delete m_deviceManager; 265 return -1;280 return exitfunction(-1); 266 281 } 267 282 268 283 if(arguments.node_id_set) { 269 IAvDevice* avDevice = m_deviceManager->getAvDevice( arguments.node_id );284 FFADODevice* avDevice = m_deviceManager->getAvDevice( arguments.node_id ); 270 285 if ( avDevice ) { 271 if ( avDevice->setSamplingFrequency( parseSampleRate( samplerate )) ) {286 if ( avDevice->setSamplingFrequency( samplerate ) ) { 272 287 m_deviceManager->discover(); 273 288 } else { … … 284 299 int node_id=m_deviceManager->getDeviceNodeId(i); 285 300 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 ); 287 302 if ( avDevice ) { 288 if ( !avDevice->setSamplingFrequency( parseSampleRate( samplerate )) ) {303 if ( !avDevice->setSamplingFrequency( samplerate ) ) { 289 304 fprintf( stderr, "Could not set samplerate\n" ); 290 305 } … … 293 308 } 294 309 delete m_deviceManager; 295 return 0;310 return exitfunction(0); 296 311 } else if ( strcmp( arguments.args[0], "ListOscSpace" ) == 0 ) { 297 312 // list osc space by using OSC messages … … 314 329 if ( !m_deviceManager ) { 315 330 fprintf( stderr, "Could not allocate device manager\n" ); 316 return -1;331 return exitfunction(-1); 317 332 } 318 333 if ( !m_deviceManager->initialize( arguments.port ) ) { 319 334 fprintf( stderr, "Could not initialize device manager\n" ); 320 335 delete m_deviceManager; 321 return -1;336 return exitfunction(-1); 322 337 } 323 338 if ( arguments.verbose ) { … … 327 342 fprintf( stderr, "Could not discover devices\n" ); 328 343 delete m_deviceManager; 329 return -1;344 return exitfunction(-1); 330 345 } 331 346 … … 345 360 printf("server stopped\n"); 346 361 delete m_deviceManager; 347 return 0;362 return exitfunction(0); 348 363 349 364 } else {