Exemple #1
0
SRef<Resampler *> Resampler_Registry::create( uint32_t inputFreq, uint32_t outputFreq,
        uint32_t duration, uint32_t nChannels )
{
    SRef<SPlugin *> plugin;

    plugin = find_plugin("float_resampler");

    if( !plugin )
        plugin = find_plugin("simple_resampler");

    if( !plugin )
    {
        my_err("Can't create resampler");
        return NULL;
    }

    SRef<Resampler_Plugin *> resampler = dynamic_cast<Resampler_Plugin *>(*plugin);

    if( !resampler )
    {
        my_err("dynamic_cast<ResamplerPlugin *> failed");
        return NULL;
    }

    my_dbg << "Creating resampler " << resampler->get_name() << std::endl;

    return resampler->create_resampler( inputFreq, outputFreq,
                                        duration, nChannels );
}
static void load_enabled_from_config (void)
{
    int count = aud_get_int ("ladspa", "plugin_count");

    for (int i = 0; i < count; i ++)
    {
        char key[32];

        snprintf (key, sizeof key, "plugin%d_path", i);
        char * path = aud_get_string ("ladspa", key);

        snprintf (key, sizeof key, "plugin%d_label", i);
        char * label = aud_get_string ("ladspa", key);

        PluginData * plugin = find_plugin (path, label);
        if (plugin)
        {
            LoadedPlugin * loaded = enable_plugin_locked (plugin);

            int ccount = index_count (loaded->plugin->controls);
            for (int ci = 0; ci < ccount; ci ++)
            {
                snprintf (key, sizeof key, "plugin%d_control%d", i, ci);
                loaded->values[ci] = aud_get_double ("ladspa", key);
            }
        }

        g_free (path);
        g_free (label);
    }
}
Exemple #3
0
Boolean
plugin_function_exists (	char			*plugin_name,
				char			*function_name,
				KTPluginInfoList	*plugin_list )
/*
Input:
	plugin_name	- The name of the plugin to find
	function_name	- The function in the plugin to find
	plugin_list	- List containing al available plugins
Returns:
	TRUE if there is plugin named 'plugin_name' in 'plugin_list' that has a
	function named 'function_name', otherwise FALSE.
*/
{
	KTPluginInfoEntry	*plugin;
	int			count;
	
	plugin = find_plugin (plugin_name, plugin_list);
	
	/* If the plugin exists */
	if (plugin)
	{
		/* Find the function */
		for (count = 0; count < plugin->num_functions; count++)
		{
			if (strcmp(plugin->function_names[count], function_name) == EQUAL)
			{
				return TRUE;
			}
		}
	}
	
	return FALSE;
}
Exemple #4
0
KTPluginInfoEntry
*get_selected_plugin (void)
/*
Returns:
	The address of the KTPluginInfoEntry which name equals the selected row of
	the tree view returned by KTGUI_plugin_treeview(). If no such
	KTPluginInfoEntry appears in plugin_list, this function will return NULL.
*/
{
	GtkTreeSelection	*tree_selection;
	GtkTreeModel		*model;
	GtkTreeIter		iter;
	gchar			*plugin_name;
	KTPluginInfoEntry	*plugin;
	
	plugin = NULL;
	tree_selection = gtk_tree_view_get_selection( KTGUI_plugin_treeview() );
	/* If a row was selected instead of deselected */
	if (gtk_tree_selection_get_selected(tree_selection, &model, &iter))
	{
		/* Get the name of the selected plugin */
		gtk_tree_model_get (model, &iter, FIRST_COLUMN, &plugin_name, -1);
		if (plugin_name != NULL) /* If a listitem was selected instead of deselected */
		{
			plugin = find_plugin((char *)plugin_name, &plugin_list);
			g_free (plugin_name);
		}
	}
	return (plugin);
}
Exemple #5
0
void CPlugins::startPlugin(const char * const name)
{
	int pluginnr = find_plugin(name);
	if (pluginnr > -1)
		startPlugin(pluginnr,0);
	else
		printf("[CPlugins] could not find %s\n", name);

}
Exemple #6
0
int main(int argc,char *argv[])
{
  int error= 0;
  char tp_path[FN_REFLEN];
  char server_path[FN_REFLEN];
  char operation[16];

  MY_INIT(argv[0]);
  plugin_data.name= 0; // initialize name
  
  /*
    The following operations comprise the method for enabling or disabling
    a plugin. We begin by processing the command options then check the
    directories specified for --datadir, --basedir, --plugin-dir, and
    --plugin-ini (if specified). If the directories are Ok, we then look
    for the mysqld executable and the plugin soname. Finally, we build a
    bootstrap command file for use in bootstraping the server.
    
    If any step fails, the method issues an error message and the tool exits.
    
      1) Parse, execute, and verify command options.
      2) Check access to directories.
      3) Look for mysqld executable.
      4) Look for the plugin.
      5) Build a bootstrap file with commands to enable or disable plugin.
      
  */
  if ((error= process_options(argc, argv, operation)) ||
      (error= check_access()) ||
      (error= find_tool("mysqld" FN_EXEEXT, server_path)) ||
      (error= find_plugin(tp_path)) ||
      (error= build_bootstrap_file(operation, bootstrap)))
    goto exit;
  
  /* Dump the bootstrap file if --verbose specified. */
  if (opt_verbose && ((error= dump_bootstrap_file(bootstrap))))
    goto exit;
  
  /* Start the server in bootstrap mode and execute bootstrap commands */
  error= bootstrap_server(server_path, bootstrap);

exit:
  /* Remove file */
  my_delete(bootstrap, MYF(0));
  if (opt_verbose && error == 0)
  {
    printf("# Operation succeeded.\n");
  }

  my_end(my_end_arg);
  exit(error ? 1 : 0);
  return 0;        /* No compiler warnings */
}
Exemple #7
0
/**
 * Unregister a global event.
 * @param plugin_name Plugin's name.
 * @param event_nr Event ID to unregister. */
