If ast_channel struct is not declared before ast_register_application2,
[lcr.git] / chan_lcr.c
index ef48739..a81e48d 100644 (file)
@@ -136,6 +136,13 @@ it is called from ast_channel process which has already locked ast_channel.
 #ifdef LCR_FOR_ASTERISK
 #include <asterisk/buildopts.h>
 #endif
+
+/*
+ * Fwd declare struct ast_channel to get rid of gcc warning about
+ * incompatible pointer type passed to ast_register_application2.
+ */
+struct ast_channel;
+
 #include <asterisk/module.h>
 #include <asterisk/channel.h>
 #include <asterisk/config.h>
@@ -161,8 +168,9 @@ it is called from ast_channel process which has already locked ast_channel.
 #include <asterisk/app.h>
 #include <asterisk/features.h>
 #include <asterisk/sched.h>
+#if ASTERISK_VERSION_NUM < 110000
 #include <asterisk/version.h>
-
+#endif
 #include "extension.h"
 #include "message.h"
 #include "callerid.h"
@@ -959,11 +967,12 @@ static void lcr_in_setup(struct chan_call *call, int message_type, union paramet
 #if ASTERISK_VERSION_NUM < 110000
        ast->tech_pvt = call;
        ast->tech = &lcr_tech;
+       ast->fds[0] = call->pipe[0];
 #else
        ast_channel_tech_pvt_set(ast, call);
        ast_channel_tech_set(ast, &lcr_tech);
+       ast_channel_set_fd(ast, 0, call->pipe[0]);
 #endif
-       ast->fds[0] = call->pipe[0];
 
        /* fill setup information */
        if (param->setup.dialinginfo.id)
@@ -2179,10 +2188,11 @@ struct ast_channel *lcr_request(const char *type, int format, void *data, int *c
        call->ast = ast;
 #if ASTERISK_VERSION_NUM < 110000
        ast->tech_pvt = call;
+       ast->fds[0] = call->pipe[0];
 #else
        ast_channel_tech_pvt_set(ast, call);
+       ast_channel_set_fd(ast, 0, call->pipe[0]);
 #endif
-       ast->fds[0] = call->pipe[0];
        call->pbx_started = 0;
        /* set state */
        call->state = CHAN_LCR_STATE_OUT_PREPARE;
@@ -2731,10 +2741,11 @@ static int lcr_hangup(struct ast_channel *ast)
        /* disconnect asterisk, maybe not required */
 #if ASTERISK_VERSION_NUM < 110000
        ast->tech_pvt = NULL;
+       ast->fds[0] = -1;
 #else
        ast_channel_tech_pvt_set(ast, NULL);
+       ast_channel_set_fd(ast, 0, -1);
 #endif
-       ast->fds[0] = -1;
        if (call->ref) {
                /* release */
                CDEBUG(call, ast, "Releasing ref and freeing call instance.\n");
@@ -2944,7 +2955,7 @@ static int lcr_indicate(struct ast_channel *ast, int cond, const void *data, siz
        union parameter newparam;
        int res = 0;
        struct chan_call *call;
-       const struct tone_zone_sound *ts = NULL;
+       const struct ast_tone_zone_sound *ts = NULL;
 
        ast_mutex_lock(&chan_lock);
 #if ASTERISK_VERSION_NUM < 110000