diff options
| -rw-r--r-- | src/buffer/audio.c | 9 | ||||
| -rw-r--r-- | src/cache/handlers/http.c | 5 | ||||
| -rw-r--r-- | src/cache/range.h | 6 | ||||
| -rw-r--r-- | src/liana/client.c | 2 | ||||
| -rw-r--r-- | src/liana/list.c | 5 | ||||
| -rw-r--r-- | src/liana/list.h | 8 | ||||
| -rw-r--r-- | src/liana/server.c | 15 | ||||
| -rw-r--r-- | src/liana/vcr.c | 6 | ||||
| -rw-r--r-- | src/libsink/sink.c | 8 | ||||
| -rw-r--r-- | src/server/server.c | 2 | ||||
| -rw-r--r-- | subprojects/libalabaster.wrap | 2 | ||||
| -rw-r--r-- | subprojects/libnaunet.wrap | 2 |
12 files changed, 36 insertions, 34 deletions
diff --git a/src/buffer/audio.c b/src/buffer/audio.c index ce027af..2e65a97 100644 --- a/src/buffer/audio.c +++ b/src/buffer/audio.c @@ -166,7 +166,7 @@ static bool push_internal(struct camu_audio_buffer *buf, f64 pts, u8 **data, s32 peak += have; if (peak >= buf->mark.min) { // If this happens the writer of this buffer is taking way too long to stop. - al_log_warn("audio_buffer", "Overrun likely, discarding peak buffer."); + al_log_warn("audio_buffer", "Overrun likely, discarding peak buffer (audio will be desynced)."); camu_peak_buffer_flush(&buf->peak); peak = 0; } @@ -256,8 +256,8 @@ void camu_audio_buffer_unpause(struct camu_audio_buffer *buf) al_atomic_add(s32)(&buf->unpause, 1, AL_ATOMIC_RELAXED); } -// PAUSE_PAUSED signifies that the last read was silence. Meaning we can skip -// around in the buffer without worrying about pops. +// PAUSE_PAUSED signifies that the last read was silence. +// This means we can skip around in the buffer without worrying about pops. ptrdiff_t camu_audio_buffer_read(struct camu_audio_buffer *buf, u8 *data, ptrdiff_t req) { if (al_atomic_load(s32)(&buf->volume.set, AL_ATOMIC_ACQUIRE) > 0) { @@ -317,6 +317,9 @@ ptrdiff_t camu_audio_buffer_read(struct camu_audio_buffer *buf, u8 *data, ptrdif else have -= buf->fade.offset; #endif + // @NOTE: We are not safe to increment buf->pts from a different thread. + // We would need to accumulate the difference and do an atomic add instead + // of the load/store we do here. f64 base_pts = al_atomic_load(f64)(&buf->pts, AL_ATOMIC_ACQUIRE); // Unpause and possibly attempt syncing to the clock. if (UNLIKELY(buf->pause == PAUSE_PAUSED)) { diff --git a/src/cache/handlers/http.c b/src/cache/handlers/http.c index 3bbb751..b34e4ba 100644 --- a/src/cache/handlers/http.c +++ b/src/cache/handlers/http.c @@ -1,8 +1,7 @@ -#include <al/random.h> #include <al/log.h> #include "../backings/memory.h" -#include "../backings/file.h" +//#include "../backings/file.h" #include "../threaded_waits.h" #include "../wait.h" @@ -41,7 +40,7 @@ static void http_callback(void *userdata, u8 op, u8 *buf, void *opaque) } case NNWT_HTTP_CONTENT_LENGTH: { curl_off_t length = *(curl_off_t *)opaque; - al_log_debug("cache_handler_http", "Content-Length: %lld.", length); + al_log_debug("cache_handler_http", "Content-Length: %"CURL_FORMAT_CURL_OFF_T".", length); cch_entry_set_size(http->handler.entry, length); cch_threaded_waits_signal_any(&http->handler); break; diff --git a/src/cache/range.h b/src/cache/range.h index 603117e..9ec1159 100644 --- a/src/cache/range.h +++ b/src/cache/range.h @@ -4,9 +4,9 @@ AL_UNUSED_FUNCTION_PUSH -// TODO: cch_backing_remove_range. -// -// TODO: report overlap, don't unlock in backing_write() and handle fill in handler +// @TODO: +// cch_backing_remove_range(). +// Report overlap, don't unlock in backing_write() and handle fill in handler. static void cch_backing_fill_range(struct cch_backing *backing, off_t index, off_t size) { diff --git a/src/liana/client.c b/src/liana/client.c index 09280cb..c847ac4 100644 --- a/src/liana/client.c +++ b/src/liana/client.c @@ -22,7 +22,7 @@ static void parse_info_packet(struct lia_client *client, struct nn_packet *packe str liana; nn_packet_read_str(packet, &liana); client->duration = nn_packet_read_u64(packet); - // TODO: This should be made into 2 steps. + // @TODO: This should be made into 2 steps. // 1. Collect all streams into an array // 2. Perform selection based on prefrences. bool have_audio = false; diff --git a/src/liana/list.c b/src/liana/list.c index 94ff3bf..db7d54c 100644 --- a/src/liana/list.c +++ b/src/liana/list.c @@ -301,9 +301,6 @@ static struct lia_list_entry *get_entry_from_id(struct lia_list *list, u32 id, s return NULL; } -// TODO: -//if (current->start != LIANA_TIMESTAMP_INVALID && current->start > ts - LIANA_BASE_PING) { - static bool handle_skipto(struct lia_list *list, s32 sequence, s32 index) { if (index == list->current) return true; @@ -844,7 +841,7 @@ void lia_list_clear(struct lia_list *list) void lia_list_close(struct lia_list *list) { - // TODO: Consider sinks being in use. Wait for list->sinks to be empty? + // @TODO: Consider sinks being in use. Wait for list->sinks to be empty? struct lia_list_entry *entry; al_array_foreach(list->entries, i, entry) { list->callback(list->userdata, LIANA_UNLOAD_ENTRY, entry, NULL); diff --git a/src/liana/list.h b/src/liana/list.h index e61074c..125dba6 100644 --- a/src/liana/list.h +++ b/src/liana/list.h @@ -16,10 +16,10 @@ //#define LIANA_LIST_SCUFFED_LOOP -// 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). - -// TODO: Factor in LIANA_BASE_PING. +// @TODO: +// 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). +// Factor in LIANA_BASE_PING enum { LIANA_SINK_SET = 0, diff --git a/src/liana/server.c b/src/liana/server.c index 2e74d1e..04b5d96 100644 --- a/src/liana/server.c +++ b/src/liana/server.c @@ -1,5 +1,3 @@ -#include <al/random.h> - #include "server.h" #include "handler.h" #include "handlers.h" @@ -101,7 +99,7 @@ static void free_connection_stream(struct lia_node_connection *conn) conn->ref = false; } -static void disable_connection(struct lia_node_connection *conn) +static void disable_connection_and_wait(struct lia_node_connection *conn) { nn_packet_pool_disable(&conn->pool); cch_handle_disable(&conn->handle); @@ -120,7 +118,7 @@ static void data_connection_closed_callback(void *userdata, struct nn_packet_str (void)stream; // We will never be here if init_thread() blocks or fails. - disable_connection(conn); + disable_connection_and_wait(conn); free_connection_stream(conn); @@ -209,7 +207,11 @@ static void packet_sent_callback(void *userdata, struct nn_packet *packet) static void demote_and_disconnect_stream(struct lia_server *server, struct nn_packet_stream *stream) { - // This connection is now nothing but a packet stream. + // Discard queue based on the currently set packet_sent_callback. + // This should always be the expected behavior but here it's mainly to + // not lose packets that belong to the packet pool. + nn_packet_stream_discard_queue(stream); + // This connection will now be nothing but a packet stream. stream->userdata = server; stream->connection_closed_callback = connection_closed_callback; stream->packet_callback = discard_packet_callback; @@ -322,13 +324,12 @@ static void packet_callback(void *userdata, struct nn_packet_stream *stream, str stream->connection_closed_callback = pre_init_connection_closed_callback; nn_thread_create(&conn->thread, init_thread, conn); } else { - // Connections never get removed from node->connection. if ((conn = get_connection_from_id(node, connection_id))) { if (conn->ref) { // Cleanup the existing connection's handler and demote it's stream. // The stream was likely already disconnected client-side but it's still safe // to disconnect it here to be sure. - disable_connection(conn); + disable_connection_and_wait(conn); demote_and_disconnect_stream(server, conn->stream); conn->ref = false; enable_connection(conn); diff --git a/src/liana/vcr.c b/src/liana/vcr.c index 33f3365..c6f6d93 100644 --- a/src/liana/vcr.c +++ b/src/liana/vcr.c @@ -378,8 +378,10 @@ void lia_vcr_close_all(struct lia_vcr *vcr) { struct lia_vcr_track *track; al_array_foreach(vcr->tracks, i, track) { - vcr_track_close_internal(track); - return_entire_cache(track); + if (VCR_TRACK_THREADED(track)) { + vcr_track_close_internal(track); + return_entire_cache(track); + } } vcr->started = false; #ifndef CAMU_DIRECT_MODE diff --git a/src/libsink/sink.c b/src/libsink/sink.c index 951b230..b5e2a65 100644 --- a/src/libsink/sink.c +++ b/src/libsink/sink.c @@ -504,7 +504,7 @@ static void maybe_remove_previous(struct camu_sink *sink) // Due to the looseness of the previous queue, we may have to explicitly remove an entry // if it becomes incorrect to attempt removing it's buffers. -// An obvious example of this is at the point an entry gets freed. See LIANA_CLIENT_REMOVE_BUFFERS. +// An obvious example of this is at the point an entry gets freed. static void maybe_remove_from_previous(struct camu_sink *sink, struct camu_sink_entry *entry) { #ifdef CAMU_SINK_TRACE @@ -875,7 +875,7 @@ static void maybe_unset_current(struct camu_sink *sink) if (!sink->current->ended) { remove_entry_buffers(sink, sink->current); } - // TODO: A current-less state is not properly handled. + // @TODO: A current-less state is not properly handled. sink->current = NULL; } } @@ -991,7 +991,7 @@ static void client_callback(void *userdata, u8 op, struct camu_codec_stream *str case CAMU_STREAM_SUBTITLE: #ifdef CAMU_HAVE_FFMPEG if (!camu_video_buffer_configure_subtitles(&entry->video.buf, stream->av.stream->codecpar)) { - // TODO: + // @TODO: } #endif break; @@ -1174,6 +1174,7 @@ static void client_callback(void *userdata, u8 op, struct camu_codec_stream *str break; } case LIANA_CLIENT_CLOSED: { + // LIANA_CLIENT_REMOVE_BUFFERS has been called on this entry before we're here. nn_mutex_lock(&sink->mutex); if (entry == sink->target) { @@ -1184,7 +1185,6 @@ static void client_callback(void *userdata, u8 op, struct camu_codec_stream *str al_assert(sink->reconnecting == sink->current); sink->reconnecting = NULL; } - // current's buffers will already be removed. sink->current = NULL; if (sink->target) { switch_to(sink, sink->target); diff --git a/src/server/server.c b/src/server/server.c index cef05b0..9a6636d 100644 --- a/src/server/server.c +++ b/src/server/server.c @@ -654,7 +654,7 @@ static struct nn_rpc_command commands[] = { static void connection_callback(void *userdata, struct nn_rpc_connection *conn) { - // TODO: Cleanup zombie connections. + // @TODO: Cleanup zombie connections. (void)userdata; (void)conn; } diff --git a/subprojects/libalabaster.wrap b/subprojects/libalabaster.wrap index cceb244..6ecfc88 100644 --- a/subprojects/libalabaster.wrap +++ b/subprojects/libalabaster.wrap @@ -1,4 +1,4 @@ [wrap-git] url = https://git.akon.city/libalabaster -revision = 562c730ac38749fb43ae5b7b53ae5f3043166bd1 +revision = d8141e0ca0c53a3e2d89f20e3c89cdec5a4593e4 depth = 1 diff --git a/subprojects/libnaunet.wrap b/subprojects/libnaunet.wrap index 7cce0e2..ab2d0fd 100644 --- a/subprojects/libnaunet.wrap +++ b/subprojects/libnaunet.wrap @@ -1,4 +1,4 @@ [wrap-git] url = https://git.akon.city/libnaunet -revision = e48874a91a86ef561aa4b3298d6170ec9777954e +revision = 7a23e4015766ae98a5f5f65e0c1aa588a491d296 depth = 1 |