static void unregister_global_event(const char *plugin_name, int event_nr)
{
	atrinik_plugin *plugin = find_plugin(plugin_name);

	if (!plugin)
	{
		LOG(llevBug, "BUG: unregister_global_event(): Could not find plugin %s.\n", plugin_name);
		return;
	}

	plugin->gevent[event_nr] = 0;
}
Exemple #8
0
/**
 * Register a global event.
 * @param plugin_name Plugin's name.
 * @param event_nr Event ID to register. */
static void register_global_event(const char *plugin_name, int event_nr)
{
	atrinik_plugin *plugin = find_plugin(plugin_name);

	if (!plugin)
	{
		LOG(llevBug, "BUG: register_global_event(): Could not find plugin %s.\n", plugin_name);
		return;
	}

	LOG(llevInfo, "Plugin %s registered the event %d\n", plugin_name, event_nr);
	plugin->gevent[event_nr] = 1;
}
static void load_enabled_from_config (void)
{
    int count = aud_get_int ("ladspa", "plugin_count");

    for (int i = 0; i < count; i ++)
    {
        char key[32];

        snprintf (key, sizeof key, "plugin%d_path", i);
        char * path = aud_get_str ("ladspa", key);

        snprintf (key, sizeof key, "plugin%d_label", i);
        char * label = aud_get_str ("ladspa", key);

        PluginData * plugin = find_plugin (path, label);
        if (plugin)
        {
            LoadedPlugin * loaded = enable_plugin_locked (plugin);

            snprintf (key, sizeof key, "plugin%d_controls", i);

            int ccount = index_count (loaded->plugin->controls);
            double temp[ccount];

            char * controls = aud_get_str ("ladspa", key);

            if (str_to_double_array (controls, temp, ccount))
            {
                for (int ci = 0; ci < ccount; ci ++)
                    loaded->values[ci] = temp[ci];
            }
            else
            {
                /* migrate from old config format */
                for (int ci = 0; ci < ccount; ci ++)
                {
                    snprintf (key, sizeof key, "plugin%d_control%d", i, ci);
                    loaded->values[ci] = aud_get_double ("ladspa", key);
                    aud_set_str ("ladspa", key, "");
                }
            }

            str_unref (controls);
        }

        str_unref (path);
        str_unref (label);
    }
}
Exemple #10
0
void CPlugins::startPlugin(const char * const name)
{
	int pluginnr = find_plugin(name);
	if (pluginnr > -1)
		startPlugin(pluginnr);
	else
	{
		dprintf(DEBUG_NORMAL, "[CPlugins] could not find %s\n", name);
		
		std::string hint = name;
		hint += " ";
		hint += g_Locale->getText(LOCALE_PLUGINS_NOT_INSTALLED);
		
		HintBox(LOCALE_MESSAGEBOX_INFO, hint.c_str());
	}

}
Exemple #11
0
/**
 * Handles triggering normal events like EVENT_ATTACK, EVENT_STOP,
 * etc.
 * @param event_type The event type.
 * @param activator Activator object.
 * @param me Object the event object is in.
 * @param other Other object.
 * @param msg Message.
 * @param parm1 First parameter.
 * @param parm2 Second parameter.
 * @param parm3 Third parameter.
 * @param flags Event flags.
 * @return 1 if the event returns an event value, 0 otherwise. */
