aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2021-09-17 08:54:57 +0200
committerThomas White <taw@physics.org>2022-06-02 12:15:38 +0200
commit9b22f7216f0f6244a97dc3b58cacec1b99c3bd01 (patch)
tree7e70dd14606c65bd4f91e09524459baf2a24a5f8
parent6db9619ba5172b9e416a5939d375f5119aa652ff (diff)
ASAP::O: Fix stream switching
-rw-r--r--src/im-asapo.c22
1 files changed, 13 insertions, 9 deletions
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;