misc
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@2704 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
c79cd67dee
commit
0fcf13bc34
|
@ -710,6 +710,10 @@ static void conference_loop(conference_member_t *member)
|
||||||
write_frame.buflen = sizeof(data);
|
write_frame.buflen = sizeof(data);
|
||||||
write_frame.codec = &member->write_codec;
|
write_frame.codec = &member->write_codec;
|
||||||
|
|
||||||
|
if (switch_test_flag(member->conference, CFLAG_ANSWERED)) {
|
||||||
|
switch_channel_answer(channel);
|
||||||
|
}
|
||||||
|
|
||||||
/* Start a thread to read data and feed it into the buffer and use this thread to generate output */
|
/* Start a thread to read data and feed it into the buffer and use this thread to generate output */
|
||||||
launch_input_thread(member, switch_core_session_get_pool(member->session));
|
launch_input_thread(member, switch_core_session_get_pool(member->session));
|
||||||
|
|
||||||
|
@ -2344,9 +2348,12 @@ static void conference_function(switch_core_session_t *session, char *data)
|
||||||
if (conference_outcall(conference, session, bridgeto, 60, NULL, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
|
if (conference_outcall(conference, session, bridgeto, 60, NULL, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
} //else
|
} else {
|
||||||
// if we're not using "bridge:" set the conference answered flag
|
// if we're not using "bridge:" set the conference answered flag
|
||||||
//switch_set_flag(conference, CFLAG_ANSWERED);
|
// and this isn't an outbound channel, answer the call
|
||||||
|
if (!switch_channel_test_flag(channel, CF_OUTBOUND))
|
||||||
|
switch_set_flag(conference, CFLAG_ANSWERED);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -187,7 +187,7 @@ static switch_status_t switch_g711a_destroy(switch_codec_t *codec)
|
||||||
|
|
||||||
/* Registration */
|
/* Registration */
|
||||||
|
|
||||||
#if 0
|
|
||||||
|
|
||||||
static const switch_codec_implementation_t g711u_8k_60ms_implementation = {
|
static const switch_codec_implementation_t g711u_8k_60ms_implementation = {
|
||||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||||
|
@ -208,7 +208,7 @@ static const switch_codec_implementation_t g711u_8k_60ms_implementation = {
|
||||||
/*.destroy */ switch_g711u_destroy
|
/*.destroy */ switch_g711u_destroy
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if 0
|
||||||
static const switch_codec_implementation_t g711u_8k_30ms_implementation = {
|
static const switch_codec_implementation_t g711u_8k_30ms_implementation = {
|
||||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||||
/*.ianacode */ 0,
|
/*.ianacode */ 0,
|
||||||
|
@ -268,6 +268,7 @@ static const switch_codec_implementation_t g711u_8k_implementation = {
|
||||||
/*.decode */ switch_g711u_decode,
|
/*.decode */ switch_g711u_decode,
|
||||||
/*.destroy */ switch_g711u_destroy,
|
/*.destroy */ switch_g711u_destroy,
|
||||||
///*.next */ &g711u_16k_implementation
|
///*.next */ &g711u_16k_implementation
|
||||||
|
&g711u_8k_60ms_implementation
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -585,7 +585,7 @@ static switch_status_t activate_rtp(struct private_object *tech_pvt)
|
||||||
ms,
|
ms,
|
||||||
flags,
|
flags,
|
||||||
key,
|
key,
|
||||||
"soft",
|
"thread_soft",
|
||||||
&err, switch_core_session_get_pool(tech_pvt->session));
|
&err, switch_core_session_get_pool(tech_pvt->session));
|
||||||
|
|
||||||
if (switch_rtp_ready(tech_pvt->rtp_session)) {
|
if (switch_rtp_ready(tech_pvt->rtp_session)) {
|
||||||
|
|
|
@ -37,16 +37,18 @@ static switch_memory_pool_t *module_pool = NULL;
|
||||||
static struct {
|
static struct {
|
||||||
int32_t RUNNING;
|
int32_t RUNNING;
|
||||||
switch_mutex_t *mutex;
|
switch_mutex_t *mutex;
|
||||||
|
uint32_t timer_milliseconds;
|
||||||
|
uint32_t timer_microseconds;
|
||||||
} globals;
|
} globals;
|
||||||
|
|
||||||
static const char modname[] = "mod_threadtimer";
|
static const char modname[] = "mod_threadtimer";
|
||||||
#define MAX_ELEMENTS 1000
|
#define MAX_ELEMENTS 1000
|
||||||
|
|
||||||
struct timer_private {
|
struct timer_private {
|
||||||
uint32_t tick;
|
uint64_t tick;
|
||||||
uint32_t reference;
|
uint64_t reference;
|
||||||
uint32_t interval;
|
uint32_t interval;
|
||||||
switch_mutex_t *mutex;
|
//switch_mutex_t *mutex;
|
||||||
struct timer_private *next;
|
struct timer_private *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -60,11 +62,30 @@ typedef struct timer_head timer_head_t;
|
||||||
|
|
||||||
static timer_head_t *TIMER_MATRIX[MAX_ELEMENTS+1];
|
static timer_head_t *TIMER_MATRIX[MAX_ELEMENTS+1];
|
||||||
|
|
||||||
|
#define IDLE_SPEED 100
|
||||||
|
|
||||||
|
static inline void set_timer(void)
|
||||||
|
{
|
||||||
|
uint32_t index = 0, min = IDLE_SPEED;
|
||||||
|
|
||||||
|
for(index = 0; index < MAX_ELEMENTS; index++) {
|
||||||
|
if (TIMER_MATRIX[index] && TIMER_MATRIX[index]->private_info) {
|
||||||
|
if (min > index) {
|
||||||
|
min = index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
globals.timer_milliseconds = min;
|
||||||
|
globals.timer_microseconds = min * 1000;
|
||||||
|
}
|
||||||
|
|
||||||
static inline switch_status_t timer_init(switch_timer_t *timer)
|
static inline switch_status_t timer_init(switch_timer_t *timer)
|
||||||
{
|
{
|
||||||
timer_private_t *private_info;
|
timer_private_t *private_info;
|
||||||
timer_head_t *head;
|
timer_head_t *head;
|
||||||
|
|
||||||
|
|
||||||
if ((private_info = switch_core_alloc(timer->memory_pool, sizeof(*private_info)))) {
|
if ((private_info = switch_core_alloc(timer->memory_pool, sizeof(*private_info)))) {
|
||||||
timer->private_info = private_info;
|
timer->private_info = private_info;
|
||||||
if (!TIMER_MATRIX[timer->interval]) {
|
if (!TIMER_MATRIX[timer->interval]) {
|
||||||
|
@ -76,13 +97,14 @@ static inline switch_status_t timer_init(switch_timer_t *timer)
|
||||||
|
|
||||||
head = TIMER_MATRIX[timer->interval];
|
head = TIMER_MATRIX[timer->interval];
|
||||||
|
|
||||||
switch_mutex_init(&private_info->mutex, SWITCH_MUTEX_NESTED, timer->memory_pool);
|
//switch_mutex_init(&private_info->mutex, SWITCH_MUTEX_NESTED, timer->memory_pool);
|
||||||
private_info->interval = timer->interval;
|
private_info->interval = timer->interval;
|
||||||
|
|
||||||
switch_mutex_lock(head->mutex);
|
switch_mutex_lock(head->mutex);
|
||||||
private_info->next = head->private_info;
|
private_info->next = head->private_info;
|
||||||
head->private_info = private_info;
|
head->private_info = private_info;
|
||||||
switch_mutex_unlock(head->mutex);
|
switch_mutex_unlock(head->mutex);
|
||||||
|
set_timer();
|
||||||
|
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -90,21 +112,13 @@ static inline switch_status_t timer_init(switch_timer_t *timer)
|
||||||
return SWITCH_STATUS_MEMERR;
|
return SWITCH_STATUS_MEMERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MAX_TICKS 0xFFFFFF00
|
|
||||||
#define check_overflow(p) if (p->reference > MAX_TICKS) {\
|
|
||||||
switch_mutex_lock(p->mutex);\
|
|
||||||
p->reference = p->tick = 0;\
|
|
||||||
switch_mutex_unlock(p->mutex);\
|
|
||||||
}\
|
|
||||||
|
|
||||||
|
|
||||||
static inline switch_status_t timer_step(switch_timer_t *timer)
|
static inline switch_status_t timer_step(switch_timer_t *timer)
|
||||||
{
|
{
|
||||||
timer_private_t *private_info = timer->private_info;
|
timer_private_t *private_info = timer->private_info;
|
||||||
|
|
||||||
switch_mutex_lock(private_info->mutex);
|
//switch_mutex_lock(private_info->mutex);
|
||||||
private_info->reference += private_info->interval;
|
private_info->reference += private_info->interval;
|
||||||
switch_mutex_unlock(private_info->mutex);
|
//switch_mutex_unlock(private_info->mutex);
|
||||||
|
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -119,7 +133,6 @@ static inline switch_status_t timer_next(switch_timer_t *timer)
|
||||||
while (private_info->tick < private_info->reference) {
|
while (private_info->tick < private_info->reference) {
|
||||||
switch_yield(1000);
|
switch_yield(1000);
|
||||||
}
|
}
|
||||||
check_overflow(private_info);
|
|
||||||
timer->samplecount += timer->samples;
|
timer->samplecount += timer->samples;
|
||||||
|
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
|
@ -131,15 +144,14 @@ static inline switch_status_t timer_check(switch_timer_t *timer)
|
||||||
timer_private_t *private_info = timer->private_info;
|
timer_private_t *private_info = timer->private_info;
|
||||||
switch_status_t status;
|
switch_status_t status;
|
||||||
|
|
||||||
switch_mutex_lock(private_info->mutex);
|
//switch_mutex_lock(private_info->mutex);
|
||||||
if (private_info->tick < private_info->reference) {
|
if (private_info->tick < private_info->reference) {
|
||||||
status = SWITCH_STATUS_FALSE;
|
status = SWITCH_STATUS_FALSE;
|
||||||
} else {
|
} else {
|
||||||
private_info->reference += private_info->interval;
|
private_info->reference += private_info->interval;
|
||||||
check_overflow(private_info);
|
|
||||||
status = SWITCH_STATUS_SUCCESS;
|
status = SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
switch_mutex_unlock(private_info->mutex);
|
//switch_mutex_unlock(private_info->mutex);
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -167,7 +179,7 @@ static inline switch_status_t timer_destroy(switch_timer_t *timer)
|
||||||
last = ptr;
|
last = ptr;
|
||||||
}
|
}
|
||||||
switch_mutex_unlock(head->mutex);
|
switch_mutex_unlock(head->mutex);
|
||||||
|
set_timer();
|
||||||
timer->private_info = NULL;
|
timer->private_info = NULL;
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -205,6 +217,8 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
|
SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
|
||||||
{
|
{
|
||||||
switch_time_t reference = switch_time_now();
|
switch_time_t reference = switch_time_now();
|
||||||
|
@ -214,19 +228,22 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
|
||||||
|
|
||||||
memset(&globals, 0, sizeof(globals));
|
memset(&globals, 0, sizeof(globals));
|
||||||
switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, module_pool);
|
switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, module_pool);
|
||||||
|
globals.timer_microseconds = IDLE_SPEED * 1000;
|
||||||
|
globals.timer_milliseconds = IDLE_SPEED;
|
||||||
|
|
||||||
globals.RUNNING = 1;
|
globals.RUNNING = 1;
|
||||||
|
|
||||||
while(globals.RUNNING == 1) {
|
while(globals.RUNNING == 1) {
|
||||||
reference += 1000;
|
reference += globals.timer_microseconds;
|
||||||
|
//printf("TEST %d\n", globals.timer_microseconds);
|
||||||
while (switch_time_now() < reference) {
|
while (switch_time_now() < reference) {
|
||||||
switch_yield(500);
|
//switch_yield((reference - now) - 1000);
|
||||||
|
switch_yield(globals.timer_microseconds >> 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
current_ms++;
|
current_ms += globals.timer_milliseconds;
|
||||||
|
|
||||||
for (x = 0; x < 1000; x++) {
|
for (x = 0; x < MAX_ELEMENTS; x++) {
|
||||||
int i = x, index;
|
int i = x, index;
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
i = 1;
|
i = 1;
|
||||||
|
@ -237,9 +254,9 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
|
||||||
if (TIMER_MATRIX[index] && TIMER_MATRIX[index]->private_info) {
|
if (TIMER_MATRIX[index] && TIMER_MATRIX[index]->private_info) {
|
||||||
switch_mutex_lock(TIMER_MATRIX[index]->mutex);
|
switch_mutex_lock(TIMER_MATRIX[index]->mutex);
|
||||||
for (ptr = TIMER_MATRIX[index]->private_info; ptr; ptr = ptr->next) {
|
for (ptr = TIMER_MATRIX[index]->private_info; ptr; ptr = ptr->next) {
|
||||||
switch_mutex_lock(ptr->mutex);
|
//switch_mutex_lock(ptr->mutex);
|
||||||
ptr->tick += ptr->interval;
|
ptr->tick += ptr->interval;
|
||||||
switch_mutex_unlock(ptr->mutex);
|
//switch_mutex_unlock(ptr->mutex);
|
||||||
}
|
}
|
||||||
switch_mutex_unlock(TIMER_MATRIX[index]->mutex);
|
switch_mutex_unlock(TIMER_MATRIX[index]->mutex);
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ static void set_high_priority()
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
|
SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
|
||||||
#else
|
#else
|
||||||
//nice(-20);
|
//nice(-19);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3624,6 +3624,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_init_and_modload(char *console, cons
|
||||||
switch_event_fire(&event);
|
switch_event_fire(&event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//#define USE_MLOCKALL
|
||||||
#ifdef HAVE_MLOCKALL
|
#ifdef HAVE_MLOCKALL
|
||||||
#ifdef USE_MLOCKALL
|
#ifdef USE_MLOCKALL
|
||||||
mlockall(MCL_CURRENT|MCL_FUTURE);
|
mlockall(MCL_CURRENT|MCL_FUTURE);
|
||||||
|
|
Loading…
Reference in New Issue