Changeset 837


Ignore:
Timestamp:
Nov 29, 2006 11:12:26 PM (17 years ago)
Author:
bennylp
Message:

Fixed sndtest bug (ticket #32): it doesn't display the correct device being tested when default device is used.

File:
1 edited

Legend:

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

    r657 r837  
    131131 
    132132 
    133 static const char *get_dev_name(int dev_id) 
    134 { 
    135     const pjmedia_snd_dev_info *info; 
    136  
    137     if (dev_id == -1) 
    138         dev_id = 0; 
    139  
    140     info = pjmedia_snd_get_dev_info(dev_id); 
    141     if (info == NULL) 
    142         return "????"; 
    143  
    144     return info->name; 
    145 } 
    146  
    147  
    148133static pj_status_t play_cb(void *user_data, pj_uint32_t timestamp, 
    149134                           void *output, unsigned size) 
     
    369354 
    370355 
    371 static int perform_test(const char *title, int dev_id, pjmedia_dir dir, 
     356static int perform_test(int dev_id, pjmedia_dir dir, 
    372357                        unsigned clock_rate, unsigned samples_per_frame,  
    373358                        unsigned nchannel, int verbose) 
     
    376361    pjmedia_snd_stream *strm; 
    377362    struct test_data test_data; 
     363    pjmedia_snd_stream_info si; 
    378364 
    379365 
     
    390376     * Open device. 
    391377     */ 
    392     PJ_LOG(3,(THIS_FILE, "Testing %s", title)); 
    393  
    394378    if (dir == PJMEDIA_DIR_CAPTURE) { 
    395379        status = pjmedia_snd_open_rec( dev_id, clock_rate, nchannel, 
     
    409393        app_perror("Unable to open device for capture", status); 
    410394        return status; 
     395    } 
     396 
     397    pjmedia_snd_stream_get_info(strm, &si); 
     398    if (si.play_id >= 0) { 
     399        PJ_LOG(3,(THIS_FILE, "Testing playback device %s",  
     400                  pjmedia_snd_get_dev_info(si.play_id)->name)); 
     401    } 
     402    if (si.rec_id >= 0) { 
     403        PJ_LOG(3,(THIS_FILE, "Testing capture device %s",  
     404                  pjmedia_snd_get_dev_info(si.rec_id)->name)); 
    411405    } 
    412406 
     
    595589 
    596590 
    597     status = perform_test(get_dev_name(id), id, PJMEDIA_DIR_CAPTURE_PLAYBACK,  
     591    status = perform_test(id, PJMEDIA_DIR_CAPTURE_PLAYBACK,  
    598592                          clock_rate, frame, channel, verbose); 
    599593    if (status != 0) 
Note: See TracChangeset for help on using the changeset viewer.