]> git.sesse.net Git - vlc/commitdiff
Fix new HAL interaction
authorClément Stenac <zorglub@videolan.org>
Sun, 27 Nov 2005 11:30:14 +0000 (11:30 +0000)
committerClément Stenac <zorglub@videolan.org>
Sun, 27 Nov 2005 11:30:14 +0000 (11:30 +0000)
modules/services_discovery/hal.c
src/libvlc.c

index 6c402c6523f3ceda01b62f4e3d4473193ef96d8c..e7ef04f66f8bf9801595484cdded56d629548708 100644 (file)
@@ -104,6 +104,7 @@ static int Open( vlc_object_t *p_this )
     playlist_view_t     *p_view;
 
     DBusError           dbus_error;
+    DBusConnection      *p_connection;
 
     p_sd->pf_run = Run;
     p_sd->p_sys  = p_sys;
@@ -111,13 +112,30 @@ static int Open( vlc_object_t *p_this )
     dbus_error_init( &dbus_error );
 
 #ifdef HAVE_HAL_1
-    if( !( p_sys->p_ctx = libhal_ctx_init_direct( &dbus_error ) ) )
+    p_sys->p_ctx = libhal_ctx_new();
+    if( !p_sys->p_ctx )
+    {
+        msg_Err( p_sd, "Unable to create HAL context") ;
+        free( p_sys );
+        return VLC_EGENERIC;
+    }
+    p_connection = dbus_bus_get( DBUS_BUS_SYSTEM, &dbus_error );
+    if( dbus_error_is_set( &dbus_error ) )
+    {
+        msg_Err( p_sd, "Unable to connect to DBUS: %s", dbus_error.message );
+        dbus_error_free( &dbus_error );
+        free( p_sys );
+        return VLC_EGENERIC;
+    }
+    libhal_ctx_set_dbus_connection( p_sys->p_ctx, p_connection );
+    if( !libhal_ctx_init( p_sys->p_ctx, &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 );
         msg_Err( p_sd, "hal not available : %s", dbus_error.message );
+        dbus_error_free( &dbus_error );
+        free( p_sys );
         return VLC_EGENERIC;
     }
 
index 1bb5f0b7fea8a223381642a6e42c7620029ecbd3..33fbeb2c3f57a682c4810da71bfd8e38ca34ea55 100644 (file)
@@ -2556,9 +2556,21 @@ static void InitDeviceValues( vlc_t *p_vlc )
     char **devices;
     char *block_dev;
     dbus_bool_t b_dvd;
+    DBusConnection *p_connection;
+    DBusError       error;
 
 #ifdef HAVE_HAL_1
-    if( ( ctx = libhal_ctx_init_direct( NULL ) ) )
+    ctx =  libhal_ctx_new();
+    if( !ctx ) return;
+    dbus_error_init( &error );
+    p_connection = dbus_bus_get ( DBUS_BUS_SYSTEM, &error );
+    if( dbus_error_is_set( &error ) )
+    {
+        dbus_error_free( &error );
+        return;
+    }
+    libhal_ctx_set_dbus_connection( ctx, p_connection );
+    if( !libhal_ctx_init( ctx, &error ) )
 #else
     if( ( ctx = hal_initialize( NULL, FALSE ) ) )
 #endif
@@ -2618,6 +2630,10 @@ static void InitDeviceValues( vlc_t *p_vlc )
         hal_shutdown( ctx );
 #endif
     }
+    else
+    {
+        msg_Dbg( p_vlc, "Unable to get HAL device properties" );
+    }
 #endif
 }