Changeset 424
- Timestamp:
- 02/27/07 03:31:33 (17 years ago)
- Files:
-
- branches/streaming-rework/libfreebob/freebob_streaming.h (modified) (1 diff)
- branches/streaming-rework/src/bebob/bebob_avdevice.cpp (modified) (12 diffs)
- branches/streaming-rework/src/bounce/bounce_avdevice.cpp (modified) (8 diffs)
- branches/streaming-rework/src/bounce/bounce_avdevice.h (modified) (4 diffs)
- branches/streaming-rework/src/bounce/bounce_slave_avdevice.cpp (modified) (2 diffs)
- branches/streaming-rework/src/bounce/bounce_slave_avdevice.h (modified) (1 diff)
- branches/streaming-rework/src/devicemanager.cpp (modified) (15 diffs)
- branches/streaming-rework/src/devicemanager.h (modified) (3 diffs)
- branches/streaming-rework/src/freebob_streaming.cpp (modified) (2 diffs)
- branches/streaming-rework/src/iavdevice.h (modified) (1 diff)
- branches/streaming-rework/src/libieee1394/IEC61883.cpp (added)
- branches/streaming-rework/src/libieee1394/IEC61883.h (added)
- branches/streaming-rework/src/libieee1394/ieee1394service.cpp (modified) (1 diff)
- branches/streaming-rework/src/libieee1394/ieee1394service.h (modified) (2 diffs)
- branches/streaming-rework/src/libstreaming/AmdtpStreamProcessor.cpp (modified) (1 diff)
- branches/streaming-rework/src/libstreaming/AmdtpStreamProcessor.h (modified) (2 diffs)
- branches/streaming-rework/src/libstreaming/StreamProcessor.cpp (modified) (2 diffs)
- branches/streaming-rework/src/libstreaming/StreamProcessor.h (modified) (3 diffs)
- branches/streaming-rework/src/libstreaming/StreamProcessorManager.cpp (modified) (3 diffs)
- branches/streaming-rework/src/libstreaming/StreamProcessorManager.h (modified) (4 diffs)
- branches/streaming-rework/src/Makefile.am (modified) (3 diffs)
- branches/streaming-rework/support/jack/freebob_driver.c (modified) (5 diffs)
- branches/streaming-rework/support/jack/freebob_driver.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/streaming-rework/libfreebob/freebob_streaming.h
r336 r424 122 122 /* verbosity */ 123 123 int verbose; 124 125 /* slave mode */ 126 int slave_mode; 127 128 /* snoop mode */ 129 int snoop_mode; 124 130 125 131 } freebob_options_t; branches/streaming-rework/src/bebob/bebob_avdevice.cpp
r420 r424 725 725 AvDevice::setSamplingFrequency( ESamplingFrequency samplingFrequency ) 726 726 { 727 728 AvPlug* plug = getPlugById( m_pcrPlugs, AvPlug::eAPD_Input, 0 ); 729 if ( !plug ) { 730 debugError( "setSampleRate: Could not retrieve iso input plug 0\n" ); 731 return false; 732 } 733 734 if ( !setSamplingFrequencyPlug( *plug, 735 AvPlug::eAPD_Input, 736 samplingFrequency ) ) 737 { 738 debugError( "setSampleRate: Setting sample rate failed\n" ); 739 return false; 740 } 741 742 plug = getPlugById( m_pcrPlugs, AvPlug::eAPD_Output, 0 ); 743 if ( !plug ) { 744 debugError( "setSampleRate: Could not retrieve iso output plug 0\n" ); 745 return false; 746 } 747 748 if ( !setSamplingFrequencyPlug( *plug, 749 AvPlug::eAPD_Output, 750 samplingFrequency ) ) 751 { 752 debugError( "setSampleRate: Setting sample rate failed\n" ); 753 return false; 754 } 755 756 757 debugOutput( DEBUG_LEVEL_VERBOSE, 758 "setSampleRate: Set sample rate to %d\n", 759 convertESamplingFrequency( samplingFrequency ) ); 760 return true; 727 bool snoopMode=false; 728 if(!getOption("snoopMode", snoopMode)) { 729 debugWarning("Could not retrieve snoopMode parameter, defauling to false\n"); 730 } 731 732 if(snoopMode) { 733 int current_sr=getSamplingFrequency(); 734 if (current_sr != convertESamplingFrequency( samplingFrequency ) ) { 735 debugError("In snoop mode it is impossible to set the sample rate.\n"); 736 debugError("Please start the client with the correct setting.\n"); 737 return false; 738 } 739 return true; 740 } else { 741 AvPlug* plug = getPlugById( m_pcrPlugs, AvPlug::eAPD_Input, 0 ); 742 if ( !plug ) { 743 debugError( "setSampleRate: Could not retrieve iso input plug 0\n" ); 744 return false; 745 } 746 747 if ( !setSamplingFrequencyPlug( *plug, 748 AvPlug::eAPD_Input, 749 samplingFrequency ) ) 750 { 751 debugError( "setSampleRate: Setting sample rate failed\n" ); 752 return false; 753 } 754 755 plug = getPlugById( m_pcrPlugs, AvPlug::eAPD_Output, 0 ); 756 if ( !plug ) { 757 debugError( "setSampleRate: Could not retrieve iso output plug 0\n" ); 758 return false; 759 } 760 761 if ( !setSamplingFrequencyPlug( *plug, 762 AvPlug::eAPD_Output, 763 samplingFrequency ) ) 764 { 765 debugError( "setSampleRate: Setting sample rate failed\n" ); 766 return false; 767 } 768 769 debugOutput( DEBUG_LEVEL_VERBOSE, 770 "setSampleRate: Set sample rate to %d\n", 771 convertESamplingFrequency( samplingFrequency ) ); 772 return true; 773 } 774 // not executable 775 return false; 761 776 } 762 777 … … 955 970 bool 956 971 AvDevice::lock() { 972 bool snoopMode=false; 973 if(!getOption("snoopMode", snoopMode)) { 974 debugWarning("Could not retrieve snoopMode parameter, defauling to false\n"); 975 } 976 977 if (snoopMode) { 978 // don't lock 979 } else { 980 981 } 957 982 958 983 return true; 959 984 } 960 985 961 962 986 bool 963 987 AvDevice::unlock() { 964 988 bool snoopMode=false; 989 if(!getOption("snoopMode", snoopMode)) { 990 debugWarning("Could not retrieve snoopMode parameter, defauling to false\n"); 991 } 992 993 if (snoopMode) { 994 // don't unlock 995 } else { 996 997 } 965 998 return true; 966 999 } … … 972 1005 debugWarning("Could not retrieve snoopMode parameter, defauling to false\n"); 973 1006 } 974 1007 975 1008 /////////// 976 1009 // get plugs … … 989 1022 int samplerate=outputPlug->getSampleRate(); 990 1023 1024 debugOutput( DEBUG_LEVEL_VERBOSE, "Initializing receive processor...\n"); 991 1025 // create & add streamprocessors 992 1026 Streaming::StreamProcessor *p; … … 1013 1047 1014 1048 // do the transmit processor 1049 debugOutput( DEBUG_LEVEL_VERBOSE, "Initializing transmit processor%s...\n", 1050 (snoopMode?" in snoop mode":"")); 1015 1051 if (snoopMode) { 1016 1052 // we are snooping, so this is receive too. … … 1039 1075 return false; 1040 1076 } 1041 m_receiveProcessors.push_back(p);1042 1077 } else { 1043 1078 if (!addPlugToProcessor(*inputPlug,p, … … 1046 1081 return false; 1047 1082 } 1048 m_transmitProcessors.push_back(p); 1049 } 1083 } 1084 1085 // we put this SP into the transmit SP vector, 1086 // no matter if we are in snoop mode or not 1087 // this allows us to find out what direction 1088 // a certain stream should have. 1089 m_transmitProcessors.push_back(p); 1050 1090 1051 1091 return true; … … 1157 1197 AvDevice::startStreamByIndex(int i) { 1158 1198 int iso_channel=-1; 1159 1199 bool snoopMode=false; 1200 if(!getOption("snoopMode", snoopMode)) { 1201 debugWarning("Could not retrieve snoopMode parameter, defauling to false\n"); 1202 } 1203 1160 1204 if (i<(int)m_receiveProcessors.size()) { 1161 1205 int n=i; 1162 1206 Streaming::StreamProcessor *p=m_receiveProcessors.at(n); 1163 1207 1164 iso_channel=m_p1394Service->allocateIsoChannelCMP( 1165 m_pConfigRom->getNodeId() | 0xffc0, 0, 1166 m_p1394Service->getLocalNodeId()| 0xffc0, -1); 1167 1208 if(snoopMode) { // a stream from the device to another host 1209 // FIXME: put this into a decent framework! 1210 // we should check the oPCR[n] on the device 1211 struct iec61883_oPCR opcr; 1212 if (iec61883_get_oPCRX( 1213 m_p1394Service->getHandle(), 1214 m_pConfigRom->getNodeId() | 0xffc0, 1215 (quadlet_t *)&opcr, 1216 n)) { 1217 1218 debugWarning("Error getting the channel for SP %d\n",i); 1219 return false; 1220 } 1221 1222 iso_channel=opcr.channel; 1223 } else { 1224 iso_channel=m_p1394Service->allocateIsoChannelCMP( 1225 m_pConfigRom->getNodeId() | 0xffc0, n, 1226 m_p1394Service->getLocalNodeId()| 0xffc0, -1); 1227 } 1168 1228 if (iso_channel<0) { 1169 1229 debugError("Could not allocate ISO channel for SP %d\n",i); 1170 1230 return false; 1171 1231 } 1232 1233 debugOutput(DEBUG_LEVEL_VERBOSE, "Started SP %d on channel %d\n",i,iso_channel); 1172 1234 1173 1235 p->setChannel(iso_channel); … … 1178 1240 Streaming::StreamProcessor *p=m_transmitProcessors.at(n); 1179 1241 1180 iso_channel=m_p1394Service->allocateIsoChannelCMP( 1181 m_p1394Service->getLocalNodeId()| 0xffc0, -1, 1182 m_pConfigRom->getNodeId() | 0xffc0, 0); 1242 if(snoopMode) { // a stream from another host to the device 1243 // FIXME: put this into a decent framework! 1244 // we should check the iPCR[n] on the device 1245 struct iec61883_iPCR ipcr; 1246 if (iec61883_get_iPCRX( 1247 m_p1394Service->getHandle(), 1248 m_pConfigRom->getNodeId() | 0xffc0, 1249 (quadlet_t *)&ipcr, 1250 n)) { 1251 1252 debugWarning("Error getting the channel for SP %d\n",i); 1253 return false; 1254 } 1255 1256 iso_channel=ipcr.channel; 1257 1258 } else { 1259 iso_channel=m_p1394Service->allocateIsoChannelCMP( 1260 m_p1394Service->getLocalNodeId()| 0xffc0, -1, 1261 m_pConfigRom->getNodeId() | 0xffc0, n); 1262 } 1183 1263 1184 1264 if (iso_channel<0) { … … 1187 1267 } 1188 1268 1269 debugOutput(DEBUG_LEVEL_VERBOSE, "Started SP %d on channel %d\n",i,iso_channel); 1270 1189 1271 p->setChannel(iso_channel); 1190 1272 return true; … … 1197 1279 bool 1198 1280 AvDevice::stopStreamByIndex(int i) { 1199 if (i<(int)m_receiveProcessors.size()) { 1281 bool snoopMode=false; 1282 if(!getOption("snoopMode", snoopMode)) { 1283 debugWarning("Could not retrieve snoopMode parameter, defauling to false\n"); 1284 } 1285 1286 if (i<(int)m_receiveProcessors.size()) { 1200 1287 int n=i; 1201 1288 Streaming::StreamProcessor *p=m_receiveProcessors.at(n); 1202 1289 1203 // deallocate ISO channel 1204 if(!m_p1394Service->freeIsoChannel(p->getChannel())) { 1205 debugError("Could not deallocate iso channel for SP %d\n",i); 1206 return false; 1290 if(snoopMode) { 1291 1292 } else { 1293 // deallocate ISO channel 1294 if(!m_p1394Service->freeIsoChannel(p->getChannel())) { 1295 debugError("Could not deallocate iso channel for SP %d\n",i); 1296 return false; 1297 } 1207 1298 } 1208 1299 p->setChannel(-1); … … 1214 1305 Streaming::StreamProcessor *p=m_transmitProcessors.at(n); 1215 1306 1216 // deallocate ISO channel 1217 if(!m_p1394Service->freeIsoChannel(p->getChannel())) { 1218 debugError("Could not deallocate iso channel for SP %d\n",i); 1219 return false; 1307 if(snoopMode) { 1308 1309 } else { 1310 // deallocate ISO channel 1311 if(!m_p1394Service->freeIsoChannel(p->getChannel())) { 1312 debugError("Could not deallocate iso channel for SP %d\n",i); 1313 return false; 1314 } 1220 1315 } 1221 1316 p->setChannel(-1); branches/streaming-rework/src/bounce/bounce_avdevice.cpp
r420 r424 45 45 static VendorModelEntry supportedDeviceList[] = 46 46 { 47 {0x0B0001 , 0x0B0001, 0x0B0001, "FreeBoB", "Bounce"},47 {0x0B0001LU, 0x0B0001LU, 0x0B0001LU, "FreeBoB", "Bounce"}, 48 48 }; 49 49 … … 58 58 , m_p1394Service( &ieee1394service ) 59 59 , m_nodeId( nodeId ) 60 , m_verboseLevel( verboseLevel ) 60 // , m_verboseLevel( verboseLevel ) 61 , m_verboseLevel( DEBUG_LEVEL_VERBOSE ) 61 62 , m_samplerate (44100) 62 63 , m_model( NULL ) … … 85 86 BounceDevice::probe( ConfigRom& configRom ) 86 87 { 88 89 debugOutput( DEBUG_LEVEL_VERBOSE, "probing BounceDevice\n"); 87 90 // unsigned int vendorId = configRom.getNodeVendorId(); 88 91 unsigned int modelId = configRom.getModelId(); 89 92 unsigned int unitSpecifierId = configRom.getUnitSpecifierId(); 93 debugOutput( DEBUG_LEVEL_VERBOSE, "modelId = 0x%08X, specid = 0x%08X\n", modelId, unitSpecifierId); 90 94 91 95 for ( unsigned int i = 0; … … 109 113 BounceDevice::discover() 110 114 { 111 // unsigned int resp_len=0; 112 // quadlet_t request[6]; 113 // quadlet_t *resp; 114 115 debugOutput( DEBUG_LEVEL_VERBOSE, "discovering BounceDevice (NodeID %d)\n", 116 m_nodeId ); 117 115 118 // unsigned int vendorId = m_configRom->getNodeVendorId(); 116 119 unsigned int modelId = m_configRom->getModelId(); … … 135 138 return true; 136 139 } 137 138 debugOutput( DEBUG_LEVEL_VERBOSE, "Discovering...\n" ); 139 140 std::string vendor=std::string(FREEBOB_BOUNCE_SERVER_VENDORNAME); 141 std::string model=std::string(FREEBOB_BOUNCE_SERVER_MODELNAME); 142 143 if (!(m_configRom->getVendorName().compare(0,vendor.length(),vendor,0,vendor.length())==0) 144 || !(m_configRom->getModelName().compare(0,model.length(),model,0,model.length())==0)) { 145 return false; 146 } 147 /* 148 // AVC1394_COMMAND_INPUT_PLUG_SIGNAL_FORMAT 149 request[0] = htonl( AVC1394_CTYPE_STATUS | (AVC1394_SUBUNIT_TYPE_FREEBOB_BOUNCE_SERVER << 19) | (0 << 16) 150 | AVC1394_COMMAND_INPUT_PLUG_SIGNAL_FORMAT | 0x00); 151 152 request[1] = 0xFFFFFFFF; 153 resp = m_p1394Service->transactionBlock( m_nodeId, 154 request, 155 2, 156 &resp_len ); 157 // hexDump((unsigned char *)request,6*4); 158 if(resp) { 159 char *buffer=(char *)&resp[1]; 160 resp[resp_len-1]=0; 161 xmlDescription=buffer; 162 // hexDump((unsigned char *)resp,6*4); 163 } 164 */ 165 return true; 140 return false; 166 141 } 167 142 … … 212 187 debugOutput(DEBUG_LEVEL_NORMAL, "Node : %d\n", m_nodeId); 213 188 debugOutput(DEBUG_LEVEL_NORMAL, "GUID : 0x%016llX\n", m_configRom->getGuid()); 214 debugOutput(DEBUG_LEVEL_NORMAL, "AVC test response : %s\n", xmlDescription.c_str());215 189 debugOutput(DEBUG_LEVEL_NORMAL, "\n" ); 216 190 } … … 434 408 // write value of ISO_CHANNEL register 435 409 reg_isoch=isochannel; 436 if(!writeReg(BOUNCE_REGISTER_ TX_ISOCHANNEL, reg_isoch)) {410 if(!writeReg(BOUNCE_REGISTER_RX_ISOCHANNEL, reg_isoch)) { 437 411 debugError("Could not write ISO_CHANNEL register\n"); 438 412 p->setChannel(-1); … … 451 425 bool 452 426 BounceDevice::stopStreamByIndex(int i) { 453 454 return false; 427 if (i<(int)m_receiveProcessors.size()) { 428 int n=i; 429 Streaming::StreamProcessor *p=m_receiveProcessors.at(n); 430 unsigned int isochannel=p->getChannel(); 431 432 fb_quadlet_t reg_isoch; 433 // check value of ISO_CHANNEL register 434 if(!readReg(BOUNCE_REGISTER_TX_ISOCHANNEL, ®_isoch)) { 435 debugError("Could not read ISO_CHANNEL register\n"); 436 return false; 437 } 438 if(reg_isoch != isochannel) { 439 debugError("ISO_CHANNEL register != 0x%08X (=0x%08X)\n", isochannel, reg_isoch); 440 return false; 441 } 442 443 // write value of ISO_CHANNEL register 444 reg_isoch=0xFFFFFFFFUL; 445 if(!writeReg(BOUNCE_REGISTER_TX_ISOCHANNEL, reg_isoch)) { 446 debugError("Could not write ISO_CHANNEL register" ); 447 return false; 448 } 449 450 // deallocate ISO channel 451 if(!deallocateIsoChannel(isochannel)) { 452 debugError("Could not deallocate iso channel for SP\n",i); 453 return false; 454 } 455 456 p->setChannel(-1); 457 return true; 458 459 } else if (i<(int)m_receiveProcessors.size() + (int)m_transmitProcessors.size()) { 460 int n=i-m_receiveProcessors.size(); 461 Streaming::StreamProcessor *p=m_transmitProcessors.at(n); 462 463 unsigned int isochannel=p->getChannel(); 464 465 fb_quadlet_t reg_isoch; 466 // check value of ISO_CHANNEL register 467 if(!readReg(BOUNCE_REGISTER_RX_ISOCHANNEL, ®_isoch)) { 468 debugError("Could not read ISO_CHANNEL register\n"); 469 return false; 470 } 471 if(reg_isoch != isochannel) { 472 debugError("ISO_CHANNEL register != 0x%08X (=0x%08X)\n", isochannel, reg_isoch); 473 return false; 474 } 475 476 // write value of ISO_CHANNEL register 477 reg_isoch=0xFFFFFFFFUL; 478 if(!writeReg(BOUNCE_REGISTER_RX_ISOCHANNEL, reg_isoch)) { 479 debugError("Could not write ISO_CHANNEL register\n"); 480 return false; 481 } 482 483 // deallocate ISO channel 484 if(!deallocateIsoChannel(isochannel)) { 485 debugError("Could not deallocate iso channel for SP (%d)\n",i); 486 return false; 487 } 488 489 p->setChannel(-1); 490 return true; 491 } 492 493 debugError("SP index %d out of range!\n",i); 494 return false; 455 495 } 456 496 branches/streaming-rework/src/bounce/bounce_avdevice.h
r420 r424 51 51 // struct to define the supported devices 52 52 struct VendorModelEntry { 53 u nsigned int vendor_id;54 u nsigned int model_id;55 u nsigned int unit_specifier_id;53 uint32_t vendor_id; 54 uint32_t model_id; 55 uint32_t unit_specifier_id; 56 56 char *vendor_name; 57 57 char *model_name; … … 69 69 70 70 static bool probe( ConfigRom& configRom ); 71 virtualbool discover();72 virtualConfigRom& getConfigRom() const;71 bool discover(); 72 ConfigRom& getConfigRom() const; 73 73 74 virtualbool addXmlDescription( xmlNodePtr deviceNode );74 bool addXmlDescription( xmlNodePtr deviceNode ); 75 75 76 virtualbool setSamplingFrequency( ESamplingFrequency samplingFrequency );77 virtualint getSamplingFrequency( );76 bool setSamplingFrequency( ESamplingFrequency samplingFrequency ); 77 int getSamplingFrequency( ); 78 78 79 virtualbool prepare();79 bool prepare(); 80 80 bool lock(); 81 81 bool unlock(); 82 83 virtualint getStreamCount();84 85 virtualStreaming::StreamProcessor *getStreamProcessorByIndex(int i);86 82 83 int getStreamCount(); 84 85 Streaming::StreamProcessor *getStreamProcessorByIndex(int i); 86 87 87 bool startStreamByIndex(int i); 88 88 bool stopStreamByIndex(int i); 89 89 90 v irtual void showDevice() const;91 virtualbool setId(unsigned int id);90 void showDevice() const; 91 bool setId(unsigned int id); 92 92 93 93 protected: … … 97 97 int m_verboseLevel; 98 98 99 private:100 99 std::string xmlDescription; 101 100 … … 117 116 int allocateIsoChannel(unsigned int packet_size); 118 117 bool deallocateIsoChannel(int channel); 119 120 pr ivate: // I/O helpers118 119 protected: // I/O helpers 121 120 // quadlet read/write routines 122 121 bool readReg(fb_nodeaddr_t, fb_quadlet_t *); branches/streaming-rework/src/bounce/bounce_slave_avdevice.cpp
r422 r424 26 26 * 27 27 */ 28 29 #include "BounceSlaveDevice.h" 28 #include "libieee1394/configrom.h" 29 #include "libieee1394/ieee1394service.h" 30 31 #include "bounce_slave_avdevice.h" 32 #include "libfreebob/freebob_bounce.h" 33 34 #include <libraw1394/raw1394.h> 35 #include <libavc1394/rom1394.h> 30 36 31 37 namespace Bounce { 32 38 33 IMPL_DEBUG_MODULE( BounceSlaveDevice, BounceSlaveDevice, DEBUG_LEVEL_NORMAL ); 34 35 BounceSlaveDevice::BounceSlaveDevice() { 36 39 static VendorModelEntry supportedDeviceList[] = 40 { 41 //{vendor_id, model_id, unit_specifier_id, vendor_name, model_name}, 42 {0x0B0001, 0x0B0001, 0x0B0001, "FreeBoB", "Bounce Slave"}, 43 }; 44 45 IMPL_DEBUG_MODULE( BounceSlaveDevice, BounceSlaveDevice, DEBUG_LEVEL_VERBOSE ); 46 47 BounceSlaveDevice::BounceSlaveDevice( std::auto_ptr< ConfigRom >( configRom ), 48 Ieee1394Service& ieee1394service, 49 int verboseLevel ) 50 : BounceDevice( configRom, 51 ieee1394service, 52 ieee1394service.getLocalNodeId(), 53 // verboseLevel ) 54 DEBUG_LEVEL_VERBOSE ) 55 { 56 addOption(Util::OptionContainer::Option("isoTimeoutSecs",(int64_t)120)); 37 57 } 38 58 … … 41 61 } 42 62 63 bool 64 BounceSlaveDevice::probe( ConfigRom& configRom ) 65 { 66 // we are always capable of constructing a slave device 67 return true; 68 } 69 70 bool 71 BounceSlaveDevice::discover() 72 { 73 m_model = &(supportedDeviceList[0]); 74 if (m_model != NULL) { 75 debugOutput( DEBUG_LEVEL_VERBOSE, "found %s %s\n", 76 m_model->vendor_name, m_model->model_name); 77 return true; 78 } 79 return false; 80 } 81 82 bool BounceSlaveDevice::initMemSpace() { 83 debugOutput(DEBUG_LEVEL_VERBOSE, "Initializing memory space...\n"); 84 fb_quadlet_t result=0xFFFFFFFFLU; 85 86 // initialize the ISO channel registers 87 // this will write to our own registers 88 if (!writeReg(BOUNCE_REGISTER_TX_ISOCHANNEL, result)) { 89 debugError("Could not initalize ISO channel register for TX\n"); 90 return false; 91 } 92 if (!writeReg(BOUNCE_REGISTER_RX_ISOCHANNEL, result)) { 93 debugError("Could not initalize ISO channel register for TX\n"); 94 return false; 95 } 96 97 // set everything such that we can be discovered 98 m_original_config_rom=save_config_rom( m_p1394Service->getHandle() ); 99 100 if ( init_config_rom( m_p1394Service->getHandle() ) < 0 ) { 101 debugError("Could not initalize local config rom\n"); 102 return false; 103 } 104 105 // refresh our config rom cache 106 if ( !m_configRom->initialize() ) { 107 // \todo If a PHY on the bus is in power safe mode then 108 // the config rom is missing. So this might be just 109 // such this case and we can safely skip it. But it might 110 // be there is a real software problem on our side. 111 // This should be handled more carefuly. 112 debugError( "Could not reread config rom from device (node id %d).\n", 113 m_nodeId ); 114 return false; 115 } 116 return true; 117 } 118 119 bool BounceSlaveDevice::restoreMemSpace() { 120 debugOutput(DEBUG_LEVEL_VERBOSE, "Restoring memory space...\n"); 121 restore_config_rom( m_p1394Service->getHandle(), m_original_config_rom); 122 return true; 123 } 124 125 bool 126 BounceSlaveDevice::lock() { 127 debugOutput(DEBUG_LEVEL_VERBOSE, "Locking %s %s at node %d\n", 128 m_model->vendor_name, m_model->model_name, m_nodeId); 129 130 // get a notifier to handle device notifications 131 nodeaddr_t notify_address; 132 notify_address = m_p1394Service->findFreeARMBlock( 133 BOUNCE_REGISTER_BASE, 134 BOUNCE_REGISTER_LENGTH, 135 BOUNCE_REGISTER_LENGTH); 136 137 if (notify_address == 0xFFFFFFFFFFFFFFFFLLU) { 138 debugError("Could not find free ARM block for notification\n"); 139 return false; 140 } 141 142 m_Notifier=new BounceSlaveDevice::BounceSlaveNotifier(this, notify_address); 143 144 if(!m_Notifier) { 145 debugError("Could not allocate notifier\n"); 146 return false; 147 } 148 149 if (!m_p1394Service->registerARMHandler(m_Notifier)) { 150 debugError("Could not register notifier\n"); 151 delete m_Notifier; 152 m_Notifier=NULL; 153 return false; 154 } 155 156 // (re)initialize the memory space 157 if (!initMemSpace()) { 158 debugError("Could not initialize memory space\n"); 159 return false; 160 } 161 162 return true; 163 } 164 165 bool 166 BounceSlaveDevice::unlock() { 167 // (re)initialize the memory space 168 if (!restoreMemSpace()) { 169 debugError("Could not restore memory space\n"); 170 return false; 171 } 172 m_p1394Service->unregisterARMHandler(m_Notifier); 173 delete m_Notifier; 174 m_Notifier=NULL; 175 176 return true; 177 } 178 179 bool 180 BounceSlaveDevice::prepare() { 181 // snooping does not make sense for a slave device 182 setOption("snoopMode", false); 183 184 // prepare the base class 185 // FIXME: when doing proper discovery this won't work anymore 186 // as it relies on a completely symmetric transmit/receive 187 if(!BounceDevice::prepare()) { 188 debugError("Base class preparation failed\n"); 189 return false; 190 } 191 192 // do any customisations here 193 194 return true; 195 } 196 197 // this has to wait until the ISO channel numbers are written 198 bool 199 BounceSlaveDevice::startStreamByIndex(int i) { 200 201 if (i<(int)m_receiveProcessors.size()) { 202 int n=i; 203 Streaming::StreamProcessor *p=m_receiveProcessors.at(n); 204 205 // the other side sends on this channel 206 nodeaddr_t iso_channel_offset = BOUNCE_REGISTER_RX_ISOCHANNEL; 207 iso_channel_offset += ((unsigned)n)*4; 208 209 if (!waitForRegisterNotEqualTo(iso_channel_offset, 0xFFFFFFFFLU)) { 210 debugError("Timeout waiting for stream %d to get an ISO channel\n",i); 211 return false; 212 } 213 214 fb_quadlet_t result; 215 // this will read from our own registers 216 if (!readReg(iso_channel_offset, &result)) { 217 debugError("Could not read ISO channel register for stream %d\n",i); 218 return false; 219 } 220 221 // set ISO channel 222 p->setChannel(result); 223 224 return true; 225 226 } else if (i<(int)m_receiveProcessors.size() + (int)m_transmitProcessors.size()) { 227 int n=i-m_receiveProcessors.size(); 228 Streaming::StreamProcessor *p=m_transmitProcessors.at(n); 229 230 // the other side sends on this channel 231 nodeaddr_t iso_channel_offset = BOUNCE_REGISTER_TX_ISOCHANNEL; 232 iso_channel_offset += ((unsigned)n)*4; 233 234 if (!waitForRegisterNotEqualTo(iso_channel_offset, 0xFFFFFFFF)) { 235 debugError("Timeout waiting for stream %d to get an ISO channel\n",i); 236 return false; 237 } 238 239 fb_quadlet_t result; 240 // this will read from our own registers 241 if (!readReg(iso_channel_offset, &result)) { 242 debugError("Could not read ISO channel register for stream %d\n",i); 243 return false; 244 } 245 246 // set ISO channel 247 p->setChannel(result); 248 249 return true; 250 251 } 252 253 debugError("SP index %d out of range!\n",i); 254 255 return false; 256 } 257 258 bool 259 BounceSlaveDevice::stopStreamByIndex(int i) { 260 // nothing special to do I guess... 261 return false; 262 } 263 264 // helpers 265 bool 266 BounceSlaveDevice::waitForRegisterNotEqualTo(nodeaddr_t offset, fb_quadlet_t v) { 267 debugOutput( DEBUG_LEVEL_VERBOSE, "Waiting for StreamProcessor streams to start running...\n"); 268 // we have to wait until all streamprocessors indicate that they are running 269 // i.e. that there is actually some data stream flowing 270 int timeoutSecs=120; 271 if(!getOption("isoTimeoutSecs", timeoutSecs)) { 272 debugWarning("Could not retrieve isoTimeoutSecs parameter, defauling to 120secs\n"); 273 } 274 275 int wait_cycles=timeoutSecs*10; // two seconds 276 277 fb_quadlet_t reg=v; 278 279 while ((v == reg) && wait_cycles) { 280 wait_cycles--; 281 if (!readReg(offset,®)) { 282 debugError("Could not read register\n"); 283 return false; 284 } 285 usleep(100000); 286 } 287 288 if(!wait_cycles) { // timout has occurred 289 return false; 290 } 291 292 return true; 293 } 294 295 // configrom helpers 296 // FIXME: should be changed into a better framework 297 298 299 struct BounceSlaveDevice::configrom_backup 300 BounceSlaveDevice::save_config_rom(raw1394handle_t handle) 301 { 302 int retval; 303 struct configrom_backup tmp; 304 /* get the current rom image */ 305 retval=raw1394_get_config_rom(handle, tmp.rom, 0x100, &tmp.rom_size, &tmp.rom_version); 306 // tmp.rom_size=rom1394_get_size(tmp.rom); 307 // printf("save_config_rom get_config_rom returned %d, romsize %d, rom_version %d:\n",retval,tmp.rom_size,tmp.rom_version); 308 309 return tmp; 310 } 311 312 int 313 BounceSlaveDevice::restore_config_rom(raw1394handle_t handle, struct BounceSlaveDevice::configrom_backup old) 314 { 315 int retval; 316 // int i; 317 318 quadlet_t current_rom[0x100]; 319 size_t current_rom_size; 320 unsigned char current_rom_version; 321 322 retval=raw1394_get_config_rom(handle, current_rom, 0x100, ¤t_rom_size, ¤t_rom_version); 323 // printf("restore_config_rom get_config_rom returned %d, romsize %d, rom_version %d:\n",retval,current_rom_size,current_rom_version); 324 325 // printf("restore_config_rom restoring to romsize %d, rom_version %d:\n",old.rom_size,old.rom_version); 326 327 retval = raw1394_update_config_rom(handle, old.rom, old.rom_size, current_rom_version); 328 // printf("restore_config_rom update_config_rom returned %d\n",retval); 329 330 /* get the current rom image */ 331 retval=raw1394_get_config_rom(handle, current_rom, 0x100, ¤t_rom_size, ¤t_rom_version); 332 current_rom_size = rom1394_get_size(current_rom); 333 // printf("get_config_rom returned %d, romsize %d, rom_version %d:",retval,current_rom_size,current_rom_version); 334 // for (i = 0; i < current_rom_size; i++) 335 // { 336 // if (i % 4 == 0) printf("\n0x%04x:", CSR_CONFIG_ROM+i*4); 337 // printf(" %08x", ntohl(current_rom[i])); 338 // } 339 // printf("\n"); 340 341 return retval; 342 } 343 344 int 345 BounceSlaveDevice::init_config_rom(raw1394handle_t handle) 346 { 347 int retval, i; 348 quadlet_t rom[0x100]; 349 size_t rom_size; 350 unsigned char rom_version; 351 rom1394_directory dir; 352 char *leaf; 353 354 /* get the current rom image */ 355 retval=raw1394_get_config_rom(handle, rom, 0x100, &rom_size, &rom_version); 356 rom_size = rom1394_get_size(rom); 357 // printf("get_config_rom returned %d, romsize %d, rom_version %d:",retval,rom_size,rom_version); 358 // for (i = 0; i < rom_size; i++) 359 // { 360 // if (i % 4 == 0) printf("\n0x%04x:", CSR_CONFIG_ROM+i*4); 361 // printf(" %08x", ntohl(rom[i])); 362 // } 363 // printf("\n"); 364 365 /* get the local directory */ 366 rom1394_get_directory( handle, raw1394_get_local_id(handle) & 0x3f, &dir); 367 368 /* change the vendor description for kicks */ 369 i = strlen(dir.textual_leafs[0]); 370 strncpy(dir.textual_leafs[0], FREEBOB_BOUNCE_SERVER_VENDORNAME " ", i); 371 372 dir.vendor_id=FREEBOB_BOUNCE_SERVER_VENDORID; 373 dir.model_id=FREEBOB_BOUNCE_SERVER_MODELID; 374 375 /* update the rom */ 376 retval = rom1394_set_directory(rom, &dir); 377 // printf("rom1394_set_directory returned %d, romsize %d:",retval,rom_size); 378 // for (i = 0; i < rom_size; i++) 379 // { 380 // if (i % 4 == 0) printf("\n0x%04x:", CSR_CONFIG_ROM+i*4); 381 // printf(" %08x", ntohl(rom[i])); 382 // } 383 // printf("\n"); 384 385 /* free the allocated mem for the textual leaves */ 386 rom1394_free_directory( &dir); 387 388 /* add an AV/C unit directory */ 389 dir.unit_spec_id = FREEBOB_BOUNCE_SERVER_SPECID; 390 dir.unit_sw_version = 0x00010001; 391 leaf = FREEBOB_BOUNCE_SERVER_MODELNAME; 392 dir.nr_textual_leafs = 1; 393 dir.textual_leafs = &leaf; 394 395 /* manipulate the rom */ 396 retval = rom1394_add_unit( rom, &dir); 397 398 /* get the computed size of the rom image */ 399 rom_size = rom1394_get_size(rom); 400 401 // printf("rom1394_add_unit_directory returned %d, romsize %d:",retval,rom_size); 402 // for (i = 0; i < rom_size; i++) 403 // { 404 // if (i % 4 == 0) printf("\n0x%04x:", CSR_CONFIG_ROM+i*4); 405 // printf(" %08x", ntohl(rom[i])); 406 // } 407 // printf("\n"); 408 // 409 /* convert computed rom size from quadlets to bytes before update */ 410 rom_size *= sizeof(quadlet_t); 411 retval = raw1394_update_config_rom(handle, rom, rom_size, rom_version); 412 // printf("update_config_rom returned %d\n",retval); 413 414 retval=raw1394_get_config_rom(handle, rom, 0x100, &rom_size, &rom_version); 415 // printf("get_config_rom returned %d, romsize %d, rom_version %d:",retval,rom_size,rom_version); 416 // for (i = 0; i < rom_size; i++) 417 // { 418 // if (i % 4 == 0) printf("\n0x%04x:", CSR_CONFIG_ROM+i*4); 419 // printf(" %08x", ntohl(rom[i])); 420 // } 421 // printf("\n"); 422 423 // printf("You need to reload your ieee1394 modules to reset the rom.\n"); 424 425 return 0; 426 } 427 428 429 // the notifier 430 431 BounceSlaveDevice::BounceSlaveNotifier::BounceSlaveNotifier(BounceSlaveDevice *d, nodeaddr_t start) 432 : ARMHandler(start, BOUNCE_REGISTER_LENGTH, 433 RAW1394_ARM_READ | RAW1394_ARM_WRITE, // allowed operations 434 0, //RAW1394_ARM_READ | RAW1394_ARM_WRITE, // operations to be notified of 435 0) // operations that are replied to by us (instead of kernel) 436 , m_bounceslavedevice(d) 437 { 438 439 } 440 441 BounceSlaveDevice::BounceSlaveNotifier::~BounceSlaveNotifier() 442 { 443 444 } 445 43 446 } // end of namespace Bounce branches/streaming-rework/src/bounce/bounce_slave_avdevice.h
r422 r424 29 29 #define __FREEBOB_BOUNCESLAVEDEVICE__ 30 30 31 #include "../debugmodule/debugmodule.h" 31 #include "debugmodule/debugmodule.h" 32 #include "bounce_avdevice.h" 32 33 33 34 namespace Bounce { 34 35 35 class BounceSlaveDevice {36 36 class BounceSlaveDevice : public BounceDevice { 37 class BounceSlaveNotifier; 37 38 public: 38 39 39 BounceSlaveDevice(); 40 virtual ~BounceSlaveDevice(); 40 BounceSlaveDevice( std::auto_ptr<ConfigRom>( configRom ), 41 Ieee1394Service& ieee1394Service, 42 int verboseLevel ); 43 virtual ~BounceSlaveDevice(); 44 45 static bool probe( ConfigRom& configRom ); 46 bool discover(); 47 bool prepare(); 48 bool lock(); 49 bool unlock(); 50 51 bool startStreamByIndex(int i); 52 bool stopStreamByIndex(int i); 53 41 54 42 55 protected: 43 56 DECLARE_DEBUG_MODULE; 57 private: 58 bool waitForRegisterNotEqualTo(nodeaddr_t offset, fb_quadlet_t v); 59 bool initMemSpace(); 60 bool restoreMemSpace(); 61 62 private: // configrom shit 44 63 64 struct configrom_backup { 65 quadlet_t rom[0x100]; 66 size_t rom_size; 67 unsigned char rom_version; 68 }; 69 struct configrom_backup m_original_config_rom; 70 71 struct configrom_backup 72 save_config_rom(raw1394handle_t handle); 73 int restore_config_rom(raw1394handle_t handle, struct configrom_backup old); 74 int init_config_rom(raw1394handle_t handle); 75 76 private: 77 BounceSlaveNotifier *m_Notifier; 78 /** 79 * this class reacts on the ohter side writing to the 80 * hosts address space 81 */ 82 class BounceSlaveNotifier : public ARMHandler 83 { 84 public: 85 BounceSlaveNotifier(BounceSlaveDevice *, nodeaddr_t start); 86 virtual ~BounceSlaveNotifier(); 87 88 private: 89 BounceSlaveDevice *m_bounceslavedevice; 90 }; 45 91 }; 46 92 branches/streaming-rework/src/devicemanager.cpp
r419 r424 43 43 #ifdef ENABLE_BOUNCE 44 44 #include "bounce/bounce_avdevice.h" 45 #include "bounce/bounce_slave_avdevice.h" 45 46 #endif 46 47 … … 68 69 : m_1394Service( 0 ) 69 70 { 70 71 addOption(Util::OptionContainer::Option("slaveMode",false)); 72 addOption(Util::OptionContainer::Option("snoopMode",false)); 71 73 } 72 74 … … 105 107 DeviceManager::discover( int verboseLevel ) 106 108 { 109 bool slaveMode=false; 110 if(!getOption("slaveMode", slaveMode)) { 111 debugWarning("Could not retrieve slaveMode parameter, defauling to false\n"); 112 } 113 bool snoopMode=false; 114 if(!getOption("snoopMode", snoopMode)) { 115 debugWarning("Could not retrieve snoopMode parameter, defauling to false\n"); 116 } 107 117 108 118 setDebugLevel( verboseLevel ); … … 117 127 m_avDevices.clear(); 118 128 119 for ( fb_nodeid_t nodeId = 0; 120 nodeId < m_1394Service->getNodeCount(); 121 ++nodeId ) 122 { 123 debugOutput( DEBUG_LEVEL_VERBOSE, "Probing node %d...\n", nodeId ); 124 125 if (nodeId == m_1394Service->getLocalNodeId()) { 126 debugOutput( DEBUG_LEVEL_VERBOSE, "Skipping local node (%d)...\n", nodeId ); 127 continue; 128 } 129 if (!slaveMode) { 130 for ( fb_nodeid_t nodeId = 0; 131 nodeId < m_1394Service->getNodeCount(); 132 ++nodeId ) 133 { 134 debugOutput( DEBUG_LEVEL_VERBOSE, "Probing node %d...\n", nodeId ); 135 136 if (nodeId == m_1394Service->getLocalNodeId()) { 137 debugOutput( DEBUG_LEVEL_VERBOSE, "Skipping local node (%d)...\n", nodeId ); 138 continue; 139 } 140 141 std::auto_ptr<ConfigRom> configRom = 142 std::auto_ptr<ConfigRom>( new ConfigRom( *m_1394Service, 143 nodeId ) ); 144 if ( !configRom->initialize() ) { 145 // \todo If a PHY on the bus is in power safe mode then 146 // the config rom is missing. So this might be just 147 // such this case and we can safely skip it. But it might 148 // be there is a real software problem on our side. 149 // This should be handled more carefuly. 150 debugOutput( DEBUG_LEVEL_NORMAL, 151 "Could not read config rom from device (node id %d). " 152 "Skip device discovering for this node\n", 153 nodeId ); 154 continue; 155 } 156 157 IAvDevice* avDevice = getDriverForDevice( configRom, 158 nodeId, 159 verboseLevel ); 160 if ( avDevice ) { 161 debugOutput( DEBUG_LEVEL_NORMAL, 162 "discover: driver found for device %d\n", 163 nodeId ); 164 165 if ( !avDevice->discover() ) { 166 debugError( "discover: could not discover device\n" ); 167 delete avDevice; 168 continue; 169 } 170 171 if ( !avDevice->setId( m_avDevices.size() ) ) { 172 debugError( "setting Id failed\n" ); 173 } 174 175 if (snoopMode) { 176 debugOutput( DEBUG_LEVEL_VERBOSE, 177 "Enabling snoop mode on node %d...\n", nodeId ); 178 179 if(!avDevice->setOption("snoopMode", snoopMode)) { 180 debugWarning("Could not set snoop mode for device on node %d\n",nodeId); 181 delete avDevice; 182 continue; 183 } 184 } 185 186 avDevice->setVerboseLevel( verboseLevel ); 187 188 if ( verboseLevel ) { 189 avDevice->showDevice(); 190 } 191 192 m_avDevices.push_back( avDevice ); 193 } 194 } 195 return true; 196 197 } else { // slave mode 198 fb_nodeid_t nodeId = m_1394Service->getLocalNodeId(); 199 debugOutput( DEBUG_LEVEL_VERBOSE, "Starting in slave mode on node %d...\n", nodeId ); 129 200 130 201 std::auto_ptr<ConfigRom> configRom = … … 141 212 "Skip device discovering for this node\n", 142 213 nodeId ); 143 continue; 144 } 145 146 IAvDevice* avDevice = getDriverForDevice( configRom, 147 nodeId, 148 verboseLevel ); 214 return false; 215 } 216 217 IAvDevice* avDevice = getSlaveDriver( configRom, verboseLevel ); 149 218 if ( avDevice ) { 150 219 debugOutput( DEBUG_LEVEL_NORMAL, … … 155 224 debugError( "discover: could not discover device\n" ); 156 225 delete avDevice; 157 continue;226 return false; 158 227 } 159 228 … … 167 236 m_avDevices.push_back( avDevice ); 168 237 } 169 }170 171 return true;238 239 return true; 240 } 172 241 } 173 242 … … 178 247 { 179 248 #ifdef ENABLE_BEBOB 249 debugOutput( DEBUG_LEVEL_VERBOSE, "Trying BeBoB...\n" ); 180 250 if ( BeBoB::AvDevice::probe( *configRom.get() ) ) { 181 251 return new BeBoB::AvDevice( configRom, *m_1394Service, id, level ); … … 184 254 185 255 #ifdef ENABLE_BEBOB 256 debugOutput( DEBUG_LEVEL_VERBOSE, "Trying M-Audio...\n" ); 186 257 if ( MAudio::AvDevice::probe( *configRom.get() ) ) { 187 258 return new MAudio::AvDevice( configRom, *m_1394Service, id, level ); … … 190 261 191 262 #ifdef ENABLE_MOTU 263 debugOutput( DEBUG_LEVEL_VERBOSE, "Trying Motu...\n" ); 192 264 if ( Motu::MotuDevice::probe( *configRom.get() ) ) { 193 265 return new Motu::MotuDevice( configRom, *m_1394Service, id, level ); … … 196 268 197 269 #ifdef ENABLE_DICE 270 debugOutput( DEBUG_LEVEL_VERBOSE, "Trying Dice...\n" ); 198 271 if ( Dice::DiceAvDevice::probe( *configRom.get() ) ) { 199 272 return new Dice::DiceAvDevice( configRom, *m_1394Service, id, level ); … … 202 275 203 276 #ifdef ENABLE_METRIC_HALO 277 debugOutput( DEBUG_LEVEL_VERBOSE, "Trying Metric Halo...\n" ); 204 278 if ( MetricHalo::MHAvDevice::probe( *configRom.get() ) ) { 205 279 return new MetricHalo::MHAvDevice( configRom, *m_1394Service, id, level ); … … 208 282 209 283 #ifdef ENABLE_RME 284 debugOutput( DEBUG_LEVEL_VERBOSE, "Trying RME...\n" ); 210 285 if ( Rme::RmeDevice::probe( *configRom.get() ) ) { 211 286 return new Rme::RmeDevice( configRom, *m_1394Service, id, level ); … … 214 289 215 290 #ifdef ENABLE_BOUNCE 291 debugOutput( DEBUG_LEVEL_VERBOSE, "Trying Bounce...\n" ); 216 292 if ( Bounce::BounceDevice::probe( *configRom.get() ) ) { 217 293 return new Bounce::BounceDevice( configRom, *m_1394Service, id, level ); 294 } 295 #endif 296 297 return 0; 298 } 299 300 IAvDevice* 301 DeviceManager::getSlaveDriver( std::auto_ptr<ConfigRom>( configRom ), int level ) 302 { 303 304 #ifdef ENABLE_BOUNCE 305 if ( Bounce::BounceSlaveDevice::probe( *configRom.get() ) ) { 306 return new Bounce::BounceSlaveDevice( configRom, *m_1394Service, level ); 218 307 } 219 308 #endif … … 300 389 DeviceManager::getSyncSource() { 301 390 IAvDevice* device = getAvDeviceByIndex(0); 302 return device->getStreamProcessorByIndex(0); 303 391 392 bool slaveMode=false; 393 if(!getOption("slaveMode", slaveMode)) { 394 debugWarning("Could not retrieve slaveMode parameter, defauling to false\n"); 395 } 396 304 397 #warning TEST CODE FOR BOUNCE DEVICE !! 305 if (device->getConfigRom().getNodeId()==0) { 398 // this makes the bounce slave use the xmit SP as sync source 399 if (slaveMode) { 400 return device->getStreamProcessorByIndex(1); 401 } else { 306 402 return device->getStreamProcessorByIndex(0); 307 } else {308 return device->getStreamProcessorByIndex(1);309 403 } 310 404 branches/streaming-rework/src/devicemanager.h
r419 r424 25 25 26 26 #include "libfreebob/xmlparser.h" 27 #include "libutil/OptionContainer.h" 27 28 28 29 #include <glibmm/ustring.h> … … 42 43 43 44 44 class DeviceManager {45 class DeviceManager : public Util::OptionContainer { 45 46 public: 46 47 DeviceManager(); … … 71 72 int id, 72 73 int level ); 74 IAvDevice* getSlaveDriver( std::auto_ptr<ConfigRom>( configRom ), 75 int level ); 73 76 74 77 protected: branches/streaming-rework/src/freebob_streaming.cpp
r419 r424 109 109 return 0; 110 110 } 111 111 112 // set slave mode option 113 bool slaveMode=(dev->options.slave_mode != 0); 114 debugOutput(DEBUG_LEVEL_VERBOSE, "setting slave mode to %d\n", slaveMode); 115 if(!dev->m_deviceManager->setOption("slaveMode", slaveMode)) { 116 debugWarning("Failed to set slave mode option\n"); 117 } 118 // set snoop mode option 119 bool snoopMode=(dev->options.snoop_mode != 0); 120 debugOutput(DEBUG_LEVEL_VERBOSE, "setting snoop mode to %d\n", snoopMode); 121 if(!dev->m_deviceManager->setOption("snoopMode", snoopMode)) { 122 debugWarning("Failed to set snoop mode option\n"); 123 } 124 112 125 // discover the devices on the bus 113 126 if(!dev->m_deviceManager->discover(DEBUG_LEVEL_NORMAL)) { 114 127 debugFatal("Could not discover devices\n"); 128 delete dev->processorManager; 129 delete dev->m_deviceManager; 130 delete dev; 131 return 0; 132 } 133 134 // are there devices on the bus? 135 if(dev->m_deviceManager->getAvDeviceCount()==0) { 136 debugFatal("There are no devices on the bus\n"); 115 137 delete dev->processorManager; 116 138 delete dev->m_deviceManager; … … 177 199 178 200 int freebob_streaming_prepare(freebob_device_t *dev) { 179 180 181 201 debugOutput(DEBUG_LEVEL_VERBOSE, "Preparing...\n"); 202 203 if (!dev->processorManager->prepare()) { 182 204 debugFatal("Could not prepare streaming...\n"); 183 205 return false; 184 185 186 206 } 207 208 return true; 187 209 } 188 210 branches/streaming-rework/src/iavdevice.h
r420 r424 216 216 virtual bool stopStreamByIndex(int i) = 0; 217 217 218 /** 219 * set verbosity level 220 */ 221 virtual void setVerboseLevel(int l) {setDebugLevel(l);}; 218 222 }; 219 223 branches/streaming-rework/src/libieee1394/ieee1394service.cpp
r415 r424 117 117 m_default_arm_handler = raw1394_set_arm_tag_handler( m_resetHandle, 118 118 this->armHandlerLowLevel ); 119 119 120 startRHThread(); 120 121 branches/streaming-rework/src/libieee1394/ieee1394service.h
r415 r424 28 28 #include "debugmodule/debugmodule.h" 29 29 30 #include "IEC61883.h" 31 30 32 #include <libraw1394/raw1394.h> 31 33 #include <pthread.h> … … 35 37 class ARMHandler; 36 38 37 class Ieee1394Service {39 class Ieee1394Service : public IEC61883 { 38 40 public: 39 41 Ieee1394Service(); branches/streaming-rework/src/libstreaming/AmdtpStreamProcessor.cpp
r419 r424 1211 1211 } 1212 1212 1213 1214 debugOutput( DEBUG_LEVEL_VERBOSE, "Prepared for:\n"); 1215 debugOutput( DEBUG_LEVEL_VERBOSE, " Samplerate: %d, DBS: %d, SYT: %d\n", 1216 m_framerate,m_dimension,m_syt_interval); 1217 debugOutput( DEBUG_LEVEL_VERBOSE, " PeriodSize: %d, NbBuffers: %d\n", 1218 m_period,m_nb_buffers); 1219 debugOutput( DEBUG_LEVEL_VERBOSE, " Port: %d, Channel: %d\n", 1220 m_port,m_channel); 1221 1213 debugOutput( DEBUG_LEVEL_VERBOSE, "Prepared for:\n"); 1214 debugOutput( DEBUG_LEVEL_VERBOSE, " Samplerate: %d, DBS: %d, SYT: %d\n", 1215 m_framerate,m_dimension,m_syt_interval); 1216 debugOutput( DEBUG_LEVEL_VERBOSE, " PeriodSize: %d, NbBuffers: %d\n", 1217 m_period,m_nb_buffers); 1218 debugOutput( DEBUG_LEVEL_VERBOSE, " Port: %d, Channel: %d\n", 1219 m_port,m_channel); 1220 1221 return true; 1222 1222 1223 1223 } branches/streaming-rework/src/libstreaming/AmdtpStreamProcessor.h
r419 r424 145 145 int encodeSilencePortToMBLAEvents(AmdtpAudioPort *, quadlet_t *data, 146 146 unsigned int offset, unsigned int nevents); 147 147 void updatePreparedState(); 148 148 149 unsigned long m_last_timestamp; 149 150 … … 216 217 217 218 int decodeMBLAEventsToPort(AmdtpAudioPort *, quadlet_t *data, unsigned int offset, unsigned int nevents); 219 void updatePreparedState(); 218 220 219 221 int m_dimension; branches/streaming-rework/src/libstreaming/StreamProcessor.cpp
r419 r424 185 185 186 186 bool StreamProcessor::isRunning() { 187 187 return m_running; 188 188 } 189 189 … … 215 215 216 216 m_disabled=false; 217 218 217 return true; 219 218 } 220 219 221 220 bool StreamProcessor::disable() { 222 223 221 m_disabled=true; 224 225 return true; 226 222 return true; 227 223 } 228 224 branches/streaming-rework/src/libstreaming/StreamProcessor.h
r419 r424 37 37 38 38 #include "libutil/StreamStatistics.h" 39 40 39 #include "libutil/TimestampedBuffer.h" 40 #include "libutil/OptionContainer.h" 41 41 42 42 namespace Streaming { … … 54 54 class StreamProcessor : public IsoStream, 55 55 public PortManager, 56 public Util::TimestampedBufferClient { 56 public Util::TimestampedBufferClient, 57 public Util::OptionContainer { 57 58 58 59 friend class StreamProcessorManager; … … 112 113 Util::TimestampedBuffer *m_data_buffer; 113 114 114 protected: 115 115 protected: // SPM related 116 116 void setManager(StreamProcessorManager *manager) {m_manager=manager;}; 117 117 void clearManager() {m_manager=0;}; 118 118 119 protected: 119 120 unsigned int m_nb_buffers; ///< cached from manager->getNbBuffers(), the number of periods to buffer 120 121 unsigned int m_period; ///< cached from manager->getPeriod(), the period size branches/streaming-rework/src/libstreaming/StreamProcessorManager.cpp
r419 r424 48 48 49 49 StreamProcessorManager::StreamProcessorManager(unsigned int period, unsigned int nb_buffers) 50 : m_SyncSource(NULL), m_nb_buffers(nb_buffers), m_period(period), m_xruns(0), 51 m_isoManager(0), m_nbperiods(0) { 52 50 : m_is_slave( false ) 51 , m_SyncSource(NULL) 52 , m_nb_buffers(nb_buffers) 53 , m_period(period) 54 , m_xruns(0) 55 , m_isoManager(0) 56 , m_nbperiods(0) 57 { 58 addOption(Util::OptionContainer::Option("slaveMode",false)); 53 59 } 54 60 … … 195 201 debugOutput( DEBUG_LEVEL_VERBOSE, "Preparing...\n"); 196 202 197 // if no sync source is set, select one here 198 if(m_SyncSource == NULL) { 199 debugWarning("Sync Source is not set. Defaulting to first StreamProcessor.\n"); 200 } 201 202 for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin(); 203 it != m_ReceiveProcessors.end(); 204 ++it ) { 205 if(m_SyncSource == NULL) { 206 debugWarning(" => Sync Source is %p.\n", *it); 207 m_SyncSource = *it; 208 } 209 } 210 211 for ( StreamProcessorVectorIterator it = m_TransmitProcessors.begin(); 212 it != m_TransmitProcessors.end(); 213 ++it ) { 214 if(m_SyncSource == NULL) { 215 debugWarning(" => Sync Source is %p.\n", *it); 216 m_SyncSource = *it; 217 } 218 } 219 220 // now do the actual preparation 221 debugOutput( DEBUG_LEVEL_VERBOSE, "Prepare Receive processors...\n"); 222 for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin(); 223 it != m_ReceiveProcessors.end(); 224 ++it ) { 225 if(!(*it)->setSyncSource(m_SyncSource)) { 226 debugFatal( " could not set sync source (%p)...\n",(*it)); 227 return false; 228 } 229 230 if(!(*it)->prepare()) { 231 debugFatal( " could not prepare (%p)...\n",(*it)); 232 return false; 233 } 234 } 235 236 debugOutput( DEBUG_LEVEL_VERBOSE, "Prepare Transmit processors...\n"); 237 for ( StreamProcessorVectorIterator it = m_TransmitProcessors.begin(); 238 it != m_TransmitProcessors.end(); 239 ++it ) { 240 if(!(*it)->setSyncSource(m_SyncSource)) { 241 debugFatal( " could not set sync source (%p)...\n",(*it)); 242 return false; 243 } 244 if(!(*it)->prepare()) { 245 debugFatal( " could not prepare (%p)...\n",(*it)); 246 return false; 247 } 248 } 203 m_is_slave=false; 204 if(!getOption("snoopMode", m_is_slave)) { 205 debugWarning("Could not retrieve slaveMode parameter, defauling to false\n"); 206 } 207 208 // if no sync source is set, select one here 209 if(m_SyncSource == NULL) { 210 debugWarning("Sync Source is not set. Defaulting to first StreamProcessor.\n"); 211 } 212 213 for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin(); 214 it != m_ReceiveProcessors.end(); 215 ++it ) { 216 if(m_SyncSource == NULL) { 217 debugWarning(" => Sync Source is %p.\n", *it); 218 m_SyncSource = *it; 219 } 220 } 221 222 for ( StreamProcessorVectorIterator it = m_TransmitProcessors.begin(); 223 it != m_TransmitProcessors.end(); 224 ++it ) { 225 if(m_SyncSource == NULL) { 226 debugWarning(" => Sync Source is %p.\n", *it); 227 m_SyncSource = *it; 228 } 229 } 230 231 // now do the actual preparation 232 debugOutput( DEBUG_LEVEL_VERBOSE, "Prepare Receive processors...\n"); 233 for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin(); 234 it != m_ReceiveProcessors.end(); 235 ++it ) { 236 237 if(!(*it)->setSyncSource(m_SyncSource)) { 238 debugFatal( " could not set sync source (%p)...\n",(*it)); 239 return false; 240 } 241 242 if(!(*it)->setOption("slaveMode", m_is_slave)) { 243 debugOutput(DEBUG_LEVEL_VERBOSE, " note: could not set slaveMode option for (%p)...\n",(*it)); 244 } 245 246 if(!(*it)->prepare()) { 247 debugFatal( " could not prepare (%p)...\n",(*it)); 248 return false; 249 } 250 } 251 252 debugOutput( DEBUG_LEVEL_VERBOSE, "Prepare Transmit processors...\n"); 253 for ( StreamProcessorVectorIterator it = m_TransmitProcessors.begin(); 254 it != m_TransmitProcessors.end(); 255 ++it ) { 256 if(!(*it)->setSyncSource(m_SyncSource)) { 257 debugFatal( " could not set sync source (%p)...\n",(*it)); 258 return false; 259 } 260 if(!(*it)->setOption("slaveMode", m_is_slave)) { 261 debugOutput(DEBUG_LEVEL_VERBOSE, " note: could not set slaveMode option for (%p)...\n",(*it)); 262 } 263 if(!(*it)->prepare()) { 264 debugFatal( " could not prepare (%p)...\n",(*it)); 265 return false; 266 } 267 } 249 268 250 269 // if there are no stream processors registered, … … 818 837 xmt_bf = (*it)->getBufferFill(); 819 838 } 820 debugOutput( DEBUG_LEVEL_VER BOSE, "XF at %011llu ticks, RBF=%d, XBF=%d, SUM=%d...\n",839 debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "XF at %011llu ticks, RBF=%d, XBF=%d, SUM=%d...\n", 821 840 m_time_of_transfer,rcv_bf,xmt_bf,rcv_bf+xmt_bf); 822 841 branches/streaming-rework/src/libstreaming/StreamProcessorManager.h
r419 r424 29 29 #define __FREEBOB_STREAMPROCESSORMANAGER__ 30 30 31 #include "../debugmodule/debugmodule.h" 32 #include "../libutil/Thread.h" 31 #include "debugmodule/debugmodule.h" 32 #include "libutil/Thread.h" 33 #include "libutil/OptionContainer.h" 33 34 #include <semaphore.h> 34 35 #include "Port.h" … … 50 51 51 52 */ 52 class StreamProcessorManager { 53 53 class StreamProcessorManager : public Util::OptionContainer { 54 friend class StreamProcessor; 55 54 56 public: 55 57 … … 108 110 virtual void setVerboseLevel(int l); 109 111 void dumpInfo(); 110 112 113 private: // slaving support 114 bool m_is_slave; 111 115 112 116 // the sync source stuff … … 118 122 StreamProcessor * getSyncSource(); 119 123 120 121 124 protected: 125 122 126 // thread sync primitives 123 127 bool m_xrun_happened; branches/streaming-rework/src/Makefile.am
r420 r424 35 35 libieee1394/configrom.h libieee1394/csr1212.h \ 36 36 libieee1394/ieee1394service.h libieee1394/ARMHandler.h \ 37 libieee1394/IEC61883.h \ 37 38 debugmodule/debugmodule.h \ 38 39 devicemanager.h fbtypes.h iavdevice.h threads.h bebob/bebob_avdevice.h \ 39 40 bebob/bebob_avdevice_subunit.h bebob/bebob_avplug.h bebob/bebob_dl_bcd.h bebob/bebob_dl_codes.h \ 40 bebob/bebob_dl_mgr.h bebob/bebob_functionblock.h bounce/bounce_avdevice.h \41 bebob/bebob_dl_mgr.h bebob/bebob_functionblock.h bounce/bounce_avdevice.h bounce/bounce_slave_avdevice.h \ 41 42 maudio/maudio_avdevice.h motu/motu_avdevice.h rme/rme_avdevice.h \ 42 43 metrichalo/mh_avdevice.h dice/dice_avdevice.h \ … … 83 84 libieee1394/csr1212.c \ 84 85 libieee1394/ieee1394service.cpp \ 86 libieee1394/IEC61883.cpp \ 85 87 libstreaming/cip.c \ 86 88 libstreaming/IsoHandler.cpp \ … … 126 128 127 129 bounce_src = \ 128 bounce/bounce_avdevice.cpp 130 bounce/bounce_avdevice.cpp \ 131 bounce/bounce_slave_avdevice.cpp 129 132 130 133 metric_halo_src = \ branches/streaming-rework/support/jack/freebob_driver.c
r369 r424 642 642 driver->device_options.node_id=params->node_id; 643 643 driver->device_options.port=params->port; 644 driver->device_options.slave_mode=params->slave_mode; 645 driver->device_options.snoop_mode=params->snoop_mode; 644 646 645 647 if(!params->capture_ports) { … … 1028 1030 1029 1031 strcpy (desc->name, "freebob"); 1030 desc->nparams = 6;1032 desc->nparams = 8; 1031 1033 1032 1034 params = calloc (desc->nparams, sizeof (jack_driver_param_desc_t)); … … 1079 1081 params[i].value.ui = 1U; 1080 1082 strcpy (params[i].short_desc, "Provide playback ports."); 1083 strcpy (params[i].long_desc, params[i].short_desc); 1084 1085 i++; 1086 strcpy (params[i].name, "slave"); 1087 params[i].character = 'x'; 1088 params[i].type = JackDriverParamUInt; 1089 params[i].value.ui = 0U; 1090 strcpy (params[i].short_desc, "Act as a BounceDevice slave"); 1091 strcpy (params[i].long_desc, params[i].short_desc); 1092 1093 i++; 1094 strcpy (params[i].name, "slave"); 1095 params[i].character = 'X'; 1096 params[i].type = JackDriverParamUInt; 1097 params[i].value.ui = 0U; 1098 strcpy (params[i].short_desc, "Operate in snoop mode"); 1081 1099 strcpy (params[i].long_desc, params[i].short_desc); 1082 1100 … … 1115 1133 cmlparams.playback_ports=1; 1116 1134 cmlparams.capture_ports=1; 1135 cmlparams.slave_mode=0; 1136 cmlparams.snoop_mode=0; 1117 1137 1118 1138 for (node = params; node; node = jack_slist_next (node)) … … 1143 1163 cmlparams.playback_ports = param->value.ui; 1144 1164 break; 1165 case 'x': 1166 cmlparams.slave_mode = param->value.ui; 1167 break; 1168 case 'X': 1169 cmlparams.snoop_mode = param->value.ui; 1170 break; 1145 1171 } 1146 1172 } branches/streaming-rework/support/jack/freebob_driver.h
r247 r424 137 137 typedef struct _freebob_jack_settings freebob_jack_settings_t; 138 138 struct _freebob_jack_settings { 139 int period_size_set; 140 jack_nframes_t period_size; 141 142 int sample_rate_set; 143 int sample_rate; 144 145 int buffer_size_set; 146 jack_nframes_t buffer_size; 147 148 int port_set; 149 int port; 150 151 int node_id_set; 152 int node_id; 153 154 int playback_ports; 155 int capture_ports; 156 157 freebob_handle_t fb_handle; 139 int period_size_set; 140 jack_nframes_t period_size; 141 142 int sample_rate_set; 143 int sample_rate; 144 145 int buffer_size_set; 146 jack_nframes_t buffer_size; 147 148 int port_set; 149 int port; 150 151 int node_id_set; 152 int node_id; 153 154 int playback_ports; 155 int capture_ports; 156 157 int slave_mode; 158 int snoop_mode; 159 160 freebob_handle_t fb_handle; 158 161 }; 159 162