mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-04 20:25:29 +00:00
Merge "channel: ast_write frame wrongly freed after call to audiohooks" into 13
This commit is contained in:
@@ -5234,26 +5234,21 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr)
|
|||||||
apply_plc(chan, fr);
|
apply_plc(chan, fr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
f = fr;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Send frame to audiohooks if present, if frametype is linear (else, later as per
|
* Send frame to audiohooks if present, if frametype is linear (else, later as per
|
||||||
* previous behavior)
|
* previous behavior)
|
||||||
*/
|
*/
|
||||||
if (ast_channel_audiohooks(chan)) {
|
if (ast_channel_audiohooks(chan)) {
|
||||||
if (ast_format_cache_is_slinear(fr->subclass.format)) {
|
if (ast_format_cache_is_slinear(fr->subclass.format)) {
|
||||||
struct ast_frame *old_frame;
|
|
||||||
hooked = 1;
|
hooked = 1;
|
||||||
old_frame = fr;
|
f = ast_audiohook_write_list(chan, ast_channel_audiohooks(chan), AST_AUDIOHOOK_DIRECTION_WRITE, fr);
|
||||||
fr = ast_audiohook_write_list(chan, ast_channel_audiohooks(chan), AST_AUDIOHOOK_DIRECTION_WRITE, fr);
|
|
||||||
if (old_frame != fr) {
|
|
||||||
ast_frfree(old_frame);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If the frame is in the raw write format, then it's easy... just use the frame - otherwise we will have to translate */
|
/* If the frame is in the raw write format, then it's easy... just use the frame - otherwise we will have to translate */
|
||||||
if (ast_format_cmp(fr->subclass.format, ast_channel_rawwriteformat(chan)) == AST_FORMAT_CMP_EQUAL) {
|
if (ast_format_cmp(fr->subclass.format, ast_channel_rawwriteformat(chan)) != AST_FORMAT_CMP_EQUAL) {
|
||||||
f = fr;
|
|
||||||
} else {
|
|
||||||
if (ast_format_cmp(ast_channel_writeformat(chan), fr->subclass.format) != AST_FORMAT_CMP_EQUAL) {
|
if (ast_format_cmp(ast_channel_writeformat(chan), fr->subclass.format) != AST_FORMAT_CMP_EQUAL) {
|
||||||
struct ast_str *codec_buf = ast_str_alloca(AST_FORMAT_CAP_NAMES_LEN);
|
struct ast_str *codec_buf = ast_str_alloca(AST_FORMAT_CAP_NAMES_LEN);
|
||||||
|
|
||||||
@@ -5279,7 +5274,20 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
f = ast_channel_writetrans(chan) ? ast_translate(ast_channel_writetrans(chan), fr, 0) : fr;
|
|
||||||
|
if (ast_channel_writetrans(chan)) {
|
||||||
|
struct ast_frame *trans_frame = ast_translate(ast_channel_writetrans(chan), f, 0);
|
||||||
|
|
||||||
|
if (trans_frame != f && f != fr) {
|
||||||
|
/*
|
||||||
|
* If translate gives us a new frame and so did the audio
|
||||||
|
* hook then we need to free the one from the audio hook.
|
||||||
|
*/
|
||||||
|
ast_frfree(f);
|
||||||
|
}
|
||||||
|
f = trans_frame;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!f) {
|
if (!f) {
|
||||||
|
Reference in New Issue
Block a user