From 37684729283f62fd7f1e74bc2b318dc9ad2cb695 Mon Sep 17 00:00:00 2001 From: Andrew Opalach Date: Fri, 17 Jan 2025 12:12:01 -0500 Subject: Account for dependency changes, platform testing Signed-off-by: Andrew Opalach --- src/libsink/sink.c | 25 +++++++++++++++---------- src/libsink/sink.h | 1 + 2 files changed, 16 insertions(+), 10 deletions(-) (limited to 'src/libsink') diff --git a/src/libsink/sink.c b/src/libsink/sink.c index 03f76b7..0f56c5b 100644 --- a/src/libsink/sink.c +++ b/src/libsink/sink.c @@ -11,6 +11,8 @@ #include "sink.h" #include "common.h" +//#define CAMU_SINK_ONESHOT + #ifndef CAMU_SINK_NO_VIDEO #include "../render/renderer_libplacebo.h" #endif @@ -58,8 +60,6 @@ enum { // If a buffer is still INIT or QUEUED after the entry is configured, it's "empty". #define BUFFER_EMPTY(buf) ((buf)->state == BUFFER_INIT || (buf)->state == BUFFER_QUEUED) -#define BUFFER_NOT_EMPTY(buf) (!BUFFER_EMPTY(buf)) - #define AUDIO_EMPTY(entry) BUFFER_EMPTY(&(entry)->audio) #ifndef CAMU_SINK_NO_VIDEO #define VIDEO_EMPTY(entry) BUFFER_EMPTY(&(entry)->video) @@ -487,7 +487,7 @@ static void maybe_remove_previous(struct camu_sink *sink) al_array_foreach(sink->previous, i, previous) { remove_entry_buffers(sink, previous); } - sink->previous.size = 0; + sink->previous.count = 0; } // Due to the looseness of the previous queue, we may have to explicitly remove an entry @@ -558,7 +558,7 @@ static void maybe_cleanup_old_entries(struct camu_sink *sink) al_array_remove_at(sink->entries, i); lia_client_disconnect(&entry->client); } - if (sink->entries.size <= ENTRY_MAX_AGE) return; + if (sink->entries.count <= ENTRY_MAX_AGE) return; } // Checking sink->lru >= ENTRY_MAX_AGE should guarantee @@ -570,7 +570,7 @@ static void maybe_cleanup_old_entries(struct camu_sink *sink) al_array_remove_at(sink->entries, i); lia_client_disconnect(&entry->client); } - if (sink->entries.size <= ENTRY_MAX_AGE) return; + if (sink->entries.count <= ENTRY_MAX_AGE) return; } } } @@ -714,6 +714,10 @@ static void pause_and_swap_to(struct camu_sink *sink, struct camu_sink_entry *ta static bool end_entry_and_advance_queue(struct camu_sink *sink, struct camu_sink_entry *entry) { al_log_info("sink", "Entry ended."); +#ifdef CAMU_SINK_ONESHOT + sink->callback(sink->userdata, CAMU_SINK_MOCK_CLOSE, 0, NULL); + return false; +#endif entry->ended = true; queue_cmd(sink, (struct camu_sink_cmd){ .op = END, @@ -743,6 +747,7 @@ static void audio_buffer_callback(void *userdata, u8 op) struct camu_sink *sink = entry->sink; switch (op) { case CAMU_BUFFER_BUFFERED: + lia_vcr_set_buffered(entry->audio.track); nn_mutex_lock(&sink->mutex); add_audio_if_set_and_buffered(entry); nn_mutex_unlock(&sink->mutex); @@ -765,7 +770,6 @@ static void audio_buffer_callback(void *userdata, u8 op) nn_mutex_unlock(&sink->mutex); break; case CAMU_BUFFER_EOF: { - lia_vcr_set_buffered(entry->audio.track); nn_mutex_lock(&sink->mutex); al_log_info("sink", "Audio EOF."); if (entry->audio.state == BUFFER_ADDED) { @@ -797,6 +801,7 @@ static void video_buffer_callback(void *userdata, u8 op) struct camu_sink *sink = entry->sink; switch (op) { case CAMU_BUFFER_BUFFERED: { + lia_vcr_set_buffered(entry->video.track); nn_mutex_lock(&sink->mutex); add_video_if_set_and_buffered(entry); nn_mutex_unlock(&sink->mutex); @@ -809,7 +814,6 @@ static void video_buffer_callback(void *userdata, u8 op) lia_vcr_uncork(entry->video.track); break; case CAMU_BUFFER_EOF: { - lia_vcr_set_buffered(entry->video.track); bool swapped = false; nn_mutex_lock(&sink->mutex); al_log_info("sink", "Video EOF."); @@ -867,7 +871,7 @@ static void clock_callback(void *userdata, u8 op) } } -static void evaluate_latency(struct camu_sink *sink, struct camu_sink_entry *entry) +static void evaluate_and_set_latency(struct camu_sink *sink, struct camu_sink_entry *entry) { #ifdef CAMU_SINK_LOCAL #ifndef CAMU_SINK_NO_VIDEO @@ -933,7 +937,7 @@ static void client_callback(void *userdata, u8 op, struct camu_codec_stream *str al_assert(false); } if (VIDEO_ADDED_OR_EMPTY(entry)) { - evaluate_latency(sink, entry); + evaluate_and_set_latency(sink, entry); } nn_mutex_unlock(&sink->mutex); break; @@ -954,7 +958,7 @@ static void client_callback(void *userdata, u8 op, struct camu_codec_stream *str al_assert(false); } if (AUDIO_ADDED_OR_EMPTY(entry)) { - evaluate_latency(sink, entry); + evaluate_and_set_latency(sink, entry); } nn_mutex_unlock(&sink->mutex); break; @@ -1292,6 +1296,7 @@ static bool set_command_callback(void *userdata, struct nn_rpc_connection *conn, struct camu_sink_entry *current = sink->current; #ifdef CAMU_SINK_LOCAL + (void)at; if (current && !current->ended && !camu_clock_is_paused(¤t->clock)) { camu_clock_pause(¤t->clock, 0); } diff --git a/src/libsink/sink.h b/src/libsink/sink.h index 10fc182..68fac15 100644 --- a/src/libsink/sink.h +++ b/src/libsink/sink.h @@ -29,6 +29,7 @@ enum { CAMU_SINK_START, CAMU_SINK_STOP, CAMU_SINK_CLEAR, + CAMU_SINK_MOCK_CLOSE, CAMU_SINK_EXIT }; -- cgit v1.2.3-101-g0448