Changeset 1263

Show
Ignore:
Timestamp:
06/21/08 07:05:50 (13 years ago)
Author:
ppalmers
Message:

improve the behavior when confronted with dying iso transmit handlers (usually due to host controller issues)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/libffado-2.0/src/devicemanager.cpp

    r1229 r1263  
    6868    , m_avDevicesLock( new Util::PosixMutex() ) 
    6969    , m_BusResetLock( new Util::PosixMutex() ) 
    70     , m_processorManager( new Streaming::StreamProcessorManager() ) 
     70    , m_processorManager( new Streaming::StreamProcessorManager( *this ) ) 
    7171    , m_deviceStringParser( new DeviceStringParser() ) 
    7272    , m_used_cache_last_time( false ) 
     
    956956} 
    957957 
    958  
    959958void 
    960959DeviceManager::setVerboseLevel(int l) 
  • branches/libffado-2.0/src/ffadodevice.h

    r1129 r1263  
    4242namespace Streaming { 
    4343    class StreamProcessor; 
    44     class StreamProcessorManager; 
    4544} 
    4645 
  • branches/libffado-2.0/src/libieee1394/IsoHandler.cpp

    r1247 r1263  
    6363                        unsigned int length, unsigned char channel, 
    6464                        unsigned char tag, unsigned char sy, unsigned int cycle, 
    65                         unsigned int dropped1) { 
     65                        unsigned int dropped) { 
    6666 
    6767    IsoHandler *recvHandler = static_cast<IsoHandler *>(raw1394_get_userdata(handle)); 
    6868    assert(recvHandler); 
    6969 
    70     unsigned int skipped = (dropped1 & 0xFFFF0000) >> 16; 
    71     unsigned int dropped = dropped1 & 0xFFFF; 
    72  
    73     return recvHandler->putPacket(data, length, channel, tag, sy, cycle, dropped, skipped); 
     70    return recvHandler->putPacket(data, length, channel, tag, sy, cycle, dropped); 
    7471} 
    7572 
     
    9289   , m_last_cycle( -1 ) 
    9390   , m_last_now( 0xFFFFFFFF ) 
     91   , m_last_packet_handled_at( 0xFFFFFFFF ) 
    9492   , m_Client( 0 ) 
    9593   , m_speed( RAW1394_ISO_SPEED_400 ) 
     
    10098   , m_packets ( 0 ) 
    10199   , m_dropped( 0 ) 
     100   , m_skipped( 0 ) 
    102101   , m_min_ahead( 7999 ) 
    103102#endif 
     
    115114   , m_last_cycle( -1 ) 
    116115   , m_last_now( 0xFFFFFFFF ) 
     116   , m_last_packet_handled_at( 0xFFFFFFFF ) 
    117117   , m_Client( 0 ) 
    118118   , m_speed( RAW1394_ISO_SPEED_400 ) 
     
    122122   , m_packets ( 0 ) 
    123123   , m_dropped( 0 ) 
     124   , m_skipped( 0 ) 
    124125   , m_min_ahead( 7999 ) 
    125126#endif 
     
    138139   , m_last_cycle( -1 ) 
    139140   , m_last_now( 0xFFFFFFFF ) 
     141   , m_last_packet_handled_at( 0xFFFFFFFF ) 
    140142   , m_Client( 0 ) 
    141143   , m_speed( speed ) 
     
    145147   , m_packets( 0 ) 
    146148   , m_dropped( 0 ) 
     149   , m_skipped( 0 ) 
     150   , m_min_ahead( 7999 ) 
    147151#endif 
    148152{ 
     
    169173    if(m_Client) { 
    170174        bool result; 
     175 
    171176        if (m_type == eHT_Receive) { 
    172177            result = m_Client->canProducePacket(); 
     
    175180        } 
    176181        debugOutputExtreme(DEBUG_LEVEL_VERY_VERBOSE, " returns %d\n", result); 
    177         return result
     182        return result && (m_State != E_Error)
    178183    } else { 
    179184        debugOutputExtreme(DEBUG_LEVEL_VERY_VERBOSE, " no client\n"); 
     
    261266    } 
    262267 
     268    // wake up any waiting reads/polls 
     269    raw1394_wake_up(m_handle); 
     270 
    263271    // this is put here to try and avoid the 
    264272    // Runaway context problem 
    265273    // don't know if it will help though. 
    266     raw1394_iso_xmit_sync(m_handle); 
     274    if(m_State != E_Error) { // if the handler is dead, this might block forever 
     275        raw1394_iso_xmit_sync(m_handle); 
     276    } 
    267277    raw1394_iso_stop(m_handle); 
    268278    m_State = E_Prepared; 
     
    308318IsoHandler::notifyOfDeath() 
    309319{ 
     320    m_State = E_Error; 
     321 
    310322    // notify the client of the fact that we have died 
    311323    m_Client->handlerDied(); 
     324 
     325    // wake ourselves up 
     326    raw1394_wake_up(m_handle); 
    312327} 
    313328 
     
    331346    } 
    332347    #ifdef DEBUG 
    333     debugOutputShort( DEBUG_LEVEL_NORMAL, "  Last cycle, dropped.........: %4d, %4u\n", 
    334             m_last_cycle, m_dropped); 
     348    debugOutputShort( DEBUG_LEVEL_NORMAL, "  Last cycle, dropped.........: %4d, %4u, %4u\n", 
     349            m_last_cycle, m_dropped, m_skipped); 
    335350    #endif 
    336351 
     
    340355{ 
    341356    setDebugLevel(l); 
     357    debugOutput( DEBUG_LEVEL_VERBOSE, "Setting verbose level to %d...\n", l ); 
    342358} 
    343359 
     
    381397                    unsigned char *data, unsigned int length, 
    382398                    unsigned char channel, unsigned char tag, unsigned char sy, 
    383                     unsigned int cycle, unsigned int dropped, unsigned int skipped) { 
     399                    unsigned int cycle, unsigned int dropped) { 
    384400 
    385401    // keep track of dropped cycles 
     
    389405        #ifdef DEBUG 
    390406        if (dropped_cycles < 0) { 
    391             debugWarning("(%p) dropped < 1 (%d), cycle: %d, last_cycle: %d, dropped: %d, 'skipped'=%u\n",  
    392                          this, dropped_cycles, cycle, m_last_cycle, dropped, skipped); 
     407            debugWarning("(%p) dropped < 1 (%d), cycle: %d, last_cycle: %d, dropped: %d\n",  
     408                         this, dropped_cycles, cycle, m_last_cycle, dropped); 
    393409        } 
    394410        if (dropped_cycles > 0) { 
    395411            debugOutput(DEBUG_LEVEL_NORMAL, 
    396                         "(%p) dropped %d packets on cycle %u, 'dropped'=%u, 'skipped'=%u, cycle=%d, m_last_cycle=%d\n", 
    397                         this, dropped_cycles, cycle, dropped, skipped, cycle, m_last_cycle); 
     412                        "(%p) dropped %d packets on cycle %u, 'dropped'=%u, cycle=%d, m_last_cycle=%d\n", 
     413                        this, dropped_cycles, cycle, dropped, cycle, m_last_cycle); 
    398414            m_dropped += dropped_cycles; 
    399415        } 
     
    477493    } 
    478494    #endif 
     495    m_last_packet_handled_at = pkt_ctr; 
    479496 
    480497    // leave the offset field (for now?) 
    481498 
    482499    debugOutputExtreme(DEBUG_LEVEL_ULTRA_VERBOSE, 
    483                        "received packet: length=%d, channel=%d, cycle=%d\n", 
    484                        length, channel, cycle); 
     500                       "received packet: length=%d, channel=%d, cycle=%d, at %08X\n", 
     501                       length, channel, cycle, pkt_ctr); 
    485502    #ifdef DEBUG 
    486503    m_packets++; 
     
    496513    // iterate the client if required 
    497514    if(m_Client) { 
    498         enum raw1394_iso_disposition retval = m_Client->putPacket(data, length, channel, tag, sy, pkt_ctr, dropped_cycles, skipped); 
     515        enum raw1394_iso_disposition retval = m_Client->putPacket(data, length, channel, tag, sy, pkt_ctr, dropped_cycles); 
    499516        if (retval == RAW1394_ISO_OK) { 
    500517            if (m_dont_exit_iterate_loop) { 
     
    527544        pkt_ctr = cycle << 12; 
    528545 
    529 #if 0 // we don't need this for xmit 
    530546        // if we assume that one iterate() loop doesn't take longer than 0.5 seconds, 
    531547        // the seconds field won't change while the iterate loop runs 
     
    560576        uint32_t pkt_ctr_ref = cycle << 12; 
    561577        pkt_ctr_ref |= (now_secs_ref & 0x7F) << 25; 
    562      
     578 
    563579        if(pkt_ctr != pkt_ctr_ref) { 
    564580            debugWarning("reconstructed CTR counter discrepancy\n"); 
     
    566582        } 
    567583        #endif 
    568 #endif 
    569     } 
    570  
     584    } 
     585    if (m_packets < m_buf_packets) { // these are still prebuffer packets 
     586        m_last_packet_handled_at = 0xFFFFFFFF; 
     587    } else { 
     588        m_last_packet_handled_at = pkt_ctr; 
     589    } 
    571590    debugOutputExtreme(DEBUG_LEVEL_ULTRA_VERBOSE, 
    572                        "sending packet: length=%d, cycle=%d\n", 
    573                        *length, cycle); 
     591                       "sending packet: length=%d, cycle=%d, at %08X\n", 
     592                       *length, cycle, pkt_ctr); 
    574593 
    575594    #ifdef DEBUG 
     
    593612                        "(%p) skipped %d cycles, cycle: %d, last_cycle: %d, dropped: %d\n",  
    594613                        this, skipped, cycle, m_last_cycle, dropped); 
     614            m_skipped += skipped; 
    595615        } 
    596616        if (dropped_cycles < 0) {  
  • branches/libffado-2.0/src/libieee1394/IsoHandler.h

    r1247 r1263  
    6969            putPacket(unsigned char *data, unsigned int length, 
    7070                        unsigned char channel, unsigned char tag, unsigned char sy, 
    71                         unsigned int cycle, unsigned int dropped, unsigned int skipped); 
     71                        unsigned int cycle, unsigned int dropped); 
    7272 
    7373    static enum raw1394_iso_disposition iso_transmit_handler(raw1394handle_t handle, 
     
    161161     */ 
    162162    uint32_t getLastIterateTime() {return m_last_now;}; 
     163 
     164    /** 
     165     * @brief returns the CTR value saved at the last iterate handler call 
     166     * @return CTR value saved at last iterate handler call 
     167     */ 
     168    uint32_t getLastPacketTime() {return m_last_packet_handled_at;}; 
    163169 
    164170    void notifyOfDeath(); 
     
    172178    int             m_last_cycle; 
    173179    uint32_t        m_last_now; 
     180    uint32_t        m_last_packet_handled_at; 
    174181 
    175182    Streaming::StreamProcessor *m_Client; // FIXME: implement with functors 
     
    189196        E_Prepared, 
    190197        E_Running, 
    191         E_Error 
     198        E_Error, 
    192199    }; 
    193200    enum EHandlerStates m_State; 
    194201 
     202public: 
    195203    #ifdef DEBUG 
    196204    unsigned int    m_packets; 
    197205    unsigned int    m_dropped; 
     206    unsigned int    m_skipped; 
    198207    int             m_min_ahead; 
    199208    #endif 
    200209 
     210protected: 
    201211    DECLARE_DEBUG_MODULE; 
    202212}; 
  • branches/libffado-2.0/src/libieee1394/IsoHandlerManager.cpp

    r1262 r1263  
    4747    , m_SyncIsoHandler ( NULL ) 
    4848    , m_handlerType( t ) 
     49    , m_running( false ) 
    4950{ 
    5051} 
     
    7374 
    7475    sem_init(&m_activity_semaphore, 0, 0); 
     76    m_running = true; 
    7577    return true; 
    7678} 
     
    8183    debugOutput(DEBUG_LEVEL_VERBOSE, "(%p) enter\n", this); 
    8284    INC_ATOMIC(&request_update); 
     85 
     86    if (m_running) { 
     87        int timeout = 1000; 
     88        while(request_update && timeout--) { 
     89            Util::SystemTimeSource::SleepUsecRelative(1000); 
     90        } 
     91        if(timeout == 0) { 
     92            debugError("timeout waiting for shadow map update\n"); 
     93        } 
     94    } 
     95    debugOutput(DEBUG_LEVEL_VERBOSE, "(%p) exit\n", this); 
    8396    return true; 
    8497} 
     
    139152IsoTask::Execute() 
    140153{ 
    141     debugOutputExtreme(DEBUG_LEVEL_VERY_VERBOSE, 
    142                        "(%p, %s) Execute\n", 
    143                        this, (m_handlerType == IsoHandler::eHT_Transmit? "Transmit": "Receive")); 
     154    debugOutput(DEBUG_LEVEL_ULTRA_VERBOSE, 
     155                "(%p, %s) Execute\n", 
     156                this, (m_handlerType == IsoHandler::eHT_Transmit? "Transmit": "Receive")); 
    144157    int err; 
    145158    unsigned int i; 
     
    157170        if(m_successive_short_loops > 10000) { 
    158171            debugError("Shutting down runaway thread\n"); 
     172            m_running = false; 
    159173            return false; 
    160174        } 
     
    209223 
    210224        if(no_one_to_poll) { 
    211             debugOutputExtreme(DEBUG_LEVEL_VERBOSE, 
    212                                "(%p, %s) No one to poll, waiting for something to happen\n", 
    213                                this, (m_handlerType == IsoHandler::eHT_Transmit? "Transmit": "Receive")); 
     225            debugOutput(DEBUG_LEVEL_ULTRA_VERBOSE, 
     226                        "(%p, %s) No one to poll, waiting for something to happen\n", 
     227                        this, (m_handlerType == IsoHandler::eHT_Transmit? "Transmit": "Receive")); 
    214228            // wait for something to happen 
    215229            switch(waitForActivity()) { 
     
    247261        } 
    248262        debugFatal("poll error: %s\n", strerror (errno)); 
     263        m_running = false; 
    249264        return false; 
    250265    } 
     
    255270    for (i = 0; i < m_poll_nfds_shadow; i++) { 
    256271        // figure out if a handler has died 
    257         // all handlers in the poll() are active, so they should be iterated 
    258         // now and then. If they aren't, the handler has died. 
    259         uint32_t last_call = m_IsoHandler_map_shadow[i]->getLastIterateTime(); 
    260         if (last_call == 0xFFFFFFFF) { 
     272 
     273        // this is the time of the last packet we saw in the iterate() handler 
     274        uint32_t last_packet_seen = m_IsoHandler_map_shadow[i]->getLastPacketTime(); 
     275        if (last_packet_seen == 0xFFFFFFFF) { 
    261276            // this was not iterated yet, so can't be dead 
     277            debugOutput(DEBUG_LEVEL_VERY_VERBOSE, 
     278                        "(%p, %s) handler %d didn't see any packets yet\n", 
     279                        this, (m_handlerType == IsoHandler::eHT_Transmit? "Transmit": "Receive"), i); 
    262280            continue; 
    263281        } 
    264282 
    265         uint64_t last_call_ticks = CYCLE_TIMER_TO_TICKS(last_call); 
    266         // we use 4 seconds since that should not cause issues with startup 
    267         int64_t max_diff_ticks = TICKS_PER_SECOND * 4; 
    268         int64_t measured_diff_ticks = diffTicks(ctr_at_poll_return_ticks, last_call_ticks); 
    269  
     283        uint64_t last_packet_seen_ticks = CYCLE_TIMER_TO_TICKS(last_packet_seen); 
     284        // we use a relatively large value to distinguish between "death" and xrun 
     285        int64_t max_diff_ticks = TICKS_PER_SECOND * 1; 
     286        int64_t measured_diff_ticks = diffTicks(ctr_at_poll_return_ticks, last_packet_seen_ticks); 
     287 
     288        debugOutputExtreme(DEBUG_LEVEL_VERBOSE, 
     289                           "(%p, %s) check handler %d: diff = %lld, max = %lld, now: %08lX, last: %08lX\n", 
     290                           this, (m_handlerType == IsoHandler::eHT_Transmit? "Transmit": "Receive"),  
     291                           i, measured_diff_ticks, max_diff_ticks, ctr_at_poll_return, last_packet_seen); 
    270292        if(measured_diff_ticks > max_diff_ticks) { 
    271293            debugFatal("(%p, %s) Handler died: now: %08lX, last: %08lX, diff: %lld (max: %lld)\n", 
    272294                       this, (m_handlerType == IsoHandler::eHT_Transmit? "Transmit": "Receive"), 
    273                        ctr_at_poll_return, last_call, measured_diff_ticks, max_diff_ticks); 
     295                       ctr_at_poll_return, last_packet_seen, measured_diff_ticks, max_diff_ticks); 
    274296            m_IsoHandler_map_shadow[i]->notifyOfDeath(); 
    275297            handler_died = true; 
     
    277299    } 
    278300    if(handler_died) { 
     301        m_running = false; 
    279302        return false; // one or more handlers have died 
    280303    } 
     
    361384    } 
    362385 
    363     debugOutputExtreme(DEBUG_LEVEL_VERBOSE, 
    364                        "(%p, %s) got activity\n", 
    365                        this, (m_handlerType == IsoHandler::eHT_Transmit? "Transmit": "Receive")); 
     386    debugOutput(DEBUG_LEVEL_ULTRA_VERBOSE, 
     387                "(%p, %s) got activity\n", 
     388                this, (m_handlerType == IsoHandler::eHT_Transmit? "Transmit": "Receive")); 
    366389    return eAR_Activity; 
    367390} 
     
    372395    // signal the activity cond var 
    373396    sem_post(&m_activity_semaphore); 
    374     debugOutputExtreme(DEBUG_LEVEL_VERBOSE, 
    375                        "(%p, %s) activity\n", 
    376                        this, (m_handlerType == IsoHandler::eHT_Transmit? "Transmit": "Receive")); 
     397    debugOutput(DEBUG_LEVEL_ULTRA_VERBOSE, 
     398                "(%p, %s) activity\n", 
     399                this, (m_handlerType == IsoHandler::eHT_Transmit? "Transmit": "Receive")); 
    377400} 
    378401 
    379402void IsoTask::setVerboseLevel(int i) { 
    380403    setDebugLevel(i); 
     404    debugOutput( DEBUG_LEVEL_VERBOSE, "Setting verbose level to %d...\n", i ); 
    381405} 
    382406 
     
    643667bool IsoHandlerManager::registerStream(StreamProcessor *stream) 
    644668{ 
    645     debugOutput( DEBUG_LEVEL_VERBOSE, "Registering stream %p\n",stream); 
     669    debugOutput( DEBUG_LEVEL_VERBOSE, "Registering %s stream %p\n", stream->getTypeString(), stream); 
    646670    assert(stream); 
    647671 
     
    768792bool IsoHandlerManager::unregisterStream(StreamProcessor *stream) 
    769793{ 
    770     debugOutput( DEBUG_LEVEL_VERBOSE, "Unregistering stream %p\n",stream); 
     794    debugOutput( DEBUG_LEVEL_VERBOSE, "Unregistering %s stream %p\n", stream->getTypeString(), stream); 
    771795    assert(stream); 
    772796 
     
    896920    { 
    897921        if((*it)->isStreamRegistered(stream)) { 
    898             return (*it)->flush(); 
     922            (*it)->flush(); 
    899923        } 
    900924    } 
    901925    debugError("Stream %p has no attached handler\n", stream); 
    902926    return; 
     927} 
     928 
     929IsoHandler * 
     930IsoHandlerManager::getHandlerForStream(Streaming::StreamProcessor *stream) { 
     931    for ( IsoHandlerVectorIterator it = m_IsoHandlers.begin(); 
     932      it != m_IsoHandlers.end(); 
     933      ++it ) 
     934    { 
     935        if((*it)->isStreamRegistered(stream)) { 
     936            return (*it); 
     937        } 
     938    } 
     939    debugError("Stream %p has no attached handler\n", stream); 
     940    return NULL; 
    903941} 
    904942 
     
    10061044    if(m_IsoThreadReceive)  m_IsoThreadReceive->setVerboseLevel(i); 
    10071045    if(m_IsoTaskReceive)    m_IsoTaskReceive->setVerboseLevel(i); 
     1046    setDebugLevel(i); 
     1047    debugOutput( DEBUG_LEVEL_VERBOSE, "Setting verbose level to %d...\n", i ); 
    10081048} 
    10091049 
  • branches/libffado-2.0/src/libieee1394/IsoHandlerManager.h

    r1144 r1263  
    4343namespace Streaming { 
    4444    class StreamProcessor; 
    45     class StreamProcessorManager; 
    4645    typedef std::vector<StreamProcessor *> StreamProcessorVector; 
    4746    typedef std::vector<StreamProcessor *>::iterator StreamProcessorVectorIterator; 
     
    113112 
    114113        enum IsoHandler::EHandlerType m_handlerType; 
     114        bool m_running; 
     115 
    115116        // debug stuff 
    116117        DECLARE_DEBUG_MODULE; 
     
    180181 
    181182        void flushHandlerForStream(Streaming::StreamProcessor *stream); 
     183        IsoHandler * getHandlerForStream(Streaming::StreamProcessor *stream); 
    182184 
    183185        Ieee1394Service& get1394Service() {return m_service;}; 
  • branches/libffado-2.0/src/libstreaming/generic/StreamProcessor.cpp

    r1168 r1263  
    109109    m_state = ePS_Stopped; 
    110110    m_in_xrun = true; 
     111    SIGNAL_ACTIVITY_ALL; 
    111112} 
    112113 
     
    287288                           unsigned char channel, unsigned char tag, unsigned char sy, 
    288289                           uint32_t pkt_ctr, 
    289                            unsigned int dropped_cycles, unsigned int skipped) { 
     290                           unsigned int dropped_cycles) { 
    290291    // bypass based upon state 
    291292#ifdef DEBUG 
     
    17931794    #ifdef DEBUG 
    17941795    debugOutputShort( DEBUG_LEVEL_NORMAL, " StreamProcessor %p, %s:\n", this, ePTToString(m_processor_type)); 
    1795     debugOutputShort( DEBUG_LEVEL_NORMAL, "  Port, Channel  : %d, %d\n", m_1394service.getPort(), m_channel); 
     1796    debugOutputShort( DEBUG_LEVEL_NORMAL, "  Port, Channel    : %d, %d\n", m_1394service.getPort(), m_channel); 
     1797    IsoHandler *h = m_IsoHandlerManager.getHandlerForStream(this); 
     1798    if (h) { 
     1799        debugOutputShort( DEBUG_LEVEL_NORMAL, "  Packets, Dropped, Skipped : %d, %d, %d\n", 
     1800                                              h->m_packets, h->m_dropped, h->m_skipped); 
     1801    } else { 
     1802        debugError("No handler for stream??\n"); 
     1803    } 
    17961804    uint64_t now = m_1394service.getCycleTimerTicks(); 
    17971805    debugOutputShort( DEBUG_LEVEL_NORMAL, "  Now                   : %011llu (%03us %04uc %04ut)\n", 
  • branches/libffado-2.0/src/libstreaming/generic/StreamProcessor.h

    r1190 r1263  
    152152        putPacket(unsigned char *data, unsigned int length, 
    153153                  unsigned char channel, unsigned char tag, unsigned char sy, 
    154                   uint32_t pkt_ctr, unsigned int dropped, unsigned int skipped); 
     154                  uint32_t pkt_ctr, unsigned int dropped); 
    155155 
    156156    enum raw1394_iso_disposition 
  • branches/libffado-2.0/src/libstreaming/StreamProcessorManager.cpp

    r1262 r1263  
    2828#include "libieee1394/cycletimer.h" 
    2929 
     30#include "devicemanager.h" 
     31 
    3032#include "libutil/Time.h" 
    3133 
     
    3840IMPL_DEBUG_MODULE( StreamProcessorManager, StreamProcessorManager, DEBUG_LEVEL_VERBOSE ); 
    3941 
    40 StreamProcessorManager::StreamProcessorManager(
     42StreamProcessorManager::StreamProcessorManager(DeviceManager &p
    4143    : m_is_slave( false ) 
    4244    , m_SyncSource(NULL) 
     45    , m_parent( p ) 
    4346    , m_xrun_happened( false ) 
    4447    , m_activity_wait_timeout_usec( 1000*1000 ) 
     
    5659} 
    5760 
    58 StreamProcessorManager::StreamProcessorManager(unsigned int period, unsigned int framerate, unsigned int nb_buffers) 
     61StreamProcessorManager::StreamProcessorManager(DeviceManager &p, unsigned int period, 
     62                                               unsigned int framerate, unsigned int nb_buffers) 
    5963    : m_is_slave( false ) 
    6064    , m_SyncSource(NULL) 
     65    , m_parent( p ) 
    6166    , m_xrun_happened( false ) 
    6267    , m_activity_wait_timeout_usec( 1000*1000 ) 
     
    698703        } else { 
    699704            debugOutput(DEBUG_LEVEL_VERBOSE, "Sync start try %d failed...\n", ntries); 
     705            if(m_shutdown_needed) { 
     706                debugOutput(DEBUG_LEVEL_VERBOSE, "Some fatal error occurred, stop trying.\n"); 
     707                return false; 
     708            } 
    700709        } 
    701710    } 
     
    704713        return false; 
    705714    } 
    706  
     715    debugOutput( DEBUG_LEVEL_VERBOSE, " Started...\n"); 
    707716    return true; 
    708717} 
     
    815824        return false; 
    816825    } 
     826    debugOutput( DEBUG_LEVEL_VERBOSE, " Stopped...\n"); 
    817827    return true; 
    818828} 
     
    900910            case eAR_Error: 
    901911                debugError("Error while waiting for activity\n"); 
     912                m_shutdown_needed = true; 
    902913                return false; 
    903914            case eAR_Interrupted: 
     
    906917                break; 
    907918            case eAR_Timeout: 
    908                 // FIXME: what to do here? 
    909919                debugWarning("Timeout while waiting for activity\n"); 
    910                 break; 
     920                #ifdef DEBUG 
     921                setVerboseLevel(DEBUG_LEVEL_ULTRA_VERBOSE); 
     922                m_parent.setVerboseLevel(DEBUG_LEVEL_ULTRA_VERBOSE); 
     923                // sleep for a brief moment, such that we can see what is happening in the other threads 
     924                SleepRelativeUsec(1000*100); 
     925                #endif 
     926                // this is a serious error since apparently there was not 
     927                // enough activity. This means one of the streams died. 
     928                m_shutdown_needed = true; 
     929                return false; 
    911930            case eAR_Activity: 
    912931                // do nothing 
     
    12151234 
    12161235void StreamProcessorManager::setVerboseLevel(int l) { 
    1217     setDebugLevel(l); 
    12181236    if(m_WaitLock) m_WaitLock->setVerboseLevel(l); 
    12191237 
    1220     debugOutput( DEBUG_LEVEL_VERBOSE, " Receive processors...\n"); 
    12211238    for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin(); 
    12221239        it != m_ReceiveProcessors.end(); 
     
    12241241        (*it)->setVerboseLevel(l); 
    12251242    } 
    1226  
    1227     debugOutput( DEBUG_LEVEL_VERBOSE, " Transmit processors...\n"); 
    12281243    for ( StreamProcessorVectorIterator it = m_TransmitProcessors.begin(); 
    12291244        it != m_TransmitProcessors.end(); 
     
    12311246        (*it)->setVerboseLevel(l); 
    12321247    } 
    1233 
    1234  
     1248    setDebugLevel(l); 
     1249    debugOutput( DEBUG_LEVEL_VERBOSE, "Setting verbose level to %d...\n", l ); 
     1250
    12351251 
    12361252int StreamProcessorManager::getPortCount(enum Port::E_PortType type, enum Port::E_Direction direction) { 
     
    12731289 
    12741290// TODO: implement a port map here, instead of the loop 
    1275  
    12761291Port* StreamProcessorManager::getPortByIndex(int idx, enum Port::E_Direction direction) { 
    12771292    int count=0; 
  • branches/libffado-2.0/src/libstreaming/StreamProcessorManager.h

    r1262 r1263  
    3636#include <semaphore.h> 
    3737 
     38class DeviceManager; 
     39 
    3840namespace Streaming { 
    3941 
     
    5658    }; 
    5759 
    58     StreamProcessorManager(); 
    59     StreamProcessorManager(unsigned int period, unsigned int rate, unsigned int nb_buffers); 
     60    StreamProcessorManager(DeviceManager &parent); 
     61    StreamProcessorManager(DeviceManager &parent, unsigned int period, 
     62                           unsigned int rate, unsigned int nb_buffers); 
    6063    virtual ~StreamProcessorManager(); 
    6164 
     
    157160protected: // FIXME: private? 
    158161 
     162    // parent device manager 
     163    DeviceManager &m_parent; 
     164 
    159165    // thread related vars 
    160166    bool m_xrun_happened; 
  • branches/libffado-2.0/src/libutil/Thread.h

    r1144 r1263  
    113113 
    114114        virtual void setVerboseLevel(int l) 
    115             {setDebugLevel(l);}; 
     115            {   setDebugLevel(l); 
     116                debugOutput( DEBUG_LEVEL_VERBOSE, "Setting verbose level to %d...\n", l ); 
     117            }; 
    116118    protected: 
    117119            DECLARE_DEBUG_MODULE;