Changeset 5273 for pjproject/trunk/pjsip/src/pjsua-lib/pjsua_aud.c
- Timestamp:
- Apr 4, 2016 1:44:10 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_aud.c
r5205 r5273 688 688 } 689 689 690 PJ_DEF(void) pjsua_snd_dev_param_default(pjsua_snd_dev_param *prm) 691 { 692 pj_bzero(prm, sizeof(*prm)); 693 prm->capture_dev = PJMEDIA_AUD_DEFAULT_CAPTURE_DEV; 694 prm->playback_dev = PJMEDIA_AUD_DEFAULT_PLAYBACK_DEV; 695 } 690 696 691 697 /* … … 1697 1703 pjmedia_port *conf_port; 1698 1704 pj_status_t status; 1705 pj_bool_t speaker_only = (pjsua_var.snd_mode & PJSUA_SND_DEV_SPEAKER_ONLY); 1699 1706 1700 1707 PJ_ASSERT_RETURN(param, PJ_EINVAL); … … 1725 1732 param->on_rec_frame = &on_aud_prev_rec_frame; 1726 1733 1727 PJ_LOG(4,(THIS_FILE, "Opening sound device %s@%d/%d/%dms", 1734 PJ_LOG(4,(THIS_FILE, "Opening sound device (%s) %s@%d/%d/%dms", 1735 speaker_only?"speaker only":"speaker + mic", 1728 1736 get_fmt_name(param->base.ext_fmt.id), 1729 1737 param->base.clock_rate, param->base.channel_count, … … 1732 1740 pj_log_push_indent(); 1733 1741 1734 status = pjmedia_snd_port_create2( pjsua_var.snd_pool, 1735 param, &pjsua_var.snd_port); 1742 if (speaker_only) { 1743 status = pjmedia_snd_port_create_player(pjsua_var.snd_pool, 1744 -1, 1745 param->base.clock_rate, 1746 param->base.channel_count, 1747 param->base.samples_per_frame, 1748 param->base.bits_per_sample, 1749 0, 1750 &pjsua_var.snd_port); 1751 1752 } else { 1753 status = pjmedia_snd_port_create2(pjsua_var.snd_pool, 1754 param, &pjsua_var.snd_port); 1755 } 1756 1736 1757 if (status != PJ_SUCCESS) 1737 1758 goto on_error; … … 1921 1942 1922 1943 1944 PJ_DEF(pj_status_t) pjsua_set_snd_dev(int capture_dev, 1945 int playback_dev) 1946 { 1947 pjsua_snd_dev_param param; 1948 1949 pjsua_snd_dev_param_default(¶m); 1950 1951 param.capture_dev = capture_dev; 1952 param.playback_dev = playback_dev; 1953 /* Always open the sound device. */ 1954 param.mode = 0; 1955 1956 return pjsua_set_snd_dev2(¶m); 1957 } 1958 1923 1959 /* 1924 1960 * Select or change sound device. Application may call this function at 1925 1961 * any time to replace current sound device. 1926 1962 */ 1927 PJ_DEF(pj_status_t) pjsua_set_snd_dev( int capture_dev, 1928 int playback_dev) 1963 PJ_DEF(pj_status_t) pjsua_set_snd_dev2(pjsua_snd_dev_param *snd_param) 1929 1964 { 1930 1965 unsigned alt_cr_cnt = 1; … … 1932 1967 unsigned i; 1933 1968 pj_status_t status = -1; 1969 unsigned orig_snd_dev_mode = pjsua_var.snd_mode; 1970 pj_bool_t no_change = (pjsua_var.snd_is_on || (!pjsua_var.snd_is_on && 1971 (snd_param->mode & 1972 PJSUA_SND_DEV_NO_IMMEDIATE_OPEN))); 1934 1973 1935 1974 PJ_LOG(4,(THIS_FILE, "Set sound device: capture=%d, playback=%d", 1936 capture_dev,playback_dev));1975 snd_param->capture_dev, snd_param->playback_dev)); 1937 1976 pj_log_push_indent(); 1938 1977 1939 1978 PJSUA_LOCK(); 1940 1979 1941 if (pjsua_var.cap_dev == capture_dev && 1942 pjsua_var.play_dev == playback_dev && 1943 pjsua_var.snd_is_on && !pjsua_var.no_snd) 1980 if (pjsua_var.cap_dev == snd_param->capture_dev && 1981 pjsua_var.play_dev == snd_param->playback_dev && 1982 pjsua_var.snd_mode == snd_param->mode && 1983 !pjsua_var.no_snd && no_change) 1944 1984 { 1945 1985 PJ_LOG(4, (THIS_FILE, "No changes in capture and playback devices")); … … 1950 1990 1951 1991 /* Null-sound */ 1952 if (capture_dev==NULL_SND_DEV_ID && playback_dev==NULL_SND_DEV_ID) { 1992 if (snd_param->capture_dev == NULL_SND_DEV_ID && 1993 snd_param->playback_dev == NULL_SND_DEV_ID) 1994 { 1953 1995 PJSUA_UNLOCK(); 1954 1996 status = pjsua_set_null_snd_dev(); 1955 1997 pj_log_pop_indent(); 1956 1998 return status; 1999 } 2000 2001 pjsua_var.snd_mode = snd_param->mode; 2002 2003 if (!pjsua_var.no_snd && 2004 (snd_param->mode & PJSUA_SND_DEV_NO_IMMEDIATE_OPEN)) 2005 { 2006 pjsua_var.cap_dev = snd_param->capture_dev; 2007 pjsua_var.play_dev = snd_param->playback_dev; 2008 2009 PJSUA_UNLOCK(); 2010 pj_log_pop_indent(); 2011 return PJ_SUCCESS; 1957 2012 } 1958 2013 … … 1983 2038 pjmedia_snd_port_param_default(¶m); 1984 2039 param.ec_options = pjsua_var.media_cfg.ec_options; 1985 status = create_aud_param(¶m.base, capture_dev, playback_dev, 2040 status = create_aud_param(¶m.base, snd_param->capture_dev, 2041 snd_param->playback_dev, 1986 2042 alt_cr[i], pjsua_var.media_cfg.channel_count, 1987 2043 samples_per_frame, 16); … … 2009 2065 2010 2066 on_error: 2067 pjsua_var.snd_mode = orig_snd_dev_mode; 2011 2068 PJSUA_UNLOCK(); 2012 2069 pj_log_pop_indent();
Note: See TracChangeset
for help on using the changeset viewer.