From 9b22f7216f0f6244a97dc3b58cacec1b99c3bd01 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Fri, 17 Sep 2021 08:54:57 +0200 Subject: ASAP::O: Fix stream switching --- src/im-asapo.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/im-asapo.c b/src/im-asapo.c index 7d4cbf3f..85cbb159 100644 --- a/src/im-asapo.c +++ b/src/im-asapo.c @@ -177,17 +177,21 @@ static int select_next_stream(struct im_asapo *a) asapo_free_handle(&err); - st = asapo_stream_infos_get_item(si, 0); - next_stream = asapo_stream_info_get_name(st); - asapo_free_handle(&st); - if ( strcmp(next_stream, a->stream) == 0 ) { - STATUS("Waiting for new data...\n"); - } else { - free(a->stream); - a->stream = strdup(next_stream); - STATUS("Selecting next stream: %s\n", a->stream); + /* Stream list includes the current stream, so we need at least + * two entries */ + if ( asapo_stream_infos_get_size(si) < 2 ) { + STATUS("No newer stream. Waiting for new data...\n"); + asapo_free_handle(&si); + return 0; } + /* Stream list includes the current stream, so look at the second one */ + st = asapo_stream_infos_get_item(si, 1); + next_stream = asapo_stream_info_get_name(st); + free(a->stream); + a->stream = strdup(next_stream); + STATUS("Selecting next stream: %s\n", a->stream); + asapo_free_handle(&st); asapo_free_handle(&si); return 0; -- cgit v1.2.3