summaryrefslogtreecommitdiff
path: root/main/sounds_index.c
diff options
context:
space:
mode:
authorCorey Farrell <git@cfware.com>2017-12-06 15:49:32 -0500
committerCorey Farrell <git@cfware.com>2017-12-06 23:36:15 -0600
commitc35613d2578c0ba14f84c7aa2eea64d2941b21a7 (patch)
tree5f0bd282fd91689170e4d3b63bdc53ea5f9e89c6 /main/sounds_index.c
parentf28fdb46f152e6ddf632bdfcd1750d8402697d20 (diff)
sounds_index: Avoid repeatedly reindexing.
The sounds index is rebuilt each time a format is registered or unregistered. This causes the index to be repeatedly rebuilt during startup and shutdown. This patch significantly reduces the work done by delaying sound index initialization until after modules are loaded. This way a reindex only occurs if a format module is loaded after startup. We also skip reindexing when format modules are unloaded during shutdown. Change-Id: I585fd6ee04200612ab1490dc804f76805f89cf0a
Diffstat (limited to 'main/sounds_index.c')
-rw-r--r--main/sounds_index.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/main/sounds_index.c b/main/sounds_index.c
index c7f9f4dd9..c792c1bbd 100644
--- a/main/sounds_index.c
+++ b/main/sounds_index.c
@@ -285,13 +285,15 @@ static void sounds_cleanup(void)
static void format_update_cb(void *data, struct stasis_subscription *sub,
struct stasis_message *message)
{
- ast_sounds_reindex();
+ /* Reindexing during shutdown is pointless. */
+ if (!ast_shutting_down()) {
+ ast_sounds_reindex();
+ }
}
int ast_sounds_index_init(void)
{
int res = 0;
- sounds_index = NULL;
if (ast_sounds_reindex()) {
return -1;
}
@@ -328,6 +330,5 @@ int ast_sounds_index_init(void)
struct ast_media_index *ast_sounds_get_index(void)
{
- ao2_ref(sounds_index, +1);
- return sounds_index;
+ return ao2_bump(sounds_index);
}