Changeset 396 for branches

Show
Ignore:
Timestamp:
02/16/07 03:34:07 (15 years ago)
Author:
pieterpalmers
Message:

- fixed initialization of buffer timestamps such that xmit-only

sync generation works

Files:

Legend:

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

    r395 r396  
    10841084    return true; 
    10851085} 
     1086 
     1087// #define TEST_XMIT_ONLY 
    10861088 
    10871089#ifdef TEST_XMIT_ONLY 
  • branches/streaming-rework/src/libstreaming/AmdtpStreamProcessor.cpp

    r395 r396  
    179179            } 
    180180            #endif 
    181             debugOutput(DEBUG_LEVEL_VERBOSE,"XMIT TS SET: TS=%10lld, FC=%4d\n", 
    182                             ts_head, m_data_buffer->getFrameCounter()); 
     181            debugOutput(DEBUG_LEVEL_VERBOSE,"XMIT TS SET: TS=%10lld, LAG=%03d, FC=%4d\n", 
     182                            ts_head, sync_lag_cycles, m_data_buffer->getFrameCounter()); 
    183183        } else { 
    184184            debugOutput(DEBUG_LEVEL_VERY_VERBOSE, 
     
    237237#endif 
    238238 
    239     #ifdef DEBUG 
     239    #ifdef DEBUG_OFF 
    240240    if((cycle % 1000) == 0) { 
    241241        uint32_t timestamp_u=timestamp; 
     
    628628} 
    629629 
    630 bool AmdtpTransmitStreamProcessor::prepareForEnable() { 
     630bool AmdtpTransmitStreamProcessor::prepareForEnable(uint64_t time_to_enable_at) { 
    631631 
    632632    debugOutput(DEBUG_LEVEL_VERBOSE,"Preparing to enable...\n"); 
    633633 
    634     if (!StreamProcessor::prepareForEnable()) { 
     634    // for the transmit SP, we have to initialize the  
     635    // buffer timestamp to something sane, because this timestamp 
     636    // is used when it is SyncSource 
     637     
     638    // the time we initialize to will determine the time at which 
     639    // the first sample in the buffer will be sent, so we should 
     640    // make it at least 'time_to_enable_at' 
     641     
     642    uint64_t now=m_handler->getCycleTimer(); 
     643    unsigned int now_secs=CYCLE_TIMER_GET_SECS(now); 
     644     
     645    // check if a wraparound on the secs will happen between 
     646    // now and the time we start 
     647    if (CYCLE_TIMER_GET_CYCLES(now)>time_to_enable_at) { 
     648        // the start will happen in the next second 
     649        now_secs++; 
     650        if (now_secs>=128) now_secs=0; 
     651    } 
     652     
     653    uint64_t ts_head= now_secs*TICKS_PER_SECOND; 
     654    ts_head+=time_to_enable_at*TICKS_PER_CYCLE; 
     655     
     656    // we also add the nb of cycles we transmit in advance 
     657    ts_head=addTicks(ts_head, TRANSMIT_ADVANCE_CYCLES*TICKS_PER_CYCLE); 
     658     
     659    m_data_buffer->setBufferTailTimestamp(ts_head); 
     660 
     661 
     662    if (!StreamProcessor::prepareForEnable(time_to_enable_at)) { 
    635663        debugError("StreamProcessor::prepareForEnable failed\n"); 
    636664        return false; 
     
    10111039        } 
    10121040         
    1013         #ifdef DEBUG 
     1041        #ifdef DEBUG_OFF 
    10141042        if((cycle % 1000) == 0) { 
    10151043            uint32_t syt = (uint32_t)ntohs(packet->syt); 
  • branches/streaming-rework/src/libstreaming/AmdtpStreamProcessor.h

    r391 r396  
    9393    bool prepareForStart(); 
    9494     
    95     bool prepareForEnable(); 
     95    bool prepareForEnable(uint64_t time_to_enable_at); 
    9696     
    9797    bool canClientTransferFrames(unsigned int nbframes); 
  • branches/streaming-rework/src/libstreaming/StreamProcessor.cpp

    r395 r396  
    129129         
    130130} 
    131      
    132 bool StreamProcessor::prepareForEnable() { 
     131 
     132bool StreamProcessor::prepareForEnable(uint64_t time_to_enable_at) { 
    133133    debugOutput(DEBUG_LEVEL_VERBOSE," StreamProcessor::prepareForEnable for (%p)\n",this); 
    134     debugOutput(DEBUG_LEVEL_VERBOSE," Now                   : %011u\n",m_handler->getCycleTimerTicks()); 
     134    debugOutput(DEBUG_LEVEL_VERBOSE,"  Now                   : %011u\n",m_handler->getCycleTimerTicks()); 
     135    debugOutput(DEBUG_LEVEL_VERBOSE,"  Enable at             : %011u\n",time_to_enable_at); 
    135136    m_data_buffer->dumpInfo(); 
    136137    return true; 
     
    139140bool StreamProcessor::prepareForDisable() { 
    140141    debugOutput(DEBUG_LEVEL_VERBOSE," StreamProcessor::prepareForDisable for (%p)\n",this); 
    141     debugOutput(DEBUG_LEVEL_VERBOSE," Now                   : %011u\n",m_handler->getCycleTimerTicks()); 
     142    debugOutput(DEBUG_LEVEL_VERBOSE," Now                   : %011u\n",m_handler->getCycleTimerTicks()); 
    142143    m_data_buffer->dumpInfo(); 
    143144    return true; 
     
    235236     
    236237    if (diff<0) { 
    237         debugWarning("Request to enable streamprocessor %d cycles ago.\n",diff); 
     238        debugWarning("Request to enable streamprocessor %d cycles ago (now=%llu, cy=%llu).\n", 
     239            diff,now_cycles,time_to_enable_at); 
    238240    } 
    239241#endif 
  • branches/streaming-rework/src/libstreaming/StreamProcessor.h

    r394 r396  
    8484 
    8585    bool isRunning(); ///< returns true if there is some stream data processed 
     86     
     87    virtual bool prepareForEnable(uint64_t time_to_enable_at); 
     88    virtual bool prepareForDisable(); 
     89     
    8690    bool enable(uint64_t time_to_enable_at); ///< enable the stream processing  
    8791    bool disable(); ///< disable the stream processing  
     
    103107    virtual bool prepareForStop() {return true;}; 
    104108    virtual bool prepareForStart() {return true;}; 
    105      
    106     virtual bool prepareForEnable(); 
    107     virtual bool prepareForDisable(); 
     109 
    108110 
    109111public: 
  • branches/streaming-rework/src/libstreaming/StreamProcessorManager.cpp

    r395 r396  
    395395    if (enable_at > 8000) enable_at -= 8000; 
    396396 
    397     debugOutput( DEBUG_LEVEL_VERBOSE, " Sync Source StreamProcessor...\n"); 
    398     if (!m_SyncSource->prepareForEnable()) { 
    399             debugFatal("Could not prepare Sync Source StreamProcessor for enable()...\n"); 
    400         return false; 
    401     } 
    402  
    403     m_SyncSource->enable(enable_at); 
    404  
    405     debugOutput( DEBUG_LEVEL_VERBOSE, " All StreamProcessors...\n"); 
    406397    if (!enableStreamProcessors(enable_at)) { 
    407398        debugFatal("Could not enable StreamProcessors...\n"); 
     
    556547 * @return true if successful, false otherwise 
    557548 */ 
    558 bool StreamProcessorManager::enableStreamProcessors(unsigned int time_to_enable_at) { 
     549bool StreamProcessorManager::enableStreamProcessors(uint64_t time_to_enable_at) { 
     550    debugOutput( DEBUG_LEVEL_VERBOSE, "Enabling StreamProcessors at %llu...\n", time_to_enable_at); 
     551 
     552    debugOutput( DEBUG_LEVEL_VERBOSE, " Sync Source StreamProcessor (%p)...\n",m_SyncSource); 
     553    debugOutput( DEBUG_LEVEL_VERBOSE, "  Prepare...\n"); 
     554    if (!m_SyncSource->prepareForEnable(time_to_enable_at)) { 
     555            debugFatal("Could not prepare Sync Source StreamProcessor for enable()...\n"); 
     556        return false; 
     557    } 
     558 
     559    debugOutput( DEBUG_LEVEL_VERBOSE, "  Enable...\n"); 
     560    m_SyncSource->enable(time_to_enable_at); 
     561     
     562    debugOutput( DEBUG_LEVEL_VERBOSE, " Other StreamProcessors...\n"); 
     563     
    559564    // we prepare the streamprocessors for enable 
    560565    for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin(); 
    561566            it != m_ReceiveProcessors.end(); 
    562             ++it ) {             
    563         (*it)->prepareForEnable(); 
     567            ++it ) { 
     568        if(*it != m_SyncSource) { 
     569            debugOutput( DEBUG_LEVEL_VERBOSE, " Prepare Receive SP (%p)...\n",*it); 
     570            (*it)->prepareForEnable(time_to_enable_at); 
     571        } 
    564572    } 
    565573 
     
    567575            it != m_TransmitProcessors.end(); 
    568576            ++it ) { 
    569         (*it)->prepareForEnable(); 
     577        if(*it != m_SyncSource) { 
     578            debugOutput( DEBUG_LEVEL_VERBOSE, " Prepare Transmit SP (%p)...\n",*it); 
     579            (*it)->prepareForEnable(time_to_enable_at); 
     580        } 
    570581    } 
    571582 
     
    574585            it != m_ReceiveProcessors.end(); 
    575586            ++it ) {             
    576         (*it)->enable(time_to_enable_at); 
     587        if(*it != m_SyncSource) { 
     588            debugOutput( DEBUG_LEVEL_VERBOSE, " Enable Receive SP (%p)...\n",*it); 
     589            (*it)->enable(time_to_enable_at); 
     590        } 
    577591    } 
    578592 
     
    580594            it != m_TransmitProcessors.end(); 
    581595            ++it ) { 
    582         (*it)->enable(time_to_enable_at); 
     596        if(*it != m_SyncSource) { 
     597            debugOutput( DEBUG_LEVEL_VERBOSE, " Enable Transmit SP (%p)...\n",*it); 
     598            (*it)->enable(time_to_enable_at); 
     599        } 
    583600    } 
    584601 
  • branches/streaming-rework/src/libstreaming/StreamProcessorManager.h

    r390 r396  
    7070    bool unregisterProcessor(StreamProcessor *processor); ///< stop managing a streamprocessor 
    7171 
    72     bool enableStreamProcessors(unsigned int time_to_enable_at); /// enable registered StreamProcessors 
     72    bool enableStreamProcessors(uint64_t time_to_enable_at); /// enable registered StreamProcessors 
    7373    bool disableStreamProcessors(); /// disable registered StreamProcessors 
    7474