Changeset 1346

Show
Ignore:
Timestamp:
09/24/08 09:18:51 (12 years ago)
Author:
ppalmers
Message:

add one syncdelay worth of frames to the roundtrip loop. this should allow to use only 2 buffers instead of 3

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/libffado-2.0/src/libstreaming/generic/StreamProcessor.cpp

    r1344 r1346  
    220220    debugOutput(DEBUG_LEVEL_VERBOSE, "Setting SP %p SyncDelay to %u ticks, %u frames\n", this, d, frames); 
    221221    #endif 
    222     m_sync_delay = d; // FIXME: sync delay not necessary anymore 
     222    m_sync_delay = d; 
     223
     224 
     225unsigned int 
     226StreamProcessor::getSyncDelayFrames() { 
     227    unsigned int frames = (unsigned int)((float)m_sync_delay / getTicksPerFrame()); 
     228    return frames; 
    223229} 
    224230 
     
    15111517            if (getType() == ePT_Transmit) { 
    15121518                ringbuffer_size_frames = m_StreamProcessorManager.getNbBuffers() * m_StreamProcessorManager.getPeriodSize(); 
     1519 
     1520                // add sync delay 
     1521                int syncdelay_in_frames = m_StreamProcessorManager.getSyncSource().getSyncDelayFrames(); 
     1522                ringbuffer_size_frames += syncdelay_in_frames; 
     1523 
    15131524                debugOutput(DEBUG_LEVEL_VERBOSE, "Prefill transmit SP %p with %u frames\n", this, ringbuffer_size_frames); 
    15141525                // prefill the buffer 
  • branches/libffado-2.0/src/libstreaming/generic/StreamProcessor.h

    r1344 r1346  
    379379         */ 
    380380        unsigned int getSyncDelay() {return m_sync_delay;}; 
     381        unsigned int getSyncDelayFrames(); 
    381382        /** 
    382383         * sets the sync delay 
  • branches/libffado-2.0/src/libstreaming/StreamProcessorManager.cpp

    r1345 r1346  
    461461    // lower on average. 
    462462    max_of_min_delay += STREAMPROCESSORMANAGER_SIGNAL_DELAY_TICKS; 
    463     debugOutput( DEBUG_LEVEL_VERBOSE, " sync delay = %d ticks (%03us %04uc %04ut)...\n",  
    464         max_of_min_delay, 
    465         (unsigned int)TICKS_TO_SECS(max_of_min_delay), 
    466         (unsigned int)TICKS_TO_CYCLES(max_of_min_delay), 
    467         (unsigned int)TICKS_TO_OFFSET(max_of_min_delay)); 
     463 
    468464    m_SyncSource->setSyncDelay(max_of_min_delay); 
     465    unsigned int syncdelay = m_SyncSource->getSyncDelay(); 
     466    debugOutput( DEBUG_LEVEL_VERBOSE, " sync delay = %d => %d ticks (%03us %04uc %04ut)...\n",  
     467        max_of_min_delay, syncdelay, 
     468        (unsigned int)TICKS_TO_SECS(syncdelay), 
     469        (unsigned int)TICKS_TO_CYCLES(syncdelay), 
     470        (unsigned int)TICKS_TO_OFFSET(syncdelay)); 
    469471 
    470472    //STEP X: when we implement such a function, we can wait for a signal from the devices that they 
     
    599601    float rate = m_SyncSource->getTicksPerFrame(); 
    600602    int64_t delay_in_ticks=(int64_t)(((float)((m_nb_buffers-1) * m_period)) * rate); 
     603    // also add the sync delay 
     604    delay_in_ticks += m_SyncSource->getSyncDelay(); 
    601605    debugOutput( DEBUG_LEVEL_VERBOSE, "  initial time of transfer %010lld, rate %f...\n", 
    602606                m_time_of_transfer, rate); 
     
    11741178        // the data we are putting into the buffer is intended to be transmitted 
    11751179        // one ringbuffer size after it has been received 
    1176         int64_t transmit_timestamp = addTicks(m_time_of_transfer, one_ringbuffer_in_ticks); 
     1180 
     1181        // we also add one syncdelay as a safety margin, since that's the amount of time we can get 
     1182        // postponed. 
     1183        int syncdelay = m_SyncSource->getSyncDelay(); 
     1184        int64_t transmit_timestamp = addTicks(m_time_of_transfer, one_ringbuffer_in_ticks + syncdelay); 
    11771185 
    11781186        for ( StreamProcessorVectorIterator it = m_TransmitProcessors.begin(); 
     
    12501258        // the data we are putting into the buffer is intended to be transmitted 
    12511259        // one ringbuffer size after it has been received 
    1252         int64_t transmit_timestamp = addTicks(m_time_of_transfer, one_ringbuffer_in_ticks); 
     1260        // we also add one syncdelay as a safety margin, since that's the amount of time we can get 
     1261        // postponed. 
     1262        int syncdelay = m_SyncSource->getSyncDelay(); 
     1263        int64_t transmit_timestamp = addTicks(m_time_of_transfer, one_ringbuffer_in_ticks + syncdelay); 
    12531264 
    12541265        for ( StreamProcessorVectorIterator it = m_TransmitProcessors.begin();