[Asterisk-code-review] res musiconhold : MOH will not start if previous hold just r... (asterisk[13])

Frederic LE FOLL asteriskteam at digium.com
Thu Aug 30 03:52:34 CDT 2018


Frederic LE FOLL has uploaded this change for review. ( https://gerrit.asterisk.org/10022


Change subject: res_musiconhold : MOH will not start if previous hold just reached end of file
......................................................................

res_musiconhold : MOH will not start if previous hold just reached end of file

On MOH activation, moh_files_readframe() is called while current stream
attached to channel is NULL and it calls ast_moh_files_next() immediatly,
but it won't call ast_moh_files_next() again if sample reading fails.
This may occur - because res_musiconhold retains last sample reading position in
the channel data - if MOH during previous hold/retrieve just reached end of file
(obviously, a bit of bad luck is required here).

This patch adds a preliminary control of ast_channel_state(chan), with a call to
ast_moh_files_next() if NULL. This leaves a chance for switching to next file
with the existing ast_moh_files_next() below, if sample reading fails.

ASTERISK-28029

Change-Id: I1508cf2c094f8feca22d6f76deaa9fdfa9944860
---
M res/res_musiconhold.c
1 file changed, 7 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/22/10022/1

diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c
index 4d98f60..e255564 100644
--- a/res/res_musiconhold.c
+++ b/res/res_musiconhold.c
@@ -402,6 +402,13 @@
 {
 	struct ast_frame *f = NULL;
 
+	/* When activating MOH (i.e. current ast_channel_stream(chan) is NULL),
+	 * call ast_moh_files_next() first. This will keep a chance for another
+	 * file search if read fails (e.g. if current file just reached EOF
+	 * due to previous reading). */
+	if (ast_channel_stream(chan) == NULL)
+		ast_moh_files_next(chan);
+
 	if (!(ast_channel_stream(chan) && (f = ast_readframe(ast_channel_stream(chan))))) {
 		if (!ast_moh_files_next(chan))
 			f = ast_readframe(ast_channel_stream(chan));

-- 
To view, visit https://gerrit.asterisk.org/10022
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1508cf2c094f8feca22d6f76deaa9fdfa9944860
Gerrit-Change-Number: 10022
Gerrit-PatchSet: 1
Gerrit-Owner: Frederic LE FOLL <frederic.lefoll at c-s.fr>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180830/abdd4da7/attachment-0001.html>


More information about the asterisk-code-review mailing list