From 24b58a516e6bacfdf59aac422411c2f1fcf4ffb2 Mon Sep 17 00:00:00 2001 From: Andrew Opalach Date: Wed, 1 Jan 2025 16:04:59 -0500 Subject: Optimizations based on video loop performance - Support nn_packet_stream direct mode - Hook up FFmpeg hardware accelerated decoding - Refactor VCR - Reduce locking when returning packets to a packet pool Signed-off-by: Andrew Opalach --- src/cache/handlers/http.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'src/cache/handlers') diff --git a/src/cache/handlers/http.c b/src/cache/handlers/http.c index 308633e..b5f2504 100644 --- a/src/cache/handlers/http.c +++ b/src/cache/handlers/http.c @@ -16,36 +16,41 @@ static bool handler_http_can_seek(struct cch_handler *handler) return false; } -static size_t http_callback(void *userdata, u8 op, u8 *buf, s64 int0) +static void http_callback(void *userdata, u8 op, u8 *buf, void *opaque) { struct cch_handler_http *http = (struct cch_handler_http *)userdata; - size_t ret = (size_t)int0; switch (op) { case NNWT_HTTP_READ: - al_assert_and_return(0); + al_assert(false); case NNWT_HTTP_WRITE: { + size_t n = *(size_t *)opaque; // If we got data before a Content-Length, assume the size is unknown. if (cch_entry_get_size(http->handler.entry) < 0) { cch_entry_set_size(http->handler.entry, 0); } - http->backing->write(http->backing, buf, http->pointer, &ret); - http->pointer += ret; + http->backing->write(http->backing, buf, http->pointer, &n); + http->pointer += n; + *(size_t *)opaque = n; cch_threaded_waits_evaluate(&http->handler, http->backing); break; } - case NNWT_HTTP_RESPONSE_CODE: - al_log_debug("cache_handler_http", "HTTP %ld.", int0); + case NNWT_HTTP_RESPONSE_CODE: { + long response_code = *(long *)opaque; + al_log_debug("cache_handler_http", "HTTP %ld.", response_code); break; + } case NNWT_HTTP_CONTENT_LENGTH: { - off_t content_length = (off_t)int0; - al_log_debug("cache_handler_http", "Content-Length: %lld.", content_length); - cch_entry_set_size(http->handler.entry, content_length); + curl_off_t length = *(curl_off_t *)opaque; + al_log_debug("cache_handler_http", "Content-Length: %lld.", length); + cch_entry_set_size(http->handler.entry, length); cch_threaded_waits_signal_any(&http->handler); break; } - case NNWT_HTTP_REDIRECT: - al_log_debug("cache_handler_http", "Redirect %ld.", int0); + case NNWT_HTTP_REDIRECT: { + long response_code = *(long *)opaque; + al_log_debug("cache_handler_http", "Redirect %ld.", response_code); break; + } case NNWT_HTTP_FINISHED: al_log_debug("cache_handler_http", "Transfer finished."); break; @@ -55,7 +60,6 @@ static size_t http_callback(void *userdata, u8 op, u8 *buf, s64 int0) default: break; } - return ret; } static void handler_http_maybe_spawn_worker(struct cch_handler *handler, size_t index) -- cgit v1.2.3-101-g0448