aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_intercom.c
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2001-03-10 19:12:11 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2001-03-10 19:12:11 +0000
commitdc884645e6463fb181af816fdea3599713b0bd87 (patch)
treec16bdd5583e05977a7893075e3b541e1a3afa073 /apps/app_intercom.c
parentea452d3fd8f99256d987297e5afa8d1c226b465e (diff)
Version 0.1.7 from FTP
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@236 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_intercom.c')
-rwxr-xr-xapps/app_intercom.c73
1 files changed, 39 insertions, 34 deletions
diff --git a/apps/app_intercom.c b/apps/app_intercom.c
index 97b427ba1..a50b533a2 100755
--- a/apps/app_intercom.c
+++ b/apps/app_intercom.c
@@ -116,48 +116,48 @@ static int intercom_exec(struct ast_channel *chan, void *data)
int res = 0;
struct localuser *u;
struct ast_frame *f;
- struct ast_channel *trans;
+ int oreadformat;
if (!data) {
ast_log(LOG_WARNING, "Playback requires an argument (filename)\n");
return -1;
}
LOCAL_USER_ADD(u);
- /* See if we need a translator */
- if (!(chan->format & AST_FORMAT_SLINEAR))
- trans = ast_translator_create(chan, AST_FORMAT_SLINEAR, AST_DIRECTION_IN);
- else
- trans = chan;
- if (trans) {
- /* Read packets from the channel */
- while(!res) {
- res = ast_waitfor(trans, -1);
- if (res > 0) {
- res = 0;
- f = ast_read(trans);
- if (f) {
- if (f->frametype == AST_FRAME_DTMF) {
- ast_frfree(f);
- break;
- } else {
- if (f->frametype == AST_FRAME_VOICE) {
- if (f->subclass == AST_FORMAT_SLINEAR) {
- res = write_audio(f->data, f->datalen);
- if (res > 0)
- res = 0;
- } else
- ast_log(LOG_DEBUG, "Unable to handle non-signed linear frame (%d)\n", f->subclass);
- }
- }
+ /* Remember original read format */
+ oreadformat = chan->readformat;
+ /* Set mode to signed linear */
+ res = ast_set_read_format(chan, AST_FORMAT_SLINEAR);
+ if (res < 0) {
+ ast_log(LOG_WARNING, "Unable to set format to signed linear on channel %s\n", chan->name);
+ return -1;
+ }
+ /* Read packets from the channel */
+ while(!res) {
+ res = ast_waitfor(chan, -1);
+ if (res > 0) {
+ res = 0;
+ f = ast_read(chan);
+ if (f) {
+ if (f->frametype == AST_FRAME_DTMF) {
ast_frfree(f);
- } else
- res = -1;
- }
+ break;
+ } else {
+ if (f->frametype == AST_FRAME_VOICE) {
+ if (f->subclass == AST_FORMAT_SLINEAR) {
+ res = write_audio(f->data, f->datalen);
+ if (res > 0)
+ res = 0;
+ } else
+ ast_log(LOG_DEBUG, "Unable to handle non-signed linear frame (%d)\n", f->subclass);
+ }
+ }
+ ast_frfree(f);
+ } else
+ res = -1;
}
- if (trans != chan)
- ast_translator_destroy(trans);
- } else
- ast_log(LOG_WARNING, "Unable to build translator to signed linear format on '%s'\n", chan->name);
+ }
LOCAL_USER_REMOVE(u);
+ if (!res)
+ ast_set_read_format(chan, oreadformat);
return res;
}
@@ -187,3 +187,8 @@ int usecount(void)
STANDARD_USECOUNT(res);
return res;
}
+
+char *key()
+{
+ return ASTERISK_GPL_KEY;
+}