Changeset 1165

Show
Ignore:
Timestamp:
05/11/08 17:58:19 (12 years ago)
Author:
ppalmers
Message:

improve library behavior in bad situations

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/src/genericavc/avc_avdevice.cpp

    r1154 r1165  
    718718        Streaming::StreamProcessor *p=m_receiveProcessors.at(n); 
    719719 
     720        // can't stop it if it's not running 
     721        if(p->getChannel() == -1) { 
     722            debugOutput(DEBUG_LEVEL_VERBOSE, "SP %d not running\n",i); 
     723            return true; 
     724        } 
     725 
    720726        if(snoopMode) { 
    721727 
     
    735741        Streaming::StreamProcessor *p=m_transmitProcessors.at(n); 
    736742 
     743        // can't stop it if it's not running 
     744        if(p->getChannel() == -1) { 
     745            debugOutput(DEBUG_LEVEL_VERBOSE, "SP %d not running\n",i); 
     746            return true; 
     747        } 
     748 
    737749        if(snoopMode) { 
    738750 
  • trunk/libffado/src/libieee1394/IsoHandler.cpp

    r1135 r1165  
    366366                    unsigned char channel, unsigned char tag, unsigned char sy, 
    367367                    unsigned int cycle, unsigned int dropped, unsigned int skipped) { 
     368 
     369    // keep track of dropped cycles 
     370    int dropped_cycles = 0; 
     371    if (m_last_cycle != (int)cycle && m_last_cycle != -1) { 
     372        dropped_cycles = diffCycles(cycle, m_last_cycle) - 1; 
     373        #ifdef DEBUG 
     374        if (dropped_cycles < 0) { 
     375            debugWarning("(%p) dropped < 1 (%d), cycle: %d, last_cycle: %d, dropped: %d, 'skipped'=%u\n",  
     376                         this, dropped_cycles, cycle, m_last_cycle, dropped, skipped); 
     377        } 
     378        if (dropped_cycles > 0) { 
     379            debugOutput(DEBUG_LEVEL_NORMAL, 
     380                        "(%p) dropped %d packets on cycle %u, 'dropped'=%u, 'skipped'=%u, cycle=%d, m_last_cycle=%d\n", 
     381                        this, dropped_cycles, cycle, dropped, skipped, cycle, m_last_cycle); 
     382            m_dropped += dropped_cycles; 
     383        } 
     384        #endif 
     385    } 
     386    m_last_cycle = cycle; 
    368387 
    369388    uint32_t pkt_ctr = cycle << 12; 
     
    408427    #ifdef DEBUG 
    409428    if( (CYCLE_TIMER_GET_CYCLES(m_last_now) < cycle) 
    410         && diffCycles(CYCLE_TIMER_GET_CYCLES(m_last_now), cycle) < 0) { 
    411         debugWarning("Special non-unwrapping happened\n"); 
     429        && diffCycles(CYCLE_TIMER_GET_CYCLES(m_last_now), cycle) < 0 
     430        // ignore this on dropped cycles, since it's normal 
     431        // that now is ahead on the received packets (as we miss packets) 
     432        && dropped_cycles == 0)  
     433    { 
     434        debugOutput(DEBUG_LEVEL_VERBOSE, "Special non-unwrapping happened\n"); 
    412435    }     
    413436    #endif 
    414      
    415437    pkt_ctr |= (now_secs & 0x7F) << 25; 
    416  
    417  
    418438 
    419439    #if ISOHANDLER_CHECK_CTR_RECONSTRUCTION 
     
    457477    } 
    458478    #endif 
    459  
    460     // keep track of dropped cycles 
    461     int dropped_cycles = 0; 
    462     if (m_last_cycle != (int)cycle && m_last_cycle != -1) { 
    463         dropped_cycles = diffCycles(cycle, m_last_cycle) - 1; 
    464         #ifdef DEBUG 
    465         if (dropped_cycles < 0) { 
    466             debugWarning("(%p) dropped < 1 (%d), cycle: %d, last_cycle: %d, dropped: %d, 'skipped'=%u\n",  
    467                          this, dropped_cycles, cycle, m_last_cycle, dropped, skipped); 
    468         } 
    469         if (dropped_cycles > 0) { 
    470             debugOutput(DEBUG_LEVEL_NORMAL, 
    471                         "(%p) dropped %d packets on cycle %u, 'dropped'=%u, 'skipped'=%u, cycle=%d, m_last_cycle=%d\n", 
    472                         this, dropped_cycles, cycle, dropped, skipped, cycle, m_last_cycle); 
    473             m_dropped += dropped_cycles; 
    474         } 
    475         #endif 
    476     } 
    477     m_last_cycle = cycle; 
    478479 
    479480    // iterate the client if required 
  • trunk/libffado/src/libstreaming/generic/StreamProcessor.cpp

    r1164 r1165  
    327327 
    328328    // check whether we are waiting for a stream to be enabled 
    329     else if(m_state == ePS_WaitingForStreamEnable) { 
     329    else if(m_state == ePS_WaitingForStreamEnable 
     330            && m_next_state == ePS_WaitingForStreamEnable) { 
    330331        // we then check whether we have to switch on this cycle 
    331332        if (diffCycles(CYCLE_TIMER_GET_CYCLES(pkt_ctr), m_cycle_to_switch_state) >= 0) { 
     
    567568    } 
    568569    // check whether we are waiting for a stream to be enabled 
    569     else if(m_state == ePS_WaitingForStreamEnable) { 
     570    else if(m_state == ePS_WaitingForStreamEnable 
     571            && m_next_state == ePS_WaitingForStreamEnable) { 
    570572        // we then check whether we have to switch on this cycle 
    571573        if (diffCycles(CYCLE_TIMER_GET_CYCLES(pkt_ctr), m_cycle_to_switch_state) >= 0) { 
     
    11011103        debugOutput(DEBUG_LEVEL_VERBOSE, " %p already in DryRunning state\n", this); 
    11021104        return true; 
     1105    } else if (m_state == ePS_WaitingForStreamEnable) { 
     1106        debugOutput(DEBUG_LEVEL_VERBOSE, " %p still waiting to switch to Running state\n", this); 
     1107        // this will happen immediately 
     1108        return scheduleStateTransition(ePS_DryRunning, tx); 
    11031109    } else if (m_state == ePS_WaitingForStreamDisable) { 
    11041110        debugOutput(DEBUG_LEVEL_VERBOSE, " %p already waiting to switch to DryRunning state\n", this); 
  • trunk/libffado/src/libstreaming/StreamProcessorManager.cpp

    r1149 r1165  
    321321} 
    322322 
    323 bool StreamProcessorManager::startDryRunning() { 
     323bool 
     324StreamProcessorManager::startDryRunning() 
     325
    324326    debugOutput( DEBUG_LEVEL_VERBOSE, "Putting StreamProcessor streams into dry-running state...\n"); 
    325327    debugOutput( DEBUG_LEVEL_VERBOSE, " Schedule start dry-running...\n"); 
  • trunk/libffado/src/libutil/SystemTimeSource.cpp

    r1083 r1165  
    5858                (int64_t)ts.tv_sec, (int64_t)ts.tv_nsec); 
    5959    int err = clock_nanosleep(CLOCK_REALTIME, TIMER_ABSTIME, &ts, NULL); 
     60    if(err) { 
     61        // maybe signal occurred, but we're going to ignore that 
     62    } 
    6063    debugOutputExtreme(DEBUG_LEVEL_VERBOSE, 
    6164                "back with err=%d\n", 
  • trunk/libffado/src/libutil/Watchdog.cpp

    r1027 r1165  
    169169Watchdog::~Watchdog() 
    170170{ 
     171    // kill threads instead of stoping them since  
     172    // they are sleeping 
    171173    if (m_CheckThread) { 
    172174        //m_CheckThread->Stop();