Changeset 1299

Show
Ignore:
Timestamp:
07/13/08 15:44:25 (13 years ago)
Author:
ppalmers
Message:

implement configuration file mechanism to ease device support and packaging. this mechanism replaces the vendormodel text files. it loads two files, one system-wide and a second in the user directory. the user config file takes precedence. this should ease adding
device id's on a per-user base. it also allows for other settings to be carried by the same 'Configuration' object (present in the devicemanager). The idea is that it will also replace the OptionContainer? mechanism on the long run, and allow for easy integration
of system options (e.g. the pre-transmit amount).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/libffado-2.0/config.h.in

    r1279 r1299  
    3131#define LIBDIR "$LIBDIR" 
    3232#define SHAREDIR "$SHAREDIR" 
     33 
     34/* configuration file locations */ 
     35#define USER_CONFIG_FILE    "$USER_CONFIG_FILE" 
     36#define SYSTEM_CONFIG_FILE  "$SYSTEM_CONFIG_FILE" 
    3337 
    3438/* Define indicating availability of lrint() */ 
  • branches/libffado-2.0/external/SConscript

    r1185 r1299  
    2626env = env.Clone() 
    2727 
    28 env.SConscript( dirs="dbus", exports="env" ) 
     28env.SConscript( dirs=["dbus", "libconfig"], exports="env" ) 
    2929 
  • branches/libffado-2.0/src/bebob/bebob_avdevice.cpp

    r1288 r1299  
    2424#include "config.h" 
    2525 
     26#include "devicemanager.h" 
    2627#include "bebob/bebob_avdevice.h" 
    2728#include "bebob/bebob_avdevice_subunit.h" 
     
    3940#include "libieee1394/ieee1394service.h" 
    4041 
    41 #include "genericavc/avc_vendormodel.h" 
    42  
    4342#include "libavc/general/avc_plug_info.h" 
    4443#include "libavc/general/avc_extended_plug_info.h" 
     
    8281 
    8382bool 
    84 AvDevice::probe( ConfigRom& configRom, bool generic ) 
     83AvDevice::probe( Util::Configuration& c, ConfigRom& configRom, bool generic ) 
    8584{ 
    8685    if(generic) { 
     
    118117        unsigned int modelId = configRom.getModelId(); 
    119118 
    120         GenericAVC::VendorModel vendorModel( SHAREDIR "/ffado_driver_bebob.txt" ); 
    121         if ( vendorModel.parse() ) { 
    122             return vendorModel.isPresent( vendorId, modelId ); 
    123         } 
    124         return false; 
     119        Util::Configuration::VendorModelEntry vme = c.findDeviceVME( vendorId, modelId ); 
     120        return c.isValid(vme) && vme.driver == Util::Configuration::eD_BeBoB; 
    125121    } 
    126122} 
     
    183179    unsigned int modelId = getConfigRom().getModelId(); 
    184180 
    185     GenericAVC::VendorModel vendorModel( SHAREDIR "/ffado_driver_bebob.txt" ); 
    186     if ( vendorModel.parse() ) { 
    187         m_model = vendorModel.find( vendorId, modelId ); 
    188     } 
    189  
    190     if (GenericAVC::VendorModel::isValid(m_model)) { 
     181    Util::Configuration &c = getDeviceManager().getConfiguration(); 
     182    Util::Configuration::VendorModelEntry vme = c.findDeviceVME( vendorId, modelId ); 
     183 
     184    if (c.isValid(vme) && vme.driver == Util::Configuration::eD_BeBoB) { 
    191185        debugOutput( DEBUG_LEVEL_VERBOSE, "found %s %s\n", 
    192                      m_model.vendor_name.c_str(), 
    193                      m_model.model_name.c_str()); 
     186                     vme.vendor_name.c_str(), 
     187                     vme.model_name.c_str()); 
    194188    } else { 
    195         debugWarning("Using generic BeBoB support for unsupported device '%s %s'\n",  
     189        debugWarning("Using generic BeBoB support for unsupported device '%s %s'\n", 
    196190                     getConfigRom().getVendorName().c_str(), getConfigRom().getModelName().c_str()); 
    197191    } 
  • branches/libffado-2.0/src/bebob/bebob_avdevice.h

    r1288 r1299  
    6363    virtual ~AvDevice(); 
    6464 
    65     static bool probe( ConfigRom& configRom, bool generic = false ); 
     65    static bool probe( Util::Configuration&, ConfigRom& configRom, bool generic = false ); 
    6666    virtual bool loadFromCache(); 
    6767    virtual bool saveCache(); 
  • branches/libffado-2.0/src/devicemanager.cpp

    r1292 r1299  
    7171    , m_processorManager( new Streaming::StreamProcessorManager( *this ) ) 
    7272    , m_deviceStringParser( new DeviceStringParser() ) 
     73    , m_configuration ( new Util::Configuration() ) 
    7374    , m_used_cache_last_time( false ) 
    7475    , m_thread_realtime( false ) 
     
    8182DeviceManager::~DeviceManager() 
    8283{ 
     84    // save configuration 
     85    if(!m_configuration->save()) { 
     86        debugWarning("could not save configuration\n"); 
     87    } 
     88 
    8389    m_BusResetLock->Lock(); // make sure we are not handling a busreset. 
    8490    m_DeviceListLock->Lock(); // make sure nobody is using this 
     
    146152    assert(m_1394Services.size() == 0); 
    147153    assert(m_busreset_functors.size() == 0); 
     154 
     155    m_configuration->openFile( "temporary", Util::Configuration::eFM_Temporary ); 
     156    m_configuration->openFile( USER_CONFIG_FILE, Util::Configuration::eFM_ReadWrite ); 
     157    m_configuration->openFile( SYSTEM_CONFIG_FILE, Util::Configuration::eFM_ReadOnly ); 
    148158 
    149159    int nb_detected_ports = Ieee1394Service::detectNbPorts(); 
     
    825835#ifdef ENABLE_BEBOB 
    826836    debugOutput( DEBUG_LEVEL_VERBOSE, "Trying BeBoB...\n" ); 
    827     if ( BeBoB::AvDevice::probe( *configRom, generic ) ) { 
     837    if ( BeBoB::AvDevice::probe( getConfiguration(), *configRom, generic ) ) { 
    828838        return BeBoB::AvDevice::createDevice( *this, std::auto_ptr<ConfigRom>( configRom ) ); 
    829839    } 
     
    832842#ifdef ENABLE_FIREWORKS 
    833843    debugOutput( DEBUG_LEVEL_VERBOSE, "Trying ECHO Audio FireWorks...\n" ); 
    834     if ( FireWorks::Device::probe( *configRom, generic ) ) { 
     844    if ( FireWorks::Device::probe( getConfiguration(), *configRom, generic ) ) { 
    835845        return FireWorks::Device::createDevice( *this, std::auto_ptr<ConfigRom>( configRom ) ); 
    836846    } 
     
    840850#ifdef ENABLE_GENERICAVC 
    841851    debugOutput( DEBUG_LEVEL_VERBOSE, "Trying Generic AV/C...\n" ); 
    842     if ( GenericAVC::AvDevice::probe( *configRom, generic ) ) { 
     852    if ( GenericAVC::AvDevice::probe( getConfiguration(), *configRom, generic ) ) { 
    843853        return GenericAVC::AvDevice::createDevice( *this, std::auto_ptr<ConfigRom>( configRom ) ); 
    844854    } 
     
    847857#ifdef ENABLE_MOTU 
    848858    debugOutput( DEBUG_LEVEL_VERBOSE, "Trying Motu...\n" ); 
    849     if ( Motu::MotuDevice::probe( *configRom, generic ) ) { 
     859    if ( Motu::MotuDevice::probe( getConfiguration(), *configRom, generic ) ) { 
    850860        return Motu::MotuDevice::createDevice( *this, std::auto_ptr<ConfigRom>( configRom ) ); 
    851861    } 
     
    982992    m_processorManager->setVerboseLevel(l); 
    983993    m_deviceStringParser->setVerboseLevel(l); 
     994    m_configuration->setVerboseLevel(l); 
    984995    for ( FFADODeviceVectorIterator it = m_avDevices.begin(); 
    985996          it != m_avDevices.end(); 
  • branches/libffado-2.0/src/devicemanager.h

    r1292 r1299  
    3838#include "libutil/Functors.h" 
    3939#include "libutil/Mutex.h" 
     40#include "libutil/Configuration.h" 
    4041 
    4142#include <vector> 
     
    128129        {return unregisterNotification(m_postUpdateNotifiers, f);}; 
    129130 
     131 
     132    Util::Configuration& getConfiguration() {return *m_configuration;}; 
     133 
    130134    void showDeviceInfo(); 
    131135    void showStreamingInfo(); 
     
    164168    Streaming::StreamProcessorManager*  m_processorManager; 
    165169    DeviceStringParser*                 m_deviceStringParser; 
     170    Util::Configuration*                m_configuration; 
    166171    bool                                m_used_cache_last_time; 
    167172 
  • branches/libffado-2.0/src/fireworks/fireworks_device.cpp

    r1292 r1299  
    2222 */ 
    2323 
     24#include "devicemanager.h" 
    2425#include "fireworks_device.h" 
    2526#include "efc/efc_avc_cmd.h" 
     
    3435#include "libieee1394/ieee1394service.h" 
    3536 
    36 #include "config.h" 
    37  
    3837#include "fireworks/fireworks_control.h" 
    3938 
     
    8079 
    8180bool 
    82 Device::probe( ConfigRom& configRom, bool generic ) 
     81Device::probe( Util::Configuration& c, ConfigRom& configRom, bool generic ) 
    8382{ 
    8483    if(generic) { 
     
    111110        unsigned int vendorId = configRom.getNodeVendorId(); 
    112111        unsigned int modelId = configRom.getModelId(); 
    113      
    114         GenericAVC::VendorModel vendorModel( SHAREDIR "/ffado_driver_fireworks.txt" ); 
    115         if ( vendorModel.parse() ) { 
    116             return vendorModel.isPresent( vendorId, modelId ); 
    117         } 
    118         return false; 
     112 
     113        Util::Configuration::VendorModelEntry vme = c.findDeviceVME( vendorId, modelId ); 
     114        return c.isValid(vme) && vme.driver == Util::Configuration::eD_FireWorks; 
    119115    } 
    120116} 
     
    126122    unsigned int modelId = getConfigRom().getModelId(); 
    127123 
    128     GenericAVC::VendorModel vendorModel( SHAREDIR "/ffado_driver_fireworks.txt" ); 
    129     if ( vendorModel.parse() ) { 
    130         m_model = vendorModel.find( vendorId, modelId ); 
    131     } 
    132  
    133     if (!GenericAVC::VendorModel::isValid(m_model)) { 
     124    Util::Configuration &c = getDeviceManager().getConfiguration(); 
     125    Util::Configuration::VendorModelEntry vme = c.findDeviceVME( vendorId, modelId ); 
     126 
     127    if (c.isValid(vme) && vme.driver == Util::Configuration::eD_FireWorks) { 
     128        debugOutput( DEBUG_LEVEL_VERBOSE, "found %s %s\n", 
     129                     vme.vendor_name.c_str(), 
     130                     vme.model_name.c_str()); 
     131    } else { 
    134132        debugWarning("Using generic ECHO Audio FireWorks support for unsupported device '%s %s'\n", 
    135             getConfigRom().getVendorName().c_str(), getConfigRom().getModelName().c_str()); 
    136     } else { 
    137         debugOutput( DEBUG_LEVEL_VERBOSE, "found %s %s\n", 
    138                 m_model.vendor_name.c_str(), m_model.model_name.c_str()); 
     133                     getConfigRom().getVendorName().c_str(), getConfigRom().getModelName().c_str()); 
    139134    } 
    140135 
     
    146141 
    147142    // discover AVC-wise 
    148     if ( !GenericAVC::AvDevice::discover() ) { 
     143    if ( !GenericAVC::AvDevice::discoverGeneric() ) { 
    149144        debugError( "Could not discover GenericAVC::AvDevice\n" ); 
    150145        return false; 
  • branches/libffado-2.0/src/fireworks/fireworks_device.h

    r1288 r1299  
    5252    virtual ~Device(); 
    5353     
    54     static bool probe( ConfigRom& configRom, bool generic = false ); 
     54    static bool probe( Util::Configuration&, ConfigRom& configRom, bool generic = false ); 
    5555    static FFADODevice * createDevice( DeviceManager& d, std::auto_ptr<ConfigRom>( configRom )); 
    5656    virtual bool discover(); 
  • branches/libffado-2.0/src/genericavc/avc_avdevice.cpp

    r1288 r1299  
    2323 */ 
    2424 
     25#include "devicemanager.h" 
    2526#include "genericavc/avc_avdevice.h" 
    2627 
     
    3435 
    3536#include "debugmodule/debugmodule.h" 
    36  
    37 #include "config.h" 
    3837 
    3938#include <string> 
     
    7776 
    7877bool 
    79 AvDevice::probe( ConfigRom& configRom, bool generic ) 
     78AvDevice::probe( Util::Configuration& c, ConfigRom& configRom, bool generic ) 
    8079{ 
    8180    if(generic) { 
     
    102101        unsigned int modelId = configRom.getModelId(); 
    103102 
    104         GenericAVC::VendorModel vendorModel( SHAREDIR "/ffado_driver_genericavc.txt" ); 
    105         if ( vendorModel.parse() ) { 
    106             return vendorModel.isPresent( vendorId, modelId ); 
    107         } 
     103        Util::Configuration::VendorModelEntry vme = c.findDeviceVME( vendorId, modelId ); 
     104        return c.isValid(vme) && vme.driver == Util::Configuration::eD_GenericAVC; 
    108105        return false; 
    109106    } 
     
    120117{ 
    121118    Util::MutexLockHelper lock(m_DeviceMutex); 
    122     // check if we already have a valid VendorModel entry 
    123     // e.g. because a subclass called this function 
    124     if (!GenericAVC::VendorModel::isValid(m_model)) { 
    125         unsigned int vendorId = getConfigRom().getNodeVendorId(); 
    126         unsigned int modelId = getConfigRom().getModelId(); 
    127  
    128         GenericAVC::VendorModel vendorModel( SHAREDIR "/ffado_driver_genericavc.txt" ); 
    129         if ( vendorModel.parse() ) { 
    130             m_model = vendorModel.find( vendorId, modelId ); 
    131         } 
    132  
    133         if (!GenericAVC::VendorModel::isValid(m_model)) { 
    134             debugWarning("Using generic AV/C support for unsupported device '%s %s'\n", 
    135                         getConfigRom().getVendorName().c_str(), getConfigRom().getModelName().c_str()); 
    136         } else { 
    137             debugOutput( DEBUG_LEVEL_VERBOSE, "found %s %s\n", 
    138                     m_model.vendor_name.c_str(), m_model.model_name.c_str()); 
    139         } 
    140     } 
    141  
     119 
     120    unsigned int vendorId = getConfigRom().getNodeVendorId(); 
     121    unsigned int modelId = getConfigRom().getModelId(); 
     122 
     123    Util::Configuration &c = getDeviceManager().getConfiguration(); 
     124    Util::Configuration::VendorModelEntry vme = c.findDeviceVME( vendorId, modelId ); 
     125 
     126    if (c.isValid(vme) && vme.driver == Util::Configuration::eD_GenericAVC) { 
     127        debugOutput( DEBUG_LEVEL_VERBOSE, "found %s %s\n", 
     128                     vme.vendor_name.c_str(), 
     129                     vme.model_name.c_str()); 
     130    } else { 
     131        debugWarning("Using generic AV/C support for unsupported device '%s %s'\n", 
     132                     getConfigRom().getVendorName().c_str(), getConfigRom().getModelName().c_str()); 
     133    } 
     134    return discoverGeneric(); 
     135
     136 
     137bool 
     138AvDevice::discoverGeneric() 
     139
    142140    if ( !Unit::discover() ) { 
    143141        debugError( "Could not discover unit\n" ); 
     
    153151        return false; 
    154152    } 
    155  
    156153    return true; 
    157154} 
  • branches/libffado-2.0/src/genericavc/avc_avdevice.h

    r1288 r1299  
    2727 
    2828#include "ffadodevice.h" 
    29 #include "genericavc/avc_vendormodel.h" 
     29#include "libutil/Configuration.h" 
    3030 
    3131#include "libavc/avc_definitions.h" 
     
    5050    AvDevice( DeviceManager& d, std::auto_ptr<ConfigRom>( configRom )); 
    5151    virtual ~AvDevice(); 
    52      
    53     static bool probe( ConfigRom& configRom, bool generic = false ); 
     52 
     53    static bool probe( Util::Configuration&, ConfigRom& configRom, bool generic = false ); 
    5454    virtual bool discover(); 
     55    bool discoverGeneric(); 
    5556    static FFADODevice * createDevice( DeviceManager& d, std::auto_ptr<ConfigRom>( configRom )); 
    5657 
     
    9394                                   AVC::ESamplingFrequency samplingFrequency );*/ 
    9495 
    95     struct VendorModelEntry m_model; 
    96  
    9796    // streaming stuff 
    9897    typedef std::vector< Streaming::StreamProcessor * > StreamProcessorVector; 
  • branches/libffado-2.0/src/libutil/TimestampedBuffer.h

    r1001 r1299  
    2525#define __FFADO_TIMESTAMPEDBUFFER__ 
    2626 
    27 #include "../debugmodule/debugmodule.h" 
     27#include "debugmodule/debugmodule.h" 
    2828#include "libutil/ringbuffer.h" 
    2929#include <pthread.h> 
  • branches/libffado-2.0/src/motu/motu_avdevice.cpp

    r1289 r1299  
    3737 
    3838#include "libutil/Time.h" 
     39#include "libutil/Configuration.h" 
    3940 
    4041#include "libcontrol/BasicElements.h" 
     
    587588 
    588589bool 
    589 MotuDevice::probe( ConfigRom& configRom, bool generic) 
     590MotuDevice::probe( Util::Configuration& c, ConfigRom& configRom, bool generic) 
    590591{ 
    591592    if(generic) return false; 
  • branches/libffado-2.0/src/motu/motu_avdevice.h

    r1288 r1299  
    9595class Ieee1394Service; 
    9696 
     97namespace Util { 
     98    class Configuration; 
     99} 
     100 
    97101namespace Motu { 
    98102 
     
    151155    virtual bool destroyMixer(); 
    152156 
    153     static bool probe( ConfigRom& configRom, bool generic = false ); 
     157    static bool probe( Util::Configuration&, ConfigRom& configRom, bool generic = false ); 
    154158    static FFADODevice * createDevice( DeviceManager& d, std::auto_ptr<ConfigRom>( configRom )); 
    155159    static int getConfigurationId( ); 
  • branches/libffado-2.0/src/SConscript

    r1280 r1299  
    7171        libstreaming/generic/PortManager.cpp \ 
    7272        libutil/cmd_serialize.cpp \ 
     73        libutil/Configuration.cpp \ 
    7374        libutil/OptionContainer.cpp \ 
    7475        libutil/PosixMutex.cpp \ 
     
    113114' ) 
    114115bebob_pkgdata = env.Split( '\ 
    115         bebob/ffado_driver_bebob.txt \ 
    116116' ) 
    117117 
    118118genericavc_source =  env.Split( '\ 
    119119        genericavc/avc_avdevice.cpp \ 
    120         genericavc/avc_vendormodel.cpp \ 
    121120' ) 
    122121 
    123122genericavc_pkgdata = env.Split( '\ 
    124         genericavc/ffado_driver_genericavc.txt \ 
    125123' )      
    126124 
     
    142140 
    143141fireworks_pkgdata =  env.Split( '\ 
    144         fireworks/ffado_driver_fireworks.txt \ 
    145142' ) 
    146143 
     
    192189                libenv.PrependUnique( LIBS=["expat"] ) 
    193190 
     191# add the libconfig 
     192env.AppendUnique( CPPPATH=["#/external/libconfig"] ) 
     193env.PrependUnique( LIBPATH=[env['build_base']+"external/libconfig"] ) 
     194env.PrependUnique( LIBS=["libconfigpp"] ) 
     195 
    194196#env1.AppendUnique( LINKFLAGS = env.Split("-Wl,-rpath $libdir -Wl,-soname -Wl,libffado.so.1 --version-info=1:0:0") ) 
    195197ffadolib = libenv.SharedLibrary( "ffado", source ) 
  • branches/libffado-2.0/support/firmware/fireworks-downloader.cpp

    r1280 r1299  
    2525#include "downloader.h" 
    2626 
     27#include "config.h" 
     28 
    2729#include "src/fireworks/fireworks_device.h" 
    2830#include "src/fireworks/fireworks_firmware.h" 
     
    3133#include "libieee1394/configrom.h" 
    3234#include "libieee1394/ieee1394service.h" 
     35#include "libutil/Configuration.h" 
    3336 
    3437#include "debugmodule/debugmodule.h" 
     
    220223    } 
    221224 
    222     if ( !FireWorks::Device::probe(*configRom) ) { 
     225    Util::Configuration c; 
     226    c.openFile( USER_CONFIG_FILE, Util::Configuration::eFM_ReadOnly ); 
     227    c.openFile( SYSTEM_CONFIG_FILE, Util::Configuration::eFM_ReadOnly ); 
     228 
     229    if ( !FireWorks::Device::probe(c, *configRom) ) { 
    223230        printMessage( "Device with node id %d is not an ECHO FireWorks device.\n", 
    224231                    node_id ); 
     
    226233        return -1; 
    227234    } 
    228      
     235 
    229236    DeviceManager d = DeviceManager(); 
    230237    Device *dev = new Device(d, std::auto_ptr<ConfigRom>(configRom) ); 
  • branches/libffado-2.0/support/SConscript

    r1185 r1299  
    2626env = env.Clone() 
    2727 
    28 env.SConscript( dirs=["mixer","firmware","dbus"], exports="env" ) 
     28env.SConscript( dirs=["mixer","mixer-qt4","firmware","dbus"], exports="env" ) 
    2929