[Freeswitch-svn] [commit] r10693 - in freeswitch/trunk/src: . include mod/applications/mod_dptools mod/applications/mod_fax mod/applications/mod_fifo mod/applications/mod_voicemail mod/languages/mod_spidermonkey
FreeSWITCH SVN
anthm at freeswitch.org
Tue Dec 9 16:48:24 PST 2008
Author: anthm
Date: Tue Dec 9 19:48:24 2008
New Revision: 10693
Log:
add sync param to sleep so you can choose to sync audio or not on sleep (reswig to follow)
Modified:
freeswitch/trunk/src/include/switch_cpp.h
freeswitch/trunk/src/include/switch_ivr.h
freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
freeswitch/trunk/src/mod/applications/mod_fax/mod_fax.c
freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c
freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c
freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
freeswitch/trunk/src/switch_cpp.cpp
freeswitch/trunk/src/switch_ivr.c
freeswitch/trunk/src/switch_ivr_menu.c
freeswitch/trunk/src/switch_ivr_originate.c
freeswitch/trunk/src/switch_ivr_play_say.c
Modified: freeswitch/trunk/src/include/switch_cpp.h
==============================================================================
--- freeswitch/trunk/src/include/switch_cpp.h (original)
+++ freeswitch/trunk/src/include/switch_cpp.h Tue Dec 9 19:48:24 2008
@@ -313,7 +313,7 @@
*
*/
SWITCH_DECLARE(int) streamFile(char *file, int starting_sample_count = 0);
- SWITCH_DECLARE(int) sleep(int ms);
+ SWITCH_DECLARE(int) sleep(int ms, int sync=0);
/** \brief flush any pending events
*/
Modified: freeswitch/trunk/src/include/switch_ivr.h
==============================================================================
--- freeswitch/trunk/src/include/switch_ivr.h (original)
+++ freeswitch/trunk/src/include/switch_ivr.h Tue Dec 9 19:48:24 2008
@@ -110,7 +110,7 @@
\param args arguements to pass for callbacks etc
\return SWITCH_STATUS_SUCCESS if the channel is still up
*/
-SWITCH_DECLARE(switch_status_t) switch_ivr_sleep(switch_core_session_t *session, uint32_t ms, switch_input_args_t *args);
+SWITCH_DECLARE(switch_status_t) switch_ivr_sleep(switch_core_session_t *session, uint32_t ms, switch_bool_t sync, switch_input_args_t *args);
SWITCH_DECLARE(switch_status_t) switch_ivr_park(switch_core_session_t *session, switch_input_args_t *args);
Modified: freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c Tue Dec 9 19:48:24 2008
@@ -1307,7 +1307,7 @@
switch_channel_set_variable(channel, SWITCH_PLAYBACK_TERMINATOR_USED, "" );
- switch_ivr_sleep(session, ms, &args);
+ switch_ivr_sleep(session, ms, SWITCH_TRUE, &args);
}
}
Modified: freeswitch/trunk/src/mod/applications/mod_fax/mod_fax.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_fax/mod_fax.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_fax/mod_fax.c Tue Dec 9 19:48:24 2008
@@ -608,7 +608,7 @@
goto done;
}
- switch_ivr_sleep(session, 250, NULL);
+ switch_ivr_sleep(session, 250, SWITCH_TRUE, NULL);
while (switch_channel_ready(channel)) {
int tx = 0;
Modified: freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c Tue Dec 9 19:48:24 2008
@@ -1167,7 +1167,7 @@
if (announce) {
switch_ivr_play_file(session, NULL, announce, NULL);
} else {
- switch_ivr_sleep(session, 500, NULL);
+ switch_ivr_sleep(session, 500, SWITCH_TRUE, NULL);
}
switch_channel_set_variable(other_channel, "fifo_serviced_by", my_id);
Modified: freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c Tue Dec 9 19:48:24 2008
@@ -1403,7 +1403,7 @@
forward_file_path = switch_core_session_sprintf(session, "%s%smsg_%s.wav", SWITCH_GLOBAL_dirs.temp_dir, SWITCH_PATH_SEPARATOR, uuid_str);
TRY_CODE(create_file(session, profile, VM_RECORD_MESSAGE_MACRO, forward_file_path, &message_len, SWITCH_TRUE, NULL, NULL));
if ((new_path = vm_merge_file(session, profile, forward_file_path, cbt->file_path))) {
- switch_ivr_sleep(session, 1500, NULL);
+ switch_ivr_sleep(session, 1500, SWITCH_TRUE, NULL);
forward_file_path = new_path;
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error merging files\n");
@@ -1637,7 +1637,7 @@
*global_buf = '\0';
while (switch_channel_ready(channel)) {
- switch_ivr_sleep(session, 100, NULL);
+ switch_ivr_sleep(session, 100, SWITCH_TRUE, NULL);
switch (vm_check_state) {
case VM_CHECK_START:
Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c (original)
+++ freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c Tue Dec 9 19:48:24 2008
@@ -1723,7 +1723,8 @@
switch_input_args_t args = { 0 };
int32 ms = 0;
jsval ret = JS_TRUE;
-
+ int sync;
+
METHOD_SANITY_CHECK();
channel = switch_core_session_get_channel(jss->session);
CHANNEL_SANITY_CHECK();
@@ -1755,12 +1756,16 @@
}
}
+ if (argc > 2) {
+ JS_ValueToInt32(cx, argv[2], &sync);
+ }
+
cb_state.ret = BOOLEAN_TO_JSVAL(JS_FALSE);
cb_state.saveDepth = JS_SuspendRequest(cx);
args.input_callback = dtmf_func;
args.buf = bp;
args.buflen = len;
- switch_ivr_sleep(jss->session, ms, &args);
+ switch_ivr_sleep(jss->session, ms, sync, &args);
JS_ResumeRequest(cx, cb_state.saveDepth);
check_hangup_hook(jss, &ret);
*rval = cb_state.ret;
Modified: freeswitch/trunk/src/switch_cpp.cpp
==============================================================================
--- freeswitch/trunk/src/switch_cpp.cpp (original)
+++ freeswitch/trunk/src/switch_cpp.cpp Tue Dec 9 19:48:24 2008
@@ -833,7 +833,7 @@
}
-SWITCH_DECLARE(int) CoreSession::sleep(int ms) {
+SWITCH_DECLARE(int) CoreSession::sleep(int ms, int sync) {
switch_status_t status;
@@ -841,7 +841,7 @@
sanity_check(-1);
begin_allow_threads();
- status = switch_ivr_sleep(session, ms, ap);
+ status = switch_ivr_sleep(session, ms, (switch_bool_t) sync, ap);
end_allow_threads();
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
Modified: freeswitch/trunk/src/switch_ivr.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr.c (original)
+++ freeswitch/trunk/src/switch_ivr.c Tue Dec 9 19:48:24 2008
@@ -38,7 +38,7 @@
#include <switch_ivr.h>
#include "stfu.h"
-SWITCH_DECLARE(switch_status_t) switch_ivr_sleep(switch_core_session_t *session, uint32_t ms, switch_input_args_t *args)
+SWITCH_DECLARE(switch_status_t) switch_ivr_sleep(switch_core_session_t *session, uint32_t ms, switch_bool_t sync, switch_input_args_t *args)
{
switch_channel_t *channel = switch_core_session_get_channel(session);
switch_status_t status = SWITCH_STATUS_SUCCESS;
@@ -80,6 +80,13 @@
write_frame.buflen = SWITCH_RECOMMENDED_BUFFER_SIZE;
write_frame.datalen = imp.decoded_bytes_per_packet;
write_frame.samples = write_frame.datalen / sizeof(int16_t);
+
+ if (!switch_channel_media_ready(channel)) {
+ if ((status = switch_channel_pre_answer(channel)) != SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot establish media.\n");
+ return SWITCH_STATUS_FALSE;
+ }
+ }
}
cng_frame.data = data;
@@ -87,7 +94,7 @@
cng_frame.buflen = 2;
switch_set_flag((&cng_frame), SFF_CNG);
- if (!switch_channel_test_flag(channel, CF_PROXY_MODE)) {
+ if (sync && !switch_channel_test_flag(channel, CF_PROXY_MODE)) {
switch_channel_audio_sync(channel);
}
Modified: freeswitch/trunk/src/switch_ivr_menu.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_menu.c (original)
+++ freeswitch/trunk/src/switch_ivr_menu.c Tue Dec 9 19:48:24 2008
@@ -529,7 +529,7 @@
}
errs++;
if (status == SWITCH_STATUS_SUCCESS) {
- status = switch_ivr_sleep(session, 1000, NULL);
+ status = switch_ivr_sleep(session, 1000, SWITCH_FALSE, NULL);
}
/* breaks are ok too */
if (SWITCH_STATUS_IS_BREAK(status)) {
Modified: freeswitch/trunk/src/switch_ivr_originate.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_originate.c (original)
+++ freeswitch/trunk/src/switch_ivr_originate.c Tue Dec 9 19:48:24 2008
@@ -91,7 +91,7 @@
return NULL;
}
- switch_ivr_sleep(collect->session, 0, NULL);
+ switch_ivr_sleep(collect->session, 0, SWITCH_TRUE, NULL);
if (!strcasecmp(collect->key, "exec")) {
char *data;
@@ -951,7 +951,7 @@
if (try > 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Originate attempt %d/%d in %d ms\n", try + 1, retries, sleep_ms);
if (caller_channel) {
- switch_ivr_sleep(session, sleep_ms, NULL);
+ switch_ivr_sleep(session, sleep_ms, SWITCH_TRUE, NULL);
} else {
switch_yield(sleep_ms * 1000);
}
@@ -1749,11 +1749,11 @@
}
if (*bleg) {
- switch_ivr_sleep(*bleg, 0, NULL);
+ switch_ivr_sleep(*bleg, 0, SWITCH_TRUE, NULL);
}
if (session) {
- switch_ivr_sleep(session, 0, NULL);
+ switch_ivr_sleep(session, 0, SWITCH_TRUE, NULL);
}
if (var_event && var_event != ovars) {
Modified: freeswitch/trunk/src/switch_ivr_play_say.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_play_say.c (original)
+++ freeswitch/trunk/src/switch_ivr_play_say.c Tue Dec 9 19:48:24 2008
@@ -327,7 +327,7 @@
}
}
- switch_ivr_sleep(session, pause, NULL);
+ switch_ivr_sleep(session, pause, SWITCH_FALSE, NULL);
}
}
More information about the Freeswitch-svn
mailing list