Ignore:
Timestamp:
Apr 3, 2006 9:43:36 AM (18 years ago)
Author:
bennylp
Message:

Added DirectSound? sound implementation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip-apps/src/samples/sndinfo.c

    r353 r371  
    7676static int play_counter; 
    7777static int rec_counter; 
     78static int min_delay = 0xFFFF, max_delay; 
     79static char play_delays[1000]; 
    7880 
    7981static pj_status_t play_cb(void *user_data, pj_uint32_t timestamp, 
    8082                           void *output, unsigned size) 
    8183{ 
     84    static pj_time_val last_cb; 
     85 
    8286    ++play_counter; 
     87 
     88    if (last_cb.sec == 0 && last_cb.msec == 0) { 
     89        pj_gettimeofday(&last_cb); 
     90    } else { 
     91        pj_time_val now, saved; 
     92        int delay; 
     93 
     94        pj_gettimeofday(&now); 
     95        saved = now; 
     96        PJ_TIME_VAL_SUB(now, last_cb); 
     97        delay = PJ_TIME_VAL_MSEC(now); 
     98 
     99        if (delay < min_delay) 
     100            min_delay = delay; 
     101        if (delay > max_delay) 
     102            max_delay = delay; 
     103 
     104        last_cb = saved; 
     105 
     106        play_delays[play_counter-1] = delay; 
     107    } 
     108 
    83109    return PJ_SUCCESS; 
    84110} 
     
    99125            title, errmsg, status); 
    100126} 
    101                  
     127 
    102128static int open_device(int dev_id, pjmedia_dir dir, 
    103129                       int clock_rate, int nchannel, int bits) 
     
    107133    pjmedia_snd_stream *strm; 
    108134    const char *dirtype; 
     135    unsigned i; 
    109136 
    110137    switch (dir) { 
     
    166193 
    167194    puts("Success."); 
     195 
     196    printf("Delay: "); 
     197    for (i=0; i<play_counter; ++i) 
     198        printf("%d ", play_delays[i]); 
     199 
     200    puts(""); 
     201    if (dir & PJMEDIA_DIR_PLAYBACK) { 
     202        printf("Callback interval: min interval=%d ms, max interval=%d ms\n", 
     203               min_delay, max_delay); 
     204    } 
     205     
     206 
    168207    return 0; 
    169208} 
Note: See TracChangeset for help on using the changeset viewer.