I'm a new developer, learning how to add a new module into the VLC.
I followed the instruction on Developer Corner. I make a new.c as following:
I put it into ~/modules/control. And then add the following line in the file modules/control/Modules.am:#include <errno.h>
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdlib.h>
/*VLC core API header*/
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_interface.h>
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static int Open ( vlc_object_t * );
static void Close ( vlc_object_t * );
static int Quit ( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
/* Status Callbacks */
static void RegisterCallbacks( intf_thread_t * );
static void Help ( intf_thread_t *, bool );
static int VolumeChanged( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
static int InputEvent( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
/*****************************************************************************
* Module descriptor
*****************************************************************************/
vlc_module_begin ()
set_shortname( N_("Hello"))
set_category( CAT_INTERFACE )
set_subcategory( SUBCAT_INTERFACE_CONTROL )
set_description( N_("Hello interface from writer") )
add_string( "hello, who.", NULL, NULL, "writer", "Who to say hello to", true )
set_capability( "interface", 0 )
set_callbacks( Activate, Deactivate )
vlc_module_end ()
/*Internal state for an instance of the module*/
struct inf_sys_t
{
char *who;
}
/*****************************************************************************
* Activate: initialize and create stuff
*****************************************************************************/
static int Open( vlc_object_t *obj )
{
intf_thread_t *intf = (intf_thread_t*)obj;
/* Allocate internal state */
inf_sys_t *sys = malloc (sizeof (*sys));
if (unlikely(sys = NULL))
return VLC_ENOMEM;
intf->p_sys = sys;
/* Read settings */
char *who = var_InheritString(intf, "hello-who");
if (who == NULL)
{
msg_Err(intf, "Nobody to say hello to!");
goto error;
}
sys->who = who;
msg_Info(intf, "Hello %s!", who);
return VLC_SUCCESS;
error:
free(sys);
return VLC_EGENERIC;
}
/*****************************************************************************
* Deactivate: uninitialize and stop the interface
*****************************************************************************/
static void Close( vlc_object_t *obj )
{
intf_thread_t *intf = (intf_thread_t *)obj;
intf_sys_t *sys = intf->p_sys;
msg_Info(intf, "Good bye %s!");
/* Free internal state */
free(sys->who);
free(sys);
}
Then, I add the following lines to extend confiure.ac:SOURCES_new = new.c
Finishing these, I used the command line:dnl
dnl new
dnl
VLC_ADD_PLUGIN([new])
After configure, I checked the Makefile.am in ~/modules/control. The following lines were added:./bootstrap
./configure
Then,# The new plugin
libnew_plugin_la_SOURCES = $(SOURCES_new)
nodist_libnew_plugin_la_SOURCES = $(nodist_SOURCES_new)
# Force per-target objects:
libnew_plugin_la_CFLAGS = $(AM_CFLAGS)
libnew_plugin_la_CXXFLAGS = $(AM_CXXFLAGS)
libnew_plugin_la_OBJCFLAGS = $(AM_OBJCFLAGS)
# Set LIBADD and DEPENDENCIES manually:
libnew_plugin_la_LIBADD = $(AM_LIBADD)
libnew_plugin_la_DEPENDENCIES = $(top_srcdir)/src/libvlccore.sym
It passed the compile, but the new module cannot be shown in the list. I failed to add this new interface module to VLC.make
./vlc --reset-plugins-cache
./vlc -vvv --color --list
Could anyone please help me find the problem? Thank you very much.