aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_talkdetect.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/app_talkdetect.c')
-rw-r--r--apps/app_talkdetect.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/apps/app_talkdetect.c b/apps/app_talkdetect.c
index 615929e94..545261c72 100644
--- a/apps/app_talkdetect.c
+++ b/apps/app_talkdetect.c
@@ -87,7 +87,7 @@ static int background_detect_exec(struct ast_channel *chan, const char *data)
int analysistime = -1;
int continue_analysis = 1;
int x;
- int origrformat = 0;
+ struct ast_format origrformat;
struct ast_dsp *dsp = NULL;
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(filename);
@@ -96,7 +96,8 @@ static int background_detect_exec(struct ast_channel *chan, const char *data)
AST_APP_ARG(max);
AST_APP_ARG(analysistime);
);
-
+
+ ast_format_clear(&origrformat);
if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "BackgroundDetect requires an argument (filename)\n");
return -1;
@@ -126,8 +127,8 @@ static int background_detect_exec(struct ast_channel *chan, const char *data)
}
}
- origrformat = chan->readformat;
- if ((ast_set_read_format(chan, AST_FORMAT_SLINEAR))) {
+ ast_format_copy(&origrformat, &chan->readformat);
+ if ((ast_set_read_format_by_id(chan, AST_FORMAT_SLINEAR))) {
ast_log(LOG_WARNING, "Unable to set read format to linear!\n");
res = -1;
break;
@@ -182,7 +183,7 @@ static int background_detect_exec(struct ast_channel *chan, const char *data)
ast_frfree(fr);
break;
}
- } else if ((fr->frametype == AST_FRAME_VOICE) && (fr->subclass.codec == AST_FORMAT_SLINEAR) && continue_analysis) {
+ } else if ((fr->frametype == AST_FRAME_VOICE) && (fr->subclass.format.id == AST_FORMAT_SLINEAR) && continue_analysis) {
int totalsilence;
int ms;
res = ast_dsp_silence(dsp, fr, &totalsilence);
@@ -228,9 +229,9 @@ static int background_detect_exec(struct ast_channel *chan, const char *data)
} while (0);
if (res > -1) {
- if (origrformat && ast_set_read_format(chan, origrformat)) {
+ if (origrformat.id && ast_set_read_format(chan, &origrformat)) {
ast_log(LOG_WARNING, "Failed to restore read format for %s to %s\n",
- chan->name, ast_getformatname(origrformat));
+ chan->name, ast_getformatname(&origrformat));
}
}
if (dsp) {