Changeset 798

Show
Ignore:
Timestamp:
01/01/08 13:27:35 (16 years ago)
Author:
ppalmers
Message:

cleanup and reliability fixes

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/config.h.in

    r797 r798  
    2828 
    2929/* Define to 1 if SSE assembly is available. */ 
    30 #define USE_SSE $USE_SSE 
     30// broken 
     31//#define USE_SSE $USE_SSE 
     32#define USE_SSE 0 
    3133 
    3234#define CACHEDIR "~/.ffado" 
     
    4951// time to a later time instant also causes the xmit buffer fill to be 
    5052// lower on average. 
    51 #define STREAMPROCESSORMANAGER_SIGNAL_DELAY_TICKS           (3072*1
     53#define STREAMPROCESSORMANAGER_SIGNAL_DELAY_TICKS           (3072*4
    5254 
    5355#define STREAMPROCESSORMANAGER_CYCLES_FOR_DRYRUN            40000 
     
    6971#define AMDTP_TRANSMIT_TRANSFER_DELAY   (11776U) 
    7072 
     73// the absolute minimum number of cycles we want to transmit 
     74// a packet ahead of the presentation time. The nominal time 
     75// the packet is transmitted ahead of the presentation time is 
     76// given by AMDTP_TRANSMIT_TRANSFER_DELAY (in ticks), but in case we 
     77// are too late for that, this constant defines how late we can 
     78// be. 
     79#define AMDTP_MIN_CYCLES_BEFORE_PRESENTATION                1 
     80 
     81// the absolute maximum number of cycles we want to transmit 
     82// a packet ahead of the ideal transmit time. The nominal time 
     83// the packet is transmitted ahead of the presentation time is 
     84// given by AMDTP_TRANSMIT_TRANSFER_DELAY (in ticks), but we can send 
     85// packets early if we want to. (not completely according to spec) 
     86// (for spec compliance you need to specify a value of 1 or 2) 
     87#define AMDTP_MAX_CYCLES_TO_TRANSMIT_EARLY                  6 
     88 
    7189#define MOTU_TRANSMIT_TRANSFER_DELAY    (11776U) 
    7290 
  • trunk/libffado/src/libstreaming/amdtp/AmdtpTransmitStreamProcessor.cpp

    r797 r798  
    7979    int cycles_until_transmit; 
    8080 
    81     // FIXME: should become a define 
    82     // the absolute minimum number of cycles we want to transmit 
    83     // a packet ahead of the presentation time. The nominal time 
    84     // the packet is transmitted ahead of the presentation time is 
    85     // given by AMDTP_TRANSMIT_TRANSFER_DELAY (in ticks), but in case we 
    86     // are too late for that, this constant defines how late we can 
    87     // be. 
    88     const int min_cycles_before_presentation = 1; 
    89     // FIXME: should become a define 
    90     // the absolute maximum number of cycles we want to transmit 
    91     // a packet ahead of the ideal transmit time. The nominal time 
    92     // the packet is transmitted ahead of the presentation time is 
    93     // given by AMDTP_TRANSMIT_TRANSFER_DELAY (in ticks), but we can send 
    94     // packets early if we want to. (not completely according to spec) 
    95     const int max_cycles_to_transmit_early = 2; 
    96  
    9781    debugOutput ( DEBUG_LEVEL_ULTRA_VERBOSE, "Try for cycle %d\n", cycle ); 
    9882    // check whether the packet buffer has packets for us to send. 
     
    147131        // we can still postpone the queueing of the packets 
    148132        // if we are far enough ahead of the presentation time 
    149         if ( cycles_until_presentation <= min_cycles_before_presentation
     133        if ( cycles_until_presentation <= AMDTP_MIN_CYCLES_BEFORE_PRESENTATION
    150134        { 
    151135            debugOutput ( DEBUG_LEVEL_VERBOSE, 
     
    216200//             // NOTE: dangerous since the device has no way of reporting that it didn't get 
    217201//             //       this packet on time. 
    218 //             if(cycles_until_presentation >= min_cycles_before_presentation
     202//             if(cycles_until_presentation >= AMDTP_MIN_CYCLES_BEFORE_PRESENTATION
    219203//             { 
    220204//                 // we are not that late and can still try to transmit the packet 
     
    227211//             } 
    228212        } 
    229         else if(cycles_until_transmit <= max_cycles_to_transmit_early
     213        else if(cycles_until_transmit <= AMDTP_MAX_CYCLES_TO_TRANSMIT_EARLY
    230214        { 
    231215            // it's time send the packet 
     
    242226                        presentation_time, ( unsigned int ) TICKS_TO_CYCLES ( presentation_time ) ); 
    243227#ifdef DEBUG 
    244             if ( cycles_until_transmit > max_cycles_to_transmit_early + 1 ) 
     228            if ( cycles_until_transmit > AMDTP_MAX_CYCLES_TO_TRANSMIT_EARLY + 1 ) 
    245229            { 
    246230                debugOutput ( DEBUG_LEVEL_VERY_VERBOSE, 
  • trunk/libffado/src/libstreaming/generic/StreamProcessor.cpp

    r797 r798  
    444444    } 
    445445 
     446    unsigned int ctr; 
     447    int now_cycles; 
     448    int cycle_diff; 
     449 
    446450    if(m_last_cycle == -1) { 
    447451        debugOutput(DEBUG_LEVEL_VERBOSE, "Handler for %s SP %p is alive (cycle = %d)\n", getTypeString(), this, cycle); 
     
    458462            debugWarning("(%p) dropped %d packets on cycle %u (last_cycle=%u, dropped=%d)\n", this, dropped_cycles, cycle, m_last_cycle, dropped); 
    459463            m_dropped += dropped_cycles; 
    460 //             flushDebugOutput(); 
    461 //             assert(0); 
     464            // HACK: this should not be necessary, since the header generation functions should trigger the xrun. 
     465            //       but apparently there are some issues with the 1394 stack 
     466            m_in_xrun = true; 
     467            if(m_state == ePS_Running) { 
     468                debugShowBackLogLines(200); 
     469                debugWarning("dropped packets xrun\n"); 
     470                debugOutput(DEBUG_LEVEL_VERBOSE, "Should update state to WaitingForStreamDisable due to dropped packets xrun\n"); 
     471                m_next_state = ePS_WaitingForStreamDisable; 
     472                // execute the requested change 
     473                if (!updateState()) { // we are allowed to change the state directly 
     474                    debugError("Could not update state!\n"); 
     475                    return RAW1394_ISO_ERROR; 
     476                } 
     477                goto send_empty_packet; 
     478            } 
    462479        } 
    463480    } 
     
    483500    // we the packet we are constructing will be sent out 
    484501    // on 'cycle', not 'now'. 
    485     unsigned int ctr = m_1394service.getCycleTimer(); 
    486     int now_cycles = (int)CYCLE_TIMER_GET_CYCLES(ctr); 
     502    ctr = m_1394service.getCycleTimer(); 
     503    now_cycles = (int)CYCLE_TIMER_GET_CYCLES(ctr); 
    487504 
    488505    // the difference between the cycle this 
    489506    // packet is intended for and 'now' 
    490     int cycle_diff = diffCycles(cycle, now_cycles); 
     507    cycle_diff = diffCycles(cycle, now_cycles); 
    491508 
    492509    if(cycle_diff < 0 && (m_state == ePS_Running || m_state == ePS_DryRunning)) { 
  • trunk/libffado/src/libstreaming/motu/MotuTransmitStreamProcessor.cpp

    r796 r798  
    117117    const int max_cycles_to_transmit_early = 2; 
    118118 
    119 try_block_of_frames: 
    120119    debugOutput ( DEBUG_LEVEL_ULTRA_VERBOSE, "Try for cycle %d\n", cycle ); 
    121120    // check whether the packet buffer has packets for us to send. 
     
    304303 
    305304        // Set up each frames's SPH. 
    306         for (unsigned int i=0; i < n_events; i++, quadlet += dbs) { 
     305        for (int i=0; i < n_events; i++, quadlet += dbs) { 
    307306//FIXME: not sure which is best for the MOTU 
    308307//            int64_t ts_frame = addTicks(ts, (unsigned int)(i * ticks_per_frame)); 
  • trunk/libffado/src/libstreaming/StreamProcessorManager.cpp

    r797 r798  
    704704        m_time_of_transfer); 
    705705 
     706    xrun_occurred = false; 
     707 
     708#if STREAMPROCESSORMANAGER_DYNAMIC_SYNC_DELAY 
    706709    // normally we can transfer frames at this time, but in some cases this is not true 
    707710    // e.g. when there are not enough frames in the receive buffer. 
     
    712715    // check if xruns occurred on the Iso side. 
    713716    // also check if xruns will occur should we transfer() now 
    714 #if STREAMPROCESSORMANAGER_DYNAMIC_SYNC_DELAY 
    715717    #ifdef DEBUG 
    716718    int waited = 0; 
    717719    #endif 
    718 #endif 
     720     
    719721    bool ready_for_transfer = false; 
    720722    bool ready; 
    721     xrun_occurred = false; 
    722723    while (!ready_for_transfer && !xrun_occurred) { 
    723724        // FIXME: can deadlock when the iso handlers die (e.g. unplug the device) 
     
    737738            xrun_occurred |= (*it)->xrunOccurred(); 
    738739        } 
    739 #if STREAMPROCESSORMANAGER_DYNAMIC_SYNC_DELAY 
     740        if(!ready_for_transfer) { 
     741            debugWarning("xrun_occurred = %d\n", xrun_occurred); 
     742        } 
    740743        if (!ready_for_transfer) { 
    741744             
     
    754757            #endif 
    755758        } 
    756 #endif 
    757759    } // we are either ready or an xrun occurred 
    758  
    759 #if STREAMPROCESSORMANAGER_DYNAMIC_SYNC_DELAY 
     760     
    760761    // in order to avoid a runaway value of the sync delay, we gradually decrease 
    761762    // it. It will be increased by a 'too early' event (cfr some lines higher)