From 8faed04b01be5e5cd4d3044aa3c84555fd492c52 Mon Sep 17 00:00:00 2001
From: "Joshua C. Colp" <jcolp@sangoma.com>
Date: Wed, 28 Apr 2021 09:17:13 -0300
Subject: [PATCH] chan_local: Skip filtering audio formats on removed streams.

When a stream topology is provided to chan_local when dialing
it filters the audio formats down. This operation did not skip
streams which were removed (that have no formats) resulting in
calling being aborted.

This change causes such streams to be skipped.

ASTERISK-29407

Change-Id: I1de8b98727cb2d10f4bc287da0b5fdcb381addd6
---
 main/core_local.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/main/core_local.c b/main/core_local.c
index 07a6ff7bea..15a546cbfc 100644
--- a/main/core_local.c
+++ b/main/core_local.c
@@ -967,7 +967,8 @@ static struct ast_channel *local_request_with_stream_topology(const char *type,
 
 		stream = ast_stream_topology_get_stream(audio_filtered_topology, i);
 
-		if (ast_stream_get_type(stream) != AST_MEDIA_TYPE_AUDIO) {
+		if (ast_stream_get_type(stream) != AST_MEDIA_TYPE_AUDIO ||
+			ast_stream_get_state(stream) == AST_STREAM_STATE_REMOVED) {
 			continue;
 		}
 
-- 
GitLab