Index: trunk/libffado/src/genericavc/avc_avdevice.cpp =================================================================== --- trunk/libffado/src/genericavc/avc_avdevice.cpp (revision 599) +++ trunk/libffado/src/genericavc/avc_avdevice.cpp (revision 607) @@ -56,6 +56,4 @@ std::auto_ptr( configRom )) : FFADODevice( ieee1394Service, configRom ) - , m_model( NULL ) - { debugOutput( DEBUG_LEVEL_VERBOSE, "Created GenericAVC::AvDevice (NodeID %d)\n", @@ -78,5 +76,5 @@ if ( vendorModel.parse() ) { vendorModel.printTable(); - return vendorModel.find( vendorId, modelId ); + return vendorModel.isPresent( vendorId, modelId ); } @@ -94,4 +92,22 @@ AvDevice::discover() { + // check if we already have a valid VendorModel entry + // e.g. because a subclass called this function + if (!GenericAVC::VendorModel::isValid(m_model)) { + unsigned int vendorId = m_pConfigRom->getNodeVendorId(); + unsigned int modelId = m_pConfigRom->getModelId(); + + GenericAVC::VendorModel vendorModel( SHAREDIR "/ffado_driver_genericavc.txt" ); + if ( vendorModel.parse() ) { + m_model = vendorModel.find( vendorId, modelId ); + } + + if (!GenericAVC::VendorModel::isValid(m_model)) { + return false; + } + debugOutput( DEBUG_LEVEL_VERBOSE, "found %s %s\n", + m_model.vendor_name.c_str(), m_model.model_name.c_str()); + } + if ( !Unit::discover() ) { debugError( "Could not discover unit\n" ); @@ -232,5 +248,5 @@ debugOutput(DEBUG_LEVEL_NORMAL, - "%s %s\n", m_model->vendor_name.c_str(), m_model->model_name.c_str()); + "%s %s\n", m_model.vendor_name.c_str(), m_model.model_name.c_str()); AVC::Unit::show(); Index: trunk/libffado/src/genericavc/avc_avdevice.h =================================================================== --- trunk/libffado/src/genericavc/avc_avdevice.h (revision 583) +++ trunk/libffado/src/genericavc/avc_avdevice.h (revision 607) @@ -85,5 +85,5 @@ AVC::ESamplingFrequency samplingFrequency );*/ - struct VendorModelEntry *m_model; + struct VendorModelEntry m_model; // streaming stuff Index: trunk/libffado/src/genericavc/avc_vendormodel.cpp =================================================================== --- trunk/libffado/src/genericavc/avc_vendormodel.cpp (revision 599) +++ trunk/libffado/src/genericavc/avc_vendormodel.cpp (revision 607) @@ -83,4 +83,17 @@ return *this; +} + +bool +GenericAVC::VendorModelEntry::operator == ( const VendorModelEntry& rhs ) const +{ + bool equal=true; + + equal &= (vendor_id == rhs.vendor_id); + equal &= (model_id == rhs.model_id); + equal &= (vendor_name == rhs.vendor_name); + equal &= (model_name == rhs.model_name); + + return equal; } @@ -194,5 +207,5 @@ }; -GenericAVC::VendorModelEntry* +GenericAVC::VendorModelEntry GenericAVC::VendorModel::find( unsigned int vendor_id, unsigned model_id ) { @@ -202,7 +215,28 @@ is_same( vendor_id, model_id ) ); if ( it != m_vendorModelEntries.end() ) - return &*it; - - return 0; + return *it; + + struct VendorModelEntry invalid; + return invalid; +} + +bool +GenericAVC::VendorModel::isPresent( unsigned int vendor_id, unsigned model_id ) +{ + VendorModelEntryVector::iterator it = + find_if ( m_vendorModelEntries.begin(), + m_vendorModelEntries.end(), + is_same( vendor_id, model_id ) ); + if ( it != m_vendorModelEntries.end() ) + return true; + + return false; +} + +bool +GenericAVC::VendorModel::isValid( const GenericAVC::VendorModelEntry& vme ) +{ + struct VendorModelEntry invalid; + return !(vme==invalid); } Index: trunk/libffado/src/genericavc/avc_vendormodel.h =================================================================== --- trunk/libffado/src/genericavc/avc_vendormodel.h (revision 599) +++ trunk/libffado/src/genericavc/avc_vendormodel.h (revision 607) @@ -35,4 +35,5 @@ VendorModelEntry(const VendorModelEntry& rhs); VendorModelEntry& operator = (const VendorModelEntry& rhs); + bool operator == (const VendorModelEntry& rhs) const; virtual ~VendorModelEntry(); @@ -56,5 +57,7 @@ std::vector::const_iterator& b, std::vector::const_iterator& e ); - VendorModelEntry* find( unsigned int vendor_id, unsigned model_id ); + VendorModelEntry find( unsigned int vendor_id, unsigned model_id ); + bool isPresent( unsigned int vendor_id, unsigned model_id ); + static bool isValid( const VendorModelEntry& vme ); const VendorModelEntryVector& getVendorModelEntries() const; @@ -62,4 +65,5 @@ std::string m_filename; VendorModelEntryVector m_vendorModelEntries; + }; Index: trunk/libffado/src/bebob/bebob_avdevice.cpp =================================================================== --- trunk/libffado/src/bebob/bebob_avdevice.cpp (revision 599) +++ trunk/libffado/src/bebob/bebob_avdevice.cpp (revision 607) @@ -79,5 +79,5 @@ if ( vendorModel.parse() ) { vendorModel.printTable(); - return vendorModel.find( vendorId, modelId ); + return vendorModel.isPresent( vendorId, modelId ); } @@ -121,8 +121,8 @@ } - if (m_model != NULL) { + if (GenericAVC::VendorModel::isValid(m_model)) { debugOutput( DEBUG_LEVEL_VERBOSE, "found %s %s\n", - m_model->vendor_name.c_str(), - m_model->model_name.c_str()); + m_model.vendor_name.c_str(), + m_model.model_name.c_str()); } else return false; Index: trunk/libffado/src/fireworks/fireworks_device.cpp =================================================================== --- trunk/libffado/src/fireworks/fireworks_device.cpp (revision 599) +++ trunk/libffado/src/fireworks/fireworks_device.cpp (revision 607) @@ -63,5 +63,5 @@ if ( vendorModel.parse() ) { vendorModel.printTable(); - return vendorModel.find( vendorId, modelId ); + return vendorModel.isPresent( vendorId, modelId ); } @@ -75,14 +75,14 @@ unsigned int modelId = m_pConfigRom->getModelId(); - GenericAVC::VendorModel vendorModel( SHAREDIR "/ffado_driver_bebob.txt" ); + GenericAVC::VendorModel vendorModel( SHAREDIR "/ffado_driver_fireworks.txt" ); if ( vendorModel.parse() ) { m_model = vendorModel.find( vendorId, modelId ); } - if (m_model == NULL) { + if (!GenericAVC::VendorModel::isValid(m_model)) { return false; } debugOutput( DEBUG_LEVEL_VERBOSE, "found %s %s\n", - m_model->vendor_name.c_str(), m_model->model_name.c_str()); + m_model.vendor_name.c_str(), m_model.model_name.c_str()); if ( !GenericAVC::AvDevice::discover() ) {