提交 6f78befa authored 作者: Traun Leyden's avatar Traun Leyden

implement flushEvents() flushDigits() setAutoHangup() and setHangupHook(). …

implement flushEvents() flushDigits() setAutoHangup() and setHangupHook().  reworked dtmfhandler and some aspects relating to threadstate.  folded in memory pool thing from mishehu.  added more asserts to switch_core_file (coordinated w/ anthony on this)

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5442 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 34d6c498
...@@ -11,6 +11,50 @@ extern "C" { ...@@ -11,6 +11,50 @@ extern "C" {
#include <switch.h> #include <switch.h>
//
// C++ Interface: switch_to_cpp_mempool
//
// Description: This class allows for overloading the new operator to allocate from a switch_memory_pool_t
//
// Author: Yossi Neiman <freeswitch@cartissolutions.com>, (C) 2007
//
// Copyright: See COPYING file that comes with this distribution
//
#ifndef SWITCHTOMEMPOOL
#define SWITCHTOMEMPOOL
class SwitchToMempool {
public:
SwitchToMempool() { }
SwitchToMempool(switch_memory_pool_t *mem) { memorypool = mem; }
void *operator new(switch_size_t num_bytes, switch_memory_pool_t *mem)
{
void *ptr = switch_core_alloc(mem, (switch_size_t) num_bytes);
return ptr;
}
protected:
switch_memory_pool_t *memorypool;
};
#endif
/*
Overview: once you create an object that inherits this class, since
the memory pool is then a class data member, you can continue to
allocate objects from the memory pool.
objects from within the class
Notes on usage:
1. The derived class will need to also overload the ctor so that it accepts a memory pool object as a parameter.
2. Instantiation of a class would then look something like this: Foo *bar = new(memory_pool) Foo(memory_pool);
Note that the first parameter to the new operator is implicitly handled by c++... not sure I like that but it's how it is...
*/
void console_log(char *level_str, char *msg); void console_log(char *level_str, char *msg);
void console_clean_log(char *msg); void console_clean_log(char *msg);
...@@ -40,6 +84,12 @@ typedef struct input_callback_state { ...@@ -40,6 +84,12 @@ typedef struct input_callback_state {
char *funcargs; // extra string that will be passed to callback function char *funcargs; // extra string that will be passed to callback function
} input_callback_state_t; } input_callback_state_t;
typedef enum {
S_HUP = (1 << 0),
S_FREE = (1 << 1),
S_RDLOCK = (1 << 2)
} session_flag_t;
class CoreSession { class CoreSession {
protected: protected:
...@@ -52,6 +102,9 @@ class CoreSession { ...@@ -52,6 +102,9 @@ class CoreSession {
char *tts_name; char *tts_name;
char *voice_name; char *voice_name;
void store_file_handle(switch_file_handle_t *fh); void store_file_handle(switch_file_handle_t *fh);
void *on_hangup; // language specific callback function, cast as void *
public: public:
CoreSession(); CoreSession();
CoreSession(char *uuid); CoreSession(char *uuid);
...@@ -59,12 +112,14 @@ class CoreSession { ...@@ -59,12 +112,14 @@ class CoreSession {
virtual ~CoreSession(); virtual ~CoreSession();
switch_core_session_t *session; switch_core_session_t *session;
switch_channel_t *channel; switch_channel_t *channel;
unsigned int flags;
input_callback_state cb_state; // callback state, always pointed to by the buf input_callback_state cb_state; // callback state, always pointed to by the buf
// field in this->args // field in this->args
switch_channel_state_t hook_state; // store hookstate for on_hangup callback
int answer(); int answer();
int preAnswer(); int preAnswer();
void hangup(char *cause); virtual void hangup(char *cause);
void setVariable(char *var, char *val); void setVariable(char *var, char *val);
char *getVariable(char *var); char *getVariable(char *var);
...@@ -118,19 +173,16 @@ class CoreSession { ...@@ -118,19 +173,16 @@ class CoreSession {
* is pressed by user during playFile(), streamfile(), and * is pressed by user during playFile(), streamfile(), and
* certain other methods are executing. * certain other methods are executing.
* *
* Note that language specific sessions might need to create
* their own version of this with a slightly different signature
* (as done in freeswitch_python.h)
*/ */
void setDTMFCallback(switch_input_callback_function_t cb, void setDTMFCallback(void *cbfunc, char *funcargs);
void *buf,
uint32_t buflen);
int speak(char *text); int speak(char *text);
void set_tts_parms(char *tts_name, char *voice_name); void set_tts_parms(char *tts_name, char *voice_name);
int getDigits(char *dtmf_buf, int getDigits(char *dtmf_buf,
int len, int buflen,
int maxdigits,
char *terminators, char *terminators,
char *terminator, char *terminator,
int timeout); int timeout);
...@@ -165,11 +217,26 @@ class CoreSession { ...@@ -165,11 +217,26 @@ class CoreSession {
*/ */
int streamfile(char *file, int starting_sample_count); int streamfile(char *file, int starting_sample_count);
/** \brief flush any pending events
*/
int flushEvents();
/** \brief flush any pending digits
*/
int flushDigits();
int setAutoHangup(bool val);
/** \brief Set the hangup callback function
* \param hangup_func - language specific function ptr cast into void *
*/
void setHangupHook(void *hangup_func);
bool ready(); bool ready();
void execute(char *app, char *data); void execute(char *app, char *data);
virtual void begin_allow_threads(); virtual bool begin_allow_threads() = 0;
virtual void end_allow_threads(); virtual bool end_allow_threads() = 0;
/** \brief Get the uuid of this session /** \brief Get the uuid of this session
* \return the uuid of this session * \return the uuid of this session
...@@ -181,6 +248,12 @@ class CoreSession { ...@@ -181,6 +248,12 @@ class CoreSession {
*/ */
const switch_input_args_t& get_cb_args() const { return args; }; const switch_input_args_t& get_cb_args() const { return args; };
/** \brief Callback to the language specific hangup callback
*/
virtual void check_hangup_hook() = 0;
virtual switch_status_t run_dtmf_callback(void *input,
switch_input_type_t itype) = 0;
}; };
...@@ -200,6 +273,19 @@ void api_reply_delete(char *reply); ...@@ -200,6 +273,19 @@ void api_reply_delete(char *reply);
void bridge(CoreSession &session_a, CoreSession &session_b); void bridge(CoreSession &session_a, CoreSession &session_b);
/** \brief the actual hangup hook called back by freeswitch core
* which in turn gets the session and calls the appropriate
* instance method to complete the callback.
*/
switch_status_t hanguphook(switch_core_session_t *session);
switch_status_t dtmf_callback(switch_core_session_t *session,
void *input,
switch_input_type_t itype,
void *buf,
unsigned int buflen);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -80,16 +80,16 @@ class input_callback_state_t(_object): ...@@ -80,16 +80,16 @@ class input_callback_state_t(_object):
input_callback_state_t_swigregister = _freeswitch.input_callback_state_t_swigregister input_callback_state_t_swigregister = _freeswitch.input_callback_state_t_swigregister
input_callback_state_t_swigregister(input_callback_state_t) input_callback_state_t_swigregister(input_callback_state_t)
S_HUP = _freeswitch.S_HUP
S_FREE = _freeswitch.S_FREE
S_RDLOCK = _freeswitch.S_RDLOCK
class CoreSession(_object): class CoreSession(_object):
__swig_setmethods__ = {} __swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, CoreSession, name, value) __setattr__ = lambda self, name, value: _swig_setattr(self, CoreSession, name, value)
__swig_getmethods__ = {} __swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, CoreSession, name) __getattr__ = lambda self, name: _swig_getattr(self, CoreSession, name)
def __init__(self): raise AttributeError, "No constructor defined"
__repr__ = _swig_repr __repr__ = _swig_repr
def __init__(self, *args):
this = _freeswitch.new_CoreSession(*args)
try: self.this.append(this)
except: self.this = this
__swig_destroy__ = _freeswitch.delete_CoreSession __swig_destroy__ = _freeswitch.delete_CoreSession
__del__ = lambda self : None; __del__ = lambda self : None;
__swig_setmethods__["session"] = _freeswitch.CoreSession_session_set __swig_setmethods__["session"] = _freeswitch.CoreSession_session_set
...@@ -98,9 +98,15 @@ class CoreSession(_object): ...@@ -98,9 +98,15 @@ class CoreSession(_object):
__swig_setmethods__["channel"] = _freeswitch.CoreSession_channel_set __swig_setmethods__["channel"] = _freeswitch.CoreSession_channel_set
__swig_getmethods__["channel"] = _freeswitch.CoreSession_channel_get __swig_getmethods__["channel"] = _freeswitch.CoreSession_channel_get
if _newclass:channel = _swig_property(_freeswitch.CoreSession_channel_get, _freeswitch.CoreSession_channel_set) if _newclass:channel = _swig_property(_freeswitch.CoreSession_channel_get, _freeswitch.CoreSession_channel_set)
__swig_setmethods__["flags"] = _freeswitch.CoreSession_flags_set
__swig_getmethods__["flags"] = _freeswitch.CoreSession_flags_get
if _newclass:flags = _swig_property(_freeswitch.CoreSession_flags_get, _freeswitch.CoreSession_flags_set)
__swig_setmethods__["cb_state"] = _freeswitch.CoreSession_cb_state_set __swig_setmethods__["cb_state"] = _freeswitch.CoreSession_cb_state_set
__swig_getmethods__["cb_state"] = _freeswitch.CoreSession_cb_state_get __swig_getmethods__["cb_state"] = _freeswitch.CoreSession_cb_state_get
if _newclass:cb_state = _swig_property(_freeswitch.CoreSession_cb_state_get, _freeswitch.CoreSession_cb_state_set) if _newclass:cb_state = _swig_property(_freeswitch.CoreSession_cb_state_get, _freeswitch.CoreSession_cb_state_set)
__swig_setmethods__["hook_state"] = _freeswitch.CoreSession_hook_state_set
__swig_getmethods__["hook_state"] = _freeswitch.CoreSession_hook_state_get
if _newclass:hook_state = _swig_property(_freeswitch.CoreSession_hook_state_get, _freeswitch.CoreSession_hook_state_set)
def answer(*args): return _freeswitch.CoreSession_answer(*args) def answer(*args): return _freeswitch.CoreSession_answer(*args)
def preAnswer(*args): return _freeswitch.CoreSession_preAnswer(*args) def preAnswer(*args): return _freeswitch.CoreSession_preAnswer(*args)
def hangup(*args): return _freeswitch.CoreSession_hangup(*args) def hangup(*args): return _freeswitch.CoreSession_hangup(*args)
...@@ -117,17 +123,26 @@ class CoreSession(_object): ...@@ -117,17 +123,26 @@ class CoreSession(_object):
def transfer(*args): return _freeswitch.CoreSession_transfer(*args) def transfer(*args): return _freeswitch.CoreSession_transfer(*args)
def playAndGetDigits(*args): return _freeswitch.CoreSession_playAndGetDigits(*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)
def setHangupHook(*args): return _freeswitch.CoreSession_setHangupHook(*args)
def ready(*args): return _freeswitch.CoreSession_ready(*args) def ready(*args): return _freeswitch.CoreSession_ready(*args)
def execute(*args): return _freeswitch.CoreSession_execute(*args) def execute(*args): return _freeswitch.CoreSession_execute(*args)
def begin_allow_threads(*args): return _freeswitch.CoreSession_begin_allow_threads(*args) def begin_allow_threads(*args): return _freeswitch.CoreSession_begin_allow_threads(*args)
def end_allow_threads(*args): return _freeswitch.CoreSession_end_allow_threads(*args) def end_allow_threads(*args): return _freeswitch.CoreSession_end_allow_threads(*args)
def get_uuid(*args): return _freeswitch.CoreSession_get_uuid(*args) def get_uuid(*args): return _freeswitch.CoreSession_get_uuid(*args)
def get_cb_args(*args): return _freeswitch.CoreSession_get_cb_args(*args) def get_cb_args(*args): return _freeswitch.CoreSession_get_cb_args(*args)
def check_hangup_hook(*args): return _freeswitch.CoreSession_check_hangup_hook(*args)
def run_dtmf_callback(*args): return _freeswitch.CoreSession_run_dtmf_callback(*args)
CoreSession_swigregister = _freeswitch.CoreSession_swigregister CoreSession_swigregister = _freeswitch.CoreSession_swigregister
CoreSession_swigregister(CoreSession) CoreSession_swigregister(CoreSession)
bridge = _freeswitch.bridge bridge = _freeswitch.bridge
PythonDTMFCallback = _freeswitch.PythonDTMFCallback hanguphook = _freeswitch.hanguphook
dtmf_callback = _freeswitch.dtmf_callback
S_SWAPPED_IN = _freeswitch.S_SWAPPED_IN
S_SWAPPED_OUT = _freeswitch.S_SWAPPED_OUT
class PySession(CoreSession): class PySession(CoreSession):
__swig_setmethods__ = {} __swig_setmethods__ = {}
for _s in [CoreSession]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) for _s in [CoreSession]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
...@@ -143,8 +158,12 @@ class PySession(CoreSession): ...@@ -143,8 +158,12 @@ class PySession(CoreSession):
__swig_destroy__ = _freeswitch.delete_PySession __swig_destroy__ = _freeswitch.delete_PySession
__del__ = lambda self : None; __del__ = lambda self : None;
def setDTMFCallback(*args): return _freeswitch.PySession_setDTMFCallback(*args) def setDTMFCallback(*args): return _freeswitch.PySession_setDTMFCallback(*args)
def setHangupHook(*args): return _freeswitch.PySession_setHangupHook(*args)
def check_hangup_hook(*args): return _freeswitch.PySession_check_hangup_hook(*args)
def hangup(*args): return _freeswitch.PySession_hangup(*args)
def begin_allow_threads(*args): return _freeswitch.PySession_begin_allow_threads(*args) def begin_allow_threads(*args): return _freeswitch.PySession_begin_allow_threads(*args)
def end_allow_threads(*args): return _freeswitch.PySession_end_allow_threads(*args) def end_allow_threads(*args): return _freeswitch.PySession_end_allow_threads(*args)
def run_dtmf_callback(*args): return _freeswitch.PySession_run_dtmf_callback(*args)
PySession_swigregister = _freeswitch.PySession_swigregister PySession_swigregister = _freeswitch.PySession_swigregister
PySession_swigregister(PySession) PySession_swigregister(PySession)
......
...@@ -14,12 +14,10 @@ extern "C" { ...@@ -14,12 +14,10 @@ extern "C" {
switch_status_t PythonDTMFCallback(switch_core_session *session, typedef enum {
void *input, S_SWAPPED_IN = (1 << 0),
switch_input_type_t itype, S_SWAPPED_OUT = (1 << 1)
void *buf, } swap_state_t;
unsigned int buflen);
void console_log(char *level_str, char *msg); void console_log(char *level_str, char *msg);
void console_clean_log(char *msg); void console_clean_log(char *msg);
...@@ -29,14 +27,21 @@ void api_reply_delete(char *reply); ...@@ -29,14 +27,21 @@ void api_reply_delete(char *reply);
class PySession : public CoreSession { class PySession : public CoreSession {
private: private:
void *threadState; void *threadState;
int swapstate;
public: public:
PySession(); PySession();
PySession(char *uuid); PySession(char *uuid);
PySession(switch_core_session_t *session); PySession(switch_core_session_t *session);
~PySession(); ~PySession();
void setDTMFCallback(PyObject *pyfunc, char *funcargs); void setDTMFCallback(PyObject *pyfunc, char *funcargs);
void begin_allow_threads(); void setHangupHook(PyObject *pyfunc);
void end_allow_threads(); void check_hangup_hook();
void hangup(char *cause);
bool begin_allow_threads();
bool end_allow_threads();
switch_status_t run_dtmf_callback(void *input,
switch_input_type_t itype);
}; };
......
...@@ -49,11 +49,12 @@ PyThreadState *mainThreadState = NULL; ...@@ -49,11 +49,12 @@ PyThreadState *mainThreadState = NULL;
void init_freeswitch(void); void init_freeswitch(void);
static switch_api_interface_t python_run_interface; static switch_api_interface_t python_run_interface;
SWITCH_MODULE_LOAD_FUNCTION(mod_python_load); SWITCH_MODULE_LOAD_FUNCTION(mod_python_load);
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_python_shutdown); SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_python_shutdown);
SWITCH_MODULE_DEFINITION(mod_python, mod_python_load, mod_python_shutdown, NULL); SWITCH_MODULE_DEFINITION(mod_python, mod_python_load, mod_python_shutdown, NULL);
static void eval_some_python(char *uuid, char *args) static void eval_some_python(char *uuid, char *args, switch_core_session_t *session)
{ {
PyThreadState *tstate = NULL; PyThreadState *tstate = NULL;
char *dupargs = NULL; char *dupargs = NULL;
...@@ -92,6 +93,11 @@ static void eval_some_python(char *uuid, char *args) ...@@ -92,6 +93,11 @@ static void eval_some_python(char *uuid, char *args)
// swap in thread state // swap in thread state
PyEval_AcquireThread(tstate); PyEval_AcquireThread(tstate);
if (session) {
// record the fact that thread state is swapped in
switch_channel_t *channel = switch_core_session_get_channel(session);
switch_channel_set_private(channel, "SwapInThreadState", NULL);
}
init_freeswitch(); init_freeswitch();
// import the module // import the module
...@@ -138,7 +144,9 @@ static void eval_some_python(char *uuid, char *args) ...@@ -138,7 +144,9 @@ static void eval_some_python(char *uuid, char *args)
} }
// invoke the handler // invoke the handler
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Call python script \n");
result = PyEval_CallObjectWithKeywords(function, arg, (PyObject *)NULL); result = PyEval_CallObjectWithKeywords(function, arg, (PyObject *)NULL);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Finished calling python script \n");
// check the result and print out any errors // check the result and print out any errors
if (!result) { if (!result) {
...@@ -160,7 +168,29 @@ static void eval_some_python(char *uuid, char *args) ...@@ -160,7 +168,29 @@ static void eval_some_python(char *uuid, char *args)
Py_XDECREF(result); Py_XDECREF(result);
// swap out thread state // swap out thread state
PyEval_ReleaseThread(tstate); if (session) {
// record the fact that thread state is swapped in
switch_channel_t *channel = switch_core_session_get_channel(session);
PyThreadState *swapin_tstate = (PyThreadState *) switch_channel_get_private(channel, "SwapInThreadState");
// so lets assume nothing in the python script swapped any thread state in
// or out .. thread state will currently be swapped in, and the SwapInThreadState
// 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");
// 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");
}
}
else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Threadstate mod_python.c swap-out! \n");
PyEval_ReleaseThread(tstate);
}
switch_safe_free(dupargs); switch_safe_free(dupargs);
...@@ -169,7 +199,7 @@ static void eval_some_python(char *uuid, char *args) ...@@ -169,7 +199,7 @@ static void eval_some_python(char *uuid, char *args)
static void python_function(switch_core_session_t *session, char *data) static void python_function(switch_core_session_t *session, char *data)
{ {
eval_some_python(switch_core_session_get_uuid(session), (char *)data); eval_some_python(switch_core_session_get_uuid(session), (char *)data, session);
} }
...@@ -183,7 +213,7 @@ static void *SWITCH_THREAD_FUNC py_thread_run(switch_thread_t *thread, void *obj ...@@ -183,7 +213,7 @@ static void *SWITCH_THREAD_FUNC py_thread_run(switch_thread_t *thread, void *obj
switch_memory_pool_t *pool; switch_memory_pool_t *pool;
struct switch_py_thread *pt = (struct switch_py_thread *) obj; struct switch_py_thread *pt = (struct switch_py_thread *) obj;
eval_some_python(NULL, strdup(pt->args)); eval_some_python(NULL, strdup(pt->args), NULL);
pool = pt->pool; pool = pt->pool;
switch_core_destroy_memory_pool(&pool); switch_core_destroy_memory_pool(&pool);
......
...@@ -9,12 +9,16 @@ ...@@ -9,12 +9,16 @@
%cstring_bounded_mutable(char *dtmf_buf, 128); %cstring_bounded_mutable(char *dtmf_buf, 128);
%cstring_bounded_mutable(char *terminator, 8); %cstring_bounded_mutable(char *terminator, 8);
/** insert the following includes into generated code so it compiles */ /** insert the following includes into generated code so it compiles */
%{ %{
#include "switch_cpp.h" #include "switch_cpp.h"
#include "freeswitch_python.h" #include "freeswitch_python.h"
%} %}
%ignore SwitchToMempool;
/** /**
* tell swig to grok everything defined in these header files and * tell swig to grok everything defined in these header files and
* build all sorts of c wrappers and python shadows of the c wrappers. * build all sorts of c wrappers and python shadows of the c wrappers.
......
...@@ -95,6 +95,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_file_open(switch_file_handle_t *fh, ...@@ -95,6 +95,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_file_open(switch_file_handle_t *fh,
SWITCH_DECLARE(switch_status_t) switch_core_file_read(switch_file_handle_t *fh, void *data, switch_size_t *len) SWITCH_DECLARE(switch_status_t) switch_core_file_read(switch_file_handle_t *fh, void *data, switch_size_t *len)
{ {
assert(fh != NULL); assert(fh != NULL);
assert(fh->file_interface != NULL);
return fh->file_interface->file_read(fh, data, len); return fh->file_interface->file_read(fh, data, len);
} }
...@@ -102,6 +103,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_file_read(switch_file_handle_t *fh, ...@@ -102,6 +103,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_file_read(switch_file_handle_t *fh,
SWITCH_DECLARE(switch_status_t) switch_core_file_write(switch_file_handle_t *fh, void *data, switch_size_t *len) SWITCH_DECLARE(switch_status_t) switch_core_file_write(switch_file_handle_t *fh, void *data, switch_size_t *len)
{ {
assert(fh != NULL); assert(fh != NULL);
assert(fh->file_interface != NULL);
return fh->file_interface->file_write(fh, data, len); return fh->file_interface->file_write(fh, data, len);
} }
...@@ -109,6 +111,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_file_write(switch_file_handle_t *fh, ...@@ -109,6 +111,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_file_write(switch_file_handle_t *fh,
SWITCH_DECLARE(switch_status_t) switch_core_file_seek(switch_file_handle_t *fh, unsigned int *cur_pos, int64_t samples, int whence) SWITCH_DECLARE(switch_status_t) switch_core_file_seek(switch_file_handle_t *fh, unsigned int *cur_pos, int64_t samples, int whence)
{ {
assert(fh != NULL); assert(fh != NULL);
assert(fh->file_interface != NULL);
switch_set_flag(fh, SWITCH_FILE_SEEK); switch_set_flag(fh, SWITCH_FILE_SEEK);
return fh->file_interface->file_seek(fh, cur_pos, samples, whence); return fh->file_interface->file_seek(fh, cur_pos, samples, whence);
...@@ -117,6 +120,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_file_seek(switch_file_handle_t *fh, ...@@ -117,6 +120,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_file_seek(switch_file_handle_t *fh,
SWITCH_DECLARE(switch_status_t) switch_core_file_set_string(switch_file_handle_t *fh, switch_audio_col_t col, const char *string) SWITCH_DECLARE(switch_status_t) switch_core_file_set_string(switch_file_handle_t *fh, switch_audio_col_t col, const char *string)
{ {
assert(fh != NULL); assert(fh != NULL);
assert(fh->file_interface != NULL);
return fh->file_interface->file_set_string(fh, col, string); return fh->file_interface->file_set_string(fh, col, string);
} }
...@@ -124,6 +128,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_file_set_string(switch_file_handle_t ...@@ -124,6 +128,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_file_set_string(switch_file_handle_t
SWITCH_DECLARE(switch_status_t) switch_core_file_get_string(switch_file_handle_t *fh, switch_audio_col_t col, const char **string) SWITCH_DECLARE(switch_status_t) switch_core_file_get_string(switch_file_handle_t *fh, switch_audio_col_t col, const char **string)
{ {
assert(fh != NULL); assert(fh != NULL);
assert(fh->file_interface != NULL);
return fh->file_interface->file_get_string(fh, col, string); return fh->file_interface->file_get_string(fh, col, string);
...@@ -132,6 +137,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_file_get_string(switch_file_handle_t ...@@ -132,6 +137,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_file_get_string(switch_file_handle_t
SWITCH_DECLARE(switch_status_t) switch_core_file_close(switch_file_handle_t *fh) SWITCH_DECLARE(switch_status_t) switch_core_file_close(switch_file_handle_t *fh)
{ {
assert(fh != NULL);
assert(fh->file_interface != NULL);
switch_clear_flag(fh, SWITCH_FILE_OPEN); switch_clear_flag(fh, SWITCH_FILE_OPEN);
return fh->file_interface->file_close(fh); return fh->file_interface->file_close(fh);
......
差异被折叠。
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论