Changeset 416
- Timestamp:
- 02/25/07 02:46:00 (16 years ago)
- Files:
-
- branches/streaming-rework/src/bebob/bebob_avdevice.cpp (modified) (14 diffs)
- branches/streaming-rework/src/bebob/bebob_avdevice.h (modified) (2 diffs)
- branches/streaming-rework/src/bounce/bounce_avdevice.cpp (modified) (6 diffs)
- branches/streaming-rework/src/bounce/bounce_avdevice.h (modified) (4 diffs)
- branches/streaming-rework/src/iavdevice.h (modified) (3 diffs)
- branches/streaming-rework/src/libutil/OptionContainer.cpp (added)
- branches/streaming-rework/src/libutil/OptionContainer.h (added)
- branches/streaming-rework/src/libutil/unittests.cpp (modified) (4 diffs)
- branches/streaming-rework/src/Makefile.am (modified) (2 diffs)
- branches/streaming-rework/src/maudio/maudio_avdevice.cpp (modified) (9 diffs)
- branches/streaming-rework/src/maudio/maudio_avdevice.h (modified) (3 diffs)
- branches/streaming-rework/src/metrichalo/mh_avdevice.cpp (modified) (8 diffs)
- branches/streaming-rework/src/metrichalo/mh_avdevice.h (modified) (1 diff)
- branches/streaming-rework/src/motu/motu_avdevice.cpp (modified) (16 diffs)
- branches/streaming-rework/src/motu/motu_avdevice.h (modified) (1 diff)
- branches/streaming-rework/src/rme/rme_avdevice.cpp (modified) (5 diffs)
- branches/streaming-rework/src/rme/rme_avdevice.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/streaming-rework/src/bebob/bebob_avdevice.cpp
r415 r416 76 76 , m_model ( NULL ) 77 77 , m_nodeId ( nodeId ) 78 , m_id( 0 )79 , m_snoopMode( false )80 78 { 81 79 setDebugLevel( verboseLevel ); 82 80 debugOutput( DEBUG_LEVEL_VERBOSE, "Created BeBoB::AvDevice (NodeID %d)\n", 83 81 nodeId ); 82 addOption(FreebobUtil::OptionContainer::Option("snoopMode",false)); 83 addOption(FreebobUtil::OptionContainer::Option("id",std::string("dev?"))); 84 84 } 85 85 … … 92 92 , m_model ( NULL ) 93 93 , m_nodeId ( -1 ) 94 , m_id( 0 ) 95 , m_snoopMode( false )96 { 94 { 95 addOption(FreebobUtil::OptionContainer::Option("snoopMode",false)); 96 addOption(FreebobUtil::OptionContainer::Option("id",std::string("dev?"))); 97 97 } 98 98 99 99 AvDevice::~AvDevice() 100 100 { 101 101 102 for ( AvDeviceSubunitVector::iterator it = m_subunits.begin(); 102 103 it != m_subunits.end(); … … 166 167 { 167 168 m_model = &(supportedDeviceList[i]); 169 break; 168 170 } 169 171 } … … 942 944 { 943 945 // FIXME: decent ID system nescessary 944 m_id=id; 945 return true; 946 std::ostringstream idstr; 947 948 idstr << "dev" << id; 949 950 debugOutput( DEBUG_LEVEL_VERBOSE, "Set id to %s...\n", idstr.str().c_str()); 951 952 return setOption("id",idstr.str()); 946 953 } 947 954 … … 961 968 bool 962 969 AvDevice::prepare() { 970 bool snoopMode=false; 971 if(!getOption("snoopMode", snoopMode)) { 972 debugWarning("Could not retrieve snoopMode parameter, defauling to false\n"); 973 } 974 963 975 /////////// 964 976 // get plugs … … 1001 1013 1002 1014 // do the transmit processor 1003 if ( m_snoopMode) {1015 if (snoopMode) { 1004 1016 // we are snooping, so this is receive too. 1005 1017 p=new FreebobStreaming::AmdtpReceiveStreamProcessor( … … 1016 1028 if(!p->init()) { 1017 1029 debugFatal("Could not initialize transmit processor %s!\n", 1018 ( m_snoopMode?" in snoop mode":""));1030 (snoopMode?" in snoop mode":"")); 1019 1031 delete p; 1020 1032 return false; 1021 1033 } 1022 1034 1023 if ( m_snoopMode) {1035 if (snoopMode) { 1024 1036 if (!addPlugToProcessor(*inputPlug,p, 1025 1037 FreebobStreaming::Port::E_Capture)) { … … 1027 1039 return false; 1028 1040 } 1041 m_receiveProcessors.push_back(p); 1029 1042 } else { 1030 1043 if (!addPlugToProcessor(*inputPlug,p, … … 1033 1046 return false; 1034 1047 } 1048 m_transmitProcessors.push_back(p); 1035 1049 } 1036 1050 … … 1043 1057 FreebobStreaming::StreamProcessor *processor, 1044 1058 FreebobStreaming::AmdtpAudioPort::E_Direction direction) { 1045 1059 1060 std::string id=std::string("dev?"); 1061 if(!getOption("id", id)) { 1062 debugWarning("Could not retrieve id parameter, defauling to 'dev?'\n"); 1063 } 1064 1046 1065 AvPlug::ClusterInfoVector& clusterInfos = plug.getClusterInfos(); 1047 1066 for ( AvPlug::ClusterInfoVector::const_iterator it = clusterInfos.begin(); … … 1059 1078 std::ostringstream portname; 1060 1079 1061 portname << "dev" << m_id << "_" << channelInfo->m_name;1080 portname << id << "_" << channelInfo->m_name; 1062 1081 1063 1082 FreebobStreaming::Port *p=NULL; … … 1332 1351 Util::IOSerialize& ser ) const 1333 1352 { 1353 1334 1354 bool result; 1335 1355 result = m_pConfigRom->serialize( basePath + "m_pConfigRom/", ser ); … … 1353 1373 } 1354 1374 1355 result &= ser.write( basePath + "m_id", m_id );1375 // result &= ser.write( basePath + "m_id", id ); 1356 1376 1357 1377 return result; … … 1397 1417 } 1398 1418 1399 result &= deser.read( basePath + "m_id", pDev->m_id );1419 // result &= deser.read( basePath + "m_id", pDev->m_id ); 1400 1420 } 1401 1421 branches/streaming-rework/src/bebob/bebob_avdevice.h
r415 r416 40 40 41 41 #include <sstream> 42 #include <vector> 42 43 43 44 class ConfigRom; … … 181 182 struct VendorModelEntry* m_model; 182 183 int m_nodeId; 183 unsigned int m_id;184 bool m_snoopMode;185 184 186 185 // streaming stuff branches/streaming-rework/src/bounce/bounce_avdevice.cpp
r415 r416 56 56 int verboseLevel ) 57 57 : m_configRom( configRom ) 58 , m_ 1394Service( &ieee1394service )58 , m_p1394Service( &ieee1394service ) 59 59 , m_nodeId( nodeId ) 60 60 , m_verboseLevel( verboseLevel ) 61 61 , m_samplerate (44100) 62 62 , m_model( NULL ) 63 , m_id(0) 64 , m_receiveProcessor ( 0 ) 65 , m_receiveProcessorBandwidth ( -1 ) 66 , m_transmitProcessor ( 0 ) 67 , m_transmitProcessorBandwidth ( -1 ) 63 , m_Notifier ( NULL ) 68 64 { 69 65 setDebugLevel( verboseLevel ); … … 71 67 debugOutput( DEBUG_LEVEL_VERBOSE, "Created Bounce::BounceDevice (NodeID %d)\n", 72 68 nodeId ); 69 addOption(FreebobUtil::OptionContainer::Option("snoopMode",false)); 70 addOption(FreebobUtil::OptionContainer::Option("id",std::string("dev?"))); 73 71 } 74 72 … … 153 151 154 152 request[1] = 0xFFFFFFFF; 155 resp = m_ 1394Service->transactionBlock( m_nodeId,153 resp = m_p1394Service->transactionBlock( m_nodeId, 156 154 request, 157 155 2, … … 181 179 182 180 bool BounceDevice::setId( unsigned int id) { 183 debugOutput( DEBUG_LEVEL_VERBOSE, "Set id to %d...\n", id); 184 m_id=id; 185 return true; 181 // FIXME: decent ID system nescessary 182 std::ostringstream idstr; 183 184 idstr << "dev" << id; 185 186 debugOutput( DEBUG_LEVEL_VERBOSE, "Set id to %s...\n", idstr.str().c_str()); 187 188 return setOption("id",idstr.str()); 186 189 } 187 190 … … 225 228 bool 226 229 BounceDevice::addPortsToProcessor( 227 228 FreebobStreaming::AmdtpAudioPort::E_Direction direction) {230 FreebobStreaming::StreamProcessor *processor, 231 FreebobStreaming::Port::E_Direction direction) { 229 232 230 233 debugOutput(DEBUG_LEVEL_VERBOSE,"Adding ports to processor\n"); 231 234 235 std::string id=std::string("dev?"); 236 if(!getOption("id", id)) { 237 debugWarning("Could not retrieve id parameter, defauling to 'dev?'\n"); 238 } 239 232 240 int i=0; 233 241 for (i=0;i<BOUNCE_NR_OF_CHANNELS;i++) { 234 242 char *buff; 235 asprintf(&buff," dev%d%s_Port%d",m_id,direction==FreebobStreaming::AmdtpAudioPort::E_Playback?"p":"c",i);243 asprintf(&buff,"%s%s_Port%d",id.c_str(),direction==FreebobStreaming::AmdtpAudioPort::E_Playback?"p":"c",i); 236 244 237 245 FreebobStreaming::Port *p=NULL; … … 269 277 bool 270 278 BounceDevice::prepare() { 271 272 279 debugOutput(DEBUG_LEVEL_NORMAL, "Preparing BounceDevice...\n" ); 273 274 m_receiveProcessor=new FreebobStreaming::AmdtpReceiveStreamProcessor( 275 m_1394Service->getPort(), 276 m_samplerate, 277 BOUNCE_NR_OF_CHANNELS); 278 279 if(!m_receiveProcessor->init()) { 280 debugFatal("Could not initialize receive processor!\n"); 281 return false; 282 283 } 284 285 if (!addPortsToProcessor(m_receiveProcessor, 286 FreebobStreaming::AmdtpAudioPort::E_Capture)) { 287 debugFatal("Could not add ports to processor!\n"); 288 return false; 289 } 290 291 // do the transmit processor 292 m_transmitProcessor=new FreebobStreaming::AmdtpTransmitStreamProcessor( 293 m_1394Service->getPort(), 294 m_samplerate, 295 BOUNCE_NR_OF_CHANNELS); 296 297 m_transmitProcessor->setVerboseLevel(getDebugLevel()); 298 299 if(!m_transmitProcessor->init()) { 300 debugFatal("Could not initialize transmit processor!\n"); 301 return false; 302 303 } 304 305 if (!addPortsToProcessor(m_transmitProcessor, 306 FreebobStreaming::AmdtpAudioPort::E_Playback)) { 307 debugFatal("Could not add ports to processor!\n"); 308 return false; 309 } 310 311 return true; 280 281 bool snoopMode=false; 282 if(!getOption("snoopMode", snoopMode)) { 283 debugWarning("Could not retrieve snoopMode parameter, defauling to false\n"); 284 } 285 286 // create & add streamprocessors 287 FreebobStreaming::StreamProcessor *p; 288 289 p=new FreebobStreaming::AmdtpReceiveStreamProcessor( 290 m_p1394Service->getPort(), 291 m_samplerate, 292 BOUNCE_NR_OF_CHANNELS); 293 294 if(!p->init()) { 295 debugFatal("Could not initialize receive processor!\n"); 296 delete p; 297 return false; 298 } 299 300 if (!addPortsToProcessor(p, 301 FreebobStreaming::Port::E_Capture)) { 302 debugFatal("Could not add plug to processor!\n"); 303 delete p; 304 return false; 305 } 306 307 m_receiveProcessors.push_back(p); 308 309 // do the transmit processor 310 if (snoopMode) { 311 // we are snooping, so this is receive too. 312 p=new FreebobStreaming::AmdtpReceiveStreamProcessor( 313 m_p1394Service->getPort(), 314 m_samplerate, 315 BOUNCE_NR_OF_CHANNELS); 316 } else { 317 p=new FreebobStreaming::AmdtpTransmitStreamProcessor( 318 m_p1394Service->getPort(), 319 m_samplerate, 320 BOUNCE_NR_OF_CHANNELS); 321 } 322 323 if(!p->init()) { 324 debugFatal("Could not initialize transmit processor %s!\n", 325 (snoopMode?" in snoop mode":"")); 326 delete p; 327 return false; 328 } 329 330 if (snoopMode) { 331 if (!addPortsToProcessor(p, 332 FreebobStreaming::Port::E_Capture)) { 333 debugFatal("Could not add plug to processor!\n"); 334 delete p; 335 return false; 336 } 337 m_receiveProcessors.push_back(p); 338 } else { 339 if (!addPortsToProcessor(p, 340 FreebobStreaming::Port::E_Playback)) { 341 debugFatal("Could not add plug to processor!\n"); 342 delete p; 343 return false; 344 } 345 m_transmitProcessors.push_back(p); 346 } 347 348 return true; 312 349 } 313 350 314 351 int 315 352 BounceDevice::getStreamCount() { 316 return 2; // one receive, one transmit353 return m_receiveProcessors.size() + m_transmitProcessors.size(); 317 354 } 318 355 319 356 FreebobStreaming::StreamProcessor * 320 357 BounceDevice::getStreamProcessorByIndex(int i) { 321 switch (i) { 322 case 0: 323 return m_receiveProcessor; 324 case 1: 325 return m_transmitProcessor; 326 default: 327 return NULL; 328 } 329 return 0; 358 if (i<(int)m_receiveProcessors.size()) { 359 return m_receiveProcessors.at(i); 360 } else if (i<(int)m_receiveProcessors.size() + (int)m_transmitProcessors.size()) { 361 return m_transmitProcessors.at(i-m_receiveProcessors.size()); 362 } 363 364 return NULL; 330 365 } 331 366 332 367 bool 333 368 BounceDevice::startStreamByIndex(int i) { 334 // int iso_channel=0; 335 // int plug=0; 336 // int hostplug=-1; 337 // 338 switch (i) { 339 case 0: 340 // // do connection management: make connection 341 // iso_channel = iec61883_cmp_connect( 342 // m_1394Service->getHandle(), 343 // m_nodeId | 0xffc0, 344 // &plug, 345 // raw1394_get_local_id (m_1394Service->getHandle()), 346 // &hostplug, 347 // &m_receiveProcessorBandwidth); 348 // 349 // // set the channel obtained by the connection management 350 #warning TEST CODE FOR BOUNCE DEVICE !! 351 if (m_configRom->getNodeId()==0) { 352 m_receiveProcessor->setChannel(1); 353 } else { 354 m_receiveProcessor->setChannel(0); 355 } 356 break; 357 case 1: 358 // // do connection management: make connection 359 // iso_channel = iec61883_cmp_connect( 360 // m_1394Service->getHandle(), 361 // raw1394_get_local_id (m_1394Service->getHandle()), 362 // &hostplug, 363 // m_nodeId | 0xffc0, 364 // &plug, 365 // &m_transmitProcessorBandwidth); 366 // 367 // // set the channel obtained by the connection management 368 // // m_receiveProcessor2->setChannel(iso_channel); 369 #warning TEST CODE FOR BOUNCE DEVICE !! 370 if (m_configRom->getNodeId()==0) { 371 m_transmitProcessor->setChannel(0); 372 } else { 373 m_transmitProcessor->setChannel(1); 374 } 375 break; 376 default: 377 return false; 378 } 379 380 return true; 381 369 if (i<(int)m_receiveProcessors.size()) { 370 int n=i; 371 FreebobStreaming::StreamProcessor *p=m_receiveProcessors.at(n); 372 373 // allocate ISO channel 374 int isochannel=allocateIsoChannel(p->getMaxPacketSize()); 375 if(isochannel<0) { 376 debugError("Could not allocate iso channel for SP %d\n",i); 377 return false; 378 } 379 p->setChannel(isochannel); 380 381 fb_quadlet_t reg_isoch; 382 // check value of ISO_CHANNEL register 383 if(!readReg(BOUNCE_REGISTER_TX_ISOCHANNEL, ®_isoch)) { 384 debugError("Could not read ISO_CHANNEL register\n", n); 385 p->setChannel(-1); 386 deallocateIsoChannel(isochannel); 387 return false; 388 } 389 if(reg_isoch != 0xFFFFFFFFUL) { 390 debugError("ISO_CHANNEL register != 0xFFFFFFFF (=0x%08X)\n", reg_isoch); 391 p->setChannel(-1); 392 deallocateIsoChannel(isochannel); 393 return false; 394 } 395 396 // write value of ISO_CHANNEL register 397 reg_isoch=isochannel; 398 if(!writeReg(BOUNCE_REGISTER_TX_ISOCHANNEL, reg_isoch)) { 399 debugError("Could not write ISO_CHANNEL register\n"); 400 p->setChannel(-1); 401 deallocateIsoChannel(isochannel); 402 return false; 403 } 404 405 return true; 406 407 } else if (i<(int)m_receiveProcessors.size() + (int)m_transmitProcessors.size()) { 408 int n=i-m_receiveProcessors.size(); 409 FreebobStreaming::StreamProcessor *p=m_transmitProcessors.at(n); 410 411 // allocate ISO channel 412 int isochannel=allocateIsoChannel(p->getMaxPacketSize()); 413 if(isochannel<0) { 414 debugError("Could not allocate iso channel for SP %d\n",i); 415 return false; 416 } 417 p->setChannel(isochannel); 418 419 fb_quadlet_t reg_isoch; 420 // check value of ISO_CHANNEL register 421 if(!readReg(BOUNCE_REGISTER_RX_ISOCHANNEL, ®_isoch)) { 422 debugError("Could not read ISO_CHANNEL register\n"); 423 p->setChannel(-1); 424 deallocateIsoChannel(isochannel); 425 return false; 426 } 427 if(reg_isoch != 0xFFFFFFFFUL) { 428 debugError("ISO_CHANNEL register != 0xFFFFFFFF (=0x%08X)\n", reg_isoch); 429 p->setChannel(-1); 430 deallocateIsoChannel(isochannel); 431 return false; 432 } 433 434 // write value of ISO_CHANNEL register 435 reg_isoch=isochannel; 436 if(!writeReg(BOUNCE_REGISTER_TX_ISOCHANNEL, reg_isoch)) { 437 debugError("Could not write ISO_CHANNEL register\n"); 438 p->setChannel(-1); 439 deallocateIsoChannel(isochannel); 440 return false; 441 } 442 443 return true; 444 } 445 446 debugError("SP index %d out of range!\n",i); 447 448 return false; 382 449 } 383 450 384 451 bool 385 452 BounceDevice::stopStreamByIndex(int i) { 386 // do connection management: break connection387 388 // int plug=0;389 // int hostplug=-1;390 //391 // switch (i) {392 // case 0:393 // // do connection management: break connection394 // iec61883_cmp_disconnect(395 // m_1394Service->getHandle(),396 // m_nodeId | 0xffc0,397 // plug,398 // raw1394_get_local_id (m_1394Service->getHandle()),399 // hostplug,400 // m_receiveProcessor->getChannel(),401 // m_receiveProcessorBandwidth);402 //403 // break;404 // case 1:405 // // do connection management: break connection406 // iec61883_cmp_disconnect(407 // m_1394Service->getHandle(),408 // raw1394_get_local_id (m_1394Service->getHandle()),409 // hostplug,410 // m_nodeId | 0xffc0,411 // plug,412 // m_transmitProcessor->getChannel(),413 // m_transmitProcessorBandwidth);414 //415 // // set the channel obtained by the connection management416 // // m_receiveProcessor2->setChannel(iso_channel);417 // break;418 // default:419 // return 0;420 // }421 453 422 454 return false; 423 455 } 424 456 457 // helper functions 458 459 // allocate ISO resources for the SP's 460 int BounceDevice::allocateIsoChannel(unsigned int packet_size) { 461 unsigned int bandwidth=8+packet_size; 462 463 int ch=m_p1394Service->allocateIsoChannelGeneric(bandwidth); 464 465 debugOutput(DEBUG_LEVEL_VERBOSE, "allocated channel %d, bandwidth %d\n", 466 ch, bandwidth); 467 468 return ch; 469 } 470 // deallocate ISO resources 471 bool BounceDevice::deallocateIsoChannel(int channel) { 472 debugOutput(DEBUG_LEVEL_VERBOSE, "freeing channel %d\n",channel); 473 return m_p1394Service->freeIsoChannel(channel); 474 } 475 476 // I/O functions 477 478 bool 479 BounceDevice::readReg(fb_nodeaddr_t offset, fb_quadlet_t *result) { 480 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Reading base register offset 0x%08llX\n", offset); 481 482 if(offset >= BOUNCE_INVALID_OFFSET) { 483 debugError("invalid offset: 0x%016llX\n", offset); 484 return false; 485 } 486 487 fb_nodeaddr_t addr=BOUNCE_REGISTER_BASE + offset; 488 fb_nodeid_t nodeId=m_nodeId | 0xFFC0; 489 490 if(!m_p1394Service->read_quadlet( nodeId, addr, result ) ) { 491 debugError("Could not read from node 0x%04X addr 0x%012X\n", nodeId, addr); 492 return false; 493 } 494 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Read result: 0x%08X\n", *result); 495 496 return true; 497 } 498 499 bool 500 BounceDevice::writeReg(fb_nodeaddr_t offset, fb_quadlet_t data) { 501 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing base register offset 0x%08llX, data: 0x%08X\n", 502 offset, data); 503 504 if(offset >= BOUNCE_INVALID_OFFSET) { 505 debugError("invalid offset: 0x%016llX\n", offset); 506 return false; 507 } 508 509 fb_nodeaddr_t addr=BOUNCE_REGISTER_BASE + offset; 510 fb_nodeid_t nodeId=m_nodeId | 0xFFC0; 511 512 if(!m_p1394Service->write_quadlet( nodeId, addr, data ) ) { 513 debugError("Could not write to node 0x%04X addr 0x%012X\n", nodeId, addr); 514 return false; 515 } 516 return true; 517 } 518 519 bool 520 BounceDevice::readRegBlock(fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length) { 521 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Reading base register offset 0x%08llX, length %u\n", 522 offset, length); 523 524 if(offset >= BOUNCE_INVALID_OFFSET) { 525 debugError("invalid offset: 0x%016llX\n", offset); 526 return false; 527 } 528 529 fb_nodeaddr_t addr=BOUNCE_REGISTER_BASE + offset; 530 fb_nodeid_t nodeId=m_nodeId | 0xFFC0; 531 532 if(!m_p1394Service->read( nodeId, addr, length, data ) ) { 533 debugError("Could not read from node 0x%04X addr 0x%012llX\n", nodeId, addr); 534 return false; 535 } 536 return true; 537 } 538 539 bool 540 BounceDevice::writeRegBlock(fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length) { 541 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing base register offset 0x%08llX, length: %u\n", 542 offset, length); 543 544 if(offset >= BOUNCE_INVALID_OFFSET) { 545 debugError("invalid offset: 0x%016llX\n", offset); 546 return false; 547 } 548 549 fb_nodeaddr_t addr=BOUNCE_REGISTER_BASE + offset; 550 fb_nodeid_t nodeId=m_nodeId | 0xFFC0; 551 552 if(!m_p1394Service->write( nodeId, addr, length, data ) ) { 553 debugError("Could not write to node 0x%04X addr 0x%012llX\n", nodeId, addr); 554 return false; 555 } 556 return true; 557 } 558 559 425 560 } // namespace branches/streaming-rework/src/bounce/bounce_avdevice.h
r415 r416 31 31 #include "libstreaming/AmdtpPortInfo.h" 32 32 33 #include "libieee1394/ARMHandler.h" 34 33 35 #include "iavdevice.h" 34 36 #include "libfreebob/freebob_bounce.h" 37 38 #include <vector> 39 40 #define BOUNCE_REGISTER_BASE 0x0000FFFFE0000000ULL 41 #define BOUNCE_REGISTER_LENGTH (4*256) 42 #define BOUNCE_REGISTER_TX_ISOCHANNEL 0x10 43 #define BOUNCE_REGISTER_RX_ISOCHANNEL 0x14 44 #define BOUNCE_INVALID_OFFSET 0xFFFFF00000000000ULL 35 45 36 46 class ConfigRom; … … 49 59 50 60 class BounceDevice : public IAvDevice { 61 private: 62 class BounceNotifier; 51 63 public: 52 64 BounceDevice( std::auto_ptr<ConfigRom>( configRom ), … … 81 93 protected: 82 94 std::auto_ptr<ConfigRom>( m_configRom ); 83 Ieee1394Service* m_ 1394Service;95 Ieee1394Service* m_p1394Service; 84 96 int m_nodeId; 85 97 int m_verboseLevel; … … 90 102 unsigned int m_samplerate; 91 103 struct VendorModelEntry* m_model; 92 unsigned int m_id;93 104 94 // streaming stuff 95 FreebobStreaming::AmdtpReceiveStreamProcessor *m_receiveProcessor; 96 int m_receiveProcessorBandwidth; 97 98 FreebobStreaming::AmdtpTransmitStreamProcessor *m_transmitProcessor; 99 int m_transmitProcessorBandwidth; 105 // streaming stuff 106 typedef std::vector< FreebobStreaming::StreamProcessor * > StreamProcessorVector; 107 StreamProcessorVector m_receiveProcessors; 108 StreamProcessorVector m_transmitProcessors; 100 109 101 110 bool addPortsToProcessor( 102 FreebobStreaming::StreamProcessor *processor, 103 FreebobStreaming::AmdtpAudioPort::E_Direction direction); 104 111 FreebobStreaming::StreamProcessor *processor, 112 FreebobStreaming::Port::E_Direction direction); 105 113 106 114 DECLARE_DEBUG_MODULE; 115 116 private: // generic helpers 117 int allocateIsoChannel(unsigned int packet_size); 118 bool deallocateIsoChannel(int channel); 119 120 private: // I/O helpers 121 // quadlet read/write routines 122 bool readReg(fb_nodeaddr_t, fb_quadlet_t *); 123 bool writeReg(fb_nodeaddr_t, fb_quadlet_t); 124 bool readRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t); 125 bool writeRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t); 126 127 private: 128 BounceNotifier *m_Notifier; 129 /** 130 * this class reacts on the ohter side writing to the 131 * hosts address space 132 */ 133 #define BOUNCE_NOTIFIER_BASE_ADDRESS 0x0000FFFFE0000000ULL 134 #define BOUNCE_NOTIFIER_BLOCK_LENGTH 4 135 class BounceNotifier : public ARMHandler 136 { 137 public: 138 BounceNotifier(BounceDevice *, nodeaddr_t start); 139 virtual ~BounceNotifier(); 140 141 private: 142 BounceDevice *m_bouncedevice; 143 }; 107 144 }; 108 145 branches/streaming-rework/src/iavdevice.h
r415 r416 24 24 #include "libfreebobavc/avc_definitions.h" 25 25 #include "libfreebob/xmlparser.h" 26 #include "libutil/OptionContainer.h" 26 27 27 28 class ConfigRom; … … 29 30 30 31 namespace FreebobStreaming { 31 32 class StreamProcessor; 32 33 } 33 34 /*! … … 38 39 39 40 */ 40 class IAvDevice {41 class IAvDevice : public FreebobUtil::OptionContainer { 41 42 public: 42 43 virtual ~IAvDevice() {} branches/streaming-rework/src/libutil/unittests.cpp
r365 r416 20 20 21 21 #include "serialize.h" 22 #include "OptionContainer.h" 23 22 24 #include <libraw1394/raw1394.h> 23 25 … … 25 27 26 28 using namespace Util; 29 using namespace FreebobUtil; 27 30 28 31 /////////////////////////////////////// … … 405 408 406 409 ///////////////////////////////////// 410 class testOC : public OptionContainer { 411 public: 412 testOC() {}; 413 ~testOC() {}; 414 415 bool test() { 416 bool result=true; 417 418 Option op1=Option(); 419 if(addOption(op1)) { 420 printf( "adding an empty option should not succeed\n" ); 421 result=false; 422 } 423 424 op1=Option("option1"); 425 if(addOption(op1)) { 426 printf( "adding an option without a value should not succeed\n" ); 427 result=false; 428 } 429 430 op1=Option("option1", (float)(1.0)); 431 if(!addOption(op1)) { 432 printf( "could not add valid option (1)\n" ); 433 result=false; 434 } 435 if(addOption(op1)) { 436 printf( "adding the same option twice should not succeed\n" ); 437 result=false; 438 } 439 if(!removeOption(op1)) { 440 printf( "could not remove option by reference\n" ); 441 result=false; 442 } 443 if(hasOption(op1)) { 444 printf( "option not removed (by reference)\n" ); 445 result=false; 446 } 447 448 op1=Option("option1", (int64_t)1); 449 if(!addOption(op1)) { 450 printf( "could not add valid option (2)\n" ); 451 result=false; 452 } 453 if(!removeOption("option1")) { 454 printf( "could not remove option by name\n" ); 455 result=false; 456 } 457 if(hasOption(op1)) { 458 printf( "option not removed (by name)\n" ); 459 result=false; 460 } 461 462 op1=Option("option1", (int64_t)(-1)); 463 if(!addOption(op1)) { 464 printf( "could not add valid option (3)\n" ); 465 result=false; 466 } 467 Option op2=Option("option1", (double)(1.75)); 468 if(addOption(op2)) { 469 printf( "adding two options with the same name should not be allowed\n" ); 470 result=false; 471 } 472 473 op2=Option("option2", (double)(1.75)); 474 if(!addOption(op2)) { 475 printf( "adding an option with a different name should be allowed (1)\n" ); 476 result=false; 477 } 478 Option op3=Option("option3", (int64_t)(1.75)); 479 if(!addOption(op3)) { 480 printf( "adding an option with a different name should be allowed (2)\n" ); 481 result=false; 482 } 483 484 if(countOptions() != 3) { 485 printf( "countOptions failed\n" ); 486 result=false; 487 } 488 489 int i=0; 490 for ( OptionContainer::iterator it = begin(); 491 it != end(); 492 ++it ) 493 { 494 // printf(" (%s)",(*it).getName().c_str()); 495 i++; 496 } 497 if(i!=3) { 498 printf( "did not iterate through the right amount of options\n" ); 499 result=false; 500 } 501 502 clearOptions(); 503 return result; 504 } 505 506 void prepare() { 507 Option op1=Option("option1", (int64_t)(-1)); 508 if(!addOption(op1)) { 509 printf( "prepare: could not add valid option (3)\n" ); 510 } 511 512 Option op2=Option("option2", (double)(1.75)); 513 if(!addOption(op2)) { 514 printf( "prepare: adding an option with a different name should be allowed (1)\n" ); 515 } 516 Option op3=Option("option3", (int64_t)(1.75)); 517 if(!addOption(op3)) { 518 printf( "prepare: adding an option with a different name should be allowed (2)\n" ); 519 } 520 } 521 }; 522 523 static bool 524 testU4() 525 { 526 bool result=true; 527 testOC oc; 528 if(!oc.test()) { 529 printf( "OptionContainer test failed\n" ); 530 result=false; 531 } 532 533 // now manipulate it externally 534 oc.prepare(); 535 536 if(!oc.hasOption("option1")) { 537 printf( "option1 should be present\n" ); 538 result=false; 539 } 540 if(!oc.hasOption("option2")) { 541 printf( "option2 should be present\n" ); 542 result=false; 543 } 544 if(!oc.hasOption("option3")) { 545 printf( "option3 should be present\n" ); 546 result=false; 547 } 548 if(oc.hasOption("option4")) { 549 printf( "option4 should not be present\n" ); 550 result=false; 551 } 552 553 oc.setOption("option1", 1024); 554 int tst; 555 if (!oc.getOption("option1", tst)) { 556 printf( "could not get option1 value\n" ); 557 result=false; 558 } 559 560 if(tst != 1024) { 561 printf( "option1 should be 1024\n" ); 562 result=false; 563 } 564 565 return result; 566 } 567 568 ///////////////////////////////////// 407 569 ///////////////////////////////////// 408 570 ///////////////////////////////////// … … 420 582 { "serialize 2", testU2 }, 421 583 { "serialize 3", testU3 }, 584 { "OptionContainer 1", testU4 }, 422 585 }; 423 586 branches/streaming-rework/src/Makefile.am
r414 r416 54 54 libstreaming/StreamProcessor.h libstreaming/StreamProcessorManager.h \ 55 55 libutil/Atomic.h libutil/cycles.h libutil/DelayLockedLoop.h libutil/PosixThread.h \ 56 libutil/ringbuffer.h libutil/PacketBuffer.h libutil/StreamStatistics.h \ 56 libutil/ringbuffer.h libutil/OptionContainer.h \ 57 libutil/PacketBuffer.h libutil/StreamStatistics.h \ 57 58 libutil/serialize.h libutil/SystemTimeSource.h libutil/Thread.h libutil/Time.h \ 58 59 libutil/TimeSource.h libutil/TimestampedBuffer.h … … 92 93 libutil/DelayLockedLoop.cpp \ 93 94 libutil/PacketBuffer.cpp \ 95 libutil/OptionContainer.cpp \ 94 96 libutil/PosixThread.cpp \ 95 97 libutil/ringbuffer.c \ branches/streaming-rework/src/maudio/maudio_avdevice.cpp
r415 r416 19 19 */ 20 20 #include "maudio/maudio_avdevice.h" 21 #include "bebob/bebob_avdevice.h" 21 22 22 23 #include "libieee1394/configrom.h" … … 41 42 int iNodeId, 42 43 int iVerboseLevel ) 43 : m_pConfigRom( configRom ) 44 , m_p1394Service( &ieee1394service ) 45 , m_iNodeId( iNodeId ) 46 , m_iVerboseLevel( iVerboseLevel ) 47 , m_pFilename( 0 ) 48 , m_id(0) 49 , m_receiveProcessor ( 0 ) 50 , m_receiveProcessorBandwidth ( -1 ) 51 , m_transmitProcessor ( 0 ) 52 , m_transmitProcessorBandwidth ( -1 ) 53 { 54 setDebugLevel( iVerboseLevel ); 55 44 : BeBoB::AvDevice( configRom, 45 ieee1394service, 46 iNodeId, 47 iVerboseLevel ) 48 , m_model ( NULL ) 49 { 56 50 debugOutput( DEBUG_LEVEL_VERBOSE, "Created MAudio::AvDevice (NodeID %d)\n", 57 51 iNodeId ); … … 62 56 } 63 57 64 ConfigRom&65 AvDevice::getConfigRom() const66 {67 return *m_pConfigRom;68 }69 70 struct VendorModelEntry {71 unsigned int m_iVendorId;72 unsigned int m_iModelId;73 const char* m_pFilename;74 };75 76 58 static VendorModelEntry supportedDeviceList[] = 77 59 { 78 //{0x0007f5, 0x00010048, "refdesign.xml"}, // BridgeCo, RD Audio1 79 80 {0x000d6c, 0x00010046, "fw410.xml"}, // M-Audio, FW 410 81 {0x000d6c, 0x00010058, "fw410.xml"}, // M-Audio, FW 410; Version 5.10.0.5036 82 {0x000d6c, 0x00010060, "fwap.xml"}, // M-Audio, FW Audiophile (to be verified); 83 84 60 //{0x0007f5, 0x00010048, "BridgeCo", "RD Audio1", "refdesign.xml"}, 61 62 {0x000d6c, 0x00010046, "M-Audio", "FW 410", "fw410.xml"}, 63 {0x000d6c, 0x00010058, "M-Audio", "FW 410", "fw410.xml"}, // Version 5.10.0.5036 64 {0x000d6c, 0x00010060, "M-Audio", "FW Audiophile", "fwap.xml"}, 85 65 }; 86 66 … … 95 75 ++i ) 96 76 { 97 if ( ( supportedDeviceList[i]. m_iVendorId == iVendorId )98 && ( supportedDeviceList[i].m _iModelId == iModelId ) )77 if ( ( supportedDeviceList[i].vendor_id == iVendorId ) 78 && ( supportedDeviceList[i].model_id == iModelId ) ) 99 79 { 100 80 return true; 101 81 } 102 82 } 103 104 83 return false; 105 84 } … … 108 87 AvDevice::discover() 109 88 { 110 unsigned int iVendorId = m_pConfigRom->getNodeVendorId(); 111 unsigned int iModelId = m_pConfigRom->getModelId(); 89 unsigned int vendorId = m_pConfigRom->getNodeVendorId(); 90 unsigned int modelId = m_pConfigRom->getModelId(); 91 112 92 for ( unsigned int i = 0; 113 93 i < ( sizeof( supportedDeviceList )/sizeof( VendorModelEntry ) ); 114 94 ++i ) 115 95 { 116 if ( ( supportedDeviceList[i].m_iVendorId == iVendorId ) 117 && ( supportedDeviceList[i].m_iModelId == iModelId ) ) 96 if ( ( supportedDeviceList[i].vendor_id == vendorId ) 97 && ( supportedDeviceList[i].model_id == modelId ) 98 ) 118 99 { 119 m_ pFilename = supportedDeviceList[i].m_pFilename;100 m_model = &(supportedDeviceList[i]); 120 101 break; 121 102 } 122 103 } 123 104 124 return m_pFilename != 0; 105 if (m_model != NULL) { 106 debugOutput( DEBUG_LEVEL_VERBOSE, "found %s %s\n", 107 m_model->vendor_name, m_model->model_name); 108 } else return false; 125 109 110 return true; 126 111 } 127 112 … … 137 122 } 138 123 139 bool140 AvDevice::lock() {141 142 return true;143 }144 145 146 bool147 AvDevice::unlock() {148 149 return true;150 }151 152 124 void 153 125 AvDevice::showDevice() const … … 159 131 { 160 132 char* pFilename; 161 if ( asprintf( &pFilename, "%s/libfreebob/maudio/%s", DATADIR, m_ pFilename ) < 0 ) {133 if ( asprintf( &pFilename, "%s/libfreebob/maudio/%s", DATADIR, m_model->filename ) < 0 ) { 162 134 debugError( "addXmlDescription: Could not create filename string\n" ); 163 135 return false; … … 213 185 if ( ( !xmlStrcmp( pSubNode->name, ( const xmlChar * ) "Node" ) ) ) { 214 186 char* result; 215 asprintf( &result, "%d", m_ iNodeId );187 asprintf( &result, "%d", m_nodeId ); 216 188 xmlNodeSetContent( pSubNode, BAD_CAST result ); 217 189 free( result ); … … 244 216 } 245 217 246 bool AvDevice::setId( unsigned int id) 247 { 248 // FIXME: decent ID system nescessary 249 m_id=id; 218 bool 219 AvDevice::prepare() { 220 250 221 return true; 251 222 } 252 223 253 bool 254 AvDevice::prepare() { 255 /* /////////// 256 // get plugs 257 258 AvPlug* inputplug = getPlugById( m_pcrPlugs, AvPlug::eAPD_Input, 0 ); 259 if ( !inputplug ) { 260 debugError( "setSampleRate: Could not retrieve iso input plug 0\n" ); 261 return false; 262 } 263 AvPlug* outputPlug = getPlugById( m_pcrPlugs, AvPlug::eAPD_Output, 0 ); 264 if ( !inputplug ) { 265 debugError( "setSampleRate: Could not retrieve iso output plug 0\n" ); 266 return false; 267 } 268 269 int samplerate=outputPlug->getSampleRate(); 270 m_receiveProcessor=new FreebobStreaming::AmdtpReceiveStreamProcessor( 271 m_p1394Service->getPort(), 272 samplerate, 273 outputPlug->getNrOfChannels()); 274 275 if(!m_receiveProcessor->init()) { 276 debugFatal("Could not initialize receive processor!\n"); 277 return false; 278 } 279 280 if (!addPlugToProcessor(*outputPlug,m_receiveProcessor, 281 FreebobStreaming::AmdtpAudioPort::E_Capture)) { 282 debugFatal("Could not add plug to processor!\n"); 283 return false; 284 } 285 286 // do the transmit processor 287 // if (m_snoopMode) { 288 // // we are snooping, so these are receive too. 289 // samplerate=inputPlug->getSampleRate(); 290 // m_receiveProcessor2=new FreebobStreaming::AmdtpReceiveStreamProcessor( 291 // channel, 292 // m_p1394Service->getPort(), 293 // samplerate, 294 // inputPlug->getNrOfChannels()); 295 // 296 // if(!m_receiveProcessor2->init()) { 297 // debugFatal("Could not initialize snooping receive processor!\n"); 298 // return false; 299 // } 300 // if (!addPlugToProcessor(*inputPlug,m_receiveProcessor2, 301 // FreebobStreaming::AmdtpAudioPort::E_Capture)) { 302 // debugFatal("Could not add plug to processor!\n"); 303 // return false; 304 // } 305 // } else { 306 // do the transmit processor 307 samplerate=inputPlug->getSampleRate(); 308 m_transmitProcessor=new FreebobStreaming::AmdtpTransmitStreamProcessor( 309 m_p1394Service->getPort(), 310 samplerate, 311 inputPlug->getNrOfChannels()); 312 313 if(!m_transmitProcessor->init()) { 314 debugFatal("Could not initialize transmit processor!\n"); 315 return false; 316 317 } 318 319 // FIXME: do this the proper way! 320 m_transmitProcessor->syncmaster=m_receiveProcessor; 321 322 if (!addPlugToProcessor(*inputPlug,m_transmitProcessor, 323 FreebobStreaming::AmdtpAudioPort::E_Playback)) { 324 debugFatal("Could not add plug to processor!\n"); 325 return false; 326 } 327 // } 328 */ 329 return true; 330 } 331 332 // bool 333 // AvDevice::addPlugToProcessor( 334 // AvPlug& plug, 335 // FreebobStreaming::StreamProcessor *processor, 336 // FreebobStreaming::AmdtpAudioPort::E_Direction direction) { 337 // 338 // AvPlug::ClusterInfoVector& clusterInfos = plug.getClusterInfos(); 339 // for ( AvPlug::ClusterInfoVector::const_iterator it = clusterInfos.begin(); 340 // it != clusterInfos.end(); 341 // ++it ) 342 // { 343 // const AvPlug::ClusterInfo* clusterInfo = &( *it ); 344 // 345 // AvPlug::ChannelInfoVector channelInfos = clusterInfo->m_channelInfos; 346 // for ( AvPlug::ChannelInfoVector::const_iterator it = channelInfos.begin(); 347 // it != channelInfos.end(); 348 // ++it ) 349 // { 350 // const AvPlug::ChannelInfo* channelInfo = &( *it ); 351 // std::ostringstream portname; 352 // 353 // portname << "dev" << m_id << "_" << channelInfo->m_name; 354 // 355 // FreebobStreaming::Port *p=NULL; 356 // switch(clusterInfo->m_portType) { 357 // case ExtendedPlugInfoClusterInfoSpecificData::ePT_Speaker: 358 // case ExtendedPlugInfoClusterInfoSpecificData::ePT_Headphone: 359 // case ExtendedPlugInfoClusterInfoSpecificData::ePT_Microphone: 360 // case ExtendedPlugInfoClusterInfoSpecificData::ePT_Line: 361 // case ExtendedPlugInfoClusterInfoSpecificData::ePT_Analog: 362 // p=new FreebobStreaming::AmdtpAudioPort( 363 // portname.str(), 364 // direction, 365 // // \todo: streaming backend expects indexing starting from 0 366 // // but bebob reports it starting from 1. Decide where 367 // // and how to handle this (pp: here) 368 // channelInfo->m_streamPosition - 1, 369 // channelInfo->m_location, 370 // FreebobStreaming::AmdtpPortInfo::E_MBLA, 371 // clusterInfo->m_portType 372 // ); 373 // break; 374 // 375 // case ExtendedPlugInfoClusterInfoSpecificData::ePT_MIDI: 376 // p=new FreebobStreaming::AmdtpMidiPort( 377 // portname.str(), 378 // direction, 379 // // \todo: streaming backend expects indexing starting from 0 380 // // but bebob reports it starting from 1. Decide where 381 // // and how to handle this (pp: here) 382 // channelInfo->m_streamPosition - 1, 383 // channelInfo->m_location, 384 // FreebobStreaming::AmdtpPortInfo::E_Midi, 385 // clusterInfo->m_portType 386 // ); 387 // 388 // break; 389 // case ExtendedPlugInfoClusterInfoSpecificData::ePT_SPDIF: 390 // case ExtendedPlugInfoClusterInfoSpecificData::ePT_ADAT: 391 // case ExtendedPlugInfoClusterInfoSpecificData::ePT_TDIF: 392 // case ExtendedPlugInfoClusterInfoSpecificData::ePT_MADI: 393 // case ExtendedPlugInfoClusterInfoSpecificData::ePT_Digital: 394 // case ExtendedPlugInfoClusterInfoSpecificData::ePT_NoType: 395 // default: 396 // // unsupported 397 // break; 398 // } 399 // 400 // if (!p) { 401 // debugOutput(DEBUG_LEVEL_VERBOSE, "Skipped port %s\n",channelInfo->m_name.c_str()); 402 // } else { 403 // 404 // if (!processor->addPort(p)) { 405 // debugWarning("Could not register port with stream processor\n"); 406 // return false; 407 // } 408 // } 409 // } 410 // } 411 // return true; 412 // } 413 414 int 415 AvDevice::getStreamCount() { 416 return 0; 417 // return 2; // one receive, one transmit 418 } 419 420 FreebobStreaming::StreamProcessor * 421 AvDevice::getStreamProcessorByIndex(int i) { 422 switch (i) { 423 case 0: 424 return m_receiveProcessor; 425 case 1: 426 // if (m_snoopMode) { 427 // return m_receiveProcessor2; 428 // } else { 429 return m_transmitProcessor; 430 // } 431 default: 432 return NULL; 433 } 434 return 0; 435 } 436 437 bool 438 AvDevice::startStreamByIndex(int i) { 439 return false; 440 } 441 442 bool 443 AvDevice::stopStreamByIndex(int i) { 444 445 return false; 446 } 447 448 } 224 } branches/streaming-rework/src/maudio/maudio_avdevice.h
r415 r416 27 27 #include "libfreebob/xmlparser.h" 28 28 29 #include "bebob/bebob_avdevice.h" 30 29 31 #include "libstreaming/AmdtpStreamProcessor.h" 30 32 #include "libstreaming/AmdtpPort.h" … … 38 40 namespace MAudio { 39 41 40 class AvDevice : public IAvDevice { 42 struct VendorModelEntry { 43 unsigned int vendor_id; 44 unsigned int model_id; 45 char *vendor_name; 46 char *model_name; 47 char *filename; 48 }; 49 50 class AvDevice : public BeBoB::AvDevice { 41 51 public: 42 52 AvDevice( std::auto_ptr<ConfigRom>( configRom ), … … 47 57 48 58 static bool probe( ConfigRom& configRom ); 49 virtual bool discover(); 50 virtual ConfigRom& getConfigRom() const; 51 virtual bool addXmlDescription( xmlNodePtr pDeviceNode ); 52 virtual void showDevice() const; 59 bool discover(); 53 60 54 virtual bool setSamplingFrequency( ESamplingFrequency samplingFrequency ); 55 virtual int getSamplingFrequency( ); 56 57 virtual bool setId(unsigned int id); 61 bool addXmlDescription( xmlNodePtr pDeviceNode ); 62 void showDevice() const; 63 64 bool setSamplingFrequency( ESamplingFrequency samplingFrequency ); 65 int getSamplingFrequency( ); 58 66 59 virtual int getStreamCount(); 60 virtual FreebobStreaming::StreamProcessor *getStreamProcessorByIndex(int i); 61 62 virtual bool prepare(); 63 bool lock(); 64 bool unlock(); 65 66 bool startStreamByIndex(int i); 67 bool stopStreamByIndex(int i); 67 bool prepare(); 68 68 69 69 protected: 70 std::auto_ptr<ConfigRom>( m_pConfigRom ); 71 Ieee1394Service* m_p1394Service; 72 int m_iNodeId; 73 int m_iVerboseLevel; 74 const char* m_pFilename; 75 76 unsigned int m_id; 77 78 // streaming stuff 79 FreebobStreaming::AmdtpReceiveStreamProcessor *m_receiveProcessor; 80 int m_receiveProcessorBandwidth; 81 82 FreebobStreaming::AmdtpTransmitStreamProcessor *m_transmitProcessor; 83 int m_transmitProcessorBandwidth; 70 struct VendorModelEntry* m_model; 84 71 85 72 DECLARE_DEBUG_MODULE; branches/streaming-rework/src/metrichalo/mh_avdevice.cpp
r415 r416 34 34 #include <assert.h> 35 35 #include <netinet/in.h> 36 #include <iostream> 37 #include <sstream> 36 38 37 39 #include <libraw1394/csr.h> … … 56 58 , m_nodeId( nodeId ) 57 59 , m_verboseLevel( verboseLevel ) 58 , m_id(0)59 , m_iso_recv_channel ( -1 )60 , m_iso_send_channel ( -1 )61 60 62 61 { … … 65 64 debugOutput( DEBUG_LEVEL_VERBOSE, "Created MetricHalo::MHAvDevice (NodeID %d)\n", 66 65 nodeId ); 66 addOption(FreebobUtil::OptionContainer::Option("id",std::string("dev?"))); 67 67 68 68 } … … 140 140 141 141 bool MHAvDevice::setId( unsigned int id) { 142 debugOutput( DEBUG_LEVEL_VERBOSE, "Set id to %d...\n", id); 143 m_id=id; 144 return true; 142 // FIXME: decent ID system nescessary 143 std::ostringstream idstr; 144 145 idstr << "dev" << id; 146 147 debugOutput( DEBUG_LEVEL_VERBOSE, "Set id to %s...\n", idstr.str().c_str()); 148 149 return setOption("id",idstr.str()); 145 150 } 146 151 … … 174 179 int 175 180 MHAvDevice::getStreamCount() { 176 return 0; // one receive, one transmit181 return 0; 177 182 } 178 183 … … 180 185 MHAvDevice::getStreamProcessorByIndex(int i) { 181 186 182 // switch (i) {183 // case 0:184 // return m_receiveProcessor;185 // case 1:186 // return m_transmitProcessor;187 // default:188 // return NULL;189 // }190 // return 0;191 187 return NULL; 192 188 } … … 194 190 bool 195 191 MHAvDevice::startStreamByIndex(int i) { 196 197 192 return false; 198 193 } … … 203 198 } 204 199 205 signed int MHAvDevice::getIsoRecvChannel(void) { 206 return m_iso_recv_channel; 207 } 208 209 signed int MHAvDevice::getIsoSendChannel(void) { 210 return m_iso_send_channel; 211 } 212 213 } 200 } branches/streaming-rework/src/metrichalo/mh_avdevice.h
r415 r416 86 86 int m_nodeId; 87 87 int m_verboseLevel; 88 signed int m_id;89 signed int m_iso_recv_channel, m_iso_send_channel;90 91 // FreebobStreaming::MHReceiveStreamProcessor *m_receiveProcessor;92 // FreebobStreaming::MHTransmitStreamProcessor *m_transmitProcessor;93 88 94 89 private: branches/streaming-rework/src/motu/motu_avdevice.cpp
r415 r416 37 37 #include <assert.h> 38 38 #include <netinet/in.h> 39 #include <iostream> 40 #include <sstream> 39 41 40 42 #include <libraw1394/csr.h> … … 61 63 , m_nodeId( nodeId ) 62 64 , m_verboseLevel( verboseLevel ) 63 , m_id(0)64 65 , m_iso_recv_channel ( -1 ) 65 66 , m_iso_send_channel ( -1 ) … … 304 305 305 306 bool MotuDevice::setId( unsigned int id) { 306 debugOutput( DEBUG_LEVEL_VERBOSE, "Set id to %d...\n", id); 307 m_id=id; 308 return true; 307 // FIXME: decent ID system nescessary 308 std::ostringstream idstr; 309 310 idstr << "dev" << id; 311 312 debugOutput( DEBUG_LEVEL_VERBOSE, "Set id to %s...\n", idstr.str().c_str()); 313 314 return setOption("id",idstr.str()); 309 315 } 310 316 … … 399 405 char *buff; 400 406 FreebobStreaming::Port *p=NULL; 401 407 408 // retrieve the ID 409 std::string id=std::string("dev?"); 410 if(!getOption("id", id)) { 411 debugWarning("Could not retrieve id parameter, defauling to 'dev?'\n"); 412 } 413 402 414 // Add audio capture ports 403 415 if (!addDirPorts(FreebobStreaming::Port::E_Capture, samp_freq, optical_in_mode)) { … … 408 420 // MIDI byte sent using a 3 byte sequence starting at byte 4 of the 409 421 // event data. 410 asprintf(&buff," dev%d_cap_MIDI0",m_id);422 asprintf(&buff,"%s_cap_MIDI0",id.c_str()); 411 423 p = new FreebobStreaming::MotuMidiPort(buff, 412 424 FreebobStreaming::Port::E_Capture, 4); … … 425 437 426 438 // example of adding an control port: 427 // asprintf(&buff," dev%d_cap_%s",m_id,"myportnamehere");439 // asprintf(&buff,"%s_cap_%s",id.c_str(),"myportnamehere"); 428 440 // p=new FreebobStreaming::MotuControlPort( 429 441 // buff, … … 468 480 // MIDI byte transmitted using a 3 byte sequence starting at byte 4 469 481 // of the event data. 470 asprintf(&buff," dev%d_pbk_MIDI0",m_id);482 asprintf(&buff,"%s_pbk_MIDI0",id.c_str()); 471 483 p = new FreebobStreaming::MotuMidiPort(buff, 472 484 FreebobStreaming::Port::E_Capture, 4); … … 485 497 486 498 // example of adding an control port: 487 // asprintf(&buff," dev%d_pbk_%s",m_id,"myportnamehere");499 // asprintf(&buff,"%s_pbk_%s",id.c_str(),"myportnamehere"); 488 500 // 489 501 // p=new FreebobStreaming::MotuControlPort( … … 765 777 char *buff; 766 778 779 // retrieve the ID 780 std::string id=std::string("dev?"); 781 if(!getOption("id", id)) { 782 debugWarning("Could not retrieve id parameter, defauling to 'dev?'\n"); 783 } 784 767 785 if (direction == FreebobStreaming::Port::E_Capture) { 768 786 s_processor = m_receiveProcessor; … … 777 795 if (sample_rate<=96000) { 778 796 for (i=0; i<2; i++, ofs+=3) { 779 asprintf(&buff," dev%d_%s_%s-%c", m_id, mode_str,797 asprintf(&buff,"%s_%s_%s-%c", id.c_str(), mode_str, 780 798 aux_str, i==0?'L':'R'); 781 799 if (!addPort(s_processor, buff, direction, ofs, 0)) … … 787 805 // always present no matter what the device configuration is. 788 806 for (i=0; i<8; i++, ofs+=3) { 789 asprintf(&buff," dev%d_%s_Analog%d", m_id, mode_str, i+1);807 asprintf(&buff,"%s_%s_Analog%d", id.c_str(), mode_str, i+1); 790 808 if (!addPort(s_processor, buff, direction, ofs, 0)) 791 809 return false; … … 799 817 for (i=0; i<2; i++, ofs+=3) { 800 818 if (m_motu_model == MOTUFW_MODEL_TRAVELER) { 801 asprintf(&buff," dev%d_%s_AES/EBU%d", m_id, mode_str, i+1);819 asprintf(&buff,"%s_%s_AES/EBU%d", id.c_str(), mode_str, i+1); 802 820 } else { 803 821 if (direction == FreebobStreaming::Port::E_Capture) 804 asprintf(&buff," dev%d_%s_Mic%d", m_id, mode_str, i+1);822 asprintf(&buff,"%s_%s_Mic%d", id.c_str(), mode_str, i+1); 805 823 else 806 asprintf(&buff," dev%d_%s_MainOut-%c", m_id, mode_str, i==0?'L':'R');824 asprintf(&buff,"%s_%s_MainOut-%c", id.c_str(), mode_str, i==0?'L':'R'); 807 825 } 808 826 if (!addPort(s_processor, buff, direction, ofs, 0)) … … 815 833 if (sample_rate<=96000 && optical_mode!=MOTUFW_OPTICAL_MODE_TOSLINK) { 816 834 for (i=0; i<2; i++, ofs+=3) { 817 asprintf(&buff," dev%d_%s_SPDIF%d", m_id, mode_str, i+1);835 asprintf(&buff,"%s_%s_SPDIF%d", id.c_str(), mode_str, i+1); 818 836 if (!addPort(s_processor, buff, direction, ofs, 0)) 819 837 return false; … … 825 843 if (sample_rate<=96000 && optical_mode==MOTUFW_OPTICAL_MODE_TOSLINK) { 826 844 for (i=0; i<2; i++, ofs+=3) { 827 asprintf(&buff," dev%d_%s_TOSLINK%d", m_id, mode_str, i+1);845 asprintf(&buff,"%s_%s_TOSLINK%d", id.c_str(), mode_str, i+1); 828 846 if (!addPort(s_processor, buff, direction, ofs, 0)) 829 847 return false; … … 835 853 if (sample_rate<=96000 && optical_mode==MOTUFW_OPTICAL_MODE_ADAT) { 836 854 for (i=0; i<4; i++, ofs+=3) { 837 asprintf(&buff," dev%d_%s_ADAT%d", m_id, mode_str, i+1);855 asprintf(&buff,"%s_%s_ADAT%d", id.c_str(), mode_str, i+1); 838 856 if (!addPort(s_processor, buff, direction, ofs, 0)) 839 857 return false; … … 845 863 if (sample_rate<=48000 && optical_mode==MOTUFW_OPTICAL_MODE_ADAT) { 846 864 for (i=4; i<8; i++, ofs+=3) { 847 asprintf(&buff," dev%d_%s_ADAT%d", m_id, mode_str, i+1);865 asprintf(&buff,"%s_%s_ADAT%d", id.c_str(), mode_str, i+1); 848 866 if (!addPort(s_processor, buff, direction, ofs, 0)) 849 867 return false; branches/streaming-rework/src/motu/motu_avdevice.h
r415 r416 137 137 int m_nodeId; 138 138 int m_verboseLevel; 139 signed int m_id;140 139 signed int m_iso_recv_channel, m_iso_send_channel; 141 140 signed int m_bandwidth; branches/streaming-rework/src/rme/rme_avdevice.cpp
r415 r416 33 33 #include <netinet/in.h> 34 34 35 #include <iostream> 36 #include <sstream> 37 35 38 #include <libraw1394/csr.h> 36 39 … … 54 57 , m_nodeId( nodeId ) 55 58 , m_verboseLevel( verboseLevel ) 56 , m_id(0)57 , m_iso_recv_channel ( -1 )58 , m_iso_send_channel ( -1 )59 , m_bandwidth ( -1 )60 // , m_receiveProcessor ( 0 )61 // , m_transmitProcessor ( 0 )62 59 63 60 { … … 71 68 RmeDevice::~RmeDevice() 72 69 { 73 // Free ieee1394 bus resources if they have been allocated 74 if (m_p1394Service != NULL) { 75 if(m_p1394Service->freeIsoChannel(m_iso_recv_channel)) { 76 debugOutput(DEBUG_LEVEL_VERBOSE, "Could not free recv iso channel %d\n", m_iso_recv_channel); 77 78 } 79 if(m_p1394Service->freeIsoChannel(m_iso_send_channel)) { 80 debugOutput(DEBUG_LEVEL_VERBOSE, "Could not free send iso channel %d\n", m_iso_send_channel); 81 82 } 83 } 70 84 71 } 85 72 … … 158 145 159 146 bool RmeDevice::setId( unsigned int id) { 160 debugOutput( DEBUG_LEVEL_VERBOSE, "Set id to %d...\n", id); 161 m_id=id; 162 return true; 147 // FIXME: decent ID system nescessary 148 std::ostringstream idstr; 149 150 idstr << "dev" << id; 151 152 debugOutput( DEBUG_LEVEL_VERBOSE, "Set id to %s...\n", idstr.str().c_str()); 153 154 return setOption("id",idstr.str()); 163 155 } 164 156 … … 213 205 } 214 206 215 signed int RmeDevice::getIsoRecvChannel(void) { 216 return m_iso_recv_channel; 217 } 218 219 signed int RmeDevice::getIsoSendChannel(void) { 220 return m_iso_send_channel; 221 } 222 223 signed int RmeDevice::getEventSize(unsigned int dir) { 224 return 0; 225 } 226 227 } 207 } branches/streaming-rework/src/rme/rme_avdevice.h
r415 r416 75 75 bool startStreamByIndex(int i); 76 76 bool stopStreamByIndex(int i); 77 78 signed int getIsoRecvChannel(void);79 signed int getIsoSendChannel(void);80 81 signed int getEventSize(unsigned int dir);82 77 83 78 protected: … … 89 84 int m_nodeId; 90 85 int m_verboseLevel; 91 signed int m_id;92 signed int m_iso_recv_channel, m_iso_send_channel;93 signed int m_bandwidth;94 95 // FreebobStreaming::RmeReceiveStreamProcessor *m_receiveProcessor;96 // FreebobStreaming::RmeTransmitStreamProcessor *m_transmitProcessor;97 86 98 87 private: 99 // bool addPort(FreebobStreaming::StreamProcessor *s_processor,100 // char *name,101 // enum FreebobStreaming::Port::E_Direction direction,102 // int position, int size);103 // bool addDirPorts(104 // enum FreebobStreaming::Port::E_Direction direction,105 // unsigned int sample_rate, unsigned int optical_mode);106 107 unsigned int ReadRegister(unsigned int reg);108 signed int WriteRegister(unsigned int reg, quadlet_t data);109 88 110 89 // debug support