Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion libvisual/libvisual/lv_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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"};
}

Expand Down
9 changes: 9 additions & 0 deletions libvisual/libvisual/lv_actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having this is a good idea. Can we move this into a separate patch and add the method to LV::Morph and LV::Input as well?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kaixiong done 👍

Expand Down
6 changes: 5 additions & 1 deletion libvisual/libvisual/lv_input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ namespace LV {
return static_cast<VisInputPlugin*> (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 {
Expand All @@ -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"};
}

Expand Down
9 changes: 9 additions & 0 deletions libvisual/libvisual/lv_input.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
6 changes: 5 additions & 1 deletion libvisual/libvisual/lv_morph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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"};
}

Expand Down
9 changes: 9 additions & 0 deletions libvisual/libvisual/lv_morph.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
19 changes: 11 additions & 8 deletions libvisual/tools/lv-tool/lv-tool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,8 @@
#include <getopt.h>

// 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
Expand All @@ -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;
Expand Down Expand Up @@ -179,7 +176,7 @@ namespace {
"\t--depth <depth> \t-c <depth>\tSet output colour depth (automatic by default)\n"
"\t--driver <driver>\t-d <driver>\tUse this output driver [%s]\n"
"\t--input <input>\t\t-i <input>\tUse this input plugin [%s]\n"
"\t--actor <actor>\t\t-a <actor>\tUse this actor plugin [%s]\n"
"\t--actor <actor>\t\t-a <actor>\tUse this actor plugin [%s/%s]\n"
"\t--morph <morph>\t\t-m <morph>\tUse this morph plugin [%s]\n"
"\t--seed <seed>\t\t-s <seed>\tSet random seed\n"
"\t--fps <n>\t\t-f <n>\t\tLimit output to n frames per second (if display driver supports it) [%d]\n"
Expand All @@ -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);

Expand Down Expand Up @@ -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 + "'");
Expand Down