]> git.sesse.net Git - vlc/commitdiff
* ./src/libvlc.c: initialize dvd/vcd/cd-audio values using HAL.
authorJon Lech Johansen <jlj@videolan.org>
Tue, 24 Aug 2004 16:30:53 +0000 (16:30 +0000)
committerJon Lech Johansen <jlj@videolan.org>
Tue, 24 Aug 2004 16:30:53 +0000 (16:30 +0000)
configure.ac
src/libvlc.c

index abcd73b3ed5d4c584090767b2010433cbfb05d6f..7e7c49cc21abafda98bac9c20073d38bd86756b1 100644 (file)
@@ -668,6 +668,13 @@ if test "${x_libraries}" = "NONE"; then
   x_libraries="/usr/X11R6/lib"
 fi
 
+dnl Check for hal
+PKG_CHECK_MODULES(HAL, hal >= 0.2.97,
+  [AC_DEFINE(HAVE_HAL, [], [Define if you have the HAL library])
+   VLC_ADD_LDFLAGS([vlc],[$HAL_LIBS])
+   VLC_ADD_CFLAGS([vlc],[$HAL_CFLAGS])],
+  [AC_MSG_WARN(HAL library not found)])
+
 dnl Build the gtk_main plugins?
 NEED_GTK_MAIN=no
 NEED_GNOME_MAIN=no
index a93bbcdc12bf1695fcbe862b74536b5291c820f9..83f9cec58d3110ef351ed6c41ed5b988a8c79b6c 100644 (file)
 #   include <locale.h>
 #endif
 
+#ifdef HAVE_HAL
+#   include <hal/libhal.h>
+#endif
+
 #include "vlc_cpu.h"                                        /* CPU detection */
 #include "os_specific.h"
 
@@ -103,6 +107,8 @@ static int  ConsoleWidth  ( void );
 static int  VerboseCallback( vlc_object_t *, char const *,
                              vlc_value_t, vlc_value_t, void * );
 
+static void InitDeviceValues( vlc_t * );
+
 /*****************************************************************************
  * vlc_current_object: return the current object.
  *****************************************************************************
@@ -488,6 +494,11 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] )
         return VLC_EEXIT;
     }
 
+    /*
+     * Init device values
+     */
+    InitDeviceValues( p_vlc );
+
     /*
      * Override default configuration with config file settings
      */
@@ -2206,3 +2217,51 @@ static int VerboseCallback( vlc_object_t *p_this, const char *psz_variable,
     }
     return VLC_SUCCESS;
 }
+
+/*****************************************************************************
+ * InitDeviceValues: initialize device values
+ *****************************************************************************
+ * This function inits the dvd, vcd and cd-audio values
+ *****************************************************************************/
+static void InitDeviceValues( vlc_t *p_vlc )
+{
+#ifdef HAVE_HAL
+    LibHalContext * ctx;
+    int i, i_devices;
+    char **devices;
+    char *block_dev;
+    dbus_bool_t b_dvd;
+
+    if( ( ctx = hal_initialize( NULL, FALSE ) ) )
+    {
+        if( ( devices = hal_get_all_devices( ctx, &i_devices ) ) )
+        {
+            for( i = 0; i < i_devices; i++ )
+            {
+                if( !hal_device_property_exists( ctx, devices[ i ],
+                                                "storage.cdrom.dvd" ) )
+                {
+                    continue;
+                }
+
+                b_dvd = hal_device_get_property_bool( ctx, devices[ i ],
+                                                      "storage.cdrom.dvd" );
+                block_dev = hal_device_get_property_string( ctx, devices[ i ],
+                                                            "block.device" );
+
+                if( b_dvd )
+                {
+                    config_PutPsz( p_vlc, "dvd", block_dev );
+                }
+
+                config_PutPsz( p_vlc, "vcd", block_dev );
+                config_PutPsz( p_vlc, "cd-audio", block_dev );
+
+                hal_free_string( block_dev );
+            }
+        }
+
+        hal_shutdown( ctx );
+    }
+#endif
+}