Changeset 469 for pjproject


Ignore:
Timestamp:
May 22, 2006 10:28:44 AM (19 years ago)
Author:
bennylp
Message:

Put back high thread priority in dsound.c

Location:
pjproject/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia/dsound.c

    r467 r469  
    463463 
    464464 
    465     /* Raise self priority */ 
    466     //SetThreadPriority( GetCurrentThread(), THREAD_PRIORITY_HIGHEST); 
     465    /* Raise self priority. We don't want the audio to be distorted by 
     466     * system activity. 
     467     */ 
     468    SetThreadPriority( GetCurrentThread(), THREAD_PRIORITY_HIGHEST); 
    467469 
    468470    /* Calculate bytes per frame */ 
  • pjproject/trunk/pjsip-apps/src/samples/sndtest.c

    r464 r469  
    3737#define DURATION            10000 
    3838 
    39 /* Max frames per sec. */ 
     39/* Skip the first msec from the calculation */ 
     40#define SKIP_DURATION       1000 
     41 
     42/* Max frames per sec (to calculate number of delays to keep). */ 
    4043#define MAX_FRAMES_PER_SEC  100 
    4144 
     
    134137    struct stream_data *strm_data = &test_data->playback_data; 
    135138 
     139    /* Skip frames when test is not started or test has finished */ 
    136140    if (!test_data->running) { 
    137141        pj_memset(output, 0, size); 
     
    139143    } 
    140144 
     145    /* Save last timestamp seen (to calculate drift) */ 
    141146    strm_data->last_timestamp = timestamp; 
    142147 
    143148    if (strm_data->last_called.u64 == 0) { 
    144149        pj_get_timestamp(&strm_data->last_called); 
     150        /* Init min_delay to one frame */ 
    145151        strm_data->min_delay = test_data->samples_per_frame * 1000000 / 
    146152                               test_data->clock_rate; 
     
    153159        pj_get_timestamp(&now); 
    154160         
     161        /* Calculate frame interval */ 
    155162        delay = pj_elapsed_usec(&strm_data->last_called, &now); 
    156163        if (delay < strm_data->min_delay) 
     
    161168        strm_data->last_called = now; 
    162169 
     170        /* Save the frame interval for later calculation */ 
    163171        strm_data->delay[strm_data->counter] = delay; 
    164172        ++strm_data->counter; 
     173 
     174    } else { 
     175 
     176        /* No space, can't take anymore frames */ 
     177        test_data->running = 0; 
     178 
    165179    } 
    166180 
     
    179193    PJ_UNUSED_ARG(size); 
    180194 
     195    /* Skip frames when test is not started or test has finished */ 
    181196    if (!test_data->running) { 
    182197        return PJ_SUCCESS; 
    183198    } 
    184199 
     200    /* Save last timestamp seen (to calculate drift) */ 
    185201    strm_data->last_timestamp = timestamp; 
    186202 
    187203    if (strm_data->last_called.u64 == 0) { 
    188204        pj_get_timestamp(&strm_data->last_called); 
     205        /* Init min_delay to one frame */ 
    189206        strm_data->min_delay = test_data->samples_per_frame * 1000000 / 
    190207                               test_data->clock_rate; 
     
    196213 
    197214        pj_get_timestamp(&now); 
    198          
     215 
     216        /* Calculate frame interval */ 
    199217        delay = pj_elapsed_usec(&strm_data->last_called, &now); 
    200218        if (delay < strm_data->min_delay) 
     
    205223        strm_data->last_called = now; 
    206224 
     225        /* Save the frame interval for later calculation */ 
    207226        strm_data->delay[strm_data->counter] = delay; 
    208227        ++strm_data->counter; 
     228 
     229    } else { 
     230 
     231        /* No space, can't take anymore frames */ 
     232        test_data->running = 0; 
     233 
    209234    } 
    210235 
     
    228253{ 
    229254    unsigned i, dur; 
    230     unsigned min_jitter, max_jitter, avg_jitter=0; 
     255    unsigned min_jitter, max_jitter, sum_jitter, avg_jitter=0; 
    231256 
    232257    PJ_LOG(3,(THIS_FILE, "  %s stream report:", title)); 
     
    276301    min_jitter = 0xFFFFF; 
    277302    max_jitter = 0; 
     303    sum_jitter = 0; 
    278304 
    279305    for (i=1; i<strm_data->counter; ++i) { 
     
    285311        if (jitter > (int)max_jitter) max_jitter = jitter; 
    286312 
    287         avg_jitter = ((i-1) * avg_jitter + jitter) / i; 
    288     } 
     313        sum_jitter += jitter; 
     314    } 
     315 
     316    avg_jitter = (sum_jitter) / (strm_data->counter - 1); 
     317 
    289318    if (max_jitter < WARN_JITTER_USEC) { 
    290319        PJ_LOG(3,(THIS_FILE,  
     
    347376 
    348377    /* Sleep for a while to let sound device "settles" */ 
    349     pj_thread_sleep(100); 
     378    pj_thread_sleep(200); 
    350379 
    351380 
     
    359388    } 
    360389 
    361     /* Let the stream runs for 1 second to get stable result. 
     390    PJ_LOG(3,(THIS_FILE, 
     391              " Please wait while test is in progress (~%d secs)..", 
     392              (DURATION+SKIP_DURATION)/1000)); 
     393 
     394    /* Let the stream runs for few msec/sec to get stable result. 
    362395     * (capture normally begins with frames available simultaneously). 
    363396     */ 
    364     pj_thread_sleep(1000); 
     397    pj_thread_sleep(SKIP_DURATION); 
    365398 
    366399 
     
    371404     * Let the test runs for a while. 
    372405     */ 
    373     PJ_LOG(3,(THIS_FILE, 
    374               " Please wait while test is in progress (~%d secs)..", 
    375               (DURATION/1000))); 
    376406    pj_thread_sleep(DURATION); 
    377407 
     
    427457            PJ_LOG(2,(THIS_FILE,  
    428458                      "   Sound capture is %d samples %s than playback " 
    429                       "at the end of the test (at the rate about %d samples" 
     459                      "at the end of the test (average is %d samples" 
    430460                      " per second)", 
    431461                      drift, which,  
Note: See TracChangeset for help on using the changeset viewer.