Revert inadvertant code commit to app_originate
[asterisk/asterisk.git] / bridges / bridge_softmix.c
index 4f1e4d7..a980386 100644 (file)
@@ -85,13 +85,21 @@ 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;
        }
 
-       ast_timer_close(timingfd);
+       bridge->bridge_pvt = timer;
+
+       return 0;
+}
+
+/*! \brief Function called when a bridge is destroyed */
+static int softmix_bridge_destroy(struct ast_bridge *bridge)
+{
+       ast_timer_close((struct ast_timer *) bridge->bridge_pvt);
 
        return 0;
 }
@@ -199,13 +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;
+       struct ast_timer *timer = (struct ast_timer *) bridge->bridge_pvt;
+       int timingfd = ast_timer_fd(timer);
 
-       if ((timingfd = ast_timer_open()) < 0) {
-               return -1;
-       }
-
-       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;
@@ -262,14 +267,11 @@ 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);
        }
 
-       ast_timer_set_rate(timingfd, 0);
-       ast_timer_close(timingfd);
-
        return 0;
 }
 
@@ -283,6 +285,7 @@ static struct ast_bridge_technology softmix_bridge = {
        .formats = AST_FORMAT_SLINEAR,
 #endif
        .create = softmix_bridge_create,
+       .destroy = softmix_bridge_destroy,
        .join = softmix_bridge_join,
        .leave = softmix_bridge_leave,
        .write = softmix_bridge_write,