aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_speech_utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/app_speech_utils.c')
-rw-r--r--apps/app_speech_utils.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/apps/app_speech_utils.c b/apps/app_speech_utils.c
index 0323f7c47..fe99157e9 100644
--- a/apps/app_speech_utils.c
+++ b/apps/app_speech_utils.c
@@ -642,7 +642,7 @@ static int speech_background(struct ast_channel *chan, const char *data)
int res = 0, done = 0, started = 0, quieted = 0, max_dtmf_len = 0;
struct ast_speech *speech = find_speech(chan);
struct ast_frame *f = NULL;
- int oldreadformat = AST_FORMAT_SLINEAR;
+ struct ast_format oldreadformat;
char dtmf[AST_MAX_EXTENSION] = "";
struct timeval start = { 0, 0 }, current;
struct ast_datastore *datastore = NULL;
@@ -658,6 +658,7 @@ static int speech_background(struct ast_channel *chan, const char *data)
parse = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, parse);
+ ast_format_clear(&oldreadformat);
if (speech == NULL)
return -1;
@@ -673,10 +674,10 @@ static int speech_background(struct ast_channel *chan, const char *data)
}
/* Record old read format */
- oldreadformat = chan->readformat;
+ ast_format_copy(&oldreadformat, &chan->readformat);
/* Change read format to be signed linear */
- if (ast_set_read_format(chan, speech->format))
+ if (ast_set_read_format(chan, &speech->format))
return -1;
if (!ast_strlen_zero(args.soundfile)) {
@@ -881,7 +882,7 @@ static int speech_background(struct ast_channel *chan, const char *data)
ast_channel_datastore_remove(chan, datastore);
} else {
/* Channel is okay so restore read format */
- ast_set_read_format(chan, oldreadformat);
+ ast_set_read_format(chan, &oldreadformat);
}
return 0;