diff --git a/main/core_unreal.c b/main/core_unreal.c index 411cc5123e80b5b79fc9b9f6c191777a5874210a..19f2d1f6516668410d03e69800353cb87783d612 100644 --- a/main/core_unreal.c +++ b/main/core_unreal.c @@ -409,7 +409,12 @@ static int unreal_queue_indicate(struct ast_unreal_pvt *p, struct ast_channel *a int isoutbound; ao2_lock(p); - if (ast_test_flag(p, AST_UNREAL_NO_OPTIMIZATION)) { + /* + * Block -1 stop tones events if we are to be optimized out. We + * don't need a flurry of these events on an unreal channel chain + * when initially connected to slow the optimization process. + */ + if (0 <= condition || ast_test_flag(p, AST_UNREAL_NO_OPTIMIZATION)) { struct ast_frame f = { .frametype = AST_FRAME_CONTROL, .subclass.integer = condition, @@ -549,6 +554,18 @@ int ast_unreal_indicate(struct ast_channel *ast, int condition, const void *data } res = unreal_queue_indicate(p, ast, condition, data, datalen); break; + case AST_CONTROL_RINGING: + /* Don't queue ringing frames if the channel is not in a "ring" state. Otherwise, + * the real channel on the other end will likely start a playtones generator. It is + * possible that this playtones generator will never be stopped under certain + * circumstances. + */ + if (ast_channel_state(ast) == AST_STATE_RING) { + res = unreal_queue_indicate(p, ast, condition, data, datalen); + } else { + res = -1; + } + break; default: res = unreal_queue_indicate(p, ast, condition, data, datalen); break;