Show
Ignore:
Timestamp:
06/05/06 06:41:55 (17 years ago)
Author:
pieterpalmers
Message:

- re-enabled the Motu device and updated it to the IAvDevice changes
- created a framework streamprocessor for the motu devices

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/libfreebob-2.0/src/devicemanager.cpp

    r242 r246  
    4242    : m_1394Service( 0 ) 
    4343{ 
    44 //      m_probeList.push_back( probeMotu ); 
    4544    m_probeList.push_back( probeBeBoB ); 
     45    m_probeList.push_back( probeMotu ); 
    4646    m_probeList.push_back( probeBounce ); 
    4747} 
     
    174174} 
    175175 
    176 // IAvDevice* 
    177 // DeviceManager::probeMotu(Ieee1394Service& service, int id, int level) 
    178 //
    179 //     IAvDevice* avDevice = new Motu::MotuDevice( service, id, level ); 
    180 //     if ( !avDevice ) { 
    181 //         return NULL; 
    182 //     } 
    183 //  
    184 //     if ( !avDevice->discover() ) { 
    185 //         delete avDevice; 
    186 //         return NULL; 
    187 //     } 
    188 //     return avDevice; 
    189 //
     176IAvDevice* 
     177DeviceManager::probeMotu(Ieee1394Service& service, int id, int level) 
     178
     179    IAvDevice* avDevice = new Motu::MotuDevice( service, id, level ); 
     180    if ( !avDevice ) { 
     181        return NULL; 
     182    } 
     183 
     184    if ( !avDevice->discover() ) { 
     185        delete avDevice; 
     186        return NULL; 
     187    } 
     188    return avDevice; 
     189
    190190 
    191191bool 
  • branches/libfreebob-2.0/src/libstreaming/AmdtpPortInfo.h

    r225 r246  
    4444 
    4545public: 
     46    /** 
     47     * Sometimes a channel can have multiple formats, depending on the  
     48     * device configuration (e.g. an SPDIF port could be plain audio in 24bit integer 
     49     * or AC3 passthrough in IEC compliant frames.)  
     50     * 
     51     * This kind of enum allows to discriminate these formats when decoding 
     52     * If all channels always have the same format, you won't be needing this 
     53     */ 
    4654        enum E_Formats { 
    47                 E_MBLA, 
    48                 E_Midi, 
    49                 E_SPDIF, 
     55                E_MBLA, ///< multibit linear audio 
     56                E_Midi, ///< midi 
     57                E_SPDIF,///< IEC.... format 
    5058        }; 
    5159        enum E_Types { 
  • branches/libfreebob-2.0/src/libstreaming/AmdtpStreamProcessor.cpp

    r244 r246  
    135135        /* there is no more data in the ringbuffer */ 
    136136         
    137         /* If there are already more than on period 
    138         * of frames transfered to the XMIT buffer, there is no xrun. 
    139         *  
    140         */ 
    141         if(m_framecounter>m_period) { 
    142             // we stop processing this untill the next period boundary 
    143             // that's when new data is ready 
    144              
    145             //connection->pfd->events=0; 
    146              
    147             // reset the cip to the old value 
    148             memcpy(&m_cip_status,&old_cip,sizeof(struct iec61883_cip)); 
    149  
    150             // retry this packed  
    151             retval=RAW1394_ISO_AGAIN; 
    152             nevents=0; 
    153             debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "again!\n"); 
    154              
    155         } else { 
    156             debugWarning("Transmit buffer underrun (cycle %d, FC=%d, PC=%d)\n",  
    157                      cycle, m_framecounter, m_handler->getPacketCount()); 
    158              
    159             // signal underrun 
    160             m_xruns++; 
    161      
    162             retval=RAW1394_ISO_DEFER; 
    163             *length=0; 
    164             nevents=0; 
    165         } 
     137        debugWarning("Transmit buffer underrun (cycle %d, FC=%d, PC=%d)\n",  
     138                 cycle, m_framecounter, m_handler->getPacketCount()); 
     139         
     140        // signal underrun 
     141        m_xruns++; 
     142 
     143        retval=RAW1394_ISO_DEFER; 
     144        *length=0; 
     145        nevents=0; 
     146 
    166147 
    167148    } else { 
     
    1005986    if(m_framecounter > (int)m_period) { 
    1006987     return true; 
    1007     } 
     988    } else return false; 
    1008989 
    1009990} 
  • branches/libfreebob-2.0/src/libstreaming/Makefile.am

    r233 r246  
    1919noinst_LTLIBRARIES = libstreaming.la 
    2020noinst_HEADERS = cip.h FreebobPosixThread.h FreebobThread.h FreebobAtomic.h \ 
    21         IsoHandler.h IsoHandlerManager.h IsoStream.h ringbuffer.h PacketBuffer.h \ 
    22         PortManager.h Port.h StreamProcessor.h StreamProcessorManager.h AmdtpPortInfo.h \ 
    23         AmdtpPort.h AmdtpStreamProcessor.h StreamRunner.h ringbuffer.h streamstatistics.h 
     21                IsoHandler.h IsoHandlerManager.h IsoStream.h ringbuffer.h PacketBuffer.h \ 
     22                PortManager.h Port.h StreamProcessor.h StreamProcessorManager.h AmdtpPortInfo.h \ 
     23                AmdtpPort.h AmdtpStreamProcessor.h StreamRunner.h ringbuffer.h streamstatistics.h \ 
     24        MotuStreamProcessor.h MotuPort.h MotuPortInfo.h 
    2425 
    25 libstreaming_la_SOURCES = cip.c FreebobPosixThread.cpp
    26                freebob_streaming.cpp IsoHandler.cpp IsoHandlerManager.cpp IsoStream.cpp PacketBuffer.cpp \ 
    27                PortManager.cpp Port.cpp StreamProcessor.cpp StreamProcessorManager.cpp \ 
    28                AmdtpPortInfo.cpp AmdtpPort.cpp AmdtpStreamProcessor.cpp StreamRunner.cpp      ringbuffer.c \ 
    29         streamstatistics.cpp 
     26libstreaming_la_SOURCES = cip.c FreebobPosixThread.cpp                 freebob_streaming.cpp
     27        IsoHandler.cpp IsoHandlerManager.cpp IsoStream.cpp PacketBuffer.cpp            PortManager.cpp \ 
     28        Port.cpp StreamProcessor.cpp StreamProcessorManager.cpp                AmdtpPortInfo.cpp \ 
     29        AmdtpPort.cpp AmdtpStreamProcessor.cpp StreamRunner.cpp       ringbuffer.c \ 
     30               streamstatistics.cpp MotuStreamProcessor.cpp MotuPort.cpp MotuPortInfo.cpp 
    3031 
    3132INCLUDES = $(LIBRAW1394_CFLAGS) $(LIBIEC61883_CFLAGS) -I$(top_srcdir)/src \ 
  • branches/libfreebob-2.0/src/libstreaming/MotuPort.cpp

    r228 r246  
    2727 */ 
    2828 
    29 #include "AmdtpPort.h" 
     29#include "MotuPort.h" 
    3030#include <assert.h> 
    3131 
  • branches/libfreebob-2.0/src/libstreaming/MotuPort.h

    r228 r246  
    2626 * 
    2727 */ 
    28 #ifndef __FREEBOB_AMDTPPORT__ 
    29 #define __FREEBOB_AMDTPPORT__ 
     28#ifndef __FREEBOB_MOTUPORT__ 
     29#define __FREEBOB_MOTUPORT__ 
    3030 
    3131/** 
    32  * This file implements the AMDTP ports as used in the BeBoB'
     32 * This file implements the ports used in Motu device
    3333 */ 
    3434 
    3535#include "../debugmodule/debugmodule.h" 
    3636#include "Port.h" 
    37 #include "AmdtpPortInfo.h" 
     37#include "MotuPortInfo.h" 
    3838 
    3939namespace FreebobStreaming { 
    4040 
    4141/*! 
    42 \brief The Base Class for an AMDTP Audio Port 
     42\brief The Base Class for Motu Audio Port 
    4343 
    44  The AMDTP/AM824/IEC61883-6 port that represents audio. 
    45   
     44 
    4645*/ 
    47 class AmdtpAudioPort  
    48         : public AudioPort, public AmdtpPortInfo 
     46class MotuAudioPort  
     47        : public AudioPort, public MotuPortInfo 
    4948{ 
    5049 
    5150public: 
    5251 
    53         AmdtpAudioPort(std::string name,  
     52        MotuAudioPort(std::string name,  
    5453                           enum E_Direction direction, 
    55                            int position,  
    56                            int location,  
    57                            enum E_Formats format,  
    58                            int type) 
     54                           int position) 
    5955        : AudioPort(name, direction), 
    60           AmdtpPortInfo(name, position, location, format, type) 
     56          MotuPortInfo(name, position) // TODO: add more port information parameters here if nescessary 
    6157        {}; 
    6258 
    63         virtual ~AmdtpAudioPort() {}; 
     59        virtual ~MotuAudioPort() {}; 
    6460  
    6561protected: 
     
    6864 
    6965/*! 
    70 \brief The Base Class for an AMDTP Midi Port 
     66\brief The Base Class for an Motu Midi Port 
    7167 
    72  The AMDTP/AM824/IEC61883-6 port that represents midi. 
    73   
     68 
    7469*/ 
    75 class AmdtpMidiPort  
    76         : public MidiPort, public AmdtpPortInfo 
     70class MotuMidiPort  
     71        : public MidiPort, public MotuPortInfo 
    7772{ 
    7873 
    7974public: 
    8075 
    81         AmdtpMidiPort(std::string name,  
     76        MotuMidiPort(std::string name,  
    8277                           enum E_Direction direction, 
    83                            int position,  
    84                            int location,  
    85                            enum E_Formats format,  
    86                            int type) 
     78                           int position) 
    8779                : MidiPort(name, direction), 
    88                   AmdtpPortInfo(name, position, location, format, type)  
     80                  MotuPortInfo(name, position)  // TODO: add more port information parameters here if nescessary 
    8981        {}; 
    9082 
    9183 
    92         virtual ~AmdtpMidiPort() {}; 
     84        virtual ~MotuMidiPort() {}; 
     85 
     86protected: 
     87         
     88}; 
     89 
     90/*! 
     91\brief The Base Class for an Motu Control Port 
     92 
     93 
     94*/ 
     95class MotuControlPort  
     96        : public ControlPort, public MotuPortInfo 
     97
     98 
     99public: 
     100 
     101        MotuControlPort(std::string name,  
     102                           enum E_Direction direction, 
     103                           int position) 
     104                : ControlPort(name, direction), 
     105                  MotuPortInfo(name, position) // TODO: add more port information parameters here if nescessary  
     106        {}; 
     107 
     108 
     109        virtual ~MotuControlPort() {}; 
    93110 
    94111protected: 
     
    98115} // end of namespace FreebobStreaming 
    99116 
    100 #endif /* __FREEBOB_AMDTPPORT__ */ 
     117#endif /* __FREEBOB_MOTUPORT__ */ 
    101118 
    102119 
  • branches/libfreebob-2.0/src/libstreaming/MotuPortInfo.cpp

    r221 r246  
    2727 */ 
    2828 
    29 #include "AmdtpPortInfo.h" 
     29#include "MotuPortInfo.h" 
    3030#include <assert.h> 
    3131 
  • branches/libfreebob-2.0/src/libstreaming/MotuPortInfo.h

    r225 r246  
    2626 * 
    2727 */ 
    28 #ifndef __FREEBOB_AMDTPPORTINFO__ 
    29 #define __FREEBOB_AMDTPPORTINFO__ 
     28#ifndef __FREEBOB_MOTUPORTINFO__ 
     29#define __FREEBOB_MOTUPORTINFO__ 
    3030 
    3131#include "../debugmodule/debugmodule.h" 
     
    3434namespace FreebobStreaming { 
    3535/*! 
    36 \brief Class containing the stream information for an AMDTP channel 
     36\brief Class containing the stream information for a Motu channel 
    3737 
    38  Contains the information that maps the port to an AMDTP stream position (i.e. channel) 
    39  this allows the AMDTP stream demultiplexer to find the channel associated  
    40  to this port. 
    41   
     38 Contains the information that enables the decoding routine to find  
     39 this port's data in the ISO events  
     40 
    4241*/ 
    43 class AmdtpPortInfo { 
     42class MotuPortInfo { 
    4443 
    4544public: 
     45    /** 
     46     * Sometimes a channel can have multiple formats, depending on the  
     47     * device configuration (e.g. an SPDIF port could be plain audio in 24bit integer 
     48     * or AC3 passthrough in IEC compliant frames.)  
     49     * 
     50     * This kind of enum allows to discriminate these formats when decoding 
     51     * If all channels always have the same format, you won't be needing this 
     52     */ 
     53     /* 
    4654        enum E_Formats { 
    47                 E_MBLA, 
     55                E_MBLA, // Multibit linear audio, is acutally AMDTP. Change if needed 
    4856                E_Midi, 
    4957                E_SPDIF, 
    5058        }; 
    51         enum E_Types { 
    52  
    53         }; 
    54  
    55         AmdtpPortInfo(std::string name, int position, int location, enum E_Formats format, int type) 
    56           : m_name(name), m_position(position), m_location(location), m_format(format), m_type(type) 
     59    */ 
     60     
     61        /** 
     62         * Initialize Motu portinfo 
     63         * should not be called directly, is inherited by motu ports 
     64         * 
     65         * the position parameter is an example 
     66         * the name parameter is mandatory 
     67         * 
     68         * @param name  
     69         * @param position example parameter 
     70         * @return  
     71         */ 
     72        MotuPortInfo(std::string name, int position) 
     73          : m_name(name), m_position(position) 
    5774        {}; 
    58         virtual ~AmdtpPortInfo() {}; 
     75        virtual ~MotuPortInfo() {}; 
    5976 
    6077 
    6178        std::string getName() {return m_name;}; 
    62         int getLocation()     {return m_location;}; 
    6379        int getPosition()     {return m_position;}; 
    64         enum E_Formats getFormat()       {return m_format;}; 
    65         int getType()         {return m_type;}; 
    6680 
    6781protected: 
     
    6983 
    7084    int m_position; 
    71     int m_location; 
    72     enum E_Formats m_format; 
    73     int m_type; 
    7485 
    7586}; 
     
    7788} // end of namespace FreebobStreaming 
    7889 
    79 #endif /* __FREEBOB_AMDTPPORTINFO__ */ 
     90#endif /* __FREEBOB_MOTUPORTINFO__ */ 
    8091 
    8192 
  • branches/libfreebob-2.0/src/libstreaming/Port.h

    r235 r246  
    355355public: 
    356356 
    357         ControlPort(std::string name, enum E_SignalType type, enum E_BufferType buffertype, enum E_Direction direction)  
     357        ControlPort(std::string name, enum E_Direction direction)  
    358358          : Port(name, E_Control, direction) 
    359359        {}; 
  • branches/libfreebob-2.0/src/Makefile.am

    r242 r246  
    3232        bebob_light/bebob_light_avdevicesubunit.h       \ 
    3333        bebob_light/bebob_light_avplug.h                \ 
    34         bounce/bounce_avdevice.h                         
     34        bounce/bounce_avdevice.h                        \ 
     35        motu/motu_avdevice.h                             
    3536#       bebob/bebob_avdevice.h                          \ 
    3637#       bebob/bebob_avdevice_subunit.h                  \ 
    3738#       bebob/bebob_avplug.h                            \ 
    38 #       bebob/bebob_functionblock.h                     \ 
    39 #       motu/motu_avdevice.h                             
     39#       bebob/bebob_functionblock.h                      
    4040 
    4141libfreebob_la_SOURCES =                                 \ 
     
    4848        bebob_light/bebob_light_avdevicesubunit.cpp     \ 
    4949        bebob_light/bebob_light_avplug.cpp              \ 
    50         bounce/bounce_avdevice.cpp                       
     50        bounce/bounce_avdevice.cpp                      \ 
     51        motu/motu_avdevice.cpp 
    5152#       bebob/bebob_avdevice.cpp                        \ 
    5253#       bebob/bebob_avdevice_xml.cpp                    \ 
     
    5455#       bebob/bebob_avplug.cpp                          \ 
    5556#       bebob/bebob_avplug_xml.cpp                      \ 
    56 #       bebob/bebob_functionblock.cpp                   \ 
    57 #       motu/motu_avdevice.cpp 
     57#       bebob/bebob_functionblock.cpp                    
    5858 
    5959libfreebob_la_LDFLAGS = -version-info $(LT_VERSION) -lpthread $(LIBSIGC_LIBS) \ 
  • branches/libfreebob-2.0/src/motu/motu_avdevice.cpp

    r208 r246  
    2727#include "debugmodule/debugmodule.h" 
    2828 
     29#include "libstreaming/MotuStreamProcessor.h" 
     30#include "libstreaming/MotuPort.h" 
     31 
    2932#include <string> 
    3033#include <stdint.h> 
     
    4245    , m_nodeId( nodeId ) 
    4346    , m_verboseLevel( verboseLevel ) 
     47    , m_id(0) 
     48    , m_receiveProcessor ( 0 ) 
     49    , m_transmitProcessor ( 0 ) 
     50     
    4451{ 
    4552    if ( m_verboseLevel ) { 
     
    115122} 
    116123 
    117  
     124int  
     125MotuDevice::getSamplingFrequency( ) { 
     126    /* 
     127     Implement the procedure to retrieve the samplerate here 
     128    */ 
     129    // FIXME:  
     130    return 44100; 
     131 
     132
    118133 
    119134bool 
    120135MotuDevice::setSamplingFrequency( ESamplingFrequency samplingFrequency ) 
    121136{ 
     137    /* 
     138     Implement the procedure to set the samplerate here 
     139    */ 
     140 
    122141    quadlet_t new_rate=0; 
    123142        int supported=true; 
     
    171190} 
    172191 
     192bool MotuDevice::setId( unsigned int id) { 
     193    debugOutput( DEBUG_LEVEL_VERBOSE, "Set id to %d...\n", id); 
     194    m_id=id; 
     195    return true; 
     196} 
     197 
    173198void 
    174199MotuDevice::showDevice() const 
    175200{ 
    176201    printf( "%s %s at node %d\n", 
    177                 m_configRom->getVendorName(),  
    178                 m_configRom->getModelName()
     202                m_configRom->getVendorName().c_str(),  
     203                m_configRom->getModelName().c_str()
    179204                m_nodeId ); 
    180205 
     
    182207 
    183208bool 
    184 MotuDevice::addXmlDescription( xmlNodePtr deviceNode ) 
    185 
    186     return true; 
    187 
     209MotuDevice::prepare() { 
     210 
     211    debugOutput(DEBUG_LEVEL_NORMAL, "Preparing MotuDevice...\n" ); 
     212 
     213        m_receiveProcessor=new FreebobStreaming::MotuReceiveStreamProcessor( 
     214                                 m_1394Service->getPort(), 
     215                                 getSamplingFrequency()); 
     216                                  
     217        // the first thing is to initialize the processor 
     218        // this creates the data structures 
     219        if(!m_receiveProcessor->init()) { 
     220                debugFatal("Could not initialize receive processor!\n"); 
     221                return false; 
     222         
     223        } 
     224 
     225    // now we add ports to the processor 
     226    debugOutput(DEBUG_LEVEL_VERBOSE,"Adding ports to receive processor\n"); 
     227         
     228        // TODO: change this into something based upon device detection/configuration 
     229         
     230    char *buff; 
     231    FreebobStreaming::Port *p=NULL; 
     232     
     233        // example of adding an audio port: 
     234    asprintf(&buff,"dev%d_cap_%s",m_id,"myportnamehere"); 
     235     
     236    p=new FreebobStreaming::MotuAudioPort( 
     237            buff, 
     238            FreebobStreaming::Port::E_Capture,  
     239            0 // you can add all other port specific stuff you  
     240              // need to pass by extending MotuXXXPort and MotuPortInfo 
     241    ); 
     242     
     243    free(buff); 
     244 
     245    if (!p) { 
     246        debugOutput(DEBUG_LEVEL_VERBOSE, "Skipped port %s\n",buff); 
     247    } else { 
     248 
     249        if (!m_receiveProcessor->addPort(p)) { 
     250            debugWarning("Could not register port with stream processor\n"); 
     251            return false; 
     252        } else { 
     253            debugOutput(DEBUG_LEVEL_VERBOSE, "Added port %s\n",buff); 
     254         
     255        } 
     256    } 
     257     
     258        // example of adding an midi port: 
     259    asprintf(&buff,"dev%d_cap_%s",m_id,"myportnamehere"); 
     260     
     261    p=new FreebobStreaming::MotuMidiPort( 
     262            buff, 
     263            FreebobStreaming::Port::E_Capture,  
     264            0 // you can add all other port specific stuff you  
     265              // need to pass by extending MotuXXXPort and MotuPortInfo 
     266    ); 
     267     
     268    free(buff); 
     269 
     270    if (!p) { 
     271        debugOutput(DEBUG_LEVEL_VERBOSE, "Skipped port %s\n",buff); 
     272    } else { 
     273 
     274        if (!m_receiveProcessor->addPort(p)) { 
     275            debugWarning("Could not register port with stream processor\n"); 
     276            return false; 
     277        } else { 
     278            debugOutput(DEBUG_LEVEL_VERBOSE, "Added port %s\n",buff); 
     279         
     280        } 
     281    } 
     282     
     283        // example of adding an control port: 
     284    asprintf(&buff,"dev%d_cap_%s",m_id,"myportnamehere"); 
     285     
     286    p=new FreebobStreaming::MotuControlPort( 
     287            buff, 
     288            FreebobStreaming::Port::E_Capture,  
     289            0 // you can add all other port specific stuff you  
     290              // need to pass by extending MotuXXXPort and MotuPortInfo 
     291    ); 
     292     
     293    free(buff); 
     294 
     295    if (!p) { 
     296        debugOutput(DEBUG_LEVEL_VERBOSE, "Skipped port %s\n",buff); 
     297    } else { 
     298 
     299        if (!m_receiveProcessor->addPort(p)) { 
     300            debugWarning("Could not register port with stream processor\n"); 
     301            return false; 
     302        } else { 
     303            debugOutput(DEBUG_LEVEL_VERBOSE, "Added port %s\n",buff); 
     304         
     305        } 
     306    } 
     307 
     308 
     309        // do the same for the transmit processor 
     310        m_transmitProcessor=new FreebobStreaming::MotuTransmitStreamProcessor( 
     311                                 m_1394Service->getPort(), 
     312                                 getSamplingFrequency()); 
     313                                  
     314        m_transmitProcessor->setVerboseLevel(getDebugLevel()); 
     315         
     316        if(!m_transmitProcessor->init()) { 
     317                debugFatal("Could not initialize transmit processor!\n"); 
     318                return false; 
     319         
     320        } 
     321 
     322    // now we add ports to the processor 
     323    debugOutput(DEBUG_LEVEL_VERBOSE,"Adding ports to transmit processor\n"); 
     324     
     325        // example of adding an audio port: 
     326        // we change the naming and the direction to E_Playback 
     327    asprintf(&buff,"dev%d_pbk_%s",m_id,"myportnamehere"); 
     328     
     329    p=new FreebobStreaming::MotuAudioPort( 
     330            buff, 
     331            FreebobStreaming::Port::E_Playback,  
     332            0 // you can add all other port specific stuff you  
     333              // need to pass by extending MotuXXXPort and MotuPortInfo 
     334    ); 
     335     
     336    free(buff); 
     337 
     338    if (!p) { 
     339        debugOutput(DEBUG_LEVEL_VERBOSE, "Skipped port %s\n",buff); 
     340    } else { 
     341 
     342        if (!m_transmitProcessor->addPort(p)) { 
     343            debugWarning("Could not register port with stream processor\n"); 
     344            return false; 
     345        } else { 
     346            debugOutput(DEBUG_LEVEL_VERBOSE, "Added port %s\n",buff); 
     347         
     348        } 
     349    } 
     350     
     351        // example of adding an midi port: 
     352    asprintf(&buff,"dev%d_pbk_%s",m_id,"myportnamehere"); 
     353     
     354    p=new FreebobStreaming::MotuMidiPort( 
     355            buff, 
     356            FreebobStreaming::Port::E_Playback,  
     357            0 // you can add all other port specific stuff you  
     358              // need to pass by extending MotuXXXPort and MotuPortInfo 
     359    ); 
     360     
     361    free(buff); 
     362 
     363    if (!p) { 
     364        debugOutput(DEBUG_LEVEL_VERBOSE, "Skipped port %s\n",buff); 
     365    } else { 
     366 
     367        if (!m_transmitProcessor->addPort(p)) { 
     368            debugWarning("Could not register port with stream processor\n"); 
     369            return false; 
     370        } else { 
     371            debugOutput(DEBUG_LEVEL_VERBOSE, "Added port %s\n",buff); 
     372         
     373        } 
     374    } 
     375     
     376        // example of adding an control port: 
     377    asprintf(&buff,"dev%d_pbk_%s",m_id,"myportnamehere"); 
     378     
     379    p=new FreebobStreaming::MotuControlPort( 
     380            buff, 
     381            FreebobStreaming::Port::E_Playback,  
     382            0 // you can add all other port specific stuff you  
     383              // need to pass by extending MotuXXXPort and MotuPortInfo 
     384    ); 
     385     
     386    free(buff); 
     387 
     388    if (!p) { 
     389        debugOutput(DEBUG_LEVEL_VERBOSE, "Skipped port %s\n",buff); 
     390    } else { 
     391 
     392        if (!m_transmitProcessor->addPort(p)) { 
     393            debugWarning("Could not register port with stream processor\n"); 
     394            return false; 
     395        } else { 
     396            debugOutput(DEBUG_LEVEL_VERBOSE, "Added port %s\n",buff); 
     397         
     398        } 
     399    } 
     400         
     401        return true; 
     402
     403 
     404int  
     405MotuDevice::getStreamCount() { 
     406        return 2; // one receive, one transmit 
     407
     408 
     409FreebobStreaming::StreamProcessor * 
     410MotuDevice::getStreamProcessorByIndex(int i) { 
     411        switch (i) { 
     412        case 0: 
     413                return m_receiveProcessor; 
     414        case 1: 
     415                return m_transmitProcessor; 
     416        default: 
     417                return NULL; 
     418        } 
     419        return 0; 
     420
     421 
     422int 
     423MotuDevice::startStreamByIndex(int i) { 
     424 
     425    // NOTE: this assumes that you have two streams 
     426        switch (i) { 
     427        case 0: 
     428        // TODO: do the stuff that is nescessary to make the device 
     429        // transmit a stream 
     430 
     431 
     432                // set the streamprocessor channel to the one obtained by  
     433                // the connection management 
     434                // IMPORTANT!! 
     435                m_receiveProcessor->setChannel(1); // TODO: change the channel NR 
     436                break; 
     437        case 1: 
     438        // TODO: do the stuff that is nescessary to make the device 
     439        // receive a stream 
     440 
     441                // set the streamprocessor channel to the one obtained by  
     442                // the connection management 
     443                // IMPORTANT!! 
     444                m_transmitProcessor->setChannel(0); // TODO: change the channel NR 
     445                break; 
     446                 
     447        default: // invalid index 
     448                return -1; 
     449        } 
     450 
     451        return 0; 
     452 
     453
     454 
     455int 
     456MotuDevice::stopStreamByIndex(int i) { 
     457        // TODO: connection management: break connection 
     458        // cfr the start function 
     459 
     460        return 0; 
     461
     462 
     463 
     464 
    188465 
    189466/* ======================================================================== */ 
  • branches/libfreebob-2.0/src/motu/motu_avdevice.h

    r208 r246  
    2828#include "libfreebob/xmlparser.h" 
    2929 
     30#include "libstreaming/MotuStreamProcessor.h" 
     31 
    3032#define MOTU_BASE_ADDR     0xfffff0000000ULL 
    3133#define MOTU_BASE_RATE_44100            (0<<4) 
     
    5153    virtual bool discover(); 
    5254    virtual ConfigRom& getConfigRom() const; 
    53     virtual bool addXmlDescription( xmlNodePtr deviceNode ); 
     55 
     56    // obsolete, will be removed soon, unused 
     57    virtual bool addXmlDescription( xmlNodePtr deviceNode ) {return true;}; 
     58 
     59    virtual void showDevice() const; 
     60 
    5461    virtual bool setSamplingFrequency( ESamplingFrequency samplingFrequency ); 
    55     virtual void showDevice() const; 
     62    virtual int getSamplingFrequency( ); 
     63 
     64    virtual bool setId(unsigned int id); 
     65 
     66    virtual int getStreamCount(); 
     67    virtual FreebobStreaming::StreamProcessor *getStreamProcessorByIndex(int i); 
     68 
     69    virtual bool prepare(); 
     70 
     71    virtual int startStreamByIndex(int i); 
     72    virtual int stopStreamByIndex(int i); 
    5673 
    5774protected: 
     
    6077    int              m_nodeId; 
    6178    int              m_verboseLevel; 
     79    unsigned int m_id; 
     80     
     81        FreebobStreaming::MotuReceiveStreamProcessor *m_receiveProcessor; 
     82        FreebobStreaming::MotuTransmitStreamProcessor *m_transmitProcessor; 
    6283 
    6384private: 
     85 
    6486        unsigned int ReadRegister(unsigned int reg); 
    6587        signed int WriteRegister(unsigned int reg, quadlet_t data);