aboutsummaryrefslogtreecommitdiffstats
path: root/funcs/func_channel.c
diff options
context:
space:
mode:
Diffstat (limited to 'funcs/func_channel.c')
-rw-r--r--funcs/func_channel.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/funcs/func_channel.c b/funcs/func_channel.c
index 959f332d2..ff8eeb2e5 100644
--- a/funcs/func_channel.c
+++ b/funcs/func_channel.c
@@ -296,12 +296,19 @@ static int func_channel_write(struct ast_channel *chan, const char *function,
}
#endif
else if (!strcasecmp(data, "tonezone")) {
- struct tone_zone *new_zone;
+ struct ast_tone_zone *new_zone;
if (!(new_zone = ast_get_indication_zone(value))) {
ast_log(LOG_ERROR, "Unknown country code '%s' for tonezone. Check indications.conf for available country codes.\n", value);
ret = -1;
- } else
- chan->zone = new_zone;
+ } else {
+ ast_channel_lock(chan);
+ if (chan->zone) {
+ chan->zone = ast_tone_zone_unref(chan->zone);
+ }
+ chan->zone = ast_tone_zone_ref(new_zone);
+ ast_channel_unlock(chan);
+ new_zone = ast_tone_zone_unref(new_zone);
+ }
} else if (!strcasecmp(data, "callgroup"))
chan->callgroup = ast_get_group(value);
else if (!strcasecmp(data, "txgain")) {