mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-19 03:08:45 +00:00
don't install moh functions if no classes are configured (issue #5025 with mods)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6412 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -471,7 +471,7 @@ static void *monmp3thread(void *data)
|
|||||||
/* Spawn mp3 player if it's not there */
|
/* Spawn mp3 player if it's not there */
|
||||||
if (class->srcfd < 0) {
|
if (class->srcfd < 0) {
|
||||||
if ((class->srcfd = spawn_mp3(class)) < 0) {
|
if ((class->srcfd = spawn_mp3(class)) < 0) {
|
||||||
ast_log(LOG_WARNING, "unable to spawn mp3player\n");
|
ast_log(LOG_WARNING, "Unable to spawn mp3player\n");
|
||||||
/* Try again later */
|
/* Try again later */
|
||||||
sleep(500);
|
sleep(500);
|
||||||
}
|
}
|
||||||
@@ -1135,24 +1135,25 @@ static struct ast_cli_entry cli_moh_classes_show = { { "moh", "classes", "show"
|
|||||||
|
|
||||||
static struct ast_cli_entry cli_moh_files_show = { { "moh", "files", "show"}, cli_files_show, "List MOH file-based classes", "Lists all loaded file-based MOH classes and their files", NULL};
|
static struct ast_cli_entry cli_moh_files_show = { { "moh", "files", "show"}, cli_files_show, "List MOH file-based classes", "Lists all loaded file-based MOH classes and their files", NULL};
|
||||||
|
|
||||||
static void init_classes(void)
|
static int init_classes(void)
|
||||||
{
|
{
|
||||||
struct mohclass *moh;
|
struct mohclass *moh;
|
||||||
|
|
||||||
load_moh_classes();
|
if (!load_moh_classes()) /* Load classes from config */
|
||||||
|
return 0; /* Return if nothing is found */
|
||||||
moh = mohclasses;
|
moh = mohclasses;
|
||||||
while (moh) {
|
while (moh) {
|
||||||
if (moh->total_files)
|
if (moh->total_files)
|
||||||
moh_scan_files(moh);
|
moh_scan_files(moh);
|
||||||
moh = moh->next;
|
moh = moh->next;
|
||||||
}
|
}
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int load_module(void)
|
int load_module(void)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
ast_install_music_functions(local_ast_moh_start, local_ast_moh_stop, local_ast_moh_cleanup);
|
|
||||||
res = ast_register_application(app0, moh0_exec, synopsis0, descrip0);
|
res = ast_register_application(app0, moh0_exec, synopsis0, descrip0);
|
||||||
ast_register_atexit(ast_moh_destroy);
|
ast_register_atexit(ast_moh_destroy);
|
||||||
ast_cli_register(&cli_moh);
|
ast_cli_register(&cli_moh);
|
||||||
@@ -1167,14 +1168,19 @@ int load_module(void)
|
|||||||
if (!res)
|
if (!res)
|
||||||
res = ast_register_application(app4, moh4_exec, synopsis4, descrip4);
|
res = ast_register_application(app4, moh4_exec, synopsis4, descrip4);
|
||||||
|
|
||||||
init_classes();
|
if (!init_classes()) { /* No music classes configured, so skip it */
|
||||||
|
ast_log(LOG_WARNING, "No music on hold classes configured, disabling music on hold.");
|
||||||
|
} else {
|
||||||
|
ast_install_music_functions(local_ast_moh_start, local_ast_moh_stop, local_ast_moh_cleanup);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int reload(void)
|
int reload(void)
|
||||||
{
|
{
|
||||||
init_classes();
|
if (init_classes())
|
||||||
|
ast_install_music_functions(local_ast_moh_start, local_ast_moh_stop, local_ast_moh_cleanup);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user