diff options
Diffstat (limited to 'src/libsink')
| -rw-r--r-- | src/libsink/sink.c | 43 |
1 files changed, 38 insertions, 5 deletions
diff --git a/src/libsink/sink.c b/src/libsink/sink.c index 0f56c5b..951b230 100644 --- a/src/libsink/sink.c +++ b/src/libsink/sink.c @@ -12,6 +12,7 @@ #include "common.h" //#define CAMU_SINK_ONESHOT +//#define CAMU_SINK_TRACE #ifndef CAMU_SINK_NO_VIDEO #include "../render/renderer_libplacebo.h" @@ -191,6 +192,10 @@ static void remove_entry_video_buffer(struct camu_sink *sink, struct camu_sink_e // add_audio/video_if_set_and_buffered() no-ops for ENDED buffers. static void remove_entry_buffers(struct camu_sink *sink, struct camu_sink_entry *entry) { +#ifdef CAMU_SINK_TRACE + al_log_info("sink", "remove_entry_buffers(0x%llx), audio_state: %hhu, video_state: %hhu", + entry, entry->audio.state, entry->video.state); +#endif al_assert(!entry->ended); if (entry->audio.state != BUFFER_ENDED) { remove_entry_audio_buffer(sink, entry); @@ -446,10 +451,14 @@ static void mixer_callback(void *userdata, u8 op) struct camu_sink *sink = (struct camu_sink *)userdata; if (op == CAMU_MIXER_EMPTY) { al_log_info("sink", "Mixer empty."); +#ifndef LIANA_LIST_SCUFFED_LOOP queue_cmd(sink, (struct camu_sink_cmd){ .op = STOP, .value.i = CAMU_SINK_AUDIO }); +#else + (void)sink; +#endif } } @@ -483,6 +492,9 @@ bool camu_sink_init(struct camu_sink *sink, struct nn_event_loop *loop, static void maybe_remove_previous(struct camu_sink *sink) { +#ifdef CAMU_SINK_TRACE + al_log_info("sink", "maybe_remove_previous(), previous_count: %u", sink->previous.count); +#endif struct camu_sink_entry *previous; al_array_foreach(sink->previous, i, previous) { remove_entry_buffers(sink, previous); @@ -495,6 +507,9 @@ static void maybe_remove_previous(struct camu_sink *sink) // An obvious example of this is at the point an entry gets freed. See LIANA_CLIENT_REMOVE_BUFFERS. static void maybe_remove_from_previous(struct camu_sink *sink, struct camu_sink_entry *entry) { +#ifdef CAMU_SINK_TRACE + al_log_info("sink", "maybe_remove_from_previous(0x%llx)", entry); +#endif al_array_remove_all(sink->previous, entry); } @@ -502,6 +517,11 @@ static void maybe_remove_from_previous(struct camu_sink *sink, struct camu_sink_ static void maybe_add_to_previous(struct camu_sink *sink, struct camu_sink_entry *previous, struct camu_sink_entry *target) { +#ifdef CAMU_SINK_TRACE + al_log_info("sink", "maybe_add_to_previous(0x%llx, 0x%llx), audio_state: %hhu, video_state: %hhu", + previous, target, previous->audio.state, previous->video.state); +#endif + al_assert(previous != target && !previous->ended); struct camu_sink_entry *entry; @@ -663,6 +683,9 @@ void add_video_if_set_and_buffered(struct camu_sink_entry *entry) static void switch_to(struct camu_sink *sink, struct camu_sink_entry *target) { +#ifdef CAMU_SINK_TRACE + al_log_info("sink", "switch_to(0x%llx)", target); +#endif if (sink->current) { struct camu_sink_entry *current = sink->current; al_assert(current != target); @@ -862,6 +885,9 @@ static void clock_callback(void *userdata, u8 op) struct camu_sink_entry *entry = (struct camu_sink_entry *)userdata; struct camu_sink *sink = entry->sink; if (op == CAMU_CLOCK_PAUSED) { +#ifdef CAMU_SINK_TRACE + al_log_info("sink", "clock_callback(), target: 0x%llx", sink->target); +#endif nn_mutex_lock(&sink->mutex); if (entry == sink->current && sink->target) { switch_to(sink, sink->target); @@ -1035,10 +1061,17 @@ static void client_callback(void *userdata, u8 op, struct camu_codec_stream *str } } - // We need to call this if entry was added to previous then, + // Entry might be in previous here if it was added to previous then, // - it's being cleaned up after ENTRY_MAX_AGE - 1 entries were added but none buffered. // - it was seeked. - maybe_remove_from_previous(sink, entry); + //maybe_remove_from_previous(sink, entry); + struct camu_sink_entry *previous; + al_array_foreach(sink->previous, i, previous) { + if (previous == entry) { + maybe_remove_previous(sink); + break; + } + } bool skip_audio = sink->audio.state == SINK_PAUSED; if (entry->audio.state == BUFFER_ADDED) { @@ -1164,7 +1197,7 @@ static void client_callback(void *userdata, u8 op, struct camu_codec_stream *str } bool removed; - al_array_check_remove(sink->entries, entry, removed); + al_array_remove_checked(sink->entries, entry, removed); nn_mutex_unlock(&sink->mutex); @@ -1173,10 +1206,9 @@ static void client_callback(void *userdata, u8 op, struct camu_codec_stream *str #ifndef CAMU_SINK_NO_VIDEO camu_video_buffer_free(&entry->video.buf); #endif + al_log_info("sink", "Entry (0x%llx) closed by %s.", entry, removed ? "disconnect" : "cleanup"); al_free(entry); - al_log_info("sink", "Entry closed by %s.", removed ? "disconnect" : "cleanup"); - break; } } @@ -1307,6 +1339,7 @@ static bool set_command_callback(void *userdata, struct nn_rpc_connection *conn, camu_clock_resume(&entry->clock, 0); } + al_assert(entry != current); switch_to(sink, entry); #else switch (pause) { |