int trigger_event(int event_type, object *const activator, object *const me, object *const other, const char *msg, int parm1, int parm2, int parm3, int flags)
{
	object *event_obj;
	atrinik_plugin *plugin;

	if (me == NULL || !(me->event_flags & EVENT_FLAG(event_type)) || !plugins_list)
	{
		return 0;
	}

	if ((event_obj = get_event_object(me, event_type)) == NULL)
	{
		LOG(llevBug, "BUG: Object with event flag and no event object: %s\n", STRING_OBJ_NAME(me));
		me->event_flags &= ~(1 << event_type);
		return 0;
	}

	if (event_obj->name && (plugin = find_plugin(event_obj->name)))
	{
		int returnvalue;
#ifdef TIME_SCRIPTS
		struct timeval start, stop;
		uint64 start_u, stop_u;

		gettimeofday(&start, NULL);
#endif

		returnvalue = *(int *) plugin->eventfunc(0, event_type, activator, me, other, event_obj, msg, parm1, parm2, parm3, flags, event_obj->race, event_obj->slaying);

#ifdef TIME_SCRIPTS
		gettimeofday(&stop, NULL);
		start_u = start.tv_sec * 1000000 + start.tv_usec;
		stop_u = stop.tv_sec * 1000000 + stop.tv_usec;

		LOG(llevDebug, "Running time: %2.6f seconds\n", (stop_u - start_u) / 1000000.0);
#endif
		return returnvalue;
	}
	else
	{
		LOG(llevBug, "BUG: event object with unknown plugin: %s, plugin %s\n", STRING_OBJ_NAME(me), STRING_OBJ_NAME(event_obj));
		me->event_flags &= ~(1 << event_type);
	}

	return 0;
}
Exemple #12
0
void
on_plugin_combo_entry_changed          (GtkEditable     *editable,
                                        gpointer         user_data)
{
	char			*plugin_name;
	KTPluginInfoEntry	*plugin;
	GtkWidget		*special_action_radiobutton;
	
	plugin_name = (char *) gtk_entry_get_text(GTK_ENTRY(editable));
	plugin = find_plugin (plugin_name, &plugin_list);
	if (plugin != NULL)
	{
		reload_plugin_function_list (KTGUI_plugin_function_combo_list(),
		                             GTK_OBJECT( KTGUI_plugin_function_combo_entry() ),
		                             on_plugin_function_combo_entry_changed,
		                             plugin);
		handle_changed_special_action (GTK_TOGGLE_BUTTON( KTGUI_special_action_radiobutton() ));
	}
}
Exemple #13
0
void
read_plugin_dir (	char			*dir,
			KTPluginInfoList	*plugin_list  )
