Changeset 721

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

another update

Files:

Legend:

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

    r720 r721  
    145145    { 
    146146        // not enough frames in the buffer, 
    147         debugOutput ( DEBUG_LEVEL_VERBOSE, 
    148                     "Insufficient frames: N=%02d, CY=%04u, TC=%04u, CUT=%04d\n", 
    149                     fc, cycle, transmit_at_cycle, cycles_until_transmit ); 
     147 
    150148        // we can still postpone the queueing of the packets 
    151149        // if we are far enough ahead of the presentation time 
    152150        if ( cycles_until_presentation <= min_cycles_before_presentation ) 
    153151        { 
     152            debugOutput ( DEBUG_LEVEL_VERBOSE, 
     153                        "Insufficient frames (P): N=%02d, CY=%04u, TC=%04u, CUT=%04d\n", 
     154                        fc, cycle, transmit_at_cycle, cycles_until_transmit ); 
    154155            // we are too late 
    155156            // meaning that we in some sort of xrun state 
     
    161162        else 
    162163        { 
     164            debugOutput ( DEBUG_LEVEL_VERY_VERBOSE, 
     165                        "Insufficient frames (NP): N=%02d, CY=%04u, TC=%04u, CUT=%04d\n", 
     166                        fc, cycle, transmit_at_cycle, cycles_until_transmit ); 
    163167            // there is still time left to send the packet 
    164168            // we want the system to give this packet another go 
  • branches/ppalmers-streaming/src/libstreaming/generic/StreamProcessor.cpp

    r720 r721  
    464464            } 
    465465            return RAW1394_ISO_OK; 
     466        } else { // pick up the possible xruns 
     467             
    466468        } 
    467469    } 
     
    512514    // use the ts parameter. It specifies the time of the block's  
    513515    // last sample. 
    514      
    515     // determine the time at which we want reception to start 
    516516    float srate = m_manager->getSyncSource().getTicksPerFrame(); 
    517517    assert(srate != 0.0); 
    518518    int64_t this_block_length_in_ticks = (int64_t)(((float)nbframes) * srate); 
    519      
     519 
    520520    ffado_timestamp_t ts_head_tmp; 
    521521    m_data_buffer->getBufferHeadTimestamp(&ts_head_tmp, &fc); 
    522522    ts_expected = addTicks((uint64_t)ts_head_tmp, this_block_length_in_ticks); 
    523      
     523 
    524524    lag_ticks = diffTicks(ts, ts_expected); 
    525      
    526      
    527525    lag_frames = (((float)lag_ticks) / srate); 
    528      
    529526    debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "stream (%p): drifts %6d ticks = %10.5f frames (rate=%10.5f), %lld, %llu, %d\n", 
    530527                 this, lag_ticks, lag_frames, srate, ts, ts_expected, fc); 
    531  
    532528    if (lag_frames >= 1.0) { 
    533529        // the stream lags 
     
    611607} 
    612608 
    613 bool StreamProcessor::stop() 
    614 { 
    615     debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "stop...\n"); 
    616     switch (m_state) { 
    617         case ePS_Stopped: return true; 
    618         case ePS_DryRunning: 
    619             return stopDryRunning(-1); 
    620         case ePS_Running: 
    621             return stopRunning(-1) &&  
    622                    stopDryRunning(-1); 
    623         default: 
    624             debugError("Bad state: %s\n", ePSToString(m_state)); 
    625             return false; 
    626     } 
    627 } 
    628  
    629609bool 
    630610StreamProcessor::scheduleStateTransition(enum eProcessorState state, uint64_t time_instant) 
     
    661641    } 
    662642    debugOutput(DEBUG_LEVEL_VERBOSE,"for %s SP (%p)\n", ePTToString(getType()), this); 
    663     debugOutput(DEBUG_LEVEL_VERBOSE,"  Now                   : %011lu\n", m_handler->getCycleTimerTicks()); 
    664     debugOutput(DEBUG_LEVEL_VERBOSE,"  Start at              : %011llu (%u)\n", tx, TICKS_TO_CYCLES(tx)); 
     643    uint64_t now = m_handler->getCycleTimerTicks(); 
     644    debugOutput(DEBUG_LEVEL_VERBOSE,"  Now                   : %011llu (%03us %04uc %04ut)\n", 
     645                          now, 
     646                          (unsigned int)TICKS_TO_SECS(now), 
     647                          (unsigned int)TICKS_TO_CYCLES(now), 
     648                          (unsigned int)TICKS_TO_OFFSET(now)); 
     649    debugOutput(DEBUG_LEVEL_VERBOSE,"  Start at              : %011llu (%03us %04uc %04ut)\n", 
     650                          tx, 
     651                          (unsigned int)TICKS_TO_SECS(tx), 
     652                          (unsigned int)TICKS_TO_CYCLES(tx), 
     653                          (unsigned int)TICKS_TO_OFFSET(tx)); 
    665654    if (m_state == ePS_Stopped) { 
    666655        return scheduleStateTransition(ePS_WaitingForStream, tx); 
     
    681670    } 
    682671    debugOutput(DEBUG_LEVEL_VERBOSE,"for %s SP (%p)\n", ePTToString(getType()), this); 
    683     debugOutput(DEBUG_LEVEL_VERBOSE,"  Now                   : %011lu\n", m_handler->getCycleTimerTicks()); 
    684     debugOutput(DEBUG_LEVEL_VERBOSE,"  Start at              : %011llu (%u)\n", tx, TICKS_TO_CYCLES(tx)); 
     672    uint64_t now = m_handler->getCycleTimerTicks(); 
     673    debugOutput(DEBUG_LEVEL_VERBOSE,"  Now                   : %011llu (%03us %04uc %04ut)\n", 
     674                          now, 
     675                          (unsigned int)TICKS_TO_SECS(now), 
     676                          (unsigned int)TICKS_TO_CYCLES(now), 
     677                          (unsigned int)TICKS_TO_OFFSET(now)); 
     678    debugOutput(DEBUG_LEVEL_VERBOSE,"  Start at              : %011llu (%03us %04uc %04ut)\n", 
     679                          tx, 
     680                          (unsigned int)TICKS_TO_SECS(tx), 
     681                          (unsigned int)TICKS_TO_CYCLES(tx), 
     682                          (unsigned int)TICKS_TO_OFFSET(tx)); 
    685683    return scheduleStateTransition(ePS_WaitingForStreamEnable, tx); 
    686684} 
     
    694692    } 
    695693    debugOutput(DEBUG_LEVEL_VERBOSE,"for %s SP (%p)\n", ePTToString(getType()), this); 
    696     debugOutput(DEBUG_LEVEL_VERBOSE,"  Now                   : %011lu\n", m_handler->getCycleTimerTicks()); 
    697     debugOutput(DEBUG_LEVEL_VERBOSE,"  Stop at               : %011llu (%u)\n", tx, TICKS_TO_CYCLES(tx)); 
     694    uint64_t now = m_handler->getCycleTimerTicks(); 
     695    debugOutput(DEBUG_LEVEL_VERBOSE,"  Now                   : %011llu (%03us %04uc %04ut)\n", 
     696                          now, 
     697                          (unsigned int)TICKS_TO_SECS(now), 
     698                          (unsigned int)TICKS_TO_CYCLES(now), 
     699                          (unsigned int)TICKS_TO_OFFSET(now)); 
     700    debugOutput(DEBUG_LEVEL_VERBOSE,"  Stop at               : %011llu (%03us %04uc %04ut)\n", 
     701                          tx, 
     702                          (unsigned int)TICKS_TO_SECS(tx), 
     703                          (unsigned int)TICKS_TO_CYCLES(tx), 
     704                          (unsigned int)TICKS_TO_OFFSET(tx)); 
    698705    return scheduleStateTransition(ePS_Stopped, tx); 
    699706} 
     
    707714    } 
    708715    debugOutput(DEBUG_LEVEL_VERBOSE,"for %s SP (%p)\n", ePTToString(getType()), this); 
    709     debugOutput(DEBUG_LEVEL_VERBOSE,"  Now                   : %011lu\n", m_handler->getCycleTimerTicks()); 
    710     debugOutput(DEBUG_LEVEL_VERBOSE,"  Stop at               : %011llu (%u)\n", tx, TICKS_TO_CYCLES(tx)); 
     716    uint64_t now = m_handler->getCycleTimerTicks(); 
     717    debugOutput(DEBUG_LEVEL_VERBOSE,"  Now                   : %011llu (%03us %04uc %04ut)\n", 
     718                          now, 
     719                          (unsigned int)TICKS_TO_SECS(now), 
     720                          (unsigned int)TICKS_TO_CYCLES(now), 
     721                          (unsigned int)TICKS_TO_OFFSET(now)); 
     722    debugOutput(DEBUG_LEVEL_VERBOSE,"  Stop at               : %011llu (%03us %04uc %04ut)\n", 
     723                          tx, 
     724                          (unsigned int)TICKS_TO_SECS(tx), 
     725                          (unsigned int)TICKS_TO_CYCLES(tx), 
     726                          (unsigned int)TICKS_TO_OFFSET(tx)); 
    711727    return scheduleStateTransition(ePS_WaitingForStreamDisable, tx); 
    712728} 
  • branches/ppalmers-streaming/src/libstreaming/generic/StreamProcessor.h

    r720 r721  
    110110    bool isDryRunning() 
    111111            {return m_state == ePS_DryRunning;}; 
     112    bool isStopped() 
     113            {return m_state == ePS_Stopped;}; 
    112114 
    113115    // these schedule and wait for the state transition 
     
    127129    bool init(); 
    128130    bool prepare(); 
    129  
    130     ///> stop the SP from running or dryrunning 
    131     bool stop(); 
    132131 
    133132public: // constructor/destructor 
  • branches/ppalmers-streaming/src/libstreaming/StreamProcessorManager.cpp

    r720 r721  
    268268    // the received frames will all be presented to the SP 
    269269    debugOutput( DEBUG_LEVEL_VERBOSE, "Finding minimal sync delay...\n"); 
    270     int max_of_min_delay=0; 
    271     int min_delay=0; 
     270    int max_of_min_delay = 0; 
     271    int min_delay = 0; 
    272272    for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin(); 
    273273            it != m_ReceiveProcessors.end(); 
    274274            ++it ) { 
    275         min_delay=(*it)->getMaxFrameLatency(); 
    276         if(min_delay>max_of_min_delay) max_of_min_delay=min_delay; 
     275        min_delay = (*it)->getMaxFrameLatency(); 
     276        if(min_delay > max_of_min_delay) max_of_min_delay = min_delay; 
    277277    } 
    278278 
     
    459459    assert(m_isoManager); 
    460460 
    461     debugOutput( DEBUG_LEVEL_VERBOSE, "Waiting for all StreamProcessors to prepare to stop...\n"); 
    462     // Most stream processors can just stop without special treatment.  However, some 
    463     // (like the MOTU) need to do a few things before it's safe to turn off the iso 
    464     // handling. 
     461    debugOutput( DEBUG_LEVEL_VERBOSE, " scheduling stop for all SP's...\n"); 
     462 
     463    // switch SP's over to the dry-running state 
    465464    for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin(); 
    466465          it != m_ReceiveProcessors.end(); 
    467466          ++it ) { 
    468         if(!(*it)->stop()) { 
    469             debugError("Could not stop SP %p", (*it)); 
     467        if(!(*it)->scheduleStopRunning(-1)) { 
     468            debugError("%p->scheduleStopRunning(-1) failed\n", *it); 
     469            return false; 
    470470        } 
    471471    } 
     
    473473          it != m_TransmitProcessors.end(); 
    474474          ++it ) { 
    475         if(!(*it)->stop()) { 
    476             debugError("Could not stop SP %p", (*it)); 
    477         } 
     475        if(!(*it)->scheduleStopRunning(-1)) { 
     476            debugError("%p->scheduleStopRunning(-1) failed\n", *it); 
     477            return false; 
     478        } 
     479    } 
     480    // wait for the SP's to get into the dry-running state 
     481    int cnt = 200; 
     482    bool ready = false; 
     483    while (!ready && cnt) { 
     484        ready = true; 
     485        for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin(); 
     486            it != m_ReceiveProcessors.end(); 
     487            ++it ) { 
     488            ready &= ((*it)->isDryRunning() || (*it)->isStopped()); 
     489        } 
     490        for ( StreamProcessorVectorIterator it = m_TransmitProcessors.begin(); 
     491            it != m_TransmitProcessors.end(); 
     492            ++it ) { 
     493            ready &= ((*it)->isDryRunning() || (*it)->isStopped()); 
     494        } 
     495        usleep(125); 
     496        cnt--; 
     497    } 
     498    if(cnt==0) { 
     499        debugOutput(DEBUG_LEVEL_VERBOSE, " Timeout waiting for the SP's to start dry-running\n"); 
     500        return false; 
     501    } 
     502 
     503    // switch SP's over to the stopped state 
     504    for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin(); 
     505          it != m_ReceiveProcessors.end(); 
     506          ++it ) { 
     507        if(!(*it)->scheduleStopDryRunning(-1)) { 
     508            debugError("%p->scheduleStopDryRunning(-1) failed\n", *it); 
     509            return false; 
     510        } 
     511    } 
     512    for ( StreamProcessorVectorIterator it = m_TransmitProcessors.begin(); 
     513          it != m_TransmitProcessors.end(); 
     514          ++it ) { 
     515        if(!(*it)->scheduleStopDryRunning(-1)) { 
     516            debugError("%p->scheduleStopDryRunning(-1) failed\n", *it); 
     517            return false; 
     518        } 
     519    } 
     520    // wait for the SP's to get into the running state 
     521    cnt = 200; 
     522    ready = false; 
     523    while (!ready && cnt) { 
     524        ready = true; 
     525        for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin(); 
     526            it != m_ReceiveProcessors.end(); 
     527            ++it ) { 
     528            ready &= (*it)->isStopped(); 
     529        } 
     530        for ( StreamProcessorVectorIterator it = m_TransmitProcessors.begin(); 
     531            it != m_TransmitProcessors.end(); 
     532            ++it ) { 
     533            ready &= (*it)->isStopped(); 
     534        } 
     535        usleep(125); 
     536        cnt--; 
     537    } 
     538    if(cnt==0) { 
     539        debugOutput(DEBUG_LEVEL_VERBOSE, " Timeout waiting for the SP's to stop\n"); 
     540        return false; 
    478541    } 
    479542 
     
    504567        } 
    505568    } 
    506  
    507569    return true; 
    508570}