[Freeswitch-svn] [commit] r4151 - in freeswitch/trunk/src: . include mod/timers/mod_softtimer
Freeswitch SVN
anthm at freeswitch.org
Wed Feb 7 14:18:15 EST 2007
Author: anthm
Date: Wed Feb 7 14:18:15 2007
New Revision: 4151
Modified:
freeswitch/trunk/src/include/switch_core.h
freeswitch/trunk/src/include/switch_module_interfaces.h
freeswitch/trunk/src/mod/timers/mod_softtimer/mod_softtimer.c
freeswitch/trunk/src/switch_core.c
freeswitch/trunk/src/switch_rtp.c
Log:
timer mojo (cont)
Modified: freeswitch/trunk/src/include/switch_core.h
==============================================================================
--- freeswitch/trunk/src/include/switch_core.h (original)
+++ freeswitch/trunk/src/include/switch_core.h Wed Feb 7 14:18:15 2007
@@ -905,10 +905,9 @@
/*!
\brief Check if the current step has been exceeded
\param timer the timer to wait on
- \param diff the remaining number of ms
\return the newest sample count
*/
-SWITCH_DECLARE(switch_status_t) switch_core_timer_check(switch_timer_t *timer, uint32_t *diff);
+SWITCH_DECLARE(switch_status_t) switch_core_timer_check(switch_timer_t *timer);
/*!
\brief Destroy an allocated timer
Modified: freeswitch/trunk/src/include/switch_module_interfaces.h
==============================================================================
--- freeswitch/trunk/src/include/switch_module_interfaces.h (original)
+++ freeswitch/trunk/src/include/switch_module_interfaces.h Wed Feb 7 14:18:15 2007
@@ -245,7 +245,7 @@
/*! function to step the timer one step */
switch_status_t (*timer_step)(switch_timer_t *);
/*! function to check if the current step has expired */
- switch_status_t (*timer_check)(switch_timer_t *, uint32_t *);
+ switch_status_t (*timer_check)(switch_timer_t *);
/*! function to deallocate the timer */
switch_status_t (*timer_destroy)(switch_timer_t *);
const struct switch_timer_interface *next;
Modified: freeswitch/trunk/src/mod/timers/mod_softtimer/mod_softtimer.c
==============================================================================
--- freeswitch/trunk/src/mod/timers/mod_softtimer/mod_softtimer.c (original)
+++ freeswitch/trunk/src/mod/timers/mod_softtimer/mod_softtimer.c Wed Feb 7 14:18:15 2007
@@ -78,11 +78,8 @@
{
timer_private_t *private_info = timer->private_info;
- while(private_info->reference <= TIMER_MATRIX[timer->interval].tick) {
- private_info->reference += timer->interval;
- }
-
- return SWITCH_STATUS_SUCCESS;
+ private_info->reference += timer->interval;
+ return SWITCH_STATUS_SUCCESS;
}
@@ -93,41 +90,31 @@
timer_step(timer);
while (TIMER_MATRIX[timer->interval].tick < private_info->reference) {
uint64_t diff;
-
- if ((diff = (private_info->reference - TIMER_MATRIX[timer->interval].tick))) {
- if (diff == timer->interval) {
- switch_yield(diff * 500);
- } else {
- switch_yield(1000);
- }
- } else {
- break;
- }
+ switch_yield(timer->interval * 500);
}
timer->samplecount += timer->samples;
return SWITCH_STATUS_SUCCESS;
}
-static inline switch_status_t timer_check(switch_timer_t *timer, uint32_t *diff)
+static inline switch_status_t timer_check(switch_timer_t *timer)
{
timer_private_t *private_info = timer->private_info;
switch_status_t status = SWITCH_STATUS_SUCCESS;
+ uint64_t diff;
if (TIMER_MATRIX[timer->interval].tick < private_info->reference) {
- uint64_t _diff = private_info->reference - TIMER_MATRIX[timer->interval].tick;
- *diff = (uint32_t) _diff;
+ diff = private_info->reference - TIMER_MATRIX[timer->interval].tick;
} else {
- *diff = 0;
+ diff = 0;
}
- if (*diff) {
+ if (diff) {
status = SWITCH_STATUS_FALSE;
} else {
timer_step(timer);
}
-
return status;
}
Modified: freeswitch/trunk/src/switch_core.c
==============================================================================
--- freeswitch/trunk/src/switch_core.c (original)
+++ freeswitch/trunk/src/switch_core.c Wed Feb 7 14:18:15 2007
@@ -1321,14 +1321,14 @@
return timer->timer_interface->timer_step(timer);
}
-SWITCH_DECLARE(switch_status_t) switch_core_timer_check(switch_timer_t *timer, uint32_t *diff)
+SWITCH_DECLARE(switch_status_t) switch_core_timer_check(switch_timer_t *timer)
{
if (!timer->timer_interface) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Timer is not initilized!\n");
return SWITCH_STATUS_GENERR;
}
- return timer->timer_interface->timer_check(timer, diff);
+ return timer->timer_interface->timer_check(timer);
}
Modified: freeswitch/trunk/src/switch_rtp.c
==============================================================================
--- freeswitch/trunk/src/switch_rtp.c (original)
+++ freeswitch/trunk/src/switch_rtp.c Wed Feb 7 14:18:15 2007
@@ -711,7 +711,6 @@
switch_size_t bytes = 0;
switch_status_t status;
uint8_t check = 1;
- uint32_t diff = 0;
if (!rtp_session->timer.interval) {
rtp_session->last_time = switch_time_now();
@@ -758,7 +757,7 @@
}
if (rtp_session->timer.interval) {
- check = (uint8_t)(switch_core_timer_check(&rtp_session->timer, &diff) == SWITCH_STATUS_SUCCESS);
+ check = (uint8_t)(switch_core_timer_check(&rtp_session->timer) == SWITCH_STATUS_SUCCESS);
}
if (check) {
@@ -781,7 +780,7 @@
if (status == SWITCH_STATUS_BREAK || bytes == 0) {
if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_DATAWAIT)) {
- switch_yield(diff * 500);
+ switch_yield((rtp_session->ms_per_packet / 1000) * 750);
continue;
}
return 0;
More information about the Freeswitch-svn
mailing list