diff options
author | Richard Mudgett <rmudgett@digium.com> | 2014-04-04 19:19:55 +0000 |
---|---|---|
committer | Richard Mudgett <rmudgett@digium.com> | 2014-04-04 19:19:55 +0000 |
commit | 03beadb6e9d88d4c99d097a45e87267a6b2f36b4 (patch) | |
tree | 15296cb9e2f13ea6397dd6e163a2397e5f9f7965 | |
parent | 9be438299d47e71a36d252ea55d5432ac751504f (diff) |
internal_timing: Remove the option and always make it enabled if a timing module is loaded.
The masquerade supertest frequently fails because either the local channel
chain doesn't completely optimize out or the DTMF handshake doesn't
completely get accross. Local channel optimization requires frames
flowing to trigger when optimization can happen. When optimization
happens the media frame that triggered the optimization is dropped.
Sending DTMF requires frames to flow in the other direction for timing
purposes while sending nothing. If internal timing is not enabled when
MOH is playing, Asterisk switches to received timing when an audio frame
is received. With optimization dropping media frames and MOH not sending
frames unless it receives frames, occasionaly there are no more frames
being passed and the test fails.
* The asterisk command line -I option and the asterisk.conf
internal_timing option are removed. Asterisk now always uses internal
timing when needed if any timing module is loaded. The issue
ASTERISK-14861 did this quite awhile ago in v1.4 but effectively is broken
if other internal timing modules besides DAHDI are used. The
ast_read_generator_actions() now only does received timing if it has no
choice for frame generators like MOH, silence, and playback streaming.
* Cleaned up some code dealing with frame generators in
ast_deactivate_generator(), generator_write_format_change(),
ast_activate_generator(), and ast_channel_stop_silence_generator().
* Removed ast_internal_timing_enabled(), AST_OPT_FLAG_INTERNAL_TIMING, and
ast_opt_internal_timing.
ASTERISK-22846 #close
Reported by: Matt Jordan
Review: https://reviewboard.asterisk.org/r/3414/
........
Merged revisions 411715 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........
Merged revisions 411716 from http://svn.asterisk.org/svn/asterisk/branches/11
........
Merged revisions 411717 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@411724 65c4cc65-6c06-0410-ace0-fbb531ad65f3
-rw-r--r-- | UPGRADE.txt | 19 | ||||
-rw-r--r-- | channels/chan_sip.c | 2 | ||||
-rw-r--r-- | configs/asterisk.conf.sample | 1 | ||||
-rw-r--r-- | include/asterisk/channel.h | 11 | ||||
-rw-r--r-- | include/asterisk/options.h | 7 | ||||
-rw-r--r-- | main/asterisk.c | 8 | ||||
-rw-r--r-- | main/channel.c | 138 | ||||
-rw-r--r-- | utils/extconf.c | 3 |
8 files changed, 86 insertions, 103 deletions
diff --git a/UPGRADE.txt b/UPGRADE.txt index 41f21f2ec..85a764379 100644 --- a/UPGRADE.txt +++ b/UPGRADE.txt @@ -23,14 +23,17 @@ From 12 to 13: -- The per console verbose level feature as previously implemented caused a - large performance penalty. The fix required some minor incompatibilities - if the new rasterisk is used to connect to an earlier version. If the new - rasterisk connects to an older Asterisk version then the root console verbose - level is always affected by the "core set verbose" command of the remote - console even though it may appear to only affect the current console. If - an older version of rasterisk connects to the new version then the - "core set verbose" command will have no effect. + - The asterisk command line -I option and the asterisk.conf internal_timing + option are removed and always enabled if any timing module is loaded. + + - The per console verbose level feature as previously implemented caused a + large performance penalty. The fix required some minor incompatibilities + if the new rasterisk is used to connect to an earlier version. If the new + rasterisk connects to an older Asterisk version then the root console verbose + level is always affected by the "core set verbose" command of the remote + console even though it may appear to only affect the current console. If + an older version of rasterisk connects to the new version then the + "core set verbose" command will have no effect. ARI: - The ARI version has been changed from 1.0.0 to 1.1.0. This is to reflect diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 3d52ce4b8..4db0fe59f 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -13444,7 +13444,7 @@ static enum sip_result add_sdp(struct sip_request *resp, struct sip_pvt *p, int ast_debug(3, "-- Done with adding codecs to SDP\n"); - if (!p->owner || !ast_internal_timing_enabled(p->owner)) { + if (!p->owner || ast_channel_timingfd(p->owner) == -1) { ast_str_append(&a_audio, 0, "a=silenceSupp:off - - - -\r\n"); } diff --git a/configs/asterisk.conf.sample b/configs/asterisk.conf.sample index 985c80c28..e10385fbd 100644 --- a/configs/asterisk.conf.sample +++ b/configs/asterisk.conf.sample @@ -28,7 +28,6 @@ astsbindir => /usr/sbin ;dontwarn = yes ; Disable some warnings. ;dumpcore = yes ; Dump core on crash (same as -g at startup). ;languageprefix = yes ; Use the new sound prefix path syntax. -;internal_timing = yes ;systemname = my_system_name ; Prefix uniqueid with a system name for ; Global uniqueness issues. ;autosystemname = yes ; Automatically set systemname to hostname, diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h index 497ef0bd3..8cef68e87 100644 --- a/include/asterisk/channel.h +++ b/include/asterisk/channel.h @@ -2387,17 +2387,6 @@ struct ast_silence_generator *ast_channel_start_silence_generator(struct ast_cha void ast_channel_stop_silence_generator(struct ast_channel *chan, struct ast_silence_generator *state); /*! - * \brief Check if the channel can run in internal timing mode. - * \param chan The channel to check - * \return boolean - * - * \details - * This function will return 1 if internal timing is enabled and the timing - * device is available. - */ -int ast_internal_timing_enabled(struct ast_channel *chan); - -/*! * \brief Determine which channel has an older linkedid * \param a First channel * \param b Second channel diff --git a/include/asterisk/options.h b/include/asterisk/options.h index 2761415b8..1b35b3666 100644 --- a/include/asterisk/options.h +++ b/include/asterisk/options.h @@ -76,8 +76,6 @@ enum ast_option_flags { AST_OPT_FLAG_DONT_WARN = (1 << 18), /*! End CDRs before the 'h' extension */ AST_OPT_FLAG_END_CDR_BEFORE_H_EXTEN = (1 << 19), - /*! Use DAHDI Timing for generators if available */ - AST_OPT_FLAG_INTERNAL_TIMING = (1 << 20), /*! Always fork, even if verbose or debug settings are non-zero */ AST_OPT_FLAG_ALWAYS_FORK = (1 << 21), /*! Disable log/verbose output to remote consoles */ @@ -101,11 +99,7 @@ enum ast_option_flags { }; /*! These are the options that set by default when Asterisk starts */ -#if (defined(HAVE_DAHDI_VERSION) && HAVE_DAHDI_VERSION >= 230) -#define AST_DEFAULT_OPTIONS AST_OPT_FLAG_TRANSCODE_VIA_SLIN | AST_OPT_FLAG_INTERNAL_TIMING -#else #define AST_DEFAULT_OPTIONS AST_OPT_FLAG_TRANSCODE_VIA_SLIN -#endif #define ast_opt_exec_includes ast_test_flag(&ast_options, AST_OPT_FLAG_EXEC_INCLUDES) #define ast_opt_no_fork ast_test_flag(&ast_options, AST_OPT_FLAG_NO_FORK) @@ -128,7 +122,6 @@ enum ast_option_flags { #define ast_opt_transmit_silence ast_test_flag(&ast_options, AST_OPT_FLAG_TRANSMIT_SILENCE) #define ast_opt_dont_warn ast_test_flag(&ast_options, AST_OPT_FLAG_DONT_WARN) #define ast_opt_end_cdr_before_h_exten ast_test_flag(&ast_options, AST_OPT_FLAG_END_CDR_BEFORE_H_EXTEN) -#define ast_opt_internal_timing ast_test_flag(&ast_options, AST_OPT_FLAG_INTERNAL_TIMING) #define ast_opt_always_fork ast_test_flag(&ast_options, AST_OPT_FLAG_ALWAYS_FORK) #define ast_opt_mute ast_test_flag(&ast_options, AST_OPT_FLAG_MUTE) #define ast_opt_dbg_module ast_test_flag(&ast_options, AST_OPT_FLAG_DEBUG_MODULE) diff --git a/main/asterisk.c b/main/asterisk.c index ffa9b6338..83a451852 100644 --- a/main/asterisk.c +++ b/main/asterisk.c @@ -637,7 +637,6 @@ static char *handle_show_settings(struct ast_cli_entry *e, int cmd, struct ast_c ast_cli(a->fd, " User name and group: %s/%s\n", ast_config_AST_RUN_USER, ast_config_AST_RUN_GROUP); ast_cli(a->fd, " Executable includes: %s\n", ast_test_flag(&ast_options, AST_OPT_FLAG_EXEC_INCLUDES) ? "Enabled" : "Disabled"); ast_cli(a->fd, " Transcode via SLIN: %s\n", ast_test_flag(&ast_options, AST_OPT_FLAG_TRANSCODE_VIA_SLIN) ? "Enabled" : "Disabled"); - ast_cli(a->fd, " Internal timing: %s\n", ast_test_flag(&ast_options, AST_OPT_FLAG_INTERNAL_TIMING) ? "Enabled" : "Disabled"); ast_cli(a->fd, " Transmit silence during rec: %s\n", ast_test_flag(&ast_options, AST_OPT_FLAG_TRANSMIT_SILENCE) ? "Enabled" : "Disabled"); ast_cli(a->fd, " Generic PLC: %s\n", ast_test_flag(&ast_options, AST_OPT_FLAG_GENERIC_PLC) ? "Enabled" : "Disabled"); ast_cli(a->fd, " Min DTMF duration:: %u\n", option_dtmfminduration); @@ -3363,7 +3362,6 @@ static int show_cli_help(void) printf(" -g Dump core in case of a crash\n"); printf(" -h This help screen\n"); printf(" -i Initialize crypto keys at startup\n"); - printf(" -I Enable internal timing if DAHDI timer is available\n"); printf(" -L <load> Limit the maximum load average before rejecting new calls\n"); printf(" -M <value> Limit the maximum number of calls to the specified value\n"); printf(" -m Mute debugging and console output on the console\n"); @@ -3539,9 +3537,6 @@ static void ast_readconfig(void) /* Transmit SLINEAR silence while a channel is being recorded or DTMF is being generated on a channel */ } else if (!strcasecmp(v->name, "transmit_silence_during_record") || !strcasecmp(v->name, "transmit_silence")) { ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_TRANSMIT_SILENCE); - /* Enable internal timing */ - } else if (!strcasecmp(v->name, "internal_timing")) { - ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_INTERNAL_TIMING); } else if (!strcasecmp(v->name, "mindtmfduration")) { if (sscanf(v->value, "%30u", &option_dtmfminduration) != 1) { option_dtmfminduration = AST_MIN_DTMF_DURATION; @@ -3869,9 +3864,6 @@ int main(int argc, char *argv[]) case 'h': show_cli_help(); exit(0); - case 'I': - ast_set_flag(&ast_options, AST_OPT_FLAG_INTERNAL_TIMING); - break; case 'i': ast_set_flag(&ast_options, AST_OPT_FLAG_INIT_KEYS); break; diff --git a/main/channel.c b/main/channel.c index 23ea4b7c0..94b0e8b1c 100644 --- a/main/channel.c +++ b/main/channel.c @@ -2943,12 +2943,13 @@ int ast_channel_get_up_time(struct ast_channel *chan) return (ast_tvdiff_ms(ast_tvnow(), ast_channel_answertime(chan)) / 1000); } -void ast_deactivate_generator(struct ast_channel *chan) +static void deactivate_generator_nolock(struct ast_channel *chan) { - ast_channel_lock(chan); if (ast_channel_generatordata(chan)) { - if (ast_channel_generator(chan) && ast_channel_generator(chan)->release) { - ast_channel_generator(chan)->release(chan, ast_channel_generatordata(chan)); + struct ast_generator *generator = ast_channel_generator(chan); + + if (generator && generator->release) { + generator->release(chan, ast_channel_generatordata(chan)); } ast_channel_generatordata_set(chan, NULL); ast_channel_generator_set(chan, NULL); @@ -2956,14 +2957,23 @@ void ast_deactivate_generator(struct ast_channel *chan) ast_clear_flag(ast_channel_flags(chan), AST_FLAG_WRITE_INT); ast_settimeout(chan, 0, NULL, NULL); } +} + +void ast_deactivate_generator(struct ast_channel *chan) +{ + ast_channel_lock(chan); + deactivate_generator_nolock(chan); ast_channel_unlock(chan); } static void generator_write_format_change(struct ast_channel *chan) { + struct ast_generator *generator; + ast_channel_lock(chan); - if (ast_channel_generator(chan) && ast_channel_generator(chan)->write_format_change) { - ast_channel_generator(chan)->write_format_change(chan, ast_channel_generatordata(chan)); + generator = ast_channel_generator(chan); + if (generator && generator->write_format_change) { + generator->write_format_change(chan, ast_channel_generatordata(chan)); } ast_channel_unlock(chan); } @@ -3009,8 +3019,10 @@ int ast_activate_generator(struct ast_channel *chan, struct ast_generator *gen, ast_channel_lock(chan); if (ast_channel_generatordata(chan)) { - if (ast_channel_generator(chan) && ast_channel_generator(chan)->release) { - ast_channel_generator(chan)->release(chan, ast_channel_generatordata(chan)); + struct ast_generator *generator_old = ast_channel_generator(chan); + + if (generator_old && generator_old->release) { + generator_old->release(chan, ast_channel_generatordata(chan)); } } if (gen->alloc && !(generatordata = gen->alloc(chan, params))) { @@ -3642,49 +3654,57 @@ static void send_dtmf_end_event(struct ast_channel *chan, static void ast_read_generator_actions(struct ast_channel *chan, struct ast_frame *f) { - if (ast_channel_generator(chan) && ast_channel_generator(chan)->generate && ast_channel_generatordata(chan) && !ast_internal_timing_enabled(chan)) { - void *tmp = ast_channel_generatordata(chan); - int (*generate)(struct ast_channel *chan, void *tmp, int datalen, int samples) = ast_channel_generator(chan)->generate; - int res; - int samples; + struct ast_generator *generator; + void *gendata; + int res; + int samples; + + generator = ast_channel_generator(chan); + if (!generator + || !generator->generate + || f->frametype != AST_FRAME_VOICE + || !ast_channel_generatordata(chan) + || ast_channel_timingfunc(chan)) { + return; + } - if (ast_channel_timingfunc(chan)) { - ast_debug(1, "Generator got voice, switching to phase locked mode\n"); - ast_settimeout(chan, 0, NULL, NULL); - } + /* + * We must generate frames in phase locked mode since + * we have no internal timer available. + */ - ast_channel_generatordata_set(chan, NULL); /* reset, to let writes go through */ + if (ast_format_cmp(&f->subclass.format, ast_channel_writeformat(chan)) == AST_FORMAT_CMP_NOT_EQUAL) { + float factor; - if (ast_format_cmp(&f->subclass.format, ast_channel_writeformat(chan)) == AST_FORMAT_CMP_NOT_EQUAL) { - float factor; - factor = ((float) ast_format_rate(ast_channel_writeformat(chan))) / ((float) ast_format_rate(&f->subclass.format)); - samples = (int) ( ((float) f->samples) * factor ); - } else { - samples = f->samples; - } + factor = ((float) ast_format_rate(ast_channel_writeformat(chan))) / ((float) ast_format_rate(&f->subclass.format)); + samples = (int) (((float) f->samples) * factor); + } else { + samples = f->samples; + } - /* This unlock is here based on two assumptions that hold true at this point in the - * code. 1) this function is only called from within __ast_read() and 2) all generators - * call ast_write() in their generate callback. - * - * The reason this is added is so that when ast_write is called, the lock that occurs - * there will not recursively lock the channel. Doing this will cause intended deadlock - * avoidance not to work in deeper functions - */ - ast_channel_unlock(chan); - res = generate(chan, tmp, f->datalen, samples); - ast_channel_lock(chan); - ast_channel_generatordata_set(chan, tmp); + gendata = ast_channel_generatordata(chan); + ast_channel_generatordata_set(chan, NULL); /* reset, to let writes go through */ + + /* + * This unlock is here based on two assumptions that hold true at + * this point in the code. 1) this function is only called from + * within __ast_read() and 2) all generators call ast_write() in + * their generate callback. + * + * The reason this is added is so that when ast_write is called, + * the lock that occurs there will not recursively lock the + * channel. Doing this will allow deadlock avoidance to work in + * deeper functions. + */ + ast_channel_unlock(chan); + res = generator->generate(chan, gendata, f->datalen, samples); + ast_channel_lock(chan); + if (generator == ast_channel_generator(chan)) { + ast_channel_generatordata_set(chan, gendata); if (res) { ast_debug(1, "Auto-deactivating generator\n"); ast_deactivate_generator(chan); } - - } else if (f->frametype == AST_FRAME_CNG) { - if (ast_channel_generator(chan) && !ast_channel_timingfunc(chan) && (ast_channel_timingfd(chan) > -1)) { - ast_debug(1, "Generator got CNG, switching to timed mode\n"); - ast_settimeout(chan, 50, generator_force, chan); - } } } @@ -4265,11 +4285,6 @@ done: return f; } -int ast_internal_timing_enabled(struct ast_channel *chan) -{ - return (ast_opt_internal_timing && ast_channel_timingfd(chan) > -1); -} - struct ast_frame *ast_read(struct ast_channel *chan) { return __ast_read(chan, 0); @@ -7693,30 +7708,24 @@ struct ast_silence_generator *ast_channel_start_silence_generator(struct ast_cha return state; } -static int internal_deactivate_generator(struct ast_channel *chan, void* generator) +static int deactivate_silence_generator(struct ast_channel *chan) { ast_channel_lock(chan); if (!ast_channel_generatordata(chan)) { - ast_debug(1, "Trying to stop silence generator when there is no " - "generator on '%s'\n", ast_channel_name(chan)); + ast_debug(1, "Trying to stop silence generator when there is no generator on '%s'\n", + ast_channel_name(chan)); ast_channel_unlock(chan); return 0; } - if (ast_channel_generator(chan) != generator) { - ast_debug(1, "Trying to stop silence generator when it is not the current " - "generator on '%s'\n", ast_channel_name(chan)); + if (ast_channel_generator(chan) != &silence_generator) { + ast_debug(1, "Trying to stop silence generator when it is not the current generator on '%s'\n", + ast_channel_name(chan)); ast_channel_unlock(chan); return 0; } - if (ast_channel_generator(chan) && ast_channel_generator(chan)->release) { - ast_channel_generator(chan)->release(chan, ast_channel_generatordata(chan)); - } - ast_channel_generatordata_set(chan, NULL); - ast_channel_generator_set(chan, NULL); - ast_channel_set_fd(chan, AST_GENERATOR_FD, -1); - ast_clear_flag(ast_channel_flags(chan), AST_FLAG_WRITE_INT); - ast_settimeout(chan, 0, NULL, NULL); + deactivate_generator_nolock(chan); + ast_channel_unlock(chan); return 1; @@ -7724,10 +7733,11 @@ static int internal_deactivate_generator(struct ast_channel *chan, void* generat void ast_channel_stop_silence_generator(struct ast_channel *chan, struct ast_silence_generator *state) { - if (!state) + if (!state) { return; + } - if (internal_deactivate_generator(chan, &silence_generator)) { + if (deactivate_silence_generator(chan)) { ast_debug(1, "Stopped silence generator on '%s'\n", ast_channel_name(chan)); 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"); diff --git a/utils/extconf.c b/utils/extconf.c index 1d9884041..051ce7978 100644 --- a/utils/extconf.c +++ b/utils/extconf.c @@ -1841,8 +1841,6 @@ enum ast_option_flags { AST_OPT_FLAG_DONT_WARN = (1 << 18), /*! End CDRs before the 'h' extension */ AST_OPT_FLAG_END_CDR_BEFORE_H_EXTEN = (1 << 19), - /*! Use DAHDI Timing for generators if available */ - AST_OPT_FLAG_INTERNAL_TIMING = (1 << 20), /*! Always fork, even if verbose or debug settings are non-zero */ AST_OPT_FLAG_ALWAYS_FORK = (1 << 21), /*! Disable log/verbose output to remote consoles */ @@ -1888,7 +1886,6 @@ struct ast_flags ast_options = { AST_DEFAULT_OPTIONS }; #define ast_opt_transmit_silence ast_test_flag(&ast_options, AST_OPT_FLAG_TRANSMIT_SILENCE) #define ast_opt_dont_warn ast_test_flag(&ast_options, AST_OPT_FLAG_DONT_WARN) #define ast_opt_end_cdr_before_h_exten ast_test_flag(&ast_options, AST_OPT_FLAG_END_CDR_BEFORE_H_EXTEN) -#define ast_opt_internal_timing ast_test_flag(&ast_options, AST_OPT_FLAG_INTERNAL_TIMING) #define ast_opt_always_fork ast_test_flag(&ast_options, AST_OPT_FLAG_ALWAYS_FORK) #define ast_opt_mute ast_test_flag(&ast_options, AST_OPT_FLAG_MUTE) |