diff options
Diffstat (limited to 'src/server')
| -rw-r--r-- | src/server/common.h | 3 | ||||
| -rw-r--r-- | src/server/resource.h | 5 | ||||
| -rw-r--r-- | src/server/server.c | 66 |
3 files changed, 45 insertions, 29 deletions
diff --git a/src/server/common.h b/src/server/common.h index 0d47f48..b939974 100644 --- a/src/server/common.h +++ b/src/server/common.h @@ -47,7 +47,8 @@ enum { enum { CAMU_RESOURCE_FILE = 0, - CAMU_RESOURCE_PORTAL + CAMU_RESOURCE_PORTAL, + CAMU_RESOURCE_CDIO }; AL_UNUSED_FUNCTION_PUSH diff --git a/src/server/resource.h b/src/server/resource.h index 87250e9..6056e8e 100644 --- a/src/server/resource.h +++ b/src/server/resource.h @@ -27,3 +27,8 @@ struct camu_resource_portal { struct camu_resource r; struct camu_post *post; }; + +struct camu_resource_cdio { + struct camu_resource r; + u32 track; +}; diff --git a/src/server/server.c b/src/server/server.c index 57d7d7b..a72a1b1 100644 --- a/src/server/server.c +++ b/src/server/server.c @@ -3,6 +3,7 @@ #include "../cache/handlers/file.h" #include "../cache/handlers/http.h" +#include "../cache/handlers/cdio.h" #include "../libclient/common.h" #include "../libsink/common.h" #ifdef CAMU_HAVE_PORTAL @@ -148,6 +149,7 @@ static void list_sink_callback(void *userdata, u8 op, struct lia_list_entry *ent aki_packet_write_u64(packet, timing->at); aki_packet_write_u64(packet, timing->seek_pos); aki_packet_write_u8(packet, timing->pause); + aki_packet_write_bool(packet, timing->previous_ended); aki_packet_write_bool(packet, timing->ended); aki_rpc_connection_command(sink->conn, packet, NULL, NULL); break; @@ -298,26 +300,20 @@ out: static void handle_add_command(struct camu_server *server, struct lia_list *list, struct aki_packet *packet) { u8 op = aki_packet_read_u8(packet); + struct cch_entry *entry = NULL; + struct camu_resource *resource; + wstr name; switch (op) { case CAMU_RESOURCE_FILE: { str path; aki_packet_read_str(packet, &path); - struct cch_entry *entry = cch_handler_file_create(&path); + entry = cch_handler_file_create(&path); if (!entry) return; - struct camu_resource_file *resource = al_alloc_object(struct camu_resource_file); - resource->r.type = CAMU_RESOURCE_FILE; - resource->r.load = CAMU_RESOURCE_NOT_LOADED; - al_str_clone(&resource->path, &path); - resource->r.entry = entry; - resource->r.node = lia_server_create_node(&server->data.server, resource->r.entry); - resource->r.node->callback = node_callback; - resource->r.node->userdata = (struct camu_resource *)resource; - resource->r.duration = LIANA_TIMESTAMP_INVALID; - al_array_init(resource->r.pending); - wstr name; + struct camu_resource_file *file = al_alloc_object(struct camu_resource_file); + al_str_clone(&file->path, &path); al_wstr_from_str(&name, &path); - lia_list_add(list, resource, resource->r.duration, &name); - al_wstr_free(&name); + resource = (struct camu_resource *)file; + resource->type = CAMU_RESOURCE_FILE; break; } case CAMU_RESOURCE_PORTAL: { @@ -325,7 +321,7 @@ static void handle_add_command(struct camu_server *server, struct lia_list *list aki_packet_read_str(packet, &unique_id); u32 index = aki_packet_read_u32(packet); struct camu_post *post = camu_post_cache_get(&server->cache, &unique_id); - struct cch_entry *entry = NULL; + entry = NULL; if (index <= post->media.size) { struct camu_post_media *media = &al_array_at(post->media, index); if (!al_str_is_empty(&media->url)) { @@ -336,22 +332,36 @@ static void handle_add_command(struct camu_server *server, struct lia_list *list al_log_warn("server", "Failed to load resource %.*s %u.", AL_STR_PRINTF(&unique_id), index); return; } - struct camu_resource_portal *resource = al_alloc_object(struct camu_resource_portal); - resource->r.type = CAMU_RESOURCE_PORTAL; - resource->r.load = CAMU_RESOURCE_NOT_LOADED; - resource->post = post; - resource->r.entry = entry; - struct cch_handler *handler = resource->r.entry->handler; - handler->maybe_spawn_worker(handler, 0); - resource->r.node = lia_server_create_node(&server->data.server, resource->r.entry); - resource->r.node->callback = node_callback; - resource->r.node->userdata = (struct camu_resource *)resource; - resource->r.duration = LIANA_TIMESTAMP_INVALID; - al_array_init(resource->r.pending); - lia_list_add(list, resource, resource->r.duration, &resource->post->title); + entry->handler->maybe_spawn_worker(entry->handler, 0); + struct camu_resource_portal *portal = al_alloc_object(struct camu_resource_portal); + portal->post = post; + al_wstr_clone(&name, &post->title); + resource = (struct camu_resource *)portal; + resource->type = CAMU_RESOURCE_PORTAL; + break; + } + case CAMU_RESOURCE_CDIO: { + u32 track = aki_packet_read_u32(packet); + entry = cch_handler_cdio_create(); + struct cch_chapter *chapter = &al_array_at(entry->chapters, track); + entry->handler->maybe_spawn_worker(entry->handler, chapter->start); + struct camu_resource_cdio *cdio = al_alloc_object(struct camu_resource_cdio); + cdio->track = track; + al_wstr_from_cstr(&name, "cdio"); + resource = (struct camu_resource *)cdio; + resource->type = CAMU_RESOURCE_CDIO; break; } } + resource->load = CAMU_RESOURCE_NOT_LOADED; + resource->entry = entry; + resource->node = lia_server_create_node(&server->data.server, resource->entry); + resource->node->callback = node_callback; + resource->node->userdata = resource; + resource->duration = LIANA_TIMESTAMP_INVALID; + al_array_init(resource->pending); + lia_list_add(list, resource, resource->duration, &name); + al_wstr_free(&name); } static bool list_action_callback(void *userdata, struct aki_rpc_connection *conn, |