mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-03 11:25:35 +00:00
Merge "bridge_softmix: Use removed stream spots when renegotiating."
This commit is contained in:
@@ -524,15 +524,32 @@ static int append_all_streams(struct ast_stream_topology *dest,
|
||||
const struct ast_stream_topology *source)
|
||||
{
|
||||
int i;
|
||||
int dest_index = 0;
|
||||
|
||||
for (i = 0; i < ast_stream_topology_get_count(source); ++i) {
|
||||
struct ast_stream *clone;
|
||||
int added = 0;
|
||||
|
||||
clone = ast_stream_clone(ast_stream_topology_get_stream(source, i), NULL);
|
||||
if (!clone) {
|
||||
return -1;
|
||||
}
|
||||
if (ast_stream_topology_append_stream(dest, clone) < 0) {
|
||||
|
||||
/* If we can reuse an existing removed stream then do so */
|
||||
while (dest_index < ast_stream_topology_get_count(dest)) {
|
||||
struct ast_stream *stream = ast_stream_topology_get_stream(dest, dest_index);
|
||||
|
||||
dest_index++;
|
||||
|
||||
if (ast_stream_get_state(stream) == AST_STREAM_STATE_REMOVED) {
|
||||
ast_stream_topology_set_stream(dest, dest_index - 1, clone);
|
||||
added = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* If no removed stream exists that we took the place of append the stream */
|
||||
if (!added && ast_stream_topology_append_stream(dest, clone) < 0) {
|
||||
ast_stream_free(clone);
|
||||
return -1;
|
||||
}
|
||||
|
Reference in New Issue
Block a user