Changeset 416

Show
Ignore:
Timestamp:
02/25/07 02:46:00 (16 years ago)
Author:
pieterpalmers
Message:

- Introduced a generic option mechanism. AvDevices? now automatically

inherit from OptionContainer? (via IAvDevice) and can specify options
(e.g. at construction). These can then be get/set using the container
functions from the outside.

- Modified the bebob, bounce, motu, mh, rme AvDevices? to make use of the

option system for their Id value and the 'snoopMode' option.

- Made M-Audio avdevice a subclass of the BeBoB avdevice to avoid code

duplication.

- Extended the bounce device

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/streaming-rework/src/bebob/bebob_avdevice.cpp

    r415 r416  
    7676    , m_model ( NULL ) 
    7777    , m_nodeId ( nodeId ) 
    78     , m_id( 0 ) 
    79     , m_snoopMode( false ) 
    8078{ 
    8179    setDebugLevel( verboseLevel ); 
    8280    debugOutput( DEBUG_LEVEL_VERBOSE, "Created BeBoB::AvDevice (NodeID %d)\n", 
    8381                 nodeId ); 
     82    addOption(FreebobUtil::OptionContainer::Option("snoopMode",false)); 
     83    addOption(FreebobUtil::OptionContainer::Option("id",std::string("dev?"))); 
    8484} 
    8585 
     
    9292    , m_model ( NULL ) 
    9393    , m_nodeId ( -1 ) 
    94     , m_id( 0 ) 
    95     , m_snoopMode( false ) 
    96 
     94
     95    addOption(FreebobUtil::OptionContainer::Option("snoopMode",false)); 
     96    addOption(FreebobUtil::OptionContainer::Option("id",std::string("dev?"))); 
    9797} 
    9898 
    9999AvDevice::~AvDevice() 
    100100{ 
     101 
    101102    for ( AvDeviceSubunitVector::iterator it = m_subunits.begin(); 
    102103          it != m_subunits.end(); 
     
    166167        { 
    167168            m_model = &(supportedDeviceList[i]); 
     169            break; 
    168170        } 
    169171    } 
     
    942944{ 
    943945    // FIXME: decent ID system nescessary 
    944     m_id=id; 
    945         return true; 
     946    std::ostringstream idstr; 
     947 
     948    idstr << "dev" << id; 
     949     
     950    debugOutput( DEBUG_LEVEL_VERBOSE, "Set id to %s...\n", idstr.str().c_str()); 
     951     
     952    return setOption("id",idstr.str()); 
    946953} 
    947954 
     
    961968bool 
    962969AvDevice::prepare() { 
     970    bool snoopMode=false; 
     971    if(!getOption("snoopMode", snoopMode)) { 
     972        debugWarning("Could not retrieve snoopMode parameter, defauling to false\n"); 
     973    } 
     974 
    963975    /////////// 
    964976    // get plugs 
     
    10011013 
    10021014    // do the transmit processor 
    1003     if (m_snoopMode) { 
     1015    if (snoopMode) { 
    10041016        // we are snooping, so this is receive too. 
    10051017        p=new FreebobStreaming::AmdtpReceiveStreamProcessor( 
     
    10161028    if(!p->init()) { 
    10171029        debugFatal("Could not initialize transmit processor %s!\n", 
    1018             (m_snoopMode?" in snoop mode":"")); 
     1030            (snoopMode?" in snoop mode":"")); 
    10191031        delete p; 
    10201032        return false; 
    10211033    } 
    10221034 
    1023     if (m_snoopMode) { 
     1035    if (snoopMode) { 
    10241036        if (!addPlugToProcessor(*inputPlug,p, 
    10251037            FreebobStreaming::Port::E_Capture)) { 
     
    10271039            return false; 
    10281040        } 
     1041        m_receiveProcessors.push_back(p); 
    10291042    } else { 
    10301043        if (!addPlugToProcessor(*inputPlug,p, 
     
    10331046            return false; 
    10341047        } 
     1048        m_transmitProcessors.push_back(p); 
    10351049    } 
    10361050 
     
    10431057    FreebobStreaming::StreamProcessor *processor, 
    10441058    FreebobStreaming::AmdtpAudioPort::E_Direction direction) { 
    1045  
     1059     
     1060    std::string id=std::string("dev?"); 
     1061    if(!getOption("id", id)) { 
     1062        debugWarning("Could not retrieve id parameter, defauling to 'dev?'\n"); 
     1063    } 
     1064     
    10461065    AvPlug::ClusterInfoVector& clusterInfos = plug.getClusterInfos(); 
    10471066    for ( AvPlug::ClusterInfoVector::const_iterator it = clusterInfos.begin(); 
     
    10591078            std::ostringstream portname; 
    10601079 
    1061             portname << "dev" << m_id << "_" << channelInfo->m_name; 
     1080            portname << id << "_" << channelInfo->m_name; 
    10621081 
    10631082            FreebobStreaming::Port *p=NULL; 
     
    13321351                     Util::IOSerialize& ser ) const 
    13331352{ 
     1353     
    13341354    bool result; 
    13351355    result  = m_pConfigRom->serialize( basePath + "m_pConfigRom/", ser ); 
     
    13531373    } 
    13541374 
    1355     result &= ser.write( basePath + "m_id", m_id ); 
     1375//     result &= ser.write( basePath + "m_id", id ); 
    13561376 
    13571377    return result; 
     
    13971417        } 
    13981418 
    1399         result &= deser.read( basePath + "m_id", pDev->m_id ); 
     1419//         result &= deser.read( basePath + "m_id", pDev->m_id ); 
    14001420    } 
    14011421 
  • branches/streaming-rework/src/bebob/bebob_avdevice.h

    r415 r416  
    4040 
    4141#include <sstream> 
     42#include <vector> 
    4243 
    4344class ConfigRom; 
     
    181182    struct VendorModelEntry*  m_model; 
    182183    int                       m_nodeId; 
    183     unsigned int              m_id; 
    184     bool                      m_snoopMode; 
    185184 
    186185    // streaming stuff 
  • branches/streaming-rework/src/bounce/bounce_avdevice.cpp

    r415 r416  
    5656                            int verboseLevel ) 
    5757    : m_configRom( configRom ) 
    58     , m_1394Service( &ieee1394service ) 
     58    , m_p1394Service( &ieee1394service ) 
    5959    , m_nodeId( nodeId ) 
    6060    , m_verboseLevel( verboseLevel ) 
    6161    , m_samplerate (44100) 
    6262    , m_model( NULL ) 
    63     , m_id(0) 
    64     , m_receiveProcessor ( 0 ) 
    65     , m_receiveProcessorBandwidth ( -1 ) 
    66     , m_transmitProcessor ( 0 ) 
    67     , m_transmitProcessorBandwidth ( -1 ) 
     63    , m_Notifier ( NULL ) 
    6864{ 
    6965    setDebugLevel( verboseLevel ); 
     
    7167    debugOutput( DEBUG_LEVEL_VERBOSE, "Created Bounce::BounceDevice (NodeID %d)\n", 
    7268                 nodeId ); 
     69    addOption(FreebobUtil::OptionContainer::Option("snoopMode",false)); 
     70    addOption(FreebobUtil::OptionContainer::Option("id",std::string("dev?"))); 
    7371} 
    7472 
     
    153151 
    154152        request[1] =  0xFFFFFFFF; 
    155         resp = m_1394Service->transactionBlock( m_nodeId, 
     153        resp = m_p1394Service->transactionBlock( m_nodeId, 
    156154                                                       request, 
    157155                                                       2, 
     
    181179 
    182180bool BounceDevice::setId( unsigned int id) { 
    183     debugOutput( DEBUG_LEVEL_VERBOSE, "Set id to %d...\n", id); 
    184     m_id=id; 
    185     return true; 
     181    // FIXME: decent ID system nescessary 
     182    std::ostringstream idstr; 
     183 
     184    idstr << "dev" << id; 
     185     
     186    debugOutput( DEBUG_LEVEL_VERBOSE, "Set id to %s...\n", idstr.str().c_str()); 
     187     
     188    return setOption("id",idstr.str()); 
    186189} 
    187190 
     
    225228bool 
    226229BounceDevice::addPortsToProcessor( 
    227        FreebobStreaming::StreamProcessor *processor, 
    228        FreebobStreaming::AmdtpAudioPort::E_Direction direction) { 
     230    FreebobStreaming::StreamProcessor *processor, 
     231    FreebobStreaming::Port::E_Direction direction) { 
    229232 
    230233    debugOutput(DEBUG_LEVEL_VERBOSE,"Adding ports to processor\n"); 
    231  
     234     
     235    std::string id=std::string("dev?"); 
     236    if(!getOption("id", id)) { 
     237        debugWarning("Could not retrieve id parameter, defauling to 'dev?'\n"); 
     238    } 
     239     
    232240    int i=0; 
    233241    for (i=0;i<BOUNCE_NR_OF_CHANNELS;i++) { 
    234242        char *buff; 
    235         asprintf(&buff,"dev%d%s_Port%d",m_id,direction==FreebobStreaming::AmdtpAudioPort::E_Playback?"p":"c",i); 
     243        asprintf(&buff,"%s%s_Port%d",id.c_str(),direction==FreebobStreaming::AmdtpAudioPort::E_Playback?"p":"c",i); 
    236244 
    237245        FreebobStreaming::Port *p=NULL; 
     
    269277bool 
    270278BounceDevice::prepare() { 
    271  
    272279    debugOutput(DEBUG_LEVEL_NORMAL, "Preparing BounceDevice...\n" ); 
    273  
    274         m_receiveProcessor=new FreebobStreaming::AmdtpReceiveStreamProcessor( 
    275                                  m_1394Service->getPort(), 
    276                                  m_samplerate, 
    277                                  BOUNCE_NR_OF_CHANNELS); 
    278  
    279         if(!m_receiveProcessor->init()) { 
    280                 debugFatal("Could not initialize receive processor!\n"); 
    281                 return false; 
    282  
    283         } 
    284  
    285         if (!addPortsToProcessor(m_receiveProcessor, 
    286                 FreebobStreaming::AmdtpAudioPort::E_Capture)) { 
    287                 debugFatal("Could not add ports to processor!\n"); 
    288                 return false; 
    289         } 
    290  
    291         // do the transmit processor 
    292         m_transmitProcessor=new FreebobStreaming::AmdtpTransmitStreamProcessor( 
    293                                  m_1394Service->getPort(), 
    294                                  m_samplerate, 
    295                                  BOUNCE_NR_OF_CHANNELS); 
    296  
    297         m_transmitProcessor->setVerboseLevel(getDebugLevel()); 
    298  
    299         if(!m_transmitProcessor->init()) { 
    300                 debugFatal("Could not initialize transmit processor!\n"); 
    301                 return false; 
    302  
    303         } 
    304  
    305         if (!addPortsToProcessor(m_transmitProcessor, 
    306                 FreebobStreaming::AmdtpAudioPort::E_Playback)) { 
    307                 debugFatal("Could not add ports to processor!\n"); 
    308                 return false; 
    309         } 
    310  
    311         return true; 
     280     
     281    bool snoopMode=false; 
     282    if(!getOption("snoopMode", snoopMode)) { 
     283        debugWarning("Could not retrieve snoopMode parameter, defauling to false\n"); 
     284    } 
     285 
     286    // create & add streamprocessors 
     287    FreebobStreaming::StreamProcessor *p; 
     288     
     289    p=new FreebobStreaming::AmdtpReceiveStreamProcessor( 
     290                             m_p1394Service->getPort(), 
     291                             m_samplerate, 
     292                             BOUNCE_NR_OF_CHANNELS); 
     293 
     294    if(!p->init()) { 
     295        debugFatal("Could not initialize receive processor!\n"); 
     296        delete p; 
     297        return false; 
     298    } 
     299 
     300    if (!addPortsToProcessor(p, 
     301            FreebobStreaming::Port::E_Capture)) { 
     302        debugFatal("Could not add plug to processor!\n"); 
     303        delete p; 
     304        return false; 
     305    } 
     306 
     307    m_receiveProcessors.push_back(p); 
     308 
     309    // do the transmit processor 
     310    if (snoopMode) { 
     311        // we are snooping, so this is receive too. 
     312        p=new FreebobStreaming::AmdtpReceiveStreamProcessor( 
     313                                  m_p1394Service->getPort(), 
     314                                  m_samplerate, 
     315                                  BOUNCE_NR_OF_CHANNELS); 
     316    } else { 
     317        p=new FreebobStreaming::AmdtpTransmitStreamProcessor( 
     318                                m_p1394Service->getPort(), 
     319                                m_samplerate, 
     320                                BOUNCE_NR_OF_CHANNELS); 
     321    } 
     322     
     323    if(!p->init()) { 
     324        debugFatal("Could not initialize transmit processor %s!\n", 
     325            (snoopMode?" in snoop mode":"")); 
     326        delete p; 
     327        return false; 
     328    } 
     329 
     330    if (snoopMode) { 
     331        if (!addPortsToProcessor(p, 
     332            FreebobStreaming::Port::E_Capture)) { 
     333            debugFatal("Could not add plug to processor!\n"); 
     334            delete p; 
     335            return false; 
     336        } 
     337        m_receiveProcessors.push_back(p); 
     338    } else { 
     339        if (!addPortsToProcessor(p, 
     340            FreebobStreaming::Port::E_Playback)) { 
     341            debugFatal("Could not add plug to processor!\n"); 
     342            delete p; 
     343            return false; 
     344        } 
     345        m_transmitProcessors.push_back(p); 
     346    } 
     347 
     348    return true; 
    312349} 
    313350 
    314351int 
    315352BounceDevice::getStreamCount() { 
    316        return 2; // one receive, one transmit 
     353    return m_receiveProcessors.size() + m_transmitProcessors.size(); 
    317354} 
    318355 
    319356FreebobStreaming::StreamProcessor * 
    320357BounceDevice::getStreamProcessorByIndex(int i) { 
    321         switch (i) { 
    322         case 0: 
    323                 return m_receiveProcessor; 
    324         case 1: 
    325                 return m_transmitProcessor; 
    326         default: 
    327                 return NULL; 
    328         } 
    329         return 0; 
     358    if (i<(int)m_receiveProcessors.size()) { 
     359        return m_receiveProcessors.at(i); 
     360    } else if (i<(int)m_receiveProcessors.size() + (int)m_transmitProcessors.size()) { 
     361        return m_transmitProcessors.at(i-m_receiveProcessors.size()); 
     362    } 
     363 
     364    return NULL; 
    330365} 
    331366 
    332367bool 
    333368BounceDevice::startStreamByIndex(int i) { 
    334 //      int iso_channel=0; 
    335 //      int plug=0; 
    336 //      int hostplug=-1; 
    337 // 
    338         switch (i) { 
    339         case 0: 
    340 //              // do connection management: make connection 
    341 //              iso_channel = iec61883_cmp_connect( 
    342 //                      m_1394Service->getHandle(), 
    343 //                      m_nodeId | 0xffc0, 
    344 //                      &plug, 
    345 //                      raw1394_get_local_id (m_1394Service->getHandle()), 
    346 //                      &hostplug, 
    347 //                      &m_receiveProcessorBandwidth); 
    348 // 
    349 //              // set the channel obtained by the connection management 
    350     #warning TEST CODE FOR BOUNCE DEVICE !! 
    351         if (m_configRom->getNodeId()==0) { 
    352             m_receiveProcessor->setChannel(1); 
    353         } else { 
    354             m_receiveProcessor->setChannel(0); 
    355         } 
    356                 break; 
    357         case 1: 
    358 //              // do connection management: make connection 
    359 //              iso_channel = iec61883_cmp_connect( 
    360 //                      m_1394Service->getHandle(), 
    361 //                      raw1394_get_local_id (m_1394Service->getHandle()), 
    362 //                      &hostplug, 
    363 //                      m_nodeId | 0xffc0, 
    364 //                      &plug, 
    365 //                      &m_transmitProcessorBandwidth); 
    366 // 
    367 //              // set the channel obtained by the connection management 
    368 // //           m_receiveProcessor2->setChannel(iso_channel); 
    369     #warning TEST CODE FOR BOUNCE DEVICE !! 
    370         if (m_configRom->getNodeId()==0) { 
    371             m_transmitProcessor->setChannel(0); 
    372         } else { 
    373             m_transmitProcessor->setChannel(1); 
    374         } 
    375                 break; 
    376         default: 
    377                 return false; 
    378         } 
    379  
    380         return true; 
    381  
     369    if (i<(int)m_receiveProcessors.size()) { 
     370        int n=i; 
     371        FreebobStreaming::StreamProcessor *p=m_receiveProcessors.at(n); 
     372         
     373        // allocate ISO channel 
     374        int isochannel=allocateIsoChannel(p->getMaxPacketSize()); 
     375        if(isochannel<0) { 
     376            debugError("Could not allocate iso channel for SP %d\n",i); 
     377            return false; 
     378        } 
     379        p->setChannel(isochannel); 
     380         
     381        fb_quadlet_t reg_isoch; 
     382        // check value of ISO_CHANNEL register 
     383        if(!readReg(BOUNCE_REGISTER_TX_ISOCHANNEL, &reg_isoch)) { 
     384            debugError("Could not read ISO_CHANNEL register\n", n); 
     385            p->setChannel(-1); 
     386            deallocateIsoChannel(isochannel); 
     387            return false; 
     388        } 
     389        if(reg_isoch != 0xFFFFFFFFUL) { 
     390            debugError("ISO_CHANNEL register != 0xFFFFFFFF (=0x%08X)\n", reg_isoch); 
     391            p->setChannel(-1); 
     392            deallocateIsoChannel(isochannel); 
     393            return false; 
     394        } 
     395         
     396        // write value of ISO_CHANNEL register 
     397        reg_isoch=isochannel; 
     398        if(!writeReg(BOUNCE_REGISTER_TX_ISOCHANNEL, reg_isoch)) { 
     399            debugError("Could not write ISO_CHANNEL register\n"); 
     400            p->setChannel(-1); 
     401            deallocateIsoChannel(isochannel); 
     402            return false; 
     403        } 
     404         
     405        return true; 
     406         
     407    } else if (i<(int)m_receiveProcessors.size() + (int)m_transmitProcessors.size()) { 
     408        int n=i-m_receiveProcessors.size(); 
     409        FreebobStreaming::StreamProcessor *p=m_transmitProcessors.at(n); 
     410         
     411        // allocate ISO channel 
     412        int isochannel=allocateIsoChannel(p->getMaxPacketSize()); 
     413        if(isochannel<0) { 
     414            debugError("Could not allocate iso channel for SP %d\n",i); 
     415            return false; 
     416        } 
     417        p->setChannel(isochannel); 
     418         
     419        fb_quadlet_t reg_isoch; 
     420        // check value of ISO_CHANNEL register 
     421        if(!readReg(BOUNCE_REGISTER_RX_ISOCHANNEL, &reg_isoch)) { 
     422            debugError("Could not read ISO_CHANNEL register\n"); 
     423            p->setChannel(-1); 
     424            deallocateIsoChannel(isochannel); 
     425            return false; 
     426        } 
     427        if(reg_isoch != 0xFFFFFFFFUL) { 
     428            debugError("ISO_CHANNEL register != 0xFFFFFFFF (=0x%08X)\n", reg_isoch); 
     429            p->setChannel(-1); 
     430            deallocateIsoChannel(isochannel); 
     431            return false; 
     432        } 
     433         
     434        // write value of ISO_CHANNEL register 
     435        reg_isoch=isochannel; 
     436        if(!writeReg(BOUNCE_REGISTER_TX_ISOCHANNEL, reg_isoch)) { 
     437            debugError("Could not write ISO_CHANNEL register\n"); 
     438            p->setChannel(-1); 
     439            deallocateIsoChannel(isochannel); 
     440            return false; 
     441        } 
     442         
     443        return true; 
     444    } 
     445     
     446    debugError("SP index %d out of range!\n",i); 
     447     
     448    return false; 
    382449} 
    383450 
    384451bool 
    385452BounceDevice::stopStreamByIndex(int i) { 
    386         // do connection management: break connection 
    387  
    388 //      int plug=0; 
    389 //      int hostplug=-1; 
    390 // 
    391 //      switch (i) { 
    392 //      case 0: 
    393 //              // do connection management: break connection 
    394 //              iec61883_cmp_disconnect( 
    395 //                      m_1394Service->getHandle(), 
    396 //                      m_nodeId | 0xffc0, 
    397 //                      plug, 
    398 //                      raw1394_get_local_id (m_1394Service->getHandle()), 
    399 //                      hostplug, 
    400 //                      m_receiveProcessor->getChannel(), 
    401 //                      m_receiveProcessorBandwidth); 
    402 // 
    403 //              break; 
    404 //      case 1: 
    405 //              // do connection management: break connection 
    406 //              iec61883_cmp_disconnect( 
    407 //                      m_1394Service->getHandle(), 
    408 //                      raw1394_get_local_id (m_1394Service->getHandle()), 
    409 //                      hostplug, 
    410 //                      m_nodeId | 0xffc0, 
    411 //                      plug, 
    412 //                      m_transmitProcessor->getChannel(), 
    413 //                      m_transmitProcessorBandwidth); 
    414 // 
    415 //              // set the channel obtained by the connection management 
    416 // //           m_receiveProcessor2->setChannel(iso_channel); 
    417 //              break; 
    418 //      default: 
    419 //              return 0; 
    420 //      } 
    421453 
    422454        return false; 
    423455} 
    424456 
     457// helper functions 
     458 
     459// allocate ISO resources for the SP's 
     460int BounceDevice::allocateIsoChannel(unsigned int packet_size) { 
     461    unsigned int bandwidth=8+packet_size; 
     462     
     463    int ch=m_p1394Service->allocateIsoChannelGeneric(bandwidth); 
     464         
     465    debugOutput(DEBUG_LEVEL_VERBOSE, "allocated channel %d, bandwidth %d\n", 
     466        ch, bandwidth); 
     467     
     468    return ch; 
     469} 
     470// deallocate ISO resources 
     471bool BounceDevice::deallocateIsoChannel(int channel) { 
     472    debugOutput(DEBUG_LEVEL_VERBOSE, "freeing channel %d\n",channel); 
     473    return m_p1394Service->freeIsoChannel(channel); 
     474} 
     475 
     476// I/O functions 
     477 
     478bool 
     479BounceDevice::readReg(fb_nodeaddr_t offset, fb_quadlet_t *result) { 
     480    debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Reading base register offset 0x%08llX\n", offset); 
     481     
     482    if(offset >= BOUNCE_INVALID_OFFSET) { 
     483        debugError("invalid offset: 0x%016llX\n", offset); 
     484        return false; 
     485    } 
     486     
     487    fb_nodeaddr_t addr=BOUNCE_REGISTER_BASE + offset; 
     488    fb_nodeid_t nodeId=m_nodeId | 0xFFC0; 
     489     
     490    if(!m_p1394Service->read_quadlet( nodeId, addr, result ) ) { 
     491        debugError("Could not read from node 0x%04X addr 0x%012X\n", nodeId, addr); 
     492        return false; 
     493    } 
     494    debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Read result: 0x%08X\n", *result); 
     495    
     496    return true; 
     497} 
     498 
     499bool 
     500BounceDevice::writeReg(fb_nodeaddr_t offset, fb_quadlet_t data) { 
     501    debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing base register offset 0x%08llX, data: 0x%08X\n",   
     502        offset, data); 
     503     
     504    if(offset >= BOUNCE_INVALID_OFFSET) { 
     505        debugError("invalid offset: 0x%016llX\n", offset); 
     506        return false; 
     507    } 
     508     
     509    fb_nodeaddr_t addr=BOUNCE_REGISTER_BASE + offset; 
     510    fb_nodeid_t nodeId=m_nodeId | 0xFFC0; 
     511     
     512    if(!m_p1394Service->write_quadlet( nodeId, addr, data ) ) { 
     513        debugError("Could not write to node 0x%04X addr 0x%012X\n", nodeId, addr); 
     514        return false; 
     515    } 
     516    return true; 
     517} 
     518 
     519bool  
     520BounceDevice::readRegBlock(fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length) { 
     521    debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Reading base register offset 0x%08llX, length %u\n",  
     522        offset, length); 
     523     
     524    if(offset >= BOUNCE_INVALID_OFFSET) { 
     525        debugError("invalid offset: 0x%016llX\n", offset); 
     526        return false; 
     527    } 
     528     
     529    fb_nodeaddr_t addr=BOUNCE_REGISTER_BASE + offset; 
     530    fb_nodeid_t nodeId=m_nodeId | 0xFFC0; 
     531     
     532    if(!m_p1394Service->read( nodeId, addr, length, data ) ) { 
     533        debugError("Could not read from node 0x%04X addr 0x%012llX\n", nodeId, addr); 
     534        return false; 
     535    } 
     536    return true; 
     537} 
     538 
     539bool  
     540BounceDevice::writeRegBlock(fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length) { 
     541    debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing base register offset 0x%08llX, length: %u\n",   
     542        offset, length); 
     543     
     544    if(offset >= BOUNCE_INVALID_OFFSET) { 
     545        debugError("invalid offset: 0x%016llX\n", offset); 
     546        return false; 
     547    } 
     548     
     549    fb_nodeaddr_t addr=BOUNCE_REGISTER_BASE + offset; 
     550    fb_nodeid_t nodeId=m_nodeId | 0xFFC0; 
     551 
     552    if(!m_p1394Service->write( nodeId, addr, length, data ) ) { 
     553        debugError("Could not write to node 0x%04X addr 0x%012llX\n", nodeId, addr); 
     554        return false; 
     555    } 
     556    return true; 
     557} 
     558 
     559 
    425560} // namespace 
  • branches/streaming-rework/src/bounce/bounce_avdevice.h

    r415 r416  
    3131#include "libstreaming/AmdtpPortInfo.h" 
    3232 
     33#include "libieee1394/ARMHandler.h" 
     34 
    3335#include "iavdevice.h" 
    3436#include "libfreebob/freebob_bounce.h" 
     37 
     38#include <vector> 
     39 
     40#define BOUNCE_REGISTER_BASE 0x0000FFFFE0000000ULL 
     41#define BOUNCE_REGISTER_LENGTH (4*256) 
     42#define BOUNCE_REGISTER_TX_ISOCHANNEL 0x10 
     43#define BOUNCE_REGISTER_RX_ISOCHANNEL 0x14 
     44#define BOUNCE_INVALID_OFFSET 0xFFFFF00000000000ULL 
    3545 
    3646class ConfigRom; 
     
    4959 
    5060class BounceDevice : public IAvDevice { 
     61private: 
     62    class BounceNotifier; 
    5163public: 
    5264    BounceDevice( std::auto_ptr<ConfigRom>( configRom ), 
     
    8193protected: 
    8294    std::auto_ptr<ConfigRom>( m_configRom ); 
    83     Ieee1394Service* m_1394Service; 
     95    Ieee1394Service* m_p1394Service; 
    8496    int              m_nodeId; 
    8597    int              m_verboseLevel; 
     
    90102    unsigned int m_samplerate; 
    91103    struct VendorModelEntry* m_model; 
    92     unsigned int m_id; 
    93104 
    94         // streaming stuff 
    95         FreebobStreaming::AmdtpReceiveStreamProcessor *m_receiveProcessor; 
    96         int m_receiveProcessorBandwidth; 
    97          
    98         FreebobStreaming::AmdtpTransmitStreamProcessor *m_transmitProcessor; 
    99         int m_transmitProcessorBandwidth; 
     105    // streaming stuff 
     106    typedef std::vector< FreebobStreaming::StreamProcessor * > StreamProcessorVector; 
     107    StreamProcessorVector m_receiveProcessors; 
     108    StreamProcessorVector m_transmitProcessors; 
    100109 
    101110    bool addPortsToProcessor( 
    102            FreebobStreaming::StreamProcessor *processor,  
    103            FreebobStreaming::AmdtpAudioPort::E_Direction direction); 
    104  
     111       FreebobStreaming::StreamProcessor *processor,  
     112       FreebobStreaming::Port::E_Direction direction); 
    105113 
    106114    DECLARE_DEBUG_MODULE; 
     115     
     116private: // generic helpers 
     117    int allocateIsoChannel(unsigned int packet_size); 
     118    bool deallocateIsoChannel(int channel); 
     119     
     120private: // I/O helpers 
     121    // quadlet read/write routines 
     122    bool readReg(fb_nodeaddr_t, fb_quadlet_t *); 
     123    bool writeReg(fb_nodeaddr_t, fb_quadlet_t); 
     124    bool readRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t); 
     125    bool writeRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t); 
     126     
     127private: 
     128    BounceNotifier *m_Notifier; 
     129    /** 
     130     * this class reacts on the ohter side writing to the  
     131     * hosts address space 
     132     */ 
     133    #define BOUNCE_NOTIFIER_BASE_ADDRESS 0x0000FFFFE0000000ULL 
     134    #define BOUNCE_NOTIFIER_BLOCK_LENGTH 4 
     135    class BounceNotifier : public ARMHandler 
     136    { 
     137    public: 
     138        BounceNotifier(BounceDevice *, nodeaddr_t start); 
     139        virtual ~BounceNotifier(); 
     140         
     141    private: 
     142        BounceDevice *m_bouncedevice; 
     143    }; 
    107144}; 
    108145 
  • branches/streaming-rework/src/iavdevice.h

    r415 r416  
    2424#include "libfreebobavc/avc_definitions.h" 
    2525#include "libfreebob/xmlparser.h" 
     26#include "libutil/OptionContainer.h" 
    2627 
    2728class ConfigRom; 
     
    2930 
    3031namespace FreebobStreaming { 
    31        class StreamProcessor; 
     32    class StreamProcessor; 
    3233} 
    3334/*! 
     
    3839 
    3940*/ 
    40 class IAvDevice
     41class IAvDevice : public FreebobUtil::OptionContainer
    4142public: 
    4243        virtual ~IAvDevice() {} 
  • branches/streaming-rework/src/libutil/unittests.cpp

    r365 r416  
    2020 
    2121#include "serialize.h" 
     22#include "OptionContainer.h" 
     23 
    2224#include <libraw1394/raw1394.h> 
    2325 
     
    2527 
    2628using namespace Util; 
     29using namespace FreebobUtil; 
    2730 
    2831/////////////////////////////////////// 
     
    405408 
    406409///////////////////////////////////// 
     410class testOC : public OptionContainer { 
     411public: 
     412    testOC() {}; 
     413    ~testOC() {}; 
     414     
     415    bool test() { 
     416        bool result=true; 
     417         
     418        Option op1=Option(); 
     419        if(addOption(op1)) { 
     420            printf( "adding an empty option should not succeed\n" ); 
     421            result=false; 
     422        } 
     423         
     424        op1=Option("option1"); 
     425        if(addOption(op1)) { 
     426            printf( "adding an option without a value should not succeed\n" ); 
     427            result=false; 
     428        } 
     429         
     430        op1=Option("option1", (float)(1.0)); 
     431        if(!addOption(op1)) { 
     432            printf( "could not add valid option (1)\n" ); 
     433            result=false; 
     434        } 
     435        if(addOption(op1)) { 
     436            printf( "adding the same option twice should not succeed\n" ); 
     437            result=false; 
     438        } 
     439        if(!removeOption(op1)) { 
     440            printf( "could not remove option by reference\n" ); 
     441            result=false; 
     442        } 
     443        if(hasOption(op1)) { 
     444            printf( "option not removed (by reference)\n" ); 
     445            result=false; 
     446        } 
     447         
     448        op1=Option("option1", (int64_t)1); 
     449        if(!addOption(op1)) { 
     450            printf( "could not add valid option (2)\n" ); 
     451            result=false; 
     452        } 
     453        if(!removeOption("option1")) { 
     454            printf( "could not remove option by name\n" ); 
     455            result=false; 
     456        } 
     457        if(hasOption(op1)) { 
     458            printf( "option not removed (by name)\n" ); 
     459            result=false; 
     460        } 
     461         
     462        op1=Option("option1", (int64_t)(-1)); 
     463        if(!addOption(op1)) { 
     464            printf( "could not add valid option (3)\n" ); 
     465            result=false; 
     466        } 
     467        Option op2=Option("option1", (double)(1.75)); 
     468        if(addOption(op2)) { 
     469            printf( "adding two options with the same name should not be allowed\n" ); 
     470            result=false; 
     471        } 
     472         
     473        op2=Option("option2", (double)(1.75)); 
     474        if(!addOption(op2)) { 
     475            printf( "adding an option with a different name should be allowed (1)\n" ); 
     476            result=false; 
     477        } 
     478        Option op3=Option("option3", (int64_t)(1.75)); 
     479        if(!addOption(op3)) { 
     480            printf( "adding an option with a different name should be allowed (2)\n" ); 
     481            result=false; 
     482        } 
     483         
     484        if(countOptions() != 3) { 
     485            printf( "countOptions failed\n" ); 
     486            result=false; 
     487        } 
     488             
     489        int i=0; 
     490        for ( OptionContainer::iterator it = begin(); 
     491          it != end(); 
     492          ++it ) 
     493        { 
     494    //         printf(" (%s)",(*it).getName().c_str()); 
     495            i++; 
     496        } 
     497        if(i!=3) { 
     498            printf( "did not iterate through the right amount of options\n" ); 
     499            result=false; 
     500        } 
     501         
     502        clearOptions(); 
     503        return result; 
     504    } 
     505     
     506    void prepare() { 
     507        Option op1=Option("option1", (int64_t)(-1)); 
     508        if(!addOption(op1)) { 
     509            printf( "prepare: could not add valid option (3)\n" ); 
     510        } 
     511         
     512        Option op2=Option("option2", (double)(1.75)); 
     513        if(!addOption(op2)) { 
     514            printf( "prepare: adding an option with a different name should be allowed (1)\n" ); 
     515        } 
     516        Option op3=Option("option3", (int64_t)(1.75)); 
     517        if(!addOption(op3)) { 
     518            printf( "prepare: adding an option with a different name should be allowed (2)\n" ); 
     519        } 
     520    } 
     521}; 
     522 
     523static bool 
     524testU4() 
     525{ 
     526    bool result=true; 
     527    testOC oc; 
     528    if(!oc.test()) { 
     529        printf( "OptionContainer test failed\n" ); 
     530        result=false; 
     531    } 
     532     
     533    // now manipulate it externally 
     534    oc.prepare(); 
     535     
     536    if(!oc.hasOption("option1")) { 
     537        printf( "option1 should be present\n" ); 
     538        result=false; 
     539    } 
     540    if(!oc.hasOption("option2")) { 
     541        printf( "option2 should be present\n" ); 
     542        result=false; 
     543    } 
     544    if(!oc.hasOption("option3")) { 
     545        printf( "option3 should be present\n" ); 
     546        result=false; 
     547    } 
     548    if(oc.hasOption("option4")) { 
     549        printf( "option4 should not be present\n" ); 
     550        result=false; 
     551    } 
     552 
     553    oc.setOption("option1", 1024); 
     554    int tst; 
     555    if (!oc.getOption("option1", tst)) { 
     556        printf( "could not get option1 value\n" ); 
     557        result=false; 
     558    } 
     559     
     560    if(tst != 1024) { 
     561        printf( "option1 should be 1024\n" ); 
     562        result=false; 
     563    } 
     564     
     565    return result; 
     566} 
     567 
     568///////////////////////////////////// 
    407569///////////////////////////////////// 
    408570///////////////////////////////////// 
     
    420582    { "serialize 2",  testU2 }, 
    421583    { "serialize 3",  testU3 }, 
     584    { "OptionContainer 1",  testU4 }, 
    422585}; 
    423586 
  • branches/streaming-rework/src/Makefile.am

    r414 r416  
    5454        libstreaming/StreamProcessor.h libstreaming/StreamProcessorManager.h \ 
    5555        libutil/Atomic.h libutil/cycles.h libutil/DelayLockedLoop.h libutil/PosixThread.h \ 
    56         libutil/ringbuffer.h libutil/PacketBuffer.h libutil/StreamStatistics.h \ 
     56        libutil/ringbuffer.h libutil/OptionContainer.h \ 
     57        libutil/PacketBuffer.h libutil/StreamStatistics.h \ 
    5758        libutil/serialize.h libutil/SystemTimeSource.h libutil/Thread.h libutil/Time.h \ 
    5859        libutil/TimeSource.h libutil/TimestampedBuffer.h 
     
    9293        libutil/DelayLockedLoop.cpp \ 
    9394        libutil/PacketBuffer.cpp \ 
     95        libutil/OptionContainer.cpp \ 
    9496        libutil/PosixThread.cpp \ 
    9597        libutil/ringbuffer.c \ 
  • branches/streaming-rework/src/maudio/maudio_avdevice.cpp

    r415 r416  
    1919 */ 
    2020#include "maudio/maudio_avdevice.h" 
     21#include "bebob/bebob_avdevice.h" 
    2122 
    2223#include "libieee1394/configrom.h" 
     
    4142                    int iNodeId, 
    4243                    int iVerboseLevel ) 
    43     :  m_pConfigRom( configRom ) 
    44     , m_p1394Service( &ieee1394service ) 
    45     , m_iNodeId( iNodeId ) 
    46     , m_iVerboseLevel( iVerboseLevel ) 
    47     , m_pFilename( 0 ) 
    48     , m_id(0) 
    49     , m_receiveProcessor ( 0 ) 
    50     , m_receiveProcessorBandwidth ( -1 ) 
    51     , m_transmitProcessor ( 0 ) 
    52     , m_transmitProcessorBandwidth ( -1 ) 
    53 
    54     setDebugLevel( iVerboseLevel ); 
    55      
     44    : BeBoB::AvDevice( configRom, 
     45                    ieee1394service, 
     46                    iNodeId, 
     47                    iVerboseLevel ) 
     48    , m_model ( NULL ) 
     49
    5650    debugOutput( DEBUG_LEVEL_VERBOSE, "Created MAudio::AvDevice (NodeID %d)\n", 
    5751                 iNodeId ); 
     
    6256} 
    6357 
    64 ConfigRom& 
    65 AvDevice::getConfigRom() const 
    66 { 
    67     return *m_pConfigRom; 
    68 } 
    69  
    70 struct VendorModelEntry { 
    71     unsigned int m_iVendorId; 
    72     unsigned int m_iModelId; 
    73     const char*  m_pFilename; 
    74 }; 
    75  
    7658static VendorModelEntry supportedDeviceList[] = 
    7759{ 
    78     //{0x0007f5, 0x00010048, "refdesign.xml"},  // BridgeCo, RD Audio1 
    79  
    80     {0x000d6c, 0x00010046, "fw410.xml"},       // M-Audio, FW 410 
    81     {0x000d6c, 0x00010058, "fw410.xml"},       // M-Audio, FW 410; Version 5.10.0.5036 
    82     {0x000d6c, 0x00010060, "fwap.xml"},        // M-Audio, FW Audiophile (to be verified); 
    83  
    84      
     60    //{0x0007f5, 0x00010048, "BridgeCo", "RD Audio1", "refdesign.xml"}, 
     61 
     62    {0x000d6c, 0x00010046, "M-Audio", "FW 410", "fw410.xml"}, 
     63    {0x000d6c, 0x00010058, "M-Audio", "FW 410", "fw410.xml"},       // Version 5.10.0.5036 
     64    {0x000d6c, 0x00010060, "M-Audio", "FW Audiophile", "fwap.xml"}, 
    8565}; 
    8666 
     
    9575          ++i ) 
    9676    { 
    97         if ( ( supportedDeviceList[i].m_iVendorId == iVendorId ) 
    98              && ( supportedDeviceList[i].m_iModelId == iModelId ) ) 
     77        if ( ( supportedDeviceList[i].vendor_id == iVendorId ) 
     78             && ( supportedDeviceList[i].model_id == iModelId ) ) 
    9979        { 
    10080            return true; 
    10181        } 
    10282    } 
    103  
    10483    return false; 
    10584} 
     
    10887AvDevice::discover() 
    10988{ 
    110     unsigned int iVendorId = m_pConfigRom->getNodeVendorId(); 
    111     unsigned int iModelId = m_pConfigRom->getModelId(); 
     89    unsigned int vendorId = m_pConfigRom->getNodeVendorId(); 
     90    unsigned int modelId = m_pConfigRom->getModelId(); 
     91 
    11292    for ( unsigned int i = 0; 
    11393          i < ( sizeof( supportedDeviceList )/sizeof( VendorModelEntry ) ); 
    11494          ++i ) 
    11595    { 
    116         if ( ( supportedDeviceList[i].m_iVendorId == iVendorId ) 
    117              && ( supportedDeviceList[i].m_iModelId == iModelId ) ) 
     96        if ( ( supportedDeviceList[i].vendor_id == vendorId ) 
     97             && ( supportedDeviceList[i].model_id == modelId )  
     98           ) 
    11899        { 
    119             m_pFilename = supportedDeviceList[i].m_pFilename
     100            m_model = &(supportedDeviceList[i])
    120101            break; 
    121102        } 
    122103    } 
    123104 
    124     return m_pFilename != 0;     
     105    if (m_model != NULL) { 
     106        debugOutput( DEBUG_LEVEL_VERBOSE, "found %s %s\n", 
     107                m_model->vendor_name, m_model->model_name); 
     108    } else return false; 
    125109     
     110    return true; 
    126111} 
    127112 
     
    137122} 
    138123 
    139 bool 
    140 AvDevice::lock() { 
    141  
    142     return true; 
    143 } 
    144  
    145  
    146 bool 
    147 AvDevice::unlock() { 
    148  
    149     return true; 
    150 } 
    151  
    152124void 
    153125AvDevice::showDevice() const 
     
    159131{ 
    160132    char* pFilename; 
    161     if ( asprintf( &pFilename, "%s/libfreebob/maudio/%s", DATADIR, m_pFilename ) < 0 ) { 
     133    if ( asprintf( &pFilename, "%s/libfreebob/maudio/%s", DATADIR, m_model->filename ) < 0 ) { 
    162134        debugError( "addXmlDescription: Could not create filename string\n" ); 
    163135        return false; 
     
    213185                            if ( ( !xmlStrcmp( pSubNode->name,  ( const xmlChar * ) "Node" ) ) ) { 
    214186                                char* result; 
    215                                 asprintf( &result, "%d", m_iNodeId ); 
     187                                asprintf( &result, "%d", m_nodeId ); 
    216188                                xmlNodeSetContent( pSubNode, BAD_CAST result ); 
    217189                                free( result ); 
     
    244216} 
    245217 
    246 bool AvDevice::setId( unsigned int id) 
    247 
    248     // FIXME: decent ID system nescessary 
    249     m_id=id; 
     218bool 
     219AvDevice::prepare() { 
     220 
    250221    return true; 
    251222} 
    252223 
    253 bool 
    254 AvDevice::prepare() { 
    255 /*    /////////// 
    256     // get plugs 
    257  
    258     AvPlug* inputplug = getPlugById( m_pcrPlugs, AvPlug::eAPD_Input, 0 ); 
    259     if ( !inputplug ) { 
    260         debugError( "setSampleRate: Could not retrieve iso input plug 0\n" ); 
    261         return false; 
    262     } 
    263     AvPlug* outputPlug = getPlugById( m_pcrPlugs, AvPlug::eAPD_Output, 0 ); 
    264     if ( !inputplug ) { 
    265         debugError( "setSampleRate: Could not retrieve iso output plug 0\n" ); 
    266         return false; 
    267     } 
    268  
    269     int samplerate=outputPlug->getSampleRate(); 
    270     m_receiveProcessor=new FreebobStreaming::AmdtpReceiveStreamProcessor( 
    271                              m_p1394Service->getPort(), 
    272                              samplerate, 
    273                              outputPlug->getNrOfChannels()); 
    274  
    275     if(!m_receiveProcessor->init()) { 
    276         debugFatal("Could not initialize receive processor!\n"); 
    277         return false; 
    278     } 
    279  
    280     if (!addPlugToProcessor(*outputPlug,m_receiveProcessor,  
    281         FreebobStreaming::AmdtpAudioPort::E_Capture)) { 
    282         debugFatal("Could not add plug to processor!\n"); 
    283         return false; 
    284     } 
    285  
    286     // do the transmit processor 
    287 //     if (m_snoopMode) { 
    288 //         // we are snooping, so these are receive too. 
    289 //         samplerate=inputPlug->getSampleRate(); 
    290 //         m_receiveProcessor2=new FreebobStreaming::AmdtpReceiveStreamProcessor( 
    291 //                                   channel, 
    292 //                                   m_p1394Service->getPort(), 
    293 //                                   samplerate, 
    294 //                                   inputPlug->getNrOfChannels()); 
    295 //          
    296 //         if(!m_receiveProcessor2->init()) { 
    297 //             debugFatal("Could not initialize snooping receive processor!\n"); 
    298 //             return false; 
    299 //         } 
    300 //         if (!addPlugToProcessor(*inputPlug,m_receiveProcessor2,  
    301 //             FreebobStreaming::AmdtpAudioPort::E_Capture)) { 
    302 //             debugFatal("Could not add plug to processor!\n"); 
    303 //             return false; 
    304 //         } 
    305 //     } else { 
    306         // do the transmit processor 
    307         samplerate=inputPlug->getSampleRate(); 
    308         m_transmitProcessor=new FreebobStreaming::AmdtpTransmitStreamProcessor( 
    309                                 m_p1394Service->getPort(), 
    310                                 samplerate, 
    311                                 inputPlug->getNrOfChannels()); 
    312                                  
    313         if(!m_transmitProcessor->init()) { 
    314             debugFatal("Could not initialize transmit processor!\n"); 
    315             return false; 
    316          
    317         } 
    318          
    319         // FIXME: do this the proper way! 
    320         m_transmitProcessor->syncmaster=m_receiveProcessor; 
    321      
    322         if (!addPlugToProcessor(*inputPlug,m_transmitProcessor,  
    323             FreebobStreaming::AmdtpAudioPort::E_Playback)) { 
    324             debugFatal("Could not add plug to processor!\n"); 
    325             return false; 
    326         } 
    327 //     } 
    328 */ 
    329     return true; 
    330 
    331  
    332 // bool 
    333 // AvDevice::addPlugToProcessor( 
    334 //     AvPlug& plug,  
    335 //     FreebobStreaming::StreamProcessor *processor,  
    336 //     FreebobStreaming::AmdtpAudioPort::E_Direction direction) { 
    337 //  
    338 //     AvPlug::ClusterInfoVector& clusterInfos = plug.getClusterInfos(); 
    339 //     for ( AvPlug::ClusterInfoVector::const_iterator it = clusterInfos.begin(); 
    340 //           it != clusterInfos.end(); 
    341 //           ++it ) 
    342 //     { 
    343 //         const AvPlug::ClusterInfo* clusterInfo = &( *it ); 
    344 //  
    345 //         AvPlug::ChannelInfoVector channelInfos = clusterInfo->m_channelInfos; 
    346 //         for ( AvPlug::ChannelInfoVector::const_iterator it = channelInfos.begin(); 
    347 //               it != channelInfos.end(); 
    348 //               ++it ) 
    349 //         { 
    350 //             const AvPlug::ChannelInfo* channelInfo = &( *it ); 
    351 //             std::ostringstream portname; 
    352 //              
    353 //             portname << "dev" << m_id << "_" << channelInfo->m_name; 
    354 //              
    355 //             FreebobStreaming::Port *p=NULL; 
    356 //             switch(clusterInfo->m_portType) { 
    357 //             case ExtendedPlugInfoClusterInfoSpecificData::ePT_Speaker: 
    358 //             case ExtendedPlugInfoClusterInfoSpecificData::ePT_Headphone: 
    359 //             case ExtendedPlugInfoClusterInfoSpecificData::ePT_Microphone: 
    360 //             case ExtendedPlugInfoClusterInfoSpecificData::ePT_Line: 
    361 //             case ExtendedPlugInfoClusterInfoSpecificData::ePT_Analog: 
    362 //                 p=new FreebobStreaming::AmdtpAudioPort( 
    363 //                         portname.str(), 
    364 //                         direction,  
    365 //                         // \todo: streaming backend expects indexing starting from 0 
    366 //                         // but bebob reports it starting from 1. Decide where 
    367 //                         // and how to handle this (pp: here) 
    368 //                         channelInfo->m_streamPosition - 1,  
    369 //                         channelInfo->m_location,  
    370 //                         FreebobStreaming::AmdtpPortInfo::E_MBLA,  
    371 //                         clusterInfo->m_portType 
    372 //                 ); 
    373 //                 break; 
    374 //  
    375 //             case ExtendedPlugInfoClusterInfoSpecificData::ePT_MIDI: 
    376 //                 p=new FreebobStreaming::AmdtpMidiPort( 
    377 //                         portname.str(), 
    378 //                         direction,  
    379 //                         // \todo: streaming backend expects indexing starting from 0 
    380 //                         // but bebob reports it starting from 1. Decide where 
    381 //                         // and how to handle this (pp: here) 
    382 //                         channelInfo->m_streamPosition - 1,  
    383 //                         channelInfo->m_location,  
    384 //                         FreebobStreaming::AmdtpPortInfo::E_Midi,  
    385 //                         clusterInfo->m_portType 
    386 //                 ); 
    387 //  
    388 //                 break; 
    389 //             case ExtendedPlugInfoClusterInfoSpecificData::ePT_SPDIF: 
    390 //             case ExtendedPlugInfoClusterInfoSpecificData::ePT_ADAT: 
    391 //             case ExtendedPlugInfoClusterInfoSpecificData::ePT_TDIF: 
    392 //             case ExtendedPlugInfoClusterInfoSpecificData::ePT_MADI: 
    393 //             case ExtendedPlugInfoClusterInfoSpecificData::ePT_Digital: 
    394 //             case ExtendedPlugInfoClusterInfoSpecificData::ePT_NoType: 
    395 //             default: 
    396 //             // unsupported 
    397 //                 break; 
    398 //             } 
    399 //  
    400 //             if (!p) { 
    401 //                 debugOutput(DEBUG_LEVEL_VERBOSE, "Skipped port %s\n",channelInfo->m_name.c_str()); 
    402 //             } else { 
    403 //          
    404 //                 if (!processor->addPort(p)) { 
    405 //                     debugWarning("Could not register port with stream processor\n"); 
    406 //                     return false; 
    407 //                 } 
    408 //             } 
    409 //          } 
    410 //     } 
    411 //     return true; 
    412 // } 
    413  
    414 int  
    415 AvDevice::getStreamCount() { 
    416     return 0; 
    417 //     return 2; // one receive, one transmit 
    418 
    419  
    420 FreebobStreaming::StreamProcessor * 
    421 AvDevice::getStreamProcessorByIndex(int i) { 
    422     switch (i) { 
    423     case 0: 
    424         return m_receiveProcessor; 
    425     case 1: 
    426 //         if (m_snoopMode) { 
    427 //             return m_receiveProcessor2; 
    428 //         } else { 
    429             return m_transmitProcessor; 
    430 //         } 
    431     default: 
    432         return NULL; 
    433     } 
    434     return 0; 
    435 
    436  
    437 bool 
    438 AvDevice::startStreamByIndex(int i) { 
    439     return false; 
    440 
    441  
    442 bool 
    443 AvDevice::stopStreamByIndex(int i) { 
    444  
    445     return false; 
    446 
    447  
    448 
     224
  • branches/streaming-rework/src/maudio/maudio_avdevice.h

    r415 r416  
    2727#include "libfreebob/xmlparser.h" 
    2828 
     29#include "bebob/bebob_avdevice.h" 
     30 
    2931#include "libstreaming/AmdtpStreamProcessor.h" 
    3032#include "libstreaming/AmdtpPort.h" 
     
    3840namespace MAudio { 
    3941 
    40 class AvDevice : public IAvDevice { 
     42struct VendorModelEntry { 
     43    unsigned int vendor_id; 
     44    unsigned int model_id; 
     45    char *vendor_name; 
     46    char *model_name;  
     47    char *filename; 
     48}; 
     49 
     50class AvDevice : public BeBoB::AvDevice { 
    4151public: 
    4252    AvDevice( std::auto_ptr<ConfigRom>( configRom ), 
     
    4757 
    4858    static bool probe( ConfigRom& configRom ); 
    49     virtual bool discover(); 
    50     virtual ConfigRom& getConfigRom() const; 
    51     virtual bool addXmlDescription( xmlNodePtr pDeviceNode ); 
    52     virtual void showDevice() const; 
     59    bool discover(); 
    5360     
    54     virtual bool setSamplingFrequency( ESamplingFrequency samplingFrequency ); 
    55     virtual int getSamplingFrequency( ); 
    56          
    57     virtual bool setId(unsigned int id); 
     61    bool addXmlDescription( xmlNodePtr pDeviceNode ); 
     62    void showDevice() const; 
     63     
     64    bool setSamplingFrequency( ESamplingFrequency samplingFrequency ); 
     65    int getSamplingFrequency( ); 
    5866 
    59     virtual int getStreamCount(); 
    60     virtual FreebobStreaming::StreamProcessor *getStreamProcessorByIndex(int i); 
    61  
    62     virtual bool prepare(); 
    63     bool lock(); 
    64     bool unlock(); 
    65  
    66     bool startStreamByIndex(int i); 
    67     bool stopStreamByIndex(int i); 
     67    bool prepare(); 
    6868 
    6969protected: 
    70     std::auto_ptr<ConfigRom>( m_pConfigRom ); 
    71     Ieee1394Service* m_p1394Service; 
    72     int              m_iNodeId; 
    73     int              m_iVerboseLevel; 
    74     const char*      m_pFilename; 
    75      
    76     unsigned int m_id; 
    77  
    78     // streaming stuff 
    79     FreebobStreaming::AmdtpReceiveStreamProcessor *m_receiveProcessor; 
    80     int m_receiveProcessorBandwidth; 
    81  
    82     FreebobStreaming::AmdtpTransmitStreamProcessor *m_transmitProcessor; 
    83     int m_transmitProcessorBandwidth; 
     70    struct VendorModelEntry*  m_model; 
    8471     
    8572    DECLARE_DEBUG_MODULE; 
  • branches/streaming-rework/src/metrichalo/mh_avdevice.cpp

    r415 r416  
    3434#include <assert.h> 
    3535#include <netinet/in.h> 
     36#include <iostream> 
     37#include <sstream> 
    3638 
    3739#include <libraw1394/csr.h> 
     
    5658    , m_nodeId( nodeId ) 
    5759    , m_verboseLevel( verboseLevel ) 
    58     , m_id(0) 
    59     , m_iso_recv_channel ( -1 ) 
    60     , m_iso_send_channel ( -1 ) 
    6160     
    6261{ 
     
    6564    debugOutput( DEBUG_LEVEL_VERBOSE, "Created MetricHalo::MHAvDevice (NodeID %d)\n", 
    6665                 nodeId ); 
     66    addOption(FreebobUtil::OptionContainer::Option("id",std::string("dev?"))); 
    6767 
    6868} 
     
    140140 
    141141bool MHAvDevice::setId( unsigned int id) { 
    142     debugOutput( DEBUG_LEVEL_VERBOSE, "Set id to %d...\n", id); 
    143     m_id=id; 
    144     return true; 
     142    // FIXME: decent ID system nescessary 
     143    std::ostringstream idstr; 
     144 
     145    idstr << "dev" << id; 
     146     
     147    debugOutput( DEBUG_LEVEL_VERBOSE, "Set id to %s...\n", idstr.str().c_str()); 
     148     
     149    return setOption("id",idstr.str()); 
    145150} 
    146151 
     
    174179int  
    175180MHAvDevice::getStreamCount() { 
    176     return 0; // one receive, one transmit 
     181    return 0; 
    177182} 
    178183 
     
    180185MHAvDevice::getStreamProcessorByIndex(int i) { 
    181186 
    182 //    switch (i) { 
    183 //    case 0: 
    184 //        return m_receiveProcessor; 
    185 //    case 1: 
    186 //        return m_transmitProcessor; 
    187 //    default: 
    188 //        return NULL; 
    189 //    } 
    190 //    return 0; 
    191187    return NULL; 
    192188} 
     
    194190bool 
    195191MHAvDevice::startStreamByIndex(int i) { 
    196  
    197192    return false; 
    198193} 
     
    203198} 
    204199 
    205 signed int MHAvDevice::getIsoRecvChannel(void) { 
    206     return m_iso_recv_channel; 
    207 
    208  
    209 signed int MHAvDevice::getIsoSendChannel(void) { 
    210     return m_iso_send_channel; 
    211 
    212  
    213 
     200
  • branches/streaming-rework/src/metrichalo/mh_avdevice.h

    r415 r416  
    8686    int              m_nodeId; 
    8787    int              m_verboseLevel; 
    88     signed int m_id; 
    89     signed int m_iso_recv_channel, m_iso_send_channel; 
    90      
    91 //      FreebobStreaming::MHReceiveStreamProcessor *m_receiveProcessor; 
    92 //      FreebobStreaming::MHTransmitStreamProcessor *m_transmitProcessor; 
    9388 
    9489private: 
  • branches/streaming-rework/src/motu/motu_avdevice.cpp

    r415 r416  
    3737#include <assert.h> 
    3838#include <netinet/in.h> 
     39#include <iostream> 
     40#include <sstream> 
    3941 
    4042#include <libraw1394/csr.h> 
     
    6163    , m_nodeId( nodeId ) 
    6264    , m_verboseLevel( verboseLevel ) 
    63     , m_id(0) 
    6465    , m_iso_recv_channel ( -1 ) 
    6566    , m_iso_send_channel ( -1 ) 
     
    304305 
    305306bool MotuDevice::setId( unsigned int id) { 
    306         debugOutput( DEBUG_LEVEL_VERBOSE, "Set id to %d...\n", id); 
    307         m_id=id; 
    308         return true; 
     307    // FIXME: decent ID system nescessary 
     308    std::ostringstream idstr; 
     309 
     310    idstr << "dev" << id; 
     311     
     312    debugOutput( DEBUG_LEVEL_VERBOSE, "Set id to %s...\n", idstr.str().c_str()); 
     313     
     314    return setOption("id",idstr.str()); 
    309315} 
    310316 
     
    399405        char *buff; 
    400406        FreebobStreaming::Port *p=NULL; 
    401  
     407         
     408        // retrieve the ID 
     409    std::string id=std::string("dev?"); 
     410    if(!getOption("id", id)) { 
     411        debugWarning("Could not retrieve id parameter, defauling to 'dev?'\n"); 
     412    } 
     413     
    402414        // Add audio capture ports 
    403415        if (!addDirPorts(FreebobStreaming::Port::E_Capture, samp_freq, optical_in_mode)) { 
     
    408420        // MIDI byte sent using a 3 byte sequence starting at byte 4 of the 
    409421        // event data. 
    410         asprintf(&buff,"dev%d_cap_MIDI0",m_id); 
     422        asprintf(&buff,"%s_cap_MIDI0",id.c_str()); 
    411423        p = new FreebobStreaming::MotuMidiPort(buff, 
    412424                FreebobStreaming::Port::E_Capture, 4); 
     
    425437 
    426438        // example of adding an control port: 
    427 //    asprintf(&buff,"dev%d_cap_%s",m_id,"myportnamehere"); 
     439//    asprintf(&buff,"%s_cap_%s",id.c_str(),"myportnamehere"); 
    428440//    p=new FreebobStreaming::MotuControlPort( 
    429441//            buff, 
     
    468480        // MIDI byte transmitted using a 3 byte sequence starting at byte 4 
    469481        // of the event data. 
    470         asprintf(&buff,"dev%d_pbk_MIDI0",m_id); 
     482        asprintf(&buff,"%s_pbk_MIDI0",id.c_str()); 
    471483        p = new FreebobStreaming::MotuMidiPort(buff, 
    472484                FreebobStreaming::Port::E_Capture, 4); 
     
    485497 
    486498        // example of adding an control port: 
    487 //    asprintf(&buff,"dev%d_pbk_%s",m_id,"myportnamehere"); 
     499//    asprintf(&buff,"%s_pbk_%s",id.c_str(),"myportnamehere"); 
    488500//     
    489501//    p=new FreebobStreaming::MotuControlPort( 
     
    765777char *buff; 
    766778 
     779        // retrieve the ID 
     780    std::string id=std::string("dev?"); 
     781    if(!getOption("id", id)) { 
     782        debugWarning("Could not retrieve id parameter, defauling to 'dev?'\n"); 
     783    } 
     784 
    767785        if (direction == FreebobStreaming::Port::E_Capture) { 
    768786                s_processor = m_receiveProcessor; 
     
    777795        if (sample_rate<=96000) { 
    778796                for (i=0; i<2; i++, ofs+=3) { 
    779                         asprintf(&buff,"dev%d_%s_%s-%c", m_id, mode_str, 
     797                        asprintf(&buff,"%s_%s_%s-%c", id.c_str(), mode_str, 
    780798                          aux_str, i==0?'L':'R'); 
    781799                        if (!addPort(s_processor, buff, direction, ofs, 0)) 
     
    787805        // always present no matter what the device configuration is. 
    788806        for (i=0; i<8; i++, ofs+=3) { 
    789                 asprintf(&buff,"dev%d_%s_Analog%d", m_id, mode_str, i+1); 
     807                asprintf(&buff,"%s_%s_Analog%d", id.c_str(), mode_str, i+1); 
    790808                if (!addPort(s_processor, buff, direction, ofs, 0)) 
    791809                        return false; 
     
    799817                for (i=0; i<2; i++, ofs+=3) { 
    800818                        if (m_motu_model == MOTUFW_MODEL_TRAVELER) { 
    801                                 asprintf(&buff,"dev%d_%s_AES/EBU%d", m_id, mode_str, i+1); 
     819                                asprintf(&buff,"%s_%s_AES/EBU%d", id.c_str(), mode_str, i+1); 
    802820                        } else { 
    803821                                if (direction == FreebobStreaming::Port::E_Capture) 
    804                                         asprintf(&buff,"dev%d_%s_Mic%d", m_id, mode_str, i+1); 
     822                                        asprintf(&buff,"%s_%s_Mic%d", id.c_str(), mode_str, i+1); 
    805823                                else 
    806                                         asprintf(&buff,"dev%d_%s_MainOut-%c", m_id, mode_str, i==0?'L':'R'); 
     824                                        asprintf(&buff,"%s_%s_MainOut-%c", id.c_str(), mode_str, i==0?'L':'R'); 
    807825                        } 
    808826                        if (!addPort(s_processor, buff, direction, ofs, 0)) 
     
    815833        if (sample_rate<=96000 && optical_mode!=MOTUFW_OPTICAL_MODE_TOSLINK) { 
    816834                for (i=0; i<2; i++, ofs+=3) { 
    817                         asprintf(&buff,"dev%d_%s_SPDIF%d", m_id, mode_str, i+1); 
     835                        asprintf(&buff,"%s_%s_SPDIF%d", id.c_str(), mode_str, i+1); 
    818836                        if (!addPort(s_processor, buff, direction, ofs, 0)) 
    819837                                return false; 
     
    825843        if (sample_rate<=96000 && optical_mode==MOTUFW_OPTICAL_MODE_TOSLINK) { 
    826844                for (i=0; i<2; i++, ofs+=3) { 
    827                         asprintf(&buff,"dev%d_%s_TOSLINK%d", m_id, mode_str, i+1); 
     845                        asprintf(&buff,"%s_%s_TOSLINK%d", id.c_str(), mode_str, i+1); 
    828846                        if (!addPort(s_processor, buff, direction, ofs, 0)) 
    829847                                return false; 
     
    835853        if (sample_rate<=96000 && optical_mode==MOTUFW_OPTICAL_MODE_ADAT) { 
    836854                for (i=0; i<4; i++, ofs+=3) { 
    837                         asprintf(&buff,"dev%d_%s_ADAT%d", m_id, mode_str, i+1); 
     855                        asprintf(&buff,"%s_%s_ADAT%d", id.c_str(), mode_str, i+1); 
    838856                        if (!addPort(s_processor, buff, direction, ofs, 0)) 
    839857                                return false; 
     
    845863        if (sample_rate<=48000 && optical_mode==MOTUFW_OPTICAL_MODE_ADAT) { 
    846864                for (i=4; i<8; i++, ofs+=3) { 
    847                         asprintf(&buff,"dev%d_%s_ADAT%d", m_id, mode_str, i+1); 
     865                        asprintf(&buff,"%s_%s_ADAT%d", id.c_str(), mode_str, i+1); 
    848866                        if (!addPort(s_processor, buff, direction, ofs, 0)) 
    849867                                return false; 
  • branches/streaming-rework/src/motu/motu_avdevice.h

    r415 r416  
    137137    int              m_nodeId; 
    138138    int              m_verboseLevel; 
    139     signed int m_id; 
    140139    signed int m_iso_recv_channel, m_iso_send_channel; 
    141140    signed int m_bandwidth; 
  • branches/streaming-rework/src/rme/rme_avdevice.cpp

    r415 r416  
    3333#include <netinet/in.h> 
    3434 
     35#include <iostream> 
     36#include <sstream> 
     37 
    3538#include <libraw1394/csr.h> 
    3639 
     
    5457    , m_nodeId( nodeId ) 
    5558    , m_verboseLevel( verboseLevel ) 
    56     , m_id(0) 
    57     , m_iso_recv_channel ( -1 ) 
    58     , m_iso_send_channel ( -1 ) 
    59     , m_bandwidth ( -1 ) 
    60 //    , m_receiveProcessor ( 0 ) 
    61 //    , m_transmitProcessor ( 0 ) 
    6259     
    6360{ 
     
    7168RmeDevice::~RmeDevice() 
    7269{ 
    73     // Free ieee1394 bus resources if they have been allocated 
    74     if (m_p1394Service != NULL) { 
    75         if(m_p1394Service->freeIsoChannel(m_iso_recv_channel)) { 
    76             debugOutput(DEBUG_LEVEL_VERBOSE, "Could not free recv iso channel %d\n", m_iso_recv_channel); 
    77              
    78         } 
    79         if(m_p1394Service->freeIsoChannel(m_iso_send_channel)) { 
    80             debugOutput(DEBUG_LEVEL_VERBOSE, "Could not free send iso channel %d\n", m_iso_send_channel); 
    81              
    82         } 
    83     } 
     70 
    8471} 
    8572 
     
    158145 
    159146bool RmeDevice::setId( unsigned int id) { 
    160         debugOutput( DEBUG_LEVEL_VERBOSE, "Set id to %d...\n", id); 
    161         m_id=id; 
    162         return true; 
     147    // FIXME: decent ID system nescessary 
     148    std::ostringstream idstr; 
     149 
     150    idstr << "dev" << id; 
     151     
     152    debugOutput( DEBUG_LEVEL_VERBOSE, "Set id to %s...\n", idstr.str().c_str()); 
     153     
     154    return setOption("id",idstr.str()); 
    163155} 
    164156 
     
    213205} 
    214206 
    215 signed int RmeDevice::getIsoRecvChannel(void) { 
    216         return m_iso_recv_channel; 
    217 
    218  
    219 signed int RmeDevice::getIsoSendChannel(void) { 
    220         return m_iso_send_channel; 
    221 
    222  
    223 signed int RmeDevice::getEventSize(unsigned int dir) { 
    224     return 0; 
    225 
    226  
    227 
     207
  • branches/streaming-rework/src/rme/rme_avdevice.h

    r415 r416  
    7575    bool startStreamByIndex(int i); 
    7676    bool stopStreamByIndex(int i); 
    77  
    78     signed int getIsoRecvChannel(void); 
    79     signed int getIsoSendChannel(void); 
    80  
    81     signed int getEventSize(unsigned int dir); 
    8277   
    8378protected: 
     
    8984    int              m_nodeId; 
    9085    int              m_verboseLevel; 
    91     signed int m_id; 
    92     signed int m_iso_recv_channel, m_iso_send_channel; 
    93     signed int m_bandwidth; 
    94      
    95 //      FreebobStreaming::RmeReceiveStreamProcessor *m_receiveProcessor; 
    96 //      FreebobStreaming::RmeTransmitStreamProcessor *m_transmitProcessor; 
    9786 
    9887private: 
    99 //      bool addPort(FreebobStreaming::StreamProcessor *s_processor, 
    100 //              char *name,  
    101 //              enum FreebobStreaming::Port::E_Direction direction, 
    102 //              int position, int size); 
    103 //      bool addDirPorts( 
    104 //              enum FreebobStreaming::Port::E_Direction direction, 
    105 //              unsigned int sample_rate, unsigned int optical_mode); 
    106          
    107         unsigned int ReadRegister(unsigned int reg); 
    108         signed int WriteRegister(unsigned int reg, quadlet_t data); 
    10988 
    11089    // debug support