[asterisk-commits] beagles: branch 10 r376208 - in /branches/10: ./ main/channel.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Nov 13 12:20:17 CST 2012
Author: beagles
Date: Tue Nov 13 12:20:13 2012
New Revision: 376208
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=376208
Log:
Patch to prevent stopping the active generator when it is not the silence
generator.
This patch introduces an internal helper function to safely check whether the
current generator is the one that is expected before deactivating it. The
current externally accessible ast_channel_stop_generator() function has been
modified to be implemented in terms of the new function.
(closes issue ASTERISK-19918)
Reported by: Eduardo Abad
........
Merged revisions 376199 from http://svn.asterisk.org/svn/asterisk/branches/1.8
Modified:
branches/10/ (props changed)
branches/10/main/channel.c
Propchange: branches/10/
------------------------------------------------------------------------------
Binary property 'branch-1.8-merged' - no diff available.
Modified: branches/10/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/branches/10/main/channel.c?view=diff&rev=376208&r1=376207&r2=376208
==============================================================================
--- branches/10/main/channel.c (original)
+++ branches/10/main/channel.c Tue Nov 13 12:20:13 2012
@@ -3169,7 +3169,11 @@
res = generate(chan, tmp, 0, ast_format_rate(&chan->writeformat) / 50);
- chan->generatordata = tmp;
+ ast_channel_lock(chan);
+ if (chan->generator && generate == chan->generator->generate) {
+ chan->generatordata = tmp;
+ }
+ ast_channel_unlock(chan);
if (res) {
ast_debug(1, "Auto-deactivating generator\n");
@@ -8442,18 +8446,45 @@
return state;
}
+static int internal_deactivate_generator(struct ast_channel *chan, void* generator)
+{
+ ast_channel_lock(chan);
+
+ if (!chan->generatordata) {
+ ast_debug(1, "Trying to stop silence generator when there is no "
+ "generator on '%s'\n", chan->name);
+ ast_channel_unlock(chan);
+ return 0;
+ }
+ if (chan->generator != generator) {
+ ast_debug(1, "Trying to stop silence generator when it is not the current "
+ "generator on '%s'\n", chan->name);
+ ast_channel_unlock(chan);
+ return 0;
+ }
+ if (chan->generator && chan->generator->release) {
+ chan->generator->release(chan, chan->generatordata);
+ }
+ chan->generatordata = NULL;
+ chan->generator = NULL;
+ ast_channel_set_fd(chan, AST_GENERATOR_FD, -1);
+ ast_clear_flag(chan, AST_FLAG_WRITE_INT);
+ ast_settimeout(chan, 0, NULL, NULL);
+ ast_channel_unlock(chan);
+
+ return 1;
+}
+
void ast_channel_stop_silence_generator(struct ast_channel *chan, struct ast_silence_generator *state)
{
if (!state)
return;
- ast_deactivate_generator(chan);
-
- ast_debug(1, "Stopped silence generator on '%s'\n", chan->name);
-
- if (ast_set_write_format(chan, &state->old_write_format) < 0)
- ast_log(LOG_ERROR, "Could not return write format to its original state\n");
-
+ if (internal_deactivate_generator(chan, &silence_generator)) {
+ ast_debug(1, "Stopped silence generator on '%s'\n", chan->name);
+ if (ast_set_write_format(chan, &state->old_write_format) < 0)
+ ast_log(LOG_ERROR, "Could not return write format to its original state\n");
+ }
ast_free(state);
}
More information about the asterisk-commits
mailing list