summaryrefslogtreecommitdiff
path: root/src/liana
diff options
context:
space:
mode:
authorAndrew Opalach <andrew@akon.city> 2024-10-22 18:11:37 -0400
committerAndrew Opalach <andrew@akon.city> 2024-10-22 18:11:37 -0400
commit626f299dd3512d44df4bcf95fc7a21b9417c06b0 (patch)
treecff4be789f6125a82a362fbf29c8c1cfa0cc4160 /src/liana
parent60b4ebfbf3be78dba9dc7c65ab2bdaa0b218c0c2 (diff)
downloadcamu-626f299dd3512d44df4bcf95fc7a21b9417c06b0.tar.gz
camu-626f299dd3512d44df4bcf95fc7a21b9417c06b0.tar.bz2
camu-626f299dd3512d44df4bcf95fc7a21b9417c06b0.zip
Various fixes, doc cleanup
Signed-off-by: Andrew Opalach <andrew@akon.city>
Diffstat (limited to 'src/liana')
-rw-r--r--src/liana/client.c22
-rw-r--r--src/liana/client.h3
-rw-r--r--src/liana/handler.h4
-rw-r--r--src/liana/handlers/cdio_server.c1
-rw-r--r--src/liana/list.c4
-rw-r--r--src/liana/list.h21
-rw-r--r--src/liana/meson.build13
-rw-r--r--src/liana/vcr.c6
8 files changed, 33 insertions, 41 deletions
diff --git a/src/liana/client.c b/src/liana/client.c
index d556453..5e33086 100644
--- a/src/liana/client.c
+++ b/src/liana/client.c
@@ -5,6 +5,7 @@
#include "client.h"
#include "handlers.h"
+#include "list.h"
static void data_packet_callback(void *userdata, struct aki_packet_stream *stream, struct aki_packet *packet)
{
@@ -84,9 +85,17 @@ static void parse_info_packet(struct lia_client *client, struct aki_packet *pack
track->client->callback = client->callback;
track->client->userdata = client->userdata;
track->stream.mode = mode;
- if (track->client->init(track->client, client->renderer, &track->stream)) {
- client->callback(client->userdata, LIANA_CLIENT_CONFIGURE, track->client->stream, track);
+ if (!track->client->init(track->client, client->renderer, &track->stream)) {
+ track->client->free(&track->client);
+#if CAMU_HAVE_FFMPEG
+ if (track->stream.mode == CAMU_FFMPEG_COMPAT) {
+ avformat_free_context(track->stream.av.format_context);
+ }
+#endif
+ al_free(track);
+ continue;
}
+ client->callback(client->userdata, LIANA_CLIENT_CONFIGURE, track->client->stream, track);
lia_vcr_add_track(&client->vcr, track);
}
}
@@ -141,6 +150,12 @@ static void connection_closed_callback(void *userdata, struct aki_packet_stream
client->callback(client->userdata, LIANA_CLIENT_REMOVE_BUFFERS, NULL, &client->reconnect);
if (client->reconnect) {
client->reconnect = false;
+ struct lia_timing time = {
+ .at = client->at,
+ .seek_pos = client->pos,
+ .pause = LIANA_PAUSE_NONE
+ };
+ client->callback(client->userdata, LIANA_CLIENT_RESUME_AT, NULL, &time);
aki_packet_stream_reconnect(stream, &client->addr, client->port);
} else {
client->callback(client->userdata, LIANA_CLIENT_CLOSED, NULL, NULL);
@@ -173,10 +188,11 @@ void lia_client_set_renderer(struct lia_client *client, struct camu_renderer *re
client->renderer = renderer;
}
-void lia_client_seek(struct lia_client *client, u64 pos)
+void lia_client_seek(struct lia_client *client, u64 pos, u64 at)
{
client->reconnect = true;
client->pos = pos;
+ client->at = at;
aki_packet_stream_disconnect(&client->data);
}
diff --git a/src/liana/client.h b/src/liana/client.h
index 5c16cd8..24526af 100644
--- a/src/liana/client.h
+++ b/src/liana/client.h
@@ -11,6 +11,7 @@ struct lia_client {
u16 id;
s32 mask;
u64 pos;
+ u64 at;
bool reconnect;
str addr;
u16 port;
@@ -25,7 +26,7 @@ struct lia_client {
void lia_client_connect(struct lia_client *client, struct aki_event_loop *loop, u8 type,
str *addr, u16 port, u16 id, u64 pos, struct camu_renderer *renderer);
-void lia_client_seek(struct lia_client *client, u64 pos);
+void lia_client_seek(struct lia_client *client, u64 pos, u64 at);
void lia_client_reseek(struct lia_client *client);
void lia_client_disconnect(struct lia_client *client);
void lia_client_free(struct lia_client *client);
diff --git a/src/liana/handler.h b/src/liana/handler.h
index 6c23ac5..f994069 100644
--- a/src/liana/handler.h
+++ b/src/liana/handler.h
@@ -25,11 +25,9 @@ enum {
enum {
LIANA_CLIENT_CONFIGURE = 0,
- LIANA_CLIENT_SET,
- LIANA_CLIENT_PAUSE,
- LIANA_CLIENT_RESUME,
LIANA_CLIENT_DATA,
LIANA_CLIENT_REMOVE_BUFFERS,
+ LIANA_CLIENT_RESUME_AT,
LIANA_CLIENT_EOF,
LIANA_CLIENT_CLOSED
};
diff --git a/src/liana/handlers/cdio_server.c b/src/liana/handlers/cdio_server.c
index 1eaf6f3..118f6b5 100644
--- a/src/liana/handlers/cdio_server.c
+++ b/src/liana/handlers/cdio_server.c
@@ -1,5 +1,4 @@
#include <al/log.h>
-#include <cdio/paranoia/cdda.h>
#include "../../cache/entry.h"
#include "../../cache/handlers/cdio.h"
diff --git a/src/liana/list.c b/src/liana/list.c
index 37a144f..18bfd6c 100644
--- a/src/liana/list.c
+++ b/src/liana/list.c
@@ -59,7 +59,7 @@ void lia_list_add_sink(struct lia_list *list, void (*callback)(void *, u8, struc
u64 seek_pos = current->offset;
if (current->paused_at == LIANA_TIMESTAMP_INVALID) {
now += LIANA_BASE_DELAY;
- if (now > current->start) {
+ if (now > current->start && now - current->start > LIANA_BASE_DELAY) {
at = now;
seek_pos += now - current->start;
} else {
@@ -333,7 +333,7 @@ void lia_list_end(struct lia_list *list, s32 sequence)
s32 next = sequence + 1;
list->previous = sequence;
struct lia_list_entry *current = al_array_at(list->entries, list->current);
- //current->offset = current->duration;
+ current->offset = current->duration;
if (list->queued >= 0) {
list->current = list->queued;
list->queued = -1;
diff --git a/src/liana/list.h b/src/liana/list.h
index 8adea17..eb9a3cb 100644
--- a/src/liana/list.h
+++ b/src/liana/list.h
@@ -25,25 +25,10 @@ enum {
LIANA_META_QUEUED
};
-// Pause:
-// - Set `paused_at` to now() + PAUSE_DELAY.
-// - Increment `offset` by how long the entry will have been
-// playing when paused at the requested timestamp (`paused_at` - `start`).
-// Resume:
-// - Unset `paused_at`
-// - Set `start` to now() + PAUSE_DELAY.
-// Next/Prev:
-// Current Playing, Target Playing:
-// - Set `current->held_at` to now() + PAUSE_DELAY.
-// - Increment `current->offset` by the same logic as pause.
-// -
-// Current Playing, Target Paused:
-// Current Paused, Target Playing:
-// Current Paused, Target Paused:
-// Seek:
+// NOTE: To handle an entry being queued right before a skip, keep a global
+// "max time until all sinks buffered" and used that instead of LIANA_PAUSE_DELAY (if greater).
-// NOTE: keep global per list max time until all sinks _should_ by buffered
-// possibly use that instead of LIANA_PAUSE_DELAY.
+// TODO: Factor in LIANA_BASE_PING.
enum {
LIANA_PAUSE_NONE = 0,
diff --git a/src/liana/meson.build b/src/liana/meson.build
index 0859e99..da53214 100644
--- a/src/liana/meson.build
+++ b/src/liana/meson.build
@@ -13,23 +13,12 @@ liana_client_src = [
liana_deps = [codecs]
liana_args = []
-libcdio_paranoia = dependency('libcdio_paranoia', required: false, allow_fallback: true)
-libcdio_cdda = dependency('libcdio_cdda', required: false, allow_fallback: true)
-if libcdio_paranoia.found() and libcdio_cdda.found()
+if cache_have_cdio
liana_server_src += ['handlers/cdio_server.c']
liana_client_src += ['handlers/cdio_client.c']
- liana_deps += [libcdio_paranoia, libcdio_cdda]
liana_args += ['-DLIANA_HAVE_CDIO']
endif
-#libdvdcss = dependency('libdvdcss', required: false, allow_fallback: true)
-#libdvdread = dependency('libdvdread', required: false, allow_fallback: true)
-#libdvdnav = dependency('libdvdnav', required: false, allow_fallback: true)
-#if libdvdcss.found() and libdvdread.found() and libdvdnav.found()
-# liana_server_src += ['handlers/dvd_server.c']
-# liana_server_deps += [libdvdcss]
-#endif
-
liana_server = declare_dependency(sources: liana_server_src, dependencies: liana_deps,
compile_args: [liana_args, '-DLIANA_SERVER'])
liana_client = declare_dependency(sources: liana_client_src, dependencies: liana_deps,
diff --git a/src/liana/vcr.c b/src/liana/vcr.c
index fad8b78..39fe0fe 100644
--- a/src/liana/vcr.c
+++ b/src/liana/vcr.c
@@ -123,7 +123,11 @@ bool lia_vcr_push_packet(struct lia_vcr *vcr, struct aki_packet *packet)
switch (op) {
case LIANA_PACKET_DATA:
track = get_track_from_index(vcr, aki_packet_read_s32(packet));
- al_assert(track);
+ if (!track) {
+ al_log_warn("liana", "Received data from errored or unknown track.");
+ aki_packet_free(packet);
+ return false;
+ }
if (!track->running) {
aki_thread_create(&track->thread, vcr_track_thread, track);
track->running = true;