Changeset 410 for pjproject/trunk


Ignore:
Timestamp:
Apr 25, 2006 10:02:40 AM (19 years ago)
Author:
bennylp
Message:

Added sound clock drifting reporting in sndinfo sample

File:
1 edited

Legend:

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

    r373 r410  
    7474} 
    7575 
     76static int clock_rate; 
    7677static int play_counter; 
    7778static int rec_counter; 
    7879static int min_delay = 0xFFFF, max_delay; 
    7980static char play_delays[1000]; 
     81static pj_uint32_t last_play_timestamp, last_rec_timestamp; 
    8082 
    8183static pj_status_t play_cb(void *user_data, pj_uint32_t timestamp, 
     
    8587 
    8688    ++play_counter; 
     89    last_play_timestamp = timestamp; 
    8790 
    8891    if (last_cb.u64 == 0) { 
    8992        pj_get_timestamp(&last_cb); 
    90     } else { 
     93    } else if (play_counter <= PJ_ARRAY_SIZE(play_delays)) { 
    9194        pj_timestamp now; 
    9295        int delay; 
     
    112115{ 
    113116    ++rec_counter; 
     117 
     118    if (timestamp - last_rec_timestamp >= clock_rate) { 
     119        int diff; 
     120        diff = last_play_timestamp - timestamp; 
     121        printf("Play timestamp=%u, capture timestamp=%u, diff=%d\n", 
     122               last_play_timestamp, timestamp, diff); 
     123        last_rec_timestamp = timestamp; 
     124    } 
    114125    return PJ_SUCCESS; 
    115126} 
     
    125136 
    126137static int open_device(int dev_id, pjmedia_dir dir, 
    127                        int clock_rate, int nchannel, int bits) 
     138                       int nchannel, int bits) 
    128139{ 
    129140    pj_status_t status = PJ_SUCCESS; 
     
    131142    pjmedia_snd_stream *strm; 
    132143    const char *dirtype; 
     144    char tmp[10]; 
    133145    unsigned i; 
    134146 
     
    176188     
    177189    /* Let playback/capture runs for a while */ 
    178     pj_thread_sleep(1000); 
     190    //pj_thread_sleep(1000); 
     191    puts("Press <ENTER> to stop"); 
     192    fgets(tmp, sizeof(tmp), stdin); 
     193 
    179194 
    180195    pjmedia_snd_stream_close(strm); 
     
    235250        int dev_id; 
    236251        pjmedia_dir dir; 
    237         int clock_rate; 
    238252        int nchannel; 
    239253        int bits; 
     
    252266        bits = atoi(argv[5]); 
    253267 
    254         return open_device(dev_id, dir, clock_rate, nchannel, bits); 
     268        return open_device(dev_id, dir, nchannel, bits); 
    255269 
    256270    } else { 
Note: See TracChangeset for help on using the changeset viewer.