Commit 7f0d9408 authored by Sam Hocevar's avatar Sam Hocevar

* ./src/misc/modules.c: module_Need accepts a comma-separated list of

    module names. Try for instance: "vlc --intf gnome,gtk,dummy".
parent 3266cd72
......@@ -4,7 +4,7 @@
* It includes functions allowing to declare, get or set configuration options.
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: configuration.h,v 1.14 2002/06/11 09:44:21 gbazin Exp $
* $Id: configuration.h,v 1.15 2002/07/03 19:40:49 sam Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
......@@ -75,7 +75,7 @@ VLC_EXPORT( void, __config_PutInt, (vlc_object_t *, const char *, int) );
VLC_EXPORT( float, __config_GetFloat, (vlc_object_t *, const char *) );
VLC_EXPORT( void, __config_PutFloat, (vlc_object_t *, const char *, float) );
VLC_EXPORT( char *, __config_GetPsz, (vlc_object_t *, const char *) );
VLC_EXPORT( void, __config_PutPsz, (vlc_object_t *, const char *, char *) );
VLC_EXPORT( void, __config_PutPsz, (vlc_object_t *, const char *, const char *) );
VLC_EXPORT( int, __config_LoadCmdLine, ( vlc_object_t *, int *, char *[], vlc_bool_t ) );
VLC_EXPORT( char *, config_GetHomeDir, ( void ) );
......
/* include/defs.h.in. Generated automatically from configure.in by autoheader. */
/* include/defs.h.in. Generated automatically from configure.in by autoheader 2.13. */
/* Define if using alloca.c. */
#undef C_ALLOCA
......
......@@ -2,7 +2,7 @@
* modules.h : Module management functions.
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: modules.h,v 1.55 2002/06/11 09:44:21 gbazin Exp $
* $Id: modules.h,v 1.56 2002/07/03 19:40:49 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -335,6 +335,6 @@ void __module_ResetBank ( vlc_object_t * );
void __module_ManageBank ( vlc_object_t * );
#define module_Need(a,b,c,d) __module_Need(CAST_TO_VLC_OBJECT(a),b,c,d)
VLC_EXPORT( module_t *, __module_Need, ( vlc_object_t *, int, char *, void * ) );
VLC_EXPORT( module_t *, __module_Need, ( vlc_object_t *, int, const char *, void * ) );
VLC_EXPORT( void, module_Unneed, ( module_t * ) );
......@@ -2,7 +2,7 @@
* vlc.h: global header for vlc
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: vlc.h,v 1.3 2002/06/07 14:30:40 sam Exp $
* $Id: vlc.h,v 1.4 2002/07/03 19:40:49 sam Exp $
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -27,10 +27,21 @@ extern "C" {
# endif
/*****************************************************************************
* Error values
* Our custom types
*****************************************************************************/
#define VLC_DECLARE_STRUCT( name ) \
struct name##_s; \
typedef struct name##_s name##_t;
VLC_DECLARE_STRUCT(vlc)
VLC_DECLARE_STRUCT(vlc_object)
typedef signed int vlc_error_t;
typedef int vlc_bool_t;
typedef int vlc_status_t;
/*****************************************************************************
* Error values
*****************************************************************************/
#define VLC_SUCCESS -0 /* No error */
#define VLC_EGENERIC -1 /* Generic error */
#define VLC_ENOMEM -2 /* Not enough memory */
......@@ -40,29 +51,45 @@ typedef signed int vlc_error_t;
/*****************************************************************************
* Booleans
*****************************************************************************/
typedef int vlc_bool_t;
#define VLC_FALSE 0
#define VLC_TRUE 1
/*****************************************************************************
* Main structure status
*****************************************************************************/
typedef int vlc_status_t;
#define VLC_STATUS_NONE 0x00000000
#define VLC_STATUS_CREATED 0x02020202
#define VLC_STATUS_STOPPED 0x12121212
#define VLC_STATUS_RUNNING 0x42424242
/*****************************************************************************
* Structure types
* Playlist
*****************************************************************************/
#define VLC_DECLARE_STRUCT( name ) \
struct name##_s; \
typedef struct name##_s name##_t;
VLC_DECLARE_STRUCT(vlc)
VLC_DECLARE_STRUCT(vlc_object)
/* Used by playlist_Add */
#define PLAYLIST_INSERT 0x0001
#define PLAYLIST_REPLACE 0x0002
#define PLAYLIST_APPEND 0x0004
#define PLAYLIST_GO 0x0008
#define PLAYLIST_END -666
/* Playlist parsing mode */
#define PLAYLIST_REPEAT_CURRENT 0 /* Keep playing current item */
#define PLAYLIST_FORWARD 1 /* Parse playlist until end */
#define PLAYLIST_BACKWARD -1 /* Parse backwards */
#define PLAYLIST_FORWARD_LOOP 2 /* Parse playlist and loop */
#define PLAYLIST_BACKWARD_LOOP -2 /* Parse backwards and loop */
#define PLAYLIST_RANDOM 3 /* Shuffle play */
#define PLAYLIST_REVERSE_RANDOM -3 /* Reverse shuffle play */
/* Playlist commands */
#define PLAYLIST_PLAY 1 /* Starts playing. No arg. */
#define PLAYLIST_PAUSE 2 /* Toggles playlist pause. No arg. */
#define PLAYLIST_STOP 3 /* Stops playing. No arg. */
#define PLAYLIST_SKIP 4 /* Skip X items and play. */
#define PLAYLIST_GOTO 5 /* Goto Xth item. */
#define PLAYLIST_MODE 6 /* Set playlist mode. ??? */
/*****************************************************************************
* Required internal headers
......@@ -90,8 +117,8 @@ vlc_error_t vlc_stop ( vlc_t * );
vlc_error_t vlc_end ( vlc_t * );
vlc_error_t vlc_destroy ( vlc_t * );
vlc_error_t vlc_add_intf ( vlc_t *, char *, vlc_bool_t );
vlc_error_t vlc_add_target ( vlc_t *, char *, int, int );
vlc_error_t vlc_add_intf ( vlc_t *, const char *, vlc_bool_t );
vlc_error_t vlc_add_target ( vlc_t *, const char *, int, int );
vlc_status_t vlc_status ( vlc_t * );
......
......@@ -2,7 +2,7 @@
* vlc_playlist.h : Playlist functions
*****************************************************************************
* Copyright (C) 1999, 2000, 2001, 2002 VideoLAN
* $Id: vlc_playlist.h,v 1.1 2002/06/07 23:53:44 sam Exp $
* $Id: vlc_playlist.h,v 1.2 2002/07/03 19:40:49 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -51,31 +51,6 @@ struct playlist_s
input_thread_t * p_input;
};
/* Used by playlist_Add */
#define PLAYLIST_INSERT 0x0001
#define PLAYLIST_REPLACE 0x0002
#define PLAYLIST_APPEND 0x0004
#define PLAYLIST_GO 0x0008
#define PLAYLIST_END -666
/* Playlist parsing mode */
#define PLAYLIST_REPEAT_CURRENT 0 /* Keep playing current item */
#define PLAYLIST_FORWARD 1 /* Parse playlist until end */
#define PLAYLIST_BACKWARD -1 /* Parse backwards */
#define PLAYLIST_FORWARD_LOOP 2 /* Parse playlist and loop */
#define PLAYLIST_BACKWARD_LOOP -2 /* Parse backwards and loop */
#define PLAYLIST_RANDOM 3 /* Shuffle play */
#define PLAYLIST_REVERSE_RANDOM -3 /* Reverse shuffle play */
/* Playlist commands */
#define PLAYLIST_PLAY 1 /* Starts playing. No arg. */
#define PLAYLIST_PAUSE 2 /* Toggles playlist pause. No arg. */
#define PLAYLIST_STOP 3 /* Stops playing. No arg. */
#define PLAYLIST_SKIP 4 /* Skip X items and play. */
#define PLAYLIST_GOTO 5 /* Goto Xth item. */
#define PLAYLIST_MODE 6 /* Set playlist mode. ??? */
/*****************************************************************************
* Prototypes
*****************************************************************************/
......
......@@ -47,7 +47,7 @@ struct module_symbols_s
int (* vlc_threads_end_inner) ( void ) ;
int (* vout_ChromaCmp_inner) ( u32, u32 ) ;
module_config_t * (* config_FindConfig_inner) ( vlc_object_t *, const char *psz_name ) ;
module_t * (* __module_Need_inner) ( vlc_object_t *, int, char *, void * ) ;
module_t * (* __module_Need_inner) ( vlc_object_t *, int, const char *, void * ) ;
msg_subscription_t* (* __msg_Subscribe_inner) ( vlc_object_t * ) ;
mtime_t (* input_ClockGetTS_inner) ( input_thread_t *, pgrm_descriptor_t *, mtime_t ) ;
mtime_t (* mdate_inner) ( void ) ;
......@@ -73,7 +73,7 @@ struct module_symbols_s
void (* UnalignedRemoveBits_inner) ( bit_stream_t * ) ;
void (* __config_PutFloat_inner) (vlc_object_t *, const char *, float) ;
void (* __config_PutInt_inner) (vlc_object_t *, const char *, int) ;
void (* __config_PutPsz_inner) (vlc_object_t *, const char *, char *) ;
void (* __config_PutPsz_inner) (vlc_object_t *, const char *, const char *) ;
void (* __input_Seek_inner) ( vlc_object_t *, off_t, int ) ;
void (* __input_SetStatus_inner) ( vlc_object_t *, int ) ;
void (* __input_Tell_inner) ( vlc_object_t *, stream_position_t * ) ;
......
......@@ -4,7 +4,7 @@
* and spawns threads.
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
* $Id: libvlc.c,v 1.11 2002/06/27 19:05:17 sam Exp $
* $Id: libvlc.c,v 1.12 2002/07/03 19:40:49 sam Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
......@@ -536,7 +536,8 @@ vlc_error_t vlc_run( vlc_t *p_vlc )
* separate thread. If b_block is set to 1, vlc_add_intf will continue until
* user requests to quit.
*****************************************************************************/
vlc_error_t vlc_add_intf( vlc_t *p_vlc, char *psz_module, vlc_bool_t b_block )
vlc_error_t vlc_add_intf( vlc_t *p_vlc, const char *psz_module,
vlc_bool_t b_block )
{
vlc_error_t err;
intf_thread_t *p_intf;
......@@ -788,7 +789,7 @@ vlc_status_t vlc_status( vlc_t *p_vlc )
return p_vlc->i_status;
}
vlc_error_t vlc_add_target( vlc_t *p_vlc, char *psz_target,
vlc_error_t vlc_add_target( vlc_t *p_vlc, const char *psz_target,
int i_mode, int i_pos )
{
vlc_error_t err;
......
......@@ -2,7 +2,7 @@
* configuration.c management of the modules configuration
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: configuration.c,v 1.31 2002/06/11 09:44:22 gbazin Exp $
* $Id: configuration.c,v 1.32 2002/07/03 19:40:49 sam Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
......@@ -151,7 +151,7 @@ char * __config_GetPsz( vlc_object_t *p_this, const char *psz_name )
* and CONFIG_ITEM_MODULE).
*****************************************************************************/
void __config_PutPsz( vlc_object_t *p_this,
const char *psz_name, char *psz_value )
const char *psz_name, const char *psz_value )
{
module_config_t *p_config;
......
......@@ -2,7 +2,7 @@
* modules.c : Builtin and plugin modules management functions
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: modules.c,v 1.69 2002/06/27 19:05:17 sam Exp $
* $Id: modules.c,v 1.70 2002/07/03 19:40:49 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
* Ethan C. Baldridge <BaldridgeE@cadmus.com>
......@@ -260,24 +260,27 @@ void __module_ManageBank( vlc_object_t *p_this )
*****************************************************************************
* This function returns the module that best fits the asked capabilities.
*****************************************************************************/
module_t * __module_Need( vlc_object_t *p_this,
int i_capability, char *psz_name, void *p_data )
module_t * __module_Need( vlc_object_t *p_this, int i_capability,
const char *psz_name, void *p_data )
{
typedef struct module_list_s module_list_t;
struct module_list_s
{
module_t *p_module;
int i_score;
module_list_t *p_next;
};
module_list_t *p_list, *p_first, *p_tmp;
int i_ret, i_index = 0;
vlc_bool_t b_intf = 0;
vlc_bool_t b_intf = VLC_FALSE;
module_t *p_module;
char *psz_realname = NULL;
int i_shortcuts = 1;
char *psz_shortcuts = NULL;
msg_Dbg( p_this, "looking for %s module",
MODULE_CAPABILITY( i_capability ) );
......@@ -285,19 +288,19 @@ module_t * __module_Need( vlc_object_t *p_this,
/* We take the global lock */
vlc_mutex_lock( &p_this->p_vlc->module_bank.lock );
if( psz_name != NULL && *psz_name )
if( psz_name && *psz_name )
{
/* A module name was requested. */
psz_realname = strdup( psz_name );
if( psz_realname )
char *psz_parser;
psz_shortcuts = strdup( psz_name );
for( psz_parser = psz_shortcuts; *psz_parser; psz_parser++ )
{
char *p;
p = strchr( psz_realname, ':' );
if( p )
if( *psz_parser == ',' )
{
*p = '\0';
*psz_parser = '\0';
i_shortcuts++;
}
psz_name = psz_realname;
}
}
......@@ -311,6 +314,8 @@ module_t * __module_Need( vlc_object_t *p_this,
p_module != NULL ;
p_module = p_module->next )
{
int i_shortcut_bonus = 0;
/* Test that this module can do everything we need */
if( !(p_module->i_capabilities & ( 1 << i_capability )) )
{
......@@ -326,16 +331,33 @@ module_t * __module_Need( vlc_object_t *p_this,
}
/* If we required a shortcut, check this plugin provides it. */
if( psz_name != NULL && *psz_name )
if( psz_shortcuts )
{
vlc_bool_t b_trash = 1;
int i_dummy;
vlc_bool_t b_trash = VLC_TRUE;
int i_dummy, i_short = i_shortcuts;
char *psz_name = psz_shortcuts;
for( i_dummy = 0;
b_trash && p_module->pp_shortcuts[i_dummy];
i_dummy++ )
while( i_short )
{
b_trash = strcmp( psz_name, p_module->pp_shortcuts[i_dummy] );
for( i_dummy = 0;
b_trash && p_module->pp_shortcuts[i_dummy];
i_dummy++ )
{
b_trash = strcmp( psz_name, p_module->pp_shortcuts[i_dummy] );
}
if( !b_trash )
{
i_shortcut_bonus = i_short * 10000;
break;
}
while( *psz_name )
{
psz_name++;
}
psz_name++;
i_short--;
}
if( b_trash )
......@@ -360,7 +382,7 @@ module_t * __module_Need( vlc_object_t *p_this,
{
/* Remove previous non-matching plugins */
i_index = 0;
b_intf = 1;
b_intf = VLC_TRUE;
}
}
else
......@@ -375,6 +397,8 @@ module_t * __module_Need( vlc_object_t *p_this,
/* Store this new module */
p_list[ i_index ].p_module = p_module;
p_list[ i_index ].i_score = p_module->pi_score[i_capability]
+ i_shortcut_bonus;
/* Add it to the modules-to-probe list */
if( i_index == 0 )
......@@ -389,17 +413,15 @@ module_t * __module_Need( vlc_object_t *p_this,
* thousands of items. Here we have barely 50. */
module_list_t *p_newlist = p_first;
if( p_first->p_module->pi_score[i_capability]
< p_module->pi_score[i_capability] )
if( p_first->i_score < p_list[ i_index ].i_score )
{
p_list[ i_index ].p_next = p_first;
p_first = &p_list[ i_index ];
}
else
{
while( p_newlist->p_next != NULL
&& p_newlist->p_next->p_module->pi_score[i_capability]
>= p_module->pi_score[i_capability] )
while( p_newlist->p_next != NULL &&
p_newlist->p_next->i_score >= p_list[ i_index ].i_score )
{
p_newlist = p_newlist->p_next;
}
......@@ -527,18 +549,18 @@ module_t * __module_Need( vlc_object_t *p_this,
}
else if( p_first == NULL )
{
msg_Err( p_this, "no %s module named `%s'",
msg_Err( p_this, "no available %s module matched `%s'",
MODULE_CAPABILITY( i_capability ), psz_name );
}
else if( psz_name != NULL && *psz_name )
{
msg_Err( p_this, "could not load %s module `%s'",
msg_Err( p_this, "could not load any %s module matching `%s'",
MODULE_CAPABILITY( i_capability ), psz_name );
}
if( psz_realname )
if( psz_shortcuts )
{
free( psz_realname );
free( psz_shortcuts );
}
/* Don't forget that the module is still locked */
......@@ -602,13 +624,13 @@ static void AllocateAllPlugins( vlc_object_t *p_this )
int i_dirlen = strlen( *ppsz_path );
#if defined( SYS_BEOS ) || defined( SYS_DARWIN )
b_notinroot = 0;
b_notinroot = VLC_FALSE;
/* Under BeOS, we need to add beos_GetProgramPath() to access
* files under the current directory */
if( ( i_dirlen > 1 ) && strncmp( *ppsz_path, "/", 1 ) )
{
i_dirlen += i_vlclen + 2;
b_notinroot = 1;
b_notinroot = VLC_TRUE;
psz_fullpath = malloc( i_dirlen );
if( psz_fullpath == NULL )
......@@ -779,7 +801,7 @@ static int AllocatePluginModule( vlc_object_t * p_this, char * psz_filename )
p_module->i_usage = 0;
p_module->i_unused_delay = 0;
p_module->b_builtin = 0;
p_module->b_builtin = VLC_FALSE;
/* Link module into the linked list */
if( p_this->p_vlc->module_bank.first != NULL )
......@@ -864,7 +886,7 @@ static int AllocateBuiltinModule( vlc_object_t * p_this,
p_module->i_usage = 0;
p_module->i_unused_delay = 0;
p_module->b_builtin = 1;
p_module->b_builtin = VLC_TRUE;
p_module->is.builtin.pf_deactivate = pf_deactivate;
/* Link module into the linked list */
......
......@@ -2,7 +2,7 @@
* vlc.c: the vlc player
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
* $Id: vlc.c,v 1.2 2002/06/27 19:05:17 sam Exp $
* $Id: vlc.c,v 1.3 2002/07/03 19:40:49 sam Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
......@@ -68,8 +68,10 @@ int main(int i_argc, char *ppsz_argv[], char *ppsz_env[])
/* Add background interfaces */
//{ int i; for( i=10; i--; ) vlc_add_intf( p_vlc, "dummy", 0 ); }
//vlc_add_intf( p_vlc, "dummy", VLC_FALSE );
//vlc_add_intf( p_vlc, "logger", VLC_FALSE );
vlc_add_intf( p_vlc, "dummy", VLC_FALSE );
vlc_add_intf( p_vlc, "logger", VLC_FALSE );
//vlc_add_intf( p_vlc, "xosd", VLC_FALSE );
//vlc_add_intf( p_vlc, "kde", VLC_FALSE );
vlc_add_intf( p_vlc, "rc", VLC_FALSE );
/* Add a blocking interface */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment