diff options
author | Richard Mudgett <rmudgett@digium.com> | 2012-09-27 22:33:15 +0000 |
---|---|---|
committer | Richard Mudgett <rmudgett@digium.com> | 2012-09-27 22:33:15 +0000 |
commit | a8771e39533d967734f31a3f7b0fd790592d4328 (patch) | |
tree | 24bc626cfe1dc12bca7d396a8b35eed2f47b6802 /main | |
parent | 02ed1bd638e2c84f86c2456c3ef0d5b91bf96cf7 (diff) |
Cleanup ast_dtmf_stream()
* Made ast_dtmf_stream() wait after starting the silence generator rather
than before.
* Made ast_dtmf_stream() put the peer in autoservice for the whole time
things are being done to the chan.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@373966 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main')
-rw-r--r-- | main/app.c | 37 |
1 files changed, 13 insertions, 24 deletions
diff --git a/main/app.c b/main/app.c index c8cb29c90..8f90ddf7e 100644 --- a/main/app.c +++ b/main/app.c @@ -731,32 +731,25 @@ int ast_vm_test_destroy_user(const char *context, const char *mailbox) int ast_dtmf_stream(struct ast_channel *chan, struct ast_channel *peer, const char *digits, int between, unsigned int duration) { const char *ptr; - int res = 0; + int res; struct ast_silence_generator *silgen = NULL; if (!between) { between = 100; } - if (peer) { - res = ast_autoservice_start(peer); - } - - if (!res) { - res = ast_waitfor(chan, 100); - } - - /* ast_waitfor will return the number of remaining ms on success */ - if (res < 0) { - if (peer) { - ast_autoservice_stop(peer); - } - return res; + if (peer && ast_autoservice_start(peer)) { + return -1; } + /* Need a quiet time before sending digits. */ if (ast_opt_transmit_silence) { silgen = ast_channel_start_silence_generator(chan); } + res = ast_safe_sleep(chan, 100); + if (res) { + goto dtmf_stream_cleanup; + } for (ptr = digits; *ptr; ptr++) { if (*ptr == 'w') { @@ -765,11 +758,11 @@ int ast_dtmf_stream(struct ast_channel *chan, struct ast_channel *peer, const ch break; } } else if (strchr("0123456789*#abcdfABCDF", *ptr)) { - /* Character represents valid DTMF */ if (*ptr == 'f' || *ptr == 'F') { /* ignore return values if not supported by channel */ ast_indicate(chan, AST_CONTROL_FLASH); } else { + /* Character represents valid DTMF */ ast_senddigit(chan, *ptr, duration); } /* pause between digits */ @@ -781,17 +774,13 @@ int ast_dtmf_stream(struct ast_channel *chan, struct ast_channel *peer, const ch } } - if (peer) { - /* Stop autoservice on the peer channel, but don't overwrite any error condition - that has occurred previously while acting on the primary channel */ - if (ast_autoservice_stop(peer) && !res) { - res = -1; - } - } - +dtmf_stream_cleanup: if (silgen) { ast_channel_stop_silence_generator(chan, silgen); } + if (peer && ast_autoservice_stop(peer)) { + res = -1; + } return res; } |