undo abundant evil -props to the man who won't stfu and leave me alone to code <- his request i say that....
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@2774 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
33ba8c434c
commit
6c5672b1ef
|
@ -1713,6 +1713,8 @@ static void *SWITCH_THREAD_FUNC profile_thread_run(switch_thread_t *thread, void
|
|||
NUTAG_EARLY_MEDIA(1),
|
||||
NUTAG_AUTOANSWER(0),
|
||||
NUTAG_AUTOALERT(0),
|
||||
//NUTAG_ALLOW("REGISTER"),
|
||||
//SIPTAG_ALLOW_STR("REGISTER"),
|
||||
SIPTAG_SUPPORTED_STR("100rel, precondition"),
|
||||
TAG_END());
|
||||
|
||||
|
|
|
@ -37,8 +37,6 @@ static switch_memory_pool_t *module_pool = NULL;
|
|||
static struct {
|
||||
int32_t RUNNING;
|
||||
switch_mutex_t *mutex;
|
||||
uint32_t timer_milliseconds;
|
||||
switch_interval_time_t timer_microseconds;
|
||||
} globals;
|
||||
|
||||
static const char modname[] = "mod_softtimer";
|
||||
|
@ -60,22 +58,6 @@ static timer_matrix_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].count) {
|
||||
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)
|
||||
{
|
||||
timer_private_t *private_info;
|
||||
|
@ -86,8 +68,6 @@ static inline switch_status_t timer_init(switch_timer_t *timer)
|
|||
switch_mutex_unlock(globals.mutex);
|
||||
timer->private_info = private_info;
|
||||
private_info->reference = TIMER_MATRIX[timer->interval].tick;
|
||||
set_timer();
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -113,7 +93,6 @@ static inline switch_status_t timer_next(switch_timer_t *timer)
|
|||
switch_yield(1000);
|
||||
}
|
||||
timer->samplecount += timer->samples;
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -139,7 +118,6 @@ static inline switch_status_t timer_destroy(switch_timer_t *timer)
|
|||
switch_mutex_lock(globals.mutex);
|
||||
TIMER_MATRIX[timer->interval].count--;
|
||||
switch_mutex_unlock(globals.mutex);
|
||||
set_timer();
|
||||
timer->private_info = NULL;
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
@ -187,21 +165,17 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
|
|||
|
||||
memset(&globals, 0, sizeof(globals));
|
||||
switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, module_pool);
|
||||
globals.timer_microseconds = IDLE_SPEED * 1000;
|
||||
globals.timer_milliseconds = IDLE_SPEED;
|
||||
|
||||
globals.RUNNING = 1;
|
||||
|
||||
while(globals.RUNNING == 1) {
|
||||
reference += globals.timer_microseconds;
|
||||
reference += 1000;
|
||||
|
||||
while (switch_time_now() < reference) {
|
||||
//switch_yield((reference - now) - 1000);
|
||||
//switch_yield(globals.timer_microseconds >> 1);
|
||||
switch_yield(1000);
|
||||
}
|
||||
|
||||
current_ms += globals.timer_milliseconds;
|
||||
current_ms++;
|
||||
|
||||
for (x = 0; x < MAX_ELEMENTS; x++) {
|
||||
int i = x, index;
|
||||
|
|
|
@ -40,7 +40,7 @@ typedef enum {
|
|||
|
||||
struct switch_buffer {
|
||||
switch_byte_t *data;
|
||||
switch_byte_t *front;
|
||||
switch_byte_t *head;
|
||||
switch_size_t used;
|
||||
switch_size_t datalen;
|
||||
switch_size_t max_len;
|
||||
|
@ -57,7 +57,7 @@ SWITCH_DECLARE(switch_status_t) switch_buffer_create(switch_memory_pool_t *pool,
|
|||
&& (new_buffer->data = switch_core_alloc(pool, max_len)) != 0) {
|
||||
new_buffer->datalen = max_len;
|
||||
new_buffer->id = buffer_id++;
|
||||
new_buffer->front = new_buffer->data;
|
||||
new_buffer->head = new_buffer->data;
|
||||
*buffer = new_buffer;
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ SWITCH_DECLARE(switch_status_t) switch_buffer_create_dynamic(switch_buffer_t **b
|
|||
new_buffer->datalen = start_len;
|
||||
new_buffer->id = buffer_id++;
|
||||
new_buffer->blocksize = blocksize;
|
||||
new_buffer->front = new_buffer->data;
|
||||
new_buffer->head = new_buffer->data;
|
||||
switch_set_flag(new_buffer, SWITCH_BUFFER_FLAG_DYNAMIC);
|
||||
|
||||
*buffer = new_buffer;
|
||||
|
@ -143,10 +143,11 @@ SWITCH_DECLARE(switch_size_t) switch_buffer_toss(switch_buffer_t *buffer, switch
|
|||
reading = buffer->used;
|
||||
}
|
||||
|
||||
memmove(buffer->data, buffer->data + reading, buffer->datalen - reading);
|
||||
buffer->used -= datalen;
|
||||
memmove(buffer->data, buffer->data + reading, reading);
|
||||
buffer->head = buffer->data;
|
||||
buffer->used -= reading;
|
||||
|
||||
return buffer->datalen;
|
||||
return buffer->used;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_size_t) switch_buffer_read(switch_buffer_t *buffer, void *data, switch_size_t datalen)
|
||||
|
@ -166,12 +167,11 @@ SWITCH_DECLARE(switch_size_t) switch_buffer_read(switch_buffer_t *buffer, void *
|
|||
reading = buffer->used;
|
||||
}
|
||||
|
||||
memcpy(data, buffer->front, reading);
|
||||
|
||||
buffer->front += reading;
|
||||
memcpy(data, buffer->head, reading);
|
||||
buffer->used -= reading;
|
||||
buffer->head += reading;
|
||||
|
||||
//if (buffer->id == 3) printf("%u o %d = %d\n", buffer->id, (uint32_t)reading, (uint32_t)buffer->used);
|
||||
//if (buffer->id == 4) printf("%u o %d = %d\n", buffer->id, (uint32_t)reading, (uint32_t)buffer->used);
|
||||
return reading;
|
||||
}
|
||||
|
||||
|
@ -182,28 +182,33 @@ SWITCH_DECLARE(switch_size_t) switch_buffer_write(switch_buffer_t *buffer, void
|
|||
assert(buffer != NULL);
|
||||
assert(data != NULL);
|
||||
assert(buffer->data != NULL);
|
||||
|
||||
if (!datalen) {
|
||||
return buffer->used;
|
||||
}
|
||||
|
||||
freespace = buffer->datalen - buffer->used;
|
||||
|
||||
if (buffer->used && buffer->data != buffer->front) {
|
||||
memmove(buffer->data, buffer->front, buffer->used);
|
||||
buffer->front = buffer->data;
|
||||
if (buffer->data != buffer->head) {
|
||||
memmove(buffer->data, buffer->head, buffer->used);
|
||||
buffer->head = buffer->data;
|
||||
}
|
||||
|
||||
if (switch_test_flag(buffer, SWITCH_BUFFER_FLAG_DYNAMIC)) {
|
||||
if (freespace < datalen) {
|
||||
switch_size_t new_size, new_block_size;
|
||||
|
||||
new_size = buffer->datalen + datalen;
|
||||
new_block_size = buffer->datalen + buffer->blocksize;
|
||||
|
||||
if (new_block_size > new_size) {
|
||||
new_size = new_block_size;
|
||||
}
|
||||
|
||||
buffer->head = buffer->data;
|
||||
if (!(buffer->data = realloc(buffer->data, new_size))) {
|
||||
return 0;
|
||||
}
|
||||
buffer->front = buffer->data;
|
||||
buffer->head = buffer->data;
|
||||
buffer->datalen = new_size;
|
||||
}
|
||||
}
|
||||
|
@ -216,7 +221,7 @@ SWITCH_DECLARE(switch_size_t) switch_buffer_write(switch_buffer_t *buffer, void
|
|||
memcpy(buffer->data + buffer->used, data, datalen);
|
||||
buffer->used += datalen;
|
||||
}
|
||||
//if (buffer->id == 3) printf("%u i %d = %d\n", buffer->id, (uint32_t)datalen, (uint32_t)buffer->used);
|
||||
//if (buffer->id == 4) printf("%u i %d = %d\n", buffer->id, (uint32_t)datalen, (uint32_t)buffer->used);
|
||||
|
||||
return buffer->used;
|
||||
}
|
||||
|
@ -227,7 +232,7 @@ SWITCH_DECLARE(void) switch_buffer_zero(switch_buffer_t *buffer)
|
|||
assert(buffer->data != NULL);
|
||||
|
||||
buffer->used = 0;
|
||||
|
||||
buffer->head = buffer->data;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(void) switch_buffer_destroy(switch_buffer_t **buffer)
|
||||
|
|
|
@ -389,7 +389,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_create(switch_rtp_t **new_rtp_session
|
|||
|
||||
switch_mutex_init(&rtp_session->flag_mutex, SWITCH_MUTEX_NESTED, rtp_session->pool);
|
||||
switch_mutex_init(&rtp_session->dtmf_data.dtmf_mutex, SWITCH_MUTEX_NESTED, rtp_session->pool);
|
||||
switch_buffer_create(rtp_session->pool, &rtp_session->dtmf_data.dtmf_buffer, 128);
|
||||
switch_buffer_create_dynamic(&rtp_session->dtmf_data.dtmf_buffer, 128, 128, 0);
|
||||
/* for from address on recvfrom calls */
|
||||
switch_sockaddr_info_get(&rtp_session->from_addr, NULL, SWITCH_UNSPEC, 0, 0, rtp_session->pool);
|
||||
|
||||
|
|
Loading…
Reference in New Issue