> Hi. > > I wanted to write a "popcorn" app for myself, both to learn how to > script in extensions.conf, but also because it was something handy. > > Along the way, I found myself doing something like: > > [popcorn] > exten => s,1,Set(FUTURETIME=$[${EPOCH} + 10]) > ... > exten => s,n,While(${EPOCH} < ${FUTURETIME}) > exten => s,n,Wait(0.01) > exten => s,n,EndWhile() > exten => s,n,Play(beep) > exten => s,n,Hangup() > > and hating myself for it (my Asterisk runs on a 500MHz Geode LX). > > So I decided it would be useful (in general, and educational for me in > particular) to write a WaitUntil() application instead. > > Well, I've done that. > > I was going to file a bug and then post a "fix" to get their feature in, > but the Bug guidelines seem to be pretty clear that this is not the way > to go. > > So, I'm posting here instead. > > The example to paste into the documentation or extensions.conf is: > > [popcorn] > exten => s,1,Answer() > ; the amount of delay is set for English; you may need to adjust this time > ; for other languages is there's no pause before the synchronizing beep. > exten => s,n,Set(FUTURETIME=$[${EPOCH} + 11]) > exten => s,n,SayUnixTime(${FUTURETIME},Zulu,HNS) > exten => s,n,SayPhonetic(z) > exten => s,n,SayUnixTime(${FUTURETIME},,HNS) > exten => s,n,Playback(local) > exten => s,n,WaitUntil(${FUTURETIME}) > exten => s,n,Playback(beep) > exten => s,n,Return() > > > I invoke it as: > > exten => 712,1,Gosub(popcorn,s,1) > exten => 712,n,Hangup() > > And lastly, attached is the source for app_waituntil.c. > > It's fairly straightforward, and not very big. > > But hopefully useful. > > Oh, before I forget: it does require the recording of one additional > phrase, > either "local" or "localtime". I've used "local" in my example above. > And > I read out the time first as GMT/UT (because I travel a lot), and then in > the > timezone of my PBX... > > -Philip >Philip, I just was looking over the app_waitutil.c and am confused you add 500 to tv.tv_usec on the line "msec = (future - tv.tv_sec) * 1000 - ((tv.tv_usec + 500) / 1000);"? Ryan
Ryan Burke wrote:> I just was looking over the app_waitutil.c and am confused you add 500 > to tv.tv_usec on the line "msec = (future - tv.tv_sec) * 1000 - > ((tv.tv_usec + 500) / 1000);"?Without having looked at Philips code at all, that looks like he is rounding up? /Per Jessen, Z?rich -- http://www.spamchek.com/ - your spam is our business.
Tony Mountifield
2007-Dec-05 14:55 UTC
[asterisk-users] New feature: calling all bug marshals
In article <15243.199.46.199.237.1196858285.squirrel at www.tailorhosting.com>, Ryan Burke <burke at tailorhosting.com> wrote:> > I just was looking over the app_waitutil.c and am confused you add 500 to > tv.tv_usec on the line "msec = (future - tv.tv_sec) * 1000 - ((tv.tv_usec > + 500) / 1000);"?It's just doing a standard "round to nearest" integer division, by adding half the divisor to the dividend before dividing. Without that, you just get "round down" instead. Cheers Tony -- Tony Mountifield Work: tony at softins.co.uk - http://www.softins.co.uk Play: tony at mountifield.org - http://tony.mountifield.org