[Home]

Summary:ASTERISK-24006: app_waitforsilence logic error when used as WaitForNoise
Reporter:M vd S (mvds)Labels:
Date Opened:2014-07-08 21:55:53Date Closed:2017-09-08 10:31:26
Priority:TrivialRegression?No
Status:Closed/CompleteComponents:Applications/app_waitforsilence
Versions:1.8.13.1 1.8.29.0 Frequency of
Occurrence
Constant
Related
Issues:
Environment:N/A (but observed on Debian 7.5)Attachments:
Description:Actually 2 connected issues:

1) In do_waiting(), a condition in which no frames are received is treated as if it would trigger the dsp function. This is okay if the dsp tries to find silence, but if the dsp needs noise, you get the odd result that a muted channel is seen as noise.

2a) For some reason, when calling outbound using SIP, and invoking WaitForNoise() almost immediately (as to wait for the called party to start talking), no frames are received, nor is any audio recorded by the Monitor, while WaitForNoise() is running.

[update 20140711]
2b) When calling outbound using SIP, and invoking Record(), a zero-sized file is created but no sound is recorded to it. Also, when invoked in such a way that it should end on silence, it hangs in Record() indefinitely. (to be precise, on "ms = ast_waitfor(chan, ms);" which is called with ms==-1)

Issue 1 is resolved by changing this line:

  dsptime = timereqd;

to

  if ( wait_for_silence ) dsptime = timereqd;

Issue 2 is worked around by simply playing a short (1 ms) silent audio file before doing anything else.

I personally don't need to have this fixed, but it might save other users a few hours of searching, since the combined effect of these issues is quite obscure.
Comments:By: Rusty Newton (rnewton) 2014-07-11 10:11:29.213-0500

Can you verify if the latest version of 1.8 has the same behavior?

By: M vd S (mvds) 2014-07-11 16:21:41.797-0500

Yes, I just checked out, compiled and ran Asterisk SVN-branch-1.8-r418261M, to observe the exact same behavior.

I also found strange bugs calling Record() without the starting beep and before outputting audio, which seems to boil down to the same issue, that no frames are received and ast_waitfor() gives unexpected results (in my case a lockup, as it waits indefinitely for silence to end the recording). Also fixed by outputting 1 ms of silence, so no major problem.

[ps. updated description to add the Record() issue]

By: Rusty Newton (rnewton) 2014-07-25 18:04:25.934-0500

Thanks. If you decide you want to submit a patch, here is the [Patch Contribution process|https://wiki.asterisk.org/wiki/display/AST/Patch+Contribution+Process]. Otherwise, work can probably be done with the suggestions you provided.

By: Rusty Newton (rnewton) 2014-07-25 18:06:38.071-0500

Note that app_waitforsilence is under extended support, and therefore supported by the community. So unless someone else submits a patch and moves it forward, your best bet may be to go ahead and post a patch, put it on [reviewboard|https://wiki.asterisk.org/wiki/display/AST/Review+Board+Usage] and ask on the dev list for someone to help move it through.

By: Sean Bright (seanbright) 2017-09-06 16:20:35.189-0500

[Patch is here|https://gerrit.asterisk.org/#/c/6451/]. I wasn't about to duplicate issues 2a and 2b, but 1 is resolved.

By: Sean Bright (seanbright) 2017-09-08 10:31:26.226-0500

Fixed by https://gerrit.asterisk.org/#/c/6457/