Changeset 493

Show
Ignore:
Timestamp:
07/22/07 16:55:57 (17 years ago)
Author:
jwoithe
Message:

StreamProcessorManager?.cpp: MOTU requires larger ENABLE_DELAY_CYCLES to successfully start.
TimestampedBuffer?.cpp: MOTU needs more exact m_buffer_tail_timestamp.
MOTU: Make startup more reliable and nearly eliminate audio glitches in output.
Note that the changes to StreamProcessorManager?.cpp and TimestampedBuffer?.cpp are regarded as temporary while a more robust solution is devised following further investigations.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/src/libstreaming/MotuStreamProcessor.cpp

    r492 r493  
    6464  // too. 
    6565  if (CYCLE_TIMER_GET_CYCLES(sph) > now_cycles + 1000) { 
    66 debugOutput(DEBUG_LEVEL_VERBOSE, "now=%d, ct=%d\n", now_cycles, CYCLE_TIMER_GET_CYCLES(sph)); 
     66//debugOutput(DEBUG_LEVEL_VERBOSE, "now=%d, ct=%d\n", now_cycles, CYCLE_TIMER_GET_CYCLES(sph)); 
    6767    if (ts_sec) 
    6868      ts_sec--; 
     
    7171  } else 
    7272  if (now_cycles > CYCLE_TIMER_GET_CYCLES(sph) + 1000) { 
    73 debugOutput(DEBUG_LEVEL_VERBOSE, "inverted wrap: now=%d, ct=%d\n", now_cycles, CYCLE_TIMER_GET_CYCLES(sph)); 
     73//debugOutput(DEBUG_LEVEL_VERBOSE, "inverted wrap: now=%d, ct=%d\n", now_cycles, CYCLE_TIMER_GET_CYCLES(sph)); 
    7474    if (ts_sec == 127) 
    7575      ts_sec = 0; 
     
    193193// These are just copied from AmdtpStreamProcessor.  At some point we should 
    194194// verify that they make sense for the MOTU. 
    195 //            ts_head = substractTicks(ts_head, TICKS_PER_CYCLE); 
     195            ts_head = substractTicks(ts_head, TICKS_PER_CYCLE); 
    196196            // account for the number of cycles we are too late to enable 
    197197            ts_head = addTicks(ts_head, cycles_past_enable * TICKS_PER_CYCLE); 
    198198            // account for one extra packet of frames 
    199 //            ts_head = substractTicks(ts_head, 
    200 //              (uint32_t)((float)n_events * m_SyncSource->m_data_buffer->getRate()));  
     199            ts_head = substractTicks(ts_head, 
     200              (uint32_t)((float)n_events * m_SyncSource->m_data_buffer->getRate()));  
    201201 
    202202            m_data_buffer->setBufferTailTimestamp(ts_head); 
     
    347347 
    348348float ticks_per_frame = m_SyncSource->m_data_buffer->getRate(); 
     349//debugOutput(DEBUG_LEVEL_VERBOSE, "ticks per frame=%10.6f\n",ticks_per_frame); 
    349350        for (i=0; i<n_events; i++, quadlet += dbs) { 
    350351//FIXME: not sure which is best for the MOTU 
     
    11161117m_last_timestamp = sphRecvToFullTicks(last_sph, m_handler->getCycleTimer()); 
    11171118#endif 
     1119//debugOutput(DEBUG_LEVEL_VERBOSE,"ave ticks=%g\n",(m_last_timestamp-m_last_timestamp2)/8.0); 
    11181120                                                          
    11191121        // Signal that we're running 
     
    11331135            // the next (possible) sample is not this one, but lies 
    11341136            // SYT_INTERVAL * rate later 
    1135             float frame_size=m_framerate<=48000?8:(m_framerate<=96000?16:32); 
     1137            float frames_per_packet=m_framerate<=48000?8:(m_framerate<=96000?16:32); 
    11361138            uint64_t ts=addTicks(m_last_timestamp, 
    1137                                  (uint64_t)(frame_size * m_ticks_per_frame)); 
     1139                                 (uint64_t)(frames_per_packet * m_ticks_per_frame)); 
    11381140//            uint64_t ts=addTicks(m_last_timestamp, 
    11391141//                                 (uint64_t)(m_ticks_per_frame)); 
     
    11431145            // corresponding to the last frame which would have been added to the 
    11441146            // buffer this cycle if we weren't disabled. 
    1145 if (ts >= 128L* TICKS_PER_SECOND) 
    1146   ts -= 128L*TICKS_PER_SECOND; 
    1147 //            m_data_buffer->setBufferTailTimestamp(ts); 
    1148             m_data_buffer->setBufferTailTimestamp(m_last_timestamp); 
     1147            // 
     1148            // FIXME: in theory m_last_timestamp is already equal to the 
     1149            // timestamp of the last frame/sample in this packet since 
     1150            // that's what we used to set it in the first place.  However, 
     1151            // if m_last_timestamp is used to set the buffer tail we get a 
     1152            // series of "difference too large" warnings during the early 
     1153            // stages after enabling.  These tend to indicate that the 
     1154            // buffer timestamp is one packet out.  Using ts (which predicts 
     1155            // the timestamp of the last frame of the *next* packet) seems 
     1156            // to stop these warnings most of the time and allow for a 
     1157            // smoother startup. 
     1158            m_data_buffer->setBufferTailTimestamp(ts); 
     1159//            m_data_buffer->setBufferTailTimestamp(m_last_timestamp); 
    11491160//debugOutput(DEBUG_LEVEL_VERBOSE,"%p, last ts=%lld, ts=%lld, lts2=%lld\n", m_data_buffer, m_last_timestamp, ts, m_last_timestamp2); 
    11501161 
  • trunk/libffado/src/libstreaming/StreamProcessorManager.cpp

    r480 r493  
    3636#define ENABLE_TIMEOUT_MSEC 4000 
    3737 
    38 #define ENABLE_DELAY_CYCLES 100 
     38//#define ENABLE_DELAY_CYCLES 100 
     39#define ENABLE_DELAY_CYCLES 1000 
    3940 
    4041namespace Streaming { 
  • trunk/libffado/src/libutil/TimestampedBuffer.cpp

    r445 r493  
    807807    m_framecounter += nbframes; 
    808808 
    809     m_buffer_tail_timestamp=m_buffer_next_tail_timestamp; 
     809//    m_buffer_tail_timestamp=m_buffer_next_tail_timestamp; 
     810//    m_buffer_next_tail_timestamp += (int64_t)(m_dll_b * err + m_dll_e2); 
     811    m_buffer_tail_timestamp=ts; 
    810812    m_buffer_next_tail_timestamp += (int64_t)(m_dll_b * err + m_dll_e2); 
    811813