From 28f56a9e1324fbde6854c72d6b234c2f00748d03 Mon Sep 17 00:00:00 2001 From: Andrew Opalach Date: Wed, 27 Nov 2024 11:32:17 -0500 Subject: Sink fixes, update for dependency changes Signed-off-by: Andrew Opalach --- src/liana/handlers.c | 2 +- src/liana/list.c | 13 +++++++------ src/liana/server.c | 8 +++++--- src/liana/server.h | 1 + src/liana/vcr.c | 2 +- 5 files changed, 15 insertions(+), 11 deletions(-) (limited to 'src/liana') diff --git a/src/liana/handlers.c b/src/liana/handlers.c index e67250a..936f801 100644 --- a/src/liana/handlers.c +++ b/src/liana/handlers.c @@ -28,7 +28,7 @@ struct lia_handler_entry liana_handlers[] = { struct lia_handler_entry *lia_handler_by_name(str *name) { - for (u32 i = 0; i < AL_ARRAY_SIZE(liana_handlers); i++) { + for (u32 i = 0; i < ARRAY_SIZE(liana_handlers); i++) { if (al_str_eq(liana_handlers[i].name, name)) { return &liana_handlers[i]; } diff --git a/src/liana/list.c b/src/liana/list.c index 09720b6..94e3fa2 100644 --- a/src/liana/list.c +++ b/src/liana/list.c @@ -12,7 +12,7 @@ static void buffer_ahead(struct lia_list *list) s32 size = (s32)list->entries.size; if (list->queued >= 0 && list->queued + 1 < size) { s32 ahead = list->queued + 1; - for (s32 i = ahead; i < AL_MIN(ahead + LIANA_BUFFER_AHEAD, size); i++) { + for (s32 i = ahead; i < MIN(ahead + LIANA_BUFFER_AHEAD, size); i++) { struct lia_list_entry *buffered = al_array_at(list->entries, i); struct lia_list_sink *sink; al_array_foreach(list->sinks, i, sink) { @@ -151,7 +151,7 @@ static bool handle_add(struct lia_list *list, struct lia_list_entry *entry) sink->set = list->current; sink->callback(sink->userdata, LIANA_SINK_SET, entry, list->current, &time); } - al_log_info("list", "Now playing: %ls.\n", AL_WSTR_PRINTF(&entry->name)); + al_log_info("list", "Now playing: %ls.", AL_WSTR_PRINTF(&entry->name)); } else { /* if (list->queued == -1) { @@ -270,6 +270,7 @@ static bool handle_skipto(struct lia_list *list, s32 sequence, s32 index) bool ended = assume_ended(current, now); bool target_ended = assume_ended(target, now); + al_log_info("list", "ended: %d, target_ended: %d", ended, target_ended); if (ended || current->paused_at == LIANA_TIMESTAMP_INVALID) { if (!ended) { current->paused_at = at; @@ -309,7 +310,7 @@ static bool handle_skipto(struct lia_list *list, s32 sequence, s32 index) sink->callback(sink->userdata, LIANA_SINK_SET, target, index, &time); } - al_log_info("list", "Now playing: %ls.\n", AL_WSTR_PRINTF(&target->name)); + al_log_info("list", "Now playing: %ls.", AL_WSTR_PRINTF(&target->name)); return true; } @@ -403,7 +404,7 @@ static void handle_end(struct lia_list *list, s32 sequence) al_array_foreach(list->sinks, i, sink) { sink->queued = -1; } - al_log_info("list", "Now playing: %ls.\n", AL_WSTR_PRINTF(¤t->name)); + al_log_info("list", "Now playing: %ls.", AL_WSTR_PRINTF(¤t->name)); } else if (next < size) { struct lia_list_cmd *cmd = al_alloc_object(struct lia_list_cmd); cmd->op = SKIPTO; @@ -426,7 +427,7 @@ static void handle_reverse(struct lia_list *list) for (u32 i = 0; i < size; i++) { u32 tail = size - (i + 1); if (tail <= i) break; - AL_SWAP(al_array_at(list->entries, i), al_array_at(list->entries, tail), struct lia_list_entry *); + SWAP(al_array_at(list->entries, i), al_array_at(list->entries, tail)); } unset_all(list, previous); } @@ -445,7 +446,7 @@ static void handle_shuffle(struct lia_list *list) if (size == 0) return; for (u32 i = 0; i < size - 1; i++) { u32 j = i + al_rand() / (AL_RAND_MAX / (size - i) + 1); - AL_SWAP(al_array_at(list->entries, i), al_array_at(list->entries, j), struct lia_list_entry *); + SWAP(al_array_at(list->entries, i), al_array_at(list->entries, j)); } unset_all(list, previous); } diff --git a/src/liana/server.c b/src/liana/server.c index ccca0fd..93ee643 100644 --- a/src/liana/server.c +++ b/src/liana/server.c @@ -3,11 +3,11 @@ #include "server.h" #include "handler.h" #include "handlers.h" -#include "list.h" bool lia_server_init(struct lia_server *server, struct aki_event_loop *loop) { server->loop = loop; + server->increment = 1; al_array_init(server->nodes); al_array_init(server->zombies); return true; @@ -163,7 +163,8 @@ static void signal_callback(void *userdata) return; } if (!conn->errored) { - conn->id = al_inc_u16(); + conn->id = server->increment; + server->increment = al_u16_inc_wrap(server->increment); aki_packet_pool_init(&conn->pool, 96, server->loop, packet_pool_callback, conn); al_array_push(node->connections, conn); handle_connection(conn, packet); @@ -281,7 +282,8 @@ void lia_server_add_socket(struct lia_server *server, struct aki_socket *sock) struct lia_node *lia_server_create_node(struct lia_server *server, struct cch_entry *entry) { struct lia_node *node = al_alloc_object(struct lia_node); - node->id = al_inc_u16(); + node->id = server->increment; + server->increment = al_u16_inc_wrap(server->increment); node->entry = entry; al_array_init(node->connections); node->server = server; diff --git a/src/liana/server.h b/src/liana/server.h index 2ed7c12..11fdfa9 100644 --- a/src/liana/server.h +++ b/src/liana/server.h @@ -44,6 +44,7 @@ struct lia_node { struct lia_server { struct aki_event_loop *loop; + u16 increment; array(struct lia_node *) nodes; array(struct aki_packet_stream *) zombies; }; diff --git a/src/liana/vcr.c b/src/liana/vcr.c index c9e7975..571fe4e 100644 --- a/src/liana/vcr.c +++ b/src/liana/vcr.c @@ -3,7 +3,7 @@ #include "vcr.h" #include "handler.h" -#define VCR_BUFFER_BUFFERED MB(24) +#define VCR_BUFFER_BUFFERED MB(12) enum { VCR_EXPAND_UNTOUCHED = 0, -- cgit v1.2.3-101-g0448