From 0dc408891e98c07461cf85cfd922e27a19ebd22e Mon Sep 17 00:00:00 2001 From: jpeeler Date: Wed, 10 Dec 2008 22:04:18 +0000 Subject: (closes issue #13229) Reported by: clegall_proformatique Ensure that moh_generate does not return prematurely before local_ast_moh_stop is called. Also, the sleep in mp3_spawn now only occurs for http locations since it seems to have been added originally only for failing media streams. git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@162874 f38db490-d61c-443f-a65b-d21fe96a405b --- res/res_musiconhold.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'res/res_musiconhold.c') diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c index 255f8d5d9..8b69cd1d4 100644 --- a/res/res_musiconhold.c +++ b/res/res_musiconhold.c @@ -371,7 +371,7 @@ static int spawn_mp3(struct mohclass *class) files = 1; } else { dir = opendir(class->dir); - if (!dir && !strstr(class->dir,"http://") && !strstr(class->dir,"HTTP://")) { + if (!dir && !strncasecmp(class->dir, "http://", 7)) { ast_log(LOG_WARNING, "%s is not a valid directory\n", class->dir); return -1; } @@ -414,8 +414,7 @@ static int spawn_mp3(struct mohclass *class) } } - - if (strstr(class->dir,"http://") || strstr(class->dir,"HTTP://")) { + if (!strncasecmp(class->dir, "http://", 7)) { ast_copy_string(fns[files], class->dir, sizeof(fns[files])); argv[argc++] = fns[files]; files++; @@ -446,7 +445,7 @@ static int spawn_mp3(struct mohclass *class) close(fds[1]); return -1; } - if (time(NULL) - class->start < respawn_time) { + if (!strncasecmp(class->dir, "http://", 7) && time(NULL) - class->start < respawn_time) { sleep(respawn_time - (time(NULL) - class->start)); } @@ -743,8 +742,9 @@ static int moh_generate(struct ast_channel *chan, void *data, int len, int sampl short buf[1280 + AST_FRIENDLY_OFFSET / 2]; int res; - if (!moh->parent->pid) + if (!moh->parent->pid && moh->parent->inuse == 0) { return -1; + } len = ast_codec_get_len(moh->parent->format, samples); -- cgit v1.2.3