Changeset 767

Show
Ignore:
Timestamp:
12/23/07 07:21:18 (13 years ago)
Author:
ppalmers
Message:

code refactoring

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/src/libieee1394/CycleTimerHelper.cpp

    r764 r767  
    3232#define DLL_COEFF_B   (DLL_SQRT2 * DLL_OMEGA) 
    3333#define DLL_COEFF_C   (DLL_OMEGA * DLL_OMEGA) 
     34 
     35/* 
     36#define ENTER_CRITICAL_SECTION { \ 
     37    if (pthread_mutex_trylock(&m_compute_vars_lock) == EBUSY) { \ 
     38        debugWarning(" (%p) lock clash\n", this); \ 
     39        ENTER_CRITICAL_SECTION; \ 
     40    } \ 
     41    } 
     42*/ 
     43#define ENTER_CRITICAL_SECTION { \ 
     44    ENTER_CRITICAL_SECTION; \ 
     45    } 
     46#define EXIT_CRITICAL_SECTION { \ 
     47    EXIT_CRITICAL_SECTION; \ 
     48    } 
     49 
    3450 
    3551IMPL_DEBUG_MODULE( CycleTimerHelper, CycleTimerHelper, DEBUG_LEVEL_NORMAL ); 
     
    168184CycleTimerHelper::Execute() 
    169185{ 
    170     debugOutput( DEBUG_LEVEL_ULTRA_VERBOSE, "Execute %p...\n", this); 
     186    debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "Execute %p...\n", this); 
    171187    uint32_t cycle_timer; 
    172188    uint64_t local_time; 
     
    175191        return false; 
    176192    } 
    177     debugOutput( DEBUG_LEVEL_ULTRA_VERBOSE, " read : CTR: %11lu, local: %17llu\n", 
     193    debugOutput( DEBUG_LEVEL_VERY_VERBOSE, " read : CTR: %11lu, local: %17llu\n", 
    178194                    cycle_timer, local_time); 
    179195 
     
    195211 
    196212        double diff = m_next_time_usecs - m_current_time_usecs; 
    197         debugOutput( DEBUG_LEVEL_ULTRA_VERBOSE, " usecs: local: %11llu current: %f next: %f, diff: %f\n", 
     213        debugOutput( DEBUG_LEVEL_VERY_VERBOSE, " usecs: local: %11llu current: %f next: %f, diff: %f\n", 
    198214                    local_time, m_current_time_usecs, m_next_time_usecs, diff); 
    199215 
     
    204220        m_current_time_usecs = m_next_time_usecs; 
    205221        m_next_time_usecs = (local_time - usecs_late) + m_usecs_per_update; 
    206         debugOutput( DEBUG_LEVEL_ULTRA_VERBOSE, " usecs: current: %f next: %f usecs_late=%f\n", 
     222        debugOutput( DEBUG_LEVEL_VERY_VERBOSE, " usecs: current: %f next: %f usecs_late=%f\n", 
    207223                    m_current_time_usecs, m_next_time_usecs, usecs_late); 
    208224 
     
    213229                                     (uint64_t)((DLL_COEFF_B * diff_ticks) + m_dll_e2)); 
    214230        m_dll_e2 += DLL_COEFF_C * diff_ticks; 
    215         debugOutput( DEBUG_LEVEL_ULTRA_VERBOSE, " ticks: current: %f next: %f diff=%f\n", 
     231        debugOutput( DEBUG_LEVEL_VERY_VERBOSE, " ticks: current: %f next: %f diff=%f\n", 
    216232                    m_current_time_ticks, m_next_time_ticks, diff_ticks); 
    217233 
    218         debugOutput( DEBUG_LEVEL_ULTRA_VERBOSE, " state: local: %11llu, dll_e2: %f, rate: %f\n", 
     234        debugOutput( DEBUG_LEVEL_VERY_VERBOSE, " state: local: %11llu, dll_e2: %f, rate: %f\n", 
    219235                    local_time, m_dll_e2, getRate()); 
    220236    } 
     
    224240 
    225241    // FIXME: priority inversion! 
    226     pthread_mutex_lock(&m_compute_vars_lock)
     242    ENTER_CRITICAL_SECTION
    227243    m_current_vars.ticks = m_current_time_ticks; 
    228244    m_current_vars.usecs = m_current_time_usecs; 
    229245    m_current_vars.rate = getRate(); 
    230     pthread_mutex_unlock(&m_compute_vars_lock)
     246    EXIT_CRITICAL_SECTION
    231247 
    232248    // wait for the next update period 
     
    235251    //int64_t time_to_sleep = m_usecs_per_update; 
    236252    if (time_to_sleep > 0) { 
    237         debugOutput( DEBUG_LEVEL_ULTRA_VERBOSE, " sleeping %lld usecs (avg delay: %f)\n", time_to_sleep, m_avg_wakeup_delay); 
     253        debugOutput( DEBUG_LEVEL_VERY_VERBOSE, " sleeping %lld usecs (avg delay: %f)\n", time_to_sleep, m_avg_wakeup_delay); 
    238254        usleep(time_to_sleep); 
    239255    } 
     
    255271 
    256272    // reduce lock contention 
    257     pthread_mutex_lock(&m_compute_vars_lock)
     273    ENTER_CRITICAL_SECTION
    258274    my_vars = m_current_vars; 
    259     pthread_mutex_unlock(&m_compute_vars_lock)
     275    EXIT_CRITICAL_SECTION
    260276 
    261277    double time_diff = now - my_vars.usecs; 
     
    266282    if (y_step_in_ticks_int > 0) { 
    267283        retval = addTicks(offset_in_ticks_int, y_step_in_ticks_int); 
     284        debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "y_step_in_ticks_int > 0: %lld, time_diff: %f, rate: %f, retval: %lu\n",  
     285                     y_step_in_ticks_int, time_diff, my_vars.rate, retval); 
    268286    } else { 
     287        retval = substractTicks(offset_in_ticks_int, -y_step_in_ticks_int); 
     288 
    269289        // this can happen if the update thread was woken up earlier than it should have been 
    270         debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "y_step_in_ticks_int <= 0: %lld, time_diff: %f, rate: %f\n",  
    271                      y_step_in_ticks_int, time_diff, my_vars.rate); 
    272         retval = substractTicks(offset_in_ticks_int, -y_step_in_ticks_int); 
     290        debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "y_step_in_ticks_int <= 0: %lld, time_diff: %f, rate: %f, retval: %lu\n",  
     291                     y_step_in_ticks_int, time_diff, my_vars.rate, retval); 
    273292    } 
    274293 
  • trunk/libffado/src/libieee1394/IsoHandlerManager.cpp

    r759 r767  
    356356        if(irq_interval <= 0) irq_interval=1; 
    357357        // FIXME: test 
    358         //irq_interval=1; 
     358        irq_interval=1; 
    359359 
    360360#else 
     
    440440            debugError("Max packet size too large! (%d)\n", stream->getMaxPacketSize()); 
    441441        } 
    442  
     442        irq_interval=2; 
    443443#endif 
    444444        // the SP specifies how many packets to buffer 
  • trunk/libffado/src/libieee1394/IsoHandlerManager.h

    r760 r767  
    3434#include <vector> 
    3535 
    36 //#define THREAD_PER_ISOHANDLER 
     36// #define THREAD_PER_ISOHANDLER 
    3737 
    3838#define FFADO_MAX_ISO_HANDLERS_PER_PORT 16