mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-07-09 13:51:53 +00:00
streamFiles 2nd argument is now optional. fix segfault that was happening with originate/bridge due to no valid session in b leg. rename streamfile to streamFile. remove playFile since streamFile does the same thing
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5454 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
@@ -115,14 +115,13 @@ class CoreSession(_object):
|
||||
def recordFile(*args): return _freeswitch.CoreSession_recordFile(*args)
|
||||
def setCallerData(*args): return _freeswitch.CoreSession_setCallerData(*args)
|
||||
def originate(*args): return _freeswitch.CoreSession_originate(*args)
|
||||
def playFile(*args): return _freeswitch.CoreSession_playFile(*args)
|
||||
def setDTMFCallback(*args): return _freeswitch.CoreSession_setDTMFCallback(*args)
|
||||
def speak(*args): return _freeswitch.CoreSession_speak(*args)
|
||||
def set_tts_parms(*args): return _freeswitch.CoreSession_set_tts_parms(*args)
|
||||
def getDigits(*args): return _freeswitch.CoreSession_getDigits(*args)
|
||||
def transfer(*args): return _freeswitch.CoreSession_transfer(*args)
|
||||
def playAndGetDigits(*args): return _freeswitch.CoreSession_playAndGetDigits(*args)
|
||||
def streamfile(*args): return _freeswitch.CoreSession_streamfile(*args)
|
||||
def streamFile(*args): return _freeswitch.CoreSession_streamFile(*args)
|
||||
def flushEvents(*args): return _freeswitch.CoreSession_flushEvents(*args)
|
||||
def flushDigits(*args): return _freeswitch.CoreSession_flushDigits(*args)
|
||||
def setAutoHangup(*args): return _freeswitch.CoreSession_setAutoHangup(*args)
|
||||
|
||||
@@ -175,6 +175,11 @@ switch_status_t PySession::run_dtmf_callback(void *input,
|
||||
bool PySession::begin_allow_threads(void) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "PySession::begin_allow_threads() called\n");
|
||||
|
||||
if (!session) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "No valid session\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
// swap out threadstate and store in instance variable
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
PyThreadState *swapin_tstate = (PyThreadState *) switch_channel_get_private(channel, "SwapInThreadState");
|
||||
@@ -196,7 +201,6 @@ bool PySession::begin_allow_threads(void) {
|
||||
}
|
||||
else {
|
||||
// currently swapped out
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Threadstate already swapd-out! Skipping\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -205,11 +209,15 @@ bool PySession::begin_allow_threads(void) {
|
||||
bool PySession::end_allow_threads(void) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "PySession::end_allow_threads() called\n");
|
||||
// swap in threadstate from instance variable saved earlier
|
||||
if (!session) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "No valid session\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
PyThreadState *swapin_tstate = (PyThreadState *) switch_channel_get_private(channel, "SwapInThreadState");
|
||||
if (swapin_tstate == NULL) {
|
||||
// currently swapped in
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Threadstate double swap-in! Skipping\n");
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -177,18 +177,19 @@ static void eval_some_python(char *uuid, char *args, switch_core_session_t *sess
|
||||
// will be null
|
||||
if (swapin_tstate == NULL) {
|
||||
// swap it out
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Threadstate mod_python.c swap-out! \n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Threadstate mod_python.c swap-out! \n");
|
||||
// PyEval_ReleaseThread(cur_tstate);
|
||||
swapin_tstate = (void *) PyEval_SaveThread();
|
||||
switch_channel_set_private(channel, "SwapInThreadState", (void *) swapin_tstate);
|
||||
}
|
||||
else {
|
||||
// thread state is already swapped out, so, nothing for us to do
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "according to chan priv data, already swapped out \n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "according to chan priv data, already swapped out \n");
|
||||
}
|
||||
}
|
||||
else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Threadstate mod_python.c swap-out! \n");
|
||||
// they ran python script from cmd line, behave a bit differently (untested)
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Threadstate mod_python.c swap-out! \n");
|
||||
PyEval_ReleaseThread(tstate);
|
||||
}
|
||||
|
||||
|
||||
@@ -3961,52 +3961,6 @@ fail:
|
||||
}
|
||||
|
||||
|
||||
SWIGINTERN PyObject *_wrap_CoreSession_playFile(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
|
||||
PyObject *resultobj = 0;
|
||||
CoreSession *arg1 = (CoreSession *) 0 ;
|
||||
char *arg2 = (char *) 0 ;
|
||||
char *arg3 = (char *) 0 ;
|
||||
int result;
|
||||
void *argp1 = 0 ;
|
||||
int res1 = 0 ;
|
||||
int res2 ;
|
||||
char *buf2 = 0 ;
|
||||
int alloc2 = 0 ;
|
||||
int res3 ;
|
||||
char *buf3 = 0 ;
|
||||
int alloc3 = 0 ;
|
||||
PyObject * obj0 = 0 ;
|
||||
PyObject * obj1 = 0 ;
|
||||
PyObject * obj2 = 0 ;
|
||||
|
||||
if (!PyArg_ParseTuple(args,(char *)"OOO:CoreSession_playFile",&obj0,&obj1,&obj2)) SWIG_fail;
|
||||
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CoreSession, 0 | 0 );
|
||||
if (!SWIG_IsOK(res1)) {
|
||||
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CoreSession_playFile" "', argument " "1"" of type '" "CoreSession *""'");
|
||||
}
|
||||
arg1 = reinterpret_cast< CoreSession * >(argp1);
|
||||
res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2);
|
||||
if (!SWIG_IsOK(res2)) {
|
||||
SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CoreSession_playFile" "', argument " "2"" of type '" "char *""'");
|
||||
}
|
||||
arg2 = reinterpret_cast< char * >(buf2);
|
||||
res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3);
|
||||
if (!SWIG_IsOK(res3)) {
|
||||
SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "CoreSession_playFile" "', argument " "3"" of type '" "char *""'");
|
||||
}
|
||||
arg3 = reinterpret_cast< char * >(buf3);
|
||||
result = (int)(arg1)->playFile(arg2,arg3);
|
||||
resultobj = SWIG_From_int(static_cast< int >(result));
|
||||
if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
|
||||
if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
|
||||
return resultobj;
|
||||
fail:
|
||||
if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
|
||||
if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
SWIGINTERN PyObject *_wrap_CoreSession_setDTMFCallback(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
|
||||
PyObject *resultobj = 0;
|
||||
CoreSession *arg1 = (CoreSession *) 0 ;
|
||||
@@ -4405,11 +4359,11 @@ fail:
|
||||
}
|
||||
|
||||
|
||||
SWIGINTERN PyObject *_wrap_CoreSession_streamfile(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
|
||||
SWIGINTERN PyObject *_wrap_CoreSession_streamFile(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
|
||||
PyObject *resultobj = 0;
|
||||
CoreSession *arg1 = (CoreSession *) 0 ;
|
||||
char *arg2 = (char *) 0 ;
|
||||
int arg3 ;
|
||||
int arg3 = (int) 0 ;
|
||||
int result;
|
||||
void *argp1 = 0 ;
|
||||
int res1 = 0 ;
|
||||
@@ -4422,23 +4376,25 @@ SWIGINTERN PyObject *_wrap_CoreSession_streamfile(PyObject *SWIGUNUSEDPARM(self)
|
||||
PyObject * obj1 = 0 ;
|
||||
PyObject * obj2 = 0 ;
|
||||
|
||||
if (!PyArg_ParseTuple(args,(char *)"OOO:CoreSession_streamfile",&obj0,&obj1,&obj2)) SWIG_fail;
|
||||
if (!PyArg_ParseTuple(args,(char *)"OO|O:CoreSession_streamFile",&obj0,&obj1,&obj2)) SWIG_fail;
|
||||
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CoreSession, 0 | 0 );
|
||||
if (!SWIG_IsOK(res1)) {
|
||||
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CoreSession_streamfile" "', argument " "1"" of type '" "CoreSession *""'");
|
||||
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CoreSession_streamFile" "', argument " "1"" of type '" "CoreSession *""'");
|
||||
}
|
||||
arg1 = reinterpret_cast< CoreSession * >(argp1);
|
||||
res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2);
|
||||
if (!SWIG_IsOK(res2)) {
|
||||
SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CoreSession_streamfile" "', argument " "2"" of type '" "char *""'");
|
||||
SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CoreSession_streamFile" "', argument " "2"" of type '" "char *""'");
|
||||
}
|
||||
arg2 = reinterpret_cast< char * >(buf2);
|
||||
ecode3 = SWIG_AsVal_int(obj2, &val3);
|
||||
if (!SWIG_IsOK(ecode3)) {
|
||||
SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "CoreSession_streamfile" "', argument " "3"" of type '" "int""'");
|
||||
}
|
||||
arg3 = static_cast< int >(val3);
|
||||
result = (int)(arg1)->streamfile(arg2,arg3);
|
||||
if (obj2) {
|
||||
ecode3 = SWIG_AsVal_int(obj2, &val3);
|
||||
if (!SWIG_IsOK(ecode3)) {
|
||||
SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "CoreSession_streamFile" "', argument " "3"" of type '" "int""'");
|
||||
}
|
||||
arg3 = static_cast< int >(val3);
|
||||
}
|
||||
result = (int)(arg1)->streamFile(arg2,arg3);
|
||||
resultobj = SWIG_From_int(static_cast< int >(result));
|
||||
if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
|
||||
return resultobj;
|
||||
@@ -5269,14 +5225,13 @@ static PyMethodDef SwigMethods[] = {
|
||||
{ (char *)"CoreSession_recordFile", _wrap_CoreSession_recordFile, METH_VARARGS, NULL},
|
||||
{ (char *)"CoreSession_setCallerData", _wrap_CoreSession_setCallerData, METH_VARARGS, NULL},
|
||||
{ (char *)"CoreSession_originate", _wrap_CoreSession_originate, METH_VARARGS, NULL},
|
||||
{ (char *)"CoreSession_playFile", _wrap_CoreSession_playFile, METH_VARARGS, NULL},
|
||||
{ (char *)"CoreSession_setDTMFCallback", _wrap_CoreSession_setDTMFCallback, METH_VARARGS, NULL},
|
||||
{ (char *)"CoreSession_speak", _wrap_CoreSession_speak, METH_VARARGS, NULL},
|
||||
{ (char *)"CoreSession_set_tts_parms", _wrap_CoreSession_set_tts_parms, METH_VARARGS, NULL},
|
||||
{ (char *)"CoreSession_getDigits", _wrap_CoreSession_getDigits, METH_VARARGS, NULL},
|
||||
{ (char *)"CoreSession_transfer", _wrap_CoreSession_transfer, METH_VARARGS, NULL},
|
||||
{ (char *)"CoreSession_playAndGetDigits", _wrap_CoreSession_playAndGetDigits, METH_VARARGS, NULL},
|
||||
{ (char *)"CoreSession_streamfile", _wrap_CoreSession_streamfile, METH_VARARGS, NULL},
|
||||
{ (char *)"CoreSession_streamFile", _wrap_CoreSession_streamFile, METH_VARARGS, NULL},
|
||||
{ (char *)"CoreSession_flushEvents", _wrap_CoreSession_flushEvents, METH_VARARGS, NULL},
|
||||
{ (char *)"CoreSession_flushDigits", _wrap_CoreSession_flushDigits, METH_VARARGS, NULL},
|
||||
{ (char *)"CoreSession_setAutoHangup", _wrap_CoreSession_setAutoHangup, METH_VARARGS, NULL},
|
||||
|
||||
Reference in New Issue
Block a user