/*
Input:
	dir		- The directory to read the plugins from.
Output:
	plugin_list	- The plugins in dir are added to this list.
Returns:
	-
Description:
	This function reads the plugins from the directory which path is dir and
	adds them to plugin_list.
*/
{
	struct dirent		**file_list;
	int			num_files,
				count;
	KTPluginInfoEntry	*plugin;
	
	num_files = scandir (dir, &file_list, always_true, alphasort);
	if (num_files >= 0)
	{
		for (count = 0; count < num_files; count++)
		{
			
			plugin = load_plugin_info (dir, file_list[count]->d_name);
			if (plugin != NULL && !find_plugin (plugin->info.name, plugin_list))
			{
				add_plugin (plugin, plugin_list);
			}
		}
	}
	else if (mkdir(dir, S_IWUSR | S_IRUSR | S_IXUSR) == -1)
	{
		KTError (_("Plugin directory '%s' does not exist and "
			   "creating the directory failed. This program "
			   "will continue without loading the plugins "
			   "in this directory."), dir);
	}
}
Exemple #14
0
int obs_load_module(const char *path)
{
	struct obs_module mod;
	char *plugin_path = find_plugin(path);
	int errorcode;

	mod.module = os_dlopen(plugin_path);
	bfree(plugin_path);
	if (!mod.module) {
		blog(LOG_DEBUG, "Module '%s' not found", path);
		return MODULE_FILE_NOT_FOUND;
	}

	errorcode = call_module_load(mod.module, path);
	if (errorcode != MODULE_SUCCESS) {
		os_dlclose(mod.module);
		return errorcode;
	}

	mod.name = bstrdup(path);
	da_push_back(obs->modules, &mod);
	return MODULE_SUCCESS;
}
Exemple #15
0
gboolean
on_key_treeview_selection (	GtkTreeSelection	*selection,
				GtkTreeModel		*model,
				GtkTreePath		*path,
				gboolean		path_currently_selected,
				gpointer		userdata )
