Changeset 1293

Show
Ignore:
Timestamp:
07/13/08 15:23:09 (13 years ago)
Author:
ppalmers
Message:

implement workaround for bogus timestamp calculation. should be fixed properly at some point.

Files:

Legend:

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

    r1292 r1293  
    390390 
    391391    if (result == eCRV_OK) { 
    392         #ifdef DEBUG 
     392//         #ifdef DEBUG 
    393393        int ticks_per_packet = (int)(getTicksPerFrame() * getNominalFramesPerPacket()); 
    394394        int diff = diffTicks(m_last_timestamp, m_last_timestamp2); 
     
    401401                        CYCLE_TIMER_GET_CYCLES(pkt_ctr), m_last_timestamp2, 
    402402                        m_last_timestamp, diff, ticks_per_packet); 
     403            // !!!HACK!!! FIXME: this is the result of a failure in wrapping/unwrapping somewhere 
     404            // it's definitely a bug. 
     405            // try to fix up the timestamp 
     406            int64_t last_timestamp_fixed; 
     407            // first try to add one second 
     408            last_timestamp_fixed = m_last_timestamp + TICKS_PER_SECOND; 
     409            diff = diffTicks(last_timestamp_fixed, m_last_timestamp2); 
     410            if(diff-ticks_per_packet < 50 && diff-ticks_per_packet > -50) { 
     411                debugWarning("cy %04u rather large TSP difference TS=%011llu => TS=%011llu (%d, nom %d)\n", 
     412                             CYCLE_TIMER_GET_CYCLES(pkt_ctr), m_last_timestamp2, 
     413                             m_last_timestamp, diff, ticks_per_packet); 
     414                debugWarning("HACK: fixed by adding one second of ticks. This is a bug being run-time fixed.\n"); 
     415                m_last_timestamp = last_timestamp_fixed; 
     416            } 
     417            // then try to subtract one second 
     418            last_timestamp_fixed = m_last_timestamp - TICKS_PER_SECOND; 
     419            if(last_timestamp_fixed >= 0) { 
     420                diff = diffTicks(last_timestamp_fixed, m_last_timestamp2); 
     421                if(diff-ticks_per_packet < 50 && diff-ticks_per_packet > -50) { 
     422                    debugWarning("cy %04u rather large TSP difference TS=%011llu => TS=%011llu (%d, nom %d)\n", 
     423                                CYCLE_TIMER_GET_CYCLES(pkt_ctr), m_last_timestamp2, 
     424                                m_last_timestamp, diff, ticks_per_packet); 
     425                    debugWarning("HACK: fixed by subtracing one second of ticks. This is a bug being run-time fixed.\n"); 
     426                    m_last_timestamp = last_timestamp_fixed; 
     427                } 
     428            } 
    403429        } 
    404430        debugOutputExtreme(DEBUG_LEVEL_VERY_VERBOSE, 
     
    407433                           m_last_timestamp2, m_last_timestamp,  
    408434                           diff, ticks_per_packet); 
    409         #endif 
     435//         #endif 
    410436 
    411437        debugOutputExtreme(DEBUG_LEVEL_VERY_VERBOSE, 
     
    906932StreamProcessor::shiftStream(int nbframes) 
    907933{ 
     934    // FIXME: this is not a good idea since the ISO thread is also writing the buffer 
     935    // resulting in multiple writers (not supported) 
    908936    bool result; 
    909937    if(nbframes == 0) return true; 
    910938    if(nbframes > 0) { 
     939        debugOutput(DEBUG_LEVEL_VERBOSE, 
     940                    "(%p) dropping %d frames\n", 
     941                    this, nbframes); 
    911942        result = m_data_buffer->dropFrames(nbframes); 
    912         SIGNAL_ACTIVITY_ALL; 
     943    } else { 
     944        result = false; 
    913945        return result; 
    914     } else { 
    915         result = true; 
     946        debugOutput(DEBUG_LEVEL_VERBOSE, 
     947                    "(%p) adding %d frames\n", 
     948                    this, nbframes); 
    916949        while(nbframes++) { 
    917950            result &= m_data_buffer->writeDummyFrame(); 
    918951        } 
    919         SIGNAL_ACTIVITY_ALL; 
    920         return result
    921     } 
     952    } 
     953    SIGNAL_ACTIVITY_ALL
     954    return result; 
    922955} 
    923956