Changeset 821

Show
Ignore:
Timestamp:
01/06/08 07:46:47 (16 years ago)
Author:
ppalmers
Message:

make xrun hanling more robust

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/api-cleanup/config.h.in

    r807 r821  
    6767#define STREAMPROCESSORMANAGER_PRESTART_CYCLES_FOR_XMIT     20 
    6868#define STREAMPROCESSORMANAGER_PRESTART_CYCLES_FOR_RECV     0 
     69#define STREAMPROCESSORMANAGER_SYNCSTART_TRIES              10 
    6970#define STREAMPROCESSORMANAGER_ALIGN_AVERAGE_TIME_MSEC      200 
    7071#define STREAMPROCESSORMANAGER_NB_ALIGN_TRIES               40 
  • branches/api-cleanup/libffado/ffado.h

    r816 r821  
    217217 
    218218/** 
     219 * 
     220 * Wait responses 
     221 * 
     222 */ 
     223typedef enum { 
     224    ffado_wait_error           = -2, 
     225    ffado_wait_xrun            = -1, 
     226    ffado_wait_ok              =  0, 
     227} ffado_wait_response; 
     228 
     229/** 
    219230 * Initializes the streaming from/to a FFADO device. A FFADO device 
    220231 * is a virtual device composed of several BeBoB or compatible devices, 
     
    408419 * @return The number of frames ready. -1 when a problem occurred. 
    409420 */ 
    410 int ffado_streaming_wait(ffado_device_t *dev); 
     421ffado_wait_response ffado_streaming_wait(ffado_device_t *dev); 
    411422 
    412423/** 
  • branches/api-cleanup/src/devicemanager.cpp

    r807 r821  
    553553} 
    554554 
    555 bool 
     555enum DeviceManager::eWaitResult 
    556556DeviceManager::waitForPeriod() { 
    557557    if(m_processorManager->waitForPeriod()) { 
    558         return true
     558        return eWR_OK
    559559    } else { 
    560560        debugWarning("XRUN detected\n"); 
    561561        // do xrun recovery 
    562562        if(m_processorManager->handleXrun()) { 
    563             return false
     563            return eWR_Xrun
    564564        } else { 
    565565            debugError("Could not handle XRUN\n"); 
    566             return false
     566            return eWR_Error
    567567        } 
    568568    } 
  • branches/api-cleanup/src/devicemanager.h

    r777 r821  
    6161{ 
    6262public: 
     63    enum eWaitResult { 
     64        eWR_OK, 
     65        eWR_Xrun, 
     66        eWR_Error, 
     67    }; 
     68 
    6369    DeviceManager(); 
    6470    ~DeviceManager(); 
     
    7985    bool stopStreaming(); 
    8086    bool resetStreaming(); 
    81     bool waitForPeriod(); 
     87    enum eWaitResult waitForPeriod(); 
    8288    bool setStreamingParams(unsigned int period, unsigned int rate, unsigned int nb_buffers); 
    8389 
  • branches/api-cleanup/src/ffado.cpp

    r816 r821  
    226226} 
    227227 
    228 int ffado_streaming_wait(ffado_device_t *dev) { 
     228ffado_wait_response 
     229ffado_streaming_wait(ffado_device_t *dev) { 
    229230    static int periods=0; 
    230231    static int periods_print=0; 
     
    242243    } 
    243244 
    244     if(dev->m_deviceManager->waitForPeriod()) { 
    245         return dev->options.period_size; 
     245    enum DeviceManager::eWaitResult result; 
     246    result = dev->m_deviceManager->waitForPeriod(); 
     247    if(result == DeviceManager::eWR_OK) { 
     248        return ffado_wait_ok; 
     249    } else if (result == DeviceManager::eWR_Xrun) { 
     250        debugWarning("Handled XRUN\n"); 
     251        xruns++; 
     252        return ffado_wait_xrun; 
    246253    } else { 
    247         debugWarning("XRUN\n"); 
     254        debugError("Unhandled XRUN (BUG)\n"); 
    248255        xruns++; 
    249         return -1
     256        return ffado_wait_error
    250257    } 
    251258} 
  • branches/api-cleanup/src/libieee1394/IsoHandler.cpp

    r815 r821  
    214214    // wait for the availability of frames in the client 
    215215    // (blocking for transmit handlers) 
    216  
    217216#if 0 //#ifdef DEBUG 
    218217    if (getType() == eHT_Transmit) { 
    219         debugOutput(DEBUG_LEVEL_VERBOSE, "(%p) Waiting for Client to signal frame availability...\n", this); 
     218        debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "(%p) Waiting for Client to signal frame availability...\n", this); 
    220219    } 
    221220#endif 
     
    223222 
    224223#if ISOHANDLER_USE_POLL 
    225         uint64_t poll_enter = m_manager.get1394Service().getCurrentTimeAsUsecs(); 
    226         err = poll(&m_poll_fd, 1, m_poll_timeout); 
    227         uint64_t poll_exit = m_manager.get1394Service().getCurrentTimeAsUsecs(); 
    228         if (err == -1) { 
    229             if (errno == EINTR) { 
    230                 return true; 
    231             } 
    232             debugFatal("%p, poll error: %s\n", this, strerror (errno)); 
    233             return false; 
    234         } 
    235         uint64_t iter_enter=0; 
    236         uint64_t iter_exit=0; 
    237         if(m_poll_fd.revents & (POLLIN)) { 
    238             iter_enter = m_manager.get1394Service().getCurrentTimeAsUsecs(); 
    239             if(!iterate()) { 
    240                 debugOutput( DEBUG_LEVEL_VERBOSE, 
    241                             "IsoHandler (%p): Failed to iterate handler\n", 
    242                             this); 
     224        bool result = true; 
     225        while(result && m_Client && m_Client->canProcessPackets()) { 
     226            int err = poll(&m_poll_fd, 1, m_poll_timeout); 
     227            if (err == -1) { 
     228                if (errno == EINTR) { 
     229                    return true; 
     230                } 
     231                debugFatal("%p, poll error: %s\n", this, strerror (errno)); 
    243232                return false; 
    244233            } 
    245             iter_exit = m_manager.get1394Service().getCurrentTimeAsUsecs(); 
    246         } else { 
    247             if (m_poll_fd.revents & POLLERR) { 
    248                 debugWarning("error on fd for %p\n", this); 
     234 
     235            if(m_poll_fd.revents & (POLLIN)) { 
     236                result=iterate(); 
     237                if(!result) { 
     238                    debugOutput( DEBUG_LEVEL_VERBOSE, 
     239                                "IsoHandler (%p): Failed to iterate handler\n", 
     240                                this); 
     241                } 
     242            } else { 
     243                if (m_poll_fd.revents & POLLERR) { 
     244                    debugWarning("error on fd for %p\n", this); 
     245                } 
     246                if (m_poll_fd.revents & POLLHUP) { 
     247                    debugWarning("hangup on fd for %p\n",this); 
     248                } 
     249                break; 
    249250            } 
    250             if (m_poll_fd.revents & POLLHUP) { 
    251                 debugWarning("hangup on fd for %p\n",this); 
    252             } 
    253         } 
    254         debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "(%c %p) poll took %lldus, iterate took %lldus\n",  
    255                     (getType()==eHT_Receive?'R':'X'), this,  
    256                     poll_exit-poll_enter, iter_exit-iter_enter); 
    257         return true; 
     251        } 
     252        return result; 
    258253#else 
    259254        // iterate() is blocking if no 1394 data is available 
    260255        // so poll'ing is not really necessary 
    261256        bool result = true; 
    262         while(result && m_Client->canProcessPackets()) { 
     257        while(result && m_Client && m_Client->canProcessPackets()) { 
    263258            result = iterate(); 
    264             //debugOutput(DEBUG_LEVEL_VERBOSE, "(%p, %s) Iterate returned: %d\n", 
    265             //            this, (m_type==eHT_Receive?"Receive":"Transmit"), result); 
     259//             if (getType() == eHT_Receive) { 
     260//                 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "(%p, %s) Iterate returned: %d\n", 
     261//                             this, (m_type==eHT_Receive?"Receive":"Transmit"), result); 
     262//             } 
    266263        } 
    267264        return result; 
     
    275272bool 
    276273IsoHandler::iterate() { 
    277     //debugOutput(DEBUG_LEVEL_VERBOSE, "(%p, %s) Iterating ISO handler\n",  
    278     //            this, (m_type==eHT_Receive?"Receive":"Transmit")); 
     274//     if(m_type==eHT_Receive) { 
     275//         debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "(%p, %s) Iterating ISO handler\n",  
     276//                 this, (m_type==eHT_Receive?"Receive":"Transmit")); 
     277//     } 
    279278    if(m_State == E_Running) { 
    280279#if ISOHANDLER_FLUSH_BEFORE_ITERATE 
  • branches/api-cleanup/src/libstreaming/generic/StreamProcessor.cpp

    r816 r821  
    288288                           unsigned char channel, unsigned char tag, unsigned char sy, 
    289289                           unsigned int cycle, unsigned int dropped) { 
     290#ifdef DEBUG 
    290291    if(m_last_cycle == -1) { 
    291292        debugOutput(DEBUG_LEVEL_VERBOSE, "Handler for %s SP %p is alive (cycle = %u)\n", getTypeString(), this, cycle); 
    292293    } 
     294#endif 
    293295 
    294296    int dropped_cycles = 0; 
     
    303305                this, dropped_cycles, cycle, dropped, cycle, m_last_cycle); 
    304306            m_dropped += dropped_cycles; 
    305             m_in_xrun = true; 
    306307            m_last_cycle = cycle; 
    307             POST_SEMAPHORE; 
    308             return RAW1394_ISO_DEFER; 
    309             //flushDebugOutput(); 
    310             //assert(0); 
    311308        } 
    312309    } 
     
    346343        // the received data can be discarded while waiting for the stream 
    347344        // to be disabled 
     345        // similarly for dropped packets 
    348346        return RAW1394_ISO_OK; 
    349347    } 
     
    374372        m_last_good_cycle = cycle; 
    375373        m_last_dropped = dropped_cycles; 
    376  
    377         // check whether we are waiting for a stream to startup 
    378         // this requires that the packet is good 
    379         if(m_state == ePS_WaitingForStream) { 
    380             // since we have a packet with an OK header, 
    381             // we can indicate that the stream started up 
    382  
    383             // we then check whether we have to switch on this cycle 
    384             if (diffCycles(cycle, m_cycle_to_switch_state) >= 0) { 
    385                 debugOutput(DEBUG_LEVEL_VERBOSE, "Should update state to DryRunning due to good packet\n"); 
    386                 // hence go to the dryRunning state 
    387                 m_next_state = ePS_DryRunning; 
    388                 if (!updateState()) { // we are allowed to change the state directly 
    389                     debugError("Could not update state!\n"); 
    390                     POST_SEMAPHORE; 
    391                     return RAW1394_ISO_ERROR; 
    392                 } 
    393             } else { 
    394                 // not time (yet) to switch state 
    395             } 
    396             // in both cases we don't want to process the data 
    397             return RAW1394_ISO_OK; 
    398         } 
    399  
    400         // check whether a state change has been requested 
    401         // note that only the wait state changes are synchronized with the cycles 
    402         else if(m_state != m_next_state) { 
    403             debugOutput(DEBUG_LEVEL_VERBOSE, "Should update state from %s to %s\n", 
    404                                              ePSToString(m_state), ePSToString(m_next_state)); 
    405             // execute the requested change 
    406             if (!updateState()) { // we are allowed to change the state directly 
    407                 debugError("Could not update state!\n"); 
    408                 POST_SEMAPHORE; 
    409                 return RAW1394_ISO_ERROR; 
    410             } 
    411         } 
    412374 
    413375        // handle dropped cycles 
     
    429391                    return RAW1394_ISO_ERROR; 
    430392                } 
     393            } 
     394        } 
     395 
     396        // check whether we are waiting for a stream to startup 
     397        // this requires that the packet is good 
     398        if(m_state == ePS_WaitingForStream) { 
     399            // since we have a packet with an OK header, 
     400            // we can indicate that the stream started up 
     401 
     402            // we then check whether we have to switch on this cycle 
     403            if (diffCycles(cycle, m_cycle_to_switch_state) >= 0) { 
     404                debugOutput(DEBUG_LEVEL_VERBOSE, "Should update state to DryRunning due to good packet\n"); 
     405                // hence go to the dryRunning state 
     406                m_next_state = ePS_DryRunning; 
     407                if (!updateState()) { // we are allowed to change the state directly 
     408                    debugError("Could not update state!\n"); 
     409                    POST_SEMAPHORE; 
     410                    return RAW1394_ISO_ERROR; 
     411                } 
     412            } else { 
     413                // not time (yet) to switch state 
     414            } 
     415            // in both cases we don't want to process the data 
     416            return RAW1394_ISO_OK; 
     417        } 
     418 
     419        // check whether a state change has been requested 
     420        // note that only the wait state changes are synchronized with the cycles 
     421        else if(m_state != m_next_state) { 
     422            debugOutput(DEBUG_LEVEL_VERBOSE, "Should update state from %s to %s\n", 
     423                                             ePSToString(m_state), ePSToString(m_next_state)); 
     424            // execute the requested change 
     425            if (!updateState()) { // we are allowed to change the state directly 
     426                debugError("Could not update state!\n"); 
    431427                POST_SEMAPHORE; 
    432                 return RAW1394_ISO_DEFER; 
     428                return RAW1394_ISO_ERROR; 
    433429            } 
    434430        } 
     
    468464                    unsigned int signal_period = m_signal_period * (semval + 1) + m_signal_offset; 
    469465                    if(bufferfill >= signal_period) { 
    470                         debugOutput(DEBUG_LEVEL_VERBOSE, "(%p) buffer fill (%d) > signal period (%d), sem_val=%d\n", 
     466                        debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "(%p) buffer fill (%d) > signal period (%d), sem_val=%d\n", 
    471467                                    this, m_data_buffer->getBufferFill(), signal_period, semval); 
    472468                        POST_SEMAPHORE; 
     
    511507    int cycle_diff; 
    512508 
     509#ifdef DEBUG 
    513510    if(m_last_cycle == -1) { 
    514511        debugOutput(DEBUG_LEVEL_VERBOSE, "Handler for %s SP %p is alive (cycle = %d)\n", getTypeString(), this, cycle); 
    515512    } 
     513#endif 
    516514 
    517515    int dropped_cycles = 0; 
     
    532530                debugWarning("dropped packets xrun\n"); 
    533531                debugOutput(DEBUG_LEVEL_VERBOSE, "Should update state to WaitingForStreamDisable due to dropped packets xrun\n"); 
     532                m_cycle_to_switch_state = cycle + 1; 
    534533                m_next_state = ePS_WaitingForStreamDisable; 
    535534                // execute the requested change 
     
    546545    } 
    547546 
     547#ifdef DEBUG 
    548548    // bypass based upon state 
    549549    if (m_state == ePS_Invalid) { 
     
    551551        return RAW1394_ISO_ERROR; 
    552552    } 
     553#endif 
     554 
    553555    if (m_state == ePS_Created) { 
    554556        *tag = 0; 
     
    580582            m_in_xrun = true; 
    581583            debugOutput(DEBUG_LEVEL_VERBOSE, "Should update state to WaitingForStreamDisable due to data xrun\n"); 
     584            m_cycle_to_switch_state = cycle + 1; 
    582585            m_next_state = ePS_WaitingForStreamDisable; 
    583586            // execute the requested change 
     
    673676                m_in_xrun = true; 
    674677                debugOutput(DEBUG_LEVEL_VERBOSE, "Should update state to WaitingForStreamDisable due to data xrun\n"); 
    675                 m_cycle_to_switch_state = cycle+1; // switch in the next cycle 
     678                m_cycle_to_switch_state = cycle + 1; // switch in the next cycle 
    676679                m_next_state = ePS_WaitingForStreamDisable; 
    677680                // execute the requested change 
     
    692695            m_in_xrun = true; 
    693696            debugOutput(DEBUG_LEVEL_VERBOSE, "Should update state to WaitingForStreamDisable due to header xrun\n"); 
     697            m_cycle_to_switch_state = cycle + 1; // switch in the next cycle 
    694698            m_next_state = ePS_WaitingForStreamDisable; 
    695699            // execute the requested change 
     
    744748    } 
    745749 
    746     debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "XMIT EMPTY: CY=%04u\n", cycle); 
     750    debugOutput(DEBUG_LEVEL_ULTRA_VERBOSE, "XMIT EMPTY: CY=%04u\n", cycle); 
    747751    generateSilentPacketHeader(data, length, tag, sy, cycle, dropped_cycles, max_length); 
    748752    generateSilentPacketData(data, length, tag, sy, cycle, dropped_cycles, max_length); 
     
    840844    unsigned int bufferfill = m_data_buffer->getBufferFill(); 
    841845    if (bufferfill >= m_signal_period + m_signal_offset) { 
    842         debugOutput(DEBUG_LEVEL_VERBOSE, "(%p) sufficient frames in buffer (%d / %d), posting semaphore\n", 
     846        debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "(%p) sufficient frames in buffer (%d / %d), posting semaphore\n", 
    843847                                         this, bufferfill, m_signal_period + m_signal_offset); 
    844848        POST_SEMAPHORE; 
    845849    } else { 
    846         debugOutput(DEBUG_LEVEL_VERBOSE, "(%p) insufficient frames in buffer (%d / %d), not posting semaphore\n", 
     850        debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "(%p) insufficient frames in buffer (%d / %d), not posting semaphore\n", 
    847851                                         this, bufferfill, m_signal_period + m_signal_offset); 
    848852    } 
     
    898902{ 
    899903    int result; 
    900     if(m_state == ePS_Running) { 
     904    if(m_state == ePS_Running && m_next_state == ePS_Running) { 
    901905        result = sem_wait(&m_signal_semaphore); 
    902906#ifdef DEBUG 
    903907        int tmp; 
    904908        sem_getvalue(&m_signal_semaphore, &tmp); 
    905         debugOutput(DEBUG_LEVEL_VERBOSE, " sem_wait returns: %d, sem_value: %d\n", result, tmp); 
     909        debugOutput(DEBUG_LEVEL_VERY_VERBOSE, " sem_wait returns: %d, sem_value: %d\n", result, tmp); 
    906910#endif 
    907911        return result == 0; 
    908912    } else { 
    909913        // when we're not running, we can always provide frames 
     914        // when we're in a state transition, keep iterating too 
    910915        debugOutput(DEBUG_LEVEL_VERBOSE, "Not running...\n"); 
    911916        return true; 
     
    928933StreamProcessor::canProcessPackets() 
    929934{ 
    930     if(m_state != ePS_Running) return true; 
     935    if(m_state != ePS_Running || m_next_state != ePS_Running) return true; 
    931936    bool result; 
    932937    int bufferfill; 
     
    937942    } 
    938943    result = bufferfill > getNominalFramesPerPacket(); 
    939     // debugOutput(DEBUG_LEVEL_VERBOSE, "(%p, %s) for a bufferfill of %d, we return %d\n", 
    940     //             this, ePTToString(getType()), bufferfill, result); 
     944//    debugOutput(DEBUG_LEVEL_VERBOSE, "(%p, %s) for a bufferfill of %d, we return %d\n", 
     945//                 this, ePTToString(getType()), bufferfill, result); 
    941946    return result; 
    942947} 
     
    11171122    m_cycle_to_switch_state = TICKS_TO_CYCLES(time_instant); 
    11181123    m_next_state = state; 
     1124    POST_SEMAPHORE; // needed to ensure that things don't get deadlocked 
    11191125    return true; 
    11201126} 
     
    15971603        // do init here  
    15981604        result = doStop(); 
    1599         if (result) return true; 
     1605        if (result) {POST_SEMAPHORE; return true;} 
    16001606        else goto updateState_exit_change_failed; 
    16011607    } 
     
    16071613        } 
    16081614        result = doWaitForRunningStream(); 
    1609         if (result) return true; 
     1615        if (result) {POST_SEMAPHORE; return true;} 
    16101616        else goto updateState_exit_change_failed; 
    16111617    } 
     
    16181624        } 
    16191625        result = doDryRunning(); 
    1620         if (result) return true; 
     1626        if (result) {POST_SEMAPHORE; return true;} 
    16211627        else goto updateState_exit_change_failed; 
    16221628    } 
     
    16351641            result = doWaitForStreamEnable(); 
    16361642        } 
    1637         if (result) return true; 
     1643        if (result) {POST_SEMAPHORE; return true;} 
    16381644        else goto updateState_exit_change_failed; 
    16391645    } 
     
    16521658            result = doRunning(); 
    16531659        } 
    1654         if (result) return true; 
     1660        if (result) {POST_SEMAPHORE; return true;} 
    16551661        else goto updateState_exit_change_failed; 
    16561662    } 
     
    16621668        } 
    16631669        result = doWaitForStreamDisable(); 
    1664         if (result) return true; 
     1670        if (result) {POST_SEMAPHORE; return true;} 
    16651671        else goto updateState_exit_change_failed; 
    16661672    } 
     
    16721678        } 
    16731679        result = doDryRunning(); 
    1674         if (result) return true; 
     1680        if (result) {POST_SEMAPHORE; return true;} 
    16751681        else goto updateState_exit_change_failed; 
    16761682    } 
     
    16801686    debugError("Invalid state transition: %s => %s\n", 
    16811687        ePSToString(m_state), ePSToString(next_state)); 
     1688    POST_SEMAPHORE; 
    16821689    return false; 
    16831690updateState_exit_change_failed: 
    16841691    debugError("State transition failed: %s => %s\n", 
    16851692        ePSToString(m_state), ePSToString(next_state)); 
     1693    POST_SEMAPHORE; 
    16861694    return false; 
    16871695} 
  • branches/api-cleanup/src/libstreaming/StreamProcessorManager.cpp

    r816 r821  
    419419    } 
    420420 
    421     // now align the received streams 
    422421    if(!alignReceivedStreams()) { 
    423         debugError("Could not align streams\n"); 
     422        debugError("Could not align streams...\n"); 
    424423        return false; 
    425424    } 
     425 
    426426    debugOutput( DEBUG_LEVEL_VERBOSE, " StreamProcessor streams running...\n"); 
    427427    return true; 
     
    431431StreamProcessorManager::alignReceivedStreams() 
    432432{ 
    433     if(m_SyncSource == NULL) return false; 
    434433    debugOutput( DEBUG_LEVEL_VERBOSE, "Aligning received streams...\n"); 
    435434    unsigned int nb_sync_runs; 
     
    508507    debugOutput( DEBUG_LEVEL_VERBOSE, "Starting Processors...\n"); 
    509508 
    510     // put all SP's into dry-running state 
    511     if (!startDryRunning()) { 
    512         debugFatal("Could not put SP's in dry-running state\n"); 
    513         return false; 
    514     } 
    515  
    516509    // start all SP's synchonized 
    517     if (!syncStartAll()) { 
     510    bool start_result = false; 
     511    for (int ntries; ntries < STREAMPROCESSORMANAGER_SYNCSTART_TRIES; ntries++) { 
     512        // put all SP's into dry-running state 
     513        if (!startDryRunning()) { 
     514            debugOutput(DEBUG_LEVEL_VERBOSE, "Could not put SP's in dry-running state (try %d)\n", ntries); 
     515            start_result = false; 
     516            continue; 
     517        } 
     518 
     519        start_result = syncStartAll(); 
     520        if(start_result) { 
     521            break; 
     522        } else { 
     523            debugOutput(DEBUG_LEVEL_VERBOSE, "Sync start try %d failed...\n", ntries); 
     524        } 
     525    } 
     526    if (!start_result) { 
    518527        debugFatal("Could not syncStartAll...\n"); 
    519528        return false; 
    520529    } 
     530 
    521531    return true; 
    522532} 
     
    645655     */ 
    646656 
    647     // put all SP's back into dry-running state 
    648     if (!startDryRunning()) { 
    649         debugFatal("Could not put SP's in dry-running state\n"); 
    650         return false; 
    651     } 
    652  
    653657    debugOutput( DEBUG_LEVEL_VERBOSE, "Restarting StreamProcessors...\n"); 
    654658    // start all SP's synchonized 
    655     if (!syncStartAll()) { 
     659    bool start_result = false; 
     660    for (int ntries; ntries < STREAMPROCESSORMANAGER_SYNCSTART_TRIES; ntries++) { 
     661        // put all SP's into dry-running state 
     662        if (!startDryRunning()) { 
     663            debugShowBackLog(); 
     664            debugOutput(DEBUG_LEVEL_VERBOSE, "Could not put SP's in dry-running state (try %d)\n", ntries); 
     665            start_result = false; 
     666            continue; 
     667        } 
     668 
     669        start_result = syncStartAll(); 
     670        if(start_result) { 
     671            break; 
     672        } else { 
     673            debugOutput(DEBUG_LEVEL_VERBOSE, "Sync start try %d failed...\n", ntries); 
     674        } 
     675    } 
     676    if (!start_result) { 
    656677        debugFatal("Could not syncStartAll...\n"); 
    657678        return false; 
    658679    } 
    659  
    660680    debugOutput( DEBUG_LEVEL_VERBOSE, "Xrun handled...\n"); 
    661681 
     
    677697 
    678698    while(period_not_ready) { 
    679         debugOutput( DEBUG_LEVEL_VERBOSE, "waiting for period (%d frames in buffer)...\n", m_SyncSource->getBufferFill()); 
     699        debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "waiting for period (%d frames in buffer)...\n", m_SyncSource->getBufferFill()); 
    680700        if(!m_SyncSource->waitForSignal()) { 
    681701            debugError("Error waiting for signal\n"); 
     
    688708#ifdef DEBUG 
    689709        if(period_not_ready) { 
    690             debugOutput(DEBUG_LEVEL_VERBOSE, "period is not ready (bufferfill: %u)\n", bufferfill); 
     710            debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "period is not ready (bufferfill: %u)\n", bufferfill); 
    691711        } else { 
    692             debugOutput(DEBUG_LEVEL_VERBOSE, "period is ready (bufferfill: %u)\n", bufferfill); 
     712            debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "period is ready (bufferfill: %u)\n", bufferfill); 
    693713        } 
    694714#endif 
     
    719739    //       and the receive processors should have done their transfer. 
    720740    m_time_of_transfer = m_SyncSource->getTimeAtPeriod(); 
    721     debugOutput( DEBUG_LEVEL_VERBOSE, "transfer at %llu ticks...\n", 
     741    debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "transfer at %llu ticks...\n", 
    722742        m_time_of_transfer); 
    723743 
  • branches/api-cleanup/tests/streaming/teststreaming3.cpp

    r818 r821  
    267267 
    268268    int nb_in_channels=0, nb_out_channels=0; 
    269     int retval=0; 
    270269    int i=0; 
    271270    int start_flag = 0; 
     
    413412    debugOutput(DEBUG_LEVEL_NORMAL, "Entering receive loop (IN: %d, OUT: %d)\n", nb_in_channels, nb_out_channels); 
    414413    while(run && start_flag==0) { 
    415         retval = ffado_streaming_wait(dev); 
    416         if (retval < 0) { 
     414        ffado_wait_response response; 
     415        response = ffado_streaming_wait(dev); 
     416        if (response == ffado_wait_xrun) { 
    417417            debugOutput(DEBUG_LEVEL_NORMAL, "Xrun\n"); 
    418418            ffado_streaming_reset(dev); 
    419419            continue; 
    420         } 
    421  
     420        } else if (response == ffado_wait_error) { 
     421            debugError("fatal xrun\n"); 
     422            break; 
     423        } 
    422424        ffado_streaming_transfer_capture_buffers(dev); 
    423425