Changeset 545

Show
Ignore:
Timestamp:
08/21/07 08:19:33 (14 years ago)
Author:
ppalmers
Message:

- Remove name parameter from PortInfo? since it's already in Port

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/echoaudio/src/libstreaming/AmdtpPort.h

    r445 r545  
    5353                   enum E_Formats format) 
    5454    : AudioPort(name, direction), 
    55       AmdtpPortInfo(name, position, location, format) 
     55      AmdtpPortInfo(position, location, format) 
    5656    {}; 
    5757 
     
    8080                   enum E_Formats format) 
    8181        : MidiPort(name, direction), 
    82           AmdtpPortInfo(name, position, location, format) 
     82          AmdtpPortInfo(position, location, format) 
    8383    {}; 
    8484 
  • branches/echoaudio/src/libstreaming/AmdtpPortInfo.h

    r445 r545  
    5454    }; 
    5555 
    56     AmdtpPortInfo(std::string name, int position, int location, enum E_Formats format) 
    57       : m_name(name), m_position(position), m_location(location), m_format(format) 
     56    AmdtpPortInfo( int position, int location, enum E_Formats format) 
     57      : m_position(position), m_location(location), m_format(format) 
    5858    {}; 
    5959    virtual ~AmdtpPortInfo() {}; 
    6060 
    6161 
    62     std::string getName() {return m_name;}; 
    6362    int getLocation()     {return m_location;}; 
    6463    int getPosition()     {return m_position;}; 
     
    6665 
    6766protected: 
    68     std::string m_name; 
    69  
    7067    int m_position; 
    7168    int m_location; 
  • branches/echoaudio/src/libstreaming/MotuPort.h

    r445 r545  
    5252                   int size) 
    5353    : AudioPort(name, direction), 
    54       MotuPortInfo(name, position, size) // TODO: add more port information parameters here if nescessary 
     54      MotuPortInfo( position, size) // TODO: add more port information parameters here if nescessary 
    5555    {}; 
    5656 
     
    7676                   int position) 
    7777        : MidiPort(name, direction), 
    78           MotuPortInfo(name, position, 0)  // TODO: add more port information parameters here if nescessary 
     78          MotuPortInfo(position, 0)  // TODO: add more port information parameters here if nescessary 
    7979    {}; 
    8080 
  • branches/echoaudio/src/libstreaming/MotuPortInfo.h

    r445 r545  
    6060     * the name parameter is mandatory 
    6161     * 
    62      * @param name Port name 
    6362     * @param position Start position of port's data in iso event 
    6463     * @param format Format of data in iso event 
     
    6665     * @return 
    6766     */ 
    68     MotuPortInfo(std::string name, int position, int size) 
    69       : m_name(name), m_position(position), m_size(size) 
     67    MotuPortInfo( int position, int size) 
     68      : m_position(position), m_size(size) 
    7069    {}; 
    7170    virtual ~MotuPortInfo() {}; 
    7271 
    7372 
    74     std::string getName() {return m_name;}; 
    7573    int getPosition()     {return m_position;}; 
    7674    int getSize()         {return m_size;}; 
    7775 
    7876protected: 
    79     std::string m_name; 
    8077 
    8178    int m_position; 
  • branches/echoaudio/src/libstreaming/Port.cpp

    r445 r545  
    3535    m_BufferType(E_PointerBuffer), 
    3636    m_disabled(true), 
    37     m_initialized(false), 
    3837    m_buffersize(0), 
    3938    m_eventsize(0), 
     
    4948    m_rate_counter(0), 
    5049    m_rate_counter_minimum(0), 
    51     m_average_ratecontrol(false) 
    52  
     50    m_average_ratecontrol(false), 
     51    m_State(E_Created) 
    5352{ 
    5453 
     
    6362 */ 
    6463bool Port::init() { 
    65     if (m_initialized) { 
    66         debugFatal("Port already initialized... (%s)\n",m_Name.c_str()); 
     64    if (m_State != E_Created) { 
     65        debugFatal("Port (%s) not in E_Created state: %d\n",m_Name.c_str(),m_State); 
    6766        return false; 
    6867    } 
     
    9897    } 
    9998 
    100     m_initialized=true; 
    101  
    10299    m_eventsize=getEventSize(); // this won't change, so cache it 
    103  
    104     return m_initialized; 
     100     
     101    m_State = E_Initialized; 
     102    return true; 
    105103} 
    106104 
     
    112110}; 
    113111 
     112void Port::show() { 
     113    debugOutput(DEBUG_LEVEL_VERBOSE,"Name          : %s\n", m_Name.c_str()); 
     114    debugOutput(DEBUG_LEVEL_VERBOSE,"Signal Type   : %d\n", m_SignalType); 
     115    debugOutput(DEBUG_LEVEL_VERBOSE,"Buffer Type   : %d\n", m_BufferType); 
     116    debugOutput(DEBUG_LEVEL_VERBOSE,"Enabled?      : %d\n", m_disabled); 
     117    debugOutput(DEBUG_LEVEL_VERBOSE,"State?        : %d\n", m_State); 
     118    debugOutput(DEBUG_LEVEL_VERBOSE,"Buffer Size   : %d\n", m_buffersize); 
     119    debugOutput(DEBUG_LEVEL_VERBOSE,"Event Size    : %d\n", m_eventsize); 
     120    debugOutput(DEBUG_LEVEL_VERBOSE,"Data Type     : %d\n", m_DataType); 
     121    debugOutput(DEBUG_LEVEL_VERBOSE,"Port Type     : %d\n", m_PortType); 
     122    debugOutput(DEBUG_LEVEL_VERBOSE,"Direction     : %d\n", m_Direction); 
     123    debugOutput(DEBUG_LEVEL_VERBOSE,"Rate Control? : %d\n", m_do_ratecontrol); 
     124} 
    114125 
    115126void Port::setVerboseLevel(int l) { 
     
    120131    debugOutput( DEBUG_LEVEL_VERBOSE, "Setting name to %s for port %s\n",name.c_str(),m_Name.c_str()); 
    121132 
    122     if (m_initialized) { 
    123         debugFatal("Port already initialized... (%s)\n",m_Name.c_str()); 
     133    if (m_State != E_Created) { 
     134        debugFatal("Port (%s) not in E_Created state: %d\n",m_Name.c_str(),m_State); 
    124135        return false; 
    125136    } 
     
    132143bool Port::setBufferSize(unsigned int newsize) { 
    133144    debugOutput( DEBUG_LEVEL_VERBOSE, "Setting buffersize to %d for port %s\n",newsize,m_Name.c_str()); 
    134     if (m_initialized) { 
    135         debugFatal("Port already initialized... (%s)\n",m_Name.c_str()); 
     145    if (m_State != E_Created) { 
     146        debugFatal("Port (%s) not in E_Created state: %d\n",m_Name.c_str(),m_State); 
    136147        return false; 
    137148    } 
     
    157168bool Port::setDataType(enum E_DataType d) { 
    158169    debugOutput( DEBUG_LEVEL_VERBOSE, "Setting datatype to %d for port %s\n",(int) d,m_Name.c_str()); 
    159     if (m_initialized) { 
    160         debugFatal("Port already initialized... (%s)\n",m_Name.c_str()); 
     170    if (m_State != E_Created) { 
     171        debugFatal("Port (%s) not in E_Created state: %d\n",m_Name.c_str(),m_State); 
    161172        return false; 
    162173    } 
     
    190201bool Port::setSignalType(enum E_SignalType s) { 
    191202    debugOutput( DEBUG_LEVEL_VERBOSE, "Setting signaltype to %d for port %s\n",(int)s,m_Name.c_str()); 
    192     if (m_initialized) { 
    193         debugFatal("Port already initialized... (%s)\n",m_Name.c_str()); 
     203    if (m_State != E_Created) { 
     204        debugFatal("Port (%s) not in E_Created state: %d\n",m_Name.c_str(),m_State); 
    194205        return false; 
    195206    } 
     
    223234bool Port::setBufferType(enum E_BufferType b) { 
    224235    debugOutput( DEBUG_LEVEL_VERBOSE, "Setting buffer type to %d for port %s\n",(int)b,m_Name.c_str()); 
    225     if (m_initialized) { 
    226         debugFatal("Port already initialized... (%s)\n",m_Name.c_str()); 
     236    if (m_State != E_Created) { 
     237        debugFatal("Port (%s) not in E_Created state: %d\n",m_Name.c_str(),m_State); 
    227238        return false; 
    228239    } 
     
    257268    // If called on an initialised stream but the request isn't for a change silently 
    258269    // allow it (relied on by C API as used by jack backend driver) 
    259     if (m_initialized && m_use_external_buffer==b) 
     270    if (m_State==E_Initialized && m_use_external_buffer==b) 
    260271        return true; 
    261272 
    262273    debugOutput( DEBUG_LEVEL_VERBOSE, "Setting external buffer use to %d for port %s\n",(int)b,m_Name.c_str()); 
    263274 
    264     if (m_initialized) { 
    265         debugFatal("Port already initialized... (%s)\n",m_Name.c_str()); 
     275    if (m_State != E_Created) { 
     276        debugFatal("Port (%s) not in E_Created state: %d\n",m_Name.c_str(),m_State); 
    266277        return false; 
    267278    } 
     
    284295/** 
    285296 * Set the external buffer address. 
    286  * only call this when specifying an external buffer before init() 
     297 * only call this when you have specified that you will use 
     298 * an external buffer before doing the init() 
    287299 * 
    288300 * @param buff 
     
    296308// buffer handling api's for ringbuffers 
    297309bool Port::writeEvent(void *event) { 
    298     assert(m_BufferType==E_RingBuffer); 
     310 
     311#ifdef DEBUG 
     312    if (m_State != E_Initialized) { 
     313        debugFatal("Port (%s) not in E_Initialized state: %d\n",m_Name.c_str(),m_State); 
     314        return false; 
     315    } 
     316     
     317    if(m_BufferType!=E_RingBuffer) { 
     318        debugError("operation not allowed on non E_RingBuffer ports\n"); 
     319        show(); 
     320        return false; 
     321    } 
    299322    assert(m_ringbuffer); 
     323#endif 
    300324 
    301325    debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "Writing event %08X with size %d to port %s\n",*((quadlet_t *)event),m_eventsize, m_Name.c_str()); 
     
    305329 
    306330bool Port::readEvent(void *event) { 
     331 
     332#ifdef DEBUG 
     333    if (m_State != E_Initialized) { 
     334        debugFatal("Port (%s) not in E_Initialized state: %d\n",m_Name.c_str(),m_State); 
     335        return false; 
     336    } 
     337     
     338    if(m_BufferType!=E_RingBuffer) { 
     339        debugError("operation not allowed on non E_RingBuffer ports\n"); 
     340        show(); 
     341        return false; 
     342    } 
    307343    assert(m_ringbuffer); 
    308  
     344#endif 
     345 
     346     
    309347    unsigned int read=ffado_ringbuffer_read(m_ringbuffer, (char *)event, m_eventsize); 
    310  
     348     
    311349    debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "Reading event %X with size %d from port %s\n",*((quadlet_t *)event),m_eventsize,m_Name.c_str()); 
     350 
     351 
    312352    return (read==m_eventsize); 
    313353} 
    314354 
    315355int Port::writeEvents(void *event, unsigned int nevents) { 
    316     assert(m_BufferType==E_RingBuffer); 
     356 
     357#ifdef DEBUG 
     358    if (m_State != E_Initialized) { 
     359        debugFatal("Port (%s) not in E_Initialized state: %d\n",m_Name.c_str(),m_State); 
     360        return false; 
     361    } 
     362     
     363    if(m_BufferType!=E_RingBuffer) { 
     364        debugError("operation not allowed on non E_RingBuffer ports\n"); 
     365        show(); 
     366        return false; 
     367    } 
    317368    assert(m_ringbuffer); 
     369#endif 
     370 
    318371 
    319372    unsigned int bytes2write=m_eventsize*nevents; 
     
    338391 
    339392int Port::readEvents(void *event, unsigned int nevents) { 
     393 
     394#ifdef DEBUG 
     395    if (m_State != E_Initialized) { 
     396        debugFatal("Port (%s) not in E_Initialized state: %d\n",m_Name.c_str(),m_State); 
     397        return false; 
     398    } 
     399    if(m_BufferType!=E_RingBuffer) { 
     400        debugError("operation not allowed on non E_RingBuffer ports\n"); 
     401        show(); 
     402        return false; 
     403    } 
    340404    assert(m_ringbuffer); 
     405#endif 
     406 
    341407 
    342408    unsigned int bytes2read=m_eventsize*nevents; 
  • branches/echoaudio/src/libstreaming/Port.h

    r445 r545  
    270270    int readEvents(void *event, unsigned int nevents); ///< read multiple events 
    271271 
    272      virtual void setVerboseLevel(int l); 
    273  
     272    virtual void setVerboseLevel(int l); 
     273    virtual void show(); 
     274     
    274275protected: 
    275276    std::string m_Name; ///< Port name, [at construction] 
     
    279280 
    280281    bool m_disabled; ///< is the port disabled?, [anytime] 
    281     bool m_initialized; ///< is the port initialized? [after init()] 
    282282 
    283283    unsigned int m_buffersize; 
     
    306306 
    307307    DECLARE_DEBUG_MODULE; 
    308  
     308     
     309    // the state machine 
     310    protected: 
     311        enum EStates { 
     312            E_Created, 
     313            E_Initialized, 
     314            E_Prepared, 
     315            E_Running, 
     316            E_Error 
     317        }; 
     318 
     319        enum EStates m_State; 
    309320}; 
    310321