diff options
author | George Joseph <gjoseph@digium.com> | 2017-04-11 10:07:39 -0600 |
---|---|---|
committer | George Joseph <gjoseph@digium.com> | 2017-04-12 16:46:22 -0500 |
commit | f882ca25722b6290dc6e8d786452b0b26adceed1 (patch) | |
tree | 98f8862eaf958ea63650ca50900c0d43fce2a541 /channels/chan_alsa.c | |
parent | 2e9f186c179e86316fbe1b43fbda9702bddaa615 (diff) |
modules: change module LOAD_FAILUREs to LOAD_DECLINES
In all non-pbx modules, AST_MODULE_LOAD_FAILURE has been changed
to AST_MODULE_LOAD_DECLINE. This prevents asterisk from exiting
if a module can't be loaded. If the user wishes to retain the
FAILURE behavior for a specific module, they can use the "require"
or "preload-require" keyword in modules.conf.
A new API was added to logger: ast_is_logger_initialized(). This
allows asterisk.c/check_init() to print to the error log once the
logger subsystem is ready instead of just to stdout. If something
does fail before the logger is initialized, we now print to stderr
instead of stdout.
Change-Id: I5f4b50623d9b5a6cb7c5624a8c5c1274c13b2b25
Diffstat (limited to 'channels/chan_alsa.c')
-rw-r--r-- | channels/chan_alsa.c | 46 |
1 files changed, 25 insertions, 21 deletions
diff --git a/channels/chan_alsa.c b/channels/chan_alsa.c index 61ea2e719..0f61d7c03 100644 --- a/channels/chan_alsa.c +++ b/channels/chan_alsa.c @@ -926,6 +926,26 @@ static struct ast_cli_entry cli_alsa[] = { AST_CLI_DEFINE(console_mute, "Disable/Enable mic input"), }; +static int unload_module(void) +{ + ast_channel_unregister(&alsa_tech); + ast_cli_unregister_multiple(cli_alsa, ARRAY_LEN(cli_alsa)); + + if (alsa.icard) + snd_pcm_close(alsa.icard); + if (alsa.ocard) + snd_pcm_close(alsa.ocard); + if (alsa.owner) + ast_softhangup(alsa.owner, AST_SOFTHANGUP_APPUNLOAD); + if (alsa.owner) + return -1; + + ao2_cleanup(alsa_tech.capabilities); + alsa_tech.capabilities = NULL; + + return 0; +} + /*! * \brief Load the module * @@ -996,12 +1016,16 @@ static int load_module(void) if (soundcard_init() < 0) { ast_verb(2, "No sound card detected -- console channel will be unavailable\n"); ast_verb(2, "Turn off ALSA support by adding 'noload=chan_alsa.so' in /etc/asterisk/modules.conf\n"); + unload_module(); + return AST_MODULE_LOAD_DECLINE; } if (ast_channel_register(&alsa_tech)) { ast_log(LOG_ERROR, "Unable to register channel class 'Console'\n"); - return AST_MODULE_LOAD_FAILURE; + unload_module(); + + return AST_MODULE_LOAD_DECLINE; } ast_cli_register_multiple(cli_alsa, ARRAY_LEN(cli_alsa)); @@ -1009,26 +1033,6 @@ static int load_module(void) return AST_MODULE_LOAD_SUCCESS; } -static int unload_module(void) -{ - ast_channel_unregister(&alsa_tech); - ast_cli_unregister_multiple(cli_alsa, ARRAY_LEN(cli_alsa)); - - if (alsa.icard) - snd_pcm_close(alsa.icard); - if (alsa.ocard) - snd_pcm_close(alsa.ocard); - if (alsa.owner) - ast_softhangup(alsa.owner, AST_SOFTHANGUP_APPUNLOAD); - if (alsa.owner) - return -1; - - ao2_cleanup(alsa_tech.capabilities); - alsa_tech.capabilities = NULL; - - return 0; -} - AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "ALSA Console Channel Driver", .support_level = AST_MODULE_SUPPORT_EXTENDED, .load = load_module, |