From dc5a05996c7e4a4223644ed5caf04ff92c959df8 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Wed, 18 Jan 2023 16:24:49 +0100 Subject: [PATCH 1/2] libvisual: Extract static methods (Actor|Input|Morph)::available (inspired by 0.4.x commit e4a6cf5b60771b8cffa90834c0dd967b006bd3b1) --- libvisual/libvisual/lv_actor.cpp | 6 +++++- libvisual/libvisual/lv_actor.h | 9 +++++++++ libvisual/libvisual/lv_input.cpp | 6 +++++- libvisual/libvisual/lv_input.h | 9 +++++++++ libvisual/libvisual/lv_morph.cpp | 6 +++++- libvisual/libvisual/lv_morph.h | 9 +++++++++ 6 files changed, 42 insertions(+), 3 deletions(-) diff --git a/libvisual/libvisual/lv_actor.cpp b/libvisual/libvisual/lv_actor.cpp index ef7709e05..2988fb02f 100644 --- a/libvisual/libvisual/lv_actor.cpp +++ b/libvisual/libvisual/lv_actor.cpp @@ -74,6 +74,10 @@ namespace LV { return actor_plugin ? actor_plugin->vidoptions.depth : VISUAL_VIDEO_DEPTH_NONE; } + bool Actor::available(std::string const& name) { + return LV::PluginRegistry::instance()->has_plugin (VISUAL_PLUGIN_TYPE_ACTOR, name); + } + ActorPtr Actor::load (std::string const& name) { try { @@ -89,7 +93,7 @@ namespace LV { : m_impl {new Impl} , m_ref_count {1} { - if (!LV::PluginRegistry::instance()->has_plugin (VISUAL_PLUGIN_TYPE_ACTOR, name)) { + if (!available (name)) { throw std::runtime_error {"Actor plugin not found"}; } diff --git a/libvisual/libvisual/lv_actor.h b/libvisual/libvisual/lv_actor.h index 94f1703d3..7109141c1 100644 --- a/libvisual/libvisual/lv_actor.h +++ b/libvisual/libvisual/lv_actor.h @@ -52,6 +52,15 @@ namespace LV { public: + /** + * Determines if an actor plugin by the given name is available. + * + * @param name Name of actor plugin to check for + * + * @return True if an actor plugin by that name is available, else false + */ + static bool available (std::string const& name); + /** * Creates a new Actor with a plugin of a given name. * diff --git a/libvisual/libvisual/lv_input.cpp b/libvisual/libvisual/lv_input.cpp index d14cf3f98..81a12f44b 100644 --- a/libvisual/libvisual/lv_input.cpp +++ b/libvisual/libvisual/lv_input.cpp @@ -60,6 +60,10 @@ namespace LV { return static_cast (visual_plugin_get_info (plugin)->plugin); } + bool Input::available(std::string const& name) { + return LV::PluginRegistry::instance()->has_plugin (VISUAL_PLUGIN_TYPE_INPUT, name); + } + InputPtr Input::load (std::string const& name) { try { @@ -75,7 +79,7 @@ namespace LV { : m_impl {new Impl} , m_ref_count {1} { - if (!LV::PluginRegistry::instance()->has_plugin (VISUAL_PLUGIN_TYPE_INPUT, name)) { + if (!available (name)) { throw std::runtime_error {"Input plugin not found"}; } diff --git a/libvisual/libvisual/lv_input.h b/libvisual/libvisual/lv_input.h index cc046a5c1..8121bfea5 100644 --- a/libvisual/libvisual/lv_input.h +++ b/libvisual/libvisual/lv_input.h @@ -48,6 +48,15 @@ namespace LV { { public: + /** + * Determines if an input plugin by the given name is available. + * + * @param name Name of input plugin to check for + * + * @return True if an input plugin by that name is available, else false + */ + static bool available (std::string const& name); + /** * Creates a new Input with a plugin of a given name. * diff --git a/libvisual/libvisual/lv_morph.cpp b/libvisual/libvisual/lv_morph.cpp index 0624fbef3..df03ef734 100644 --- a/libvisual/libvisual/lv_morph.cpp +++ b/libvisual/libvisual/lv_morph.cpp @@ -74,6 +74,10 @@ namespace LV { return m_impl->plugin; } + bool Morph::available(std::string const& name) { + return LV::PluginRegistry::instance()->has_plugin (VISUAL_PLUGIN_TYPE_MORPH, name); + } + MorphPtr Morph::load (std::string const& name) { try { @@ -90,7 +94,7 @@ namespace LV { : m_impl (new Impl) , m_ref_count (1) { - if (!PluginRegistry::instance()->has_plugin (VISUAL_PLUGIN_TYPE_MORPH, name)) { + if (!available (name)) { throw std::runtime_error {"Morph plugin not found"}; } diff --git a/libvisual/libvisual/lv_morph.h b/libvisual/libvisual/lv_morph.h index a86ade172..1ac5b5582 100644 --- a/libvisual/libvisual/lv_morph.h +++ b/libvisual/libvisual/lv_morph.h @@ -51,6 +51,15 @@ namespace LV { { public: + /** + * Determines if a morph plugin by the given name is available. + * + * @param name Name of morph plugin to check for + * + * @return True if a morph plugin by that name is available, else false + */ + static bool available (std::string const& name); + /** * Creates a new Morph wit a plugin of a given name. * From 60ad4af90df1fc01a9415818aa82008fa8e84b69 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Wed, 18 Jan 2023 16:25:17 +0100 Subject: [PATCH 2/2] lv-tool: Upgrade default actor plugin to "lv_gltest" if available (based on 0.4.x commit e4a6cf5b60771b8cffa90834c0dd967b006bd3b1) --- libvisual/tools/lv-tool/lv-tool.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/libvisual/tools/lv-tool/lv-tool.cpp b/libvisual/tools/lv-tool/lv-tool.cpp index 41f6897ce..35b3ceef2 100644 --- a/libvisual/tools/lv-tool/lv-tool.cpp +++ b/libvisual/tools/lv-tool/lv-tool.cpp @@ -39,11 +39,8 @@ #include // Defaults -#ifdef HAVE_GL -# define DEFAULT_ACTOR "lv_gltest" -#else -# define DEFAULT_ACTOR "lv_analyzer" -#endif +#define DEFAULT_ACTOR_GL "lv_gltest" +#define DEFAULT_ACTOR_NONGL "lv_analyzer" #define DEFAULT_INPUT "debug" #define DEFAULT_MORPH "slide_left" #define DEFAULT_WIDTH 320 @@ -59,7 +56,7 @@ namespace { - std::string actor_name = DEFAULT_ACTOR; + std::string actor_name = DEFAULT_ACTOR_NONGL; std::string input_name = DEFAULT_INPUT; std::string morph_name = DEFAULT_MORPH; std::string driver_name = DEFAULT_DRIVER; @@ -179,7 +176,7 @@ namespace { "\t--depth \t-c \tSet output colour depth (automatic by default)\n" "\t--driver \t-d \tUse this output driver [%s]\n" "\t--input \t\t-i \tUse this input plugin [%s]\n" - "\t--actor \t\t-a \tUse this actor plugin [%s]\n" + "\t--actor \t\t-a \tUse this actor plugin [%s/%s]\n" "\t--morph \t\t-m \tUse this morph plugin [%s]\n" "\t--seed \t\t-s \tSet random seed\n" "\t--fps \t\t-f \t\tLimit output to n frames per second (if display driver supports it) [%d]\n" @@ -191,7 +188,8 @@ namespace { width, height, driver_name.c_str (), input_name.c_str (), - actor_name.c_str (), + DEFAULT_ACTOR_GL, + DEFAULT_ACTOR_NONGL, morph_name.c_str (), frame_rate); @@ -454,6 +452,11 @@ int main (int argc, char **argv) bin.set_supported_depth(VISUAL_VIDEO_DEPTH_ALL); bin.use_morph(false); + // Upgrade to a more appealing OpenGL actor if available + if (LV::Actor::available(DEFAULT_ACTOR_GL)) { + actor_name = DEFAULT_ACTOR_GL; + } + // Let the bin manage plugins. There's a bug otherwise. if (!bin.connect(actor_name, input_name)) { throw std::runtime_error ("Failed to start pipeline with actor '" + actor_name + "' and input '" + input_name + "'");