From 86009433e39c36ccdee515f58c80dc11cba437e0 Mon Sep 17 00:00:00 2001 From: nick black Date: Wed, 20 Jan 2021 23:00:22 -0500 Subject: [PATCH] properly dispatch post-split ncvisual_subtitles() --- src/lib/internal.h | 1 + src/lib/visual.cpp | 6 ++++-- src/media/ffmpeg.cpp | 5 +++-- src/media/oiio.cpp | 3 ++- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/lib/internal.h b/src/lib/internal.h index b5f670508..bf9ebe650 100644 --- a/src/lib/internal.h +++ b/src/lib/internal.h @@ -1072,6 +1072,7 @@ typedef struct ncvisual_implementation { // have been prepared already in 'ncv'. void (*ncvisual_details_seed)(struct ncvisual* ncv); void (*ncvisual_details_destroy)(struct ncvisual_details* deets); + char* (*ncvisual_subtitle)(const struct ncvisual* ncv); bool canopen_images; bool canopen_videos; } ncvisual_implementation; diff --git a/src/lib/visual.cpp b/src/lib/visual.cpp index 768052ba5..ad94fb284 100644 --- a/src/lib/visual.cpp +++ b/src/lib/visual.cpp @@ -663,8 +663,10 @@ auto ncvisual_stream(notcurses* nc, ncvisual* ncv, float timescale, } auto ncvisual_subtitle(const ncvisual* ncv) -> char* { - (void)ncv; - return nullptr; + if(!visual_implementation){ + return nullptr; + } + return visual_implementation->ncvisual_subtitle(ncv); } auto ncvisual_resize(ncvisual* nc, int rows, int cols) -> int { diff --git a/src/media/ffmpeg.cpp b/src/media/ffmpeg.cpp index 598921926..2a41bf559 100644 --- a/src/media/ffmpeg.cpp +++ b/src/media/ffmpeg.cpp @@ -112,7 +112,7 @@ deass(const char* ass) { return dup; } -auto ncvisual_subtitle(const ncvisual* ncv) -> char* { +auto ffmpeg_subtitle(const ncvisual* ncv) -> char* { for(unsigned i = 0 ; i < ncv->details->subtitle.num_rects ; ++i){ const AVSubtitleRect* rect = ncv->details->subtitle.rects[i]; if(rect->type == SUBTITLE_ASS){ @@ -584,13 +584,14 @@ auto ncvisual_details_destroy(ncvisual_details* deets) -> void { delete deets; } -const static ncvisual_implementation ffmpeg_impl = { +static const ncvisual_implementation ffmpeg_impl = { .ncvisual_init = ffmpeg_init, .ncvisual_printbanner = ncvisual_printbanner, .ncvisual_blit = ffmpeg_blit, .ncvisual_create = ncvisual_create, .ncvisual_details_seed = ncvisual_details_seed, .ncvisual_details_destroy = ncvisual_details_destroy, + .ncvisual_subtitle = ffmpeg_subtitle, .canopen_images = true, .canopen_videos = true, }; diff --git a/src/media/oiio.cpp b/src/media/oiio.cpp index 4c7f96e36..ba117ff59 100644 --- a/src/media/oiio.cpp +++ b/src/media/oiio.cpp @@ -227,7 +227,7 @@ auto ncvisual_stream(notcurses* nc, ncvisual* ncv, float timescale, return -1; } -char* ncvisual_subtitle(const ncvisual* ncv) { // no support in OIIO +char* oiio_subtitle(const ncvisual* ncv) { // no support in OIIO (void)ncv; return nullptr; } @@ -275,6 +275,7 @@ const static ncvisual_implementation oiio_impl = { .ncvisual_create = oiio_create, .ncvisual_details_seed = oiio_details_seed, .ncvisual_details_destroy = oiio_details_destroy, + .ncvisual_subtitle = oiio_subtitle, .canopen_images = true, .canopen_videos = false, };