#include "../client.h" #include "cdio.h" static bool cdio_client_init(struct lia_client_handler *handler, struct camu_renderer *renderer, struct camu_codec_stream *stream) { struct lia_cdio_client *cdio = (struct lia_cdio_client *)handler; (void)renderer; cdio->handler.stream = stream; return true; } static bool cdio_client_handle_packet(struct lia_client_handler *handler, struct nn_packet *packet) { struct lia_cdio_client *cdio = (struct lia_cdio_client *)handler; if (!packet) { cdio->handler.callback(cdio->handler.userdata, LIANA_CLIENT_EOF, cdio->handler.stream, NULL); return true; } struct camu_codec_frame *frame = al_alloc_object(struct camu_codec_frame); frame->mode = CAMU_NORMAL; frame->pts = nn_packet_read_f64(packet); frame->audio.sample_count = nn_packet_read_s32(packet); struct nn_buffer buffer; nn_packet_read_buffer(packet, &buffer); frame->data = (u8 *)al_malloc(buffer.size); al_memcpy(frame->data, nn_buffer_get_ptr(&buffer, 0), buffer.size); cdio->handler.callback(cdio->handler.userdata, LIANA_CLIENT_DATA, cdio->handler.stream, frame); return true; } static void cdio_client_flush(struct lia_client_handler *handler) { (void)handler; } static void cdio_client_free(struct lia_client_handler **handler) { (void)handler; } struct lia_client_handler *lia_cdio_client_create(void) { struct lia_cdio_client *cdio = al_alloc_object(struct lia_cdio_client); cdio->handler.init = cdio_client_init; cdio->handler.handle_packet = cdio_client_handle_packet; cdio->handler.flush = cdio_client_flush; cdio->handler.free = cdio_client_free; return (struct lia_client_handler *)cdio; }