Changeset 2555 for pjproject


Ignore:
Timestamp:
Mar 27, 2009 3:15:46 PM (16 years ago)
Author:
nanang
Message:

Ticket #771 (auddev-misc):
Updated audio test tool:

  • Fixed playback report on avg interval.
  • Added feature to set/get capture & playback latecies setting.
  • Minor update on drift calculation, improve a bit readibility for debugging.
Location:
pjproject/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia-audiodev/audiotest.c

    r2506 r2555  
    235235    result->play.min_interval = DIV_ROUND(test_data.playback_data.delay.min, 1000); 
    236236    result->play.max_interval = DIV_ROUND(test_data.playback_data.delay.max, 1000); 
    237     result->play.avg_interval = DIV_ROUND(test_data.capture_data.delay.mean, 1000); 
     237    result->play.avg_interval = DIV_ROUND(test_data.playback_data.delay.mean, 1000); 
    238238    result->play.dev_interval = DIV_ROUND(tmp, 1000); 
    239239    result->play.max_burst    = DIV_ROUND_UP(result->play.max_interval, ptime); 
     
    241241    /* Check drifting */ 
    242242    if (param->dir == PJMEDIA_DIR_CAPTURE_PLAYBACK) { 
    243         int end_diff, start_diff, drift; 
    244  
    245         end_diff = test_data.capture_data.last_timestamp - 
    246                    test_data.playback_data.last_timestamp; 
    247         start_diff = test_data.capture_data.first_timestamp- 
    248                       test_data.playback_data.first_timestamp; 
    249         drift = end_diff > start_diff? end_diff - start_diff : 
    250                 start_diff - end_diff; 
     243        int play_diff, cap_diff, drift; 
     244 
     245        play_diff = test_data.playback_data.last_timestamp - 
     246                    test_data.playback_data.first_timestamp; 
     247        cap_diff  = test_data.capture_data.last_timestamp - 
     248                    test_data.capture_data.first_timestamp; 
     249        drift = play_diff > cap_diff? play_diff - cap_diff : 
     250                cap_diff - play_diff; 
    251251 
    252252        /* Allow one frame tolerance for clock drift detection */ 
  • pjproject/trunk/pjsip-apps/src/samples/auddemo.c

    r2517 r2555  
    3030 
    3131static unsigned dev_count; 
     32static unsigned playback_lat = PJMEDIA_SND_DEFAULT_PLAY_LATENCY; 
     33static unsigned capture_lat = PJMEDIA_SND_DEFAULT_REC_LATENCY; 
    3234 
    3335static void app_perror(const char *title, pj_status_t status) 
     
    178180    param.channel_count = chnum; 
    179181    param.samples_per_frame = clock_rate * chnum * ptime / 1000; 
     182 
     183    /* Latency settings */ 
     184    param.flags |= (PJMEDIA_AUD_DEV_CAP_INPUT_LATENCY |  
     185                    PJMEDIA_AUD_DEV_CAP_OUTPUT_LATENCY); 
     186    param.input_latency_ms = capture_lat; 
     187    param.output_latency_ms = playback_lat; 
    180188 
    181189    PJ_LOG(3,(THIS_FILE, "Performing test..")); 
     
    384392    puts("  r RID [FILE]             Record capture device RID to WAV file"); 
    385393    puts("  p PID [FILE]             Playback WAV file to device ID PID"); 
     394    puts("  d [RLAT [PLAT]]          Get/set sound device latencies (in ms):"); 
     395    puts("                             Specify no param to get current latencies setting"); 
     396    puts("                             RLAT      :  record latency (-1 for default)"); 
     397    puts("                             PLAT      :  playback latency (-1 for default)"); 
    386398    puts("  v                        Toggle log verbosity"); 
    387399    puts("  q                        Quit"); 
     
    521533            break; 
    522534 
     535        case 'd': 
     536            /* latencies */ 
     537            { 
     538                int rec_lat, play_lat; 
     539 
     540                if (sscanf(line+2, "%d %d", &rec_lat, &play_lat) == 2) { 
     541                    capture_lat = (unsigned)  
     542                         (rec_lat>=0? rec_lat:PJMEDIA_SND_DEFAULT_REC_LATENCY); 
     543                    playback_lat = (unsigned) 
     544                         (play_lat >= 0? play_lat : PJMEDIA_SND_DEFAULT_PLAY_LATENCY); 
     545                    printf("Recording latency=%ums, playback latency=%ums", 
     546                           capture_lat, playback_lat); 
     547                } else { 
     548                    printf("Current latencies: record=%ums, playback=%ums", 
     549                           capture_lat, playback_lat); 
     550                } 
     551                puts(""); 
     552            } 
     553            break; 
     554 
    523555        case 'v': 
    524556            if (pj_log_get_level() <= 3) { 
Note: See TracChangeset for help on using the changeset viewer.