- Timestamp:
- 10/21/08 10:45:01 (12 years ago)
- Files:
-
- branches/libffado-2.0/src/bebob/bebob_avdevice.cpp (modified) (3 diffs)
- branches/libffado-2.0/src/bebob/bebob_avdevice.h (modified) (2 diffs)
- branches/libffado-2.0/src/bebob/focusrite/focusrite_saffirepro.cpp (modified) (2 diffs)
- branches/libffado-2.0/src/bebob/focusrite/focusrite_saffirepro.h (modified) (2 diffs)
- branches/libffado-2.0/src/devicemanager.cpp (modified) (2 diffs)
- branches/libffado-2.0/src/ffadodevice.cpp (modified) (1 diff)
- branches/libffado-2.0/src/ffadodevice.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/libffado-2.0/src/bebob/bebob_avdevice.cpp
r1351 r1366 62 62 AvDevice::AvDevice( DeviceManager& d, std::auto_ptr< ConfigRom >( configRom ) ) 63 63 : GenericAVC::AvDevice( d, configRom ) 64 , m_last_discovery_config_id ( 0xFFFFFFFFFFFFFFFFLLU ) 64 65 , m_Mixer ( 0 ) 65 66 { … … 208 209 debugWarning("Could not build mixer\n"); 209 210 } 211 212 // keep track of the config id of this discovery 213 m_last_discovery_config_id = getConfigurationId(); 214 210 215 return true; 211 216 } … … 656 661 } 657 662 663 bool 664 AvDevice::needsRediscovery() 665 { 666 // require rediscovery if the config id differs from the one saved 667 // in the previous discovery 668 return getConfigurationId() != m_last_discovery_config_id; 669 } 670 658 671 uint64_t 659 672 AvDevice::getConfigurationId() branches/libffado-2.0/src/bebob/bebob_avdevice.h
r1351 r1366 112 112 113 113 virtual uint64_t getConfigurationId(); 114 virtual bool needsRediscovery(); 114 115 115 116 std::string getCachePath(); … … 121 122 122 123 std::vector<int> m_supported_frequencies; 124 uint64_t m_last_discovery_config_id; 125 123 126 protected: 124 127 Mixer* m_Mixer; branches/libffado-2.0/src/bebob/focusrite/focusrite_saffirepro.cpp
r1294 r1366 524 524 } 525 525 526 uint64_t 527 SaffireProDevice::getConfigurationId() 528 { 529 // have the generic mechanism create a unique configuration id. 530 uint64_t id = BeBoB::AvDevice::getConfigurationId(); 531 532 // there are some parts that can be enabled/disabled and 533 // that have influence on the AV/C model and channel config 534 // so add them to the config id 535 #if 0 536 // FIXME: doesn't seem to be working, but the channel count 537 // makes that it's not that important 538 if(getEnableDigitalChannel(eDC_SPDIF)) { 539 id |= 1ULL << 40; 540 } 541 if(isPro26()) { 542 if(getEnableDigitalChannel(eDC_ADAT1)) { 543 id |= 1ULL << 41; 544 } 545 if(getEnableDigitalChannel(eDC_ADAT2)) { 546 id |= 1ULL << 42; 547 } 548 } 549 #endif 550 return id; 551 } 552 526 553 bool 527 554 SaffireProDevice::setNickname( std::string name) … … 863 890 "PLL lock range: %d\n", retval ); 864 891 return retval; 892 } 893 894 bool 895 SaffireProDevice::isMidiEnabled() { 896 uint32_t ready; 897 if ( !getSpecificValue(FR_SAFFIREPRO_CMD_ID_AVC_MODEL_MIDI, &ready ) ) { 898 debugError( "getSpecificValue failed\n" ); 899 return false; 900 } 901 902 debugOutput( DEBUG_LEVEL_VERBOSE, 903 "isMidiEnabled: %d\n", ready != 0 ); 904 return ready != 0; 865 905 } 866 906 branches/libffado-2.0/src/bebob/focusrite/focusrite_saffirepro.h
r1294 r1366 373 373 void flashLed(); 374 374 bool isAudioOn(); 375 bool isMidiEnabled(); 375 376 bool isExtClockLocked(); 376 377 uint32_t getCount32(); … … 409 410 protected: 410 411 virtual uint16_t getConfigurationIdSyncMode(); 412 virtual uint64_t getConfigurationId(); 411 413 412 414 private: branches/libffado-2.0/src/devicemanager.cpp
r1299 r1366 449 449 450 450 if (!slaveMode) { 451 // for the devices that are still in the list check if they require re-discovery 452 FFADODeviceVector failed_to_rediscover; 453 for ( FFADODeviceVectorIterator it_dev = m_avDevices.begin(); 454 it_dev != m_avDevices.end(); 455 ++it_dev ) 456 { 457 FFADODevice* avDevice = *it_dev; 458 if(avDevice->needsRediscovery()) { 459 debugOutput( DEBUG_LEVEL_NORMAL, 460 "Device with GUID %s requires rediscovery (state changed)...\n", 461 avDevice->getConfigRom().getGuidString().c_str()); 462 463 bool isFromCache = false; 464 if ( useCache && avDevice->loadFromCache() ) { 465 debugOutput( DEBUG_LEVEL_VERBOSE, "could load from cache\n" ); 466 isFromCache = true; 467 // restore the debug level for everything that was loaded 468 avDevice->setVerboseLevel( getDebugLevel() ); 469 } else if ( avDevice->discover() ) { 470 debugOutput( DEBUG_LEVEL_VERBOSE, "discovery successful\n" ); 471 } else { 472 debugError( "could not discover device\n" ); 473 failed_to_rediscover.push_back(avDevice); 474 continue; 475 } 476 if ( !isFromCache && !avDevice->saveCache() ) { 477 debugOutput( DEBUG_LEVEL_VERBOSE, "No cached version of AVC model created\n" ); 478 } 479 } else { 480 debugOutput( DEBUG_LEVEL_NORMAL, 481 "Device with GUID %s does not require rediscovery...\n", 482 avDevice->getConfigRom().getGuidString().c_str()); 483 } 484 } 485 // remove devices that failed to rediscover 486 // FIXME: surely there has to be a better way to do this 487 FFADODeviceVector to_keep; 488 for ( FFADODeviceVectorIterator it = m_avDevices.begin(); 489 it != m_avDevices.end(); 490 ++it ) 491 { 492 bool keep_this_device = true; 493 for ( FFADODeviceVectorIterator it2 = failed_to_rediscover.begin(); 494 it2 != failed_to_rediscover.end(); 495 ++it2 ) 496 { 497 if(*it == *it2) { 498 debugOutput( DEBUG_LEVEL_NORMAL, 499 "Removing device with GUID %s due to failed discovery...\n", 500 (*it)->getConfigRom().getGuidString().c_str()); 501 keep_this_device = false; 502 break; 503 } 504 } 505 if(keep_this_device) { 506 to_keep.push_back(*it); 507 } 508 } 509 for ( FFADODeviceVectorIterator it2 = failed_to_rediscover.begin(); 510 it2 != failed_to_rediscover.end(); 511 ++it2 ) 512 { 513 if (!deleteElement(*it2)) { 514 debugWarning("failed to remove AvDevice from Control::Container\n"); 515 } 516 delete *it2; 517 } 518 m_avDevices = to_keep; 519 520 // pick up new devices 451 521 for ( Ieee1394ServiceVectorIterator it = m_1394Services.begin(); 452 522 it != m_1394Services.end(); … … 480 550 481 551 bool already_in_vector = false; 482 for ( FFADODeviceVectorIterator it = m_avDevices.begin();483 it != m_avDevices.end();484 ++it )552 for ( FFADODeviceVectorIterator it_dev = m_avDevices.begin(); 553 it_dev != m_avDevices.end(); 554 ++it_dev ) 485 555 { 486 if ((*it )->getConfigRom().getGuid() == configRom->getGuid()) {556 if ((*it_dev)->getConfigRom().getGuid() == configRom->getGuid()) { 487 557 already_in_vector = true; 488 558 break; branches/libffado-2.0/src/ffadodevice.cpp
r1215 r1366 142 142 { 143 143 return false; 144 } 145 146 bool 147 FFADODevice::needsRediscovery() 148 { 149 // require rediscovery by default 150 return true; 144 151 } 145 152 branches/libffado-2.0/src/ffadodevice.h
r1288 r1366 103 103 */ 104 104 virtual bool saveCache(); 105 106 /** 107 * @brief Called by DeviceManager to check whether a device requires rediscovery 108 * 109 * This function is called to figure out if the device has to be rediscovered 110 * e.g. after a bus reset where the device internal structure changed. 111 * 112 * @returns true if device requires rediscovery 113 */ 114 virtual bool needsRediscovery(); 105 115 106 116 /**