Changeset 401

Show
Ignore:
Timestamp:
02/17/07 08:37:50 (17 years ago)
Author:
pieterpalmers
Message:

move some code from amdtp SP to SP base class

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/streaming-rework/src/libstreaming/AmdtpStreamProcessor.cpp

    r399 r401  
    361361    return RAW1394_ISO_ERROR; 
    362362 
    363 } 
    364  
    365 int64_t AmdtpTransmitStreamProcessor::getTimeUntilNextPeriodUsecs() { 
    366     uint64_t time_at_period=getTimeAtPeriod(); 
    367      
    368     uint64_t cycle_timer=m_handler->getCycleTimerTicks(); 
    369      
    370     // calculate the time until the next period 
    371     int64_t until_next=substractTicks(time_at_period,cycle_timer); 
    372      
    373     debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "=> TAP=%11llu, CTR=%11llu, UTN=%11lld\n", 
    374         time_at_period, cycle_timer, until_next 
    375         ); 
    376      
    377     // now convert to usecs 
    378     // don't use the mapping function because it only works 
    379     // for absolute times, not the relative time we are 
    380     // using here (which can also be negative). 
    381     return (int64_t)(((float)until_next) / TICKS_PER_USEC); 
    382 } 
    383  
    384 uint64_t AmdtpTransmitStreamProcessor::getTimeAtPeriodUsecs() { 
    385     // then we should convert this into usecs 
    386     return (uint64_t)((float)getTimeAtPeriod() * TICKS_PER_USEC); 
    387 } 
    388  
    389 uint64_t AmdtpTransmitStreamProcessor::getTimeAtPeriod() { 
    390     uint64_t next_period_boundary=m_data_buffer->getTimestampFromTail((m_nb_buffers-1) * m_period); 
    391      
    392     #ifdef DEBUG 
    393     uint64_t ts,fc; 
    394     m_data_buffer->getBufferTailTimestamp(&ts,&fc); 
    395      
    396     debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "=> NPD=%11lld, LTS=%11llu, FC=%5u, TPF=%f\n", 
    397         next_period_boundary, ts, fc, m_ticks_per_frame 
    398         ); 
    399     #endif 
    400      
    401     return next_period_boundary; 
    402363} 
    403364 
     
    699660} 
    700661 
    701 bool AmdtpTransmitStreamProcessor::canClientTransferFrames(unsigned int nbframes) { 
    702     // there has to be enough space to put the frames in 
    703     return m_ringbuffer_size_frames - m_data_buffer->getFrameCounter() > nbframes; 
    704 } 
    705  
    706662bool AmdtpTransmitStreamProcessor::putFrames(unsigned int nbframes, int64_t ts) { 
    707663    m_PeriodStat.mark(m_data_buffer->getBufferFill()); 
     
    10991055 
    11001056    return retval; 
    1101 } 
    1102  
    1103 int64_t AmdtpReceiveStreamProcessor::getTimeUntilNextPeriodUsecs() { 
    1104     uint64_t time_at_period=getTimeAtPeriod(); 
    1105      
    1106     uint64_t cycle_timer=m_handler->getCycleTimerTicks(); 
    1107      
    1108     // calculate the time until the next period 
    1109     int64_t until_next=substractTicks(time_at_period,cycle_timer); 
    1110      
    1111     debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "=> TAP=%11llu, CTR=%11llu, UTN=%11lld\n", 
    1112         time_at_period, cycle_timer, until_next 
    1113         ); 
    1114      
    1115     // now convert to usecs 
    1116     // don't use the mapping function because it only works 
    1117     // for absolute times, not the relative time we are 
    1118     // using here (which can also be negative). 
    1119     return (int64_t)(((float)until_next) / TICKS_PER_USEC); 
    1120 } 
    1121  
    1122 uint64_t AmdtpReceiveStreamProcessor::getTimeAtPeriodUsecs() { 
    1123     // then we should convert this into usecs 
    1124     return (uint64_t)((float)getTimeAtPeriod()*TICKS_PER_USEC); 
    1125 } 
    1126  
    1127 uint64_t AmdtpReceiveStreamProcessor::getTimeAtPeriod() { 
    1128     uint64_t next_period_boundary=m_data_buffer->getTimestampFromHead(m_period); 
    1129      
    1130     #ifdef DEBUG 
    1131     uint64_t ts,fc; 
    1132     m_data_buffer->getBufferTailTimestamp(&ts,&fc); 
    1133      
    1134     debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "=> NPD=%11lld, LTS=%11llu, FC=%5u, TPF=%f\n", 
    1135         next_period_boundary, ts, fc, m_ticks_per_frame 
    1136         ); 
    1137     #endif 
    1138      
    1139     return next_period_boundary; 
    11401057} 
    11411058 
     
    13551272} 
    13561273 
    1357 bool AmdtpReceiveStreamProcessor::canClientTransferFrames(unsigned int nbframes) { 
    1358     return m_data_buffer->getFrameCounter() >= (int) nbframes; 
    1359 } 
    1360  
    13611274bool AmdtpReceiveStreamProcessor::getFrames(unsigned int nbframes) { 
    13621275 
  • branches/streaming-rework/src/libstreaming/AmdtpStreamProcessor.h

    r399 r401  
    9595    bool prepareForEnable(uint64_t time_to_enable_at); 
    9696     
    97     bool canClientTransferFrames(unsigned int nbframes); 
    9897    bool putFrames(unsigned int nbframes, int64_t ts); ///< transfer the buffer contents from the client 
    9998 
     
    109108    unsigned int getMaxPacketSize() {return 4 * (2 + m_syt_interval * m_dimension);};  
    110109     
    111     int64_t getTimeUntilNextPeriodUsecs(); 
    112  
    113     uint64_t getTimeAtPeriodUsecs(); 
    114     uint64_t getTimeAtPeriod(); 
    115110    int getMinimalSyncDelay(); 
    116111     
     
    183178    bool prepareForStart(); 
    184179         
    185     bool canClientTransferFrames(unsigned int nbframes); 
    186180    bool getFrames(unsigned int nbframes); ///< transfer the buffer contents to the client 
    187181 
     
    199193    void dumpInfo(); 
    200194     
    201     int64_t getTimeUntilNextPeriodUsecs(); 
    202  
    203     uint64_t getTimeAtPeriodUsecs(); 
    204     uint64_t getTimeAtPeriod(); 
    205195    int getMinimalSyncDelay(); 
    206196         
  • branches/streaming-rework/src/libstreaming/StreamProcessor.cpp

    r399 r401  
    232232} 
    233233 
     234int64_t StreamProcessor::getTimeUntilNextPeriodUsecs() { 
     235    uint64_t time_at_period=getTimeAtPeriod(); 
     236     
     237    uint64_t cycle_timer=m_handler->getCycleTimerTicks(); 
     238     
     239    // calculate the time until the next period 
     240    int64_t until_next=substractTicks(time_at_period,cycle_timer); 
     241     
     242    debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "=> TAP=%11llu, CTR=%11llu, UTN=%11lld\n", 
     243        time_at_period, cycle_timer, until_next 
     244        ); 
     245     
     246    // now convert to usecs 
     247    // don't use the mapping function because it only works 
     248    // for absolute times, not the relative time we are 
     249    // using here (which can also be negative). 
     250    return (int64_t)(((float)until_next) / TICKS_PER_USEC); 
     251} 
     252 
     253uint64_t StreamProcessor::getTimeAtPeriodUsecs() { 
     254    return (uint64_t)((float)getTimeAtPeriod() * TICKS_PER_USEC); 
     255} 
     256 
    234257/** 
    235258 * Resets the xrun counter, in a atomic way. This 
     
    262285} 
    263286 
     287uint64_t ReceiveStreamProcessor::getTimeAtPeriod() { 
     288    uint64_t next_period_boundary=m_data_buffer->getTimestampFromHead(m_period); 
     289     
     290    #ifdef DEBUG 
     291    uint64_t ts,fc; 
     292    m_data_buffer->getBufferTailTimestamp(&ts,&fc); 
     293     
     294    debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "=> NPD=%11lld, LTS=%11llu, FC=%5u, TPF=%f\n", 
     295        next_period_boundary, ts, fc, m_ticks_per_frame 
     296        ); 
     297    #endif 
     298     
     299    return next_period_boundary; 
     300} 
     301 
     302bool ReceiveStreamProcessor::canClientTransferFrames(unsigned int nbframes) { 
     303    return m_data_buffer->getFrameCounter() >= (int) nbframes; 
     304} 
    264305 
    265306TransmitStreamProcessor::TransmitStreamProcessor( int port, int framerate)  
     
    278319} 
    279320 
    280 
     321uint64_t TransmitStreamProcessor::getTimeAtPeriod() { 
     322    uint64_t next_period_boundary=m_data_buffer->getTimestampFromTail((m_nb_buffers-1) * m_period); 
     323     
     324    #ifdef DEBUG 
     325    uint64_t ts,fc; 
     326    m_data_buffer->getBufferTailTimestamp(&ts,&fc); 
     327     
     328    debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "=> NPD=%11lld, LTS=%11llu, FC=%5u, TPF=%f\n", 
     329        next_period_boundary, ts, fc, m_ticks_per_frame 
     330        ); 
     331    #endif 
     332     
     333    return next_period_boundary; 
     334
     335 
     336bool TransmitStreamProcessor::canClientTransferFrames(unsigned int nbframes) { 
     337    // there has to be enough space to put the frames in 
     338    return m_data_buffer->getBufferSize() - m_data_buffer->getFrameCounter() > nbframes; 
     339
     340 
     341 
     342
  • branches/streaming-rework/src/libstreaming/StreamProcessor.h

    r399 r401  
    151151         *         false if it can't 
    152152         */ 
    153         virtual bool canClientTransferFrames(unsigned int nframes) {return true;}
     153        virtual bool canClientTransferFrames(unsigned int nframes) = 0
    154154         
    155155        /** 
     
    164164         * \return the time in usecs 
    165165         */ 
    166         virtual int64_t getTimeUntilNextPeriodUsecs() = 0
     166        int64_t getTimeUntilNextPeriodUsecs()
    167167        /** 
    168168         * \brief return the time of the next period boundary (in microseconds) 
     
    176176         * \return the time in usecs 
    177177         */ 
    178         virtual uint64_t getTimeAtPeriodUsecs() = 0
     178        uint64_t getTimeAtPeriodUsecs()
    179179 
    180180        /** 
     
    251251        virtual void setVerboseLevel(int l); 
    252252 
     253    uint64_t getTimeAtPeriod(); 
     254    bool canClientTransferFrames(unsigned int nframes); 
     255 
    253256protected: 
    254257    bool processWriteBlock(char *data, unsigned int nevents, unsigned int offset) {return true;}; 
     
    283286        virtual void setVerboseLevel(int l); 
    284287 
     288    uint64_t getTimeAtPeriod(); 
     289    bool canClientTransferFrames(unsigned int nframes); 
     290 
    285291protected: 
    286292    bool processReadBlock(char *data, unsigned int nevents, unsigned int offset) {return true;}; 
  • branches/streaming-rework/src/libutil/TimestampedBuffer.h

    r397 r401  
    100100    bool setEventsPerFrame(unsigned int s); 
    101101    bool setBufferSize(unsigned int s); 
     102    unsigned int getBufferSize() {return m_buffer_size;}; 
    102103     
    103104    bool setWrapValue(uint64_t w);