/*
Global input:
	key_list	- The list containing the settings for every key
Global output:
	selected_key	- Will point to the KTKeySettings in 'key_list' that
			  corresponds to the selected key (if a key is selected)
Description:
	This function sets all the settings of the selected key (if one selected) to
	the GUI and sets 'selected_key' to the address of the selected key settings.
	The key settings will be found in 'key_list'.
*/
{
	GtkEntry		*program_entry = NULL,
				*default_entry,
				*plugin_combo_entry,
				*plugin_function_combo_entry;
	GtkRadioButton		*radiobutton,
				*default_radiobutton,
				*program_radiobutton,
				*special_action_radiobutton;
	GtkList			*plugin_combo_list,
				*plugin_function_combo_list;
	GtkTreeView		*key_treeview;
	GtkTreeIter		iter;
	char			*key_name,
				*program_user = "",
				*default_action;
	KTPluginInfoEntry	*plugin;
	
	/* If a row was selected instead of deselected */
	if (gtk_tree_model_get_iter(model, &iter, path)) 
	{
		/* Get the name of the selected key */
		gtk_tree_model_get (model, &iter, FIRST_COLUMN, &key_name, -1);
		if (key_name != NULL) /* If a listitem was selected instead of deselected */
		{
			key_treeview = gtk_tree_selection_get_tree_view(selection);
			program_entry = KTGUI_program_entry();
			default_entry = KTGUI_default_entry();
			plugin_combo_entry = KTGUI_plugin_combo_entry();
			plugin_function_combo_entry = KTGUI_plugin_function_combo_entry();
			default_radiobutton = KTGUI_default_radiobutton();
			program_radiobutton = KTGUI_program_radiobutton();
			special_action_radiobutton = KTGUI_special_action_radiobutton();
			plugin_combo_list = KTGUI_plugin_combo_list();
			plugin_function_combo_list = KTGUI_plugin_function_combo_list();
			
			/* Block the signal handlers of the entries and the radiobuttons */
			g_signal_handlers_block_by_func (GTK_OBJECT(program_entry),
			                                  (void *)on_program_entry_changed, NULL);
			g_signal_handlers_block_by_func (GTK_OBJECT(default_radiobutton),
			                                  (void *)on_default_radiobutton_toggled, NULL);
			g_signal_handlers_block_by_func (GTK_OBJECT(program_radiobutton),
			                                  (void *)on_program_radiobutton_toggled, NULL);
			g_signal_handlers_block_by_func (GTK_OBJECT(special_action_radiobutton), 
			                                  (void *)on_special_action_radiobutton_toggled, NULL);
			g_signal_handlers_block_by_func (GTK_OBJECT(plugin_combo_entry),
			                                  (void *)on_plugin_combo_entry_changed, NULL);
			g_signal_handlers_block_by_func (GTK_OBJECT(plugin_function_combo_entry),
			                                  (void *)on_plugin_function_combo_entry_changed, NULL);
			
			gtk_entry_set_text (plugin_combo_entry, "");
			gtk_entry_set_text (plugin_function_combo_entry, "");
			/* Clear the plugin function list */
			gtk_list_clear_items (plugin_function_combo_list, 0, -1); /* Clear the whole list */
			/* Select the key in the linked list */
			selected_key = find_key_settings(key_name, &key_list);
			/* Read the settings of the key */
			if (!memcmp(&selected_key->action, &selected_key->default_action, sizeof(KTAction)))
			{
				radiobutton = default_radiobutton;
			}
			else if (selected_key->action.type == KTActionTypeProgram)
			{
				program_user = selected_key->action.program.command;
				radiobutton = GTK_RADIO_BUTTON( lookup_widget(GTK_WIDGET(key_treeview), "program_radiobutton") );
			}
			else if (selected_key->action.type == KTActionTypePlugin)
			{
				plugin = find_plugin (selected_key->action.plugin.plugin_name, &plugin_list);
				if (plugin_function_exists (selected_key->action.plugin.plugin_name,
				                            selected_key->action.plugin.function_name,
				                            &plugin_list))
				{
					reload_plugin_function_list (KTGUI_plugin_function_combo_list(),
					                             GTK_OBJECT( KTGUI_plugin_function_combo_entry() ),
					                             on_plugin_function_combo_entry_changed,
					                             plugin);
					gtk_entry_set_text (plugin_combo_entry,
					                    selected_key->action.plugin.plugin_name);
					gtk_entry_set_text (plugin_function_combo_entry,
					                    selected_key->action.plugin.function_name);
					radiobutton = special_action_radiobutton;
				}
				else
				{
					radiobutton = default_radiobutton;
				}
			}
			
			/* Show the settings of the key */
			gtk_label_set_text (KTGUI_key_name_label(), key_name);
			gtk_entry_set_text (GTK_ENTRY(program_entry), program_user);
			gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(radiobutton), TRUE);
			
			if (selected_key->default_action.type == KTActionTypePlugin)
			{
				/* If the plugin is not available on this system */
				if (selected_key->default_action.plugin.plugin_name == NULL)
				{
					default_action = "";
				}
				else
				{
					default_action = (char *)g_strdup_printf ("%s - %s",
							selected_key->default_action.plugin.plugin_name,
							selected_key->default_action.plugin.function_name);
				}
			}
			else if (selected_key->default_action.type == KTActionTypeProgram)
			{
				default_action = (char *)g_strdup_printf(
						selected_key->default_action.program.command);
			}
			/* Show the default action */
			gtk_entry_set_text (GTK_ENTRY(default_entry), default_action);
			if (default_action[0] != '\0')
			{
				g_free (default_action);
			}
			
			/* Unblock the signal handlers of the entries and the radiobuttons */
			g_signal_handlers_unblock_by_func (GTK_OBJECT(program_entry),
			                                    (void *)on_program_entry_changed, NULL);
			g_signal_handlers_unblock_by_func (GTK_OBJECT(default_radiobutton),
			                                    (void *)on_default_radiobutton_toggled, NULL);
			g_signal_handlers_unblock_by_func (GTK_OBJECT(program_radiobutton),
			                                    (void *)on_program_radiobutton_toggled, NULL);
			g_signal_handlers_unblock_by_func (GTK_OBJECT(special_action_radiobutton),
			                                    (void *)on_special_action_radiobutton_toggled, NULL);
			g_signal_handlers_unblock_by_func (GTK_OBJECT(plugin_combo_entry), 
			                                    (void *)on_plugin_combo_entry_changed, NULL);
			g_signal_handlers_unblock_by_func (GTK_OBJECT(plugin_function_combo_entry), 
			                                    (void *)on_plugin_function_combo_entry_changed, NULL);
			
			g_free (key_name);
		}
	}
	
	return (TRUE);
}
Exemple #16
0
bool CPlugins::plugin_exists(const std::string & filename)
{
	return (find_plugin(filename) >= 0);
}
 bool PluginRegistry::has_plugin (PluginType type, std::string const& name) const
 {
     return find_plugin (type, name) != 0;
 }
  VisPluginInfo const* PluginRegistry::get_plugin_info (PluginType type, std::string const& name) const
  {
      PluginRef* ref = find_plugin (type, name);

      return ref ? ref->info : 0;
  }