Skip to content

Commit 526a6e0

Browse files
dsp.c: Fix and improve potentially inaccurate log message.
If ast_dsp_process is called with a codec besides slin, ulaw, or alaw, a warning is logged that in-band DTMF is not supported, but this message is not always appropriate or correct, because ast_dsp_process is much more generic than just DTMF detection. This logs a more generic message in those cases, and also improves codec-mismatch logging throughout dsp.c by ensuring incompatible codecs are printed out. Resolves: #595
1 parent 29a2736 commit 526a6e0

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

main/dsp.c

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ struct ast_dsp {
413413
int totalnoise;
414414
int features;
415415
int ringtimeout;
416-
int busymaybe;
416+
int busymaybe; /* Boolean, could be a bitfield */
417417
int busycount;
418418
struct ast_dsp_busy_pattern busy_cadence;
419419
int historicnoise[DSP_HISTORY];
@@ -428,8 +428,8 @@ struct ast_dsp {
428428
int digitmode;
429429
int faxmode;
430430
int freqmode;
431-
int dtmf_began;
432-
int display_inband_dtmf_warning;
431+
int dtmf_began; /* Boolean, could be a bitfield */
432+
int display_inband_dtmf_warning; /* Boolean, could be a bitfield */
433433
float genergy;
434434
int mute_fragments;
435435
unsigned int sample_rate;
@@ -1223,7 +1223,8 @@ int ast_dsp_call_progress(struct ast_dsp *dsp, struct ast_frame *inf)
12231223
return 0;
12241224
}
12251225
if (!ast_format_cache_is_slinear(inf->subclass.format)) {
1226-
ast_log(LOG_WARNING, "Can only check call progress in signed-linear frames\n");
1226+
ast_log(LOG_WARNING, "Can only check call progress in signed-linear frames, %s not supported\n",
1227+
ast_format_get_name(inf->subclass.format));
12271228
return 0;
12281229
}
12291230
return __ast_dsp_call_progress(dsp, inf->data.ptr, inf->datalen / 2);
@@ -1466,7 +1467,8 @@ static int ast_dsp_silence_noise_with_energy(struct ast_dsp *dsp, struct ast_fra
14661467
s[x] = AST_ALAW(odata[x]);
14671468
}
14681469
} else {
1469-
ast_log(LOG_WARNING, "Can only calculate silence on signed-linear, alaw or ulaw frames :(\n");
1470+
ast_log(LOG_WARNING, "Can only calculate silence on signed-linear, alaw or ulaw frames, %s not supported\n",
1471+
ast_format_get_name(f->subclass.format));
14701472
return 0;
14711473
}
14721474
}
@@ -1529,9 +1531,17 @@ struct ast_frame *ast_dsp_process(struct ast_channel *chan, struct ast_dsp *dsp,
15291531
shortdata[x] = AST_ALAW(odata[x]);
15301532
}
15311533
} else {
1532-
/*Display warning only once. Otherwise you would get hundreds of warnings every second */
1534+
/* Display warning only once. Otherwise you would get hundreds of warnings every second */
15331535
if (dsp->display_inband_dtmf_warning) {
1534-
ast_log(LOG_WARNING, "Inband DTMF is not supported on codec %s. Use RFC2833\n", ast_format_get_name(af->subclass.format));
1536+
/* If DTMF is enabled for the DSP, try to be helpful and warn about that specifically,
1537+
* otherwise emit a more generic message that covers all other cases. */
1538+
if ((dsp->features & DSP_FEATURE_DIGIT_DETECT) && (dsp->digitmode & DSP_DIGITMODE_DTMF)) {
1539+
ast_log(LOG_WARNING, "Inband DTMF is not supported on codec %s. Use RFC2833\n",
1540+
ast_format_get_name(af->subclass.format));
1541+
} else {
1542+
ast_log(LOG_WARNING, "Can only do DSP on signed-linear, alaw or ulaw frames (%s not supported)\n",
1543+
ast_format_get_name(af->subclass.format));
1544+
}
15351545
}
15361546
dsp->display_inband_dtmf_warning = 0;
15371547
return af;

0 commit comments

Comments
 (0)