提交 d487b211 authored 作者: Anthony Minessale's avatar Anthony Minessale

add 'pa rescan' to portaudio to look for new devices

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8839 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 a7276cac
差异被折叠。
...@@ -317,10 +317,10 @@ static void deactivate_audio_device(void) ...@@ -317,10 +317,10 @@ static void deactivate_audio_device(void)
static void deactivate_ring_device(void) static void deactivate_ring_device(void)
{ {
switch_mutex_lock(globals.device_lock); switch_mutex_lock(globals.device_lock);
if (globals.ring_stream) { if (globals.ringdev != globals.outdev && globals.ring_stream) {
CloseAudioStream(globals.ring_stream); CloseAudioStream(globals.ring_stream);
globals.ring_stream = NULL;
} }
globals.ring_stream = NULL;
switch_mutex_unlock(globals.device_lock); switch_mutex_unlock(globals.device_lock);
} }
...@@ -712,6 +712,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_portaudio_load) ...@@ -712,6 +712,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_portaudio_load)
return SWITCH_STATUS_TERM; return SWITCH_STATUS_TERM;
} }
memset(&globals, 0, sizeof(globals));
if ((status = load_config()) != SWITCH_STATUS_SUCCESS) { if ((status = load_config()) != SWITCH_STATUS_SUCCESS) {
return status; return status;
} }
...@@ -776,7 +778,6 @@ static switch_status_t load_config(void) ...@@ -776,7 +778,6 @@ static switch_status_t load_config(void)
return SWITCH_STATUS_TERM; return SWITCH_STATUS_TERM;
} }
memset(&globals, 0, sizeof(globals));
globals.indev = globals.outdev = globals.ringdev = -1; globals.indev = globals.outdev = globals.ringdev = -1;
if ((settings = switch_xml_child(cfg, "settings"))) { if ((settings = switch_xml_child(cfg, "settings"))) {
...@@ -1021,6 +1022,14 @@ static int dump_info(int verbose) ...@@ -1021,6 +1022,14 @@ static int dump_info(int verbose)
return 0; return 0;
} }
if (verbose < 0) {
Pa_Terminate();
Pa_Initialize();
load_config();
verbose = 0;
}
numDevices = Pa_GetDeviceCount(); numDevices = Pa_GetDeviceCount();
if (numDevices < 0) { if (numDevices < 0) {
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "ERROR: Pa_CountDevices returned 0x%x\n", numDevices); switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "ERROR: Pa_CountDevices returned 0x%x\n", numDevices);
...@@ -1207,6 +1216,9 @@ static switch_status_t engage_ring_device(int sample_rate, int channels) ...@@ -1207,6 +1216,9 @@ static switch_status_t engage_ring_device(int sample_rate, int channels)
PaError err; PaError err;
if (!globals.ring_stream) { if (!globals.ring_stream) {
if (globals.ringdev == globals.outdev) {
globals.ring_stream = globals.audio_stream;
} else {
if (!sample_rate) { if (!sample_rate) {
sample_rate = globals.sample_rate; sample_rate = globals.sample_rate;
} }
...@@ -1228,6 +1240,7 @@ static switch_status_t engage_ring_device(int sample_rate, int channels) ...@@ -1228,6 +1240,7 @@ static switch_status_t engage_ring_device(int sample_rate, int channels)
return SWITCH_STATUS_FALSE; return SWITCH_STATUS_FALSE;
} }
} }
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Engage ring device! rate: %d channels %d\n", sample_rate, channels); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Engage ring device! rate: %d channels %d\n", sample_rate, channels);
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
...@@ -1572,6 +1585,7 @@ SWITCH_STANDARD_API(pa_cmd) ...@@ -1572,6 +1585,7 @@ SWITCH_STANDARD_API(pa_cmd)
"--------------------------------------------------------------------------------\n" "--------------------------------------------------------------------------------\n"
"pa help\n" "pa help\n"
"pa dump\n" "pa dump\n"
"pa rescan\n"
"pa call <dest> [<dialplan> <cid_name> <cid_num> <rate>]\n" "pa call <dest> [<dialplan> <cid_name> <cid_num> <rate>]\n"
"pa answer [<call_id>]\n" "pa answer [<call_id>]\n"
"pa hangup [<call_id>]\n" "pa hangup [<call_id>]\n"
...@@ -1650,6 +1664,10 @@ SWITCH_STANDARD_API(pa_cmd) ...@@ -1650,6 +1664,10 @@ SWITCH_STANDARD_API(pa_cmd)
goto done; goto done;
} else if (!strcasecmp(argv[0], "devlist")) { } else if (!strcasecmp(argv[0], "devlist")) {
func = devlist; func = devlist;
} else if (!strcasecmp(argv[0], "rescan")) {
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "Looking for new devices.\n");
dump_info(-1);
goto done;
} else if (!strcasecmp(argv[0], "dump")) { } else if (!strcasecmp(argv[0], "dump")) {
dump_info(1); dump_info(1);
goto done; goto done;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论