diff options
| -rw-r--r-- | src/buffer/video.c | 2 | ||||
| -rw-r--r-- | src/cache/entry.c | 3 | ||||
| -rw-r--r-- | src/cache/entry.h | 33 | ||||
| -rw-r--r-- | src/cache/handlers/cdio.c | 2 | ||||
| -rw-r--r-- | src/cache/handlers/file.c | 2 | ||||
| -rw-r--r-- | src/cache/handlers/http.c | 2 | ||||
| -rw-r--r-- | src/codec/ffmpeg/decoder.c | 6 | ||||
| -rw-r--r-- | src/codec/meson.build | 4 | ||||
| -rw-r--r-- | src/liana/handlers/codec_client.c | 2 | ||||
| -rw-r--r-- | src/liana/meson.build | 2 | ||||
| -rw-r--r-- | src/liana/server.h | 14 | ||||
| -rw-r--r-- | src/liana/vcr.c | 3 |
12 files changed, 41 insertions, 34 deletions
diff --git a/src/buffer/video.c b/src/buffer/video.c index 783fea0..c29f1b7 100644 --- a/src/buffer/video.c +++ b/src/buffer/video.c @@ -13,7 +13,7 @@ #include "../codec/ffmpeg/scaler.h" #endif -#define BUFFER_MARK_LOW ((1.0 / 24.0) * 3) +#define BUFFER_MARK_LOW ((1.0 / 24.0) * 2) #define BUFFER_MARK_BUFFERED ((1.0 / 24.0) * 4) // Must be >1. #define BUFFER_MARK_HIGH ((1.0 / 24.0) * 6) #define BUFFER_MARK_RESET (BUFFER_MARK_HIGH * 2.0) diff --git a/src/cache/entry.c b/src/cache/entry.c index 560e5ee..a3ad9e9 100644 --- a/src/cache/entry.c +++ b/src/cache/entry.c @@ -10,7 +10,6 @@ bool cch_entry_get_handle(struct cch_entry *entry, struct cch_handle *handle) nn_cond_init(&handle->wait.cond); nn_mutex_init(&handle->wait.lock); nn_mutex_lock(&entry->mutex); - entry->ref_count++; nn_mutex_unlock(&entry->mutex); return true; } @@ -40,8 +39,8 @@ off_t cch_entry_get_size(struct cch_entry *entry) void cch_entry_return_handle(struct cch_entry *entry, struct cch_handle *handle) { + al_assert(handle->entry == entry); handle->entry = NULL; - entry->ref_count--; nn_mutex_destroy(&handle->wait.lock); nn_cond_destroy(&handle->wait.cond); } diff --git a/src/cache/entry.h b/src/cache/entry.h index 4a20058..161eaab 100644 --- a/src/cache/entry.h +++ b/src/cache/entry.h @@ -6,14 +6,43 @@ #include "backing.h" #include "handler.h" +/* + Types to consider: + - file + - http + - hls + - http index? + - archive + - cue + single file + - cue + multiple files + - dvd/bluray (drive or iso) + - live source (radio antenna) + + Other considerations: + - Chapter priority (disc drive) + - For now 1 user and 1 list owns the drive totally. + - Scan list from current down on order change to create priority. + - DVD's have a runtime + - We will minimially have to pass inputs to the handler. + - Resource has to support being networked at a point before a liana server node. + - Networked backing? + - Is a liana "node handler" necessary? + + Cache/liana refactor: + - On creation, the handler can create multiple backings and chapters. + - Chapters include index into array of backings. + - get_handle() takes chapter as a arugment. + - get/set_size() no longer make sense. + - Remove liana field from handler. + - Method of requesting a unique file backing. + */ + struct cch_chapter { off_t start; off_t end; }; struct cch_entry { - u32 hash; - s32 ref_count; bool unknown_size; array(struct cch_chapter) chapters; struct cch_chapter *chapter; diff --git a/src/cache/handlers/cdio.c b/src/cache/handlers/cdio.c index e978343..e319f74 100644 --- a/src/cache/handlers/cdio.c +++ b/src/cache/handlers/cdio.c @@ -192,9 +192,7 @@ struct cch_entry *cch_handler_cdio_create(void) struct cch_entry *entry = al_alloc_object(struct cch_entry); entry->backing = backing; entry->handler = (struct cch_handler *)cdio; - entry->ref_count = 0; entry->unknown_size = false; - entry->hash = 0; nn_mutex_init(&entry->mutex); entry->handler->can_seek = handler_cdio_can_seek; entry->handler->maybe_spawn_worker = handler_cdio_maybe_spawn_worker; diff --git a/src/cache/handlers/file.c b/src/cache/handlers/file.c index 9ac8933..9529772 100644 --- a/src/cache/handlers/file.c +++ b/src/cache/handlers/file.c @@ -39,9 +39,7 @@ struct cch_entry *cch_handler_file_create(str *path, str *liana) struct cch_entry *entry = al_alloc_object(struct cch_entry); entry->backing = backing; entry->handler = (struct cch_handler *)file; - entry->ref_count = 0; entry->unknown_size = false; - entry->hash = 0; nn_mutex_init(&entry->mutex); entry->handler->can_seek = handler_file_can_seek; entry->handler->maybe_spawn_worker = handler_file_maybe_spawn_worker; diff --git a/src/cache/handlers/http.c b/src/cache/handlers/http.c index 08bd165..ed84bdc 100644 --- a/src/cache/handlers/http.c +++ b/src/cache/handlers/http.c @@ -106,9 +106,7 @@ struct cch_entry *cch_handler_http_create(str *url, struct nn_event_loop *loop) struct cch_entry *entry = al_alloc_object(struct cch_entry); entry->backing = backing; entry->handler = (struct cch_handler *)http; - entry->ref_count = 0; entry->unknown_size = false; - entry->hash = 0; nn_mutex_init(&entry->mutex); entry->handler->can_seek = handler_http_can_seek; entry->handler->maybe_spawn_worker = handler_http_maybe_spawn_worker; diff --git a/src/codec/ffmpeg/decoder.c b/src/codec/ffmpeg/decoder.c index e22f184..cae56d1 100644 --- a/src/codec/ffmpeg/decoder.c +++ b/src/codec/ffmpeg/decoder.c @@ -256,12 +256,14 @@ static bool ff_decoder_init(struct camu_decoder *dec, struct camu_renderer *rend s32 cpus = 0; if (av->codec_context->codec_type == AVMEDIA_TYPE_VIDEO) { cpus = av_cpu_count(); - cpus = MIN(3, MAX(1, cpus / 2)); + cpus = MIN(4, MAX(1, cpus / 2)); } if (cpus > 0) { av->codec_context->thread_count = cpus; // FF_THREAD_FRAME or FF_THREAD_SLICE. - av->codec_context->thread_type = FF_THREAD_FRAME; + // SLICE seems to work better based on videos that got completely choked + // in THREAD_FRAME mode (4k60 hevc, FFMpeg 7.1.1, AMD 3900x). + av->codec_context->thread_type = FF_THREAD_SLICE; log_info("Using %i threads for decoder.", cpus); } } diff --git a/src/codec/meson.build b/src/codec/meson.build index a739de0..9401b0b 100644 --- a/src/codec/meson.build +++ b/src/codec/meson.build @@ -19,9 +19,7 @@ if get_option('codecs').contains('wuffs') subdir('wuffs') endif -if not no_video - codec_client_deps += [stela] -endif +codec_client_deps += [stela] codecs_server = declare_dependency(sources: codec_src, dependencies: codec_server_deps) codecs_client = declare_dependency(sources: codec_src, dependencies: codec_client_deps) diff --git a/src/liana/handlers/codec_client.c b/src/liana/handlers/codec_client.c index a412b5c..39bb2d1 100644 --- a/src/liana/handlers/codec_client.c +++ b/src/liana/handlers/codec_client.c @@ -124,7 +124,7 @@ static bool codec_client_handle_packet(struct lia_client_handler *handler, struc } #ifdef VCR_BUFFER_WHOLE_FILE struct camu_codec_stream *stream = codec->handler.stream; - AVRational time_base = stream->av.stream->time; + AVRational time_base = stream->av.stream->time_base; pkt->pts += av_rescale_q(stream->duration, AV_TIME_BASE_Q, time_base); #else av_packet_free_side_data(pkt); diff --git a/src/liana/meson.build b/src/liana/meson.build index 12345c9..5c1cc42 100644 --- a/src/liana/meson.build +++ b/src/liana/meson.build @@ -11,7 +11,7 @@ liana_client_src = [ 'handlers/codec_client.c', 'handlers.c' ] -liana_server_deps = [cache, codecs_server] +liana_server_deps = [cache, codecs_server, codecs_client] # codecs_client for transcode. liana_client_deps = [codecs_client] liana_args = [] diff --git a/src/liana/server.h b/src/liana/server.h index 13f4a6e..55a581e 100644 --- a/src/liana/server.h +++ b/src/liana/server.h @@ -9,20 +9,6 @@ //#define LIANA_SERVER_LOOP -// OLD: cache entry -> [connection handler -> connection] -// NEW: cache entry -> node handler -> [connection handler -> connection] -// [] = list of - -// liana supported server resources: -// - file -// - http -// - hls -// - cd -// - dvd -// - bluray -// - archive -// - live source (radio) - struct lia_node_connection { u32 id; struct nn_packet *packet; diff --git a/src/liana/vcr.c b/src/liana/vcr.c index c3adddf..4e176e7 100644 --- a/src/liana/vcr.c +++ b/src/liana/vcr.c @@ -337,8 +337,7 @@ void lia_vcr_uncork(struct lia_vcr_track *track) static void vcr_track_close_internal(struct lia_vcr_track *track) { struct lia_vcr *vcr = track->vcr; - // Calling packet_cache_disable() while holding the track mutex can - // very possibly deadlock. + // Calling packet_cache_disable() while holding the track mutex can very possibly deadlock. nn_packet_cache_disable(&track->cache); nn_mutex_lock(&track->mutex); al_atomic_store(s32)(&track->state, VCR_TRACK_CLOSED, AL_ATOMIC_RELAXED); |