[Home]

Summary:ASTERISK-07943: Unable to have played sound in background (async with script) manner
Reporter:Anton Fedorov (datacompboy)Labels:
Date Opened:2006-10-17 06:37:47Date Closed:2011-06-07 14:08:25
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Resources/res_agi
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:
Description:    I have tried to compile
http://lists.digium.com/pipermail/asterisk-dev/2006-July/021803.html
   on Asterisk 1.2.12.1, it compiles and runs fine.

 But upon execution no playback heared...
 If I'm add call to ast_waitstream after ast_playstream  -- sound here, but no async
 :(

 What's wrong? something changed in asterisk core?
 As far, as I see in CVS commits and with google codesearch, nothing changed since 1.2.4.

 What's wrong? or there other way to get async sound from AGI ?
Comments:By: Anton Fedorov (datacompboy) 2006-10-17 12:16:22

Continue digging, looks like run_agi function from res_agi.c should be changed:
ms = -1;
c = ast_waitfor_nandfds(&chan, dead ? 0 : 1, &agi->ctrl, 1, NULL, &outfd, &ms);
should be changed to:
ms = (chan->sched) ? ast_sched_wait(chan->sched) : -1;
c = ast_waitfor_nandfds(&chan, dead ? 0 : 1, &agi->ctrl, 1, NULL, &outfd, &ms);
if (chan->sched) ast_sched_runq(chan->sched);
that will correctly handle enabled schedules on channel while we are in AGI script.

By: Russell Bryant (russell) 2006-10-17 21:06:00

This code is not supported since it is not actually in Asterisk.

By: Anton Fedorov (datacompboy) 2006-10-17 23:58:48

Yes, AGI BACKGROUND() itself not an asterisk.

But scheduler on channel should be runned by AGI manager!
Not sure will that cause errors in other cases, but that can cause problem with other scheduled events, not sure, but think that Playtones/StopPlaytones should have that problem too.

At least, don't running palnned schedulus will cause problem with external defined async extensions -- sound generation should work on any channel, not on only zaptel with ZAPTEL_OPTIMIZATION enabled, as that now.



By: Anton Fedorov (datacompboy) 2006-10-18 00:13:36

Also, for correct workin with "silence suppression" enabled in phone, correct scheduler code should be:
   ms = (chan->sched) ? ast_sched_wait(chan->sched) : -1;
   c = ast_waitfor_nandfds(&chan, dead ? 0 : 1, &agi->ctrl, 1, NULL, &outfd, &ms);
   if (chan->sched) ast_sched_runq(chan->sched);
   if (ms==0) retry = RETRY; /* When we got 0, that exit from waitfor for scheduler */

By: Tilghman Lesher (tilghman) 2006-11-12 21:35:02.000-0600

AGI is designed to be synchronous, not asynchronous.  Any previous asynchronous behavior was a bug.