aboutsummaryrefslogtreecommitdiffstats
path: root/bridges
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2009-03-27 19:10:32 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2009-03-27 19:10:32 +0000
commit4a40e0ec6f423de8e8cd744bd5e5c1592f88d2bc (patch)
treece5d46d0d87fc7ee22af3c25180e9916951b3cfc /bridges
parent34087ec576d4a7446ecd9fd0ed97430b57c4004b (diff)
Improve timing interface to remember which provider provided a timer
The ability to load/unload timing interfaces is nice, but it means that when a timer is allocated, it may come from provider A, but later provider B becomes the 'preferred' provider. If this happens, all timer API calls on the timer that was provided by provider A will actually be handed to provider B, which will say WTF and return an error. This patch changes the timer API to include a pointer to the provider of the timer handle so that future operations on the timer will be forwarded to the proper provider. (closes issue #14697) Reported by: moy Review: http://reviewboard.digium.com/r/211/ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@184762 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'bridges')
-rw-r--r--bridges/bridge_softmix.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/bridges/bridge_softmix.c b/bridges/bridge_softmix.c
index 8a8e94d83..a98038660 100644
--- a/bridges/bridge_softmix.c
+++ b/bridges/bridge_softmix.c
@@ -85,13 +85,13 @@ struct softmix_channel {
/*! \brief Function called when a bridge is created */
static int softmix_bridge_create(struct ast_bridge *bridge)
{
- int timingfd;
+ struct ast_timer *timer;
- if ((timingfd = ast_timer_open()) < 0) {
+ if (!(timer = ast_timer_open())) {
return -1;
}
- bridge->bridge_pvt = (void*)(unsigned long)timingfd;
+ bridge->bridge_pvt = timer;
return 0;
}
@@ -99,9 +99,7 @@ static int softmix_bridge_create(struct ast_bridge *bridge)
/*! \brief Function called when a bridge is destroyed */
static int softmix_bridge_destroy(struct ast_bridge *bridge)
{
- int timingfd = (unsigned long)bridge->bridge_pvt;
-
- ast_timer_close(timingfd);
+ ast_timer_close((struct ast_timer *) bridge->bridge_pvt);
return 0;
}
@@ -209,9 +207,10 @@ static int softmix_bridge_poke(struct ast_bridge *bridge, struct ast_bridge_chan
/*! \brief Function which acts as the mixing thread */
static int softmix_bridge_thread(struct ast_bridge *bridge)
{
- int timingfd = (unsigned long)bridge->bridge_pvt;
+ struct ast_timer *timer = (struct ast_timer *) bridge->bridge_pvt;
+ int timingfd = ast_timer_fd(timer);
- ast_timer_set_rate(timingfd, (1000 / SOFTMIX_INTERVAL));
+ ast_timer_set_rate(timer, (1000 / SOFTMIX_INTERVAL));
while (!bridge->stop && !bridge->refresh && bridge->array_num) {
struct ast_bridge_channel *bridge_channel = NULL;
@@ -268,7 +267,7 @@ static int softmix_bridge_thread(struct ast_bridge *bridge)
/* Wait for the timing source to tell us to wake up and get things done */
ast_waitfor_n_fd(&timingfd, 1, &timeout, NULL);
- ast_timer_ack(timingfd, 1);
+ ast_timer_ack(timer, 1);
ao2_lock(bridge);
}