Changeset 1526

Show
Ignore:
Timestamp:
03/29/09 04:43:41 (12 years ago)
Author:
ppalmers
Message:

fix the freewheeling issue. clean up the IsoHandler? and the interactions with the Manager.

Files:

Legend:

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

    r1462 r1526  
    7474   : m_manager( manager ) 
    7575   , m_type ( t ) 
    76    , m_handle( 0
     76   , m_handle( NULL
    7777   , m_buf_packets( 400 ) 
    7878   , m_max_packet_size( 1024 ) 
     
    8686   , m_prebuffers( 0 ) 
    8787   , m_dont_exit_iterate_loop( true ) 
    88    , m_State( E_Created ) 
     88   , m_State( eHS_Stopped ) 
     89   , m_NextState( eHS_Stopped ) 
     90   , m_switch_on_cycle(0) 
    8991#ifdef DEBUG 
    9092   , m_packets ( 0 ) 
     
    100102   : m_manager( manager ) 
    101103   , m_type ( t ) 
    102    , m_handle( 0
     104   , m_handle( NULL
    103105   , m_buf_packets( buf_packets ) 
    104106   , m_max_packet_size( max_packet_size ) 
     
    111113   , m_speed( RAW1394_ISO_SPEED_400 ) 
    112114   , m_prebuffers( 0 ) 
    113    , m_State( E_Created ) 
     115   , m_State( eHS_Stopped ) 
     116   , m_NextState( eHS_Stopped ) 
     117   , m_switch_on_cycle(0) 
    114118#ifdef DEBUG 
    115119   , m_packets ( 0 ) 
     
    126130   : m_manager( manager ) 
    127131   , m_type ( t ) 
    128    , m_handle( 0
     132   , m_handle( NULL
    129133   , m_buf_packets( buf_packets ) 
    130134   , m_max_packet_size( max_packet_size ) 
     
    137141   , m_speed( speed ) 
    138142   , m_prebuffers( 0 ) 
    139    , m_State( E_Created ) 
     143   , m_State( eHS_Stopped ) 
     144   , m_NextState( eHS_Stopped ) 
     145   , m_switch_on_cycle(0) 
    140146#ifdef DEBUG 
    141147   , m_packets( 0 ) 
     
    154160//     raw1394_iso_shutdown(m_handle); 
    155161    if(m_handle) { 
    156         if (m_State == E_Running) { 
     162        if (m_State == eHS_Running) { 
     163            debugError("BUG: Handler still running!\n"); 
    157164            disable(); 
    158165        } 
    159         raw1394_destroy_handle(m_handle); 
    160166    } 
    161167} 
     
    174180        } 
    175181        debugOutputExtreme(DEBUG_LEVEL_VERY_VERBOSE, " returns %d\n", result); 
    176         return result && (m_State != E_Error); 
     182        return result && (m_State != eHS_Error); 
    177183    } else { 
    178184        debugOutputExtreme(DEBUG_LEVEL_VERY_VERBOSE, " no client\n"); 
     
    191197                       this, getTypeString(), cycle_timer_now); 
    192198    m_last_now = cycle_timer_now; 
    193     if(m_State == E_Running) { 
    194 #if ISOHANDLER_FLUSH_BEFORE_ITERATE 
    195         flush(); 
    196 #endif 
     199    if(m_State == eHS_Running) { 
     200        assert(m_handle); 
     201 
     202        #if ISOHANDLER_FLUSH_BEFORE_ITERATE 
     203        // this flushes all packets received since the poll() returned 
     204        // from kernel to userspace such that they are processed by this 
     205        // iterate. Doing so might result in lower latency capability 
     206        // and/or better reliability 
     207        if(m_type == eHT_Receive) { 
     208            raw1394_iso_recv_flush(m_handle); 
     209        } 
     210        #endif 
     211 
    197212        if(raw1394_loop_iterate(m_handle)) { 
    198213            debugError( "IsoHandler (%p): Failed to iterate handler: %s\n", 
     
    210225} 
    211226 
    212 bool 
    213 IsoHandler::init() 
    214 { 
    215     debugOutput( DEBUG_LEVEL_VERBOSE, "IsoHandler (%p) enter...\n",this); 
    216     // check the state 
    217     if(m_State != E_Created) { 
    218         debugError("Incorrect state, expected E_Created, got %d\n",(int)m_State); 
    219         return false; 
    220     } 
    221  
    222     // the main handle for the ISO traffic 
    223     m_handle = raw1394_new_handle_on_port( m_manager.get1394Service().getPort() ); 
    224     if ( !m_handle ) { 
    225         if ( !errno ) { 
    226             debugError("libraw1394 not compatible\n"); 
    227         } else { 
    228             debugError("Could not get 1394 handle: %s\n", strerror(errno) ); 
    229             debugError("Are ieee1394 and raw1394 drivers loaded?\n"); 
    230         } 
    231         return false; 
    232     } 
    233     raw1394_set_userdata(m_handle, static_cast<void *>(this)); 
    234  
    235     // update the internal state 
    236     m_State=E_Initialized; 
    237     return true; 
    238 } 
    239  
    240 bool IsoHandler::disable() 
    241 { 
    242     debugOutput( DEBUG_LEVEL_VERBOSE, "(%p, %s) enter...\n",  
    243                  this, (m_type==eHT_Receive?"Receive":"Transmit")); 
    244  
    245     // check state 
    246     if(m_State == E_Prepared) return true; 
    247     if(m_State != E_Running) { 
    248         debugError("Incorrect state, expected E_Running, got %d\n",(int)m_State); 
    249         return false; 
    250     } 
    251  
    252     debugOutput( DEBUG_LEVEL_VERBOSE, "(%p, %s) wake up handle...\n",  
    253                  this, (m_type==eHT_Receive?"Receive":"Transmit")); 
    254  
    255     // wake up any waiting reads/polls 
    256     raw1394_wake_up(m_handle); 
    257  
    258     // this is put here to try and avoid the 
    259     // Runaway context problem 
    260     // don't know if it will help though. 
    261 /*    if(m_State != E_Error) { // if the handler is dead, this might block forever 
    262         raw1394_iso_xmit_sync(m_handle); 
    263     }*/ 
    264     debugOutput( DEBUG_LEVEL_VERBOSE, "(%p, %s) stop...\n",  
    265                  this, (m_type==eHT_Receive?"Receive":"Transmit")); 
    266     raw1394_iso_stop(m_handle); 
    267     m_State = E_Prepared; 
    268     return true; 
    269 } 
    270  
    271227/** 
    272228 * Bus reset handler 
     
    299255IsoHandler::notifyOfDeath() 
    300256{ 
    301     m_State = E_Error; 
     257    m_State = eHS_Error; 
     258    m_NextState = eHS_Error; 
    302259 
    303260    // notify the client of the fact that we have died 
     
    363320    m_Client=0; 
    364321    return true; 
    365 } 
    366  
    367 void IsoHandler::flush() 
    368 { 
    369     if(m_type == eHT_Receive) { 
    370         raw1394_iso_recv_flush(m_handle); 
    371     } else { 
    372         // do nothing 
    373     } 
    374322} 
    375323 
     
    540488        pkt_ctr_ref |= (now_secs_ref & 0x7F) << 25; 
    541489 
    542         if((pkt_ctr & ~0x0FFFL) != pkt_ctr_ref) { 
     490        if(((pkt_ctr & ~0x0FFFL) != pkt_ctr_ref) && (m_packets > m_buf_packets)) { 
    543491            debugWarning("reconstructed CTR counter discrepancy\n"); 
    544492            debugWarning(" ingredients: %X, %lX, %lX, %lX, %lX, %ld, %ld, %ld, %lld\n", 
     
    640588} 
    641589 
    642 bool IsoHandler::prepare() 
    643 
     590bool 
     591IsoHandler::enable(int cycle) 
     592
     593    debugOutput( DEBUG_LEVEL_VERBOSE, "start on cycle %d\n", cycle); 
     594 
    644595    // check the state 
    645     if(m_State != E_Initialized) { 
    646         debugError("Incorrect state, expected E_Initialized, got %d\n",(int)m_State); 
     596    if(m_State != eHS_Stopped) { 
     597        debugError("Incorrect state, expected eHS_Stopped, got %d\n",(int)m_State); 
    647598        return false; 
    648599    } 
    649600 
    650     // Don't call until libraw1394's raw1394_new_handle() function has been 
    651     // fixed to correctly initialise the iso_packet_infos field.  Bug is 
    652     // confirmed present in libraw1394 1.2.1. 
    653     //     raw1394_iso_shutdown(m_handle); 
    654     m_State = E_Prepared; 
    655  
     601    assert(m_handle == NULL); 
     602 
     603    // create a handle for the ISO traffic 
     604    m_handle = raw1394_new_handle_on_port( m_manager.get1394Service().getPort() ); 
     605    if ( !m_handle ) { 
     606        if ( !errno ) { 
     607            debugError("libraw1394 not compatible\n"); 
     608        } else { 
     609            debugError("Could not get 1394 handle: %s\n", strerror(errno) ); 
     610            debugError("Are ieee1394 and raw1394 drivers loaded?\n"); 
     611        } 
     612        return false; 
     613    } 
     614    raw1394_set_userdata(m_handle, static_cast<void *>(this)); 
     615 
     616    // prepare the handler, allocate the resources 
    656617    debugOutput( DEBUG_LEVEL_VERBOSE, "Preparing iso handler (%p, client=%p)\n", this, m_Client); 
    657618    dumpInfo(); 
     
    668629            return false; 
    669630        } 
    670         return true; 
     631 
     632        if(raw1394_iso_recv_start(m_handle, cycle, -1, 0)) { 
     633            debugFatal("Could not start receive handler (%s)\n",strerror(errno)); 
     634            dumpInfo(); 
     635            return false; 
     636        } 
    671637    } else { 
    672638        if(raw1394_iso_xmit_init(m_handle, 
     
    680646            return false; 
    681647        } 
    682         return true; 
    683     } 
    684 
    685  
    686 bool IsoHandler::enable(int cycle) 
    687 
    688     debugOutput( DEBUG_LEVEL_VERBOSE, "start on cycle %d\n", cycle); 
    689     // check the state 
    690     if(m_State != E_Prepared) { 
    691         if(!prepare()) { 
    692             debugFatal("Could not prepare handler\n"); 
    693             return false; 
    694         } 
    695     } 
    696  
    697     if (getType() == eHT_Receive) { 
    698         if(raw1394_iso_recv_start(m_handle, cycle, -1, 0)) { 
    699             debugFatal("Could not start receive handler (%s)\n",strerror(errno)); 
    700             dumpInfo(); 
    701             return false; 
    702         } 
    703     } else { 
     648 
    704649        if(raw1394_iso_xmit_start(m_handle, cycle, m_prebuffers)) { 
    705650            debugFatal("Could not start xmit handler (%s)\n",strerror(errno)); 
     
    713658#endif 
    714659 
     660    m_packets = 0; 
     661 
    715662    // indicate that the first iterate() still has to occur. 
    716663    m_last_now = 0xFFFFFFFF; 
    717664    m_last_packet_handled_at = 0xFFFFFFFF; 
    718665 
    719     m_State = E_Running; 
     666    m_State = eHS_Running; 
     667    m_NextState = eHS_Running; 
    720668    return true; 
     669} 
     670 
     671bool 
     672IsoHandler::disable() 
     673{ 
     674    debugOutput( DEBUG_LEVEL_VERBOSE, "(%p, %s) enter...\n",  
     675                 this, (m_type==eHT_Receive?"Receive":"Transmit")); 
     676 
     677    // check state 
     678    if(m_State != eHS_Running) { 
     679        debugError("Incorrect state, expected eHS_Running, got %d\n",(int)m_State); 
     680        return false; 
     681    } 
     682 
     683    assert(m_handle != NULL); 
     684 
     685    debugOutput( DEBUG_LEVEL_VERBOSE, "(%p, %s) wake up handle...\n",  
     686                 this, (m_type==eHT_Receive?"Receive":"Transmit")); 
     687 
     688    // wake up any waiting reads/polls 
     689    raw1394_wake_up(m_handle); 
     690 
     691    // this is put here to try and avoid the 
     692    // Runaway context problem 
     693    // don't know if it will help though. 
     694/*    if(m_State != eHS_Error) { // if the handler is dead, this might block forever 
     695        raw1394_iso_xmit_sync(m_handle); 
     696    }*/ 
     697    debugOutput( DEBUG_LEVEL_VERBOSE, "(%p, %s) stop...\n",  
     698                 this, (m_type==eHT_Receive?"Receive":"Transmit")); 
     699    // stop iso traffic 
     700    raw1394_iso_stop(m_handle); 
     701    // deallocate resources 
     702 
     703    // Don't call until libraw1394's raw1394_new_handle() function has been 
     704    // fixed to correctly initialise the iso_packet_infos field.  Bug is 
     705    // confirmed present in libraw1394 1.2.1. 
     706    raw1394_iso_shutdown(m_handle); 
     707 
     708    raw1394_destroy_handle(m_handle); 
     709    m_handle = NULL; 
     710 
     711    m_State = eHS_Stopped; 
     712    m_NextState = eHS_Stopped; 
     713    return true; 
     714} 
     715 
     716// functions to request enable or disable at the next opportunity 
     717bool 
     718IsoHandler::requestEnable(int cycle) 
     719{ 
     720    if (m_State == eHS_Running) { 
     721        debugError("Enable requested on enabled stream\n"); 
     722        return false; 
     723    } 
     724    if (m_State != eHS_Stopped) { 
     725        debugError("Enable requested on stream with state: %d\n", m_State); 
     726        return false; 
     727    } 
     728    m_NextState = eHS_Running; 
     729    return true; 
     730} 
     731 
     732bool 
     733IsoHandler::requestDisable() 
     734{ 
     735    if (m_State == eHS_Stopped) { 
     736        debugError("Disable requested on disabled stream\n"); 
     737        return false; 
     738    } 
     739    if (m_State != eHS_Running) { 
     740        debugError("Disable requested on stream with state=%d\n", m_State); 
     741        return false; 
     742    } 
     743    m_NextState = eHS_Stopped; 
     744    return true; 
     745} 
     746 
     747void 
     748IsoHandler::updateState() 
     749{ 
     750    // execute state changes requested 
     751    if(m_State != m_NextState) { 
     752        debugOutput(DEBUG_LEVEL_VERBOSE, "(%p) handler needs state update from %d => %d\n", this, m_State, m_NextState); 
     753        if(m_State == eHS_Stopped && m_NextState == eHS_Running) { 
     754            debugOutput(DEBUG_LEVEL_VERBOSE, "handler has to be enabled\n"); 
     755            enable(m_switch_on_cycle); 
     756        } else if(m_State == eHS_Running && m_NextState == eHS_Stopped) { 
     757            debugOutput(DEBUG_LEVEL_VERBOSE, "handler has to be disabled\n"); 
     758            disable(); 
     759        } else { 
     760            debugError("Unknown state transition\n"); 
     761        } 
     762    } 
    721763} 
    722764 
  • branches/libffado-2.0/src/libieee1394/IsoHandler.h

    r1372 r1526  
    9898 
    9999    bool init(); 
    100     bool prepare(); 
    101  
    102100    void setVerboseLevel(int l); 
    103101 
     102    // the enable/disable functions should only be used from within the loop that iterates() 
     103    // but not from within the iterate callback. use the requestEnable / requestDisable functions 
     104    // for that 
    104105    bool enable() {return enable(-1);}; 
    105106    bool enable(int cycle); 
    106107    bool disable(); 
    107108 
    108     void flush(); 
     109    // functions to request enable or disable at the next opportunity 
     110    bool requestEnable(int cycle = -1); 
     111    bool requestDisable(); 
     112 
     113    /** 
     114     * updates the internal state if required 
     115     */ 
     116    void updateState(); 
     117 
    109118    enum EHandlerType getType() {return m_type;}; 
    110119    const char *getTypeString() {return eHTToString(m_type); }; 
     
    114123 
    115124    bool isEnabled() 
    116         {return m_State == E_Running;}; 
     125        {return m_State == eHS_Running;}; 
    117126 
    118127    // no setter functions, because those would require a re-init 
     
    198207    // the state machine 
    199208    enum EHandlerStates { 
    200         E_Created, 
    201         E_Initialized, 
    202         E_Prepared, 
    203         E_Running, 
    204         E_Error, 
     209        eHS_Stopped, 
     210        eHS_Running, 
     211        eHS_Error, 
    205212    }; 
    206213    enum EHandlerStates m_State; 
     214    enum EHandlerStates m_NextState; 
     215    int m_switch_on_cycle; 
    207216 
    208217public: 
  • branches/libffado-2.0/src/libieee1394/IsoHandlerManager.cpp

    r1495 r1526  
    8181} 
    8282 
    83 bool 
     83void 
    8484IsoTask::requestShadowMapUpdate() 
    8585{ 
     
    8989    // get the thread going again 
    9090    signalActivity(); 
    91  
    92     if (m_running) { 
    93         int timeout = 1000; 
    94         while(request_update && timeout--) { 
    95             Util::SystemTimeSource::SleepUsecRelative(1000); 
    96         } 
    97         if(timeout == 0) { 
    98             debugError("timeout waiting for shadow map update\n"); 
    99         } 
    100     } 
    10191    debugOutput(DEBUG_LEVEL_VERBOSE, "(%p) exit\n", this); 
    102     return true; 
    10392} 
    10493 
     
    161150        if(h->getType() != m_handlerType) continue; 
    162151 
     152        // update the state of the handler 
     153        // FIXME: maybe this is not the best place to do this 
     154        // it might be better to eliminate the 'requestShadowMapUpdate' 
     155        // entirely and replace it with a mechanism that implements all 
     156        // actions on the m_manager.m_IsoHandlers in the loop 
     157        h->updateState(); 
     158 
     159        // rebuild the map 
    163160        if (h->isEnabled()) { 
    164161            m_IsoHandler_map_shadow[cnt] = h; 
     
    656653} 
    657654 
    658 bool 
    659 IsoHandlerManager::disable(IsoHandler *h) { 
    660     bool result; 
    661     int i=0; 
    662     debugOutput(DEBUG_LEVEL_VERBOSE, "Disable on IsoHandler %p\n", h); 
    663     for ( IsoHandlerVectorIterator it = m_IsoHandlers.begin(); 
    664         it != m_IsoHandlers.end(); 
    665         ++it ) 
    666     { 
    667         if ((*it) == h) { 
    668             result = h->disable(); 
    669             if(h->getType() == IsoHandler::eHT_Transmit) { 
    670                 result &= m_IsoTaskTransmit->requestShadowMapUpdate(); 
    671             } else { 
    672                 result &= m_IsoTaskReceive->requestShadowMapUpdate(); 
    673             } 
    674             debugOutput(DEBUG_LEVEL_VERY_VERBOSE, " disabled\n"); 
    675             return result; 
    676         } 
    677         i++; 
    678     } 
    679     debugError("Handler not found\n"); 
    680     return false; 
    681 } 
    682  
    683 bool 
    684 IsoHandlerManager::enable(IsoHandler *h) { 
    685     bool result; 
    686     int i=0; 
    687     debugOutput(DEBUG_LEVEL_VERBOSE, "Enable on IsoHandler %p\n", h); 
    688     for ( IsoHandlerVectorIterator it = m_IsoHandlers.begin(); 
    689         it != m_IsoHandlers.end(); 
    690         ++it ) 
    691     { 
    692         if ((*it) == h) { 
    693             result = h->enable(); 
    694             if(h->getType() == IsoHandler::eHT_Transmit) { 
    695                 result &= m_IsoTaskTransmit->requestShadowMapUpdate(); 
    696             } else { 
    697                 result &= m_IsoTaskReceive->requestShadowMapUpdate(); 
    698             } 
    699             debugOutput(DEBUG_LEVEL_VERY_VERBOSE, " enabled\n"); 
    700             return result; 
    701         } 
    702         i++; 
    703     } 
    704     debugError("Handler not found\n"); 
    705     return false; 
    706 } 
    707  
    708655void 
    709656IsoHandlerManager::signalActivityTransmit() 
     
    927874    h->setVerboseLevel(getDebugLevel()); 
    928875 
    929     // init the handler 
    930     if(!h->init()) { 
    931         debugFatal("Could not initialize receive handler\n"); 
    932         return false; 
    933     } 
    934  
    935876    // register the stream with the handler 
    936877    if(!h->registerStream(stream)) { 
     
    1027968} 
    1028969 
     970int 
     971IsoHandlerManager::getPacketLatencyForStream(Streaming::StreamProcessor *stream) { 
     972    for ( IsoHandlerVectorIterator it = m_IsoHandlers.begin(); 
     973      it != m_IsoHandlers.end(); 
     974      ++it ) 
     975    { 
     976        if((*it)->isStreamRegistered(stream)) { 
     977            return (*it)->getIrqInterval(); 
     978        } 
     979    } 
     980    debugError("Stream %p has no attached handler\n", stream); 
     981    return 0; 
     982} 
     983 
     984IsoHandler * 
     985IsoHandlerManager::getHandlerForStream(Streaming::StreamProcessor *stream) { 
     986    for ( IsoHandlerVectorIterator it = m_IsoHandlers.begin(); 
     987      it != m_IsoHandlers.end(); 
     988      ++it ) 
     989    { 
     990        if((*it)->isStreamRegistered(stream)) { 
     991            return (*it); 
     992        } 
     993    } 
     994    debugError("Stream %p has no attached handler\n", stream); 
     995    return NULL; 
     996} 
     997 
     998bool 
     999IsoHandlerManager::startHandlerForStream(Streaming::StreamProcessor *stream) { 
     1000    return startHandlerForStream(stream, -1); 
     1001} 
     1002 
     1003bool 
     1004IsoHandlerManager::startHandlerForStream(Streaming::StreamProcessor *stream, int cycle) { 
     1005    // check state 
     1006    if(m_State != E_Running) { 
     1007        debugError("Incorrect state, expected E_Running, got %s\n", eHSToString(m_State)); 
     1008        return false; 
     1009    } 
     1010    for ( IsoHandlerVectorIterator it = m_IsoHandlers.begin(); 
     1011      it != m_IsoHandlers.end(); 
     1012      ++it ) 
     1013    { 
     1014        if((*it)->isStreamRegistered(stream)) { 
     1015            debugOutput( DEBUG_LEVEL_VERBOSE, " starting handler %p for stream %p\n", *it, stream); 
     1016            if(!(*it)->requestEnable(cycle)) { 
     1017                debugOutput( DEBUG_LEVEL_VERBOSE, " could not request enable for handler %p)\n",*it); 
     1018                return false; 
     1019            } 
     1020 
     1021            if((*it)->getType() == IsoHandler::eHT_Transmit) { 
     1022                m_IsoTaskTransmit->requestShadowMapUpdate(); 
     1023            } else { 
     1024                m_IsoTaskReceive->requestShadowMapUpdate(); 
     1025            } 
     1026 
     1027            debugOutput(DEBUG_LEVEL_VERY_VERBOSE, " requested enable for handler %p\n", *it); 
     1028            return true; 
     1029        } 
     1030    } 
     1031    debugError("Stream %p has no attached handler\n", stream); 
     1032    return false; 
     1033} 
     1034 
    10291035bool 
    10301036IsoHandlerManager::stopHandlerForStream(Streaming::StreamProcessor *stream) { 
     
    10401046        if((*it)->isStreamRegistered(stream)) { 
    10411047            debugOutput( DEBUG_LEVEL_VERBOSE, " stopping handler %p for stream %p\n", *it, stream); 
    1042             if(!(*it)->disable()) { 
    1043                 debugOutput( DEBUG_LEVEL_VERBOSE, " could not disable handler (%p)\n",*it); 
     1048            if(!(*it)->requestDisable()) { 
     1049                debugOutput( DEBUG_LEVEL_VERBOSE, " could not request disable for handler %p\n",*it); 
    10441050                return false; 
    10451051            } 
    1046             bool result; 
     1052 
    10471053            if((*it)->getType() == IsoHandler::eHT_Transmit) { 
    1048                 result = m_IsoTaskTransmit->requestShadowMapUpdate(); 
     1054                m_IsoTaskTransmit->requestShadowMapUpdate(); 
    10491055            } else { 
    1050                 result = m_IsoTaskReceive->requestShadowMapUpdate(); 
     1056                m_IsoTaskReceive->requestShadowMapUpdate(); 
    10511057            } 
    1052             if(!result) { 
    1053                 debugOutput( DEBUG_LEVEL_VERBOSE, " could not update shadow map for handler (%p)\n",*it); 
    1054                 return false; 
    1055             } 
     1058 
     1059            debugOutput(DEBUG_LEVEL_VERBOSE, " requested disable for handler %p\n", *it); 
    10561060            return true; 
    10571061        } 
     
    10611065} 
    10621066 
    1063 int 
    1064 IsoHandlerManager::getPacketLatencyForStream(Streaming::StreamProcessor *stream) { 
    1065     for ( IsoHandlerVectorIterator it = m_IsoHandlers.begin(); 
    1066       it != m_IsoHandlers.end(); 
    1067       ++it ) 
    1068     { 
    1069         if((*it)->isStreamRegistered(stream)) { 
    1070             return (*it)->getIrqInterval(); 
    1071         } 
    1072     } 
    1073     debugError("Stream %p has no attached handler\n", stream); 
    1074     return 0; 
    1075 
    1076  
    1077 void 
    1078 IsoHandlerManager::flushHandlerForStream(Streaming::StreamProcessor *stream) { 
    1079     for ( IsoHandlerVectorIterator it = m_IsoHandlers.begin(); 
    1080       it != m_IsoHandlers.end(); 
    1081       ++it ) 
    1082     { 
    1083         if((*it)->isStreamRegistered(stream)) { 
    1084             (*it)->flush(); 
    1085         } 
    1086     } 
    1087     debugError("Stream %p has no attached handler\n", stream); 
    1088     return; 
    1089 
    1090  
    1091 IsoHandler * 
    1092 IsoHandlerManager::getHandlerForStream(Streaming::StreamProcessor *stream) { 
    1093     for ( IsoHandlerVectorIterator it = m_IsoHandlers.begin(); 
    1094       it != m_IsoHandlers.end(); 
    1095       ++it ) 
    1096     { 
    1097         if((*it)->isStreamRegistered(stream)) { 
    1098             return (*it); 
    1099         } 
    1100     } 
    1101     debugError("Stream %p has no attached handler\n", stream); 
    1102     return NULL; 
    1103 
    1104  
    1105 bool 
    1106 IsoHandlerManager::startHandlerForStream(Streaming::StreamProcessor *stream) { 
    1107     return startHandlerForStream(stream, -1); 
    1108 
    1109  
    1110 bool 
    1111 IsoHandlerManager::startHandlerForStream(Streaming::StreamProcessor *stream, int cycle) { 
     1067bool IsoHandlerManager::stopHandlers() { 
     1068    debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 
     1069 
    11121070    // check state 
    11131071    if(m_State != E_Running) { 
     
    11151073        return false; 
    11161074    } 
    1117     for ( IsoHandlerVectorIterator it = m_IsoHandlers.begin(); 
    1118       it != m_IsoHandlers.end(); 
    1119       ++it ) 
    1120     { 
    1121         if((*it)->isStreamRegistered(stream)) { 
    1122             debugOutput( DEBUG_LEVEL_VERBOSE, " starting handler %p for stream %p\n", *it, stream); 
    1123             if(!(*it)->enable(cycle)) { 
    1124                 debugOutput( DEBUG_LEVEL_VERBOSE, " could not enable handler (%p)\n",*it); 
    1125                 return false; 
    1126             } 
    1127             bool result; 
    1128             if((*it)->getType() == IsoHandler::eHT_Transmit) { 
    1129                 result = m_IsoTaskTransmit->requestShadowMapUpdate(); 
    1130             } else { 
    1131                 result = m_IsoTaskReceive->requestShadowMapUpdate(); 
    1132             } 
    1133             if(!result) { 
    1134                 debugOutput( DEBUG_LEVEL_VERBOSE, " could not update shadow map for handler (%p)\n",*it); 
    1135                 return false; 
    1136             } 
    1137             return true; 
    1138         } 
    1139     } 
    1140     debugError("Stream %p has no attached handler\n", stream); 
    1141     return false; 
    1142 } 
    1143  
    1144 bool IsoHandlerManager::stopHandlers() { 
    1145     debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 
    1146  
    1147     // check state 
    1148     if(m_State != E_Running) { 
    1149         debugError("Incorrect state, expected E_Running, got %s\n", eHSToString(m_State)); 
    1150         return false; 
    1151     } 
    11521075 
    11531076    bool retval=true; 
     
    11581081    { 
    11591082        debugOutput( DEBUG_LEVEL_VERBOSE, "Stopping handler (%p)\n",*it); 
    1160         if(!(*it)->disable()){ 
    1161             debugOutput( DEBUG_LEVEL_VERBOSE, " could not stop handler (%p)\n",*it); 
    1162             retval=false; 
    1163         } 
    1164         bool result; 
     1083 
     1084        if(!(*it)->requestDisable()) { 
     1085            debugOutput( DEBUG_LEVEL_VERBOSE, " could not request disable for handler %p\n",*it); 
     1086            return false; 
     1087        } 
     1088 
    11651089        if((*it)->getType() == IsoHandler::eHT_Transmit) { 
    1166             result = m_IsoTaskTransmit->requestShadowMapUpdate(); 
     1090            m_IsoTaskTransmit->requestShadowMapUpdate(); 
    11671091        } else { 
    1168             result = m_IsoTaskReceive->requestShadowMapUpdate(); 
    1169         } 
    1170         if(!result) { 
    1171             debugOutput( DEBUG_LEVEL_VERBOSE, " could not update shadow map for handler (%p)\n",*it); 
    1172             return false; 
    1173         } 
     1092            m_IsoTaskReceive->requestShadowMapUpdate(); 
     1093        } 
     1094 
     1095        debugOutput(DEBUG_LEVEL_VERBOSE, " requested disable for handler %p\n", *it); 
    11741096    } 
    11751097 
  • branches/libffado-2.0/src/libieee1394/IsoHandlerManager.h

    r1373 r1526  
    6969         * @brief requests the thread to sync it's stream map with the manager 
    7070         */ 
    71         bool requestShadowMapUpdate(); 
     71        void requestShadowMapUpdate(); 
    7272        enum eActivityResult { 
    7373            eAR_Activity, 
     
    164164        bool init(); 
    165165 
    166         bool disable(IsoHandler *); ///< disables a handler 
    167         bool enable(IsoHandler *); ///< enables a handler 
    168  
    169166        /** 
    170167         * @brief signals that something happened in one of the clients 
     
    188185        int getPacketLatencyForStream(Streaming::StreamProcessor *); 
    189186 
    190         void flushHandlerForStream(Streaming::StreamProcessor *stream); 
    191187        IsoHandler * getHandlerForStream(Streaming::StreamProcessor *stream); 
    192188 
  • branches/libffado-2.0/src/libstreaming/generic/StreamProcessor.cpp

    r1525 r1526  
    172172 * Buffer management and manipulation          * 
    173173 ***********************************************/ 
    174 void StreamProcessor::flush() { 
    175     m_IsoHandlerManager.flushHandlerForStream(this); 
    176 } 
    177174 
    178175int StreamProcessor::getBufferFill() { 
  • branches/libffado-2.0/src/libstreaming/generic/StreamProcessor.h

    r1525 r1526  
    214214    bool shiftStream(int nframes); 
    215215 
    216     /** 
    217      * @brief tries to fill/sink the stream as far as possible 
    218      */ 
    219     void flush(); 
    220  
    221216protected: // the helper receive/transmit functions 
    222217    enum eChildReturnValue {