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

Support new HAL API. Based on patch by Josselin Mouette

parent 1f47871d
...@@ -731,12 +731,21 @@ AC_ARG_ENABLE(hal, ...@@ -731,12 +731,21 @@ AC_ARG_ENABLE(hal,
if test "${enable_hal}" != "no" -a "${SYS}" = "linux" if test "${enable_hal}" != "no" -a "${SYS}" = "linux"
then then
PKG_CHECK_MODULES(HAL, hal >= 0.2.97, PKG_CHECK_MODULES(HAL, hal >= 0.5.0,
[AC_DEFINE(HAVE_HAL, [], [Define if you have the HAL library]) [ AC_DEFINE( HAVE_HAL_1, [] , [Define if you have the new HAL library API])
VLC_ADD_PLUGINS([hal]) AC_DEFINE( HAVE_HAL, [], [Define if you have the HAL library] )
VLC_ADD_LDFLAGS([vlc hal],[$HAL_LIBS]) VLC_ADD_PLUGINS([hal])
VLC_ADD_CFLAGS([vlc hal],[$HAL_CFLAGS])], VLC_ADD_LDFLAGS([vlc hal],[$HAL_LIBS])
[AC_MSG_WARN(HAL library not found)]) VLC_ADD_CFLAGS([vlc hal],[$HAL_CFLAGS])],
dnl No hal 0.5 Test for 0.2
[ PKG_CHECK_MODULES( HAL, hal >= 0.2.97,
[AC_DEFINE(HAVE_HAL, [], [Define if you have the HAL library])
VLC_ADD_PLUGINS([hal])
VLC_ADD_LDFLAGS([vlc hal],[$HAL_LIBS])
VLC_ADD_CFLAGS([vlc hal],[$HAL_CFLAGS])],
[AC_MSG_WARN(HAL library not found)])
]
)
fi fi
dnl Build the gtk_main plugins? dnl Build the gtk_main plugins?
......
...@@ -103,13 +103,21 @@ static int Open( vlc_object_t *p_this ) ...@@ -103,13 +103,21 @@ static int Open( vlc_object_t *p_this )
playlist_t *p_playlist; playlist_t *p_playlist;
playlist_view_t *p_view; playlist_view_t *p_view;
DBusError dbus_error;
p_sd->pf_run = Run; p_sd->pf_run = Run;
p_sd->p_sys = p_sys; p_sd->p_sys = p_sys;
dbus_error_init( &dbus_error );
#ifdef HAVE_HAL_1
if( !( p_sys->p_ctx = libhal_ctx_init_direct( &dbus_error ) ) )
#else
if( !( p_sys->p_ctx = hal_initialize( NULL, FALSE ) ) ) if( !( p_sys->p_ctx = hal_initialize( NULL, FALSE ) ) )
#endif
{ {
free( p_sys ); free( p_sys );
msg_Err( p_sd, "hal not available" ); msg_Err( p_sd, "hal not available : %s", dbus_error.message );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
...@@ -160,16 +168,27 @@ static void AddDvd( services_discovery_t *p_sd, char *psz_device ) ...@@ -160,16 +168,27 @@ static void AddDvd( services_discovery_t *p_sd, char *psz_device )
services_discovery_sys_t *p_sys = p_sd->p_sys; services_discovery_sys_t *p_sys = p_sd->p_sys;
playlist_t *p_playlist; playlist_t *p_playlist;
playlist_item_t *p_item; playlist_item_t *p_item;
#ifdef HAVE_HAL_1
psz_name = libhal_device_get_property_string( p_sd->p_sys->p_ctx,
psz_device, "volume.label", NULL );
psz_blockdevice = libhal_device_get_property_string( p_sd->p_sys->p_ctx,
psz_device, "block.device", NULL );
#else
psz_name = hal_device_get_property_string( p_sd->p_sys->p_ctx, psz_name = hal_device_get_property_string( p_sd->p_sys->p_ctx,
psz_device, "volume.label" ); psz_device, "volume.label" );
psz_blockdevice = hal_device_get_property_string( p_sd->p_sys->p_ctx, psz_blockdevice = hal_device_get_property_string( p_sd->p_sys->p_ctx,
psz_device, "block.device" ); psz_device, "block.device" );
#endif
asprintf( &psz_uri, "dvd://%s", psz_blockdevice ); asprintf( &psz_uri, "dvd://%s", psz_blockdevice );
/* Create the playlist item here */ /* Create the playlist item here */
p_item = playlist_ItemNew( p_sd, psz_uri, p_item = playlist_ItemNew( p_sd, psz_uri,
psz_name ); psz_name );
free( psz_uri ); free( psz_uri );
#ifdef HAVE_HAL_1
libhal_free_string( psz_device );
#else
hal_free_string( psz_device ); hal_free_string( psz_device );
#endif
if( !p_item ) if( !p_item )
{ {
return; return;
...@@ -197,14 +216,23 @@ static void AddCdda( services_discovery_t *p_sd, char *psz_device ) ...@@ -197,14 +216,23 @@ static void AddCdda( services_discovery_t *p_sd, char *psz_device )
services_discovery_sys_t *p_sys = p_sd->p_sys; services_discovery_sys_t *p_sys = p_sd->p_sys;
playlist_t *p_playlist; playlist_t *p_playlist;
playlist_item_t *p_item; playlist_item_t *p_item;
#ifdef HAVE_HAL_1
psz_blockdevice = libhal_device_get_property_string( p_sd->p_sys->p_ctx,
psz_device, "block.device", NULL );
#else
psz_blockdevice = hal_device_get_property_string( p_sd->p_sys->p_ctx, psz_blockdevice = hal_device_get_property_string( p_sd->p_sys->p_ctx,
psz_device, "block.device" ); psz_device, "block.device" );
#endif
asprintf( &psz_uri, "cdda://%s", psz_blockdevice ); asprintf( &psz_uri, "cdda://%s", psz_blockdevice );
/* Create the playlist item here */ /* Create the playlist item here */
p_item = playlist_ItemNew( p_sd, psz_uri, p_item = playlist_ItemNew( p_sd, psz_uri,
psz_name ); psz_name );
free( psz_uri ); free( psz_uri );
#ifdef HAVE_HAL_1
libhal_free_string( psz_device );
#else
hal_free_string( psz_device ); hal_free_string( psz_device );
#endif
if( !p_item ) if( !p_item )
{ {
return; return;
...@@ -229,24 +257,44 @@ static void ParseDevice( services_discovery_t *p_sd, char *psz_device ) ...@@ -229,24 +257,44 @@ static void ParseDevice( services_discovery_t *p_sd, char *psz_device )
{ {
char *psz_disc_type; char *psz_disc_type;
services_discovery_sys_t *p_sys = p_sd->p_sys; services_discovery_sys_t *p_sys = p_sd->p_sys;
#ifdef HAVE_HAL_1
if( libhal_device_property_exists( p_sys->p_ctx, psz_device,
"volume.disc.type", NULL ) )
{
psz_disc_type = libhal_device_get_property_string( p_sys->p_ctx,
psz_device,
"volume.disc.type",
NULL );
#else
if( hal_device_property_exists( p_sys->p_ctx, psz_device, if( hal_device_property_exists( p_sys->p_ctx, psz_device,
"volume.disc.type" ) ) "volume.disc.type" ) )
{ {
psz_disc_type = hal_device_get_property_string( p_sys->p_ctx, psz_disc_type = hal_device_get_property_string( p_sys->p_ctx,
psz_device, psz_device,
"volume.disc.type" ); "volume.disc.type" );
#endif
if( !strcmp( psz_disc_type, "dvd_rom" ) ) if( !strcmp( psz_disc_type, "dvd_rom" ) )
{ {
AddDvd( p_sd, psz_device ); AddDvd( p_sd, psz_device );
} }
else if( !strcmp( psz_disc_type, "cd_rom" ) ) else if( !strcmp( psz_disc_type, "cd_rom" ) )
{ {
if( hal_device_get_property_bool( p_sys->p_ctx, psz_device, "volume.disc.has_audio" ) ) #ifdef HAVE_HAL_1
if( libhal_device_get_property_bool( p_sys->p_ctx, psz_device,
"volume.disc.has_audio" , NULL ) )
#else
if( hal_device_get_property_bool( p_sys->p_ctx, psz_device,
"volume.disc.has_audio" ) )
#endif
{ {
AddCdda( p_sd, psz_device ); AddCdda( p_sd, psz_device );
} }
} }
#ifdef HAVE_HAL_1
libhal_free_string( psz_disc_type );
#else
hal_free_string( psz_disc_type ); hal_free_string( psz_disc_type );
#endif
} }
} }
...@@ -260,7 +308,11 @@ static void Run( services_discovery_t *p_sd ) ...@@ -260,7 +308,11 @@ static void Run( services_discovery_t *p_sd )
services_discovery_sys_t *p_sys = p_sd->p_sys; services_discovery_sys_t *p_sys = p_sd->p_sys;
/* parse existing devices first */ /* parse existing devices first */
#ifdef HAVE_HAL_1
if( ( devices = libhal_get_all_devices( p_sys->p_ctx, &i_devices, NULL ) ) )
#else
if( ( devices = hal_get_all_devices( p_sys->p_ctx, &i_devices ) ) ) if( ( devices = hal_get_all_devices( p_sys->p_ctx, &i_devices ) ) )
#endif
{ {
for( i = 0; i < i_devices; i++ ) for( i = 0; i < i_devices; i++ )
{ {
......
...@@ -2550,23 +2550,41 @@ static void InitDeviceValues( vlc_t *p_vlc ) ...@@ -2550,23 +2550,41 @@ static void InitDeviceValues( vlc_t *p_vlc )
char *block_dev; char *block_dev;
dbus_bool_t b_dvd; dbus_bool_t b_dvd;
#ifdef HAVE_HAL_1
if( ( ctx = libhal_ctx_init_direct( NULL ) ) )
#else
if( ( ctx = hal_initialize( NULL, FALSE ) ) ) if( ( ctx = hal_initialize( NULL, FALSE ) ) )
#endif
{ {
#ifdef HAVE_HAL_1
if( ( devices = libhal_get_all_devices( ctx, &i_devices, NULL ) ) )
#else
if( ( devices = hal_get_all_devices( ctx, &i_devices ) ) ) if( ( devices = hal_get_all_devices( ctx, &i_devices ) ) )
#endif
{ {
for( i = 0; i < i_devices; i++ ) for( i = 0; i < i_devices; i++ )
{ {
#ifdef HAVE_HAL_1
if( !libhal_device_property_exists( ctx, devices[i],
"storage.cdrom.dvd", NULL ) )
#else
if( !hal_device_property_exists( ctx, devices[ i ], if( !hal_device_property_exists( ctx, devices[ i ],
"storage.cdrom.dvd" ) ) "storage.cdrom.dvd" ) )
#endif
{ {
continue; continue;
} }
#ifdef HAVE_HAL_1
b_dvd = libhal_device_get_property_bool( ctx, devices[ i ],
"storage.cdrom.dvd", NULL );
block_dev = libhal_device_get_property_string( ctx,
devices[ i ], "block.device" , NULL );
#else
b_dvd = hal_device_get_property_bool( ctx, devices[ i ], b_dvd = hal_device_get_property_bool( ctx, devices[ i ],
"storage.cdrom.dvd" ); "storage.cdrom.dvd" );
block_dev = hal_device_get_property_string( ctx, devices[ i ], block_dev = hal_device_get_property_string( ctx, devices[ i ],
"block.device" ); "block.device" );
#endif
if( b_dvd ) if( b_dvd )
{ {
config_PutPsz( p_vlc, "dvd", block_dev ); config_PutPsz( p_vlc, "dvd", block_dev );
...@@ -2574,13 +2592,24 @@ static void InitDeviceValues( vlc_t *p_vlc ) ...@@ -2574,13 +2592,24 @@ static void InitDeviceValues( vlc_t *p_vlc )
config_PutPsz( p_vlc, "vcd", block_dev ); config_PutPsz( p_vlc, "vcd", block_dev );
config_PutPsz( p_vlc, "cd-audio", block_dev ); config_PutPsz( p_vlc, "cd-audio", block_dev );
#ifdef HAVE_HAL_1
libhal_free_string( block_dev );
#else
hal_free_string( block_dev ); hal_free_string( block_dev );
#endif
} }
#ifdef HAVE_HAL_1
libhal_free_string_array( devices );
#else
hal_free_string_array( devices ); hal_free_string_array( devices );
#endif
} }
#ifdef HAVE_HAL_1
libhal_ctx_shutdown( ctx, NULL );
#else
hal_shutdown( ctx ); hal_shutdown( ctx );
#endif
} }
#endif #endif
} }
......
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