Changeset 708 for branches

Show
Ignore:
Timestamp:
11/04/07 09:32:40 (13 years ago)
Author:
ppalmers
Message:

some more startup checks

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/ppalmers-streaming/src/libstreaming/StreamProcessorManager.cpp

    r707 r708  
    3030#include <assert.h> 
    3131 
    32 #define CYCLES_TO_SLEEP_AFTER_RUN_SIGNAL 5 
    33  
    3432#define RUNNING_TIMEOUT_MSEC 4000 
    3533#define PREPARE_TIMEOUT_MSEC 4000 
    3634#define ENABLE_TIMEOUT_MSEC 4000 
    37  
    38 //#define ENABLE_DELAY_CYCLES 100 
    39 #define ENABLE_DELAY_CYCLES 1000 
    4035 
    4136namespace Streaming { 
     
    436431    debugOutput( DEBUG_LEVEL_VERBOSE, "Enabling StreamProcessors...\n"); 
    437432 
    438     uint64_t now=m_SyncSource->getTimeNow(); // fixme: should be in usecs, not ticks 
    439  
    440433    // FIXME: this should not be in cycles, but in 'time' 
    441434    // FIXME: remove the timestamp 
    442     unsigned int enable_at=TICKS_TO_CYCLES(now)+ENABLE_DELAY_CYCLES; 
    443     if (enable_at > 8000) enable_at -= 8000; 
    444  
    445     if (!enableStreamProcessors(enable_at)) { 
     435    if (!enableStreamProcessors(0)) { 
    446436        debugFatal("Could not enable StreamProcessors...\n"); 
    447437        return false; 
     
    449439 
    450440    debugOutput( DEBUG_LEVEL_VERBOSE, "Running dry for a while...\n"); 
     441    #define MAX_DRYRUN_CYCLES               20 
     442    #define MIN_SUCCESSFUL_DRYRUN_CYCLES    4 
    451443    // run some cycles 'dry' such that everything can stabilize 
    452     int nb_dryrun_cycles=10; 
    453     bool no_xrun; 
    454     while(nb_dryrun_cycles--) { 
     444    int nb_dryrun_cycles_left = MAX_DRYRUN_CYCLES; 
     445    int nb_succesful_cycles = 0; 
     446    while(nb_dryrun_cycles_left > 0 && 
     447          nb_succesful_cycles < MIN_SUCCESSFUL_DRYRUN_CYCLES ) { 
     448 
    455449        waitForPeriod(); 
    456         m_TransmitProcessors.at(0)->m_PacketStat.dumpInfo(); 
    457         no_xrun = dryRun(); // dry run both receive and xmit 
    458  
    459         if (!no_xrun)
     450 
     451        if (dryRun()) { 
     452            nb_succesful_cycles++; 
     453        } else
    460454            debugOutput( DEBUG_LEVEL_VERBOSE, " This dry-run was not xrun free...\n" ); 
    461455            resetXrunCounters(); 
     456            nb_succesful_cycles = 0; 
    462457            // FIXME: xruns can screw up the framecounter accounting. do something more sane here 
    463458        } 
    464     } 
     459        nb_dryrun_cycles_left--; 
     460    } 
     461 
     462    if(nb_dryrun_cycles_left == 0) { 
     463        debugOutput( DEBUG_LEVEL_VERBOSE, " max # dry-run cycles achieved without steady-state...\n" ); 
     464        return false; 
     465    } 
     466    debugOutput( DEBUG_LEVEL_VERBOSE, " dry-run resulted in steady-state...\n" ); 
    465467 
    466468    // now we should clear the xrun flags