[Asterisk-Dev] play tone for auto monitoring

Keiron Liddle keiron at avoncore.com
Wed Sep 7 23:29:20 MST 2005


Hi,


What I am looking to achieve is simply so that when you press the start 
monitor feature key it will have the option to play a message/tone to 
both caller and callee (ie. both channels). I also wanted to have a 
different tone for starting and finishing.

I have attached a diff that sort of does this I know this isn't the 
right way to do it.
It seems to work okay with this diff except it gets the thread blocking 
error below, it also does not play the sound at exactly the sime time 
but that is only a minor problem.
It would be better if there was a way to play one sound to both channels 
at once but I don't understand how this all works, so I have no idea how 
that would be done.

Sep  7 16:29:47 WARNING[4099]: channel.c:1251 ast_waitfor_nandfds: 
Thread -1221518416 Blocking 'SIP/8980-71c4', already blocked by thread 
-1221243984 in procedure ast_waitfor_nandfds

Another thing that should be added is an option to play on both channels 
or just the caller channel.

So my question is, what is the right way to do this or is there any 
other option?

Thanks,
Keiron


-------------- next part --------------
Index: res/res_features.c
===================================================================
RCS file: /usr/cvsroot/asterisk/res/res_features.c,v
retrieving revision 1.68
diff -r1.68 res_features.c
80a81,82
> static char startmontone[256] = "";
> static char endmontone[256] = "";
462c464,465
<       if (!ast_strlen_zero(courtesytone)) {
---
>         if (!callee_chan->monitor) {
>       if (!ast_strlen_zero(startmontone)) {
465c468,470
<               if (!ast_streamfile(caller_chan, courtesytone, caller_chan->language)) {
---
> int res1 = ast_streamfile(caller_chan, startmontone, caller_chan->language);
> int res2 = ast_streamfile(callee_chan, startmontone, callee_chan->language);
>               if (!(res1 && res2)) {
467c472
<                               ast_log(LOG_WARNING, "Failed to play courtesy tone!\n");
---
>                               ast_log(LOG_WARNING, "Failed to play start tone!\n");
470a476,480
>                       if(ast_waitstream(callee_chan, "") < 0) {
>                                 ast_log(LOG_WARNING, "Failed to play start tone!\n");
>                                 ast_autoservice_stop(callee_chan);
>                                 return -1;
>                       }
475c485,506
< 
---
>       } else {
>         if (!ast_strlen_zero(endmontone)) {
>                 if (ast_autoservice_start(callee_chan))
>                       return -1;
> int res1 = ast_streamfile(caller_chan, endmontone, caller_chan->language);
> int res2 = ast_streamfile(callee_chan, endmontone, callee_chan->language);
>                 if (!(res1 && res2)) {
>                         if (ast_waitstream(caller_chan, "") < 0) {
>                                 ast_log(LOG_WARNING, "Failed to play end tone!\n");
>                                 ast_autoservice_stop(callee_chan);
>                                 return -1;
>                       }
>                       if(ast_waitstream(callee_chan, "") < 0) {
>                                 ast_log(LOG_WARNING, "Failed to play end tone!\n");
>                                 ast_autoservice_stop(callee_chan);
>                                 return -1;
>                         }
>                 }
>                 if (ast_autoservice_stop(callee_chan))
>                       return -1;
>         }
>       }
1966a1998,2001
>                         } else if (!strcasecmp(var->name, "startmontone")) {
>                                 ast_copy_string(startmontone, var->value, sizeof(startmontone));
>                         } else if (!strcasecmp(var->name, "endmontone")) {
>                                 ast_copy_string(endmontone, var->value, sizeof(endmontone));



More information about the asterisk-dev mailing list