Changeset 776

Show
Ignore:
Timestamp:
12/26/07 07:26:00 (13 years ago)
Author:
ppalmers
Message:

try to fix deadlock / performace issues

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/src/debugmodule/debugmodule.h

    r742 r776  
    5353#define MB_BUFFERSIZE       DEBUG_MAX_MESSAGE_LENGTH 
    5454 
    55 // #define IMPLEMENT_BACKLOG 
     55#define IMPLEMENT_BACKLOG 
    5656#ifdef IMPLEMENT_BACKLOG 
    5757// the backlog is a similar buffer as the message buffer 
    5858#define BACKLOG_MB_BUFFERS      (256) 
    5959#define BACKLOG_MB_NEXT(index)  (((index)+1) & (BACKLOG_MB_BUFFERS-1)) 
    60 #define BACKLOG_MIN_LEVEL       DEBUG_LEVEL_VERBOSE 
     60#define BACKLOG_MIN_LEVEL       DEBUG_LEVEL_VERY_VERBOSE 
    6161#endif 
    6262 
  • trunk/libffado/src/libieee1394/IsoHandler.cpp

    r759 r776  
    183183    } 
    184184 
     185#ifdef DO_POLL 
    185186    uint64_t poll_enter = m_manager.get1394Service().getCurrentTimeAsUsecs(); 
    186187    err = poll(&m_poll_fd, 1, m_poll_timeout); 
     
    215216                (this->getType()==eHT_Receive?'R':'X'), this,  
    216217                poll_exit-poll_enter, iter_exit-iter_enter); 
     218#else 
     219    // iterate itself blocks if nothing is available 
     220    // so poll'ing is not really necessary 
     221    bool result = iterate(); 
     222    usleep(125); 
     223    return result; 
     224#endif 
    217225    return true; 
    218226} 
  • trunk/libffado/src/libieee1394/IsoHandlerManager.cpp

    r767 r776  
    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         irq_interval=2; 
     442  //      irq_interval=2; 
    443443#endif 
    444444        // the SP specifies how many packets to buffer 
  • trunk/libffado/src/libieee1394/IsoHandlerManager.h

    r767 r776  
    3434#include <vector> 
    3535 
    36 // #define THREAD_PER_ISOHANDLER 
     36#define THREAD_PER_ISOHANDLER 
    3737 
    3838#define FFADO_MAX_ISO_HANDLERS_PER_PORT 16 
  • trunk/libffado/src/libstreaming/amdtp/AmdtpTransmitStreamProcessor.cpp

    r766 r776  
    162162        else 
    163163        { 
     164            unsigned int now_cycle = ( unsigned int ) ( TICKS_TO_CYCLES ( m_1394service.getCycleTimerTicks() ) ); 
     165 
    164166            debugOutput ( DEBUG_LEVEL_VERBOSE, 
    165                         "Insufficient frames (NP): N=%02d, CY=%04u, TC=%04u, CUT=%04d\n", 
    166                         fc, cycle, transmit_at_cycle, cycles_until_transmit ); 
    167             debugWarning( "Insufficient frames (NP): N=%02d, CY=%04u, TC=%04u, CUT=%04d\n", 
    168                           fc, cycle, transmit_at_cycle, cycles_until_transmit ); 
     167                        "Insufficient frames (NP): N=%02d, CY=%04u, TC=%04u, CUT=%04d, NOW=%04d\n", 
     168                        fc, cycle, transmit_at_cycle, cycles_until_transmit, now_cycle ); 
     169            debugWarning("Insufficient frames (NP): N=%02d, CY=%04u, TC=%04u, CUT=%04d, NOW=%04d\n", 
     170                         fc, cycle, transmit_at_cycle, cycles_until_transmit, now_cycle ); 
     171 
    169172            // there is still time left to send the packet 
    170173            // we want the system to give this packet another go at a later time instant 
     
    213216                        transmit_at_cycle, cycles_until_transmit, 
    214217                        presentation_time, (unsigned int)TICKS_TO_CYCLES(presentation_time) ); 
    215  
     218            debugShowBackLogLines(200); 
     219            flushDebugOutput(); 
    216220            // however, if we can send this sufficiently before the presentation 
    217221            // time, it could be harmless. 
  • trunk/libffado/src/libstreaming/generic/StreamProcessor.cpp

    r775 r776  
    113113    // however we have to take into account the fact that there is some sync delay (unknown at this point) 
    114114    packets_to_prebuffer -= 16; //FIXME: magic 
     115     
     116    // only queue a part (80%) of the theoretical max in order not to have too much 'not ready' cycles 
     117    packets_to_prebuffer = (packets_to_prebuffer * 8000) / 10000; 
    115118     
    116119    return packets_to_prebuffer; 
     
    615618                } 
    616619            } 
    617             usleep(125); // only when using thread per handler mode! 
    618             return RAW1394_ISO_AGAIN; 
     620//             return RAW1394_ISO_AGAIN; 
     621            generateSilentPacketHeader(data, length, tag, sy, cycle, dropped_cycles, max_length); 
     622            generateSilentPacketData(data, length, tag, sy, cycle, dropped_cycles, max_length); 
     623            return RAW1394_ISO_DEFER; 
    619624        } else { 
    620625            debugError("Invalid return value: %d\n", result); 
  • trunk/libffado/src/libstreaming/StreamProcessorManager.cpp

    r766 r776  
    410410    // wait for the syncsource to start running. 
    411411    // that will block the waitForPeriod call until everyone has started (theoretically) 
    412     int cnt = CYCLES_FOR_STARTUP * 2; // by then it should have started 
     412    int cnt = CYCLES_FOR_STARTUP * 20; // by then it should have started 
    413413    while (!m_SyncSource->isRunning() && cnt) { 
    414414        usleep(125); 
     
    432432StreamProcessorManager::alignReceivedStreams() 
    433433{ 
    434     #define NB_PERIODS_FOR_ALIGN_AVERAGE 2
    435     #define NB_ALIGN_TRIES 2
     434    #define ALIGN_AVERAGE_TIME_MSEC 20
     435    #define NB_ALIGN_TRIES 4
    436436    debugOutput( DEBUG_LEVEL_VERBOSE, "Aligning received streams...\n"); 
    437437    unsigned int nb_sync_runs; 
     
    442442    unsigned int i; 
    443443 
     444    unsigned int periods_per_align_try = (ALIGN_AVERAGE_TIME_MSEC * getNominalRate()); 
     445    periods_per_align_try /= 1000; 
     446    periods_per_align_try /= getPeriodSize(); 
     447    debugOutput( DEBUG_LEVEL_VERBOSE, " averaging over %u periods...\n", periods_per_align_try); 
     448 
    444449    bool aligned = false; 
    445450    int cnt = NB_ALIGN_TRIES; 
    446451    while (!aligned && cnt--) { 
    447         nb_sync_runs = NB_PERIODS_FOR_ALIGN_AVERAGE
     452        nb_sync_runs = periods_per_align_try
    448453        while(nb_sync_runs) { 
    449454            debugOutput( DEBUG_LEVEL_VERY_VERBOSE, " check (%d)...\n", nb_sync_runs); 
     
    456461                debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "  offset between SyncSP %p and SP %p is %lld ticks...\n",  
    457462                    m_SyncSource, s, diff); 
    458                 if ( nb_sync_runs == NB_PERIODS_FOR_ALIGN_AVERAGE ) { 
     463                if ( nb_sync_runs == periods_per_align_try ) { 
    459464                    diff_between_streams[i] = diff; 
    460465                } else { 
     
    475480            StreamProcessor *s = m_ReceiveProcessors.at(i); 
    476481 
    477             diff_between_streams[i] /= NB_PERIODS_FOR_ALIGN_AVERAGE
     482            diff_between_streams[i] /= periods_per_align_try
    478483            diff_between_streams_frames[i] = (int)roundf(diff_between_streams[i] / s->getTicksPerFrame()); 
    479484            debugOutput( DEBUG_LEVEL_VERBOSE, "   avg offset between SyncSP %p and SP %p is %lld ticks, %d frames...\n",