Changeset 5677


Ignore:
Timestamp:
Oct 27, 2017 6:30:50 AM (20 months ago)
Author:
ming
Message:

Fixed #2053: Update pjsua_get_snd_dev() info before calling on_snd_dev_operation() callback

Location:
pjproject/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/include/pjmedia/audiodev.h

    r5430 r5677  
    5050 * Device index constants. 
    5151 */ 
    52 enum 
     52typedef enum pjmedia_aud_dev_id 
    5353{ 
    5454    /**  
     
    6666     */ 
    6767    PJMEDIA_AUD_INVALID_DEV = -3 
    68 }; 
     68} pjmedia_aud_dev_id; 
    6969 
    7070 
  • pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c

    r5534 r5677  
    960960static pj_status_t on_snd_dev_operation(int operation) 
    961961{ 
    962     PJ_LOG(3,(THIS_FILE, "Turning sound device %s", (operation? "ON":"OFF"))); 
     962    int cap_dev, play_dev; 
     963 
     964    pjsua_get_snd_dev(&cap_dev, &play_dev); 
     965    PJ_LOG(3,(THIS_FILE, "Turning sound device %d %d %s", cap_dev, play_dev, 
     966              (operation? "ON":"OFF"))); 
    963967    return PJ_SUCCESS; 
    964968} 
  • pjproject/trunk/pjsip-apps/src/swig/symbols.i

    r5649 r5677  
    5656 
    5757typedef enum pjmedia_vid_dev_cap {PJMEDIA_VID_DEV_CAP_FORMAT = 1, PJMEDIA_VID_DEV_CAP_INPUT_SCALE = 2, PJMEDIA_VID_DEV_CAP_OUTPUT_WINDOW = 4, PJMEDIA_VID_DEV_CAP_OUTPUT_RESIZE = 8, PJMEDIA_VID_DEV_CAP_OUTPUT_POSITION = 16, PJMEDIA_VID_DEV_CAP_OUTPUT_HIDE = 32, PJMEDIA_VID_DEV_CAP_INPUT_PREVIEW = 64, PJMEDIA_VID_DEV_CAP_ORIENTATION = 128, PJMEDIA_VID_DEV_CAP_SWITCH = 256, PJMEDIA_VID_DEV_CAP_OUTPUT_WINDOW_FLAGS = 512, PJMEDIA_VID_DEV_CAP_MAX = 16384} pjmedia_vid_dev_cap; 
     58 
     59typedef enum pjmedia_aud_dev_id {PJMEDIA_AUD_DEFAULT_CAPTURE_DEV = -1, PJMEDIA_AUD_DEFAULT_PLAYBACK_DEV = -2, PJMEDIA_AUD_INVALID_DEV = -3} pjmedia_aud_dev_id; 
    5860 
    5961typedef enum pjmedia_aud_dev_route {PJMEDIA_AUD_DEV_ROUTE_DEFAULT = 0, PJMEDIA_AUD_DEV_ROUTE_LOUDSPEAKER = 1, PJMEDIA_AUD_DEV_ROUTE_EARPIECE = 2, PJMEDIA_AUD_DEV_ROUTE_BLUETOOTH = 4, PJMEDIA_AUD_DEV_ROUTE_CUSTOM = 128} pjmedia_aud_dev_route; 
     
    174176typedef enum pjsua_create_media_transport_flag {PJSUA_MED_TP_CLOSE_MEMBER = 1} pjsua_create_media_transport_flag; 
    175177 
     178typedef enum pjsua_snd_dev_id {PJSUA_SND_DEFAULT_CAPTURE_DEV = PJMEDIA_AUD_DEFAULT_CAPTURE_DEV, PJSUA_SND_DEFAULT_PLAYBACK_DEV = PJMEDIA_AUD_DEFAULT_PLAYBACK_DEV, PJSUA_SND_NO_DEV = PJMEDIA_AUD_INVALID_DEV, PJSUA_SND_NULL_DEV = -99} pjsua_snd_dev_id; 
     179 
    176180typedef enum pjsua_snd_dev_mode {PJSUA_SND_DEV_SPEAKER_ONLY = 1, PJSUA_SND_DEV_NO_IMMEDIATE_OPEN = 2} pjsua_snd_dev_mode; 
    177181 
  • pjproject/trunk/pjsip-apps/src/swig/symbols.lst

    r5649 r5677  
    1212pjmedia/vid_stream.h            pjmedia_vid_stream_rc_method 
    1313pjmedia-videodev/videodev.h     pjmedia_vid_dev_index pjmedia_vid_dev_std_index pjmedia_vid_dev_cap 
    14 pjmedia-audiodev/audiodev.h     pjmedia_aud_dev_route pjmedia_aud_dev_cap 
     14pjmedia-audiodev/audiodev.h     pjmedia_aud_dev_id pjmedia_aud_dev_route pjmedia_aud_dev_cap 
    1515pjmedia/wav_port.h              pjmedia_file_writer_option pjmedia_file_player_option 
    1616pjmedia/tonegen.h               pjmedia_tone_digit pjmedia_tone_digit_map pjmedia_tone_desc 
     
    3434pjsip-ua/sip_inv.h              pjsip_inv_state 
    3535 
    36 pjsua-lib/pjsua.h               pjsua_invalid_id_const_ pjsua_state pjsua_stun_use pjsua_call_hold_type pjsua_acc_id pjsua_destroy_flag pjsua_100rel_use pjsua_sip_timer_use pjsua_ipv6_use pjsua_nat64_opt pjsua_buddy_status pjsua_call_media_status pjsua_vid_win_id pjsua_call_id pjsua_med_tp_st pjsua_call_vid_strm_op pjsua_vid_req_keyframe_method pjsua_call_flag pjsua_create_media_transport_flag pjsua_snd_dev_mode pjsua_ip_change_op 
     36pjsua-lib/pjsua.h               pjsua_invalid_id_const_ pjsua_state pjsua_stun_use pjsua_call_hold_type pjsua_acc_id pjsua_destroy_flag pjsua_100rel_use pjsua_sip_timer_use pjsua_ipv6_use pjsua_nat64_opt pjsua_buddy_status pjsua_call_media_status pjsua_vid_win_id pjsua_call_id pjsua_med_tp_st pjsua_call_vid_strm_op pjsua_vid_req_keyframe_method pjsua_call_flag pjsua_create_media_transport_flag pjsua_snd_dev_id pjsua_snd_dev_mode pjsua_ip_change_op 
  • pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h

    r5676 r5677  
    14471447     * sound device is configured by the application (i.e. the 
    14481448     * #pjsua_set_null_snd_dev() and #pjsua_set_no_snd_dev() APIs). 
    1449      * This API is mostly useful when the application wants to manage 
     1449     * Application can use the API #pjsua_get_snd_dev() to get the info 
     1450     * about which sound device is going to be opened/closed. 
     1451     * 
     1452     * This callback is mostly useful when the application wants to manage 
    14501453     * the sound device by itself (i.e. with #pjsua_set_no_snd_dev()), 
    14511454     * to get notified when it should open or close the sound device. 
     
    64076410} pjsua_media_transport; 
    64086411 
     6412 
     6413/** 
     6414 * Sound device index constants. 
     6415 */ 
     6416typedef enum pjsua_snd_dev_id 
     6417{ 
     6418    /**  
     6419     * Constant to denote default capture device. 
     6420     */ 
     6421    PJSUA_SND_DEFAULT_CAPTURE_DEV = PJMEDIA_AUD_DEFAULT_CAPTURE_DEV, 
     6422 
     6423    /**  
     6424     * Constant to denote default playback device. 
     6425     */ 
     6426    PJSUA_SND_DEFAULT_PLAYBACK_DEV = PJMEDIA_AUD_DEFAULT_PLAYBACK_DEV, 
     6427 
     6428    /** 
     6429     * Constant to denote that no sound device is being used. 
     6430     */ 
     6431    PJSUA_SND_NO_DEV = PJMEDIA_AUD_INVALID_DEV, 
     6432 
     6433    /** 
     6434     * Constant to denote null sound device. 
     6435     */ 
     6436    PJSUA_SND_NULL_DEV = -99 
     6437 
     6438} pjsua_snd_dev_id; 
     6439 
    64096440/** 
    64106441 * This enumeration specifies the sound device mode. 
     
    68266857 * (for example when pjsua_start() is not called), it is possible that 
    68276858 * the function returns PJ_SUCCESS with -1 as device IDs. 
     6859 * See also #pjsua_snd_dev_id constants. 
    68286860 * 
    68296861 * @param capture_dev   On return it will be filled with device ID of the  
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_aud.c

    r5676 r5677  
    2424 
    2525#define THIS_FILE               "pjsua_aud.c" 
    26 #define NULL_SND_DEV_ID         -99 
    2726 
    2827/***************************************************************************** 
     
    881880 
    882881        if (need_reopen) { 
    883             if (pjsua_var.cap_dev != NULL_SND_DEV_ID) { 
     882            if (pjsua_var.cap_dev != PJSUA_SND_NULL_DEV) { 
    884883                pjmedia_snd_port_param param; 
    885884 
     
    17281727 
    17291728    /* Check if NULL sound device is used */ 
    1730     if (NULL_SND_DEV_ID==param->base.rec_id || 
    1731         NULL_SND_DEV_ID==param->base.play_id) 
     1729    if (PJSUA_SND_NULL_DEV==param->base.rec_id || 
     1730        PJSUA_SND_NULL_DEV==param->base.play_id) 
    17321731    { 
    17331732        return pjsua_set_null_snd_dev(); 
     
    17361735    /* Close existing sound port */ 
    17371736    close_snd_dev(); 
     1737 
     1738    /* Save the device IDs */ 
     1739    pjsua_var.cap_dev = param->base.rec_id; 
     1740    pjsua_var.play_dev = param->base.play_id; 
    17381741 
    17391742    /* Notify app */ 
     
    18531856    } 
    18541857 
    1855     /* Save the device IDs */ 
    1856     pjsua_var.cap_dev = param->base.rec_id; 
    1857     pjsua_var.play_dev = param->base.play_id; 
    1858  
    18591858    /* Update sound device name. */ 
    18601859    { 
     
    20102009     
    20112010    /* Null-sound */ 
    2012     if (snd_param->capture_dev == NULL_SND_DEV_ID &&  
    2013         snd_param->playback_dev == NULL_SND_DEV_ID)  
     2011    if (snd_param->capture_dev == PJSUA_SND_NULL_DEV &&  
     2012        snd_param->playback_dev == PJSUA_SND_NULL_DEV)  
    20142013    { 
    20152014        PJSUA_UNLOCK(); 
     
    21302129    close_snd_dev(); 
    21312130 
     2131    pjsua_var.cap_dev = PJSUA_SND_NULL_DEV; 
     2132    pjsua_var.play_dev = PJSUA_SND_NULL_DEV; 
     2133 
    21322134    /* Notify app */ 
    21332135    if (pjsua_var.ua_cfg.cb.on_snd_dev_operation) { 
     
    21622164    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 
    21632165 
    2164     pjsua_var.cap_dev = NULL_SND_DEV_ID; 
    2165     pjsua_var.play_dev = NULL_SND_DEV_ID; 
    2166  
    21672166    pjsua_var.no_snd = PJ_FALSE; 
    21682167    pjsua_var.snd_is_on = PJ_TRUE; 
     
    21852184    close_snd_dev(); 
    21862185    pjsua_var.no_snd = PJ_TRUE; 
     2186    pjsua_var.cap_dev = PJSUA_SND_NO_DEV; 
     2187    pjsua_var.play_dev = PJSUA_SND_NO_DEV; 
    21872188 
    21882189    PJSUA_UNLOCK(); 
Note: See TracChangeset for help on using the changeset viewer.