Commit dea4749b authored by Clément Stenac's avatar Clément Stenac

* Create new types for device probing

* Beginning of core implementation
parent 29f94bbc
...@@ -33,32 +33,28 @@ struct libvlc_t ...@@ -33,32 +33,28 @@ struct libvlc_t
{ {
VLC_COMMON_MEMBERS VLC_COMMON_MEMBERS
/* Initialization boolean */ vlc_bool_t b_ready; ///< Initialization boolean
vlc_bool_t b_ready; uint32_t i_cpu; ///< CPU extensions
/* CPU extensions */ int i_verbose; ///< info messages
uint32_t i_cpu; vlc_bool_t b_color; ///< color messages?
/* Generic settings */
int i_verbose; /* info messages */
vlc_bool_t b_color; /* color messages? */
/* Object structure data */ /* Object structure data */
int i_counter; /* object counter */ int i_counter; ///< object counter
int i_objects; /* Attached objects count */ int i_objects; ///< Attached objects count
vlc_object_t ** pp_objects; /* Array of all objects */ vlc_object_t ** pp_objects; ///< Array of all objects
msg_bank_t msg_bank; ///< The message bank
/* The message bank */ module_bank_t * p_module_bank; ///< The module bank
msg_bank_t msg_bank;
/* The module bank */ vlc_bool_t b_stats; ///< Should we collect stats
module_bank_t * p_module_bank; /* Timers handling */
vlc_mutex_t timer_lock; ///< Lock to protect timers
int i_timers; ///< Number of timers
counter_t **pp_timers; ///< Array of all timers
/* Do stats ? - We keep this boolean to avoid unneeded lookups */ intf_thread_t *p_probe; ///< Devices prober
vlc_bool_t b_stats;
vlc_mutex_t timer_lock;
int i_timers;
counter_t **pp_timers;
/* Arch-specific variables */ /* Arch-specific variables */
#if !defined( WIN32 ) #if !defined( WIN32 )
......
...@@ -356,6 +356,8 @@ typedef struct vlc_acl_t vlc_acl_t; ...@@ -356,6 +356,8 @@ typedef struct vlc_acl_t vlc_acl_t;
/* Misc */ /* Misc */
typedef struct iso639_lang_t iso639_lang_t; typedef struct iso639_lang_t iso639_lang_t;
typedef struct device_t device_t; typedef struct device_t device_t;
typedef struct device_probe_t device_probe_t;
typedef struct probe_sys_t probe_sys_t;
/* block */ /* block */
typedef struct block_t block_t; typedef struct block_t block_t;
......
...@@ -46,6 +46,16 @@ struct device_t ...@@ -46,6 +46,16 @@ struct device_t
char *psz_name; char *psz_name;
}; };
struct device_probe_t
{
VLC_COMMON_MEMBERS;
int i_devices;
device_t **pp_devices;
probe_sys_t *p_sys;
void ( *pf_run ) ( device_probe_t * ); /** Run function */
};
static inline void device_GetDVD() static inline void device_GetDVD()
{} {}
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
/***************************************************************************** /*****************************************************************************
* Local prototypes * Local prototypes
*****************************************************************************/ *****************************************************************************/
struct intf_sys_t struct probe_sys_t
{ {
LibHalContext *p_ctx; LibHalContext *p_ctx;
int i_devices; int i_devices;
...@@ -40,10 +40,10 @@ struct intf_sys_t ...@@ -40,10 +40,10 @@ struct intf_sys_t
static int Open ( vlc_object_t * ); static int Open ( vlc_object_t * );
static void Close( vlc_object_t * ); static void Close( vlc_object_t * );
static void Update ( intf_thread_t *p_intf ); static void Update ( device_probe_t *p_probe );
static void UpdateMedia( intf_thread_t *p_intf, device_t *p_dev ); static void UpdateMedia( device_probe_t *p_probe, device_t *p_dev );
static void AddDevice( intf_thread_t * p_intf, device_t *p_dev ); static void AddDevice( device_probe_t * p_probe, device_t *p_dev );
static device_t * ParseDisc( intf_thread_t *p_intf, char *psz_device ); static device_t * ParseDisc( device_probe_t *p_probe, char *psz_device );
/***************************************************************************** /*****************************************************************************
* Module descriptor * Module descriptor
...@@ -60,38 +60,38 @@ vlc_module_end(); ...@@ -60,38 +60,38 @@ vlc_module_end();
*****************************************************************************/ *****************************************************************************/
static int Open( vlc_object_t *p_this ) static int Open( vlc_object_t *p_this )
{ {
intf_thread_t *p_intf = (intf_thread_t *)p_this; device_probe_t *p_probe = (device_probe_t *)p_this;
DBusError dbus_error; DBusError dbus_error;
DBusConnection *p_connection; DBusConnection *p_connection;
intf_sys_t *p_sys; probe_sys_t *p_sys;
p_intf->p_sys = p_sys = (intf_sys_t*)malloc( sizeof( intf_sys_t ) ); p_probe->p_sys = p_sys = (probe_sys_t*)malloc( sizeof( probe_sys_t ) );
p_intf->p_sys->i_devices = 0; p_probe->p_sys->i_devices = 0;
p_intf->p_sys->pp_devices = NULL; p_probe->p_sys->pp_devices = NULL;
p_intf->pf_run = Update; p_probe->pf_run = Update;
dbus_error_init( &dbus_error ); dbus_error_init( &dbus_error );
p_sys->p_ctx = libhal_ctx_new(); p_sys->p_ctx = libhal_ctx_new();
if( !p_sys->p_ctx ) if( !p_sys->p_ctx )
{ {
msg_Err( p_intf, "unable to create HAL context") ; msg_Err( p_probe, "unable to create HAL context") ;
free( p_intf->p_sys ); free( p_probe->p_sys );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
p_connection = dbus_bus_get( DBUS_BUS_SYSTEM, &dbus_error ); p_connection = dbus_bus_get( DBUS_BUS_SYSTEM, &dbus_error );
if( dbus_error_is_set( &dbus_error ) ) if( dbus_error_is_set( &dbus_error ) )
{ {
msg_Err( p_intf, "unable to connect to DBUS: %s", dbus_error.message ); msg_Err( p_probe, "unable to connect to DBUS: %s", dbus_error.message );
dbus_error_free( &dbus_error ); dbus_error_free( &dbus_error );
free( p_intf->p_sys ); free( p_probe->p_sys );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
libhal_ctx_set_dbus_connection( p_intf->p_sys->p_ctx, p_connection ); libhal_ctx_set_dbus_connection( p_probe->p_sys->p_ctx, p_connection );
if( !libhal_ctx_init( p_intf->p_sys->p_ctx, &dbus_error ) ) if( !libhal_ctx_init( p_probe->p_sys->p_ctx, &dbus_error ) )
{ {
msg_Err( p_intf, "hal not available : %s", dbus_error.message ); msg_Err( p_probe, "hal not available : %s", dbus_error.message );
dbus_error_free( &dbus_error ); dbus_error_free( &dbus_error );
free( p_sys ); free( p_sys );
return VLC_EGENERIC; return VLC_EGENERIC;
...@@ -104,20 +104,20 @@ static int Open( vlc_object_t *p_this ) ...@@ -104,20 +104,20 @@ static int Open( vlc_object_t *p_this )
*****************************************************************************/ *****************************************************************************/
static void Close( vlc_object_t *p_this ) static void Close( vlc_object_t *p_this )
{ {
intf_thread_t *p_intf = (intf_thread_t *) p_this; device_probe_t *p_probe = (device_probe_t *) p_this;
intf_sys_t *p_sys = p_intf->p_sys; probe_sys_t *p_sys = p_probe->p_sys;
free( p_sys ); free( p_sys );
} }
static int GetAllDevices( intf_thread_t *p_intf, device_t ***ppp_devices ) static int GetAllDevices( device_probe_t *p_probe, device_t ***ppp_devices )
{ {
/// \todo : fill the dst array /// \todo : fill the dst array
return p_intf->p_sys->i_devices; return p_probe->p_sys->i_devices;
} }
static void Update( intf_thread_t * p_intf ) static void Update( device_probe_t * p_probe )
{ {
intf_sys_t *p_sys = p_intf->p_sys; probe_sys_t *p_sys = p_probe->p_sys;
int i, i_devices, j; int i, i_devices, j;
char **devices; char **devices;
vlc_bool_t b_exists; vlc_bool_t b_exists;
...@@ -132,7 +132,7 @@ static void Update( intf_thread_t * p_intf ) ...@@ -132,7 +132,7 @@ static void Update( intf_thread_t * p_intf )
{ {
for( i = 0; i < i_devices; i++ ) for( i = 0; i < i_devices; i++ )
{ {
device_t *p_dev = ParseDisc( p_intf, devices[ i ] ); device_t *p_dev = ParseDisc( p_probe, devices[ i ] );
b_exists = VLC_FALSE; b_exists = VLC_FALSE;
for ( j = 0 ; j < p_sys->i_devices; j++ ) for ( j = 0 ; j < p_sys->i_devices; j++ )
...@@ -142,11 +142,11 @@ static void Update( intf_thread_t * p_intf ) ...@@ -142,11 +142,11 @@ static void Update( intf_thread_t * p_intf )
{ {
b_exists = VLC_TRUE; b_exists = VLC_TRUE;
p_dev->b_seen = VLC_TRUE; p_dev->b_seen = VLC_TRUE;
UpdateMedia( p_intf, p_dev ); UpdateMedia( p_probe, p_dev );
break; break;
} }
if( !b_exists ) if( !b_exists )
AddDevice( p_intf, p_dev ); AddDevice( p_probe, p_dev );
} }
} }
} }
...@@ -154,18 +154,18 @@ static void Update( intf_thread_t * p_intf ) ...@@ -154,18 +154,18 @@ static void Update( intf_thread_t * p_intf )
} }
static void AddDevice( intf_thread_t * p_intf, device_t *p_dev ) static void AddDevice( device_probe_t * p_probe, device_t *p_dev )
{ {
INSERT_ELEM( p_intf->p_sys->pp_devices, INSERT_ELEM( p_probe->p_sys->pp_devices,
p_intf->p_sys->i_devices, p_probe->p_sys->i_devices,
p_intf->p_sys->i_devices, p_probe->p_sys->i_devices,
p_dev ); p_dev );
/// \todo : emit variable /// \todo : emit variable
} }
static device_t * ParseDisc( intf_thread_t *p_intf, char *psz_device ) static device_t * ParseDisc( device_probe_t *p_probe, char *psz_device )
{ {
intf_sys_t *p_sys = p_intf->p_sys; probe_sys_t *p_sys = p_probe->p_sys;
device_t *p_dev; device_t *p_dev;
char *block_dev; char *block_dev;
dbus_bool_t b_dvd; dbus_bool_t b_dvd;
...@@ -193,13 +193,13 @@ static device_t * ParseDisc( intf_thread_t *p_intf, char *psz_device ) ...@@ -193,13 +193,13 @@ static device_t * ParseDisc( intf_thread_t *p_intf, char *psz_device )
else else
p_dev->i_capabilities = DEVICE_CAN_CD; p_dev->i_capabilities = DEVICE_CAN_CD;
UpdateMedia( p_intf, p_dev ); UpdateMedia( p_probe, p_dev );
return p_dev; return p_dev;
} }
static void UpdateMedia( intf_thread_t *p_intf, device_t *p_dev ) static void UpdateMedia( device_probe_t *p_probe, device_t *p_dev )
{ {
intf_sys_t *p_sys = p_intf->p_sys; probe_sys_t *p_sys = p_probe->p_sys;
char **matching_media; char **matching_media;
int i_matching, i; int i_matching, i;
vlc_bool_t b_changed = VLC_FALSE;; vlc_bool_t b_changed = VLC_FALSE;;
......
...@@ -322,6 +322,7 @@ SOURCES_libvlc_common = \ ...@@ -322,6 +322,7 @@ SOURCES_libvlc_common = \
misc/vlm.c \ misc/vlm.c \
misc/xml.c \ misc/xml.c \
misc/hashtables.c \ misc/hashtables.c \
misc/devices.c \
extras/libc.c \ extras/libc.c \
control/core.c \ control/core.c \
control/playlist.c \ control/playlist.c \
......
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