tweaks
git-svn-id: http://svn.openzap.org/svn/openzap/trunk@400 a93c3328-9c30-0410-af19-c9cd2b2d52af
This commit is contained in:
parent
0d55659a6c
commit
e702576e1f
|
@ -29,6 +29,7 @@
|
|||
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
CFLAGS=-std=gnu99 -ffast-math -Wall -Wunused-variable -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes
|
||||
SRC=src
|
||||
SOURCES=\
|
||||
$(SRC)/hashtable.c \
|
||||
|
@ -138,10 +139,9 @@ $(SRC)/isdn/include/Q931.h \
|
|||
$(SRC)/isdn/include/Q931ie.h \
|
||||
$(SRC)/isdn/include/Q932.h
|
||||
|
||||
|
||||
PWD=$(shell pwd)
|
||||
INCS=-I$(PWD)/$(SRC)/include -I$(PWD)/$(SRC)/isdn/include
|
||||
CFLAGS= $(INCS) $(ZAP_CFLAGS)
|
||||
CFLAGS+= $(INCS) $(ZAP_CFLAGS)
|
||||
MYLIB=libopenzap.a
|
||||
LIBPRIA=libpri.a
|
||||
LIBPRI=./libpri
|
||||
|
@ -158,8 +158,6 @@ ADD_OBJS = $(PIKA_LIB)
|
|||
endif
|
||||
endif
|
||||
|
||||
include general.makefile
|
||||
|
||||
all: $(MYLIB)
|
||||
|
||||
$(MYLIB): $(OBJS) $(HEADERS) $(SOURCES)
|
||||
|
@ -222,239 +220,3 @@ mod_openzap-clean:
|
|||
clean: mod_openzap-clean
|
||||
rm -f $(SRC)/*.o $(SRC)/isdn/*.o $(MYLIB) *~ \#* testapp testcid testtones detect_tones detect_dtmf priserver testisdn testanalog
|
||||
@if [ -f $(LIBPRI)/$(LIBPRIA) ] ; then cd $(LIBPRI) && make clean ; fi
|
||||
|
||||
|
||||
# Copyright (c) 2007, Anthony Minessale II
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
#
|
||||
# * Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# * Neither the name of the original author; nor the names of any contributors
|
||||
# may be used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||
# OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
SRC=src
|
||||
SOURCES=\
|
||||
$(SRC)/hashtable.c \
|
||||
$(SRC)/hashtable_itr.c \
|
||||
$(SRC)/zap_io.c \
|
||||
$(SRC)/zap_isdn.c \
|
||||
$(SRC)/zap_analog.c \
|
||||
$(SRC)/zap_config.c \
|
||||
$(SRC)/zap_callerid.c \
|
||||
$(SRC)/fsk.c \
|
||||
$(SRC)/uart.c \
|
||||
$(SRC)/g711.c \
|
||||
$(SRC)/libteletone_detect.c \
|
||||
$(SRC)/libteletone_generate.c \
|
||||
$(SRC)/zap_buffer.c \
|
||||
$(SRC)/zap_threadmutex.c \
|
||||
$(SRC)/isdn/EuroISDNStateNT.c \
|
||||
$(SRC)/isdn/EuroISDNStateTE.c \
|
||||
$(SRC)/isdn/mfifo.c \
|
||||
$(SRC)/isdn/Q921.c \
|
||||
$(SRC)/isdn/Q931api.c \
|
||||
$(SRC)/isdn/Q931.c \
|
||||
$(SRC)/isdn/Q931ie.c \
|
||||
$(SRC)/isdn/Q931mes.c \
|
||||
$(SRC)/isdn/Q931StateNT.c \
|
||||
$(SRC)/isdn/Q931StateTE.c \
|
||||
$(SRC)/isdn/nationalmes.c \
|
||||
$(SRC)/isdn/nationalStateNT.c \
|
||||
$(SRC)/isdn/nationalStateTE.c \
|
||||
$(SRC)/isdn/DMSmes.c \
|
||||
$(SRC)/isdn/DMSStateNT.c \
|
||||
$(SRC)/isdn/DMSStateTE.c \
|
||||
$(SRC)/isdn/5ESSmes.c \
|
||||
$(SRC)/isdn/5ESSStateNT.c \
|
||||
$(SRC)/isdn/5ESSStateTE.c \
|
||||
$(SRC)/isdn/Q932mes.c \
|
||||
$(SRC)/zap_zt.c \
|
||||
$(SRC)/zap_wanpipe.c\
|
||||
$(SRC)/ss7_boost_client.c
|
||||
|
||||
OBJS=\
|
||||
$(SRC)/hashtable.o \
|
||||
$(SRC)/hashtable_itr.o \
|
||||
$(SRC)/zap_io.o \
|
||||
$(SRC)/zap_isdn.o \
|
||||
$(SRC)/zap_analog.o \
|
||||
$(SRC)/zap_config.o \
|
||||
$(SRC)/zap_callerid.o \
|
||||
$(SRC)/fsk.o \
|
||||
$(SRC)/uart.o \
|
||||
$(SRC)/g711.o \
|
||||
$(SRC)/libteletone_detect.o \
|
||||
$(SRC)/libteletone_generate.o \
|
||||
$(SRC)/zap_buffer.o \
|
||||
$(SRC)/zap_threadmutex.o \
|
||||
$(SRC)/isdn/EuroISDNStateNT.o \
|
||||
$(SRC)/isdn/EuroISDNStateTE.o \
|
||||
$(SRC)/isdn/mfifo.o \
|
||||
$(SRC)/isdn/Q921.o \
|
||||
$(SRC)/isdn/Q931api.o \
|
||||
$(SRC)/isdn/Q931.o \
|
||||
$(SRC)/isdn/Q931ie.o \
|
||||
$(SRC)/isdn/Q931mes.o \
|
||||
$(SRC)/isdn/Q931StateNT.o \
|
||||
$(SRC)/isdn/Q931StateTE.o \
|
||||
$(SRC)/isdn/nationalmes.o \
|
||||
$(SRC)/isdn/nationalStateNT.o \
|
||||
$(SRC)/isdn/nationalStateTE.o \
|
||||
$(SRC)/isdn/DMSmes.o \
|
||||
$(SRC)/isdn/DMSStateNT.o \
|
||||
$(SRC)/isdn/DMSStateTE.o \
|
||||
$(SRC)/isdn/5ESSmes.o \
|
||||
$(SRC)/isdn/5ESSStateNT.o \
|
||||
$(SRC)/isdn/5ESSStateTE.o \
|
||||
$(SRC)/isdn/Q932mes.o \
|
||||
$(SRC)/zap_zt.o \
|
||||
$(SRC)/zap_wanpipe.o\
|
||||
$(SRC)/ss7_boost_client.o
|
||||
|
||||
#SRCS=$(shell echo $(OBJS) | sed "s/\.o/\.c/g")
|
||||
|
||||
HEADERS= $(SRC)/include/fsk.h \
|
||||
$(SRC)/include/g711.h \
|
||||
$(SRC)/include/hashtable.h \
|
||||
$(SRC)/include/hashtable_itr.h \
|
||||
$(SRC)/include/hashtable_private.h \
|
||||
$(SRC)/include/libteletone_detect.h \
|
||||
$(SRC)/include/libteletone_generate.h \
|
||||
$(SRC)/include/libteletone.h \
|
||||
$(SRC)/include/openzap.h \
|
||||
$(SRC)/include/sangoma_tdm_api.h \
|
||||
$(SRC)/include/uart.h \
|
||||
$(SRC)/include/wanpipe_tdm_api_iface.h \
|
||||
$(SRC)/include/zap_analog.h \
|
||||
$(SRC)/include/zap_buffer.h \
|
||||
$(SRC)/include/zap_config.h \
|
||||
$(SRC)/include/zap_isdn.h \
|
||||
$(SRC)/include/zap_skel.h \
|
||||
$(SRC)/include/zap_threadmutex.h \
|
||||
$(SRC)/include/zap_types.h \
|
||||
$(SRC)/include/zap_wanpipe.h \
|
||||
$(SRC)/include/zap_zt.h \
|
||||
$(SRC)/include/ss7_boost_client.h \
|
||||
$(SRC)/isdn/include/mfifo.h \
|
||||
$(SRC)/isdn/include/national.h \
|
||||
$(SRC)/isdn/include/DMS.h \
|
||||
$(SRC)/isdn/include/5ESS.h \
|
||||
$(SRC)/isdn/include/Q921.h \
|
||||
$(SRC)/isdn/include/Q931.h \
|
||||
$(SRC)/isdn/include/Q931ie.h \
|
||||
$(SRC)/isdn/include/Q932.h
|
||||
|
||||
|
||||
PWD=$(shell pwd)
|
||||
INCS=-I$(PWD)/$(SRC)/include -I$(PWD)/$(SRC)/isdn/include
|
||||
CFLAGS= $(INCS) $(ZAP_CFLAGS)
|
||||
MYLIB=libopenzap.a
|
||||
LIBPRIA=libpri.a
|
||||
LIBPRI=./libpri
|
||||
TMP=-I$(LIBPRI) -I$(SRC)/include -I./src -w
|
||||
|
||||
SCTP_H=$(shell ls /usr/include/netinet/sctp.h 2>/dev/null)
|
||||
ifneq ($(SCTP_H),)
|
||||
CFLAGS += -DSS7BC_USE_SCTP
|
||||
endif
|
||||
|
||||
PIKA_DIR=$(shell ls -d /usr/include/pika 2>/dev/null)
|
||||
PIKA_LIB=$(shell ls /usr/lib/libpikahmpapi.so 2>/dev/null)
|
||||
|
||||
ifneq ($(PIKA_DIR),)
|
||||
ifneq ($(PIKA_LIB),)
|
||||
OBJS += $(SRC)/zap_pika.o
|
||||
CFLAGS += -DZAP_PIKA_SUPPORT -I$(PIKA_DIR)
|
||||
ADD_OBJS = $(PIKA_LIB)
|
||||
endif
|
||||
endif
|
||||
|
||||
include general.makefile
|
||||
|
||||
all: $(MYLIB)
|
||||
|
||||
$(MYLIB): $(OBJS) $(HEADERS) $(SOURCES)
|
||||
ar rcs $(MYLIB) $(OBJS) $(ADD_OBJS)
|
||||
ranlib $(MYLIB)
|
||||
|
||||
testapp: $(SRC)/testapp.c $(MYLIB)
|
||||
$(CC) $(INCS) -L. $(SRC)/testapp.c -o testapp -lopenzap -lm -lpthread
|
||||
|
||||
testcid: $(SRC)/testcid.c $(MYLIB)
|
||||
$(CC) $(INCS) -L. -g -ggdb $(SRC)/testcid.c -o testcid -lopenzap -lm -lpthread
|
||||
|
||||
testtones: $(SRC)/testtones.c $(MYLIB)
|
||||
$(CC) $(INCS) -L. $(SRC)/testtones.c -o testtones -lopenzap -lm
|
||||
|
||||
detect_tones: $(SRC)/detect_tones.c $(MYLIB)
|
||||
$(CC) $(INCS) -L. $(SRC)/detect_tones.c -o detect_tones -lopenzap -lm
|
||||
|
||||
detect_dtmf: $(SRC)/detect_dtmf.c $(MYLIB)
|
||||
$(CC) $(INCS) -L. $(SRC)/detect_dtmf.c -o detect_dtmf -lopenzap -lm
|
||||
|
||||
testisdn: $(SRC)/testisdn.c $(MYLIB)
|
||||
$(CC) $(INCS) $(ZAP_CFLAGS) -L. $(SRC)/testisdn.c -o testisdn -lopenzap -lm -lpthread
|
||||
|
||||
testanalog: $(SRC)/testanalog.c $(MYLIB)
|
||||
$(CC) $(INCS) -L. $(SRC)/testanalog.c -o testanalog -lopenzap -lm -lpthread
|
||||
|
||||
$(SRC)/priserver.o: $(SRC)/priserver.c
|
||||
$(CC) $(INCS) $(TMP) -c $(SRC)/priserver.c -o $(SRC)/priserver.o
|
||||
|
||||
$(SRC)/sangoma_pri.o: $(SRC)/sangoma_pri.c
|
||||
$(CC) $(INCS) $(TMP) -c $(SRC)/sangoma_pri.c -o $(SRC)/sangoma_pri.o
|
||||
|
||||
$(LIBPRI)/$(LIBPRIA):
|
||||
cd libpri && make
|
||||
|
||||
priserver: $(MYLIB) $(SRC)/priserver.o $(SRC)/sangoma_pri.o $(LIBPRI)/$(LIBPRIA)
|
||||
$(CC) $(SRC)/sangoma_pri.o $(SRC)/priserver.o -L. -o priserver -lopenzap -lm -lpthread $(LIBPRI)/$(LIBPRIA)
|
||||
|
||||
$(SRC)/zap_io.o: $(SRC)/zap_io.c
|
||||
$(CC) $(MOD_CFLAGS) $(CC_CFLAGS) $(CFLAGS) -c $< -o $@
|
||||
|
||||
%.o: %.c $(HEADERS)
|
||||
$(CC) $(CC_CFLAGS) $(CFLAGS) -c $< -o $@
|
||||
|
||||
dox:
|
||||
cd docs && doxygen $(PWD)/docs/Doxygen.conf
|
||||
|
||||
mod_openzap/mod_openzap.so: $(MYLIB) mod_openzap/mod_openzap.c
|
||||
cd mod_openzap && make
|
||||
|
||||
mod_openzap: mod_openzap/mod_openzap.so
|
||||
|
||||
mod_openzap-install: mod_openzap
|
||||
cd mod_openzap && make install
|
||||
|
||||
mod_openzap-clean:
|
||||
@if [ -f mod_openzap/mod_openzap.so ] ; then cd mod_openzap && make clean ; fi
|
||||
|
||||
clean: mod_openzap-clean
|
||||
rm -f $(SRC)/*.o $(SRC)/isdn/*.o $(MYLIB) *~ \#* testapp testcid testtones detect_tones detect_dtmf priserver testisdn testanalog
|
||||
@if [ -f $(LIBPRI)/$(LIBPRIA) ] ; then cd $(LIBPRI) && make clean ; fi
|
||||
|
||||
|
||||
|
|
|
@ -1188,6 +1188,7 @@ static ZIO_SIGNAL_CB_FUNCTION(on_fxs_signal)
|
|||
fail_regex = NULL;
|
||||
}
|
||||
|
||||
zap_log(ZAP_LOG_DEBUG, "got DTMF sig [%s]\n", dtmf);
|
||||
switch_set_string(sigmsg->channel->caller_data.collected, dtmf);
|
||||
|
||||
if ((regex || fail_regex) && !switch_strlen_zero(dtmf)) {
|
||||
|
|
|
@ -307,15 +307,16 @@ dsp_fsk_sample (dsp_fsk_handle_t *handle, double normalized_sample)
|
|||
if (handle->cellpos > 1.0) {
|
||||
handle->cellpos -= 1.0;
|
||||
|
||||
|
||||
switch (handle->state) {
|
||||
case FSK_STATE_DATA:
|
||||
{
|
||||
|
||||
(*handle->attr.bithandler) (handle->attr.bithandler_arg, handle->current_bit);
|
||||
}
|
||||
break;
|
||||
case FSK_STATE_CHANSEIZE:
|
||||
{
|
||||
|
||||
if (handle->last_bit != handle->current_bit) {
|
||||
handle->conscutive_state_bits++;
|
||||
} else {
|
||||
|
|
|
@ -493,6 +493,7 @@ zap_status_t zap_channel_set_state(zap_channel_t *zchan, zap_channel_state_t sta
|
|||
zap_status_t zap_span_load_tones(zap_span_t *span, char *mapname);
|
||||
zap_size_t zap_channel_dequeue_dtmf(zap_channel_t *zchan, char *dtmf, zap_size_t len);
|
||||
zap_status_t zap_channel_queue_dtmf(zap_channel_t *zchan, const char *dtmf);
|
||||
void zap_channel_flush_dtmf(zap_channel_t *zchan);
|
||||
zap_time_t zap_current_time_in_ms(void);
|
||||
zap_status_t zap_span_poll_event(zap_span_t *span, uint32_t ms);
|
||||
zap_status_t zap_span_next_event(zap_span_t *span, zap_event_t **event);
|
||||
|
@ -531,6 +532,15 @@ ZIO_CODEC_FUNCTION(zio_alaw2slin);
|
|||
ZIO_CODEC_FUNCTION(zio_ulaw2alaw);
|
||||
ZIO_CODEC_FUNCTION(zio_alaw2ulaw);
|
||||
|
||||
#ifdef DEBUG_LOCKS
|
||||
#define zap_mutex_lock(_x) printf("++++++lock %s:%d\n", __FILE__, __LINE__) && _zap_mutex_lock(_x)
|
||||
#define zap_mutex_trylock(_x) printf("++++++try %s:%d\n", __FILE__, __LINE__) && _zap_mutex_trylock(_x)
|
||||
#define zap_mutex_unlock(_x) printf("------unlock %s:%d\n", __FILE__, __LINE__) && _zap_mutex_unlock(_x)
|
||||
#else
|
||||
#define zap_mutex_lock(_x) _zap_mutex_lock(_x)
|
||||
#define zap_mutex_trylock(_x) _zap_mutex_trylock(_x)
|
||||
#define zap_mutex_unlock(_x) _zap_mutex_unlock(_x)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -32,9 +32,9 @@ zap_status_t zap_thread_create_detached_ex(zap_thread_function_t func, void *dat
|
|||
void zap_thread_override_default_stacksize(zap_size_t size);
|
||||
zap_status_t zap_mutex_create(zap_mutex_t **mutex);
|
||||
zap_status_t zap_mutex_destroy(zap_mutex_t **mutex);
|
||||
zap_status_t zap_mutex_lock(zap_mutex_t *mutex);
|
||||
zap_status_t zap_mutex_trylock(zap_mutex_t *mutex);
|
||||
zap_status_t zap_mutex_unlock(zap_mutex_t *mutex);
|
||||
zap_status_t _zap_mutex_lock(zap_mutex_t *mutex);
|
||||
zap_status_t _zap_mutex_trylock(zap_mutex_t *mutex);
|
||||
zap_status_t _zap_mutex_unlock(zap_mutex_t *mutex);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -43,8 +43,6 @@ static void *zap_analog_channel_run(zap_thread_t *me, void *obj);
|
|||
static ZIO_CHANNEL_OUTGOING_CALL_FUNCTION(analog_fxo_outgoing_call)
|
||||
{
|
||||
if (!zap_test_flag(zchan, ZAP_CHANNEL_OFFHOOK) && !zap_test_flag(zchan, ZAP_CHANNEL_INTHREAD)) {
|
||||
//zap_channel_command(zchan, ZAP_COMMAND_TRACE_INPUT, "/tmp/inbound.ul");
|
||||
//zap_channel_command(zchan, ZAP_COMMAND_TRACE_OUTPUT, "/tmp/outbound.ul");
|
||||
zap_channel_clear_needed_tones(zchan);
|
||||
zap_channel_clear_detected_tones(zchan);
|
||||
|
||||
|
@ -185,7 +183,7 @@ static void *zap_analog_channel_run(zap_thread_t *me, void *obj)
|
|||
ts.buffer = NULL;
|
||||
|
||||
if (zap_channel_open_chan(zchan) != ZAP_SUCCESS) {
|
||||
zap_log(ZAP_LOG_ERROR, "OPEN ERROR\n");
|
||||
zap_log(ZAP_LOG_ERROR, "OPEN ERROR [%s]\n", zchan->last_error);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
@ -232,6 +230,7 @@ static void *zap_analog_channel_run(zap_thread_t *me, void *obj)
|
|||
case ZAP_CHANNEL_STATE_GET_CALLERID:
|
||||
{
|
||||
if (state_counter > 5000 || !zap_test_flag(zchan, ZAP_CHANNEL_CALLERID_DETECT)) {
|
||||
zap_channel_command(zchan, ZAP_COMMAND_DISABLE_CALLERID_DETECT, NULL);
|
||||
zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_IDLE);
|
||||
}
|
||||
}
|
||||
|
@ -355,6 +354,7 @@ static void *zap_analog_channel_run(zap_thread_t *me, void *obj)
|
|||
{
|
||||
zap_channel_use(zchan);
|
||||
zap_channel_clear_needed_tones(zchan);
|
||||
zap_channel_flush_dtmf(zchan);
|
||||
|
||||
if (zchan->type == ZAP_CHAN_TYPE_FXO && !zap_test_flag(zchan, ZAP_CHANNEL_OFFHOOK)) {
|
||||
zap_channel_command(zchan, ZAP_COMMAND_OFFHOOK, NULL);
|
||||
|
@ -569,7 +569,7 @@ static void *zap_analog_channel_run(zap_thread_t *me, void *obj)
|
|||
zchan->needed_tones[ZAP_TONEMAP_FAIL1] = 1;
|
||||
zchan->needed_tones[ZAP_TONEMAP_FAIL2] = 1;
|
||||
zchan->needed_tones[ZAP_TONEMAP_FAIL3] = 1;
|
||||
dial_timeout = ((zchan->dtmf_on + zchan->dtmf_off) * strlen(zchan->caller_data.ani)) + 3000;
|
||||
dial_timeout = ((zchan->dtmf_on + zchan->dtmf_off) * strlen(zchan->caller_data.ani)) + 2000;
|
||||
}
|
||||
}
|
||||
} else if (zchan->detected_tones[ZAP_TONEMAP_RING]) {
|
||||
|
@ -658,6 +658,7 @@ static __inline__ zap_status_t process_event(zap_span_t *span, zap_event_t *even
|
|||
{
|
||||
zap_sigmsg_t sig;
|
||||
zap_analog_data_t *analog_data = event->channel->span->signal_data;
|
||||
int locked = 0;
|
||||
|
||||
memset(&sig, 0, sizeof(sig));
|
||||
sig.chan_id = event->channel->chan_id;
|
||||
|
@ -669,15 +670,16 @@ static __inline__ zap_status_t process_event(zap_span_t *span, zap_event_t *even
|
|||
zap_oob_event2str(event->enum_id), event->channel->span_id, event->channel->chan_id, zap_channel_state2str(event->channel->state));
|
||||
|
||||
zap_mutex_lock(event->channel->mutex);
|
||||
|
||||
locked++;
|
||||
|
||||
switch(event->enum_id) {
|
||||
case ZAP_OOB_RING_START:
|
||||
{
|
||||
|
||||
if (event->channel->state == ZAP_CHANNEL_STATE_DOWN && !zap_test_flag(event->channel, ZAP_CHANNEL_INTHREAD)) {
|
||||
if (!event->channel->ring_count && (event->channel->state == ZAP_CHANNEL_STATE_DOWN && !zap_test_flag(event->channel, ZAP_CHANNEL_INTHREAD))) {
|
||||
zap_set_state_locked(event->channel, ZAP_CHANNEL_STATE_GET_CALLERID);
|
||||
event->channel->ring_count = 1;
|
||||
zap_mutex_unlock(event->channel->mutex);
|
||||
locked = 0;
|
||||
zap_thread_create_detached(zap_analog_channel_run, event->channel);
|
||||
} else {
|
||||
event->channel->ring_count++;
|
||||
|
@ -693,6 +695,7 @@ static __inline__ zap_status_t process_event(zap_span_t *span, zap_event_t *even
|
|||
if (event->channel->state != ZAP_CHANNEL_STATE_DOWN) {
|
||||
zap_set_state_locked(event->channel, ZAP_CHANNEL_STATE_DOWN);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
case ZAP_OOB_FLASH:
|
||||
|
@ -724,6 +727,8 @@ static __inline__ zap_status_t process_event(zap_span_t *span, zap_event_t *even
|
|||
zap_set_state_locked(event->channel, ZAP_CHANNEL_STATE_UP);
|
||||
} else {
|
||||
zap_set_state_locked(event->channel, ZAP_CHANNEL_STATE_DIALTONE);
|
||||
zap_mutex_unlock(event->channel->mutex);
|
||||
locked = 0;
|
||||
zap_thread_create_detached(zap_analog_channel_run, event->channel);
|
||||
}
|
||||
} else {
|
||||
|
@ -736,8 +741,9 @@ static __inline__ zap_status_t process_event(zap_span_t *span, zap_event_t *even
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
zap_mutex_unlock(event->channel->mutex);
|
||||
if (locked) {
|
||||
zap_mutex_unlock(event->channel->mutex);
|
||||
}
|
||||
return ZAP_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -436,8 +436,10 @@ zap_status_t zap_span_add_channel(zap_span_t *span, zap_socket_t sockfd, zap_cha
|
|||
if (!new_chan->dtmf_off) {
|
||||
new_chan->dtmf_off = ZAP_DEFAULT_DTMF_OFF;
|
||||
}
|
||||
|
||||
zap_mutex_create(&new_chan->mutex);
|
||||
zap_buffer_create(&new_chan->digit_buffer, 128, 128, 0);
|
||||
|
||||
zap_set_flag(new_chan, ZAP_CHANNEL_CONFIGURED | ZAP_CHANNEL_READY);
|
||||
*chan = new_chan;
|
||||
return ZAP_SUCCESS;
|
||||
|
@ -814,10 +816,12 @@ zap_status_t zap_channel_open_chan(zap_channel_t *zchan)
|
|||
assert(zchan != NULL);
|
||||
|
||||
if (zap_test_flag(zchan, ZAP_CHANNEL_SUSPENDED)) {
|
||||
snprintf(zchan->last_error, sizeof(zchan->last_error), "%s", "Channel is suspended");
|
||||
return ZAP_FAIL;
|
||||
}
|
||||
|
||||
if (!zap_test_flag(zchan, ZAP_CHANNEL_READY) || (status = zap_mutex_trylock(zchan->mutex)) != ZAP_SUCCESS) {
|
||||
snprintf(zchan->last_error, sizeof(zchan->last_error), "Channel is not ready or is in use %d %d", zap_test_flag(zchan, ZAP_CHANNEL_READY), status);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
@ -828,9 +832,11 @@ zap_status_t zap_channel_open_chan(zap_channel_t *zchan)
|
|||
if (status == ZAP_SUCCESS) {
|
||||
zap_set_flag(zchan, ZAP_CHANNEL_OPEN);
|
||||
}
|
||||
} else {
|
||||
snprintf(zchan->last_error, sizeof(zchan->last_error), "%s", "Channel is not ready");
|
||||
}
|
||||
zap_mutex_unlock(zchan->mutex);
|
||||
|
||||
zap_mutex_unlock(zchan->mutex);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
@ -894,8 +900,6 @@ zap_status_t zap_channel_outgoing_call(zap_channel_t *zchan)
|
|||
|
||||
zap_status_t zap_channel_done(zap_channel_t *zchan)
|
||||
{
|
||||
int i;
|
||||
|
||||
assert(zchan != NULL);
|
||||
|
||||
memset(&zchan->caller_data, 0, sizeof(zchan->caller_data));
|
||||
|
@ -903,12 +907,6 @@ zap_status_t zap_channel_done(zap_channel_t *zchan)
|
|||
zap_clear_flag_locked(zchan, ZAP_CHANNEL_INUSE);
|
||||
zap_clear_flag_locked(zchan, ZAP_CHANNEL_OUTBOUND);
|
||||
|
||||
for (i = 0; i < 2; i++) {
|
||||
if (zchan->fds[i] > -1) {
|
||||
close(zchan->fds[i]);
|
||||
zchan->fds[i] = -1;
|
||||
}
|
||||
}
|
||||
return ZAP_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -1019,7 +1017,8 @@ zap_status_t zap_channel_command(zap_channel_t *zchan, zap_command_t command, vo
|
|||
close(zchan->fds[0]);
|
||||
zchan->fds[0] = -1;
|
||||
}
|
||||
if ((zchan->fds[0] = open(path, O_WRONLY|O_CREAT|O_TRUNC, 755)) > -1) {
|
||||
if ((zchan->fds[0] = open(path, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR)) > -1) {
|
||||
zap_log(ZAP_LOG_DEBUG, "Tracing channel %u:%u to [%s]\n", zchan->span_id, zchan->chan_id, path);
|
||||
GOTO_STATUS(done, ZAP_SUCCESS);
|
||||
}
|
||||
|
||||
|
@ -1031,10 +1030,11 @@ zap_status_t zap_channel_command(zap_channel_t *zchan, zap_command_t command, vo
|
|||
{
|
||||
char *path = (char *) obj;
|
||||
if (zchan->fds[1] > 0) {
|
||||
close(zchan->fds[0]);
|
||||
close(zchan->fds[1]);
|
||||
zchan->fds[1] = -1;
|
||||
}
|
||||
if ((zchan->fds[1] = open(path, O_WRONLY|O_CREAT|O_TRUNC, 755)) > -1) {
|
||||
if ((zchan->fds[1] = open(path, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR)) > -1) {
|
||||
zap_log(ZAP_LOG_DEBUG, "Tracing channel %u:%u to [%s]\n", zchan->span_id, zchan->chan_id, path);
|
||||
GOTO_STATUS(done, ZAP_SUCCESS);
|
||||
}
|
||||
|
||||
|
@ -1432,6 +1432,14 @@ zap_size_t zap_channel_dequeue_dtmf(zap_channel_t *zchan, char *dtmf, zap_size_t
|
|||
return bytes;
|
||||
}
|
||||
|
||||
void zap_channel_flush_dtmf(zap_channel_t *zchan)
|
||||
{
|
||||
if (zchan->digit_buffer && zap_buffer_inuse(zchan->digit_buffer)) {
|
||||
zap_mutex_lock(zchan->mutex);
|
||||
zap_buffer_zero(zchan->digit_buffer);
|
||||
zap_mutex_unlock(zchan->mutex);
|
||||
}
|
||||
}
|
||||
|
||||
zap_status_t zap_channel_queue_dtmf(zap_channel_t *zchan, const char *dtmf)
|
||||
{
|
||||
|
|
|
@ -184,7 +184,7 @@ zap_status_t zap_mutex_destroy(zap_mutex_t **mutex)
|
|||
return ZAP_SUCCESS;
|
||||
}
|
||||
|
||||
zap_status_t zap_mutex_lock(zap_mutex_t *mutex)
|
||||
zap_status_t _zap_mutex_lock(zap_mutex_t *mutex)
|
||||
{
|
||||
#ifdef WIN32
|
||||
EnterCriticalSection(&mutex->mutex);
|
||||
|
@ -195,7 +195,7 @@ zap_status_t zap_mutex_lock(zap_mutex_t *mutex)
|
|||
return ZAP_SUCCESS;
|
||||
}
|
||||
|
||||
zap_status_t zap_mutex_trylock(zap_mutex_t *mutex)
|
||||
zap_status_t _zap_mutex_trylock(zap_mutex_t *mutex)
|
||||
{
|
||||
#ifdef WIN32
|
||||
if (!TryEnterCriticalSection(&mutex->mutex))
|
||||
|
@ -207,7 +207,7 @@ zap_status_t zap_mutex_trylock(zap_mutex_t *mutex)
|
|||
return ZAP_SUCCESS;
|
||||
}
|
||||
|
||||
zap_status_t zap_mutex_unlock(zap_mutex_t *mutex)
|
||||
zap_status_t _zap_mutex_unlock(zap_mutex_t *mutex)
|
||||
{
|
||||
#ifdef WIN32
|
||||
LeaveCriticalSection(&mutex->mutex);
|
||||
|
@ -218,6 +218,10 @@ zap_status_t zap_mutex_unlock(zap_mutex_t *mutex)
|
|||
return ZAP_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
* mode:c
|
||||
|
|
|
@ -88,6 +88,7 @@ static unsigned zt_open_range(zap_span_t *span, unsigned start, unsigned end, za
|
|||
struct zt_chanconfig cc;
|
||||
memset(&cc, 0, sizeof(cc));
|
||||
cc.chan = cc.master = x;
|
||||
|
||||
switch(type) {
|
||||
case ZAP_CHAN_TYPE_FXS:
|
||||
{
|
||||
|
@ -126,11 +127,9 @@ static unsigned zt_open_range(zap_span_t *span, unsigned start, unsigned end, za
|
|||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (ioctl(CONTROL_FD, ZT_CHANCONFIG, &cc)) {
|
||||
zap_log(ZAP_LOG_ERROR, "failure configuring device %s chan %d fd %d (%s)\n",
|
||||
path, x, CONTROL_FD, strerror(errno));
|
||||
close(sockfd);
|
||||
break;
|
||||
zap_log(ZAP_LOG_WARNING, "this ioctl fails on older zaptel but is harmless if you used ztcfg\n[device %s chan %d fd %d (%s)]\n", path, x, CONTROL_FD, strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue