From e9425718762b4c4e38ba86a3d2483d34bf1b454d Mon Sep 17 00:00:00 2001
From: Anthony Minessale <anthm@freeswitch.org>
Date: Sat, 9 Mar 2013 07:58:09 -0600
Subject: [PATCH] FS-5160 --resolve This is depricated in favor of
 {loops=10}tone_stream://path=/foo/bar.ttml adding legacy code to let both
 ways work

---
 conf/vanilla/dialplan/default.xml                 | 4 ++--
 src/mod/formats/mod_tone_stream/mod_tone_stream.c | 9 +++++++++
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/conf/vanilla/dialplan/default.xml b/conf/vanilla/dialplan/default.xml
index 7f5002152f..72b9431a40 100644
--- a/conf/vanilla/dialplan/default.xml
+++ b/conf/vanilla/dialplan/default.xml
@@ -695,14 +695,14 @@
     <extension name="milliwatt">
       <condition field="destination_number" expression="^9197$">
 	<action application="answer"/>
-	<action application="playback" data="tone_stream://%(251,0,1004);loops=-1"/>
+	<action application="playback" data="{loops=-1}tone_stream://%(251,0,1004)"/>
       </condition>
     </extension>
 
     <extension name="tone_stream">
       <condition field="destination_number" expression="^9198$">
 	<action application="answer"/>
-	<action application="playback" data="tone_stream://path=${base_dir}/conf/tetris.ttml;loops=10"/>
+	<action application="playback" data="{loops=10}tone_stream://path=${base_dir}/conf/tetris.ttml"/>
       </condition>
     </extension>
 
diff --git a/src/mod/formats/mod_tone_stream/mod_tone_stream.c b/src/mod/formats/mod_tone_stream/mod_tone_stream.c
index fe3080f4c5..bf373f4162 100644
--- a/src/mod/formats/mod_tone_stream/mod_tone_stream.c
+++ b/src/mod/formats/mod_tone_stream/mod_tone_stream.c
@@ -136,6 +136,15 @@ static switch_status_t tone_stream_file_open(switch_file_handle_t *handle, const
 	switch_buffer_create_dynamic(&audio_buffer, 1024, 1024, 0);
 	switch_assert(audio_buffer);
 
+	if ((tmp = (char *)switch_stristr(";loops=", tonespec))) {
+		*tmp = '\0';
+		tmp += 7;
+		if (tmp) {
+			loops = atoi(tmp);
+			switch_buffer_set_loops(audio_buffer, loops);
+		}
+	}
+
 	if (handle->params) {
 		if ((tmp = switch_event_get_header(handle->params, "loops"))) {
 			loops = atoi(tmp);