Changeset 739

Show
Ignore:
Timestamp:
11/28/07 12:02:08 (16 years ago)
Author:
ppalmers
Message:

- Adapt the ffado external API (upgrade to v3)

NEEDS NEW JACK BACKEND

- simplify FFADODevice constructor even more
- implement first framework support for supporting multiple adapters.

currently all firewire adapters are scanned for supported devices unless specified otherwise
however attaching devices to separate adapters is not supported. using multiple adapters at
that are connected together might work.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/config.h.in

    r734 r739  
    2121#define PACKAGE_VERSION "$VERSION-$REVISION" 
    2222 
     23/* Define to the api version */ 
     24#define FFADO_API_VERSION $FFADO_API_VERSION 
     25 
    2326/* Define to 1 if SSE assembly is available. */ 
    2427/*#define USE_SSE 1*/ 
  • trunk/libffado/libffado/ffado.h

    r734 r739  
    2929#define FFADO_MAX_NAME_LEN 256 
    3030 
    31 #define FFADO_BOUNCE_SERVER_VENDORNAME  "FFADO Server" 
    32 #define FFADO_BOUNCE_SERVER_MODELNAME   "ffado-server" 
    33  
    34 #define FFADO_BOUNCE_SERVER_GETXMLDESCRIPTION_CMD 
    35 #define AVC1394_SUBUNIT_TYPE_FFADO_BOUNCE_SERVER     0x0D 
    36  
    37 #define FFADO_API_VERSION 2 
     31#include <stdlib.h> 
     32 
     33#define FFADO_STREAMING_MAX_URL_LENGTH 2048 
     34 
     35#define FFADO_IGNORE_CAPTURE         (1<<0) 
     36#define FFADO_IGNORE_PLAYBACK     (1<<1) 
    3837 
    3938enum ffado_direction { 
     
    4847#endif 
    4948 
    50 ffado_handle_t 
    51 ffado_new_handle( int port ); 
    52  
    53 int 
    54 ffado_destroy_handle( ffado_handle_t ffado_handle ); 
    55  
    56 int 
    57 ffado_discover_devices( ffado_handle_t ffado_handle, int verbose_level ); 
    58  
    59 int ffado_node_is_valid_ffado_device(ffado_handle_t fb_handle, int node_id); 
    60 int ffado_get_nb_devices_on_bus(ffado_handle_t fb_handle); 
    61  
    62 int ffado_get_device_node_id(ffado_handle_t fb_handle, int device_nr); 
    63 int ffado_set_samplerate(ffado_handle_t ffado_handle, int node_id, int samplerate); 
    64  
    6549/* ABI stuff */ 
    6650const char* 
     
    7559   will disapear as soon bug is fixed */     
    7660void ffado_sleep_after_avc_command( int time ); 
    77  
    78 #ifdef __cplusplus 
    79 } 
    80 #endif 
    81  
    82 #endif /* FFADO_H */ 
    83  
    84 /* ffado_streaming.h 
    85  * 
    86  * Specification for the FFADO Streaming API 
    87  * 
    88  */ 
    89 #ifndef __FFADO_STREAMING_H__ 
    90 #define __FFADO_STREAMING_H__ 
    91  
    92 #include <stdlib.h> 
    93  
    94 #ifdef __cplusplus 
    95 extern "C" { 
    96 #endif 
    97  
    98 #define FFADO_STREAMING_MAX_URL_LENGTH 2048 
    99  
    100 #define FFADO_IGNORE_CAPTURE         (1<<0) 
    101 #define FFADO_IGNORE_PLAYBACK     (1<<1) 
    10261 
    10362 
     
    13796 */ 
    13897 
    139 typedef unsigned int ffado_sample_t; 
    140  
    141  
     98typedef unsigned int ffado_sample_t; // FIXME 
    14299typedef unsigned int ffado_nframes_t; 
    143100 
    144  
     101#define FFADO_MAX_SPECSTRING_LENGTH 256 
     102#define FFADO_MAX_SPECSTRINGS       64 
     103/** 
     104 * This struct serves to define the devices that should be used by the library 
     105 * device_spec_strings is an array of pointers that should contain nb_device_spec_strings 
     106 * valid pointers to strings.  
     107 *  
     108 * The spec strings should be null terminated and can be no longer 
     109 * than FFADO_MAX_SPECSTRINGS. 
     110 * 
     111 * nb_device_spec_strings < FFADO_MAX_SPECSTRING_LENGTH 
     112 * nb_device_spec_strings >= 0 
     113 * 
     114 * If nb_device_spec_strings == 0, all busses are scanned for attached devices, and 
     115 * all found devices that are supported are combined into one large pseudo-device. The 
     116 * device order is defined by the GUID of the device. Devices with lower GUID's will 
     117 * be the first ones. 
     118 * 
     119 * If multiple device specifications are present, the device order is defined as follows: 
     120 *  - device(s) that correspond to a spec string with a lower index will be added before 
     121 *    devices from higher indexes. 
     122 *  - if a spec string results in multiple devices, they are sorted by GUID unless the 
     123 *    spec format dictates otherwise. 
     124 * 
     125 * The actual meaning of the device specification should be one of the following: 
     126 * - Format 1: "hw:x[,y[,z]]" 
     127 *     x = the firewire bus to use ('port' in raw1394 terminology) 
     128 *         (mandatory) 
     129 *     y = the node id the device currently has (bus resets might change that, but FFADO  
     130 *         will track these changes and keep using the device specified on startup) 
     131 *         (optional) 
     132 *     z = the stream direction to use. 
     133 *           0 => capture (record) channels only 
     134 *           1 => playback channels only 
     135 *           other/unspecified => both playback and capture 
     136 *         (optional) 
     137 * 
     138 * - Format 2: the device alias as defined in the ffado config file (UNIMPLEMENTED) 
     139 */ 
    145140typedef struct ffado_device_info { 
    146     /* TODO: How is the device specification done? */ 
    147 //    ffado_device_info_location_type location_type; 
     141    unsigned int nb_device_spec_strings; 
     142    char **device_spec_strings; 
     143 
     144    /* add some extra space to allow for future API extention  
     145       w/o breaking binary compatibility */ 
     146    int32_t reserved[32]; 
    148147} ffado_device_info_t; 
    149148 
     
    153152typedef struct ffado_options { 
    154153    /* driver related setup */ 
    155     int sample_rate;         /* this is acutally dictated by the device 
     154    int32_t sample_rate;         /* 
    156155                             * you can specify a value here or -1 to autodetect 
    157156                              */ 
    158157 
    159158    /* buffer setup */ 
    160     int period_size;     /* one period is the amount of frames that 
     159    int32_t period_size;     /* one period is the amount of frames that 
    161160                 * has to be sent or received in order for 
    162161                 * a period boundary to be signalled. 
    163162                 * (unit: frames) 
    164163                 */ 
    165     int nb_buffers;    /* the size of the frame buffer (in periods) */ 
     164    int32_t nb_buffers;    /* the size of the frame buffer (in periods) */ 
    166165 
    167166    /* packetizer thread options */ 
    168     int realtime; 
    169     int packetizer_priority; 
    170      
    171     /* libffado related setup */ 
    172     int node_id; 
    173     int port; 
    174      
    175     /* direction map */ 
    176     int directions; 
    177      
     167    int32_t realtime; 
     168    int32_t packetizer_priority; 
     169 
    178170    /* verbosity */ 
    179     int verbose; 
    180      
     171    int32_t verbose; 
     172 
    181173    /* slave mode */ 
    182     int slave_mode; 
    183      
     174    int32_t slave_mode; 
    184175    /* snoop mode */ 
    185     int snoop_mode; 
     176    int32_t snoop_mode; 
     177 
     178    /* add some extra space to allow for future API extention  
     179       w/o breaking binary compatibility */ 
     180    int32_t reserved[24]; 
    186181 
    187182} ffado_options_t; 
     
    197192 * A ffado_midi type stream is a stream of midi bytes. The bytes are 8bit UINT, 
    198193 * aligned as the first 8LSB's of the 32bit UINT of the read/write buffer. 
     194 *  
     195 * A ffado_control type stream is a stream that provides control information. The 
     196 * format of this control information is undefined, and the stream should be ignored. 
    199197 * 
    200198 */ 
    201199typedef enum { 
    202     ffado_stream_type_invalid                      =   -1, 
     200      ffado_stream_type_invalid                      =   -1, 
    203201      ffado_stream_type_unknown                      =   0, 
    204202      ffado_stream_type_audio                        =   1, 
     
    213211 */ 
    214212typedef enum { 
    215     ffado_buffer_type_per_stream          =   -1, // use this to use the per-stream read functions 
    216     ffado_buffer_type_int24           =   0, 
    217     ffado_buffer_type_float            =   1, 
    218     ffado_buffer_type_midi            =   2, 
    219 //     ffado_buffer_type_uint32           =   2, 
    220 //     ffado_buffer_type_double           =   3, 
    221 //     ... 
     213    ffado_buffer_type_per_stream      = -1, // use this to use the per-stream read functions 
     214    ffado_buffer_type_int24           =  0, 
     215    ffado_buffer_type_float           =  1, 
     216    ffado_buffer_type_midi            =  2, 
    222217} ffado_streaming_buffer_type; 
    223218 
     
    237232 * 
    238233 */ 
    239 ffado_device_t *ffado_streaming_init (ffado_device_info_t *device_info, 
     234ffado_device_t *ffado_streaming_init( 
     235                     ffado_device_info_t device_info, 
    240236                     ffado_options_t options); 
    241237 
     
    327323 * 
    328324 */ 
    329   
    330   
    331   
     325 
    332326/** 
    333327 * Sets the decode buffer for the stream. This allows for zero-copy decoding. 
  • trunk/libffado/SConstruct

    r736 r739  
    206206        env['REVISION'] = '' 
    207207 
     208env['FFADO_API_VERSION']="3" 
     209 
    208210env['PACKAGE'] = "libffado" 
    209211env['VERSION'] = "1.999.7" 
  • trunk/libffado/src/bebob/bebob_avdevice.cpp

    r728 r739  
    5555namespace BeBoB { 
    5656 
    57 AvDevice::AvDevice( Ieee1394Service& ieee1394service, 
    58                     std::auto_ptr< ConfigRom >( configRom ) ) 
    59     : GenericAVC::AvDevice( ieee1394service, configRom ) 
     57AvDevice::AvDevice(std::auto_ptr< ConfigRom >( configRom ) ) 
     58    : GenericAVC::AvDevice( configRom ) 
    6059    , m_Mixer ( 0 ) 
    6160{ 
     
    9190 
    9291FFADODevice * 
    93 AvDevice::createDevice( Ieee1394Service& ieee1394Service, 
    94                         std::auto_ptr<ConfigRom>( configRom )) 
     92AvDevice::createDevice(std::auto_ptr<ConfigRom>( configRom )) 
    9593{ 
    9694    unsigned int vendorId = configRom->getNodeVendorId(); 
     
    9997    switch (vendorId) { 
    10098        case FW_VENDORID_TERRATEC: 
    101             return new Terratec::PhaseSeriesDevice(ieee1394Service, configRom); 
     99            return new Terratec::PhaseSeriesDevice(configRom); 
    102100        case FW_VENDORID_FOCUSRITE: 
    103101            switch(modelId) { 
    104102                case 0x00000003: 
    105103                case 0x00000006: 
    106                     return new Focusrite::SaffireProDevice(ieee1394Service, configRom); 
     104                    return new Focusrite::SaffireProDevice(configRom); 
    107105                case 0x00000000: 
    108                     return new Focusrite::SaffireDevice(ieee1394Service, configRom); 
     106                    return new Focusrite::SaffireDevice(configRom); 
    109107                default: // return a plain BeBoB device 
    110                     return new AvDevice(ieee1394Service, configRom); 
     108                    return new AvDevice(configRom); 
    111109           } 
    112110        default: 
    113             return new AvDevice(ieee1394Service, configRom); 
     111            return new AvDevice(configRom); 
    114112    } 
    115113    return NULL; 
     
    119117AvDevice::discover() 
    120118{ 
    121     unsigned int vendorId = m_pConfigRom->getNodeVendorId(); 
    122     unsigned int modelId = m_pConfigRom->getModelId(); 
     119    unsigned int vendorId = getConfigRom().getNodeVendorId(); 
     120    unsigned int modelId = getConfigRom().getModelId(); 
    123121 
    124122    GenericAVC::VendorModel vendorModel( SHAREDIR "/ffado_driver_bebob.txt" ); 
     
    242240AvDevice::getConfigurationIdSampleRate() 
    243241{ 
    244     ExtendedStreamFormatCmd extStreamFormatCmd( *m_p1394Service ); 
     242    ExtendedStreamFormatCmd extStreamFormatCmd( get1394Service() ); 
    245243    UnitPlugAddress unitPlugAddress( UnitPlugAddress::ePT_PCR, 0 ); 
    246244    extStreamFormatCmd.setPlugAddress( PlugAddress( PlugAddress::ePD_Input, 
     
    275273AvDevice::getConfigurationIdNumberOfChannel( PlugAddress::EPlugDirection ePlugDirection ) 
    276274{ 
    277     ExtendedPlugInfoCmd extPlugInfoCmd( *m_p1394Service ); 
     275    ExtendedPlugInfoCmd extPlugInfoCmd( get1394Service() ); 
    278276    UnitPlugAddress unitPlugAddress( UnitPlugAddress::ePT_PCR, 
    279277                                     getNodeId() ); 
     
    310308AvDevice::getConfigurationIdSyncMode() 
    311309{ 
    312     SignalSourceCmd signalSourceCmd( *m_p1394Service ); 
     310    SignalSourceCmd signalSourceCmd( get1394Service() ); 
    313311    SignalUnitAddress signalUnitAddr; 
    314312    signalUnitAddr.m_plugId = 0x01; 
     
    409407AvDevice::loadFromCache() 
    410408{ 
    411     Glib::ustring sDevicePath = getCachePath() + m_pConfigRom->getGuidString(); 
     409    Glib::ustring sDevicePath = getCachePath() + getConfigRom().getGuidString(); 
    412410 
    413411    char* configId; 
     
    449447    // the path looks like this: 
    450448    // PATH_TO_CACHE + GUID + CONFIGURATION_ID 
    451     string tmp_path = getCachePath() + m_pConfigRom->getGuidString(); 
     449    string tmp_path = getCachePath() + getConfigRom().getGuidString(); 
    452450 
    453451    // the following piece should do something like 
  • trunk/libffado/src/bebob/bebob_avdevice.h

    r734 r739  
    6060class AvDevice : public GenericAVC::AvDevice { 
    6161public: 
    62     AvDevice( Ieee1394Service& ieee1394Service, 
    63               std::auto_ptr<ConfigRom>( configRom )); 
     62    AvDevice( std::auto_ptr<ConfigRom>( configRom )); 
    6463    virtual ~AvDevice(); 
    6564 
     
    6968    virtual bool discover(); 
    7069 
    71     static FFADODevice * createDevice( Ieee1394Service& ieee1394Service, 
    72                                         std::auto_ptr<ConfigRom>( configRom )); 
     70    static FFADODevice * createDevice( std::auto_ptr<ConfigRom>( configRom )); 
    7371 
    7472    virtual AVC::Subunit* createSubunit(AVC::Unit& unit, 
  • trunk/libffado/src/bebob/focusrite/focusrite_generic.cpp

    r680 r739  
    3030namespace Focusrite { 
    3131 
    32 FocusriteDevice::FocusriteDevice( Ieee1394Service& ieee1394Service, 
    33                             std::auto_ptr<ConfigRom>( configRom )) 
    34     : BeBoB::AvDevice( ieee1394Service, configRom) 
     32FocusriteDevice::FocusriteDevice( std::auto_ptr<ConfigRom>( configRom )) 
     33    : BeBoB::AvDevice( configRom) 
    3534{ 
    3635    debugOutput( DEBUG_LEVEL_VERBOSE, "Created BeBoB::Focusrite::FocusriteDevice (NodeID %d)\n", 
     
    141140    fb_nodeid_t nodeId = getNodeId() | 0xFFC0; 
    142141 
    143     if(!m_p1394Service->write_quadlet( nodeId, addr, htonl(data) ) ) { 
     142    if(!get1394Service().write_quadlet( nodeId, addr, htonl(data) ) ) { 
    144143        debugError("Could not write to node 0x%04X addr 0x%012X\n", nodeId, addr); 
    145144        return false; 
     
    157156    fb_nodeid_t nodeId = getNodeId() | 0xFFC0; 
    158157 
    159     if(!m_p1394Service->read_quadlet( nodeId, addr, &result ) ) { 
     158    if(!get1394Service().read_quadlet( nodeId, addr, &result ) ) { 
    160159        debugError("Could not read from node 0x%04llX addr 0x%012llX\n", nodeId, addr); 
    161160        return false; 
  • trunk/libffado/src/bebob/focusrite/focusrite_generic.h

    r676 r739  
    136136class FocusriteDevice : public BeBoB::AvDevice { 
    137137public: 
    138     FocusriteDevice( Ieee1394Service& ieee1394Service, 
    139               std::auto_ptr<ConfigRom>( configRom )); 
     138    FocusriteDevice(std::auto_ptr<ConfigRom>( configRom )); 
    140139    virtual ~FocusriteDevice() {}; 
    141140 
  • trunk/libffado/src/bebob/focusrite/focusrite_saffire.cpp

    r664 r739  
    2828namespace Focusrite { 
    2929 
    30 SaffireDevice::SaffireDevice( Ieee1394Service& ieee1394Service, 
    31                             std::auto_ptr<ConfigRom>( configRom )) 
    32     : FocusriteDevice( ieee1394Service, configRom) 
     30SaffireDevice::SaffireDevice( std::auto_ptr<ConfigRom>( configRom )) 
     31    : FocusriteDevice( configRom) 
    3332{ 
    3433    debugOutput( DEBUG_LEVEL_VERBOSE, "Created BeBoB::Focusrite::SaffireDevice (NodeID %d)\n", 
     
    3938        AVC::AVCCommand::setSleepAfterAVCCommand( 1000 ); 
    4039    } 
    41  
    42 } 
    43  
    44 SaffireDevice::~SaffireDevice() 
    45 { 
    4640 
    4741} 
  • trunk/libffado/src/bebob/focusrite/focusrite_saffire.h

    r662 r739  
    142142class SaffireDevice : public FocusriteDevice { 
    143143public: 
    144     SaffireDevice( Ieee1394Service& ieee1394Service, 
    145               std::auto_ptr<ConfigRom>( configRom )); 
    146     virtual ~SaffireDevice(); 
     144    SaffireDevice(std::auto_ptr<ConfigRom>( configRom )); 
     145    virtual ~SaffireDevice() {}; 
    147146 
    148147    virtual void showDevice(); 
  • trunk/libffado/src/bebob/focusrite/focusrite_saffirepro.cpp

    r684 r739  
    2828namespace Focusrite { 
    2929 
    30 SaffireProDevice::SaffireProDevice( Ieee1394Service& ieee1394Service, 
    31                             std::auto_ptr<ConfigRom>( configRom )) 
    32     : FocusriteDevice( ieee1394Service, configRom) 
    33     , m_MixerContainer ( NULL ) 
    34     , m_ControlContainer ( NULL ) 
     30SaffireProDevice::SaffireProDevice(std::auto_ptr<ConfigRom>( configRom )) 
     31    : FocusriteDevice( configRom ) 
     32    , m_MixerContainer( NULL ) 
     33    , m_ControlContainer( NULL ) 
    3534{ 
    3635    debugOutput( DEBUG_LEVEL_VERBOSE, "Created BeBoB::Focusrite::SaffireProDevice (NodeID %d)\n", 
  • trunk/libffado/src/bebob/focusrite/focusrite_saffirepro.h

    r684 r739  
    302302 
    303303public: 
    304     SaffireProDevice( Ieee1394Service& ieee1394Service, 
    305               std::auto_ptr<ConfigRom>( configRom )); 
     304    SaffireProDevice(std::auto_ptr<ConfigRom>( configRom )); 
    306305    virtual ~SaffireProDevice(); 
    307306 
  • trunk/libffado/src/bebob/terratec/terratec_device.cpp

    r584 r739  
    2727namespace Terratec { 
    2828 
    29 PhaseSeriesDevice::PhaseSeriesDevice( Ieee1394Service& ieee1394Service, 
    30                             std::auto_ptr<ConfigRom>( configRom )) 
    31     : BeBoB::AvDevice( ieee1394Service, configRom) 
     29PhaseSeriesDevice::PhaseSeriesDevice(std::auto_ptr<ConfigRom>( configRom )) 
     30    : BeBoB::AvDevice( configRom) 
    3231{ 
    3332    debugOutput( DEBUG_LEVEL_VERBOSE, "Created BeBoB::Terratec::PhaseSeriesDevice (NodeID %d)\n", 
  • trunk/libffado/src/bebob/terratec/terratec_device.h

    r584 r739  
    3434class PhaseSeriesDevice : public BeBoB::AvDevice { 
    3535public: 
    36     PhaseSeriesDevice( Ieee1394Service& ieee1394Service, 
    37               std::auto_ptr<ConfigRom>( configRom )); 
     36    PhaseSeriesDevice( std::auto_ptr<ConfigRom>( configRom )); 
    3837    virtual ~PhaseSeriesDevice(); 
    3938 
  • trunk/libffado/src/devicemanager.cpp

    r734 r739  
    8080DeviceManager::DeviceManager() 
    8181    : Control::Container("devicemanager") 
    82     , m_1394Service( 0 ) 
    8382{ 
    8483    addOption(Util::OptionContainer::Option("slaveMode",false)); 
     
    9897    } 
    9998 
    100     delete m_1394Service; 
     99    for ( Ieee1394ServiceVectorIterator it = m_1394Services.begin(); 
     100          it != m_1394Services.end(); 
     101          ++it ) 
     102    { 
     103        delete *it; 
     104    } 
     105    for ( FunctorVectorIterator it = m_busreset_functors.begin(); 
     106          it != m_busreset_functors.end(); 
     107          ++it ) 
     108    { 
     109        delete *it; 
     110    } 
    101111} 
    102112 
     
    106116    debugOutput( DEBUG_LEVEL_VERBOSE, "Setting verbose level to %d...\n", l ); 
    107117    setDebugLevel(l); 
    108  
    109     if (m_1394Service) m_1394Service->setVerboseLevel(l); 
    110118    Control::Element::setVerboseLevel(l); 
    111  
    112119    for ( FFADODeviceVectorIterator it = m_avDevices.begin(); 
    113120          it != m_avDevices.end(); 
     121          ++it ) 
     122    { 
     123        (*it)->setVerboseLevel(l); 
     124    } 
     125    for ( Ieee1394ServiceVectorIterator it = m_1394Services.begin(); 
     126          it != m_1394Services.end(); 
    114127          ++it ) 
    115128    { 
     
    122135    debugOutput(DEBUG_LEVEL_NORMAL, "===== Device Manager =====\n"); 
    123136    Control::Element::show(); 
    124      
    125     if (m_1394Service) debugOutput(DEBUG_LEVEL_NORMAL, "1394 port: %d\n", m_1394Service->getPort()); 
    126137 
    127138    int i=0; 
     139    for ( Ieee1394ServiceVectorIterator it = m_1394Services.begin(); 
     140          it != m_1394Services.end(); 
     141          ++it ) 
     142    { 
     143        debugOutput(DEBUG_LEVEL_NORMAL, "--- IEEE1394 Service %2d ---\n", i++); 
     144        (*it)->show(); 
     145    } 
     146 
     147    i=0; 
    128148    for ( FFADODeviceVectorIterator it = m_avDevices.begin(); 
    129149        it != m_avDevices.end(); 
     
    145165                FFADODevice::ClockSourceTypeToString(c.type), c.id, c.valid, c.active, c.description.c_str()); 
    146166        } 
    147  
    148167    } 
    149168} 
    150169 
    151170bool 
    152 DeviceManager::initialize( int port ) 
    153 
    154     m_1394Service = new Ieee1394Service(); 
    155     if ( !m_1394Service ) { 
    156         debugFatal( "Could not create Ieee1349Service object\n" ); 
     171DeviceManager::initialize() 
     172
     173    assert(m_1394Services.size() == 0); 
     174    assert(m_busreset_functors.size() == 0); 
     175 
     176    unsigned int nb_detected_ports = Ieee1394Service::detectNbPorts(); 
     177    if (nb_detected_ports == 0) { 
     178        debugFatal("No firewire ports found.\n"); 
    157179        return false; 
    158180    } 
    159  
    160     if ( !m_1394Service->initialize( port ) ) { 
    161         debugFatal( "Could not initialize Ieee1349Service object\n" ); 
    162         delete m_1394Service; 
    163         m_1394Service = 0; 
     181    debugOutput( DEBUG_LEVEL_VERBOSE, "Found %d firewire adapters (ports)\n", nb_detected_ports); 
     182    for (unsigned int port = 0; port < nb_detected_ports; port++) { 
     183        Ieee1394Service* tmp1394Service = new Ieee1394Service(); 
     184        if ( !tmp1394Service ) { 
     185            debugFatal( "Could not create Ieee1349Service object for port %d\n", port ); 
     186            return false; 
     187        } 
     188        m_1394Services.push_back(tmp1394Service); 
     189 
     190        if ( !tmp1394Service->initialize( port ) ) { 
     191            debugFatal( "Could not initialize Ieee1349Service object for port %d\n", port ); 
     192            return false; 
     193        } 
     194        // add the bus reset handler 
     195        Functor* tmp_busreset_functor = new MemberFunctor0< DeviceManager*, 
     196                    void (DeviceManager::*)() > 
     197                    ( this, &DeviceManager::busresetHandler, false ); 
     198        if ( !tmp_busreset_functor ) { 
     199            debugFatal( "Could not create busreset handler for port %d\n", port ); 
     200            return false; 
     201        } 
     202        m_busreset_functors.push_back(tmp_busreset_functor); 
     203 
     204        tmp1394Service->addBusResetHandler( tmp_busreset_functor ); 
     205        tmp1394Service->setVerboseLevel( getDebugLevel() ); 
     206    } 
     207    return true; 
     208
     209 
     210bool 
     211DeviceManager::addSpecString(char *s) { 
     212    std::string spec = s; 
     213    if(isSpecStringValid(spec)) { 
     214        debugOutput(DEBUG_LEVEL_VERBOSE, "Adding spec string %s\n", spec.c_str()); 
     215        m_SpecStrings.push_back(spec); 
     216        return true; 
     217    } else { 
     218        debugError("Invalid spec string: %s\n", spec.c_str()); 
    164219        return false; 
    165220    } 
    166  
    167     // add the bus reset handler 
    168     m_busreset_functor = new MemberFunctor0< DeviceManager*, 
    169                 void (DeviceManager::*)() > 
    170                 ( this, &DeviceManager::busresetHandler, false ); 
    171     m_1394Service->addBusResetHandler( m_busreset_functor ); 
    172  
    173     setVerboseLevel(getDebugLevel()); 
     221
     222 
     223bool 
     224DeviceManager::isSpecStringValid(std::string s) { 
    174225    return true; 
    175226} 
     
    179230{ 
    180231    debugOutput( DEBUG_LEVEL_VERBOSE, "Bus reset...\n" ); 
    181  
     232    // FIXME: what port was the bus reset on? 
    182233    // propagate the bus reset to all avDevices 
    183234    for ( FFADODeviceVectorIterator it = m_avDevices.begin(); 
     
    215266 
    216267    if (!slaveMode) { 
    217         for ( fb_nodeid_t nodeId = 0
    218               nodeId < m_1394Service->getNodeCount(); 
    219               ++nodeId
     268        for ( Ieee1394ServiceVectorIterator it = m_1394Services.begin()
     269            it != m_1394Services.end(); 
     270            ++it
    220271        { 
    221             debugOutput( DEBUG_LEVEL_VERBOSE, "Probing node %d...\n", nodeId ); 
    222  
    223             if (nodeId == m_1394Service->getLocalNodeId()) { 
    224                 debugOutput( DEBUG_LEVEL_VERBOSE, "Skipping local node (%d)...\n", nodeId ); 
    225                 continue; 
    226             } 
    227  
    228             std::auto_ptr<ConfigRom> configRom = 
    229                 std::auto_ptr<ConfigRom>( new ConfigRom( *m_1394Service, 
    230                                                          nodeId ) ); 
    231             if ( !configRom->initialize() ) { 
    232                 // \todo If a PHY on the bus is in power safe mode then 
    233                 // the config rom is missing. So this might be just 
    234                 // such this case and we can safely skip it. But it might 
    235                 // be there is a real software problem on our side. 
    236                 // This should be handlede more carefuly. 
    237                 debugOutput( DEBUG_LEVEL_NORMAL, 
    238                              "Could not read config rom from device (node id %d). " 
    239                              "Skip device discovering for this node\n", 
    240                              nodeId ); 
    241                 continue; 
    242             } 
    243  
    244             FFADODevice* avDevice = getDriverForDevice( configRom, 
    245                                                         nodeId ); 
    246  
    247             if ( avDevice ) { 
    248                 debugOutput( DEBUG_LEVEL_NORMAL, 
    249                              "driver found for device %d\n", 
    250                              nodeId ); 
    251  
    252                 avDevice->setVerboseLevel( getDebugLevel() ); 
    253                 bool isFromCache = false; 
    254                 if ( avDevice->loadFromCache() ) { 
    255                     debugOutput( DEBUG_LEVEL_VERBOSE, "could load from cache\n" ); 
    256                     isFromCache = true; 
    257                 } else if ( avDevice->discover() ) { 
    258                     debugOutput( DEBUG_LEVEL_VERBOSE, "discovering successful\n" ); 
    259                 } else { 
    260                     debugError( "could not discover device\n" ); 
    261                     delete avDevice; 
     272            Ieee1394Service *portService = *it; 
     273            for ( fb_nodeid_t nodeId = 0; 
     274                nodeId < portService->getNodeCount(); 
     275                ++nodeId ) 
     276            { 
     277                debugOutput( DEBUG_LEVEL_VERBOSE, "Probing node %d...\n", nodeId ); 
     278     
     279                if (nodeId == portService->getLocalNodeId()) { 
     280                    debugOutput( DEBUG_LEVEL_VERBOSE, "Skipping local node (%d)...\n", nodeId ); 
    262281                    continue; 
    263282                } 
    264  
    265                 if (snoopMode) { 
    266                     debugOutput( DEBUG_LEVEL_VERBOSE, 
    267                                  "Enabling snoop mode on node %d...\n", nodeId ); 
    268  
    269                     if(!avDevice->setOption("snoopMode", snoopMode)) { 
    270                         debugWarning("Could not set snoop mode for device on node %d\n", nodeId); 
     283     
     284                std::auto_ptr<ConfigRom> configRom = 
     285                    std::auto_ptr<ConfigRom>( new ConfigRom( *portService, nodeId ) ); 
     286                if ( !configRom->initialize() ) { 
     287                    // \todo If a PHY on the bus is in power safe mode then 
     288                    // the config rom is missing. So this might be just 
     289                    // such this case and we can safely skip it. But it might 
     290                    // be there is a real software problem on our side. 
     291                    // This should be handlede more carefuly. 
     292                    debugOutput( DEBUG_LEVEL_NORMAL, 
     293                                "Could not read config rom from device (node id %d). " 
     294                                "Skip device discovering for this node\n", 
     295                                nodeId ); 
     296                    continue; 
     297                } 
     298 
     299                bool already_in_vector = false; 
     300                for ( FFADODeviceVectorIterator it = m_avDevices.begin(); 
     301                    it != m_avDevices.end(); 
     302                    ++it ) 
     303                { 
     304                    if ((*it)->getConfigRom().getGuid() == configRom->getGuid()) { 
     305                        already_in_vector = true; 
     306                        break; 
     307                    } 
     308                } 
     309                if (already_in_vector) { 
     310                    debugWarning("Device with GUID %s already discovered on other port, skipping device...\n", 
     311                                 configRom->getGuidString().c_str()); 
     312                    continue; 
     313                } 
     314 
     315                if( getDebugLevel() >= DEBUG_LEVEL_VERBOSE) { 
     316                    configRom->printConfigRom(); 
     317                } 
     318 
     319                FFADODevice* avDevice = getDriverForDevice( configRom, 
     320                                                            nodeId ); 
     321     
     322                if ( avDevice ) { 
     323                    debugOutput( DEBUG_LEVEL_NORMAL, 
     324                                "driver found for device %d\n", 
     325                                nodeId ); 
     326     
     327                    avDevice->setVerboseLevel( getDebugLevel() ); 
     328                    bool isFromCache = false; 
     329                    if ( avDevice->loadFromCache() ) { 
     330                        debugOutput( DEBUG_LEVEL_VERBOSE, "could load from cache\n" ); 
     331                        isFromCache = true; 
     332                    } else if ( avDevice->discover() ) { 
     333                        debugOutput( DEBUG_LEVEL_VERBOSE, "discovering successful\n" ); 
     334                    } else { 
     335                        debugError( "could not discover device\n" ); 
    271336                        delete avDevice; 
    272337                        continue; 
    273338                    } 
     339     
     340                    if (snoopMode) { 
     341                        debugOutput( DEBUG_LEVEL_VERBOSE, 
     342                                    "Enabling snoop mode on node %d...\n", nodeId ); 
     343     
     344                        if(!avDevice->setOption("snoopMode", snoopMode)) { 
     345                            debugWarning("Could not set snoop mode for device on node %d\n", nodeId); 
     346                            delete avDevice; 
     347                            continue; 
     348                        } 
     349                    } 
     350 
     351                    if ( !isFromCache && !avDevice->saveCache() ) { 
     352                        debugOutput( DEBUG_LEVEL_VERBOSE, "No cached version of AVC model created\n" ); 
     353                    } 
     354 
     355                    m_avDevices.push_back( avDevice ); 
     356 
     357                    if (!addElement(avDevice)) { 
     358                        debugWarning("failed to add AvDevice to Control::Container\n"); 
     359                    } 
     360 
     361                    debugOutput( DEBUG_LEVEL_NORMAL, "discovery of node %d on port %d done...\n", nodeId, portService->getPort() ); 
    274362                } 
    275  
    276                 if ( !isFromCache && !avDevice->saveCache() ) { 
    277                     debugOutput( DEBUG_LEVEL_VERBOSE, "No cached version of AVC model created\n" ); 
    278                 } 
    279  
    280                 m_avDevices.push_back( avDevice ); 
    281  
    282                 if (!addElement(avDevice)) { 
    283                     debugWarning("failed to add AvDevice to Control::Container\n"); 
    284                 } 
    285                  
    286                 debugOutput( DEBUG_LEVEL_NORMAL, "discovery of node %d done...\n", nodeId ); 
    287  
    288363            } 
    289364        } 
    290365 
    291366        debugOutput( DEBUG_LEVEL_NORMAL, "Discovery finished...\n" ); 
    292  
     367        // FIXME: do better sorting 
    293368        // sort the m_avDevices vector on their GUID 
    294369        // then assign reassign the id's to the devices 
     
    296371        // a device id always corresponds to the same device 
    297372        sort(m_avDevices.begin(), m_avDevices.end(), FFADODevice::compareGUID); 
    298          
    299373        int i=0; 
    300374        for ( FFADODeviceVectorIterator it = m_avDevices.begin(); 
     
    306380            } 
    307381        } 
    308  
    309382        show(); 
    310383        return true; 
    311  
    312384    } else { // slave mode 
    313         fb_nodeid_t nodeId = m_1394Service->getLocalNodeId(); 
     385        Ieee1394Service *portService = m_1394Services.at(0); 
     386        fb_nodeid_t nodeId = portService->getLocalNodeId(); 
    314387        debugOutput( DEBUG_LEVEL_VERBOSE, "Starting in slave mode on node %d...\n", nodeId ); 
    315388 
    316389        std::auto_ptr<ConfigRom> configRom = 
    317             std::auto_ptr<ConfigRom>( new ConfigRom( *m_1394Service, 
     390            std::auto_ptr<ConfigRom>( new ConfigRom( *portService, 
    318391                                                     nodeId ) ); 
    319392        if ( !configRom->initialize() ) { 
     
    350423                avDevice->showDevice(); 
    351424            } 
    352  
    353425            m_avDevices.push_back( avDevice ); 
    354  
    355             debugOutput( DEBUG_LEVEL_NORMAL, "discovery of node %d done...\n", nodeId ); 
     426            debugOutput( DEBUG_LEVEL_NORMAL, "discovery of node %d on port %d done...\n", nodeId, portService->getPort() ); 
    356427        } 
    357428 
    358429        debugOutput( DEBUG_LEVEL_NORMAL, "discovery finished...\n" ); 
    359  
    360430        return true; 
    361431    } 
     
    369439    debugOutput( DEBUG_LEVEL_VERBOSE, "Trying BeBoB...\n" ); 
    370440    if ( BeBoB::AvDevice::probe( *configRom.get() ) ) { 
    371         return BeBoB::AvDevice::createDevice( *m_1394Service, configRom ); 
     441        return BeBoB::AvDevice::createDevice( configRom ); 
    372442    } 
    373443#endif 
     
    376446    debugOutput( DEBUG_LEVEL_VERBOSE, "Trying Generic AV/C...\n" ); 
    377447    if ( GenericAVC::AvDevice::probe( *configRom.get() ) ) { 
    378         return GenericAVC::AvDevice::createDevice( *m_1394Service, configRom ); 
     448        return GenericAVC::AvDevice::createDevice( configRom ); 
    379449    } 
    380450#endif 
     
    383453    debugOutput( DEBUG_LEVEL_VERBOSE, "Trying ECHO Audio FireWorks...\n" ); 
    384454    if ( FireWorks::Device::probe( *configRom.get() ) ) { 
    385         return FireWorks::Device::createDevice( *m_1394Service, configRom ); 
     455        return FireWorks::Device::createDevice( configRom ); 
    386456    } 
    387457#endif 
     
    390460    debugOutput( DEBUG_LEVEL_VERBOSE, "Trying M-Audio...\n" ); 
    391461    if ( MAudio::AvDevice::probe( *configRom.get() ) ) { 
    392         return MAudio::AvDevice::createDevice( *m_1394Service, configRom ); 
     462        return MAudio::AvDevice::createDevice( configRom ); 
    393463    } 
    394464#endif 
     
    397467    debugOutput( DEBUG_LEVEL_VERBOSE, "Trying Motu...\n" ); 
    398468    if ( Motu::MotuDevice::probe( *configRom.get() ) ) { 
    399         return Motu::MotuDevice::createDevice( *m_1394Service, configRom ); 
     469        return Motu::MotuDevice::createDevice( configRom ); 
    400470    } 
    401471#endif 
     
    404474    debugOutput( DEBUG_LEVEL_VERBOSE, "Trying Dice...\n" ); 
    405475    if ( Dice::DiceAvDevice::probe( *configRom.get() ) ) { 
    406         return Dice::DiceAvDevice::createDevice( *m_1394Service, configRom ); 
     476        return Dice::DiceAvDevice::createDevice( configRom ); 
    407477    } 
    408478#endif 
     
    411481    debugOutput( DEBUG_LEVEL_VERBOSE, "Trying Metric Halo...\n" ); 
    412482    if ( MetricHalo::MHAvDevice::probe( *configRom.get() ) ) { 
    413         return MetricHalo::MHAvDevice::createDevice( *m_1394Service, configRom ); 
     483        return MetricHalo::MHAvDevice::createDevice( configRom ); 
    414484    } 
    415485#endif 
     
    418488    debugOutput( DEBUG_LEVEL_VERBOSE, "Trying RME...\n" ); 
    419489    if ( Rme::RmeDevice::probe( *configRom.get() ) ) { 
    420         return Rme::RmeDevice::createDevice( *m_1394Service, configRom ); 
     490        return Rme::RmeDevice::createDevice( configRom ); 
    421491    } 
    422492#endif 
     
    425495    debugOutput( DEBUG_LEVEL_VERBOSE, "Trying Bounce...\n" ); 
    426496    if ( Bounce::BounceDevice::probe( *configRom.get() ) ) { 
    427         return Bounce::BounceDevice::createDevice( *m_1394Service, configRom ); 
     497        return Bounce::BounceDevice::createDevice( configRom ); 
    428498    } 
    429499#endif 
     
    438508#ifdef ENABLE_BOUNCE 
    439509    if ( Bounce::BounceSlaveDevice::probe( *configRom.get() ) ) { 
    440         return Bounce::BounceSlaveDevice::createDevice( *m_1394Service, configRom ); 
     510        return Bounce::BounceSlaveDevice::createDevice( configRom ); 
    441511    } 
    442512#endif 
  • trunk/libffado/src/devicemanager.h

    r734 r739  
    3737 
    3838#include <vector> 
     39#include <string> 
    3940 
    4041class Ieee1394Service; 
     
    4748typedef std::vector< FFADODevice* >::iterator FFADODeviceVectorIterator; 
    4849 
     50typedef std::vector< Ieee1394Service* > Ieee1394ServiceVector; 
     51typedef std::vector< Ieee1394Service* >::iterator Ieee1394ServiceVectorIterator; 
     52 
     53typedef std::vector< Functor* > FunctorVector; 
     54typedef std::vector< Functor* >::iterator FunctorVectorIterator; 
     55 
    4956class DeviceManager 
    5057    : public Util::OptionContainer, 
     
    5562    ~DeviceManager(); 
    5663 
    57     bool initialize( int port ); 
     64    bool initialize(); 
    5865    bool deinitialize(); 
    5966 
    60     bool discover( ); 
     67    bool addSpecString(char *); 
     68    bool isSpecStringValid(std::string s); 
     69 
     70    bool discover(); 
    6171 
    6272    bool isValidNode( int node ); 
     
    8090protected: 
    8191    FFADODevice* getDriverForDevice( std::auto_ptr<ConfigRom>( configRom ), 
    82                                    int id ); 
     92                                     int id ); 
    8393    FFADODevice* getSlaveDriver( std::auto_ptr<ConfigRom>( configRom ) ); 
    8494 
     
    8696 
    8797protected: 
    88     Ieee1394Service*   m_1394Service; 
    89     FFADODeviceVector  m_avDevices; 
    90     Functor*           m_busreset_functor; 
     98    // we have one service for each port 
     99    // found on the system. We don't allow dynamic addition of ports (yet) 
     100    Ieee1394ServiceVector   m_1394Services; 
     101    FFADODeviceVector       m_avDevices; 
     102    FunctorVector           m_busreset_functors; 
     103 
     104    std::vector<std::string>          m_SpecStrings; 
    91105 
    92106// debug stuff 
  • trunk/libffado/src/dice/dice_avdevice.cpp

    r734 r739  
    5252}; 
    5353 
    54 DiceAvDevice::DiceAvDevice( Ieee1394Service& ieee1394Service, 
    55                             std::auto_ptr<ConfigRom>( configRom )) 
    56     : FFADODevice( ieee1394Service, configRom ) 
     54DiceAvDevice::DiceAvDevice( std::auto_ptr<ConfigRom>( configRom )) 
     55    : FFADODevice( configRom ) 
    5756    , m_model( NULL ) 
    5857    , m_global_reg_offset (0xFFFFFFFFLU) 
     
    108107 
    109108FFADODevice * 
    110 DiceAvDevice::createDevice( Ieee1394Service& ieee1394Service, 
    111                             std::auto_ptr<ConfigRom>( configRom )) 
     109DiceAvDevice::createDevice( std::auto_ptr<ConfigRom>( configRom )) 
    112110{ 
    113     return new DiceAvDevice(ieee1394Service, configRom ); 
     111    return new DiceAvDevice( configRom ); 
    114112} 
    115113 
     
    117115DiceAvDevice::discover() 
    118116{ 
    119     unsigned int vendorId = m_pConfigRom->getNodeVendorId(); 
    120     unsigned int modelId = m_pConfigRom->getModelId(); 
     117    unsigned int vendorId = getConfigRom().getNodeVendorId(); 
     118    unsigned int modelId = getConfigRom().getModelId(); 
    121119 
    122120    for ( unsigned int i = 0; 
     
    490488        Streaming::AmdtpReceiveStreamProcessor *p; 
    491489        p=new Streaming::AmdtpReceiveStreamProcessor( 
    492                              m_p1394Service->getPort(), 
     490                             get1394Service().getPort(), 
    493491                             nb_channels); 
    494492 
     
    576574        Streaming::AmdtpTransmitStreamProcessor *p; 
    577575        p=new Streaming::AmdtpTransmitStreamProcessor( 
    578                              m_p1394Service->getPort(), 
     576                             get1394Service().getPort(), 
    579577                             nb_channels); 
    580578 
     
    690688    // get a notifier to handle device notifications 
    691689    nodeaddr_t notify_address; 
    692     notify_address = m_p1394Service->findFreeARMBlock( 
     690    notify_address = get1394Service().findFreeARMBlock( 
    693691                        DICE_NOTIFIER_BASE_ADDRESS, 
    694692                        DICE_NOTIFIER_BLOCK_LENGTH, 
     
    707705    } 
    708706 
    709     if (!m_p1394Service->registerARMHandler(m_notifier)) { 
     707    if (!get1394Service().registerARMHandler(m_notifier)) { 
    710708        debugError("Could not register notifier\n"); 
    711709        delete m_notifier; 
     
    726724    } 
    727725 
    728     fb_nodeaddr_t swap_value = ((0xFFC0) | m_p1394Service->getLocalNodeId()); 
     726    fb_nodeaddr_t swap_value = ((0xFFC0) | get1394Service().getLocalNodeId()); 
    729727    swap_value = swap_value << 48; 
    730728    swap_value |= m_notifier->getStart(); 
    731729 
    732     if (!m_p1394Service->lockCompareSwap64(  getNodeId() | 0xFFC0, addr, DICE_OWNER_NO_OWNER, 
     730    if (!get1394Service().lockCompareSwap64(  getNodeId() | 0xFFC0, addr, DICE_OWNER_NO_OWNER, 
    733731                                       swap_value, &result )) { 
    734732        debugWarning("Could not register ourselves as device owner\n"); 
     
    765763    } 
    766764 
    767     fb_nodeaddr_t compare_value = ((0xFFC0) | m_p1394Service->getLocalNodeId()); 
     765    fb_nodeaddr_t compare_value = ((0xFFC0) | get1394Service().getLocalNodeId()); 
    768766    compare_value <<= 48; 
    769767    compare_value |= m_notifier->getStart(); 
    770768 
    771     if (!m_p1394Service->lockCompareSwap64(  getNodeId() | 0xFFC0, addr, compare_value, 
     769    if (!get1394Service().lockCompareSwap64(  getNodeId() | 0xFFC0, addr, compare_value, 
    772770                                       DICE_OWNER_NO_OWNER, &result )) { 
    773771        debugWarning("Could not unregister ourselves as device owner\n"); 
     
    775773    } 
    776774 
    777     m_p1394Service->unregisterARMHandler(m_notifier); 
     775    get1394Service().unregisterARMHandler(m_notifier); 
    778776    delete m_notifier; 
    779777    m_notifier=NULL; 
     
    984982    unsigned int bandwidth=8+packet_size; 
    985983 
    986     int ch=m_p1394Service->allocateIsoChannelGeneric(bandwidth); 
     984    int ch=get1394Service().allocateIsoChannelGeneric(bandwidth); 
    987985 
    988986    debugOutput(DEBUG_LEVEL_VERBOSE, "allocated channel %d, bandwidth %d\n", 
     
    994992bool DiceAvDevice::deallocateIsoChannel(int channel) { 
    995993    debugOutput(DEBUG_LEVEL_VERBOSE, "freeing channel %d\n",channel); 
    996     return m_p1394Service->freeIsoChannel(channel); 
     994    return get1394Service().freeIsoChannel(channel); 
    997995} 
    998996 
     
    12271225    fb_nodeid_t nodeId=getNodeId() | 0xFFC0; 
    12281226 
    1229     if(!m_p1394Service->read_quadlet( nodeId, addr, result ) ) { 
     1227    if(!get1394Service().read_quadlet( nodeId, addr, result ) ) { 
    12301228        debugError("Could not read from node 0x%04X addr 0x%012X\n", nodeId, addr); 
    12311229        return false; 
     
    12521250    fb_nodeid_t nodeId=getNodeId() | 0xFFC0; 
    12531251 
    1254     if(!m_p1394Service->write_quadlet( nodeId, addr, htonl(data) ) ) { 
     1252    if(!get1394Service().write_quadlet( nodeId, addr, htonl(data) ) ) { 
    12551253        debugError("Could not write to node 0x%04X addr 0x%012X\n", nodeId, addr); 
    12561254        return false; 
     
    12721270    fb_nodeid_t nodeId=getNodeId() | 0xFFC0; 
    12731271 
    1274     if(!m_p1394Service->read( nodeId, addr, length/4, data ) ) { 
     1272    if(!get1394Service().read( nodeId, addr, length/4, data ) ) { 
    12751273        debugError("Could not read from node 0x%04X addr 0x%012llX\n", nodeId, addr); 
    12761274        return false; 
     
    13031301    } 
    13041302 
    1305     if(!m_p1394Service->write( nodeId, addr, length/4, data_out ) ) { 
     1303    if(!get1394Service().write( nodeId, addr, length/4, data_out ) ) { 
    13061304        debugError("Could not write to node 0x%04X addr 0x%012llX\n", nodeId, addr); 
    13071305        return false; 
  • trunk/libffado/src/dice/dice_avdevice.h

    r734 r739  
    5757    class DiceNotifier; 
    5858public: 
    59     DiceAvDevice( Ieee1394Service& ieee1394Service, 
    60                   std::auto_ptr<ConfigRom>( configRom )); 
     59    DiceAvDevice( std::auto_ptr<ConfigRom>( configRom )); 
    6160    ~DiceAvDevice(); 
    6261 
    6362    static bool probe( ConfigRom& configRom ); 
    64     static FFADODevice * createDevice( Ieee1394Service& ieee1394Service, 
    65                                         std::auto_ptr<ConfigRom>( configRom )); 
     63    static FFADODevice * createDevice( std::auto_ptr<ConfigRom>( configRom )); 
    6664    virtual bool discover(); 
    6765 
  • trunk/libffado/src/ffado.cpp

    r554 r739  
    2323 */ 
    2424 
     25/* 
     26 * Implementation of the FFADO external C API 
     27 */ 
     28 
    2529#include "config.h" 
    2630 
     
    3135#include "devicemanager.h" 
    3236#include "ffadodevice.h" 
     37#include "libstreaming/StreamProcessorManager.h" 
    3338 
    3439#include <stdio.h> 
    3540#include <stdlib.h> 
    3641#include <string.h> 
     42#include <assert.h> 
     43#include <string> 
    3744 
    3845DECLARE_GLOBAL_DEBUG_MODULE; 
     
    6370} 
    6471 
    65  
    6672int 
    6773ffado_get_api_version() { 
    6874    return FFADO_API_VERSION; 
    69 } 
    70  
    71 ffado_handle_t 
    72 ffado_new_handle( int port ) 
    73 { 
    74     ffado_handle_t handle = new struct ffado_handle; 
    75     if (! handle ) { 
    76         debugFatal( "Could not allocate memory for new handle\n" ); 
    77         return 0; 
    78     } 
    79  
    80     handle->m_deviceManager = new DeviceManager(); 
    81     if ( !handle->m_deviceManager ) { 
    82         debugFatal( "Could not allocate device manager\n" ); 
    83         delete handle; 
    84         return 0; 
    85     } 
    86     if ( !handle->m_deviceManager->initialize( port ) ) { 
    87         debugFatal( "Could not initialize device manager\n" ); 
    88         delete handle->m_deviceManager; 
    89         delete handle; 
    90         return 0; 
    91     } 
    92     return handle; 
    93 } 
    94  
    95 int 
    96 ffado_destroy_handle( ffado_handle_t ffado_handle ) 
    97 { 
    98     delete ffado_handle->m_deviceManager; 
    99     delete ffado_handle; 
    100     return 0; 
    101 } 
    102  
    103 int 
    104 ffado_discover_devices( ffado_handle_t ffado_handle, int verbose ) 
    105 { 
    106     if (verbose) { 
    107         ffado_handle->m_deviceManager->setVerboseLevel(DEBUG_LEVEL_VERBOSE); 
    108    } 
    109     return ffado_handle->m_deviceManager->discover()? 0 : -1; 
    110 } 
    111  
    112 int 
    113 ffado_node_is_valid_ffado_device( ffado_handle_t ffado_handle, int node_id ) 
    114 { 
    115     return ffado_handle->m_deviceManager->isValidNode( node_id ); 
    116 } 
    117  
    118 int 
    119 ffado_get_nb_devices_on_bus( ffado_handle_t ffado_handle ) 
    120 { 
    121     return ffado_handle->m_deviceManager->getNbDevices(); 
    122 } 
    123  
    124 int 
    125 ffado_get_device_node_id( ffado_handle_t ffado_handle, int device_nr ) 
    126 { 
    127     return ffado_handle->m_deviceManager->getDeviceNodeId(device_nr); 
    128 } 
    129  
    130 int 
    131 ffado_set_samplerate( ffado_handle_t ffado_handle, int node_id, int samplerate ) 
    132 { 
    133     FFADODevice* avDevice = ffado_handle->m_deviceManager->getAvDevice( node_id ); 
    134     if ( avDevice ) { 
    135         if ( avDevice->setSamplingFrequency( samplerate ) ) { 
    136             return ffado_handle->m_deviceManager->discover()? 0 : -1; 
    137         } 
    138     } 
    139     return -1; 
    14075} 
    14176 
     
    14681    AVC::AVCCommand::setSleepAfterAVCCommand( time ); 
    14782} 
     83 
     84 
     85using namespace Streaming; 
     86 
     87struct _ffado_device 
     88{ 
     89    DeviceManager * m_deviceManager; 
     90    StreamProcessorManager *processorManager; 
     91 
     92    ffado_options_t options; 
     93    ffado_device_info_t device_info; 
     94}; 
     95 
     96ffado_device_t *ffado_streaming_init (ffado_device_info_t device_info, ffado_options_t options) { 
     97    unsigned int i=0; 
     98    setDebugLevel(options.verbose); 
     99 
     100    struct _ffado_device *dev = new struct _ffado_device; 
     101 
     102    debugWarning("%s built %s %s\n", ffado_get_version(), __DATE__, __TIME__); 
     103 
     104    if(!dev) { 
     105        debugFatal( "Could not allocate streaming device\n" ); 
     106        return 0; 
     107    } 
     108 
     109    memcpy((void *)&dev->options, (void *)&options, sizeof(dev->options)); 
     110 
     111    dev->m_deviceManager = new DeviceManager(); 
     112    if ( !dev->m_deviceManager ) { 
     113        debugFatal( "Could not allocate device manager\n" ); 
     114        delete dev; 
     115        return 0; 
     116    } 
     117 
     118    dev->m_deviceManager->setVerboseLevel(dev->options.verbose); 
     119    if ( !dev->m_deviceManager->initialize() ) { 
     120        debugFatal( "Could not initialize device manager\n" ); 
     121        delete dev->m_deviceManager; 
     122        delete dev; 
     123        return 0; 
     124    } 
     125 
     126    for (i = 0; i < device_info.nb_device_spec_strings; i++) { 
     127        char *s = device_info.device_spec_strings[i]; 
     128        if ( !dev->m_deviceManager->addSpecString(s) ) {  
     129            debugFatal( "Could not add spec string %s to device manager\n", s ); 
     130            delete dev->m_deviceManager; 
     131            delete dev; 
     132            return 0; 
     133        } 
     134    } 
     135 
     136 
     137    // create a processor manager to manage the actual stream 
     138    // processors 
     139    dev->processorManager = new StreamProcessorManager( dev->options.period_size,  
     140                                                        dev->options.sample_rate, 
     141                                                        dev->options.nb_buffers); 
     142    if(!dev->processorManager) { 
     143            debugFatal("Could not create StreamProcessorManager\n"); 
     144            delete dev->m_deviceManager; 
     145            delete dev; 
     146            return 0; 
     147    } 
     148 
     149    dev->processorManager->setThreadParameters(dev->options.realtime, dev->options.packetizer_priority); 
     150 
     151    dev->processorManager->setVerboseLevel(dev->options.verbose); 
     152    if(!dev->processorManager->init()) { 
     153            debugFatal("Could not init StreamProcessorManager\n"); 
     154            delete dev->processorManager; 
     155            delete dev->m_deviceManager; 
     156            delete dev; 
     157            return 0; 
     158    } 
     159 
     160    // set slave mode option 
     161    bool slaveMode=(dev->options.slave_mode != 0); 
     162    debugOutput(DEBUG_LEVEL_VERBOSE, "setting slave mode to %d\n", slaveMode); 
     163    if(!dev->m_deviceManager->setOption("slaveMode", slaveMode)) { 
     164            debugWarning("Failed to set slave mode option\n"); 
     165    } 
     166    // set snoop mode option 
     167    bool snoopMode=(dev->options.snoop_mode != 0); 
     168    debugOutput(DEBUG_LEVEL_VERBOSE, "setting snoop mode to %d\n", snoopMode); 
     169    if(!dev->m_deviceManager->setOption("snoopMode", snoopMode)) { 
     170            debugWarning("Failed to set snoop mode option\n"); 
     171    } 
     172 
     173    // discover the devices on the bus 
     174    if(!dev->m_deviceManager->discover()) { 
     175            debugFatal("Could not discover devices\n"); 
     176            delete dev->processorManager; 
     177            delete dev->m_deviceManager; 
     178            delete dev; 
     179            return 0; 
     180    } 
     181 
     182    // are there devices on the bus? 
     183    if(dev->m_deviceManager->getAvDeviceCount()==0) { 
     184            debugFatal("There are no devices on the bus\n"); 
     185            delete dev->processorManager; 
     186            delete dev->m_deviceManager; 
     187            delete dev; 
     188            return 0; 
     189    } 
     190 
     191    // iterate over the found devices 
     192    // add the stream processors of the devices to the managers 
     193    for(i=0;i<dev->m_deviceManager->getAvDeviceCount();i++) { 
     194        FFADODevice *device=dev->m_deviceManager->getAvDeviceByIndex(i); 
     195        assert(device); 
     196 
     197        debugOutput(DEBUG_LEVEL_VERBOSE, "Locking device (%p)\n", device); 
     198 
     199        if (!device->lock()) { 
     200            debugWarning("Could not lock device, skipping device (%p)!\n", device); 
     201            continue; 
     202        } 
     203 
     204        debugOutput(DEBUG_LEVEL_VERBOSE, "Setting samplerate to %d for (%p)\n", 
     205                    dev->options.sample_rate, device); 
     206 
     207        // Set the device's sampling rate to that requested 
     208        // FIXME: does this really belong here?  If so we need to handle errors. 
     209        if (!device->setSamplingFrequency(dev->options.sample_rate)) { 
     210            debugOutput(DEBUG_LEVEL_VERBOSE, " => Retry setting samplerate to %d for (%p)\n", 
     211                        dev->options.sample_rate, device); 
     212 
     213            // try again: 
     214            if (!device->setSamplingFrequency(dev->options.sample_rate)) { 
     215                delete dev->processorManager; 
     216                delete dev->m_deviceManager; 
     217                delete dev; 
     218                debugFatal("Could not set sampling frequency to %d\n",dev->options.sample_rate); 
     219                return 0; 
     220            } 
     221        } 
     222 
     223        // prepare the device 
     224        device->prepare(); 
     225        int j=0; 
     226        for(j=0; j<device->getStreamCount();j++) { 
     227            StreamProcessor *streamproc=device->getStreamProcessorByIndex(j); 
     228            debugOutput(DEBUG_LEVEL_VERBOSE, "Registering stream processor %d of device %d with processormanager\n",j,i); 
     229            if (!dev->processorManager->registerProcessor(streamproc)) { 
     230                delete dev->processorManager; 
     231                delete dev->m_deviceManager; 
     232                delete dev; 
     233                debugFatal("Could not register stream processor (%p) with the Processor manager\n", streamproc); 
     234                return 0; 
     235            } 
     236        } 
     237    } 
     238 
     239    // set the sync source 
     240    if (!dev->processorManager->setSyncSource(dev->m_deviceManager->getSyncSource())) { 
     241        debugWarning("Could not set processorManager sync source (%p)\n", 
     242            dev->m_deviceManager->getSyncSource()); 
     243    } 
     244 
     245    // we are ready! 
     246    debugOutputShort(DEBUG_LEVEL_VERBOSE, "\n\n"); 
     247    return dev; 
     248 
     249} 
     250 
     251int ffado_streaming_prepare(ffado_device_t *dev) { 
     252    debugOutput(DEBUG_LEVEL_VERBOSE, "Preparing...\n"); 
     253 
     254    if (!dev->processorManager->prepare()) { 
     255        debugFatal("Could not prepare streaming...\n"); 
     256        return false; 
     257    } 
     258 
     259    return true; 
     260} 
     261 
     262void ffado_streaming_finish(ffado_device_t *dev) { 
     263    unsigned int i=0; 
     264 
     265    assert(dev); 
     266 
     267    // iterate over the found devices 
     268    for(i=0;i<dev->m_deviceManager->getAvDeviceCount();i++) { 
     269        FFADODevice *device=dev->m_deviceManager->getAvDeviceByIndex(i); 
     270        assert(device); 
     271 
     272        debugOutput(DEBUG_LEVEL_VERBOSE, "Unlocking device (%p)\n", device); 
     273 
     274        if (!device->unlock()) { 
     275            debugWarning("Could not unlock device (%p)!\n", device); 
     276        } 
     277    } 
     278 
     279    delete dev->processorManager; 
     280    delete dev->m_deviceManager; 
     281    delete dev; 
     282 
     283    return; 
     284} 
     285 
     286int ffado_streaming_start(ffado_device_t *dev) { 
     287    unsigned int i=0; 
     288    debugOutput(DEBUG_LEVEL_VERBOSE,"------------- Start -------------\n"); 
     289 
     290    // create the connections for all devices 
     291    // iterate over the found devices 
     292    // add the stream processors of the devices to the managers 
     293    for(i=0;i<dev->m_deviceManager->getAvDeviceCount();i++) { 
     294        FFADODevice *device=dev->m_deviceManager->getAvDeviceByIndex(i); 
     295        assert(device); 
     296 
     297        int j=0; 
     298        for(j=0; j<device->getStreamCount();j++) { 
     299        debugOutput(DEBUG_LEVEL_VERBOSE,"Starting stream %d of device %d\n",j,i); 
     300            // start the stream 
     301            if (!device->startStreamByIndex(j)) { 
     302                debugWarning("Could not start stream %d of device %d\n",j,i); 
     303                continue; 
     304            } 
     305        } 
     306 
     307        if (!device->enableStreaming()) { 
     308            debugWarning("Could not enable streaming on device %d!\n",i); 
     309        } 
     310    } 
     311 
     312    if(dev->processorManager->start()) { 
     313        return 0; 
     314    } else { 
     315        ffado_streaming_stop(dev); 
     316        return -1; 
     317    } 
     318} 
     319 
     320int ffado_streaming_stop(ffado_device_t *dev) { 
     321    unsigned int i; 
     322    debugOutput(DEBUG_LEVEL_VERBOSE,"------------- Stop -------------\n"); 
     323 
     324    dev->processorManager->stop(); 
     325 
     326    // create the connections for all devices 
     327    // iterate over the found devices 
     328    // add the stream processors of the devices to the managers 
     329    for(i=0;i<dev->m_deviceManager->getAvDeviceCount();i++) { 
     330        FFADODevice *device=dev->m_deviceManager->getAvDeviceByIndex(i); 
     331        assert(device); 
     332 
     333        if (!device->disableStreaming()) { 
     334            debugWarning("Could not disable streaming on device %d!\n",i); 
     335        } 
     336 
     337        int j=0; 
     338        for(j=0; j<device->getStreamCount();j++) { 
     339            debugOutput(DEBUG_LEVEL_VERBOSE,"Stopping stream %d of device %d\n",j,i); 
     340            // stop the stream 
     341            // start the stream 
     342            if (!device->stopStreamByIndex(j)) { 
     343                debugWarning("Could not stop stream %d of device %d\n",j,i); 
     344                continue; 
     345            } 
     346        } 
     347    } 
     348 
     349    return 0; 
     350} 
     351 
     352int ffado_streaming_reset(ffado_device_t *dev) { 
     353    debugOutput(DEBUG_LEVEL_VERBOSE,"------------- Reset -------------\n"); 
     354 
     355    // dev->processorManager->reset(); 
     356 
     357    return 0; 
     358} 
     359 
     360int ffado_streaming_wait(ffado_device_t *dev) { 
     361    static int periods=0; 
     362    static int periods_print=0; 
     363    static int xruns=0; 
     364 
     365    periods++; 
     366    if(periods>periods_print) { 
     367        debugOutputShort(DEBUG_LEVEL_VERBOSE, "\nffado_streaming_wait\n"); 
     368        debugOutputShort(DEBUG_LEVEL_VERBOSE, "============================================\n"); 
     369        debugOutputShort(DEBUG_LEVEL_VERBOSE, "Xruns: %d\n",xruns); 
     370        debugOutputShort(DEBUG_LEVEL_VERBOSE, "============================================\n"); 
     371        dev->processorManager->dumpInfo(); 
     372        debugOutputShort(DEBUG_LEVEL_VERBOSE, "\n"); 
     373        periods_print+=100; 
     374    } 
     375 
     376    if(dev->processorManager->waitForPeriod()) { 
     377        return dev->options.period_size; 
     378    } else { 
     379        debugWarning("XRUN detected\n"); 
     380 
     381        // do xrun recovery 
     382        dev->processorManager->handleXrun(); 
     383        xruns++; 
     384        return -1; 
     385    } 
     386} 
     387 
     388int ffado_streaming_transfer_capture_buffers(ffado_device_t *dev) { 
     389    return dev->processorManager->transfer(StreamProcessor::ePT_Receive); 
     390} 
     391 
     392int ffado_streaming_transfer_playback_buffers(ffado_device_t *dev) { 
     393    return dev->processorManager->transfer(StreamProcessor::ePT_Transmit); 
     394} 
     395 
     396int ffado_streaming_transfer_buffers(ffado_device_t *dev) { 
     397    return dev->processorManager->transfer(); 
     398} 
     399 
     400 
     401int ffado_streaming_write(ffado_device_t *dev, int i, ffado_sample_t *buffer, int nsamples) { 
     402    Port *p=dev->processorManager->getPortByIndex(i, Port::E_Playback); 
     403    // use an assert here performancewise, 
     404    // it should already have failed before, if not correct 
     405    assert(p); 
     406 
     407    return p->writeEvents((void *)buffer, nsamples); 
     408} 
     409 
     410int ffado_streaming_read(ffado_device_t *dev, int i, ffado_sample_t *buffer, int nsamples) { 
     411    Port *p=dev->processorManager->getPortByIndex(i, Port::E_Capture); 
     412    // use an assert here performancewise, 
     413    // it should already have failed before, if not correct 
     414    assert(p); 
     415 
     416    return p->readEvents((void *)buffer, nsamples); 
     417} 
     418 
     419int ffado_streaming_get_nb_capture_streams(ffado_device_t *dev) { 
     420    return dev->processorManager->getPortCount(Port::E_Capture); 
     421} 
     422 
     423int ffado_streaming_get_nb_playback_streams(ffado_device_t *dev) { 
     424    return dev->processorManager->getPortCount(Port::E_Playback); 
     425} 
     426 
     427int ffado_streaming_get_capture_stream_name(ffado_device_t *dev, int i, char* buffer, size_t buffersize) { 
     428    Port *p=dev->processorManager->getPortByIndex(i, Port::E_Capture); 
     429    if(!p) { 
     430        debugWarning("Could not get capture port at index %d\n",i); 
     431        return -1; 
     432    } 
     433 
     434    std::string name=p->getName(); 
     435    if (!strncpy(buffer, name.c_str(), buffersize)) { 
     436        debugWarning("Could not copy name\n"); 
     437        return -1; 
     438    } else return 0; 
     439} 
     440 
     441int ffado_streaming_get_playback_stream_name(ffado_device_t *dev, int i, char* buffer, size_t buffersize) { 
     442    Port *p=dev->processorManager->getPortByIndex(i, Port::E_Playback); 
     443    if(!p) { 
     444        debugWarning("Could not get playback port at index %d\n",i); 
     445        return -1; 
     446    } 
     447 
     448    std::string name=p->getName(); 
     449    if (!strncpy(buffer, name.c_str(), buffersize)) { 
     450        debugWarning("Could not copy name\n"); 
     451        return -1; 
     452    } else return 0; 
     453} 
     454 
     455ffado_streaming_stream_type ffado_streaming_get_capture_stream_type(ffado_device_t *dev, int i) { 
     456    Port *p=dev->processorManager->getPortByIndex(i, Port::E_Capture); 
     457    if(!p) { 
     458        debugWarning("Could not get capture port at index %d\n",i); 
     459        return ffado_stream_type_invalid; 
     460    } 
     461    switch(p->getPortType()) { 
     462    case Port::E_Audio: 
     463        return ffado_stream_type_audio; 
     464    case Port::E_Midi: 
     465        return ffado_stream_type_midi; 
     466    case Port::E_Control: 
     467        return ffado_stream_type_control; 
     468    default: 
     469        return ffado_stream_type_unknown; 
     470    } 
     471} 
     472 
     473ffado_streaming_stream_type ffado_streaming_get_playback_stream_type(ffado_device_t *dev, int i) { 
     474    Port *p=dev->processorManager->getPortByIndex(i, Port::E_Playback); 
     475    if(!p) { 
     476        debugWarning("Could not get playback port at index %d\n",i); 
     477        return ffado_stream_type_invalid; 
     478    } 
     479    switch(p->getPortType()) { 
     480    case Port::E_Audio: 
     481        return ffado_stream_type_audio; 
     482    case Port::E_Midi: 
     483        return ffado_stream_type_midi; 
     484    case Port::E_Control: 
     485        return ffado_stream_type_control; 
     486    default: 
     487        return ffado_stream_type_unknown; 
     488    } 
     489} 
     490 
     491int ffado_streaming_set_stream_buffer_type(ffado_device_t *dev, int i, 
     492    ffado_streaming_buffer_type t, enum Port::E_Direction direction) { 
     493 
     494    Port *p=dev->processorManager->getPortByIndex(i, direction); 
     495    if(!p) { 
     496        debugWarning("Could not get %s port at index %d\n", 
     497            (direction==Port::E_Playback?"Playback":"Capture"),i); 
     498        return -1; 
     499    } 
     500 
     501    switch(t) { 
     502    case ffado_buffer_type_int24: 
     503        if (!p->setDataType(Port::E_Int24)) { 
     504            debugWarning("%s: Could not set data type to Int24\n",p->getName().c_str()); 
     505            return -1; 
     506        } 
     507        if (!p->setBufferType(Port::E_PointerBuffer)) { 
     508            debugWarning("%s: Could not set buffer type to Pointerbuffer\n",p->getName().c_str()); 
     509            return -1; 
     510        } 
     511        break; 
     512    case ffado_buffer_type_float: 
     513        if (!p->setDataType(Port::E_Float)) { 
     514            debugWarning("%s: Could not set data type to Float\n",p->getName().c_str()); 
     515            return -1; 
     516        } 
     517        if (!p->setBufferType(Port::E_PointerBuffer)) { 
     518            debugWarning("%s: Could not set buffer type to Pointerbuffer\n",p->getName().c_str()); 
     519            return -1; 
     520        } 
     521        break; 
     522    case ffado_buffer_type_midi: 
     523        if (!p->setDataType(Port::E_MidiEvent)) { 
     524            debugWarning("%s: Could not set data type to MidiEvent\n",p->getName().c_str()); 
     525            return -1; 
     526        } 
     527        if (!p->setBufferType(Port::E_RingBuffer)) { 
     528            debugWarning("%s: Could not set buffer type to Ringbuffer\n",p->getName().c_str()); 
     529            return -1; 
     530        } 
     531        break; 
     532    default: 
     533        debugWarning("%s: Unsupported buffer type\n",p->getName().c_str()); 
     534        return -1; 
     535    } 
     536    return 0; 
     537 
     538} 
     539 
     540int ffado_streaming_set_playback_buffer_type(ffado_device_t *dev, int i, ffado_streaming_buffer_type t) { 
     541    return ffado_streaming_set_stream_buffer_type(dev, i, t, Port::E_Playback); 
     542} 
     543 
     544int ffado_streaming_set_capture_buffer_type(ffado_device_t *dev, int i, ffado_streaming_buffer_type t) { 
     545    return ffado_streaming_set_stream_buffer_type(dev, i, t, Port::E_Capture); 
     546} 
     547 
     548int ffado_streaming_stream_onoff(ffado_device_t *dev, int i, 
     549    int on, enum Port::E_Direction direction) { 
     550    Port *p=dev->processorManager->getPortByIndex(i, direction); 
     551    if(!p) { 
     552        debugWarning("Could not get %s port at index %d\n", 
     553            (direction==Port::E_Playback?"Playback":"Capture"),i); 
     554        return -1; 
     555    } 
     556    if(on) { 
     557        p->enable(); 
     558    } else { 
     559        p->disable(); 
     560    } 
     561    return 0; 
     562} 
     563 
     564int ffado_streaming_playback_stream_onoff(ffado_device_t *dev, int number, int on) { 
     565    return ffado_streaming_stream_onoff(dev, number, on, Port::E_Playback); 
     566} 
     567 
     568int ffado_streaming_capture_stream_onoff(ffado_device_t *dev, int number, int on) { 
     569    return ffado_streaming_stream_onoff(dev, number, on, Port::E_Capture); 
     570} 
     571 
     572// TODO: the way port buffers are set in the C api doesn't satisfy me 
     573int ffado_streaming_set_capture_stream_buffer(ffado_device_t *dev, int i, char *buff) { 
     574        Port *p=dev->processorManager->getPortByIndex(i, Port::E_Capture); 
     575 
     576        // use an assert here performancewise, 
     577        // it should already have failed before, if not correct 
     578        assert(p); 
     579 
     580        p->useExternalBuffer(true); 
     581        p->setExternalBufferAddress((void *)buff); 
     582 
     583        return 0; 
     584 
     585} 
     586 
     587int ffado_streaming_set_playback_stream_buffer(ffado_device_t *dev, int i, char *buff) { 
     588        Port *p=dev->processorManager->getPortByIndex(i, Port::E_Playback); 
     589        // use an assert here performancewise, 
     590        // it should already have failed before, if not correct 
     591        assert(p); 
     592 
     593        p->useExternalBuffer(true); 
     594        p->setExternalBufferAddress((void *)buff); 
     595 
     596        return 0; 
     597} 
  • trunk/libffado/src/ffadodevice.cpp

    r734 r739  
    3333#include <assert.h> 
    3434 
    35 IMPL_DEBUG_MODULE( FFADODevice, FFADODevice, DEBUG_LEVEL_VERBOSE ); 
     35IMPL_DEBUG_MODULE( FFADODevice, FFADODevice, DEBUG_LEVEL_NORMAL ); 
    3636 
    37 FFADODevice::FFADODevice( Ieee1394Service& ieee1394Service, 
    38                           std::auto_ptr<ConfigRom>( configRom )) 
     37FFADODevice::FFADODevice( std::auto_ptr<ConfigRom>( configRom )) 
    3938    : Control::Container() 
    4039    , m_pConfigRom( configRom ) 
    41     , m_p1394Service( &ieee1394Service ) 
    4240{ 
    4341    addOption(Util::OptionContainer::Option("id",std::string("dev?"))); 
     
    5957 
    6058FFADODevice * 
    61 FFADODevice::createDevice( Ieee1394Service& , 
    62                            std::auto_ptr<ConfigRom>( x )) 
     59FFADODevice::createDevice(std::auto_ptr<ConfigRom>( x )) 
    6360{ 
    6461    // re-implement this!! 
     
    8986{ 
    9087    return *m_pConfigRom; 
     88} 
     89 
     90Ieee1394Service& 
     91FFADODevice::get1394Service() 
     92{ 
     93    return getConfigRom().get1394Service(); 
    9194} 
    9295 
     
    144147FFADODevice::showDevice() 
    145148{ 
    146     debugOutput(DEBUG_LEVEL_NORMAL, "Node...........: %d\n", getNodeId()); 
    147     debugOutput(DEBUG_LEVEL_NORMAL, "GUID...........: %s\n", getConfigRom().getGuidString().c_str()); 
    148      
     149    Ieee1394Service& s = getConfigRom().get1394Service(); 
     150    debugOutput(DEBUG_LEVEL_NORMAL, "Attached to port.......: %d (%s)\n", 
     151                                    s.getPort(), s.getPortName().c_str()); 
     152    debugOutput(DEBUG_LEVEL_NORMAL, "Node...................: %d\n", getNodeId()); 
     153    debugOutput(DEBUG_LEVEL_NORMAL, "GUID...................: %s\n", 
     154                                    getConfigRom().getGuidString().c_str()); 
     155 
    149156    std::string id=std::string("dev? [none]"); 
    150157    getOption("id", id); 
    151       
     158 
    152159    debugOutput(DEBUG_LEVEL_NORMAL, "Assigned ID....: %s\n", id.c_str()); 
    153160 
  • trunk/libffado/src/ffadodevice.h

    r674 r739  
    5353{ 
    5454public: 
    55     FFADODevice( Ieee1394Service& ieee1394service, 
    56                  std::auto_ptr< ConfigRom >( configRom ) ); 
     55    FFADODevice( std::auto_ptr< ConfigRom >( configRom ) ); 
    5756 
    5857    virtual ~FFADODevice(); 
    5958 
    60      
    6159    /** 
    6260     * @brief Compares the GUID of two FFADODevices 
     
    7674 
    7775    /// Returns the 1394 service of the FFADO device 
    78     virtual Ieee1394Service& get1394Service() 
    79         { return *m_p1394Service; }; 
     76    virtual Ieee1394Service& get1394Service(); 
    8077    /// Returns the ConfigRom object of the device node. 
    8178    virtual ConfigRom& getConfigRom() const; 
    82      
     79 
    8380    /** 
    8481     * @brief Called by DeviceManager to load device model from cache. 
     
    114111     * @return a new instance of the AvDevice type, NULL when unsuccessful 
    115112     */ 
    116     static FFADODevice * createDevice( Ieee1394Service& , 
    117                                         std::auto_ptr<ConfigRom>( x )); 
     113    static FFADODevice * createDevice( std::auto_ptr<ConfigRom>( x )); 
    118114 
    119115    /** 
     
    417413 
    418414 
     415private: 
     416    std::auto_ptr<ConfigRom>( m_pConfigRom ); 
    419417protected: 
    420     std::auto_ptr<ConfigRom>( m_pConfigRom ); 
    421     Ieee1394Service*          m_p1394Service; 
    422  
    423418    DECLARE_DEBUG_MODULE; 
    424419}; 
  • trunk/libffado/src/fireworks/audiofire/audiofire_device.cpp

    r587 r739  
    3030namespace ECHO { 
    3131 
    32 AudioFire::AudioFire( Ieee1394Service& ieee1394Service, 
    33                             std::auto_ptr<ConfigRom>( configRom )) 
    34     : FireWorks::Device( ieee1394Service, configRom) 
     32AudioFire::AudioFire(std::auto_ptr<ConfigRom>( configRom )) 
     33    : FireWorks::Device(configRom) 
    3534{ 
    3635    debugOutput( DEBUG_LEVEL_VERBOSE, "Created FireWorks::ECHO::AudioFire (NodeID %d)\n", 
  • trunk/libffado/src/fireworks/audiofire/audiofire_device.h

    r639 r739  
    3535 
    3636public: 
    37     AudioFire( Ieee1394Service& ieee1394Service, 
    38                std::auto_ptr<ConfigRom>( configRom )); 
     37    AudioFire(std::auto_ptr<ConfigRom>( configRom )); 
    3938    virtual ~AudioFire(); 
    4039 
  • trunk/libffado/src/fireworks/efc/efc_cmd.cpp

    r687 r739  
    177177} 
    178178 
     179void 
     180EfcCmd::setVerboseLevel(int l) 
     181{ 
     182    setDebugLevel(l); 
     183} 
     184 
    179185} // namespace FireWorks 
  • trunk/libffado/src/fireworks/efc/efc_cmd.h

    r687 r739  
    219219 
    220220    virtual void showEfcCmd(); 
     221    virtual void setVerboseLevel(int l); 
    221222 
    222223    uint32_t            m_length; // in quadlets, including length field and header. 
  • trunk/libffado/src/fireworks/fireworks_device.cpp

    r689 r739  
    4343namespace FireWorks { 
    4444 
    45 Device::Device( Ieee1394Service& ieee1394Service, 
    46                             std::auto_ptr<ConfigRom>( configRom )) 
    47     : GenericAVC::AvDevice( ieee1394Service, configRom) 
     45Device::Device(std::auto_ptr<ConfigRom>( configRom )) 
     46    : GenericAVC::AvDevice(configRom) 
    4847    , m_efc_discovery_done ( false ) 
    4948    , m_MixerContainer ( NULL ) 
     
    9190Device::discover() 
    9291{ 
    93     unsigned int vendorId = m_pConfigRom->getNodeVendorId(); 
    94     unsigned int modelId = m_pConfigRom->getModelId(); 
     92    unsigned int vendorId = getConfigRom().getNodeVendorId(); 
     93    unsigned int modelId = getConfigRom().getModelId(); 
    9594 
    9695    GenericAVC::VendorModel vendorModel( SHAREDIR "/ffado_driver_fireworks.txt" ); 
     
    128127{ 
    129128    m_efc_discovery_done = false; 
     129    m_HwInfo.setVerboseLevel(getDebugLevel()); 
    130130 
    131131    if (!doEfcOverAVC(m_HwInfo)) { 
     
    148148 
    149149FFADODevice * 
    150 Device::createDevice( Ieee1394Service& ieee1394Service, 
    151                       std::auto_ptr<ConfigRom>( configRom )) 
     150Device::createDevice(std::auto_ptr<ConfigRom>( configRom )) 
    152151{ 
    153152    unsigned int vendorId = configRom->getNodeVendorId(); 
     
    155154 
    156155    switch(vendorId) { 
    157         case FW_VENDORID_ECHO: return new ECHO::AudioFire(ieee1394Service, configRom ); 
    158         default: return new Device(ieee1394Service, configRom ); 
     156        case FW_VENDORID_ECHO: return new ECHO::AudioFire(configRom ); 
     157        default: return new Device(configRom ); 
    159158    } 
    160159} 
     
    169168 
    170169    cmd.setVerbose( getDebugLevel() ); 
    171 //     cmd.setVerbose( DEBUG_LEVEL_VERY_VERBOSE ); 
    172  
    173170    cmd.m_cmd = &c; 
    174  
    175 //     c.showEfcCmd(); 
    176171 
    177172    if ( !cmd.fire()) { 
     
    180175        return false; 
    181176    } 
    182 //     c.showEfcCmd(); 
    183177 
    184178    if ( cmd.getResponse() != AVC::AVCCommand::eR_Accepted) { 
  • trunk/libffado/src/fireworks/fireworks_device.h

    r664 r739  
    4242class Device : public GenericAVC::AvDevice { 
    4343public: 
    44     Device( Ieee1394Service& ieee1394Service, 
    45               std::auto_ptr<ConfigRom>( configRom )); 
     44    Device(std::auto_ptr<ConfigRom>( configRom )); 
    4645    virtual ~Device(); 
    4746     
    4847    static bool probe( ConfigRom& configRom ); 
    49     static FFADODevice * createDevice( Ieee1394Service& ieee1394Service, 
    50                                         std::auto_ptr<ConfigRom>( configRom )); 
     48    static FFADODevice * createDevice( std::auto_ptr<ConfigRom>( configRom )); 
    5149    virtual bool discover(); 
    5250 
  • trunk/libffado/src/genericavc/avc_avdevice.cpp

    r736 r739  
    4949namespace GenericAVC { 
    5050 
    51 IMPL_DEBUG_MODULE( AvDevice, AvDevice, DEBUG_LEVEL_VERBOSE ); 
    52  
    53  
    54 AvDevice::AvDevice( Ieee1394Service& ieee1394Service, 
    55                     std::auto_ptr<ConfigRom>( configRom )) 
    56     : FFADODevice( ieee1394Service, configRom ) 
     51IMPL_DEBUG_MODULE( AvDevice, AvDevice, DEBUG_LEVEL_NORMAL ); 
     52 
     53AvDevice::AvDevice(std::auto_ptr<ConfigRom>( configRom )) 
     54    : FFADODevice( configRom ) 
    5755{ 
    5856    debugOutput( DEBUG_LEVEL_VERBOSE, "Created GenericAVC::AvDevice (NodeID %d)\n", 
     
    6159} 
    6260 
    63 AvDevice::~AvDevice() 
    64 { 
    65  
    66 } 
    67  
    6861bool 
    6962AvDevice::probe( ConfigRom& configRom ) 
     
    8174 
    8275FFADODevice * 
    83 AvDevice::createDevice( Ieee1394Service& ieee1394Service, 
    84                         std::auto_ptr<ConfigRom>( configRom )) 
    85 
    86     return new AvDevice(ieee1394Service, configRom ); 
     76AvDevice::createDevice(std::auto_ptr<ConfigRom>( configRom )) 
     77
     78    return new AvDevice(configRom ); 
    8779} 
    8880 
     
    9385    // e.g. because a subclass called this function 
    9486    if (!GenericAVC::VendorModel::isValid(m_model)) { 
    95         unsigned int vendorId = m_pConfigRom->getNodeVendorId(); 
    96         unsigned int modelId = m_pConfigRom->getModelId(); 
     87        unsigned int vendorId = getConfigRom().getNodeVendorId(); 
     88        unsigned int modelId = getConfigRom().getModelId(); 
    9789 
    9890        GenericAVC::VendorModel vendorModel( SHAREDIR "/ffado_driver_genericavc.txt" ); 
     
    128120AvDevice::setVerboseLevel(int l) 
    129121{ 
    130     debugOutput( DEBUG_LEVEL_VERBOSE, "Setting verbose level to %d...\n", l ); 
    131  
     122    setDebugLevel(l); 
    132123    m_pPlugManager->setVerboseLevel(l); 
    133  
    134124    FFADODevice::setVerboseLevel(l); 
    135125    AVC::Unit::setVerboseLevel(l); 
     126    debugOutput( DEBUG_LEVEL_VERBOSE, "Setting verbose level to %d...\n", l ); 
    136127} 
    137128 
     
    628619            if (iec61883_get_oPCRX( 
    629620                    get1394Service().getHandle(), 
    630                     m_pConfigRom->getNodeId() | 0xffc0, 
     621                    getConfigRom().getNodeId() | 0xffc0, 
    631622                    (quadlet_t *)&opcr, 
    632623                    n)) { 
     
    639630        } else { 
    640631            iso_channel=get1394Service().allocateIsoChannelCMP( 
    641                 m_pConfigRom->getNodeId() | 0xffc0, n, 
     632                getConfigRom().getNodeId() | 0xffc0, n, 
    642633                get1394Service().getLocalNodeId()| 0xffc0, -1); 
    643634        } 
     
    662653            if (iec61883_get_iPCRX( 
    663654                    get1394Service().getHandle(), 
    664                     m_pConfigRom->getNodeId() | 0xffc0, 
     655                    getConfigRom().getNodeId() | 0xffc0, 
    665656                    (quadlet_t *)&ipcr, 
    666657                    n)) { 
     
    675666            iso_channel=get1394Service().allocateIsoChannelCMP( 
    676667                get1394Service().getLocalNodeId()| 0xffc0, -1, 
    677                 m_pConfigRom->getNodeId() | 0xffc0, n); 
     668                getConfigRom().getNodeId() | 0xffc0, n); 
    678669        } 
    679670 
  • trunk/libffado/src/genericavc/avc_avdevice.h

    r734 r739  
    4848class AvDevice : public FFADODevice, public AVC::Unit { 
    4949public: 
    50     AvDevice( Ieee1394Service& ieee1394Service, 
    51               std::auto_ptr<ConfigRom>( configRom )); 
    52     virtual ~AvDevice(); 
     50    AvDevice( std::auto_ptr<ConfigRom>( configRom )); 
     51    virtual ~AvDevice() {}; 
    5352 
    5453    static bool probe( ConfigRom& configRom ); 
    5554    virtual bool discover(); 
    56     static FFADODevice * createDevice( Ieee1394Service& ieee1394Service, 
    57                                        std::auto_ptr<ConfigRom>( configRom )); 
     55    static FFADODevice * createDevice( std::auto_ptr<ConfigRom>( configRom )); 
    5856 
    5957    virtual bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const; 
  • trunk/libffado/src/libieee1394/configrom.cpp

    r736 r739  
    6262ConfigRom::ConfigRom( Ieee1394Service& ieee1394service, fb_nodeid_t nodeId ) 
    6363    : Control::Element("ConfigRom") 
    64     , m_1394Service( &ieee1394service ) 
     64    , m_1394Service( ieee1394service ) 
    6565    , m_nodeId( nodeId ) 
    6666    , m_avcDevice( false ) // FIXME: this does not seem veryu 
     
    8989ConfigRom::ConfigRom() 
    9090    : Control::Element("ConfigRom") 
    91     , m_1394Service( 0
     91    , m_1394Service( *(new Ieee1394Service())
    9292    , m_nodeId( -1 ) 
    9393    , m_avcDevice( false ) // FIXME: this does not seem veryu 
     
    114114} 
    115115 
    116 ConfigRom::~ConfigRom() 
    117 
     116Ieee1394Service& 
     117ConfigRom::get1394Service() 
     118
     119    return m_1394Service; 
    118120} 
    119121 
     
    133135{ 
    134136     struct config_csr_info csr_info; 
    135      csr_info.service = m_1394Service; 
     137     csr_info.service = &m_1394Service; 
    136138     csr_info.nodeId = 0xffc0 | m_nodeId; 
    137139 
     
    140142                                 &csr_info ); 
    141143    if (!m_csr || csr1212_parse_csr( m_csr ) != CSR1212_SUCCESS) { 
    142         debugError( "Could not parse config rom of node %d on port %d\n", m_nodeId, m_1394Service->getPort() ); 
     144        debugError( "Could not parse config rom of node %d on port %d\n", m_nodeId, m_1394Service.getPort() ); 
    143145        if (m_csr) { 
    144146            csr1212_destroy_csr(m_csr); 
     
    451453    struct csr1212_csr* csr = NULL; 
    452454    for ( fb_nodeid_t nodeId = 0; 
    453           nodeId < m_1394Service->getNodeCount(); 
     455          nodeId < m_1394Service.getNodeCount(); 
    454456          ++nodeId ) 
    455457    { 
    456458        struct config_csr_info csr_info; 
    457         csr_info.service = m_1394Service; 
     459        csr_info.service = &m_1394Service; 
    458460        csr_info.nodeId = 0xffc0 | nodeId; 
    459461        debugOutput( DEBUG_LEVEL_VERBOSE, "Looking at node %d...\n", nodeId); 
     
    577579    } 
    578580 
    579     pConfigRom->m_1394Service = &ieee1394Service; 
     581    pConfigRom->m_1394Service = ieee1394Service; 
    580582 
    581583    bool result; 
  • trunk/libffado/src/libieee1394/configrom.h

    r673 r739  
    4444 public: 
    4545    ConfigRom( Ieee1394Service& ieee1394service, fb_nodeid_t nodeId ); 
    46     virtual ~ConfigRom(); 
     46    virtual ~ConfigRom() {}; 
     47 
     48    Ieee1394Service& get1394Service(); 
    4749 
    4850    bool initialize(); 
     
    98100    static bool compareGUID(  const ConfigRom& a, const ConfigRom& b ); 
    99101 
    100     void printConfigRom() const; 
    101  
    102102    bool serialize( Glib::ustring path, Util::IOSerialize& ser ); 
    103103    static ConfigRom* deserialize( Glib::ustring path, 
     
    105105                   Ieee1394Service& ieee1394Service ); 
    106106 
     107    void printConfigRom() const; 
    107108    void setVerboseLevel(int level) { 
    108109        setDebugLevel(level); 
     
    117118    void processRootDirectory( struct csr1212_csr* csr ); 
    118119 
    119     Ieee1394Service* m_1394Service; 
     120    Ieee1394Service& m_1394Service; 
    120121    fb_nodeid_t      m_nodeId; 
    121122    bool             m_avcDevice; 
  • trunk/libffado/src/libieee1394/ieee1394service.cpp

    r677 r739  
    3737#include <iostream> 
    3838#include <iomanip> 
     39 
     40#define FFADO_MAX_FIREWIRE_PORTS 8 
    3941 
    4042IMPL_DEBUG_MODULE( Ieee1394Service, Ieee1394Service, DEBUG_LEVEL_NORMAL ); 
     
    8385} 
    8486 
     87unsigned int 
     88Ieee1394Service::detectNbPorts( ) 
     89{ 
     90    raw1394handle_t tmp_handle = raw1394_new_handle(); 
     91    if ( tmp_handle == NULL ) { 
     92        debugError("Could not get libraw1394 handle.\n"); 
     93        return 0; 
     94    } 
     95    struct raw1394_portinfo pinf[FFADO_MAX_FIREWIRE_PORTS]; 
     96    int nb_detected_ports = raw1394_get_port_info(tmp_handle, pinf, FFADO_MAX_FIREWIRE_PORTS); 
     97    raw1394_destroy_handle(tmp_handle); 
     98 
     99    if (nb_detected_ports < 0) { 
     100        debugError("Failed to detect number of ports\n"); 
     101        return 0; 
     102    } 
     103    return nb_detected_ports; 
     104} 
     105 
    85106bool 
    86107Ieee1394Service::initialize( int port ) 
     
    113134 
    114135    m_port = port; 
     136 
     137    // obtain port name 
     138    struct raw1394_portinfo pinf[FFADO_MAX_FIREWIRE_PORTS]; 
     139    int nb_detected_ports = raw1394_get_port_info(m_handle, pinf, FFADO_MAX_FIREWIRE_PORTS); 
     140 
     141    if(nb_detected_ports && port < FFADO_MAX_FIREWIRE_PORTS) { 
     142        m_portName = pinf[port].name; 
     143    } else { 
     144        m_portName = "Unknown"; 
     145    } 
     146    if (m_portName == "") { 
     147        m_portName = "Unknown"; 
     148    } 
    115149 
    116150    raw1394_set_userdata( m_handle, this ); 
     
    840874    setDebugLevel(l); 
    841875} 
     876 
     877void 
     878Ieee1394Service::show() 
     879{ 
     880    debugOutput( DEBUG_LEVEL_VERBOSE, "Port:  %d\n", getPort() ); 
     881    debugOutput( DEBUG_LEVEL_VERBOSE, " Name: %s\n", getPortName().c_str() ); 
     882} 
  • trunk/libffado/src/libieee1394/ieee1394service.h

    r677 r739  
    3737 
    3838#include <vector> 
     39#include <string> 
    3940 
    4041class ARMHandler; 
     
    4748    bool initialize( int port ); 
    4849 
     50   /** 
     51    * @brief get number of ports (firewire adapters) in this machine 
     52    * 
     53    * @return the number of ports 
     54    */ 
     55    static unsigned int detectNbPorts(); 
     56 
     57   /** 
     58    * @brief get port (adapter) id 
     59    * 
     60    * @return get port (adapter) id 
     61    */ 
    4962    int getPort() 
    50     { return m_port; } 
     63        { return m_port; } 
     64 
     65   /** 
     66    * @brief get port (adapter) name 
     67    * 
     68    * @return get port (adapter) name 
     69    */ 
     70    std::string getPortName() 
     71        { return m_portName; }; 
     72 
    5173   /** 
    5274    * @brief get number of nodes on the bus 
     
    238260    raw1394handle_t m_resetHandle; 
    239261    int             m_port; 
     262    std::string     m_portName; 
    240263 
    241264    pthread_t       m_thread; 
     
    256279public: 
    257280    void setVerboseLevel(int l); 
     281    void show(); 
    258282private: 
    259283    DECLARE_DEBUG_MODULE; 
  • trunk/libffado/src/libstreaming/util/IsoHandlerManager.cpp

    r729 r739  
    6969 
    7070    // propagate the debug level 
    71 //     m_isoManagerThread->setVerboseLevel(getDebugLevel()); 
     71    m_isoManagerThread->setVerboseLevel(getDebugLevel()); 
    7272 
    7373    return true; 
     
    705705    setDebugLevel(i); 
    706706 
     707    // propagate the debug level 
     708    if(m_isoManagerThread) { 
     709        m_isoManagerThread->setVerboseLevel(getDebugLevel()); 
     710    } 
     711 
    707712    for ( IsoHandlerVectorIterator it = m_IsoHandlers.begin(); 
    708713          it != m_IsoHandlers.end(); 
  • trunk/libffado/src/libutil/Thread.h

    r445 r739  
    8888        virtual pthread_t GetThreadID() = 0; 
    8989 
     90        virtual void setVerboseLevel(int l) 
     91            {setDebugLevel(l);}; 
    9092    protected: 
    9193            DECLARE_DEBUG_MODULE; 
  • trunk/libffado/src/maudio/maudio_avdevice.cpp

    r587 r739  
    4040namespace MAudio { 
    4141 
    42 AvDevice::AvDevice( Ieee1394Service& ieee1394Service, 
    43                     std::auto_ptr<ConfigRom>( configRom )) 
    44     : BeBoB::AvDevice( ieee1394Service, configRom) 
     42AvDevice::AvDevice(std::auto_ptr<ConfigRom>( configRom )) 
     43    : BeBoB::AvDevice( configRom) 
    4544    , m_model ( NULL ) 
    4645{ 
     
    8281 
    8382FFADODevice * 
    84 AvDevice::createDevice( Ieee1394Service& ieee1394Service, 
    85                         std::auto_ptr<ConfigRom>( configRom )) 
     83AvDevice::createDevice(std::auto_ptr<ConfigRom>( configRom )) 
    8684{ 
    87     return new AvDevice(ieee1394Service, configRom ); 
     85    return new AvDevice(configRom ); 
    8886} 
    8987 
     
    9189AvDevice::discover() 
    9290{ 
    93     unsigned int vendorId = m_pConfigRom->getNodeVendorId(); 
    94     unsigned int modelId = m_pConfigRom->getModelId(); 
     91    unsigned int vendorId = getConfigRom().getNodeVendorId(); 
     92    unsigned int modelId = getConfigRom().getModelId(); 
    9593 
    9694    for ( unsigned int i = 0; 
  • trunk/libffado/src/maudio/maudio_avdevice.h

    r734 r739  
    5454class AvDevice : public BeBoB::AvDevice { 
    5555public: 
    56     AvDevice( Ieee1394Service& ieee1394Service, 
    57               std::auto_ptr<ConfigRom>( configRom )); 
     56    AvDevice(std::auto_ptr<ConfigRom>( configRom )); 
    5857    virtual ~AvDevice(); 
    5958 
    6059    static bool probe( ConfigRom& configRom ); 
    61     static FFADODevice * createDevice( Ieee1394Service& ieee1394Service, 
    62                                         std::auto_ptr<ConfigRom>( configRom )); 
     60    static FFADODevice * createDevice(std::auto_ptr<ConfigRom>( configRom )); 
    6361    virtual bool discover(); 
    6462 
  • trunk/libffado/src/motu/motu_avdevice.cpp

    r734 r739  
    186186}; 
    187187 
    188 MotuDevice::MotuDevice( Ieee1394Service& ieee1394Service, 
    189                         std::auto_ptr<ConfigRom>( configRom )) 
    190     : FFADODevice( ieee1394Service, configRom ) 
     188MotuDevice::MotuDevice( std::auto_ptr<ConfigRom>( configRom )) 
     189    : FFADODevice( configRom ) 
    191190    , m_motu_model( MOTUFW_MODEL_NONE ) 
    192191    , m_iso_recv_channel ( -1 ) 
     
    206205{ 
    207206    // Free ieee1394 bus resources if they have been allocated 
    208     if (m_p1394Service != NULL) { 
    209         if (m_iso_recv_channel>=0 && !m_p1394Service->freeIsoChannel(m_iso_recv_channel)) { 
    210             debugOutput(DEBUG_LEVEL_VERBOSE, "Could not free recv iso channel %d\n", m_iso_recv_channel); 
    211         } 
    212         if (m_iso_send_channel>=0 && !m_p1394Service->freeIsoChannel(m_iso_send_channel)) { 
    213             debugOutput(DEBUG_LEVEL_VERBOSE, "Could not free send iso channel %d\n", m_iso_send_channel); 
    214         } 
     207    if (m_iso_recv_channel>=0 && !get1394Service().freeIsoChannel(m_iso_recv_channel)) { 
     208        debugOutput(DEBUG_LEVEL_VERBOSE, "Could not free recv iso channel %d\n", m_iso_recv_channel); 
     209    } 
     210    if (m_iso_send_channel>=0 && !get1394Service().freeIsoChannel(m_iso_send_channel)) { 
     211        debugOutput(DEBUG_LEVEL_VERBOSE, "Could not free send iso channel %d\n", m_iso_send_channel); 
    215212    } 
    216213} 
     
    242239 
    243240FFADODevice * 
    244 MotuDevice::createDevice( Ieee1394Service& ieee1394Service, 
    245                           std::auto_ptr<ConfigRom>( configRom )) 
    246 
    247     return new MotuDevice(ieee1394Service, configRom ); 
     241MotuDevice::createDevice(std::auto_ptr<ConfigRom>( configRom )) 
     242
     243    return new MotuDevice(configRom); 
    248244} 
    249245 
     
    251247MotuDevice::discover() 
    252248{ 
    253     unsigned int vendorId = m_pConfigRom->getNodeVendorId(); 
    254 //     unsigned int modelId = m_pConfigRom->getModelId(); 
    255     unsigned int unitVersion = m_pConfigRom->getUnitVersion(); 
    256     unsigned int unitSpecifierId = m_pConfigRom->getUnitSpecifierId(); 
     249    unsigned int vendorId = getConfigRom().getNodeVendorId(); 
     250//     unsigned int modelId = getConfigRom().getModelId(); 
     251    unsigned int unitVersion = getConfigRom().getUnitVersion(); 
     252    unsigned int unitSpecifierId = getConfigRom().getUnitSpecifierId(); 
    257253 
    258254    for ( unsigned int i = 0; 
     
    504500    // Assign iso channels if not already done 
    505501    if (m_iso_recv_channel < 0) 
    506         m_iso_recv_channel = m_p1394Service->allocateIsoChannelGeneric(m_rx_bandwidth); 
     502        m_iso_recv_channel = get1394Service().allocateIsoChannelGeneric(m_rx_bandwidth); 
    507503 
    508504    if (m_iso_send_channel < 0) 
    509         m_iso_send_channel = m_p1394Service->allocateIsoChannelGeneric(m_tx_bandwidth); 
     505        m_iso_send_channel = get1394Service().allocateIsoChannelGeneric(m_tx_bandwidth); 
    510506 
    511507    debugOutput(DEBUG_LEVEL_VERBOSE, "recv channel = %d, send channel = %d\n", 
     
    515511        // be nice and deallocate 
    516512        if (m_iso_recv_channel >= 0) 
    517             m_p1394Service->freeIsoChannel(m_iso_recv_channel); 
     513            get1394Service().freeIsoChannel(m_iso_recv_channel); 
    518514        if (m_iso_send_channel >= 0) 
    519             m_p1394Service->freeIsoChannel(m_iso_send_channel); 
     515            get1394Service().freeIsoChannel(m_iso_send_channel); 
    520516 
    521517        debugFatal("Could not allocate iso channels!\n"); 
     
    524520 
    525521    m_receiveProcessor=new Streaming::MotuReceiveStreamProcessor( 
    526         m_p1394Service->getPort(), event_size_in); 
     522        get1394Service().getPort(), event_size_in); 
    527523 
    528524    // The first thing is to initialize the processor.  This creates the 
     
    594590    // Do the same for the transmit processor 
    595591    m_transmitProcessor=new Streaming::MotuTransmitStreamProcessor( 
    596         m_p1394Service->getPort(), event_size_out); 
     592        get1394Service().getPort(), event_size_out); 
    597593 
    598594    m_transmitProcessor->setVerboseLevel(getDebugLevel()); 
     
    940936 */ 
    941937 
    942 quadlet_t quadlet; 
    943 assert(m_p1394Service); 
     938  quadlet_t quadlet; 
    944939 
    945940  quadlet = 0; 
    946941  // Note: 1394Service::read() expects a physical ID, not the node id 
    947   if (m_p1394Service->read(0xffc0 | getNodeId(), MOTUFW_BASE_ADDR+reg, 1, &quadlet) < 0) { 
     942  if (get1394Service().read(0xffc0 | getNodeId(), MOTUFW_BASE_ADDR+reg, 1, &quadlet) < 0) { 
    948943    debugError("Error doing motu read from register 0x%06x\n",reg); 
    949944  } 
     
    961956 
    962957  // Note: 1394Service::write() expects a physical ID, not the node id 
    963   if (m_p1394Service->write(0xffc0 | getNodeId(), MOTUFW_BASE_ADDR+reg, 1, &data) < 0) { 
     958  if (get1394Service().write(0xffc0 | getNodeId(), MOTUFW_BASE_ADDR+reg, 1, &data) < 0) { 
    964959    err = 1; 
    965960    debugError("Error doing motu write to register 0x%06x\n",reg); 
  • trunk/libffado/src/motu/motu_avdevice.h

    r734 r739  
    125125public: 
    126126 
    127     MotuDevice( Ieee1394Service& ieee1394Service, 
    128                 std::auto_ptr<ConfigRom>( configRom )); 
     127    MotuDevice(std::auto_ptr<ConfigRom>( configRom )); 
    129128    virtual ~MotuDevice(); 
    130129 
    131130    static bool probe( ConfigRom& configRom ); 
    132     static FFADODevice * createDevice( Ieee1394Service& ieee1394Service, 
    133                                         std::auto_ptr<ConfigRom>( configRom )); 
     131    static FFADODevice * createDevice(std::auto_ptr<ConfigRom>( configRom )); 
    134132    static int getConfigurationId( ); 
    135133    virtual bool discover(); 
  • trunk/libffado/src/SConscript

    r734 r739  
    1212        devicemanager.cpp \ 
    1313        ffado.cpp \ 
    14         ffado_streaming.cpp \ 
    1514        ffadodevice.cpp \ 
    1615        debugmodule/debugmodule.cpp \ 
  • trunk/libffado/support/dbus/ffado-dbus-server.cpp

    r730 r739  
    213213            return exitfunction(-1); 
    214214        } 
    215         if ( !m_deviceManager->initialize( arguments.port ) ) { 
     215        if ( !m_deviceManager->initialize() ) { 
    216216            debugError("Could not initialize device manager\n" ); 
    217217            delete m_deviceManager; 
  • trunk/libffado/support/firmware/fireworks-downloader.cpp

    r689 r739  
    166166    } 
    167167 
    168     Device *dev = new Device( service, std::auto_ptr<ConfigRom>(configRom) ); 
     168    Device *dev = new Device( std::auto_ptr<ConfigRom>(configRom) ); 
    169169    if (dev == NULL) { 
    170170        debugError("Could not create FireWorks::Device\n"); 
  • trunk/libffado/tests/streaming/testmidistreaming1.c

    r554 r739  
    170170        dev_options.nb_buffers=3; 
    171171 
    172         dev_options.port=0; 
    173         dev_options.node_id=-1; 
    174          
    175172        dev_options.realtime=0; 
    176173        dev_options.packetizer_priority=60; 
    177          
    178         dev_options.directions=0; 
    179174         
    180175        dev_options.verbose=5; 
     
    183178        dev_options.snoop_mode=0; 
    184179 
    185         ffado_device_t *dev=ffado_streaming_init(&device_info, dev_options); 
     180        ffado_device_t *dev=ffado_streaming_init(device_info, dev_options); 
    186181        if (!dev) { 
    187182                fprintf(stderr,"Could not init Ffado Streaming layer\n"); 
  • trunk/libffado/tests/streaming/teststreaming.c

    r554 r739  
    7979        dev_options.nb_buffers=3; 
    8080 
    81         dev_options.port=0; 
    82         dev_options.node_id=-1; 
    83          
    8481        dev_options.realtime=1; 
    8582        dev_options.packetizer_priority=60; 
    8683 
    87         dev_options.directions=0; 
    88          
    8984        dev_options.verbose=5; 
    9085         
     
    9287        dev_options.snoop_mode=0; 
    9388     
    94         ffado_device_t *dev=ffado_streaming_init(&device_info, dev_options); 
     89        ffado_device_t *dev=ffado_streaming_init(device_info, dev_options); 
    9590 
    9691        if (!dev) { 
  • trunk/libffado/tests/streaming/teststreaming2.c

    r554 r739  
    8181        dev_options.nb_buffers=3; 
    8282 
    83         dev_options.port=0; 
    84         dev_options.node_id=-1; 
    85          
    8683        dev_options.realtime=0; 
    8784        dev_options.packetizer_priority=60; 
    88          
    89         dev_options.directions=0; 
    9085         
    9186        dev_options.verbose=5; 
     
    9489        dev_options.snoop_mode=0; 
    9590 
    96         ffado_device_t *dev=ffado_streaming_init(&device_info, dev_options); 
     91        ffado_device_t *dev=ffado_streaming_init(device_info, dev_options); 
    9792        if (!dev) { 
    9893                fprintf(stderr,"Could not init Ffado Streaming layer\n"); 
  • trunk/libffado/tests/streaming/teststreaming3.c

    r554 r739  
    8585        dev_options.nb_buffers=3; 
    8686 
    87         dev_options.port=0; 
    88         dev_options.node_id=-1; 
    89  
    9087        dev_options.realtime=1; 
    9188        dev_options.packetizer_priority=70; 
    92          
    93         dev_options.directions=0; 
    9489         
    9590        dev_options.verbose=5; 
     
    9893        dev_options.snoop_mode=0; 
    9994         
    100         ffado_device_t *dev=ffado_streaming_init(&device_info, dev_options); 
     95        ffado_device_t *dev=ffado_streaming_init(device_info, dev_options); 
    10196 
    10297        if (!dev) { 
  • trunk/libffado/tests/test-ffado.cpp

    r734 r739  
    207207            m_deviceManager->setVerboseLevel(arguments.verbose); 
    208208        } 
    209         if ( !m_deviceManager->initialize( arguments.port ) ) { 
     209        if ( !m_deviceManager->initialize() ) { 
    210210            fprintf( stderr, "Could not initialize device manager\n" ); 
    211211            delete m_deviceManager; 
     
    238238            m_deviceManager->setVerboseLevel(arguments.verbose); 
    239239        } 
    240         if ( !m_deviceManager->initialize( arguments.port ) ) { 
     240        if ( !m_deviceManager->initialize() ) { 
    241241            fprintf( stderr, "Could not initialize device manager\n" ); 
    242242            delete m_deviceManager; 
     
    295295            m_deviceManager->setVerboseLevel(arguments.verbose); 
    296296        } 
    297         if ( !m_deviceManager->initialize( arguments.port ) ) { 
     297        if ( !m_deviceManager->initialize() ) { 
    298298            fprintf( stderr, "Could not initialize device manager\n" ); 
    299299            delete m_deviceManager;