]> git.sesse.net Git - vlc/commitdiff
* Ported Glide and MGA plugins to the new module API. MGA never worked,
authorSam Hocevar <sam@videolan.org>
Tue, 20 Feb 2001 07:49:13 +0000 (07:49 +0000)
committerSam Hocevar <sam@videolan.org>
Tue, 20 Feb 2001 07:49:13 +0000 (07:49 +0000)
    so this didn't make it work better.
  * Started thinking about built-in modules, and added some code to
    make it easier eventually.
  * Added Oct in the AUTHORS file.
  * Fixed a mistake in configure.in.
  * All your base are belong to us.
  * Fixed a bug in src/misc/modules which prevented loading modules
    when launched from the Tracker.
  * Fixed a similar bug in src/video_output/video_text.c.
  * BeOS CSS support, thanks to Markus Kuespert <ltlBeBoy@beosmail.com>
    who ported the Linux DVD ioctls. We can now read encrypted DVDs
    under BeOS ! Woohoo.

73 files changed:
AUTHORS
CONTRIBUTORS
INSTALL
Makefile.in
configure
configure.in
debian/control
debian/rules
debian/vlc.docs
include/modules_inner.h
plugins/alsa/alsa.c
plugins/alsa/aout_alsa.c
plugins/beos/aout_beos.cpp
plugins/beos/beos.cpp
plugins/beos/intf_beos.cpp
plugins/beos/vout_beos.cpp
plugins/dsp/aout_dsp.c
plugins/dsp/dsp.c
plugins/dummy/aout_dummy.c
plugins/dummy/dummy.c
plugins/dummy/intf_dummy.c
plugins/dummy/vout_dummy.c
plugins/dvd/dvd.c
plugins/dvd/dvd_css.c
plugins/dvd/dvd_ifo.c
plugins/dvd/dvd_ioctl.c [new file with mode: 0644]
plugins/dvd/dvd_ioctl.h [new file with mode: 0644]
plugins/dvd/dvd_udf.c
plugins/dvd/input_dvd.c
plugins/dvd/input_dvd.h
plugins/esd/aout_esd.c
plugins/esd/esd.c
plugins/fb/fb.c
plugins/fb/vout_fb.c
plugins/ggi/ggi.c
plugins/ggi/vout_ggi.c
plugins/glide/glide.c
plugins/glide/intf_glide.c [deleted file]
plugins/glide/vout_glide.c
plugins/gnome/gnome.c
plugins/gnome/gnome_callbacks.c
plugins/gnome/intf_gnome.c
plugins/idct/idct.c
plugins/idct/idctclassic.c
plugins/idct/idctmmx.c
plugins/idct/idctmmxext.c
plugins/mga/intf_mga.c [deleted file]
plugins/mga/mga.c
plugins/mga/vout_mga.c
plugins/mga/vout_mga.h
plugins/motion/motion.c
plugins/motion/motionmmx.c
plugins/motion/motionmmxext.c
plugins/mpeg/input_ps.c
plugins/mpeg/input_ts.c
plugins/mpeg/ps.c
plugins/mpeg/ts.c
plugins/null/null.c
plugins/sdl/aout_sdl.c
plugins/sdl/sdl.c
plugins/sdl/vout_sdl.c
plugins/text/intf_ncurses.c
plugins/text/ncurses.c
plugins/x11/vout_x11.c
plugins/x11/x11.c
plugins/yuv/video_yuv.c
plugins/yuv/video_yuvmmx.c
plugins/yuv/yuv.c
plugins/yuv/yuvmmx.c
src/interface/intf_msg.c
src/misc/modules.c
src/video_output/video_output.c
src/video_output/video_text.c

diff --git a/AUTHORS b/AUTHORS
index 24bda33fd58f1f89d715042ed74606aa694bf836..2892cfae9361749ac3ed2cc03d490b45fee4108e 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -4,6 +4,7 @@
 
   Olivier Pomel <pomel@via.ecp.fr>
 
+  Pierre Baillet <oct@zoy.org>
   Jean-Philippe Grimaldi <jeanphi@via.ecp.fr>
   Andres Krapf <dae@via.ecp.fr>
   Christophe Massiot <massiot@via.ecp.fr>
@@ -12,7 +13,7 @@
 
   Jean-Marc Dressler <polux@via.ecp.fr>
   GaĆ«l Hendryckx <jimmy@via.ecp.fr>
-  Samuel Hocevar <sam@zoy.org
+  Samuel Hocevar <sam@zoy.org>
   Brieuc Jeunhomme <bbp@via.ecp.fr>
   Michel Kaempf <maxx@via.ecp.fr>
 
index 3be352aa6343ce0a7e3f9f540ca8dd4f1e34db88..5ae56569e300b75cd8fbbbe88643e8ffd5e14b53 100644 (file)
@@ -8,3 +8,8 @@ Arkadiusz Miskiewicz <misiek@pld.ORG.PL>
 
   * Makefile and configure patches.
 
+
+Markus Kuespert <ltlBeBoy@beosmail.com>
+
+  * BeOS port of the DVD ioctls.
+
diff --git a/INSTALL b/INSTALL
index accc3d1bfcf9f33abba5f1cb3f737c484b32078b..ba999911cc9e8f17685198d40964b0f4f18c4d1e 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -32,7 +32,7 @@ Here's a shortcut to copy-paste to do a clean build :
 
    make distclean 2>/dev/null ; ./configure --prefix=/usr --enable-gnome \
       --enable-fb --with-glide --with-ggi --with-sdl --enable-esd \
-      --enable-alsa && make
+      --enable-alsa --enable-mga && make
 
 
 Installing and running VideoLAN
index 3d0628cc6ea18b3572af82cc8711c6800e00de0b..1ca0901d25114056e702967c6153cda9e27e4566 100644 (file)
@@ -19,6 +19,7 @@ PLUGINS=@PLUGINS@
 INSTALL=@INSTALL@
 ARCH=@ARCH@
 
+exec_prefix=@exec_prefix@
 prefix=@prefix@
 bindir=@bindir@
 datadir=@datadir@
@@ -298,9 +299,10 @@ PLUGIN_DUMMY =     plugins/dummy/dummy.o \
 
 PLUGIN_DVD =   plugins/dvd/dvd.o \
                plugins/dvd/input_dvd.o \
+               plugins/dvd/dvd_ioctl.o \
                plugins/dvd/dvd_ifo.o \
                plugins/dvd/dvd_udf.o \
-               plugins/dvd/dvd_css.o
+               plugins/dvd/dvd_css.o
 
 PLUGIN_ESD =   plugins/esd/esd.o \
                plugins/esd/aout_esd.o
@@ -312,7 +314,6 @@ PLUGIN_GGI =        plugins/ggi/ggi.o \
                plugins/ggi/vout_ggi.o
 
 PLUGIN_GLIDE = plugins/glide/glide.o \
-               plugins/glide/intf_glide.o \
                plugins/glide/vout_glide.o
 
 PLUGIN_GNOME = plugins/gnome/gnome.o \
@@ -334,7 +335,6 @@ PLUGIN_IDCTMMXEXT = plugins/idct/idctmmxext.o \
                        plugins/idct/idct_common.o
 
 PLUGIN_MGA =   plugins/mga/mga.o \
-               plugins/mga/intf_mga.o \
                plugins/mga/vout_mga.o
 
 PLUGIN_MOTION =        plugins/motion/motion.o \
index 201e8bf2488a5c56a199784cd8ab860118cfe069..c84907955a4c966a88a3809f536d492f41d2adb9 100755 (executable)
--- a/configure
+++ b/configure
@@ -3471,16 +3471,16 @@ if test "${with_sdl+set}" = set; then
    PLUGINS=${PLUGINS}"sdl ";
     if test "x$withval" != "xyes";
     then
-      LIB_SDL="-l"$withval
+      LIB_SDL="L/usr/X11R6/lib -l"$withval
     else
-      LIB_SDL="-lSDL"
+      LIB_SDL="-L/usr/X11R6/lib -lSDL"
     fi 
 fi
 
     if test "x$withval" == "x";
     then
       PLUGINS=${PLUGINS}"sdl "
-      LIB_SDL="-lSDL"
+      LIB_SDL="-L/usr/X11R6/lib -lSDL"
     fi
 # Check whether --with-glide or --without-glide was given.
 if test "${with_glide+set}" = set; then
index 69d22dfa7ebfba53455039b37a638dc6662704ff..111c16ca4754ffd8b4a6e69f413a03f4f8f0588c 100644 (file)
@@ -171,7 +171,7 @@ AC_ARG_WITH(sdl,
   [ PLUGINS=${PLUGINS}"sdl ";
     if test "x$withval" != "xyes";
     then
-      LIB_SDL="L /usr/X11R6/lib -l"$withval
+      LIB_SDL="L/usr/X11R6/lib -l"$withval
     else
       LIB_SDL="-L/usr/X11R6/lib -lSDL"
     fi ])
index 3fe4981565db5072b6964f3d3f639ccd9d1e0213..e52a4b56f4b81165e6cd57dedbe72436b1a920bc 100644 (file)
@@ -2,7 +2,7 @@ Source: vlc
 Section: graphics
 Priority: optional
 Maintainer: Samuel Hocevar <sam@zoy.org>
-Build-Depends: debhelper (>=2.2.0), xlib6g-dev, libgnome-dev, libesd0-dev, libsdl1.1-dev, alsa-headers
+Build-Depends: debhelper (>=2.2.0), xlib6g-dev, libgnome-dev, libggi2-dev, libglide-dev, libesd0-dev, libsdl1.1-dev, alsa-headers
 Standards-Version: 3.0.1
 
 Package: vlc
@@ -50,3 +50,18 @@ Description: SDL plugin for the VideoLAN Client
  This plugin adds support for the Simple DirectMedia Layer library to
  the VideoLAN Client.
 
+Package: vlc-ggi
+Architecture: any
+Depends: vlc (= ${Source-Version}), ${shlibs:Depends}
+Description: GGI plugin for the VideoLAN Client
+ VideoLAN is a free MPEG, MPEG2 and DVD software solution.
+ .
+ This is a GGI plugin for the VideoLAN Client.
+
+Package: vlc-glide
+Architecture: i386
+Depends: vlc (= ${Source-Version}), libglide2
+Description: Glide plugin for the VideoLAN Client
+ VideoLAN is a free MPEG, MPEG2 and DVD software solution.
+ .
+ This is a Glide (3dfx) plugin for the VideoLAN Client.
index 4e457e0d09575c76a7720cf806f8d93aee5b430b..8b2362a1cfe1a22cf183a7286910a99b46d28767 100755 (executable)
@@ -12,11 +12,19 @@ build: build-stamp
 build-stamp:
        dh_testdir
 
+       if [ $(DEB_BUILD_ARCH) = i386 ]; then \
        ./configure --prefix=/usr \
                --mandir=\$${prefix}/share/man \
                --infodir=\$${prefix}/share/info \
-               --enable-gnome \
-               --with-sdl --enable-esd --enable-alsa --disable-ppro ;
+               --enable-gnome --enable-fb --with-glide --with-ggi \
+               --with-sdl --enable-esd --enable-alsa --disable-ppro ; \
+       else \
+       ./configure --prefix=/usr \
+               --mandir=\$${prefix}/share/man \
+               --infodir=\$${prefix}/share/info \
+               --enable-gnome --enable-fb --with-ggi \
+               --with-sdl --enable-esd --enable-alsa; \
+       fi
 
        $(MAKE)
 
@@ -37,10 +45,10 @@ install: build
        dh_clean -k
        dh_installdirs
 
-       $(MAKE) install prefix=`pwd`/debian/vlc/usr
+       DESTDIR=`pwd`/debian/vlc/ $(MAKE) install prefix=/usr
 
        # make symlinks for packages
-       for alias in gnome esd sdl alsa ; do \
+       for alias in ggi gnome glide esd sdl alsa ; do \
                mkdir -p debian/vlc-$$alias/usr/share/doc/ ; \
                ln -s vlc debian/vlc-$$alias/usr/share/doc/vlc-$$alias ; \
                mkdir -p debian/vlc-$$alias/usr/lib/videolan/vlc/ ; \
@@ -73,10 +81,10 @@ binary-arch: build install
 #      dh_installpam
 #      dh_installinit
        dh_installcron
-       dh_installmanpages -Nvlc-gnome -Nvlc-esd -Nvlc-sdl -Nvlc-alsa
+       dh_installmanpages -Nvlc-gnome -Nvlc-ggi -Nvlc-glide -Nvlc-esd -Nvlc-sdl -Nvlc-alsa
        dh_installinfo
 #      dh_undocumented
-       dh_installchangelogs -Nvlc-gnome -Nvlc-esd -Nvlc-sdl -Nvlc-alsa
+       dh_installchangelogs -Nvlc-gnome -Nvlc-ggi -Nvlc-glide -Nvlc-esd -Nvlc-sdl -Nvlc-alsa
        dh_link
        dh_strip
        dh_compress
@@ -84,7 +92,7 @@ binary-arch: build install
 #      dh_makeshlibs
        dh_installdeb
 #      dh_perl
-       dh_shlibdeps
+       dh_shlibdeps -Nvlc-glide
        dh_gencontrol
        dh_md5sums
        dh_builddeb
index 8ef7154ae48d59a56eeac0f9b6dd12316cea43f9..6bd4fe2b3cc4bace4c85b295b127984ca73bdfd8 100644 (file)
@@ -1,4 +1,4 @@
 AUTHORS
-INSTALL
+CONTRIBUTORS
 README
 TODO
index 5e35ed8829e6eb31a13001bde839688fe2317253..b41e8126d0c55d6e80a1b1383eb3122c2444c483 100644 (file)
 /* I can't believe I need to do this to change Ā« foo Ā» to Ā« "foo" Ā» */
 #define UGLY_KLUDGE( z ) NASTY_CROCK( z )
 #define NASTY_CROCK( z ) #z
-/* And I need to do _this_ to change Ā« foo bar Ā» to Ā« foo_inner_bar Ā» ! */
+/* And I need to do _this_ to change Ā« foo bar Ā» to Ā« module_foo_bar Ā» ! */
 #define AWFUL_BRITTLE( y, z ) CRUDE_HACK( y, z )
 #define CRUDE_HACK( y, z ) module_##y##_##z
 
-/* Also, I need to do this to change Ā« blah Ā» to Ā« "VLC_MODULE_foo_blah" Ā» */
-#define MODULE_STRING UGLY_KLUDGE( MODULE_NAME )
-#define MODULE_VAR( z ) "VLC_MODULE_" UGLY_KLUDGE( MODULE_NAME ) "_" #z
+#define MODULE_VAR( z ) "VLC_MODULE_" #z
 
 /* If the module is built-in, then we need to define foo_InitModule instead
  * of InitModule. Same for Activate- and DeactivateModule. */
-#define MODULE_FUNC( function ) AWFUL_BRITTLE( MODULE_NAME, function )
+#ifdef BUILTIN
+#   define _M( function )    AWFUL_BRITTLE( MODULE_NAME, function )
+#   define MODULE_INIT \
+      int AWFUL_BRITTLE( MODULE_NAME, InitModule )      ( module_t *p_module )
+#   define MODULE_ACTIVATE \
+      int AWFUL_BRITTLE( MODULE_NAME, ActivateModule )  ( module_t *p_module )
+#   define MODULE_DEACTIVATE \
+      int AWFUL_BRITTLE( MODULE_NAME, DeactivateModule )( module_t *p_module )
+#else
+#   define _M( function )    function
+#   define MODULE_INIT       int InitModule       ( module_t *p_module )
+#   define MODULE_ACTIVATE   int ActivateModule   ( module_t *p_module )
+#   define MODULE_DEACTIVATE int DeactivateModule ( module_t *p_module )
+#endif
+
+/* Now the real stuff */
+#define MODULE_STRING UGLY_KLUDGE( MODULE_NAME )
 
 /*****************************************************************************
  * Macros used to build the configuration structure.
index 80734da46bd38f461b922ffd7384766830e0c138..aa4d58a237a3702c8b62b09d7c296e40a0a9d7bc 100644 (file)
@@ -22,6 +22,7 @@
  *****************************************************************************/
 
 #define MODULE_NAME alsa
+#include "modules_inner.h"
 
 /*****************************************************************************
  * Preamble
@@ -46,7 +47,6 @@
 #include "main.h"
 
 #include "modules.h"
-#include "modules_inner.h"
 
 /*****************************************************************************
  * Build configuration tree.
@@ -58,7 +58,7 @@ MODULE_CONFIG_END
 /*****************************************************************************
  * Capabilities defined in the other files.
  *****************************************************************************/
-extern void aout_getfunctions( function_list_t * p_function_list );
+void _M( aout_getfunctions )( function_list_t * p_function_list );
 
 /*****************************************************************************
  * InitModule: get the module structure and configuration.
@@ -68,7 +68,7 @@ extern void aout_getfunctions( function_list_t * p_function_list );
  * be unloaded later to save memory, and we want to be able to access this
  * data even after the module has been unloaded.
  *****************************************************************************/
-int InitModule( module_t * p_module )
+MODULE_INIT
 {
     p_module->psz_name = MODULE_STRING;
     p_module->psz_longname = "Alsa audio module";
@@ -87,7 +87,7 @@ int InitModule( module_t * p_module )
  * be set to 0 and calls to NeedModule() be made to increment it. To unload
  * the module, one has to wait until i_usage == 0 and call DeactivateModule().
  *****************************************************************************/
-int ActivateModule( module_t * p_module )
+MODULE_ACTIVATE
 {
     p_module->p_functions = malloc( sizeof( module_functions_t ) );
     if( p_module->p_functions == NULL )
@@ -95,7 +95,7 @@ int ActivateModule( module_t * p_module )
         return( -1 );
     }
 
-    aout_getfunctions( &p_module->p_functions->aout );
+    _M( aout_getfunctions )( &p_module->p_functions->aout );
     
     p_module->p_config = p_config;
     
@@ -110,9 +110,10 @@ int ActivateModule( module_t * p_module )
  * returns, i_usage can be set to -1 and the module unloaded. Be careful to
  * lock usage_lock during the whole process.
  *****************************************************************************/
-int DeactivateModule( module_t * p_module )
+MODULE_DEACTIVATE
 {
-        free( p_module->p_functions );
+    free( p_module->p_functions );
 
-            return( 0 );
+    return( 0 );
 }
+
index 717a9764b6e41c9db409b33ae35d76ae15efa100..f7a1b93d28ac09648708e9b2a4eb7894b9c13938 100644 (file)
@@ -22,6 +22,7 @@
  *****************************************************************************/
 
 #define MODULE_NAME alsa
+#include "modules_inner.h"
 
 /*****************************************************************************
  * Preamble
@@ -49,9 +50,6 @@
 #include "main.h"
 
 #include "modules.h"
-#include "modules_inner.h"
-
-
 
 typedef struct alsa_device_s
 {
@@ -85,12 +83,11 @@ static void    aout_Play        ( aout_thread_t *p_aout,
                                           byte_t *buffer, int i_size );
 static void    aout_Close       ( aout_thread_t *p_aout );
 
-
 /*****************************************************************************
  * Functions exported as capabilities. They are declared as static so that
  * we don't pollute the namespace too much.
  *****************************************************************************/
-void aout_getfunctions( function_list_t * p_function_list )
+void _M( aout_getfunctions )( function_list_t * p_function_list )
 {
     p_function_list->pf_probe = aout_Probe;
     p_function_list->functions.aout.pf_open = aout_Open;
@@ -99,7 +96,6 @@ void aout_getfunctions( function_list_t * p_function_list )
     p_function_list->functions.aout.pf_play = aout_Play;
     p_function_list->functions.aout.pf_close = aout_Close;
 }
-    
 
 /*****************************************************************************
  * aout_Probe: probes the audio device and return a score
index 61482e19a9feb933ad7a6ea43bfc2346a5d1e56c..2f4ed344e65661056aa8c43c990b40f230d03df0 100644 (file)
@@ -2,7 +2,7 @@
  * aout_beos.cpp: BeOS audio output
  *****************************************************************************
  * Copyright (C) 1999, 2000, 2001 VideoLAN
- * $Id: aout_beos.cpp,v 1.12 2001/02/18 03:32:02 polux Exp $
+ * $Id: aout_beos.cpp,v 1.13 2001/02/20 07:49:12 sam Exp $
  *
  * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
  *          Samuel Hocevar <sam@zoy.org>
@@ -22,6 +22,9 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
+#define MODULE_NAME beos
+#include "modules_inner.h"
+
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
@@ -88,7 +91,7 @@ static void    aout_Close       ( aout_thread_t *p_aout );
  * Functions exported as capabilities. They are declared as static so that
  * we don't pollute the namespace too much.
  *****************************************************************************/
-void aout_getfunctions( function_list_t * p_function_list )
+void _M( aout_getfunctions )( function_list_t * p_function_list )
 {
     p_function_list->pf_probe = aout_Probe;
     p_function_list->functions.aout.pf_open = aout_Open;
index 153b2200b6673573adedf242904cd471a61a8a1a..27ee8f3e90c0e8b2a5202ff0d3a720917dbdca02 100644 (file)
@@ -22,6 +22,7 @@
  *****************************************************************************/
 
 #define MODULE_NAME beos
+#include "modules_inner.h"
 
 /*****************************************************************************
  * Preamble
@@ -38,7 +39,6 @@ extern "C"
 #include "mtime.h"
 
 #include "modules.h"
-#include "modules_inner.h"
 
 /*****************************************************************************
  * Build configuration tree.
@@ -51,9 +51,9 @@ MODULE_CONFIG_END
 /*****************************************************************************
  * Capabilities defined in the other files.
  *****************************************************************************/
-extern void aout_getfunctions( function_list_t * p_function_list );
-extern void vout_getfunctions( function_list_t * p_function_list );
-extern void intf_getfunctions( function_list_t * p_function_list );
+void _M( aout_getfunctions )( function_list_t * p_function_list );
+void _M( vout_getfunctions )( function_list_t * p_function_list );
+void _M( intf_getfunctions )( function_list_t * p_function_list );
 
 /*****************************************************************************
  * InitModule: get the module structure and configuration.
@@ -63,7 +63,7 @@ extern void intf_getfunctions( function_list_t * p_function_list );
  * be unloaded later to save memory, and we want to be able to access this
  * data even after the module has been unloaded.
  *****************************************************************************/
-int InitModule( module_t * p_module )
+MODULE_INIT
 {
     p_module->psz_name = MODULE_STRING;
     p_module->psz_longname = "BeOS standard API module";
@@ -85,7 +85,7 @@ int InitModule( module_t * p_module )
  * be set to 0 and calls to NeedModule() be made to increment it. To unload
  * the module, one has to wait until i_usage == 0 and call DeactivateModule().
  *****************************************************************************/
-int ActivateModule( module_t * p_module )
+MODULE_ACTIVATE
 {
     p_module->p_functions =
                 ( module_functions_t * )malloc( sizeof( module_functions_t ) );
@@ -94,9 +94,9 @@ int ActivateModule( module_t * p_module )
         return( -1 );
     }
 
-    aout_getfunctions( &p_module->p_functions->aout );
-    vout_getfunctions( &p_module->p_functions->vout );
-    intf_getfunctions( &p_module->p_functions->intf );
+    _M( aout_getfunctions )( &p_module->p_functions->aout );
+    _M( vout_getfunctions )( &p_module->p_functions->vout );
+    _M( intf_getfunctions )( &p_module->p_functions->intf );
 
     p_module->p_config = p_config;
 
@@ -110,7 +110,7 @@ int ActivateModule( module_t * p_module )
  * returns, i_usage can be set to -1 and the module unloaded. Be careful to
  * lock usage_lock during the whole process.
  *****************************************************************************/
-int DeactivateModule( module_t * p_module )
+MODULE_DEACTIVATE
 {
     free( p_module->p_functions );
 
index 27cb3a943c917e566ddca2d0a4f412eb600acb1a..1ff3d8b466e5d03441f578d11df6fb11c47952bd 100644 (file)
@@ -2,7 +2,7 @@
  * intf_beos.cpp: beos interface
  *****************************************************************************
  * Copyright (C) 1999, 2000, 2001 VideoLAN
- * $Id: intf_beos.cpp,v 1.9 2001/02/19 03:46:27 sam Exp $
+ * $Id: intf_beos.cpp,v 1.10 2001/02/20 07:49:12 sam Exp $
  *
  * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
  *          Samuel Hocevar <sam@zoy.org>
@@ -22,6 +22,9 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
+#define MODULE_NAME beos
+#include "modules_inner.h"
+
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
@@ -153,7 +156,7 @@ static void intf_Run       ( intf_thread_t *p_intf );
  * Functions exported as capabilities. They are declared as static so that
  * we don't pollute the namespace too much.
  *****************************************************************************/
-void intf_getfunctions( function_list_t * p_function_list )
+void _M( intf_getfunctions )( function_list_t * p_function_list )
 {
     p_function_list->pf_probe = intf_Probe;
     p_function_list->functions.intf.pf_open  = intf_Open;
index 6d89bde41df0bc84965dd7968099d657ceddb9a9..0bcb58f1f9aa8edbfc19539bc090c7999ff82f62 100644 (file)
@@ -21,6 +21,9 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
+#define MODULE_NAME beos
+#include "modules_inner.h"
+
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
@@ -365,7 +368,7 @@ static void BeosCloseDisplay( vout_thread_t *p_vout );
  * Functions exported as capabilities. They are declared as static so that
  * we don't pollute the namespace too much.
  *****************************************************************************/
-void vout_getfunctions( function_list_t * p_function_list )
+void _M( vout_getfunctions )( function_list_t * p_function_list )
 {
     p_function_list->pf_probe = vout_Probe;
     p_function_list->functions.vout.pf_create     = vout_Create;
index 0283d80fbcb1d04cac922125fede4d8649267db5..68468e26e11e32c646007cc5e549108d79acb0e2 100644 (file)
@@ -21,6 +21,9 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
+#define MODULE_NAME dsp
+#include "modules_inner.h"
+
 /* TODO:
  *
  * - an aout_GetFormats() function
@@ -90,7 +93,7 @@ static void    aout_Close       ( aout_thread_t *p_aout );
  * Functions exported as capabilities. They are declared as static so that
  * we don't pollute the namespace too much.
  *****************************************************************************/
-void aout_getfunctions( function_list_t * p_function_list )
+void _M( aout_getfunctions )( function_list_t * p_function_list )
 {
     p_function_list->pf_probe = aout_Probe;
     p_function_list->functions.aout.pf_open = aout_Open;
index ec882eb2bdf06313cc005e9f55de931a83dc2895..75222b8461ebdd777a25b8eb45c8af96e7bd520f 100644 (file)
@@ -22,6 +22,7 @@
  *****************************************************************************/
 
 #define MODULE_NAME dsp
+#include "modules_inner.h"
 
 /*****************************************************************************
  * Preamble
@@ -37,7 +38,6 @@
 #include "mtime.h"
 
 #include "modules.h"
-#include "modules_inner.h"
 
 /*****************************************************************************
  * Build configuration tree.
@@ -51,7 +51,7 @@ MODULE_CONFIG_END
 /*****************************************************************************
  * Capabilities defined in the other files.
  *****************************************************************************/
-extern void aout_getfunctions( function_list_t * p_function_list );
+void _M( aout_getfunctions )( function_list_t * p_function_list );
 
 /*****************************************************************************
  * InitModule: get the module structure and configuration.
@@ -61,7 +61,7 @@ extern void aout_getfunctions( function_list_t * p_function_list );
  * be unloaded later to save memory, and we want to be able to access this
  * data even after the module has been unloaded.
  *****************************************************************************/
-int InitModule( module_t * p_module )
+MODULE_INIT
 {
     p_module->psz_name = MODULE_STRING;
     p_module->psz_longname = "Linux OSS /dev/dsp module";
@@ -81,7 +81,7 @@ int InitModule( module_t * p_module )
  * be set to 0 and calls to NeedModule() be made to increment it. To unload
  * the module, one has to wait until i_usage == 0 and call DeactivateModule().
  *****************************************************************************/
-int ActivateModule( module_t * p_module )
+MODULE_ACTIVATE
 {
     p_module->p_functions = malloc( sizeof( module_functions_t ) );
     if( p_module->p_functions == NULL )
@@ -89,7 +89,7 @@ int ActivateModule( module_t * p_module )
         return( -1 );
     }
 
-    aout_getfunctions( &p_module->p_functions->aout );
+    _M( aout_getfunctions )( &p_module->p_functions->aout );
 
     p_module->p_config = p_config;
 
@@ -103,7 +103,7 @@ int ActivateModule( module_t * p_module )
  * returns, i_usage can be set to -1 and the module unloaded. Be careful to
  * lock usage_lock during the whole process.
  *****************************************************************************/
-int DeactivateModule( module_t * p_module )
+MODULE_DEACTIVATE
 {
     free( p_module->p_functions );
 
index 34cd387a928d411b38dd1aeb61624834ea8b3bed..52a231bb97672dadf76ff6ce3b0cee71e86683d5 100644 (file)
@@ -20,6 +20,9 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
+#define MODULE_NAME dummy
+#include "modules_inner.h"
+
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
@@ -63,7 +66,7 @@ static void    aout_Close       ( aout_thread_t *p_aout );
  * Functions exported as capabilities. They are declared as static so that
  * we don't pollute the namespace too much.
  *****************************************************************************/
-void aout_getfunctions( function_list_t * p_function_list )
+void _M( aout_getfunctions )( function_list_t * p_function_list )
 {
     p_function_list->pf_probe = aout_Probe;
     p_function_list->functions.aout.pf_open = aout_Open;
index 087e926bd2faaec4d7c662b84225b5fd48e583cc..8bdc53d17cf5a67e182bcb0d15f57f4fb5b96ea1 100644 (file)
@@ -21,6 +21,7 @@
  *****************************************************************************/
 
 #define MODULE_NAME dummy
+#include "modules_inner.h"
 
 /*****************************************************************************
  * Preamble
@@ -35,7 +36,6 @@
 #include "mtime.h"
 
 #include "modules.h"
-#include "modules_inner.h"
 
 /*****************************************************************************
  * Build configuration tree.
@@ -48,9 +48,9 @@ MODULE_CONFIG_END
 /*****************************************************************************
  * Capabilities defined in the other files.
  *****************************************************************************/
-extern void aout_getfunctions( function_list_t * p_function_list );
-extern void vout_getfunctions( function_list_t * p_function_list );
-extern void intf_getfunctions( function_list_t * p_function_list );
+void _M( aout_getfunctions )( function_list_t * p_function_list );
+void _M( vout_getfunctions )( function_list_t * p_function_list );
+void _M( intf_getfunctions )( function_list_t * p_function_list );
 
 /*****************************************************************************
  * InitModule: get the module structure and configuration.
@@ -60,7 +60,7 @@ extern void intf_getfunctions( function_list_t * p_function_list );
  * be unloaded later to save memory, and we want to be able to access this
  * data even after the module has been unloaded.
  *****************************************************************************/
-int InitModule( module_t * p_module )
+MODULE_INIT
 {
     p_module->psz_name = MODULE_STRING;
     p_module->psz_longname = "dummy functions module";
@@ -82,7 +82,7 @@ int InitModule( module_t * p_module )
  * be set to 0 and calls to NeedModule() be made to increment it. To unload
  * the module, one has to wait until i_usage == 0 and call DeactivateModule().
  *****************************************************************************/
-int ActivateModule( module_t * p_module )
+MODULE_ACTIVATE
 {
     p_module->p_functions = malloc( sizeof( module_functions_t ) );
     if( p_module->p_functions == NULL )
@@ -90,9 +90,9 @@ int ActivateModule( module_t * p_module )
         return( -1 );
     }
 
-    aout_getfunctions( &p_module->p_functions->aout );
-    vout_getfunctions( &p_module->p_functions->vout );
-    intf_getfunctions( &p_module->p_functions->intf );
+    _M( aout_getfunctions )( &p_module->p_functions->aout );
+    _M( vout_getfunctions )( &p_module->p_functions->vout );
+    _M( intf_getfunctions )( &p_module->p_functions->intf );
 
     p_module->p_config = p_config;
 
@@ -106,7 +106,7 @@ int ActivateModule( module_t * p_module )
  * returns, i_usage can be set to -1 and the module unloaded. Be careful to
  * lock usage_lock during the whole process.
  *****************************************************************************/
-int DeactivateModule( module_t * p_module )
+MODULE_DEACTIVATE
 {
     free( p_module->p_functions );
 
index de62fa504cac784bb36b94472ddb837bc2a3e9fb..f22c5533c2f3889cea3a621a2441624d1c5794e4 100644 (file)
@@ -20,6 +20,9 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
+#define MODULE_NAME dummy
+#include "modules_inner.h"
+
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
 #include "threads.h"
 #include "mtime.h"
 #include "tests.h"
-#include "modules.h"
 
 #include "intf_msg.h"
 #include "interface.h"
 
+#include "modules.h"
+
 #include "main.h"
 
 /*****************************************************************************
@@ -59,7 +63,7 @@ static void intf_Run       ( intf_thread_t *p_intf );
  * Functions exported as capabilities. They are declared as static so that
  * we don't pollute the namespace too much.
  *****************************************************************************/
-void intf_getfunctions( function_list_t * p_function_list )
+void _M( intf_getfunctions )( function_list_t * p_function_list )
 {
     p_function_list->pf_probe = intf_Probe;
     p_function_list->functions.intf.pf_open  = intf_Open;
index d76e015edfc4d274eab9c9342c79e07fe40054ef..12ae8b3164d6f6ed76c50f6bd5176352426565ae 100644 (file)
@@ -20,6 +20,9 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
+#define MODULE_NAME dummy
+#include "modules_inner.h"
+
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
 #include "threads.h"
 #include "mtime.h"
 #include "tests.h"
-#include "modules.h"
 
 #include "video.h"
 #include "video_output.h"
 
 #include "intf_msg.h"
 
+#include "modules.h"
+
 #define DUMMY_WIDTH 16
 #define DUMMY_HEIGHT 16
 #define DUMMY_BITS_PER_PLANE 16
@@ -75,7 +79,7 @@ static void vout_Display   ( struct vout_thread_s * );
  * Functions exported as capabilities. They are declared as static so that
  * we don't pollute the namespace too much.
  *****************************************************************************/
-void vout_getfunctions( function_list_t * p_function_list )
+void _M( vout_getfunctions )( function_list_t * p_function_list )
 {
     p_function_list->pf_probe = vout_Probe;
     p_function_list->functions.vout.pf_create     = vout_Create;
index f648cc4fd72373ccaeb6227836de420bec40f1df..07a54d6055ea0cfe2c24bf31598762bc715ab68c 100644 (file)
@@ -21,6 +21,7 @@
  *****************************************************************************/
 
 #define MODULE_NAME dvd
+#include "modules_inner.h"
 
 /*****************************************************************************
  * Preamble
@@ -36,7 +37,6 @@
 #include "mtime.h"
 
 #include "modules.h"
-#include "modules_inner.h"
 
 /*****************************************************************************
  * Build configuration tree.
@@ -49,7 +49,7 @@ MODULE_CONFIG_END
 /*****************************************************************************
  * Capabilities defined in the other files.
  *****************************************************************************/
-extern void input_getfunctions( function_list_t * p_function_list );
+void _M( input_getfunctions )( function_list_t * p_function_list );
 
 /*****************************************************************************
  * InitModule: get the module structure and configuration.
@@ -59,7 +59,7 @@ extern void input_getfunctions( function_list_t * p_function_list );
  * be unloaded later to save memory, and we want to be able to access this
  * data even after the module has been unloaded.
  *****************************************************************************/
-int InitModule( module_t * p_module )
+MODULE_INIT
 {
     p_module->psz_name = MODULE_STRING;
     p_module->psz_longname = "DVD input module";
@@ -79,7 +79,7 @@ int InitModule( module_t * p_module )
  * be set to 0 and calls to NeedModule() be made to increment it. To unload
  * the module, one has to wait until i_usage == 0 and call DeactivateModule().
  *****************************************************************************/
-int ActivateModule( module_t * p_module )
+MODULE_ACTIVATE
 {
     p_module->p_functions = malloc( sizeof( module_functions_t ) );
     if( p_module->p_functions == NULL )
@@ -87,7 +87,7 @@ int ActivateModule( module_t * p_module )
         return( -1 );
     }
 
-    input_getfunctions( &p_module->p_functions->input );
+    _M( input_getfunctions )( &p_module->p_functions->input );
 
     p_module->p_config = p_config;
 
@@ -101,7 +101,7 @@ int ActivateModule( module_t * p_module )
  * returns, i_usage can be set to -1 and the module unloaded. Be careful to
  * lock usage_lock during the whole process.
  *****************************************************************************/
-int DeactivateModule( module_t * p_module )
+MODULE_DEACTIVATE
 {
     free( p_module->p_functions );
 
index b462ce954320573b7624a9f9413352458bc9c0a1..235ad4eb7714de46265f718270e42fd6a8c3429b 100644 (file)
@@ -2,7 +2,7 @@
  * dvd_css.c: Functions for DVD authentification and unscrambling
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: dvd_css.c,v 1.11 2001/02/20 02:53:13 stef Exp $
+ * $Id: dvd_css.c,v 1.12 2001/02/20 07:49:12 sam Exp $
  *
  * Author: StĆ©phane Borel <stef@via.ecp.fr>
  *
@@ -34,7 +34,7 @@
  *****************************************************************************/
 #include "defs.h"
 
-#if defined( HAVE_SYS_DVDIO_H ) || defined( LINUX_DVD )
+#if defined( HAVE_SYS_DVDIO_H ) || defined( LINUX_DVD ) || defined( SYS_BEOS )
 
 #include <stdio.h>
 #include <unistd.h>
 #endif
 
 #include "common.h"
+
 #include "intf_msg.h"
+
 #include "dvd_css.h"
+#include "dvd_ioctl.h"
 #include "dvd_ifo.h"
+
 #include "input_dvd.h"
 
 /*****************************************************************************
@@ -428,7 +432,7 @@ static int CSSGetASF( int i_fd )
     for( auth_info.lsasf.agid = 0 ; auth_info.lsasf.agid < 4 ;
                                                     auth_info.lsasf.agid++ )
     {
-        if( !( ioctl( i_fd, DVD_AUTH, &auth_info ) ) )
+        if( !( dvd_ioctl( i_fd, DVD_AUTH, &auth_info ) ) )
         {
             intf_WarnMsg( 3, "CSS: %sAuthenticated",
                                     ( auth_info.lsasf.asf ) ? "" : "not " );
@@ -795,7 +799,7 @@ int CSSTest( int i_fd )
     dvd.type = DVD_STRUCT_COPYRIGHT;
     dvd.copyright.layer_num = 0;
 
-    if( ioctl( i_fd, DVD_READ_STRUCT, &dvd ) < 0 )
+    if( dvd_ioctl( i_fd, DVD_READ_STRUCT, &dvd ) < 0 )
     {
         intf_ErrMsg( "DVD ioctl error" );
         return -1;
@@ -844,7 +848,7 @@ css_t CSSInit( int i_fd )
         intf_WarnMsg( 3, "CSS: Request AGID %d", i );
         auth_info.type = DVD_LU_SEND_AGID;
         auth_info.lsa.agid = 0;
-        i_error =  ioctl( i_fd, DVD_AUTH, &auth_info );
+        i_error =  dvd_ioctl( i_fd, DVD_AUTH, &auth_info );
         if( i_error != -1 )
         {
             /* No error during ioctl: we know if device
@@ -855,7 +859,7 @@ css_t CSSInit( int i_fd )
         intf_ErrMsg( "CSS: AGID N/A, invalidating" );
         auth_info.type = DVD_INVALIDATE_AGID;
         auth_info.lsa.agid = 0;
-        ioctl( i_fd, DVD_AUTH, &auth_info );
+        dvd_ioctl( i_fd, DVD_AUTH, &auth_info );
     }
 
     /* Unable to authenticate without AGID */
@@ -883,7 +887,7 @@ css_t CSSInit( int i_fd )
     css.i_agid = auth_info.lsa.agid;
 
     /* Send challenge to LU */
-    if( ioctl( i_fd, DVD_AUTH, &auth_info )<0 )
+    if( dvd_ioctl( i_fd, DVD_AUTH, &auth_info )<0 )
     {
         intf_ErrMsg( "CSS: Send challenge to LU failed ");
         css.b_error = 1;
@@ -891,7 +895,7 @@ css_t CSSInit( int i_fd )
     }
 
     /* Get key1 from LU */
-    if( ioctl( i_fd, DVD_AUTH, &auth_info ) < 0)
+    if( dvd_ioctl( i_fd, DVD_AUTH, &auth_info ) < 0)
     {
         intf_ErrMsg( "CSS: Get key1 from LU failed ");
         css.b_error = 1;
@@ -928,7 +932,7 @@ css_t CSSInit( int i_fd )
     }
 
     /* Get challenge from LU */
-    if( ioctl( i_fd, DVD_AUTH, &auth_info ) < 0 )
+    if( dvd_ioctl( i_fd, DVD_AUTH, &auth_info ) < 0 )
     {
         intf_ErrMsg( "CSS: Get challenge from LU failed ");
         css.b_error = 1;
@@ -953,7 +957,7 @@ css_t CSSInit( int i_fd )
     /* Returning data, let LU change state */
 
     /* Send key2 to LU */
-    if( ioctl( i_fd, DVD_AUTH, &auth_info ) < 0 )
+    if( dvd_ioctl( i_fd, DVD_AUTH, &auth_info ) < 0 )
     {
         intf_ErrMsg( "CSS: Send key2 to LU failed (expected)" );
         return css;
@@ -999,7 +1003,7 @@ css_t CSSInit( int i_fd )
     dvd.disckey.agid = css.i_agid;
     memset( dvd.disckey.value, 0, 2048 );
 
-    if( ioctl( i_fd, DVD_READ_STRUCT, &dvd ) < 0 )
+    if( dvd_ioctl( i_fd, DVD_READ_STRUCT, &dvd ) < 0 )
     {
         intf_ErrMsg( "CSS: Could not read Disc Key" );
         css.b_error = 1;
index fe01aef0baee08260afc4c672581eb69706f2db3..d3996f402eb544b306de7869ba31b0cc53000f1c 100644 (file)
@@ -2,7 +2,7 @@
  * dvd_ifo.c: Functions for ifo parsing
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: dvd_ifo.c,v 1.12 2001/02/20 02:56:50 stef Exp $
+ * $Id: dvd_ifo.c,v 1.13 2001/02/20 07:49:12 sam Exp $
  *
  * Author: StĆ©phane Borel <stef@via.ecp.fr>
  *
@@ -39,6 +39,7 @@
 #include "intf_msg.h"
 #include "dvd_ifo.h"
 #include "dvd_udf.h"
+#include "dvd_css.h"
 #include "input_dvd.h"
 
 /*
diff --git a/plugins/dvd/dvd_ioctl.c b/plugins/dvd/dvd_ioctl.c
new file mode 100644 (file)
index 0000000..1723a2f
--- /dev/null
@@ -0,0 +1,675 @@
+/*****************************************************************************
+ * dvd_ioctl.c: DVD ioctl replacement function
+ *****************************************************************************
+ * Copyright (C) 1999-2001 VideoLAN
+ * $Id: dvd_ioctl.c,v 1.1 2001/02/20 07:49:12 sam Exp $
+ *
+ * Authors: Markus Kuespert <ltlBeBoy@beosmail.com>
+ *          Samuel Hocevar <sam@zoy.org>
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Preamble
+ *****************************************************************************/
+#include "defs.h"
+
+#include <netinet/in.h>
+#ifdef HAVE_SYS_IOCTL_H
+#   include <sys/ioctl.h>
+#endif
+#ifdef HAVE_SYS_DVDIO_H
+#   include <sys/dvdio.h>
+#endif
+#ifdef LINUX_DVD
+#   include <linux/cdrom.h>
+#endif
+#ifdef SYS_BEOS
+#   include <malloc.h>
+#   include <scsi.h>
+#endif
+
+#include "common.h"
+#include "intf_msg.h"
+
+#include "dvd_ioctl.h"
+
+/*****************************************************************************
+ * Local prototypes
+ *****************************************************************************/
+#if defined( SYS_BEOS )
+static int  dvd_do_auth          ( int i_fd, dvd_authinfo *p_authinfo );
+static int  dvd_read_struct      ( int i_fd, dvd_struct *p_dvd );
+static int  dvd_read_physical    ( int i_fd, dvd_struct *p_dvd );
+static int  dvd_read_copyright   ( int i_fd, dvd_struct *p_dvd );
+static int  dvd_read_disckey     ( int i_fd, dvd_struct *p_dvd );
+static int  dvd_read_bca         ( int i_fd, dvd_struct *p_dvd );
+static int  dvd_read_manufact    ( int i_fd, dvd_struct *p_dvd );
+static int  communicate_with_dvd ( int i_fd,
+                                   struct cdrom_generic_command *p_cgc );
+static void init_cdrom_command   ( struct cdrom_generic_command *p_cgc,
+                                   void *buf, int i_len, int i_type );
+static void setup_report_key     ( struct cdrom_generic_command *p_cgc,
+                                   unsigned i_agid, unsigned i_type );
+static void setup_send_key       ( struct cdrom_generic_command *p_cgc,
+                                   unsigned i_agid, unsigned i_type );
+#endif
+
+/*****************************************************************************
+ * dvd_ioctl: DVD ioctl() wrapper
+ *****************************************************************************
+ * Since the DVD ioctls do not exist on every machine, we provide this wrapper
+ * so that it becomes easier to port them to any architecture.
+ *****************************************************************************/
+int dvd_ioctl( int i_fd, unsigned long i_op, void *p_arg )
+{
+#if defined( HAVE_SYS_DVDIO_H ) || defined( LINUX_DVD )
+    return( ioctl( i_fd, i_op, p_arg ) );
+
+#elif defined( SYS_BEOS )
+    switch ( i_op )
+    {
+    case DVD_AUTH:
+        return dvd_do_auth( i_fd, (dvd_authinfo *)p_arg );
+
+    case DVD_READ_STRUCT:
+        return dvd_read_struct( i_fd, (dvd_struct *)p_arg );
+
+    default:
+        intf_ErrMsg( "css error: unknown command 0x%x", i_op );
+        return -1;
+    }
+#else
+
+    return -1;
+#endif
+}
+
+#if defined( SYS_BEOS )
+
+/*****************************************************************************
+ * setup_report_key
+ *****************************************************************************/
+static void setup_report_key( struct cdrom_generic_command *p_cgc,
+                              unsigned i_agid, unsigned i_type )
+{
+    p_cgc->cmd[0] = GPCMD_REPORT_KEY;
+    p_cgc->cmd[10] = i_type | (i_agid << 6);
+
+    switch( i_type )
+    {
+        case 0:
+        case 8:
+        case 5:
+            p_cgc->buflen = 8;
+            break;
+
+        case 1:
+            p_cgc->buflen = 16;
+            break;
+
+        case 2:
+        case 4:
+            p_cgc->buflen = 12;
+            break;
+    }
+
+    p_cgc->cmd[9] = p_cgc->buflen;
+    p_cgc->data_direction = CGC_DATA_READ;
+}
+
+/*****************************************************************************
+ * setup_send_key
+ *****************************************************************************/
+static void setup_send_key( struct cdrom_generic_command *p_cgc,
+                            unsigned i_agid, unsigned i_type )
+{
+    p_cgc->cmd[0] = GPCMD_SEND_KEY;
+    p_cgc->cmd[10] = i_type | (i_agid << 6);
+
+    switch( i_type )
+    {
+        case 1:
+            p_cgc->buflen = 16;
+            break;
+
+        case 3:
+            p_cgc->buflen = 12;
+            break;
+
+        case 6:
+            p_cgc->buflen = 8;
+            break;
+    }
+
+    p_cgc->cmd[9] = p_cgc->buflen;
+    p_cgc->data_direction = CGC_DATA_WRITE;
+}
+
+/*****************************************************************************
+ * init_cdrom_command
+ *****************************************************************************/
+static void init_cdrom_command( struct cdrom_generic_command *p_cgc,
+                                void *buf, int i_len, int i_type )
+{
+    memset( p_cgc, 0, sizeof(struct cdrom_generic_command) );
+
+    if (buf)
+    {
+        memset( buf, 0, i_len );
+    }
+
+    p_cgc->buffer = (char *) buf;
+    p_cgc->buflen = i_len;
+    p_cgc->data_direction = i_type;
+    p_cgc->timeout = 255;
+}
+
+/* DVD handling */
+
+/*****************************************************************************
+ * dvd_do_auth
+ *****************************************************************************/
+static int dvd_do_auth( int i_fd, dvd_authinfo *p_authinfo )
+{
+    int i_ret;
+    unsigned char buf[20];
+    struct cdrom_generic_command p_cgc;
+
+#define copy_key(dest,src)  memcpy((dest), (src), sizeof(dvd_key))
+#define copy_chal(dest,src) memcpy((dest), (src), sizeof(dvd_challenge))
+
+#if 0
+    struct rpc_state_t rpc_state;
+#endif
+
+    memset( buf, 0, sizeof(buf) );
+    init_cdrom_command( &p_cgc, buf, 0, CGC_DATA_READ );
+
+    switch (p_authinfo->type)
+    {
+        /* LU data send */
+        case DVD_LU_SEND_AGID:
+
+            intf_WarnMsg( 2, "css dvd_do_auth: DVD_LU_SEND_AGID" );
+
+            setup_report_key(&p_cgc, p_authinfo->lsa.agid, 0);
+
+            /* handle uniform packets for scsi type devices (scsi,atapi) */
+            if ((i_ret = communicate_with_dvd(i_fd, &p_cgc)))
+            {
+                return i_ret;
+            }
+
+            p_authinfo->lsa.agid = buf[7] >> 6;
+            /* Returning data, let host change state */
+
+            break;
+
+        case DVD_LU_SEND_KEY1:
+
+            intf_WarnMsg( 2, "css dvd_do_auth: DVD_LU_SEND_KEY1" );
+
+            setup_report_key(&p_cgc, p_authinfo->lsk.agid, 2);
+
+            /* handle uniform packets for scsi type devices (scsi,atapi) */
+            if ((i_ret = communicate_with_dvd(i_fd, &p_cgc)))
+            {
+                return i_ret;
+            }
+
+            copy_key(p_authinfo->lsk.key, &buf[4]);
+            /* Returning data, let host change state */
+
+            break;
+
+        case DVD_LU_SEND_CHALLENGE:
+
+            intf_WarnMsg( 2, "css dvd_do_auth: DVD_LU_SEND_CHALLENGE" );
+
+            setup_report_key(&p_cgc, p_authinfo->lsc.agid, 1);
+
+            /* handle uniform packets for scsi type devices (scsi,atapi) */
+            if ((i_ret = communicate_with_dvd(i_fd, &p_cgc)))
+            {
+                return i_ret;
+            }
+
+            copy_chal(p_authinfo->lsc.chal, &buf[4]);
+            /* Returning data, let host change state */
+
+            break;
+
+        /* Post-auth key */
+        case DVD_LU_SEND_TITLE_KEY:
+
+            intf_WarnMsg( 2, "css dvd_do_auth: DVD_LU_SEND_TITLE_KEY" );
+
+            setup_report_key(&p_cgc, p_authinfo->lstk.agid, 4);
+            p_cgc.cmd[5] = p_authinfo->lstk.lba;
+            p_cgc.cmd[4] = p_authinfo->lstk.lba >> 8;
+            p_cgc.cmd[3] = p_authinfo->lstk.lba >> 16;
+            p_cgc.cmd[2] = p_authinfo->lstk.lba >> 24;
+
+            /* handle uniform packets for scsi type devices (scsi,atapi) */
+            if ((i_ret = communicate_with_dvd(i_fd, &p_cgc)))
+            {
+                return i_ret;
+            }
+
+            p_authinfo->lstk.cpm = (buf[4] >> 7) & 1;
+            p_authinfo->lstk.cp_sec = (buf[4] >> 6) & 1;
+            p_authinfo->lstk.cgms = (buf[4] >> 4) & 3;
+            copy_key(p_authinfo->lstk.title_key, &buf[5]);
+            /* Returning data, let host change state */
+
+            break;
+
+        case DVD_LU_SEND_ASF:
+
+            intf_WarnMsg( 2, "css dvd_do_auth: DVD_LU_SEND_ASF" );
+
+            setup_report_key(&p_cgc, p_authinfo->lsasf.agid, 5);
+
+            /* handle uniform packets for scsi type devices (scsi,atapi) */
+            if ((i_ret = communicate_with_dvd(i_fd, &p_cgc)))
+            {
+                return i_ret;
+            }
+
+            p_authinfo->lsasf.asf = buf[7] & 1;
+
+            break;
+
+        /* LU data receive (LU changes state) */
+        case DVD_HOST_SEND_CHALLENGE:
+
+            intf_WarnMsg( 2, "css dvd_do_auth: DVD_LU_SEND_CHALLENGE" );
+
+            setup_send_key(&p_cgc, p_authinfo->hsc.agid, 1);
+            buf[1] = 0xe;
+            copy_chal(&buf[4], p_authinfo->hsc.chal);
+
+            /* handle uniform packets for scsi type devices (scsi,atapi) */
+            if ((i_ret = communicate_with_dvd(i_fd, &p_cgc)))
+            {
+                return i_ret;
+            }
+
+            p_authinfo->type = DVD_LU_SEND_KEY1;
+
+            break;
+
+        case DVD_HOST_SEND_KEY2:
+
+            intf_WarnMsg( 2, "css dvd_do_auth: DVD_LU_SEND_KEY2" );
+
+            setup_send_key(&p_cgc, p_authinfo->hsk.agid, 3);
+            buf[1] = 0xa;
+            copy_key(&buf[4], p_authinfo->hsk.key);
+
+            /* handle uniform packets for scsi type devices (scsi,atapi) */
+            if ((i_ret = communicate_with_dvd(i_fd, &p_cgc)))
+            {
+                p_authinfo->type = DVD_AUTH_FAILURE;
+                return i_ret;
+            }
+            p_authinfo->type = DVD_AUTH_ESTABLISHED;
+
+            break;
+
+        /* Misc */
+        case DVD_INVALIDATE_AGID:
+
+            intf_WarnMsg( 2, "css dvd_do_auth: DVD_INVALIDATE_AGID" );
+
+            setup_report_key(&p_cgc, p_authinfo->lsa.agid, 0x3f);
+
+            /* handle uniform packets for scsi type devices (scsi,atapi) */
+            if ((i_ret = communicate_with_dvd(i_fd, &p_cgc)))
+            {
+                return i_ret;
+            }
+
+            break;
+
+        /* Get region settings */
+        case DVD_LU_SEND_RPC_STATE:
+
+            intf_WarnMsg( 2, "css dvd_do_auth: DVD_LU_SEND_RPC_STATE "
+                             "(unimplemented)" );
+
+#if 0
+            p_dvdetup_report_key(&p_cgc, 0, 8);
+            memset(&rpc_state, 0, sizeof(rpc_state_t));
+            p_cgc.buffer = (char *) &rpc_state;
+
+            /* handle uniform packets for scsi type devices (scsi,atapi) */
+            if ((i_ret = communicate_with_dvd(i_fd, &p_cgc)))
+            {
+                return i_ret;
+            }
+
+            p_authinfo->lrpcs.type = rpc_state.type_code;
+            p_authinfo->lrpcs.vra = rpc_state.vra;
+            p_authinfo->lrpcs.ucca = rpc_state.ucca;
+            p_authinfo->lrpcs.region_mask = rpc_state.region_mask;
+            p_authinfo->lrpcs.rpc_scheme = rpc_state.rpc_scheme;
+#endif
+
+            break;
+
+        /* Set region settings */
+        case DVD_HOST_SEND_RPC_STATE:
+
+            intf_WarnMsg( 2, "css dvd_do_auth: DVD_HOST_SEND_RPC_STATE" );
+
+            setup_send_key(&p_cgc, 0, 6);
+            buf[1] = 6;
+            buf[4] = p_authinfo->hrpcs.pdrc;
+
+            /* handle uniform packets for scsi type devices (scsi,atapi) */
+            if ((i_ret = communicate_with_dvd(i_fd, &p_cgc)))
+            {
+                return i_ret;
+            }
+
+            break;
+
+        default:
+            intf_ErrMsg( "css dvd_do_auth: invalid DVD key ioctl" );
+            return -1;
+
+    }
+
+    return 0;
+}
+
+/*****************************************************************************
+ * dvd_read_struct
+ *****************************************************************************/
+static int dvd_read_struct( int i_fd, dvd_struct *p_dvd )
+{
+    switch (p_dvd->type)
+    {
+        case DVD_STRUCT_PHYSICAL:
+
+            intf_WarnMsg( 2, "css dvd_read_struct: DVD_STRUCT_PHYSICAL" );
+            return dvd_read_physical(i_fd, p_dvd);
+
+        case DVD_STRUCT_COPYRIGHT:
+
+            intf_WarnMsg( 2, "css dvd_read_struct: DVD_STRUCT_COPYRIGHT" );
+            return dvd_read_copyright(i_fd, p_dvd);
+
+        case DVD_STRUCT_DISCKEY:
+
+            intf_WarnMsg( 2, "css dvd_read_struct: DVD_STRUCT_DISCKEY" );
+            return dvd_read_disckey(i_fd, p_dvd);
+
+        case DVD_STRUCT_BCA:
+
+            intf_WarnMsg( 2, "css dvd_read_struct: DVD_STRUCT_BCA" );
+            return dvd_read_bca(i_fd, p_dvd);
+
+        case DVD_STRUCT_MANUFACT:
+
+            intf_WarnMsg( 2, "css dvd_read_struct: DVD_STRUCT_MANUFACT" );
+            return dvd_read_manufact(i_fd, p_dvd);
+
+        default:
+            intf_WarnMsg( 2, "css dvd_read_struct: invalid request (%d)",
+                          p_dvd->type );
+            return -1;
+    }
+}
+
+/*****************************************************************************
+ * dvd_read_physical
+ *****************************************************************************/
+static int dvd_read_physical( int i_fd, dvd_struct *p_dvd )
+{
+    int i_ret, i;
+    u_char buf[4 + 4 * 20], *base;
+    struct dvd_layer *layer;
+    struct cdrom_generic_command cgc;
+
+    init_cdrom_command( &cgc, buf, sizeof(buf), CGC_DATA_READ );
+
+    cgc.cmd[0] = GPCMD_READ_DVD_STRUCTURE;
+    cgc.cmd[6] = p_dvd->physical.layer_num;
+    cgc.cmd[7] = p_dvd->type;
+    cgc.cmd[9] = cgc.buflen & 0xff;
+
+    /* handle uniform packets for scsi type devices (scsi,atapi) */
+    if ((i_ret = communicate_with_dvd(i_fd, &cgc)))
+    {
+        return i_ret;
+    }
+
+    base = &buf[4];
+    layer = &p_dvd->physical.layer[0];
+
+    /* place the data... really ugly, but at least we won't have to
+     * worry about endianess in userspace or here. */
+    for( i = 0; i < 4; ++i, base += 20, ++layer )
+    {
+        memset( layer, 0, sizeof(*layer) );
+
+        layer->book_version = base[0] & 0xf;
+        layer->book_type = base[0] >> 4;
+        layer->min_rate = base[1] & 0xf;
+        layer->disc_size = base[1] >> 4;
+        layer->layer_type = base[2] & 0xf;
+        layer->track_path = (base[2] >> 4) & 1;
+        layer->nlayers = (base[2] >> 5) & 3;
+        layer->track_density = base[3] & 0xf;
+        layer->linear_density = base[3] >> 4;
+        layer->start_sector = base[5] << 16 | base[6] << 8 | base[7];
+        layer->end_sector = base[9] << 16 | base[10] << 8 | base[11];
+        layer->end_sector_l0 = base[13] << 16 | base[14] << 8 | base[15];
+        layer->bca = base[16] >> 7;
+    }
+
+    return 0;
+}
+
+/*****************************************************************************
+ * dvd_read_copyright
+ *****************************************************************************/
+static int dvd_read_copyright( int i_fd, dvd_struct *p_dvd )
+{
+    int i_ret;
+    u_char buf[8];
+    struct cdrom_generic_command cgc;
+
+    init_cdrom_command( &cgc, buf, sizeof(buf), CGC_DATA_READ );
+
+    cgc.cmd[0] = GPCMD_READ_DVD_STRUCTURE;
+    cgc.cmd[6] = p_dvd->copyright.layer_num;
+    cgc.cmd[7] = p_dvd->type;
+    cgc.cmd[8] = cgc.buflen >> 8;
+    cgc.cmd[9] = cgc.buflen & 0xff;
+
+    /* handle uniform packets for scsi type devices (scsi,atapi) */
+    if( (i_ret = communicate_with_dvd(i_fd, &cgc)) )
+    {
+        return i_ret;
+    }
+
+    p_dvd->copyright.cpst = buf[4];
+    p_dvd->copyright.rmi = buf[5];
+
+    return 0;
+}
+
+/*****************************************************************************
+ * dvd_read_disckey
+ *****************************************************************************/
+static int dvd_read_disckey( int i_fd, dvd_struct *p_dvd )
+{
+    int i_ret, size;
+    u_char *buf;
+    struct cdrom_generic_command cgc;
+
+    size = sizeof( p_dvd->disckey.value ) + 4;
+
+#if 0
+    if ((buf = (u_char *) kmalloc(size, GFP_KERNEL)) == NULL)
+    {
+        return -ENOMEM;
+    }
+#endif
+    buf = (u_char *) malloc(size);
+
+    init_cdrom_command(&cgc, buf, size, CGC_DATA_READ);
+    cgc.cmd[0] = GPCMD_READ_DVD_STRUCTURE;
+    cgc.cmd[7] = p_dvd->type;
+    cgc.cmd[8] = size >> 8;
+    cgc.cmd[9] = size & 0xff;
+    cgc.cmd[10] = p_dvd->disckey.agid << 6;
+
+    /* handle uniform packets for scsi type devices (scsi,atapi) */
+    if( !(i_ret = communicate_with_dvd(i_fd, &cgc)) )
+    {
+        memcpy( p_dvd->disckey.value, &buf[4], sizeof(p_dvd->disckey.value) );
+    }
+
+    free( buf );
+    return i_ret;
+}
+
+/*****************************************************************************
+ * dvd_read_bca
+ *****************************************************************************/
+static int dvd_read_bca( int i_fd, dvd_struct *p_dvd )
+{
+    int i_ret;
+    u_char buf[4 + 188];
+    struct cdrom_generic_command cgc;
+
+    init_cdrom_command( &cgc, buf, sizeof(buf), CGC_DATA_READ );
+    cgc.cmd[0] = GPCMD_READ_DVD_STRUCTURE;
+    cgc.cmd[7] = p_dvd->type;
+    cgc.cmd[9] = cgc.buflen = 0xff;
+
+    /* handle uniform packets for scsi type devices (scsi,atapi) */
+    if( (i_ret = communicate_with_dvd(i_fd, &cgc)) )
+    {
+        return i_ret;
+    }
+
+    p_dvd->bca.len = buf[0] << 8 | buf[1];
+    if( p_dvd->bca.len < 12 || p_dvd->bca.len > 188 )
+    {
+        intf_ErrMsg("css error: invalid BCA length (%d)", p_dvd->bca.len );
+        return -1;
+    }
+
+    memcpy( p_dvd->bca.value, &buf[4], p_dvd->bca.len );
+
+    return 0;
+}
+
+/*****************************************************************************
+ * dvd_read_manufact
+ *****************************************************************************/
+static int dvd_read_manufact( int i_fd, dvd_struct *p_dvd )
+{
+    int i_ret = 0, size;
+    u_char *buf;
+    struct cdrom_generic_command cgc;
+
+    size = sizeof(p_dvd->manufact.value) + 4;
+
+#if 0
+    if( (buf = (u_char *) kmalloc(size, GFP_KERNEL)) == NULL )
+    {
+        return -ENOMEM;
+    }
+#endif
+    buf = (u_char *) malloc(size);
+
+    init_cdrom_command( &cgc, buf, size, CGC_DATA_READ );
+    cgc.cmd[0] = GPCMD_READ_DVD_STRUCTURE;
+    cgc.cmd[7] = p_dvd->type;
+    cgc.cmd[8] = size >> 8;
+    cgc.cmd[9] = size & 0xff;
+
+    /* handle uniform packets for scsi type devices (scsi,atapi) */
+    if ((i_ret = communicate_with_dvd(i_fd, &cgc)))
+    {
+        return i_ret;
+    }
+
+    p_dvd->manufact.len = buf[0] << 8 | buf[1];
+    if( p_dvd->manufact.len < 0 || p_dvd->manufact.len > 2048 )
+    {
+        intf_ErrMsg( "css error: invalid manufacturer info length "
+                     "(%d)\n", p_dvd->bca.len );
+        i_ret = -1;
+    }
+    else
+    {
+        memcpy( p_dvd->manufact.value, &buf[4], p_dvd->manufact.len );
+    }
+
+    free( buf );
+    return i_ret;
+}
+
+/*****************************************************************************
+ * communicate_with_dvd
+ *****************************************************************************/
+static int communicate_with_dvd( int i_fd,
+                                 struct cdrom_generic_command *p_cgc )
+{
+    raw_device_command rdc;
+    memset( &rdc, 0, sizeof( rdc ) );
+
+    /* fill out our raw device command data */
+    rdc.data = p_cgc->buffer;
+    rdc.data_length = p_cgc->buflen;
+    rdc.sense_data = p_cgc->sense;
+    rdc.sense_data_length = 0;
+    rdc.timeout = 1000000;
+
+    if( p_cgc->data_direction == CGC_DATA_READ )
+    {
+        intf_WarnMsg( 2, "css: data_direction == CGC_DATA_READ" );
+        rdc.flags = B_RAW_DEVICE_DATA_IN;
+    }
+
+    rdc.command_length = 12;
+    rdc.command[0] = p_cgc->cmd[0];
+    rdc.command[1] = p_cgc->cmd[1];
+    rdc.command[2] = p_cgc->cmd[2];
+    rdc.command[3] = p_cgc->cmd[3];
+    rdc.command[4] = p_cgc->cmd[4];
+    rdc.command[5] = p_cgc->cmd[5];
+    rdc.command[6] = p_cgc->cmd[6];
+    rdc.command[7] = p_cgc->cmd[7];
+    rdc.command[8] = p_cgc->cmd[8];
+    rdc.command[9] = p_cgc->cmd[9];
+    rdc.command[10] = p_cgc->cmd[10];
+    rdc.command[11] = p_cgc->cmd[11];
+    rdc.command[12] = p_cgc->cmd[12];
+
+    return ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) );
+}
+
+#endif
+
diff --git a/plugins/dvd/dvd_ioctl.h b/plugins/dvd/dvd_ioctl.h
new file mode 100644 (file)
index 0000000..4376824
--- /dev/null
@@ -0,0 +1,766 @@
+/*****************************************************************************
+ * dvd_ioctl.h: DVD ioctl replacement function
+ *****************************************************************************
+ * Copyright (C) 1999-2001 VideoLAN
+ * $Id: dvd_ioctl.h,v 1.1 2001/02/20 07:49:12 sam Exp $
+ *
+ * Authors: David Giller <rafetmad@oxy.edu>
+ *          Eberhard Moenkeberg <emoenke@gwdg.de>
+ *          David van Leeuwen <david@tm.tno.nl>
+ *          Erik Andersen <andersee@debian.org>
+ *          Jens Axboe <axboe@suse.de>
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ *****************************************************************************/
+
+int dvd_ioctl( int i_fd, unsigned long i_op, void *p_arg );
+
+/*****************************************************************************
+ * This is the Linux kernel's <linux/cdrom.h>, almost verbatim.
+ *****************************************************************************/
+
+/*
+ * -- <linux/cdrom.h>
+ * General header file for linux CD-ROM drivers 
+ * Copyright (C) 1992         David Giller, rafetmad@oxy.edu
+ *               1994, 1995   Eberhard Moenkeberg, emoenke@gwdg.de
+ *               1996         David van Leeuwen, david@tm.tno.nl
+ *               1997, 1998   Erik Andersen, andersee@debian.org
+ *               1998-2000    Jens Axboe, axboe@suse.de
+ */
+
+#ifndef        _LINUX_CDROM_H
+#define        _LINUX_CDROM_H
+
+#ifdef SYS_BEOS
+#   include <be/support/byteorder.h>
+#else
+#   include <asm/byteorder.h>
+#endif
+
+/*******************************************************
+ * As of Linux 2.1.x, all Linux CD-ROM application programs will use this 
+ * (and only this) include file.  It is my hope to provide Linux with
+ * a uniform interface between software accessing CD-ROMs and the various 
+ * device drivers that actually talk to the drives.  There may still be
+ * 23 different kinds of strange CD-ROM drives, but at least there will 
+ * now be one, and only one, Linux CD-ROM interface.
+ *
+ * Additionally, as of Linux 2.1.x, all Linux application programs 
+ * should use the O_NONBLOCK option when opening a CD-ROM device 
+ * for subsequent ioctl commands.  This allows for neat system errors 
+ * like "No medium found" or "Wrong medium type" upon attempting to 
+ * mount or play an empty slot, mount an audio disc, or play a data disc.
+ * Generally, changing an application program to support O_NONBLOCK
+ * is as easy as the following:
+ *       -    drive = open("/dev/cdrom", O_RDONLY);
+ *       +    drive = open("/dev/cdrom", O_RDONLY | O_NONBLOCK);
+ * It is worth the small change.
+ *
+ *  Patches for many common CD programs (provided by David A. van Leeuwen)
+ *  can be found at:  ftp://ftp.gwdg.de/pub/linux/cdrom/drivers/cm206/
+ * 
+ *******************************************************/
+
+/* When a driver supports a certain function, but the cdrom drive we are 
+ * using doesn't, we will return the error EDRIVE_CANT_DO_THIS.  We will 
+ * borrow the "Operation not supported" error from the network folks to 
+ * accomplish this.  Maybe someday we will get a more targeted error code, 
+ * but this will do for now... */
+#define EDRIVE_CANT_DO_THIS  EOPNOTSUPP
+
+/*******************************************************
+ * The CD-ROM IOCTL commands  -- these should be supported by 
+ * all the various cdrom drivers.  For the CD-ROM ioctls, we 
+ * will commandeer byte 0x53, or 'S'.
+ *******************************************************/
+#define CDROMPAUSE             0x5301 /* Pause Audio Operation */ 
+#define CDROMRESUME            0x5302 /* Resume paused Audio Operation */
+#define CDROMPLAYMSF           0x5303 /* Play Audio MSF (struct cdrom_msf) */
+#define CDROMPLAYTRKIND                0x5304 /* Play Audio Track/index 
+                                           (struct cdrom_ti) */
+#define CDROMREADTOCHDR                0x5305 /* Read TOC header 
+                                           (struct cdrom_tochdr) */
+#define CDROMREADTOCENTRY      0x5306 /* Read TOC entry 
+                                           (struct cdrom_tocentry) */
+#define CDROMSTOP              0x5307 /* Stop the cdrom drive */
+#define CDROMSTART             0x5308 /* Start the cdrom drive */
+#define CDROMEJECT             0x5309 /* Ejects the cdrom media */
+#define CDROMVOLCTRL           0x530a /* Control output volume 
+                                           (struct cdrom_volctrl) */
+#define CDROMSUBCHNL           0x530b /* Read subchannel data 
+                                           (struct cdrom_subchnl) */
+#define CDROMREADMODE2         0x530c /* Read CDROM mode 2 data (2336 Bytes) 
+                                           (struct cdrom_read) */
+#define CDROMREADMODE1         0x530d /* Read CDROM mode 1 data (2048 Bytes)
+                                           (struct cdrom_read) */
+#define CDROMREADAUDIO         0x530e /* (struct cdrom_read_audio) */
+#define CDROMEJECT_SW          0x530f /* enable(1)/disable(0) auto-ejecting */
+#define CDROMMULTISESSION      0x5310 /* Obtain the start-of-last-session 
+                                           address of multi session disks 
+                                           (struct cdrom_multisession) */
+#define CDROM_GET_MCN          0x5311 /* Obtain the "Universal Product Code" 
+                                           if available (struct cdrom_mcn) */
+#define CDROM_GET_UPC          CDROM_GET_MCN  /* This one is depricated, 
+                                          but here anyway for compatability */
+#define CDROMRESET             0x5312 /* hard-reset the drive */
+#define CDROMVOLREAD           0x5313 /* Get the drive's volume setting 
+                                          (struct cdrom_volctrl) */
+#define CDROMREADRAW           0x5314  /* read data in raw mode (2352 Bytes)
+                                           (struct cdrom_read) */
+/* 
+ * These ioctls are used only used in aztcd.c and optcd.c
+ */
+#define CDROMREADCOOKED                0x5315  /* read data in cooked mode */
+#define CDROMSEEK              0x5316  /* seek msf address */
+  
+/*
+ * This ioctl is only used by the scsi-cd driver.  
+   It is for playing audio in logical block addressing mode.
+ */
+#define CDROMPLAYBLK           0x5317  /* (struct cdrom_blk) */
+
+/* 
+ * These ioctls are only used in optcd.c
+ */
+#define CDROMREADALL           0x5318  /* read all 2646 bytes */
+
+/* 
+ * These ioctls are (now) only in ide-cd.c for controlling 
+ * drive spindown time.  They should be implemented in the
+ * Uniform driver, via generic packet commands, GPCMD_MODE_SELECT_10,
+ * GPCMD_MODE_SENSE_10 and the GPMODE_POWER_PAGE...
+ *  -Erik
+ */
+#define CDROMGETSPINDOWN        0x531d
+#define CDROMSETSPINDOWN        0x531e
+
+/* 
+ * These ioctls are implemented through the uniform CD-ROM driver
+ * They _will_ be adopted by all CD-ROM drivers, when all the CD-ROM
+ * drivers are eventually ported to the uniform CD-ROM driver interface.
+ */
+#define CDROMCLOSETRAY         0x5319  /* pendant of CDROMEJECT */
+#define CDROM_SET_OPTIONS      0x5320  /* Set behavior options */
+#define CDROM_CLEAR_OPTIONS    0x5321  /* Clear behavior options */
+#define CDROM_SELECT_SPEED     0x5322  /* Set the CD-ROM speed */
+#define CDROM_SELECT_DISC      0x5323  /* Select disc (for juke-boxes) */
+#define CDROM_MEDIA_CHANGED    0x5325  /* Check is media changed  */
+#define CDROM_DRIVE_STATUS     0x5326  /* Get tray position, etc. */
+#define CDROM_DISC_STATUS      0x5327  /* Get disc type, etc. */
+#define CDROM_CHANGER_NSLOTS    0x5328  /* Get number of slots */
+#define CDROM_LOCKDOOR         0x5329  /* lock or unlock door */
+#define CDROM_DEBUG            0x5330  /* Turn debug messages on/off */
+#define CDROM_GET_CAPABILITY   0x5331  /* get capabilities */
+
+/* This ioctl is only used by sbpcd at the moment */
+#define CDROMAUDIOBUFSIZ        0x5382 /* set the audio buffer size */
+
+/* DVD-ROM Specific ioctls */
+#define DVD_READ_STRUCT                0x5390  /* Read structure */
+#define DVD_WRITE_STRUCT       0x5391  /* Write structure */
+#define DVD_AUTH               0x5392  /* Authentication */
+
+#define CDROM_SEND_PACKET      0x5393  /* send a packet to the drive */
+#define CDROM_NEXT_WRITABLE    0x5394  /* get next writable block */
+#define CDROM_LAST_WRITTEN     0x5395  /* get last block written on disc */
+
+/*******************************************************
+ * CDROM IOCTL structures
+ *******************************************************/
+
+/* Address in MSF format */
+struct cdrom_msf0              
+{
+       unsigned char   minute;
+       unsigned char   second;
+       unsigned char   frame;
+};
+
+/* Address in either MSF or logical format */
+union cdrom_addr               
+{
+       struct cdrom_msf0       msf;
+       int                     lba;
+};
+
+/* This struct is used by the CDROMPLAYMSF ioctl */ 
+struct cdrom_msf 
+{
+       unsigned char   cdmsf_min0;     /* start minute */
+       unsigned char   cdmsf_sec0;     /* start second */
+       unsigned char   cdmsf_frame0;   /* start frame */
+       unsigned char   cdmsf_min1;     /* end minute */
+       unsigned char   cdmsf_sec1;     /* end second */
+       unsigned char   cdmsf_frame1;   /* end frame */
+};
+
+/* This struct is used by the CDROMPLAYTRKIND ioctl */
+struct cdrom_ti 
+{
+       unsigned char   cdti_trk0;      /* start track */
+       unsigned char   cdti_ind0;      /* start index */
+       unsigned char   cdti_trk1;      /* end track */
+       unsigned char   cdti_ind1;      /* end index */
+};
+
+/* This struct is used by the CDROMREADTOCHDR ioctl */
+struct cdrom_tochdr    
+{
+       unsigned char   cdth_trk0;      /* start track */
+       unsigned char   cdth_trk1;      /* end track */
+};
+
+/* This struct is used by the CDROMVOLCTRL and CDROMVOLREAD ioctls */
+struct cdrom_volctrl
+{
+       unsigned char   channel0;
+       unsigned char   channel1;
+       unsigned char   channel2;
+       unsigned char   channel3;
+};
+
+/* This struct is used by the CDROMSUBCHNL ioctl */
+struct cdrom_subchnl 
+{
+       unsigned char   cdsc_format;
+       unsigned char   cdsc_audiostatus;
+       unsigned char   cdsc_adr:       4;
+       unsigned char   cdsc_ctrl:      4;
+       unsigned char   cdsc_trk;
+       unsigned char   cdsc_ind;
+       union cdrom_addr cdsc_absaddr;
+       union cdrom_addr cdsc_reladdr;
+};
+
+
+/* This struct is used by the CDROMREADTOCENTRY ioctl */
+struct cdrom_tocentry 
+{
+       unsigned char   cdte_track;
+       unsigned char   cdte_adr        :4;
+       unsigned char   cdte_ctrl       :4;
+       unsigned char   cdte_format;
+       union cdrom_addr cdte_addr;
+       unsigned char   cdte_datamode;
+};
+
+/* This struct is used by the CDROMREADMODE1, and CDROMREADMODE2 ioctls */
+struct cdrom_read      
+{
+       int     cdread_lba;
+       char    *cdread_bufaddr;
+       int     cdread_buflen;
+};
+
+/* This struct is used by the CDROMREADAUDIO ioctl */
+struct cdrom_read_audio
+{
+       union cdrom_addr addr; /* frame address */
+       unsigned char addr_format;    /* CDROM_LBA or CDROM_MSF */
+       int nframes;           /* number of 2352-byte-frames to read at once */
+       unsigned char *buf;           /* frame buffer (size: nframes*2352 bytes) */
+};
+
+/* This struct is used with the CDROMMULTISESSION ioctl */
+struct cdrom_multisession
+{
+       union cdrom_addr addr; /* frame address: start-of-last-session 
+                                  (not the new "frame 16"!).  Only valid
+                                  if the "xa_flag" is true. */
+       unsigned char xa_flag;        /* 1: "is XA disk" */
+       unsigned char addr_format;    /* CDROM_LBA or CDROM_MSF */
+};
+
+/* This struct is used with the CDROM_GET_MCN ioctl.  
+ * Very few audio discs actually have Universal Product Code information, 
+ * which should just be the Medium Catalog Number on the box.  Also note 
+ * that the way the codeis written on CD is _not_ uniform across all discs!
+ */  
+struct cdrom_mcn 
+{
+  unsigned char medium_catalog_number[14]; /* 13 ASCII digits, null-terminated */
+};
+
+/* This is used by the CDROMPLAYBLK ioctl */
+struct cdrom_blk 
+{
+       unsigned from;
+       unsigned short len;
+};
+
+#define CDROM_PACKET_SIZE      12
+
+#define CGC_DATA_UNKNOWN       0
+#define CGC_DATA_WRITE         1
+#define CGC_DATA_READ          2
+#define CGC_DATA_NONE          3
+
+/* for CDROM_PACKET_COMMAND ioctl */
+struct cdrom_generic_command
+{
+       unsigned char           cmd[CDROM_PACKET_SIZE];
+       unsigned char           *buffer;
+       unsigned int            buflen;
+       int                     stat;
+       struct request_sense    *sense;
+       unsigned char           data_direction;
+       int                     quiet;
+       int                     timeout;
+       void                    *reserved[1];
+};
+
+
+/*
+ * A CD-ROM physical sector size is 2048, 2052, 2056, 2324, 2332, 2336, 
+ * 2340, or 2352 bytes long.  
+
+*         Sector types of the standard CD-ROM data formats:
+ *
+ * format   sector type               user data size (bytes)
+ * -----------------------------------------------------------------------------
+ *   1     (Red Book)    CD-DA          2352    (CD_FRAMESIZE_RAW)
+ *   2     (Yellow Book) Mode1 Form1    2048    (CD_FRAMESIZE)
+ *   3     (Yellow Book) Mode1 Form2    2336    (CD_FRAMESIZE_RAW0)
+ *   4     (Green Book)  Mode2 Form1    2048    (CD_FRAMESIZE)
+ *   5     (Green Book)  Mode2 Form2    2328    (2324+4 spare bytes)
+ *
+ *
+ *       The layout of the standard CD-ROM data formats:
+ * -----------------------------------------------------------------------------
+ * - audio (red):                  | audio_sample_bytes |
+ *                                 |        2352        |
+ *
+ * - data (yellow, mode1):         | sync - head - data - EDC - zero - ECC |
+ *                                 |  12  -   4  - 2048 -  4  -   8  - 276 |
+ *
+ * - data (yellow, mode2):         | sync - head - data |
+ *                                 |  12  -   4  - 2336 |
+ *
+ * - XA data (green, mode2 form1): | sync - head - sub - data - EDC - ECC |
+ *                                 |  12  -   4  -  8  - 2048 -  4  - 276 |
+ *
+ * - XA data (green, mode2 form2): | sync - head - sub - data - Spare |
+ *                                 |  12  -   4  -  8  - 2324 -  4    |
+ *
+ */
+
+/* Some generally useful CD-ROM information -- mostly based on the above */
+#define CD_MINS              74 /* max. minutes per CD, not really a limit */
+#define CD_SECS              60 /* seconds per minute */
+#define CD_FRAMES            75 /* frames per second */
+#define CD_SYNC_SIZE         12 /* 12 sync bytes per raw data frame */
+#define CD_MSF_OFFSET       150 /* MSF numbering offset of first frame */
+#define CD_CHUNK_SIZE        24 /* lowest-level "data bytes piece" */
+#define CD_NUM_OF_CHUNKS     98 /* chunks per frame */
+#define CD_FRAMESIZE_SUB     96 /* subchannel data "frame" size */
+#define CD_HEAD_SIZE          4 /* header (address) bytes per raw data frame */
+#define CD_SUBHEAD_SIZE       8 /* subheader bytes per raw XA data frame */
+#define CD_EDC_SIZE           4 /* bytes EDC per most raw data frame types */
+#define CD_ZERO_SIZE          8 /* bytes zero per yellow book mode 1 frame */
+#define CD_ECC_SIZE         276 /* bytes ECC per most raw data frame types */
+#define CD_FRAMESIZE       2048 /* bytes per frame, "cooked" mode */
+#define CD_FRAMESIZE_RAW   2352 /* bytes per frame, "raw" mode */
+#define CD_FRAMESIZE_RAWER 2646 /* The maximum possible returned bytes */ 
+/* most drives don't deliver everything: */
+#define CD_FRAMESIZE_RAW1 (CD_FRAMESIZE_RAW-CD_SYNC_SIZE) /*2340*/
+#define CD_FRAMESIZE_RAW0 (CD_FRAMESIZE_RAW-CD_SYNC_SIZE-CD_HEAD_SIZE) /*2336*/
+
+#define CD_XA_HEAD        (CD_HEAD_SIZE+CD_SUBHEAD_SIZE) /* "before data" part of raw XA frame */
+#define CD_XA_TAIL        (CD_EDC_SIZE+CD_ECC_SIZE) /* "after data" part of raw XA frame */
+#define CD_XA_SYNC_HEAD   (CD_SYNC_SIZE+CD_XA_HEAD) /* sync bytes + header of XA frame */
+
+/* CD-ROM address types (cdrom_tocentry.cdte_format) */
+#define        CDROM_LBA 0x01 /* "logical block": first frame is #0 */
+#define        CDROM_MSF 0x02 /* "minute-second-frame": binary, not bcd here! */
+
+/* bit to tell whether track is data or audio (cdrom_tocentry.cdte_ctrl) */
+#define        CDROM_DATA_TRACK        0x04
+
+/* The leadout track is always 0xAA, regardless of # of tracks on disc */
+#define        CDROM_LEADOUT           0xAA
+
+/* audio states (from SCSI-2, but seen with other drives, too) */
+#define        CDROM_AUDIO_INVALID     0x00    /* audio status not supported */
+#define        CDROM_AUDIO_PLAY        0x11    /* audio play operation in progress */
+#define        CDROM_AUDIO_PAUSED      0x12    /* audio play operation paused */
+#define        CDROM_AUDIO_COMPLETED   0x13    /* audio play successfully completed */
+#define        CDROM_AUDIO_ERROR       0x14    /* audio play stopped due to error */
+#define        CDROM_AUDIO_NO_STATUS   0x15    /* no current audio status to return */
+
+/* capability flags used with the uniform CD-ROM driver */ 
+#define CDC_CLOSE_TRAY         0x1     /* caddy systems _can't_ close */
+#define CDC_OPEN_TRAY          0x2     /* but _can_ eject.  */
+#define CDC_LOCK               0x4     /* disable manual eject */
+#define CDC_SELECT_SPEED       0x8     /* programmable speed */
+#define CDC_SELECT_DISC                0x10    /* select disc from juke-box */
+#define CDC_MULTI_SESSION      0x20    /* read sessions>1 */
+#define CDC_MCN                        0x40    /* Medium Catalog Number */
+#define CDC_MEDIA_CHANGED      0x80    /* media changed */
+#define CDC_PLAY_AUDIO         0x100   /* audio functions */
+#define CDC_RESET               0x200   /* hard reset device */
+#define CDC_IOCTLS              0x400   /* driver has non-standard ioctls */
+#define CDC_DRIVE_STATUS        0x800   /* driver implements drive status */
+#define CDC_GENERIC_PACKET     0x1000  /* driver implements generic packets */
+#define CDC_CD_R               0x2000  /* drive is a CD-R */
+#define CDC_CD_RW              0x4000  /* drive is a CD-RW */
+#define CDC_DVD                        0x8000  /* drive is a DVD */
+#define CDC_DVD_R              0x10000 /* drive can write DVD-R */
+#define CDC_DVD_RAM            0x20000 /* drive can write DVD-RAM */
+
+/* drive status possibilities returned by CDROM_DRIVE_STATUS ioctl */
+#define CDS_NO_INFO            0       /* if not implemented */
+#define CDS_NO_DISC            1
+#define CDS_TRAY_OPEN          2
+#define CDS_DRIVE_NOT_READY    3
+#define CDS_DISC_OK            4
+
+/* return values for the CDROM_DISC_STATUS ioctl */
+/* can also return CDS_NO_[INFO|DISC], from above */
+#define CDS_AUDIO              100
+#define CDS_DATA_1             101
+#define CDS_DATA_2             102
+#define CDS_XA_2_1             103
+#define CDS_XA_2_2             104
+#define CDS_MIXED              105
+
+/* User-configurable behavior options for the uniform CD-ROM driver */
+#define CDO_AUTO_CLOSE         0x1     /* close tray on first open() */
+#define CDO_AUTO_EJECT         0x2     /* open tray on last release() */
+#define CDO_USE_FFLAGS         0x4     /* use O_NONBLOCK information on open */
+#define CDO_LOCK               0x8     /* lock tray on open files */
+#define CDO_CHECK_TYPE         0x10    /* check type on open for data */
+
+/* Special codes used when specifying changer slots. */
+#define CDSL_NONE              ((int) (~0U>>1)-1)
+#define CDSL_CURRENT           ((int) (~0U>>1))
+
+/* For partition based multisession access. IDE can handle 64 partitions
+ * per drive - SCSI CD-ROM's use minors to differentiate between the
+ * various drives, so we can't do multisessions the same way there.
+ * Use the -o session=x option to mount on them.
+ */
+#define CD_PART_MAX            64
+#define CD_PART_MASK           (CD_PART_MAX - 1)
+
+/*********************************************************************
+ * Generic Packet commands, MMC commands, and such
+ *********************************************************************/
+
+ /* The generic packet command opcodes for CD/DVD Logical Units,
+ * From Table 57 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */
+#define GPCMD_BLANK                        0xa1
+#define GPCMD_CLOSE_TRACK                  0x5b
+#define GPCMD_FLUSH_CACHE                  0x35
+#define GPCMD_FORMAT_UNIT                  0x04
+#define GPCMD_GET_CONFIGURATION                    0x46
+#define GPCMD_GET_EVENT_STATUS_NOTIFICATION 0x4a
+#define GPCMD_GET_PERFORMANCE              0xac
+#define GPCMD_INQUIRY                      0x12
+#define GPCMD_LOAD_UNLOAD                  0xa6
+#define GPCMD_MECHANISM_STATUS             0xbd
+#define GPCMD_MODE_SELECT_10               0x55
+#define GPCMD_MODE_SENSE_10                0x5a
+#define GPCMD_PAUSE_RESUME                 0x4b
+#define GPCMD_PLAY_AUDIO_10                0x45
+#define GPCMD_PLAY_AUDIO_MSF               0x47
+#define GPCMD_PLAY_AUDIO_TI                0x48
+#define GPCMD_PLAY_CD                      0xbc
+#define GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL  0x1e
+#define GPCMD_READ_10                      0x28
+#define GPCMD_READ_12                      0xa8
+#define GPCMD_READ_CDVD_CAPACITY           0x25
+#define GPCMD_READ_CD                      0xbe
+#define GPCMD_READ_CD_MSF                  0xb9
+#define GPCMD_READ_DISC_INFO               0x51
+#define GPCMD_READ_DVD_STRUCTURE           0xad
+#define GPCMD_READ_FORMAT_CAPACITIES       0x23
+#define GPCMD_READ_HEADER                  0x44
+#define GPCMD_READ_TRACK_RZONE_INFO        0x52
+#define GPCMD_READ_SUBCHANNEL              0x42
+#define GPCMD_READ_TOC_PMA_ATIP                    0x43
+#define GPCMD_REPAIR_RZONE_TRACK           0x58
+#define GPCMD_REPORT_KEY                   0xa4
+#define GPCMD_REQUEST_SENSE                0x03
+#define GPCMD_RESERVE_RZONE_TRACK          0x53
+#define GPCMD_SCAN                         0xba
+#define GPCMD_SEEK                         0x2b
+#define GPCMD_SEND_DVD_STRUCTURE           0xad
+#define GPCMD_SEND_EVENT                   0xa2
+#define GPCMD_SEND_KEY                     0xa3
+#define GPCMD_SEND_OPC                     0x54
+#define GPCMD_SET_READ_AHEAD               0xa7
+#define GPCMD_SET_STREAMING                0xb6
+#define GPCMD_START_STOP_UNIT              0x1b
+#define GPCMD_STOP_PLAY_SCAN               0x4e
+#define GPCMD_TEST_UNIT_READY              0x00
+#define GPCMD_VERIFY_10                            0x2f
+#define GPCMD_WRITE_10                     0x2a
+#define GPCMD_WRITE_AND_VERIFY_10          0x2e
+/* This is listed as optional in ATAPI 2.6, but is (curiously) 
+ * missing from Mt. Fuji, Table 57.  It _is_ mentioned in Mt. Fuji
+ * Table 377 as an MMC command for SCSi devices though...  Most ATAPI
+ * drives support it. */
+#define GPCMD_SET_SPEED                            0xbb
+/* This seems to be a SCSI specific CD-ROM opcode 
+ * to play data at track/index */
+#define GPCMD_PLAYAUDIO_TI                 0x48
+/*
+ * From MS Media Status Notification Support Specification. For
+ * older drives only.
+ */
+#define GPCMD_GET_MEDIA_STATUS             0xda
+
+/* Mode page codes for mode sense/set */
+#define GPMODE_R_W_ERROR_PAGE          0x01
+#define GPMODE_WRITE_PARMS_PAGE                0x05
+#define GPMODE_AUDIO_CTL_PAGE          0x0e
+#define GPMODE_POWER_PAGE              0x1a
+#define GPMODE_FAULT_FAIL_PAGE         0x1c
+#define GPMODE_TO_PROTECT_PAGE         0x1d
+#define GPMODE_CAPABILITIES_PAGE       0x2a
+#define GPMODE_ALL_PAGES               0x3f
+/* Not in Mt. Fuji, but in ATAPI 2.6 -- depricated now in favor
+ * of MODE_SENSE_POWER_PAGE */
+#define GPMODE_CDROM_PAGE              0x0d
+
+
+
+/* DVD struct types */
+#define DVD_STRUCT_PHYSICAL    0x00
+#define DVD_STRUCT_COPYRIGHT   0x01
+#define DVD_STRUCT_DISCKEY     0x02
+#define DVD_STRUCT_BCA         0x03
+#define DVD_STRUCT_MANUFACT    0x04
+
+struct dvd_layer {
+       unsigned char book_version      : 4;
+       unsigned char book_type         : 4;
+       unsigned char min_rate          : 4;
+       unsigned char disc_size         : 4;
+       unsigned char layer_type                : 4;
+       unsigned char track_path                : 1;
+       unsigned char nlayers           : 2;
+       unsigned char track_density     : 4;
+       unsigned char linear_density    : 4;
+       unsigned char bca               : 1;
+       uint32 start_sector;
+       uint32 end_sector;
+       uint32 end_sector_l0;
+};
+
+struct dvd_physical {
+       unsigned char type;
+       unsigned char layer_num;
+       struct dvd_layer layer[4];
+};
+
+struct dvd_copyright {
+       unsigned char type;
+
+       unsigned char layer_num;
+       unsigned char cpst;
+       unsigned char rmi;
+};
+
+struct dvd_disckey {
+       unsigned char type;
+
+       unsigned agid           : 2;
+       unsigned char value[2048];
+};
+
+struct dvd_bca {
+       unsigned char type;
+
+       int len;
+       unsigned char value[188];
+};
+
+struct dvd_manufact {
+       unsigned char type;
+
+       unsigned char layer_num;
+       int len;
+       unsigned char value[2048];
+};
+
+typedef union {
+       unsigned char type;
+
+       struct dvd_physical     physical;
+       struct dvd_copyright    copyright;
+       struct dvd_disckey      disckey;
+       struct dvd_bca          bca;
+       struct dvd_manufact     manufact;
+} dvd_struct;
+
+/*
+ * DVD authentication ioctl
+ */
+
+/* Authentication states */
+#define DVD_LU_SEND_AGID       0
+#define DVD_HOST_SEND_CHALLENGE        1
+#define DVD_LU_SEND_KEY1       2
+#define DVD_LU_SEND_CHALLENGE  3
+#define DVD_HOST_SEND_KEY2     4
+
+/* Termination states */
+#define DVD_AUTH_ESTABLISHED   5
+#define DVD_AUTH_FAILURE       6
+
+/* Other functions */
+#define DVD_LU_SEND_TITLE_KEY  7
+#define DVD_LU_SEND_ASF                8
+#define DVD_INVALIDATE_AGID    9
+#define DVD_LU_SEND_RPC_STATE  10
+#define DVD_HOST_SEND_RPC_STATE        11
+
+/* State data */
+typedef unsigned char dvd_key[5];              /* 40-bit value, MSB is first elem. */
+typedef unsigned char dvd_challenge[10];       /* 80-bit value, MSB is first elem. */
+
+struct dvd_lu_send_agid {
+       unsigned char type;
+       unsigned agid           : 2;
+};
+
+struct dvd_host_send_challenge {
+       unsigned char type;
+       unsigned agid           : 2;
+
+       dvd_challenge chal;
+};
+
+struct dvd_send_key {
+       unsigned char type;
+       unsigned agid           : 2;
+
+       dvd_key key;
+};
+
+struct dvd_lu_send_challenge {
+       unsigned char type;
+       unsigned agid           : 2;
+
+       dvd_challenge chal;
+};
+
+#define DVD_CPM_NO_COPYRIGHT   0
+#define DVD_CPM_COPYRIGHTED    1
+
+#define DVD_CP_SEC_NONE                0
+#define DVD_CP_SEC_EXIST       1
+
+#define DVD_CGMS_UNRESTRICTED  0
+#define DVD_CGMS_SINGLE                2
+#define DVD_CGMS_RESTRICTED    3
+
+struct dvd_lu_send_title_key {
+       unsigned char type;
+       unsigned agid           : 2;
+
+       dvd_key title_key;
+       int lba;
+       unsigned cpm            : 1;
+       unsigned cp_sec         : 1;
+       unsigned cgms           : 2;
+};
+
+struct dvd_lu_send_asf {
+       unsigned char type;
+       unsigned agid           : 2;
+
+       unsigned asf            : 1;
+};
+
+struct dvd_host_send_rpcstate {
+       unsigned char type;
+       unsigned char pdrc;
+};
+
+struct dvd_lu_send_rpcstate {
+       unsigned char type              : 2;
+       unsigned char vra               : 3;
+       unsigned char ucca              : 3;
+       unsigned char region_mask;
+       unsigned char rpc_scheme;
+};
+
+typedef union {
+       unsigned char type;
+
+       struct dvd_lu_send_agid         lsa;
+       struct dvd_host_send_challenge  hsc;
+       struct dvd_send_key             lsk;
+       struct dvd_lu_send_challenge    lsc;
+       struct dvd_send_key             hsk;
+       struct dvd_lu_send_title_key    lstk;
+       struct dvd_lu_send_asf          lsasf;
+       struct dvd_host_send_rpcstate   hrpcs;
+       struct dvd_lu_send_rpcstate     lrpcs;
+} dvd_authinfo;
+
+struct request_sense {
+#if defined(__BIG_ENDIAN_BITFIELD)
+       unsigned char valid             : 1;
+       unsigned char error_code                : 7;
+#elif defined(__LITTLE_ENDIAN_BITFIELD)
+       unsigned char error_code                : 7;
+       unsigned char valid             : 1;
+#endif
+       unsigned char segment_number;
+#if defined(__BIG_ENDIAN_BITFIELD)
+       unsigned char reserved1         : 2;
+       unsigned char ili               : 1;
+       unsigned char reserved2         : 1;
+       unsigned char sense_key         : 4;
+#elif defined(__LITTLE_ENDIAN_BITFIELD)
+       unsigned char sense_key         : 4;
+       unsigned char reserved2         : 1;
+       unsigned char ili               : 1;
+       unsigned char reserved1         : 2;
+#endif
+       unsigned char information[4];
+       unsigned char add_sense_len;
+       unsigned char command_info[4];
+       unsigned char asc;
+       unsigned char ascq;
+       unsigned char fruc;
+       unsigned char sks[3];
+       unsigned char asb[46];
+};
+
+typedef struct {
+       uint16 report_key_length;
+       unsigned char reserved1;
+       unsigned char reserved2;
+#if defined(__BIG_ENDIAN_BITFIELD)
+       unsigned char type_code                 : 2;
+       unsigned char vra                       : 3;
+       unsigned char ucca                      : 3;
+#elif defined(__LITTLE_ENDIAN_BITFIELD)
+       unsigned char ucca                      : 3;
+       unsigned char vra                       : 3;
+       unsigned char type_code                 : 2;
+#endif
+       unsigned char region_mask;
+       unsigned char rpc_scheme;
+       unsigned char reserved3;
+} rpc_state_t;
+
+#endif  /* _LINUX_CDROM_H */
+
index 1434db25fd1bef7ca7ae5a681c656c65906488d9..1d7239a3fa416739c4e167fa2254586d3cd53a24 100644 (file)
@@ -5,7 +5,7 @@
  * contains the basic udf handling functions
  *****************************************************************************
  * Copyright (C) 1998-2001 VideoLAN
- * $Id: dvd_udf.c,v 1.2 2001/02/18 01:42:05 stef Exp $
+ * $Id: dvd_udf.c,v 1.3 2001/02/20 07:49:12 sam Exp $
  *
  * Author: StĆ©phane Borel <stef@via.ecp.fr>
  *
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
+
+#define MODULE_NAME dvd
+#include "modules_inner.h"
+
 /*
  * Preamble
  */
index 12556f271faaa3dd01bb62cf1fc1d19d2668da19..01ab2a12fa3fc58b17c715a919545fe9e1b0aaf5 100644 (file)
@@ -10,7 +10,7 @@
  *  -dvd_udf to find files
  *****************************************************************************
  * Copyright (C) 1998-2001 VideoLAN
- * $Id: input_dvd.c,v 1.15 2001/02/20 02:53:13 stef Exp $
+ * $Id: input_dvd.c,v 1.16 2001/02/20 07:49:12 sam Exp $
  *
  * Author: StĆ©phane Borel <stef@via.ecp.fr>
  *
@@ -29,6 +29,9 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
+#define MODULE_NAME dvd
+#include "modules_inner.h"
+
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
@@ -78,7 +81,7 @@
  *****************************************************************************/
 static struct
 {
-       char    p_code[3];
+    char    p_code[3];
     char    p_lang_long[20];
 } lang_tbl[] =
     {
@@ -248,7 +251,7 @@ static int  DVDRewind   ( struct input_thread_s * );
  * Functions exported as capabilities. They are declared as static so that
  * we don't pollute the namespace too much.
  *****************************************************************************/
-void input_getfunctions( function_list_t * p_function_list )
+void _M( input_getfunctions )( function_list_t * p_function_list )
 {
 #define input p_function_list->functions.input
     p_function_list->pf_probe = DVDProbe;
@@ -329,7 +332,7 @@ static int DVDProbe( probedata_t *p_data )
  *****************************************************************************/
 static int DVDCheckCSS( input_thread_t * p_input )
 {
-#if defined( HAVE_SYS_DVDIO_H ) || defined( LINUX_DVD )
+#if defined( HAVE_SYS_DVDIO_H ) || defined( LINUX_DVD ) || defined( SYS_BEOS )
     return CSSTest( p_input->i_handle );
 #else
     /* DVD ioctls unavailable.
@@ -370,7 +373,7 @@ static int DVDSetArea( input_thread_t * p_input,
     IfoReadVTS( &(p_method->ifo) );
     intf_WarnMsg( 2, "Ifo: VTS initialized" );
 
-#if defined( HAVE_SYS_DVDIO_H ) || defined( LINUX_DVD )
+#if defined( HAVE_SYS_DVDIO_H ) || defined( LINUX_DVD ) || defined( SYS_BEOS )
     if( p_method->b_encrypted )
     {
         p_method->css.i_title = i_title;
@@ -664,7 +667,7 @@ static void DVDInit( input_thread_t * p_input )
     if( p_method->b_encrypted )
     {
 
-#if defined( HAVE_SYS_DVDIO_H ) || defined( LINUX_DVD )
+#if defined( HAVE_SYS_DVDIO_H ) || defined( LINUX_DVD ) || defined( SYS_BEOS )
         p_method->css = CSSInit( p_input->i_handle );
 
         if( ( p_input->b_error = p_method->css.b_error ) )
@@ -771,7 +774,7 @@ static int DVDRead( input_thread_t * p_input,
     /* Reads from DVD */
     readv( p_input->i_handle, p_vec, p_method->i_read_once );
 
-#if defined( HAVE_SYS_DVDIO_H ) || defined( LINUX_DVD )
+#if defined( HAVE_SYS_DVDIO_H ) || defined( LINUX_DVD ) || defined( SYS_BEOS )
     if( p_method->b_encrypted )
     {
         for( i=0 ; i<p_method->i_read_once ; i++ )
index a33b636521b0b04c8a4b53cee4d09c15998f8832..669e1d6abcd15fbce90cf3ebee237eebc793add4 100644 (file)
@@ -40,7 +40,7 @@ typedef struct thread_dvd_data_s
     int                     i_end_cell;
 
     /* Scrambling Information */
-#if defined( HAVE_SYS_DVDIO_H ) || defined( LINUX_DVD )
+#if defined( HAVE_SYS_DVDIO_H ) || defined( LINUX_DVD ) || defined( SYS_BEOS )
     struct css_s            css;
 #endif
 
@@ -60,7 +60,7 @@ void            IfoEnd( ifo_t * );
 /*****************************************************************************
  * Prototypes in dvd_css.c
  *****************************************************************************/
-#if defined( HAVE_SYS_DVDIO_H ) || defined( LINUX_DVD )
+#if defined( HAVE_SYS_DVDIO_H ) || defined( LINUX_DVD ) || defined( SYS_BEOS )
 int             CSSTest     ( int );
 struct css_s    CSSInit     ( int );
 int             CSSGetKey   ( struct css_s * );
index 1387645d88b632f423c56274bae986a7ee9f282a..92b2d2f8116e22421677e795b5a2cfd696f47b42 100644 (file)
@@ -20,6 +20,9 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
+#define MODULE_NAME esd
+#include "modules_inner.h"
+
 /* TODO:
  *
  * - use the libesd function to get latency when it's not buggy anymore
@@ -80,7 +83,7 @@ static void    aout_Close       ( aout_thread_t *p_aout );
  * Functions exported as capabilities. They are declared as static so that
  * we don't pollute the namespace too much.
  *****************************************************************************/
-void aout_getfunctions( function_list_t * p_function_list )
+void _M( aout_getfunctions )( function_list_t * p_function_list )
 {
     p_function_list->pf_probe = aout_Probe;
     p_function_list->functions.aout.pf_open = aout_Open;
index cefa673d590e47c59abdb4d1ae94d61577dce7b6..4595ec8350cf779095bf2ce80d2022fed4cf62b9 100644 (file)
@@ -21,6 +21,7 @@
  *****************************************************************************/
 
 #define MODULE_NAME esd
+#include "modules_inner.h"
 
 /*****************************************************************************
  * Preamble
@@ -36,7 +37,6 @@
 #include "mtime.h"
 
 #include "modules.h"
-#include "modules_inner.h"
 
 /*****************************************************************************
  * Build configuration tree.
@@ -50,7 +50,7 @@ MODULE_CONFIG_END
 /*****************************************************************************
  * Capabilities defined in the other files.
  *****************************************************************************/
-extern void aout_getfunctions( function_list_t * p_function_list );
+void _M( aout_getfunctions )( function_list_t * p_function_list );
 
 /*****************************************************************************
  * InitModule: get the module structure and configuration.
@@ -60,7 +60,7 @@ extern void aout_getfunctions( function_list_t * p_function_list );
  * be unloaded later to save memory, and we want to be able to access this
  * data even after the module has been unloaded.
  *****************************************************************************/
-int InitModule( module_t * p_module )
+MODULE_INIT
 {
     p_module->psz_name = MODULE_STRING;
     p_module->psz_longname = "EsounD audio module";
@@ -80,7 +80,7 @@ int InitModule( module_t * p_module )
  * be set to 0 and calls to NeedModule() be made to increment it. To unload
  * the module, one has to wait until i_usage == 0 and call DeactivateModule().
  *****************************************************************************/
-int ActivateModule( module_t * p_module )
+MODULE_ACTIVATE
 {
     p_module->p_functions = malloc( sizeof( module_functions_t ) );
     if( p_module->p_functions == NULL )
@@ -88,7 +88,7 @@ int ActivateModule( module_t * p_module )
         return( -1 );
     }
 
-    aout_getfunctions( &p_module->p_functions->aout );
+    _M( aout_getfunctions )( &p_module->p_functions->aout );
 
     p_module->p_config = p_config;
 
@@ -102,7 +102,7 @@ int ActivateModule( module_t * p_module )
  * returns, i_usage can be set to -1 and the module unloaded. Be careful to
  * lock usage_lock during the whole process.
  *****************************************************************************/
-int DeactivateModule( module_t * p_module )
+MODULE_DEACTIVATE
 {
     free( p_module->p_functions );
 
index 6ad24fd14a48cd18fe722be6eb5511e9cd839216..d5fb7a302a06655a6f5bea1e6083bdc42dda78ce 100644 (file)
@@ -21,6 +21,7 @@
  *****************************************************************************/
 
 #define MODULE_NAME fb
+#include "modules_inner.h"
 
 /*****************************************************************************
  * Preamble
@@ -38,7 +39,6 @@
 #include "video_output.h"
 
 #include "modules.h"
-#include "modules_inner.h"
 
 /*****************************************************************************
  * Building configuration tree
@@ -51,7 +51,7 @@ MODULE_CONFIG_END
 /*****************************************************************************
  * Capabilities defined in the other files.
  ******************************************************************************/
-extern void vout_getfunctions( function_list_t * p_function_list );
+void _M( vout_getfunctions )( function_list_t * p_function_list );
 
 /*****************************************************************************
  * InitModule: get the module structure and configuration.
@@ -61,7 +61,7 @@ extern void vout_getfunctions( function_list_t * p_function_list );
  * be unloaded later to save memory, and we want to be able to access this
  * data even after the module has been unloaded.
  *****************************************************************************/
-int InitModule( module_t * p_module )
+MODULE_INIT
 {
     p_module->psz_name = MODULE_STRING;
     p_module->psz_longname = "Linux console framebuffer module";
@@ -81,7 +81,7 @@ int InitModule( module_t * p_module )
  * be set to 0 and calls to NeedModule() be made to increment it. To unload
  * the module, one has to wait until i_usage == 0 and call DeactivateModule().
  *****************************************************************************/
-int ActivateModule( module_t * p_module )
+MODULE_ACTIVATE
 {
     p_module->p_functions = malloc( sizeof( module_functions_t ) );
     if( p_module->p_functions == NULL )
@@ -89,7 +89,7 @@ int ActivateModule( module_t * p_module )
         return( -1 );
     }
 
-    vout_getfunctions( &p_module->p_functions->vout );
+    _M( vout_getfunctions )( &p_module->p_functions->vout );
 
     p_module->p_config = p_config;
 
@@ -103,7 +103,7 @@ int ActivateModule( module_t * p_module )
  * returns, i_usage can be set to -1 and the module unloaded. Be careful to
  * lock usage_lock during the whole process.
  *****************************************************************************/
-int DeactivateModule( module_t * p_module )
+MODULE_DEACTIVATE
 {
     free( p_module->p_functions );
 
index 64eb5f2debd6a4f8d326e4644f87ba2769b4e3ba..43a236aa0330bab077e79ba16adfd7cf3421830d 100644 (file)
@@ -20,6 +20,9 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
+#define MODULE_NAME fb
+#include "modules_inner.h"
+
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
@@ -107,7 +110,7 @@ static void FBGfxMode      ( int i_tty_dev );
  * Functions exported as capabilities. They are declared as static so that
  * we don't pollute the namespace too much.
  *****************************************************************************/
-void vout_getfunctions( function_list_t * p_function_list )
+void _M( vout_getfunctions )( function_list_t * p_function_list )
 {
     p_function_list->pf_probe = vout_Probe;
     p_function_list->functions.vout.pf_create     = vout_Create;
index 2381f3d2347a2c475251df7aaca3b08101ed1e1e..a06364bc8bf0ab76673df95d5ce10142a854882b 100644 (file)
@@ -21,6 +21,7 @@
  *****************************************************************************/
 
 #define MODULE_NAME ggi
+#include "modules_inner.h"
 
 /*****************************************************************************
  * Preamble
@@ -38,7 +39,6 @@
 #include "video_output.h"
 
 #include "modules.h"
-#include "modules_inner.h"
 
 /*****************************************************************************
  * Building configuration tree
@@ -51,7 +51,7 @@ MODULE_CONFIG_END
 /*****************************************************************************
  * Capabilities defined in the other files.
  ******************************************************************************/
-extern void vout_getfunctions( function_list_t * p_function_list );
+void _M( vout_getfunctions )( function_list_t * p_function_list );
 
 /*****************************************************************************
  * InitModule: get the module structure and configuration.
@@ -61,7 +61,7 @@ extern void vout_getfunctions( function_list_t * p_function_list );
  * be unloaded later to save memory, and we want to be able to access this
  * data even after the module has been unloaded.
  *****************************************************************************/
-int InitModule( module_t * p_module )
+MODULE_INIT
 {
     p_module->psz_name = MODULE_STRING;
     p_module->psz_longname = "General Graphics Interface module";
@@ -81,7 +81,7 @@ int InitModule( module_t * p_module )
  * be set to 0 and calls to NeedModule() be made to increment it. To unload
  * the module, one has to wait until i_usage == 0 and call DeactivateModule().
  *****************************************************************************/
-int ActivateModule( module_t * p_module )
+MODULE_ACTIVATE
 {
     p_module->p_functions = malloc( sizeof( module_functions_t ) );
     if( p_module->p_functions == NULL )
@@ -89,7 +89,7 @@ int ActivateModule( module_t * p_module )
         return( -1 );
     }
 
-    vout_getfunctions( &p_module->p_functions->vout );
+    _M( vout_getfunctions )( &p_module->p_functions->vout );
 
     p_module->p_config = p_config;
 
@@ -103,7 +103,7 @@ int ActivateModule( module_t * p_module )
  * returns, i_usage can be set to -1 and the module unloaded. Be careful to
  * lock usage_lock during the whole process.
  *****************************************************************************/
-int DeactivateModule( module_t * p_module )
+MODULE_DEACTIVATE
 {
     free( p_module->p_functions );
 
index 4005f13ed5ea35ff970e16a699424d7dedba887e..39942f964e46eca1b54c8a02cb56e096689175f1 100644 (file)
@@ -21,6 +21,9 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
+#define MODULE_NAME ggi
+#include "modules_inner.h"
+
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
@@ -81,7 +84,7 @@ static void GGICloseDisplay( vout_thread_t *p_vout );
  * Functions exported as capabilities. They are declared as static so that
  * we don't pollute the namespace too much.
  *****************************************************************************/
-void vout_getfunctions( function_list_t * p_function_list )
+void _M( vout_getfunctions )( function_list_t * p_function_list )
 {
     p_function_list->pf_probe = vout_Probe;
     p_function_list->functions.vout.pf_create     = vout_Create;
index d7fc8273bc3f81b21bc0c282071e97050ebcdac9..d2a90c2d4244a0d3709871fb283db1a5c5659428 100644 (file)
@@ -1,9 +1,9 @@
 /*****************************************************************************
  * glide.c : 3dfx Glide plugin for vlc
  *****************************************************************************
- * Copyright (C) 2000 VideoLAN
+ * Copyright (C) 2000, 2001 VideoLAN
  *
- * Authors:
+ * Authors: Samuel Hocevar <sam@zoy.org>
  *
  * 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
@@ -20,6 +20,9 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
+#define MODULE_NAME glide
+#include "modules_inner.h"
+
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
 
 #include <stdlib.h>                                      /* malloc(), free() */
 
-#ifndef __linux__
-#include <conio.h>                                            /* for glide ? */
-#endif
-#include <glide.h>
-
 #include "config.h"
 #include "common.h"                                     /* boolean_t, byte_t */
 #include "threads.h"
 #include "mtime.h"
-#include "tests.h"
-#include "plugins.h"
 
-#include "interface.h"
-#include "audio_output.h"
 #include "video.h"
 #include "video_output.h"
 
+#include "modules.h"
+
 /*****************************************************************************
- * Exported prototypes
+ * Building configuration tree
  *****************************************************************************/
-static void vout_GetPlugin( p_vout_thread_t p_vout );
-static void intf_GetPlugin( p_intf_thread_t p_intf );
-
-/* Video output */
-int     vout_GlideCreate       ( vout_thread_t *p_vout, char *psz_display,
-                                 int i_root_window, void *p_data );
-int     vout_GlideInit         ( p_vout_thread_t p_vout );
-void    vout_GlideEnd          ( p_vout_thread_t p_vout );
-void    vout_GlideDestroy      ( p_vout_thread_t p_vout );
-int     vout_GlideManage       ( p_vout_thread_t p_vout );
-void    vout_GlideDisplay      ( p_vout_thread_t p_vout );
-void    vout_GlideSetPalette   ( p_vout_thread_t p_vout,
-                                 u16 *red, u16 *green, u16 *blue, u16 *transp );
-
-/* Interface */
-int     intf_GlideCreate       ( p_intf_thread_t p_intf );
-void    intf_GlideDestroy      ( p_intf_thread_t p_intf );
-void    intf_GlideManage       ( p_intf_thread_t p_intf );
+MODULE_CONFIG_START
+ADD_WINDOW( "Configuration for Glide module" )
+    ADD_COMMENT( "For now, the Glide module cannot be configured" )
+MODULE_CONFIG_END
+
+/*****************************************************************************
+ * Capabilities defined in the other files.
+ ******************************************************************************/
+void _M( vout_getfunctions )( function_list_t * p_function_list );
 
 /*****************************************************************************
- * GetConfig: get the plugin structure and configuration
+ * InitModule: get the module structure and configuration.
+ *****************************************************************************
+ * We have to fill psz_name, psz_longname and psz_version. These variables
+ * will be strdup()ed later by the main application because the module can
+ * be unloaded later to save memory, and we want to be able to access this
+ * data even after the module has been unloaded.
  *****************************************************************************/
-plugin_info_t * GetConfig( void )
+MODULE_INIT
 {
-    plugin_info_t * p_info = (plugin_info_t *) malloc( sizeof(plugin_info_t) );
-
-    p_info->psz_name    = "3dfx Glide";
-    p_info->psz_version = VERSION;
-    p_info->psz_author  = "the VideoLAN team <vlc@videolan.org>";
+    p_module->psz_name = MODULE_STRING;
+    p_module->psz_longname = "3dfx Glide module";
+    p_module->psz_version = VERSION;
 
-    p_info->aout_GetPlugin = NULL;
-    p_info->vout_GetPlugin = vout_GetPlugin;
-    p_info->intf_GetPlugin = intf_GetPlugin;
-    p_info->yuv_GetPlugin  = NULL;
+    p_module->i_capabilities = MODULE_CAPABILITY_NULL
+                                | MODULE_CAPABILITY_VOUT;
 
-    /* We could do a grSstQueryBoards( GrHwConfiguration *hwConfig ) at
-     * this point, but if the user didn't configure his 3dfx card, we
-     * have great chances to segfault here. So we'd better assume
-     * everything is fine and worry only if we really need to use Glide */
-    p_info->i_score = 0x100;
+    return( 0 );
+}
 
-    if( TestProgram( "glidevlc" ) )
+/*****************************************************************************
+ * ActivateModule: set the module to an usable state.
+ *****************************************************************************
+ * This function fills the capability functions and the configuration
+ * structure. Once ActivateModule() has been called, the i_usage can
+ * be set to 0 and calls to NeedModule() be made to increment it. To unload
+ * the module, one has to wait until i_usage == 0 and call DeactivateModule().
+ *****************************************************************************/
+MODULE_ACTIVATE
+{
+    p_module->p_functions = malloc( sizeof( module_functions_t ) );
+    if( p_module->p_functions == NULL )
     {
-        p_info->i_score += 0x180;
+        return( -1 );
     }
 
-    /* If this plugin was requested, score it higher */
-    if( TestMethod( VOUT_METHOD_VAR, "glide" ) )
-    {
-        p_info->i_score += 0x200;
-    }
+    _M( vout_getfunctions )( &p_module->p_functions->vout );
+
+    p_module->p_config = p_config;
 
-    return( p_info );
+    return( 0 );
 }
 
 /*****************************************************************************
- * Following functions are only called through the p_info structure
+ * DeactivateModule: make sure the module can be unloaded.
+ *****************************************************************************
+ * This function must only be called when i_usage == 0. If it successfully
+ * returns, i_usage can be set to -1 and the module unloaded. Be careful to
+ * lock usage_lock during the whole process.
  *****************************************************************************/
-
-static void vout_GetPlugin( p_vout_thread_t p_vout )
+MODULE_DEACTIVATE
 {
-    p_vout->p_sys_create  = vout_GlideCreate;
-    p_vout->p_sys_init    = vout_GlideInit;
-    p_vout->p_sys_end     = vout_GlideEnd;
-    p_vout->p_sys_destroy = vout_GlideDestroy;
-    p_vout->p_sys_manage  = vout_GlideManage;
-    p_vout->p_sys_display = vout_GlideDisplay;
-}
+    free( p_module->p_functions );
 
-static void intf_GetPlugin( p_intf_thread_t p_intf )
-{
-    p_intf->p_sys_create  = intf_GlideCreate;
-    p_intf->p_sys_destroy = intf_GlideDestroy;
-    p_intf->p_sys_manage  = intf_GlideManage;
+    return( 0 );
 }
 
diff --git a/plugins/glide/intf_glide.c b/plugins/glide/intf_glide.c
deleted file mode 100644 (file)
index 93e6911..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-/*****************************************************************************
- * intf_glide.c: 3dfx interface plugin
- *****************************************************************************
- * Copyright (C) 2000 VideoLAN
- * $Id: intf_glide.c,v 1.6 2001/01/05 18:46:43 massiot Exp $
- *
- * Authors:
- *
- * 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
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- * 
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- *****************************************************************************/
-
-/*****************************************************************************
- * Preamble
- *****************************************************************************/
-#include "defs.h"
-
-#include <stdlib.h>                                      /* malloc(), free() */
-#include <linutil.h>                            /* Glide kbhit() and getch() */
-
-#include "config.h"
-#include "common.h"
-#include "threads.h"
-#include "mtime.h"
-#include "plugins.h"
-
-#include "stream_control.h"
-#include "input_ext-intf.h"
-
-#include "video.h"
-#include "video_output.h"
-
-#include "intf_msg.h"
-#include "interface.h"
-
-#include "main.h"
-
-/*****************************************************************************
- * intf_sys_t: description and status of 3dfx interface
- *****************************************************************************/
-typedef struct intf_sys_s
-{
-
-} intf_sys_t;
-
-/*****************************************************************************
- * intf_GlideCreate: initialize 3dfx interface
- *****************************************************************************/
-int intf_GlideCreate( intf_thread_t *p_intf )
-{
-    /* Allocate instance and initialize some members */
-    p_intf->p_sys = malloc( sizeof( intf_sys_t ) );
-    if( p_intf->p_sys == NULL )
-    {
-        return( 1 );
-    };
-
-    /* Spawn video output thread */
-    if( p_main->b_video )
-    {
-        p_intf->p_vout = vout_CreateThread( NULL, 0, 0, 0, NULL, 0, NULL );
-        if( p_intf->p_vout == NULL )                                /* error */
-        {
-            intf_ErrMsg("intf error: can't create output thread" );
-            return( 1 );
-        }
-    }
-    
-    /* bind keys */
-    intf_AssignNormalKeys( p_intf );
-
-    return( 0 );
-}
-
-/*****************************************************************************
- * intf_GlideDestroy: destroy 3dfx interface
- *****************************************************************************/
-void intf_GlideDestroy( intf_thread_t *p_intf )
-{
-    /* Close input thread, if any (blocking) */
-    if( p_intf->p_input )
-    {
-        input_DestroyThread( p_intf->p_input, NULL );
-    }
-
-    /* Close video output thread, if any (blocking) */
-    if( p_intf->p_vout )
-    {
-        vout_DestroyThread( p_intf->p_vout, NULL );
-    }
-
-    /* Destroy structure */
-    free( p_intf->p_sys );
-}
-
-
-/*****************************************************************************
- * intf_GlideManage: event loop
- *****************************************************************************/
-void intf_GlideManage( intf_thread_t *p_intf )
-{
-    unsigned int buf;
-
-    /* very Linux specific - see tlib.c in Glide for other versions */
-    while( kbhit() )
-    {
-        if( intf_ProcessKey(p_intf, (int)buf = getch()) )
-        {
-            intf_ErrMsg( "unhandled key '%c' (%i)", (char) buf, buf );
-        }
-    }
-}
-
index 757bb14043bafb229acbd88fccd18026ed0be24d..0ec45b70e47cba79110a515e93b2c2a22fa0a364 100644 (file)
@@ -1,9 +1,9 @@
 /*****************************************************************************
  * vout_glide.c: 3dfx video output display method for 3dfx cards
  *****************************************************************************
- * Copyright (C) 2000 VideoLAN
+ * Copyright (C) 2000, 2001 VideoLAN
  *
- * Authors:
+ * Authors: Samuel Hocevar <sam@zoy.org>
  *
  * 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
@@ -20,6 +20,9 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
+#define MODULE_NAME glide
+#include "modules_inner.h"
+
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
 #include <conio.h>                                            /* for glide ? */
 #endif
 #include <glide.h>
+#include <linutil.h>                            /* Glide kbhit() and getch() */
 
 #include "config.h"
 #include "common.h"
 #include "threads.h"
 #include "mtime.h"
-#include "plugins.h"
+#include "tests.h"
+#include "modules.h"
 
 #include "video.h"
 #include "video_output.h"
 
 #include "intf_msg.h"
+#include "interface.h"
+
 #include "main.h"
 
-#define WIDTH 800
-#define HEIGHT 600
-#define BITS_PER_PLANE 16
-#define BYTES_PER_PIXEL 2
+#define GLIDE_WIDTH 800
+#define GLIDE_HEIGHT 600
+#define GLIDE_BITS_PER_PLANE 16
+#define GLIDE_BYTES_PER_PIXEL 2
 
 /*****************************************************************************
  * vout_sys_t: Glide video output method descriptor
@@ -68,18 +75,61 @@ typedef struct vout_sys_s
 } vout_sys_t;
 
 /*****************************************************************************
- * Local prototypes
+ * Local prototypes.
+ *****************************************************************************/
+static int  vout_Probe     ( probedata_t *p_data );
+static int  vout_Create    ( struct vout_thread_s * );
+static int  vout_Init      ( struct vout_thread_s * );
+static void vout_End       ( struct vout_thread_s * );
+static void vout_Destroy   ( struct vout_thread_s * );
+static int  vout_Manage    ( struct vout_thread_s * );
+static void vout_Display   ( struct vout_thread_s * );
+
+static int  GlideOpenDisplay   ( vout_thread_t *p_vout );
+static void GlideCloseDisplay  ( vout_thread_t *p_vout );
+
+/*****************************************************************************
+ * Functions exported as capabilities. They are declared as static so that
+ * we don't pollute the namespace too much.
  *****************************************************************************/
-static int     GlideOpenDisplay   ( vout_thread_t *p_vout );
-static void    GlideCloseDisplay  ( vout_thread_t *p_vout );
+void _M( vout_getfunctions )( function_list_t * p_function_list )
+{
+    p_function_list->pf_probe = vout_Probe;
+    p_function_list->functions.vout.pf_create     = vout_Create;
+    p_function_list->functions.vout.pf_init       = vout_Init;
+    p_function_list->functions.vout.pf_end        = vout_End;
+    p_function_list->functions.vout.pf_destroy    = vout_Destroy;
+    p_function_list->functions.vout.pf_manage     = vout_Manage;
+    p_function_list->functions.vout.pf_display    = vout_Display;
+    p_function_list->functions.vout.pf_setpalette = NULL;
+}
 
 /*****************************************************************************
- * vout_GlideCreate: allocates Glide video thread output method
+ * vout_Probe: probe the video driver and return a score
+ *****************************************************************************
+ * This function tries to initialize SDL and returns a score to the
+ * plugin manager so that it can select the best plugin.
+ *****************************************************************************/
+static int vout_Probe( probedata_t *p_data )
+{
+    if( TestMethod( VOUT_METHOD_VAR, "glide" ) )
+    {
+        return( 999 );
+    }
+
+    /* We could do a grSstQueryBoards( GrHwConfiguration *hwConfig ) at
+     * this point, but if the user didn't configure his 3dfx card, we
+     * have great chances to segfault here. So we'd better assume
+     * everything is fine and worry only if we really need to use Glide */
+    return( 20 );
+}
+
+/*****************************************************************************
+ * vout_Create: allocates Glide video thread output method
  *****************************************************************************
  * This function allocates and initializes a Glide vout method.
  *****************************************************************************/
-int vout_GlideCreate( vout_thread_t *p_vout, char *psz_display,
-                    int i_root_window, void *p_data )
+int vout_Create( vout_thread_t *p_vout )
 {
     /* Allocate structure */
     p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
@@ -101,50 +151,68 @@ int vout_GlideCreate( vout_thread_t *p_vout, char *psz_display,
 }
 
 /*****************************************************************************
- * vout_GlideInit: initialize Glide video thread output method
+ * vout_Init: initialize Glide video thread output method
  *****************************************************************************/
-int vout_GlideInit( vout_thread_t *p_vout )
+int vout_Init( vout_thread_t *p_vout )
 {
     return( 0 );
 }
 
 /*****************************************************************************
- * vout_GlideEnd: terminate Glide video thread output method
+ * vout_End: terminate Glide video thread output method
  *****************************************************************************/
-void vout_GlideEnd( vout_thread_t *p_vout )
+void vout_End( vout_thread_t *p_vout )
 {
     ;
 }
 
 /*****************************************************************************
- * vout_GlideDestroy: destroy Glide video thread output method
+ * vout_Destroy: destroy Glide video thread output method
  *****************************************************************************
  * Terminate an output method created by vout_CreateOutputMethod
  *****************************************************************************/
-void vout_GlideDestroy( vout_thread_t *p_vout )
+void vout_Destroy( vout_thread_t *p_vout )
 {
     GlideCloseDisplay( p_vout );
     free( p_vout->p_sys );
 }
 
 /*****************************************************************************
- * vout_GlideManage: handle Glide events
+ * vout_Manage: handle Glide events
  *****************************************************************************
  * This function should be called regularly by video output thread. It manages
  * console events. It returns a non null value on error.
  *****************************************************************************/
-int vout_GlideManage( vout_thread_t *p_vout )
+int vout_Manage( vout_thread_t *p_vout )
 {
+    int buf;
+
+    /* very Linux specific - see tlib.c in Glide for other versions */
+    while( kbhit() )
+    {
+        buf = getch();
+
+        switch( (char)buf )
+        {
+        case 'q':
+            p_main->p_intf->b_die = 1;
+            break;
+
+        default:
+            break;
+        }
+    }
+
     return 0;
 }
 
 /*****************************************************************************
- * vout_GlideDisplay: displays previously rendered output
+ * vout_Display: displays previously rendered output
  *****************************************************************************
  * This function send the currently rendered image to Glide image, waits until
  * it is displayed and switch the two rendering buffers, preparing next frame.
  *****************************************************************************/
-void vout_GlideDisplay( vout_thread_t *p_vout )
+void vout_Display( vout_thread_t *p_vout )
 {
     grLfbUnlock( GR_LFB_WRITE_ONLY, GR_BUFFER_BACKBUFFER );
 
@@ -171,14 +239,15 @@ static int GlideOpenDisplay( vout_thread_t *p_vout )
     GrScreenResolution_t resolution = GR_RESOLUTION_800x600;
     GrLfbInfo_t p_front_buffer_info;                    /* front buffer info */
 
-    p_vout->i_width =                   WIDTH;
-    p_vout->i_height =                  HEIGHT;
-    p_vout->i_screen_depth =            BITS_PER_PLANE;
-    p_vout->i_bytes_per_pixel =         BYTES_PER_PIXEL;
+    p_vout->i_width =            GLIDE_WIDTH;
+    p_vout->i_height =           GLIDE_HEIGHT;
+    p_vout->i_screen_depth =     GLIDE_BITS_PER_PLANE;
+    p_vout->i_bytes_per_pixel =  GLIDE_BYTES_PER_PIXEL;
     /* bytes per line value overriden later */
-    p_vout->i_bytes_per_line =          1024 * BYTES_PER_PIXEL;
+    p_vout->i_bytes_per_line =   1024 * GLIDE_BYTES_PER_PIXEL;
 
-    p_vout->p_sys->i_page_size = WIDTH * HEIGHT * BYTES_PER_PIXEL;
+    p_vout->p_sys->i_page_size = GLIDE_WIDTH * GLIDE_HEIGHT
+                                  * GLIDE_BYTES_PER_PIXEL;
 
     p_vout->i_red_mask =   0xf800;
     p_vout->i_green_mask = 0x07e0;
index ca628042d08ba426ea164024a3d696f11a5f7943..1b3c181ebec739964d5e25e4ae74cecdc887fae6 100644 (file)
@@ -21,6 +21,7 @@
  *****************************************************************************/
 
 #define MODULE_NAME gnome
+#include "modules_inner.h"
 
 /*****************************************************************************
  * Preamble
@@ -35,7 +36,6 @@
 #include "mtime.h"
 
 #include "modules.h"
-#include "modules_inner.h"
 
 /*****************************************************************************
  * Building configuration tree
@@ -48,7 +48,7 @@ MODULE_CONFIG_END
 /*****************************************************************************
  * Capabilities defined in the other files.
  ******************************************************************************/
-extern void intf_getfunctions( function_list_t * p_function_list );
+void _M( intf_getfunctions )( function_list_t * p_function_list );
 
 /*****************************************************************************
  * InitModule: get the module structure and configuration.
@@ -58,7 +58,7 @@ extern void intf_getfunctions( function_list_t * p_function_list );
  * be unloaded later to save memory, and we want to be able to access this
  * data even after the module has been unloaded.
  *****************************************************************************/
-int InitModule( module_t * p_module )
+MODULE_INIT
 {
     p_module->psz_name = MODULE_STRING;
     p_module->psz_longname = "Gnome interface module";
@@ -78,7 +78,7 @@ int InitModule( module_t * p_module )
  * be set to 0 and calls to NeedModule() be made to increment it. To unload
  * the module, one has to wait until i_usage == 0 and call DeactivateModule().
  *****************************************************************************/
-int ActivateModule( module_t * p_module )
+MODULE_ACTIVATE
 {
     p_module->p_functions = malloc( sizeof( module_functions_t ) );
     if( p_module->p_functions == NULL )
@@ -86,7 +86,7 @@ int ActivateModule( module_t * p_module )
         return( -1 );
     }
 
-    intf_getfunctions( &p_module->p_functions->intf );
+    _M( intf_getfunctions )( &p_module->p_functions->intf );
 
     p_module->p_config = p_config;
 
@@ -100,7 +100,7 @@ int ActivateModule( module_t * p_module )
  * returns, i_usage can be set to -1 and the module unloaded. Be careful to
  * lock usage_lock during the whole process.
  *****************************************************************************/
-int DeactivateModule( module_t * p_module )
+MODULE_DEACTIVATE
 {
     free( p_module->p_functions );
 
index c34a4eb749ecf9288781ab365186d66d4e3fd5e8..53bb37631c4d6e9868a4ea5a904218b603190d1e 100644 (file)
@@ -20,6 +20,9 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
+#define MODULE_NAME gnome
+#include "modules_inner.h"
+
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
index 0934b5efab4c9ca76321938224369fd6a2e4ae47..f3de8c330e1d2d33b8e88f8c4876b5e5abb409d2 100644 (file)
@@ -2,9 +2,9 @@
  * intf_gnome.c: Gnome interface
  *****************************************************************************
  * Copyright (C) 1999, 2000 VideoLAN
- * $Id: intf_gnome.c,v 1.14 2001/02/20 02:53:13 stef Exp $
+ * $Id: intf_gnome.c,v 1.15 2001/02/20 07:49:13 sam Exp $
  *
- * Authors:
+ * Authors: Samuel Hocevar <sam@zoy.org>
  *
  * 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
@@ -21,6 +21,9 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
+#define MODULE_NAME gnome
+#include "modules_inner.h"
+
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
@@ -90,7 +93,7 @@ void g_atexit( GVoidFunc func )
  * Functions exported as capabilities. They are declared as static so that
  * we don't pollute the namespace too much.
  *****************************************************************************/
-void intf_getfunctions( function_list_t * p_function_list )
+void _M( intf_getfunctions )( function_list_t * p_function_list )
 {
     p_function_list->pf_probe = intf_Probe;
     p_function_list->functions.intf.pf_open  = intf_Open;
index 6cda95f83b3845ffbeaa5fb1b67e6bc9d86b155d..008e4b3231dda6d8255d71324b866e6d4cf42a0d 100644 (file)
@@ -2,7 +2,7 @@
  * idct.c : IDCT module
  *****************************************************************************
  * Copyright (C) 1999, 2000 VideoLAN
- * $Id: idct.c,v 1.6 2001/01/18 05:13:22 sam Exp $
+ * $Id: idct.c,v 1.7 2001/02/20 07:49:13 sam Exp $
  *
  * Authors: GaĆ«l Hendryckx <jimmy@via.ecp.fr>
  *
@@ -22,6 +22,7 @@
  *****************************************************************************/
 
 #define MODULE_NAME idct
+#include "modules_inner.h"
 
 /*****************************************************************************
  * Preamble
@@ -42,7 +43,6 @@
 #include "video_decoder.h"
 
 #include "modules.h"
-#include "modules_inner.h"
 
 #include "idct.h"
 
@@ -70,7 +70,7 @@ MODULE_CONFIG_END
  * be unloaded later to save memory, and we want to be able to access this
  * data even after the module has been unloaded.
  *****************************************************************************/
-int InitModule( module_t * p_module )
+MODULE_INIT
 {
     p_module->psz_name = MODULE_STRING;
     p_module->psz_longname = "IDCT module";
@@ -90,7 +90,7 @@ int InitModule( module_t * p_module )
  * be set to 0 and calls to NeedModule() be made to increment it. To unload
  * the module, one has to wait until i_usage == 0 and call DeactivateModule().
  *****************************************************************************/
-int ActivateModule( module_t * p_module )
+MODULE_ACTIVATE
 {
     p_module->p_functions = malloc( sizeof( module_functions_t ) );
     if( p_module->p_functions == NULL )
@@ -112,7 +112,7 @@ int ActivateModule( module_t * p_module )
  * returns, i_usage can be set to -1 and the module unloaded. Be careful to
  * lock usage_lock during the whole process.
  *****************************************************************************/
-int DeactivateModule( module_t * p_module )
+MODULE_DEACTIVATE
 {
     free( p_module->p_functions );
 
index 4d09620077f83e2f4f75f9af25f95444eb442355..51941455efa1c14a62f76163a03832f769b74979 100644 (file)
@@ -2,7 +2,7 @@
  * idctclassic.c : Classic IDCT module
  *****************************************************************************
  * Copyright (C) 1999, 2000 VideoLAN
- * $Id: idctclassic.c,v 1.6 2001/01/18 05:13:22 sam Exp $
+ * $Id: idctclassic.c,v 1.7 2001/02/20 07:49:13 sam Exp $
  *
  * Authors: GaĆ«l Hendryckx <jimmy@via.ecp.fr>
  *
@@ -70,7 +70,7 @@ MODULE_CONFIG_END
  * be unloaded later to save memory, and we want to be able to access this
  * data even after the module has been unloaded.
  *****************************************************************************/
-int InitModule( module_t * p_module )
+MODULE_INIT
 {
     p_module->psz_name = MODULE_STRING;
     p_module->psz_longname = "classic IDCT module";
@@ -90,7 +90,7 @@ int InitModule( module_t * p_module )
  * be set to 0 and calls to NeedModule() be made to increment it. To unload
  * the module, one has to wait until i_usage == 0 and call DeactivateModule().
  *****************************************************************************/
-int ActivateModule( module_t * p_module )
+MODULE_ACTIVATE
 {
     p_module->p_functions = malloc( sizeof( module_functions_t ) );
     if( p_module->p_functions == NULL )
@@ -112,7 +112,7 @@ int ActivateModule( module_t * p_module )
  * returns, i_usage can be set to -1 and the module unloaded. Be careful to
  * lock usage_lock during the whole process.
  *****************************************************************************/
-int DeactivateModule( module_t * p_module )
+MODULE_DEACTIVATE
 {
     free( p_module->p_functions );
 
index 5606819d89f8a2388a0e5b741d57d3fb5e6b474f..be625d3d4f9ed8df02bf7be3a29a9e8a6761fff6 100644 (file)
@@ -2,7 +2,7 @@
  * idctmmx.c : MMX IDCT module
  *****************************************************************************
  * Copyright (C) 1999, 2000 VideoLAN
- * $Id: idctmmx.c,v 1.7 2001/01/18 05:13:22 sam Exp $
+ * $Id: idctmmx.c,v 1.8 2001/02/20 07:49:13 sam Exp $
  *
  * Authors: Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
  *          Michel Lespinasse <walken@zoy.org>
@@ -77,7 +77,7 @@ MODULE_CONFIG_END
  * be unloaded later to save memory, and we want to be able to access this
  * data even after the module has been unloaded.
  *****************************************************************************/
-int InitModule( module_t * p_module )
+MODULE_INIT
 {
     p_module->psz_name = MODULE_STRING;
     p_module->psz_longname = "MMX IDCT module";
@@ -97,7 +97,7 @@ int InitModule( module_t * p_module )
  * be set to 0 and calls to NeedModule() be made to increment it. To unload
  * the module, one has to wait until i_usage == 0 and call DeactivateModule().
  *****************************************************************************/
-int ActivateModule( module_t * p_module )
+MODULE_ACTIVATE
 {
     p_module->p_functions = malloc( sizeof( module_functions_t ) );
     if( p_module->p_functions == NULL )
@@ -119,7 +119,7 @@ int ActivateModule( module_t * p_module )
  * returns, i_usage can be set to -1 and the module unloaded. Be careful to
  * lock usage_lock during the whole process.
  *****************************************************************************/
-int DeactivateModule( module_t * p_module )
+MODULE_DEACTIVATE
 {
     free( p_module->p_functions );
 
index 017f177effc15c7464e4b4ca4f0577cc492629d9..22e0db2c98a637fb8db28a455d79f2603680171d 100644 (file)
@@ -2,7 +2,7 @@
  * idctmmxext.c : MMX EXT IDCT module
  *****************************************************************************
  * Copyright (C) 1999, 2000 VideoLAN
- * $Id: idctmmxext.c,v 1.4 2001/01/17 18:17:30 massiot Exp $
+ * $Id: idctmmxext.c,v 1.5 2001/02/20 07:49:13 sam Exp $
  *
  * Authors: Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
  *          Michel Lespinasse <walken@zoy.org>
@@ -77,7 +77,7 @@ MODULE_CONFIG_END
  * be unloaded later to save memory, and we want to be able to access this
  * data even after the module has been unloaded.
  *****************************************************************************/
-int InitModule( module_t * p_module )
+MODULE_INIT
 {
     p_module->psz_name = MODULE_STRING;
     p_module->psz_longname = "MMX EXT IDCT module";
@@ -97,7 +97,7 @@ int InitModule( module_t * p_module )
  * be set to 0 and calls to NeedModule() be made to increment it. To unload
  * the module, one has to wait until i_usage == 0 and call DeactivateModule().
  *****************************************************************************/
-int ActivateModule( module_t * p_module )
+MODULE_ACTIVATE
 {
     p_module->p_functions = malloc( sizeof( module_functions_t ) );
     if( p_module->p_functions == NULL )
@@ -119,7 +119,7 @@ int ActivateModule( module_t * p_module )
  * returns, i_usage can be set to -1 and the module unloaded. Be careful to
  * lock usage_lock during the whole process.
  *****************************************************************************/
-int DeactivateModule( module_t * p_module )
+MODULE_DEACTIVATE
 {
     free( p_module->p_functions );
 
diff --git a/plugins/mga/intf_mga.c b/plugins/mga/intf_mga.c
deleted file mode 100644 (file)
index 1c6172e..0000000
+++ /dev/null
@@ -1,528 +0,0 @@
-/*****************************************************************************
- * intf_mga.c: MGA interface
- *****************************************************************************
- * Copyright (C) 1999, 2000 VideoLAN
- * $Id: intf_mga.c,v 1.7 2001/01/15 06:18:23 sam Exp $
- *
- * Authors:
- *
- * 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
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- * 
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- *****************************************************************************/
-
-/*****************************************************************************
- * Preamble
- *****************************************************************************/
-#include "defs.h"
-
-#include <errno.h>                                                 /* ENOMEM */
-#include <stdlib.h>                                                /* free() */
-#include <string.h>                                            /* strerror() */
-
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#include <X11/keysym.h>
-
-#include "config.h"
-#include "common.h"
-#include "threads.h"
-#include "mtime.h"
-#include "plugins.h"
-
-#include "stream_control.h"
-#include "input_ext-intf.h"
-
-#include "video.h"
-#include "video_output.h"
-
-#include "intf_msg.h"
-#include "interface.h"
-
-#include "main.h"
-
-/*****************************************************************************
- * intf_sys_t: description and status of X11 interface
- *****************************************************************************/
-typedef struct intf_sys_s
-{
-    /* X11 generic properties */
-    Display *           p_display;                    /* X11 display pointer */
-    int                 i_screen;                              /* X11 screen */
-    Atom                wm_protocols;
-    Atom                wm_delete_window;
-
-    /* Main window properties */
-    Window              window;                               /* main window */
-    GC                  gc;               /* graphic context for main window */
-    int                 i_width;                     /* width of main window */
-    int                 i_height;                   /* height of main window */
-
-    /* Screen saver properties */
-    int                 i_ss_count;              /* enabling/disabling count */
-    int                 i_ss_timeout;                             /* timeout */
-    int                 i_ss_interval;           /* interval between changes */
-    int                 i_ss_blanking;                      /* blanking mode */
-    int                 i_ss_exposure;                      /* exposure mode */
-
-    /* Mouse pointer properties */
-    boolean_t           b_mouse;         /* is the mouse pointer displayed ? */
-
-} intf_sys_t;
-
-/*****************************************************************************
- * Local prototypes
- *****************************************************************************/
-static int  X11CreateWindow             ( intf_thread_t *p_intf );
-static void X11DestroyWindow            ( intf_thread_t *p_intf );
-static void X11ManageWindow             ( intf_thread_t *p_intf );
-static void X11EnableScreenSaver        ( intf_thread_t *p_intf );
-static void X11DisableScreenSaver       ( intf_thread_t *p_intf );
-static void X11TogglePointer            ( intf_thread_t *p_intf );
-
-/*****************************************************************************
- * intf_MGACreate: initialize and create window
- *****************************************************************************/
-int intf_MGACreate( intf_thread_t *p_intf )
-{
-    char       *psz_display;
-
-    /* Allocate instance and initialize some members */
-    p_intf->p_sys = malloc( sizeof( intf_sys_t ) );
-    if( p_intf->p_sys == NULL )
-    {
-        intf_ErrMsg("error: %s", strerror(ENOMEM));
-        return( 1 );
-    }
-
-    /* Open display, unsing 'vlc_display' or DISPLAY environment variable */
-    psz_display = XDisplayName( main_GetPszVariable( VOUT_DISPLAY_VAR, NULL ) );
-    p_intf->p_sys->p_display = XOpenDisplay( psz_display );
-    if( !p_intf->p_sys->p_display )                                 /* error */
-    {
-        intf_ErrMsg("error: can't open display %s", psz_display );
-        free( p_intf->p_sys );
-        return( 1 );
-    }
-    p_intf->p_sys->i_screen = DefaultScreen( p_intf->p_sys->p_display );
-
-    /* Spawn base window - this window will include the video output window,
-     * but also command buttons, subtitles and other indicators */
-    if( X11CreateWindow( p_intf ) )
-    {
-        intf_ErrMsg("error: can't create interface window" );
-        XCloseDisplay( p_intf->p_sys->p_display );
-        free( p_intf->p_sys );
-        return( 1 );
-    }
-
-    /* Spawn video output thread */
-    if( p_main->b_video )
-    {
-        p_intf->p_vout = vout_CreateThread( psz_display, p_intf->p_sys->window,
-                                            p_intf->p_sys->i_width,
-                                            p_intf->p_sys->i_height, NULL, 0, NULL );
-        if( p_intf->p_vout == NULL )                                /* error */
-        {
-            intf_ErrMsg("error: can't create video output thread" );
-            X11DestroyWindow( p_intf );
-            XCloseDisplay( p_intf->p_sys->p_display );
-            free( p_intf->p_sys );
-            return( 1 );
-        }
-    }
-
-    p_intf->p_sys->b_mouse = 1;
-    
-    /* bind keys */
-    intf_AssignNormalKeys( p_intf );
-
-    
-    /* Disable screen saver and return */
-    p_intf->p_sys->i_ss_count = 1;
-    X11DisableScreenSaver( p_intf );
-    return( 0 );
-}
-
-/*****************************************************************************
- * intf_MGADestroy: destroy interface window
- *****************************************************************************/
-void intf_MGADestroy( intf_thread_t *p_intf )
-{
-    /* Enable screen saver */
-    X11EnableScreenSaver( p_intf );
-
-    /* Close input thread, if any (blocking) */
-    if( p_intf->p_input )
-    {
-        input_DestroyThread( p_intf->p_input, NULL );
-    }
-
-    /* Close video output thread, if any (blocking) */
-    if( p_intf->p_vout )
-    {
-        vout_DestroyThread( p_intf->p_vout, NULL );
-    }
-
-    /* Close main window and display */
-    X11DestroyWindow( p_intf );
-    XCloseDisplay( p_intf->p_sys->p_display );
-
-    /* Destroy structure */
-    free( p_intf->p_sys );
-}
-
-
-/*****************************************************************************
- * intf_MGAManage: event loop
- *****************************************************************************/
-void intf_MGAManage( intf_thread_t *p_intf )
-{
-    /* Manage main window */
-    X11ManageWindow( p_intf );
-}
-
-/* following functions are local */
-
-/*****************************************************************************
- * X11CreateWindow: open and set-up X11 main window
- *****************************************************************************/
-static int X11CreateWindow( intf_thread_t *p_intf )
-{
-    XSizeHints              xsize_hints;
-    XSetWindowAttributes    xwindow_attributes;
-    XGCValues               xgcvalues;
-    XEvent                  xevent;
-    boolean_t               b_expose;
-    boolean_t               b_configure_notify;
-    boolean_t               b_map_notify;
-
-    /* Set main window's size */
-    p_intf->p_sys->i_width =  main_GetIntVariable( VOUT_WIDTH_VAR, VOUT_WIDTH_DEFAULT );
-    p_intf->p_sys->i_height = main_GetIntVariable( VOUT_HEIGHT_VAR, VOUT_HEIGHT_DEFAULT );
-
-    /* Prepare window manager hints and properties */
-    xsize_hints.base_width =            p_intf->p_sys->i_width;
-    xsize_hints.base_height =           p_intf->p_sys->i_height;
-    xsize_hints.flags =                 PSize;
-    p_intf->p_sys->wm_protocols =       XInternAtom( p_intf->p_sys->p_display,
-                                                     "WM_PROTOCOLS", True );
-    p_intf->p_sys->wm_delete_window =   XInternAtom( p_intf->p_sys->p_display,
-                                                     "WM_DELETE_WINDOW", True );
-
-    /* Prepare window attributes */
-    xwindow_attributes.backing_store = Always;       /* save the hidden part */
-    xwindow_attributes.background_pixel = WhitePixel( p_intf->p_sys->p_display,
-                                                      p_intf->p_sys->i_screen );
-
-    /* Create the window and set hints - the window must receive ConfigureNotify
-     * events, and, until it is displayed, Expose and MapNotify events. */
-    p_intf->p_sys->window = XCreateSimpleWindow( p_intf->p_sys->p_display,
-                                         DefaultRootWindow( p_intf->p_sys->p_display ),
-                                         0, 0,
-                                         p_intf->p_sys->i_width, p_intf->p_sys->i_height,
-                                         0, 0, 0);
-    XSelectInput( p_intf->p_sys->p_display, p_intf->p_sys->window,
-                  ExposureMask | StructureNotifyMask );
-    XChangeWindowAttributes( p_intf->p_sys->p_display, p_intf->p_sys->window,
-                             CWBackingStore | CWBackPixel, &xwindow_attributes);
-
-    /* Set window manager hints and properties: size hints, command, window's name,
-     * and accepted protocols */
-    XSetWMNormalHints( p_intf->p_sys->p_display, p_intf->p_sys->window, &xsize_hints );
-    XSetCommand( p_intf->p_sys->p_display, p_intf->p_sys->window,
-                 p_main->ppsz_argv, p_main->i_argc );
-    XStoreName( p_intf->p_sys->p_display, p_intf->p_sys->window, VOUT_TITLE );
-    if( (p_intf->p_sys->wm_protocols == None)        /* use WM_DELETE_WINDOW */
-        || (p_intf->p_sys->wm_delete_window == None)
-        || !XSetWMProtocols( p_intf->p_sys->p_display, p_intf->p_sys->window,
-                             &p_intf->p_sys->wm_delete_window, 1 ) )
-    {
-        /* WM_DELETE_WINDOW is not supported by window manager */
-        intf_Msg("intf error: missing or bad window manager - please exit program kindly.");
-    }
-
-    /* Creation of a graphic context that doesn't generate a GraphicsExpose event
-       when using functions like XCopyArea */
-    xgcvalues.graphics_exposures = False;
-    p_intf->p_sys->gc =  XCreateGC( p_intf->p_sys->p_display, p_intf->p_sys->window,
-                                    GCGraphicsExposures, &xgcvalues);
-
-    /* Send orders to server, and wait until window is displayed - three events
-     * must be received: a MapNotify event, an Expose event allowing drawing in the
-     * window, and a ConfigureNotify to get the window dimensions. Once those events
-     * have been received, only ConfigureNotify events need to be received. */
-    b_expose = 0;
-    b_configure_notify = 0;
-    b_map_notify = 0;
-    XMapWindow( p_intf->p_sys->p_display, p_intf->p_sys->window);
-    do
-    {
-        XNextEvent( p_intf->p_sys->p_display, &xevent);
-        if( (xevent.type == Expose)
-            && (xevent.xexpose.window == p_intf->p_sys->window) )
-        {
-            b_expose = 1;
-        }
-        else if( (xevent.type == MapNotify)
-                 && (xevent.xmap.window == p_intf->p_sys->window) )
-        {
-            b_map_notify = 1;
-        }
-        else if( (xevent.type == ConfigureNotify)
-                 && (xevent.xconfigure.window == p_intf->p_sys->window) )
-        {
-            b_configure_notify = 1;
-            p_intf->p_sys->i_width = xevent.xconfigure.width;
-            p_intf->p_sys->i_height = xevent.xconfigure.height;
-        }
-    }
-    while( !( b_expose && b_configure_notify && b_map_notify ) );
-    XSelectInput( p_intf->p_sys->p_display, p_intf->p_sys->window,
-                  StructureNotifyMask | KeyPressMask | ButtonPressMask );
-
-    /* At this stage, the window is openned, displayed, and ready to receive data */
-    return( 0 );
-}
-
-/*****************************************************************************
- * X11DestroyWindow: destroy X11 main window
- *****************************************************************************/
-static void X11DestroyWindow( intf_thread_t *p_intf )
-{
-    XUnmapWindow( p_intf->p_sys->p_display, p_intf->p_sys->window );
-    XFreeGC( p_intf->p_sys->p_display, p_intf->p_sys->gc );
-    XDestroyWindow( p_intf->p_sys->p_display, p_intf->p_sys->window );
-}
-
-/*****************************************************************************
- * X11ManageWindow: manage X11 main window
- *****************************************************************************/
-static void X11ManageWindow( intf_thread_t *p_intf )
-{
-    XEvent      xevent;                                         /* X11 event */
-    boolean_t   b_resized;                        /* window has been resized */
-    char        i_key;                                    /* ISO Latin-1 key */
-
-    /* Handle X11 events: ConfigureNotify events are parsed to know if the
-     * output window's size changed, MapNotify and UnmapNotify to know if the
-     * window is mapped (and if the display is useful), and ClientMessages
-     * to intercept window destruction requests */
-    b_resized = 0;
-    while( XCheckWindowEvent( p_intf->p_sys->p_display, p_intf->p_sys->window,
-                              StructureNotifyMask | KeyPressMask |
-                              ButtonPressMask, &xevent ) == True )
-    {
-        /* ConfigureNotify event: prepare  */
-        if( (xevent.type == ConfigureNotify)
-            && ((xevent.xconfigure.width != p_intf->p_sys->i_width)
-                || (xevent.xconfigure.height != p_intf->p_sys->i_height)) )
-        {
-            /* Update dimensions */
-            b_resized = 1;
-            p_intf->p_sys->i_width = xevent.xconfigure.width;
-            p_intf->p_sys->i_height = xevent.xconfigure.height;
-        }
-        /* MapNotify event: change window status and disable screen saver */
-        else if( xevent.type == MapNotify)
-        {
-            if( (p_intf->p_vout != NULL) && !p_intf->p_vout->b_active )
-            {
-                X11DisableScreenSaver( p_intf );
-                p_intf->p_vout->b_active = 1;
-            }
-        }
-        /* UnmapNotify event: change window status and enable screen saver */
-        else if( xevent.type == UnmapNotify )
-        {
-            if( (p_intf->p_vout != NULL) && p_intf->p_vout->b_active )
-            {
-                X11EnableScreenSaver( p_intf );
-                p_intf->p_vout->b_active = 0;
-            }
-        }
-        /* DestroyNotify event: window has been destroyed */
-        else if( xevent.type == DestroyNotify )
-        {
-            intf_ErrMsg( "vout: window destroyed !");
-        }
-        /* Keyboard event */
-        else if( xevent.type == KeyPress )
-        {
-            if( XLookupString( &xevent.xkey, &i_key, 1, NULL, NULL ) )
-            {
-                if( intf_ProcessKey( p_intf, i_key ) )
-                {
-                    intf_DbgMsg("unhandled key '%c' (%i)", (char) i_key, i_key );
-                }
-            }
-        }
-        /* Mouse click */
-        else if( xevent.type == ButtonPress )
-        {
-            switch( ((XButtonEvent *)&xevent)->button )
-            {
-                case Button1:
-                    /* in this part we will eventually manage
-                     * clicks for DVD navigation for instance */
-                    break;
-
-                case Button2:
-                    X11TogglePointer( p_intf );
-                    break;
-
-                case Button3:
-                    vlc_mutex_lock( &p_intf->p_vout->change_lock );
-                    p_intf->p_vout->b_interface = !p_intf->p_vout->b_interface;
-                    p_intf->p_vout->i_changes  |= VOUT_INTF_CHANGE;
-                    vlc_mutex_unlock( &p_intf->p_vout->change_lock );
-                    break;
-            }
-        }
-        /* ClientMessage event - only WM_PROTOCOLS with WM_DELETE_WINDOW data
-         * are handled - according to the man pages, the format is always 32
-         * in this case */
-        else if( (xevent.type == ClientMessage)
-                 && (xevent.xclient.message_type == p_intf->p_sys->wm_protocols)
-                 && (xevent.xclient.data.l[0] == p_intf->p_sys->wm_delete_window ) )
-        {
-            /* FIXME: this never happens :( how to receive wm messages ?? */
-            intf_DbgMsg("ClientMessage received");
-        }
-#ifdef DEBUG
-        /* Other event */
-        else
-        {
-            intf_DbgMsg("%p -> unhandled event type %d received", p_intf, xevent.type );
-        }
-#endif
-    }
-
-    /*
-     * Handle vout or interface windows resizing
-     */
-    if( p_intf->p_vout != NULL )
-    {
-        if( b_resized )
-        {
-            /* If interface window has been resized, change vout size */
-            intf_DbgMsg("resizing output window");
-            vlc_mutex_lock( &p_intf->p_vout->change_lock );
-            p_intf->p_vout->i_width =  p_intf->p_sys->i_width;
-            p_intf->p_vout->i_height = p_intf->p_sys->i_height;
-            p_intf->p_vout->i_changes |= VOUT_SIZE_CHANGE;
-            vlc_mutex_unlock( &p_intf->p_vout->change_lock );
-        }
-        else if( (p_intf->p_vout->i_width  != p_intf->p_sys->i_width) ||
-                 (p_intf->p_vout->i_height != p_intf->p_sys->i_height) )
-        {
-           /* If video output size has changed, change interface window size */
-            intf_DbgMsg("resizing interface window");
-            p_intf->p_sys->i_width =    p_intf->p_vout->i_width;
-            p_intf->p_sys->i_height =   p_intf->p_vout->i_height;
-            XResizeWindow( p_intf->p_sys->p_display, p_intf->p_sys->window,
-                           p_intf->p_sys->i_width, p_intf->p_sys->i_height );
-        }
-    }
-}
-
-/*****************************************************************************
- * X11EnableScreenSaver: enable screen saver
- *****************************************************************************
- * This function enable the screen saver on a display after it had been
- * disabled by XDisableScreenSaver. Both functions use a counter mechanism to
- * know wether the screen saver can be activated or not: if n successive calls
- * are made to XDisableScreenSaver, n successive calls to XEnableScreenSaver
- * will be required before the screen saver could effectively be activated.
- *****************************************************************************/
-void X11EnableScreenSaver( intf_thread_t *p_intf )
-{
-    if( p_intf->p_sys->i_ss_count++ == 0 )
-    {
-        intf_DbgMsg("intf: enabling screen saver");
-        XSetScreenSaver( p_intf->p_sys->p_display, p_intf->p_sys->i_ss_timeout,
-                         p_intf->p_sys->i_ss_interval, p_intf->p_sys->i_ss_blanking,
-                         p_intf->p_sys->i_ss_exposure );
-    }
-}
-
-/*****************************************************************************
- * X11DisableScreenSaver: disable screen saver
- *****************************************************************************
- * See XEnableScreenSaver
- *****************************************************************************/
-void X11DisableScreenSaver( intf_thread_t *p_intf )
-{
-    if( --p_intf->p_sys->i_ss_count == 0 )
-    {
-        /* Save screen saver informations */
-        XGetScreenSaver( p_intf->p_sys->p_display, &p_intf->p_sys->i_ss_timeout,
-                         &p_intf->p_sys->i_ss_interval, &p_intf->p_sys->i_ss_blanking,
-                         &p_intf->p_sys->i_ss_exposure );
-
-        /* Disable screen saver */
-        intf_DbgMsg("intf: disabling screen saver");
-        XSetScreenSaver( p_intf->p_sys->p_display, 0,
-                         p_intf->p_sys->i_ss_interval, p_intf->p_sys->i_ss_blanking,
-                         p_intf->p_sys->i_ss_exposure );
-    }
-}
-
-/*****************************************************************************
- * X11TogglePointer: hide or show the mouse pointer
- *****************************************************************************
- * This function hides the X pointer if it is visible by putting it at
- * coordinates (32,32) and setting the pointer sprite to a blank one. To
- * show it again, we disable the sprite and restore the original coordinates.
- *****************************************************************************/
-void X11TogglePointer( intf_thread_t *p_intf )
-{
-    static Cursor cursor;
-    static boolean_t b_cursor = 0;
-
-    if( p_intf->p_sys->b_mouse )
-    {
-        p_intf->p_sys->b_mouse = 0;
-
-        if( !b_cursor )
-        {
-            XColor color;
-            Pixmap blank = XCreatePixmap( p_intf->p_sys->p_display,
-                               DefaultRootWindow(p_intf->p_sys->p_display),
-                               1, 1, 1 );
-
-            XParseColor( p_intf->p_sys->p_display,
-                         XCreateColormap( p_intf->p_sys->p_display,
-                                          DefaultRootWindow(
-                                                  p_intf->p_sys->p_display ),
-                                          DefaultVisual(
-                                                  p_intf->p_sys->p_display,
-                                                  p_intf->p_sys->i_screen ),
-                                          AllocNone ),
-                         "black", &color );
-
-            cursor = XCreatePixmapCursor( p_intf->p_sys->p_display,
-                           blank, blank, &color, &color, 1, 1 );
-
-            b_cursor = 1;
-        }
-        XDefineCursor( p_intf->p_sys->p_display,
-                       p_intf->p_sys->window, cursor );
-    }
-    else
-    {
-        p_intf->p_sys->b_mouse = 1;
-
-        XUndefineCursor( p_intf->p_sys->p_display, p_intf->p_sys->window );
-    }
-}
index b824b78d56fba2006fa548ff919c6f025e1373f1..e7c43b137383920a264b469b85ad2f2614555790 100644 (file)
@@ -1,9 +1,9 @@
 /*****************************************************************************
  * mga.c : Matrox Graphic Array plugin for vlc
  *****************************************************************************
- * Copyright (C) 2000 VideoLAN
+ * Copyright (C) 2000, 2001 VideoLAN
  *
- * Authors:
+ * Authors: Samuel Hocevar <sam@zoy.org>
  *
  * 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
@@ -20,6 +20,9 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
+#define MODULE_NAME mga
+#include "modules_inner.h"
+
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
 #include "common.h"                                     /* boolean_t, byte_t */
 #include "threads.h"
 #include "mtime.h"
-#include "plugins.h"
 
-#include "interface.h"
-#include "audio_output.h"
 #include "video.h"
 #include "video_output.h"
 
+#include "modules.h"
+
 /*****************************************************************************
- * Exported prototypes
+ * Building configuration tree
  *****************************************************************************/
-static void vout_GetPlugin( p_vout_thread_t p_vout );
-static void intf_GetPlugin( p_intf_thread_t p_intf );
-
-/* Video output */
-int     vout_MGACreate       ( vout_thread_t *p_vout, char *psz_display,
-                               int i_root_window, void *p_data );
-int     vout_MGAInit         ( p_vout_thread_t p_vout );
-void    vout_MGAEnd          ( p_vout_thread_t p_vout );
-void    vout_MGADestroy      ( p_vout_thread_t p_vout );
-int     vout_MGAManage       ( p_vout_thread_t p_vout );
-void    vout_MGADisplay      ( p_vout_thread_t p_vout );
-void    vout_SetPalette      ( p_vout_thread_t p_vout,
-                               u16 *red, u16 *green, u16 *blue, u16 *transp );
-
-/* Interface */
-int     intf_MGACreate       ( p_intf_thread_t p_intf );
-void    intf_MGADestroy      ( p_intf_thread_t p_intf );
-void    intf_MGAManage       ( p_intf_thread_t p_intf );
+MODULE_CONFIG_START
+ADD_WINDOW( "Configuration for MGA module" )
+    ADD_COMMENT( "For now, the MGA module cannot be configured" )
+MODULE_CONFIG_END
+
+/*****************************************************************************
+ * Capabilities defined in the other files.
+ ******************************************************************************/
+void _M( vout_getfunctions )( function_list_t * p_function_list );
 
 /*****************************************************************************
- * GetConfig: get the plugin structure and configuration
+ * InitModule: get the module structure and configuration.
+ *****************************************************************************
+ * We have to fill psz_name, psz_longname and psz_version. These variables
+ * will be strdup()ed later by the main application because the module can
+ * be unloaded later to save memory, and we want to be able to access this
+ * data even after the module has been unloaded.
  *****************************************************************************/
-plugin_info_t * GetConfig( void )
+MODULE_INIT
 {
-    plugin_info_t * p_info = (plugin_info_t *) malloc( sizeof(plugin_info_t) );
-
-    p_info->psz_name    = "Matrox Acceleration";
-    p_info->psz_version = VERSION;
-    p_info->psz_author  = "the VideoLAN team <vlc@videolan.org>";
+    p_module->psz_name = MODULE_STRING;
+    p_module->psz_longname = "Matrox Graphic Array module";
+    p_module->psz_version = VERSION;
 
-    p_info->aout_GetPlugin = NULL;
-    p_info->vout_GetPlugin = vout_GetPlugin;
-    p_info->intf_GetPlugin = intf_GetPlugin;
-    p_info->yuv_GetPlugin  = NULL;
+    p_module->i_capabilities = MODULE_CAPABILITY_NULL
+                                | MODULE_CAPABILITY_VOUT;
 
-    /* The MGA module does not work yet */
-    p_info->i_score = 0x0;
-
-    return( p_info );
+    return( 0 );
 }
 
 /*****************************************************************************
- * Following functions are only called through the p_info structure
+ * ActivateModule: set the module to an usable state.
+ *****************************************************************************
+ * This function fills the capability functions and the configuration
+ * structure. Once ActivateModule() has been called, the i_usage can
+ * be set to 0 and calls to NeedModule() be made to increment it. To unload
+ * the module, one has to wait until i_usage == 0 and call DeactivateModule().
  *****************************************************************************/
-
-static void vout_GetPlugin( p_vout_thread_t p_vout )
+MODULE_ACTIVATE
 {
-    p_vout->p_sys_create  = vout_MGACreate;
-    p_vout->p_sys_init    = vout_MGAInit;
-    p_vout->p_sys_end     = vout_MGAEnd;
-    p_vout->p_sys_destroy = vout_MGADestroy;
-    p_vout->p_sys_manage  = vout_MGAManage;
-    p_vout->p_sys_display = vout_MGADisplay;
+    p_module->p_functions = malloc( sizeof( module_functions_t ) );
+    if( p_module->p_functions == NULL )
+    {
+        return( -1 );
+    }
+
+    _M( vout_getfunctions )( &p_module->p_functions->vout );
+
+    p_module->p_config = p_config;
+
+    return( 0 );
 }
 
-static void intf_GetPlugin( p_intf_thread_t p_intf )
+/*****************************************************************************
+ * DeactivateModule: make sure the module can be unloaded.
+ *****************************************************************************
+ * This function must only be called when i_usage == 0. If it successfully
+ * returns, i_usage can be set to -1 and the module unloaded. Be careful to
+ * lock usage_lock during the whole process.
+ *****************************************************************************/
+MODULE_DEACTIVATE
 {
-    p_intf->p_sys_create  = intf_MGACreate;
-    p_intf->p_sys_destroy = intf_MGADestroy;
-    p_intf->p_sys_manage  = intf_MGAManage;
+    free( p_module->p_functions );
+
+    return( 0 );
 }
 
index efc1e37ce58251f486e340a9adf1dd0922203f0c..3756f09e9959fa5219c5232aeb6e9ad8ba74504f 100644 (file)
@@ -1,9 +1,10 @@
 /*****************************************************************************
  * vout_mga.c: MGA video output display method
  *****************************************************************************
- * Copyright (C) 1998, 1999, 2000 VideoLAN
+ * Copyright (C) 1998, 1999, 2000, 2001 VideoLAN
  *
- * Authors:
+ * Authors: Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
+ *          Samuel Hocevar <sam@zoy.org>
  *
  * 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
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
+#define MODULE_NAME mga
+#include "modules_inner.h"
+
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
 #include "defs.h"
 
 #include <errno.h>                                                 /* ENOMEM */
+#include <unistd.h>                                               /* close() */
 #include <stdlib.h>                                                /* free() */
 #include <string.h>                                            /* strerror() */
 #include <fcntl.h>                                                 /* open() */
 #include <sys/types.h>                                     /* typedef ushort */
 #endif
 
-#include <sys/shm.h>                                   /* shmget(), shmctl() */
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#include <X11/extensions/XShm.h>
-
 #include "config.h"
 #include "common.h"
 #include "threads.h"
 #include "mtime.h"
-#include "plugins.h"
+#include "tests.h"
+#include "modules.h"
 
 #include "video.h"
 #include "video_output.h"
 #include "vout_mga.h"
 
 /*****************************************************************************
- * vout_MGACreate: allocate X11 video thread output method
+ * vout_sys_t: video output MGA method descriptor
+ *****************************************************************************
+ * This structure is part of the video output thread descriptor.
+ * It describes the MGA specific properties of an output thread.
+ *****************************************************************************/
+#ifndef __LINUX_MGAVID_H
+#   define __LINUX_MGAVID_H
+#   define MGA_VID_CONFIG _IOR('J', 1, mga_vid_config_t)
+#   define MGA_VID_ON     _IO ('J', 2)
+#   define MGA_VID_OFF    _IO ('J', 3)
+#   define MGA_G200 0x1234
+#   define MGA_G400 0x5678
+typedef struct mga_vid_config_s
+{
+    u32     card_type;
+    u32     ram_size;
+    u32     src_width;
+    u32     src_height;
+    u32     dest_width;
+    u32     dest_height;
+    u32     x_org;
+    u32     y_org;
+    u8      colkey_on;
+    u8      colkey_red;
+    u8      colkey_green;
+    u8      colkey_blue;
+} mga_vid_config_t;
+#endif
+
+typedef struct vout_sys_s
+{
+    int                 i_page_size;
+    byte_t             *p_video;
+
+    /* MGA specific variables */
+    int                 i_fd;
+    int                 i_size;
+    mga_vid_config_t    mga;
+    byte_t *            p_mga_vid_base;
+    boolean_t           b_g400;
+
+} vout_sys_t;
+
+#define DUMMY_WIDTH 16
+#define DUMMY_HEIGHT 16
+#define DUMMY_BITS_PER_PLANE 16
+#define DUMMY_BYTES_PER_PIXEL 2
+
+/*****************************************************************************
+ * Local prototypes
+ *****************************************************************************/
+static int  vout_Probe     ( probedata_t *p_data );
+static int  vout_Create    ( struct vout_thread_s * );
+static int  vout_Init      ( struct vout_thread_s * );
+static void vout_End       ( struct vout_thread_s * );
+static void vout_Destroy   ( struct vout_thread_s * );
+static int  vout_Manage    ( struct vout_thread_s * );
+static void vout_Display   ( struct vout_thread_s * );
+
+/*****************************************************************************
+ * Functions exported as capabilities. They are declared as static so that
+ * we don't pollute the namespace too much.
+ *****************************************************************************/
+void _M( vout_getfunctions )( function_list_t * p_function_list )
+{
+    p_function_list->pf_probe = vout_Probe;
+    p_function_list->functions.vout.pf_create     = vout_Create;
+    p_function_list->functions.vout.pf_init       = vout_Init;
+    p_function_list->functions.vout.pf_end        = vout_End;
+    p_function_list->functions.vout.pf_destroy    = vout_Destroy;
+    p_function_list->functions.vout.pf_manage     = vout_Manage;
+    p_function_list->functions.vout.pf_display    = vout_Display;
+    p_function_list->functions.vout.pf_setpalette = NULL;
+}
+
+/*****************************************************************************
+ * intf_Probe: return a score
+ *****************************************************************************/
+static int vout_Probe( probedata_t *p_data )
+{
+    if( TestMethod( VOUT_METHOD_VAR, "mga" ) )
+    {
+        return( 999 );
+    }
+
+    return( 10 );
+}
+
+/*****************************************************************************
+ * vout_Create: allocates dummy video thread output method
  *****************************************************************************
- * This function allocate and initialize a X11 vout method. It uses some of the
- * vout properties to choose the window size, and change them according to the
- * actual properties of the display.
+ * This function allocates and initializes a dummy vout method.
  *****************************************************************************/
-int vout_MGACreate( vout_thread_t *p_vout, char *psz_display,
-                    int i_root_window, void *p_data )
+static int vout_Create( vout_thread_t *p_vout )
 {
     /* Allocate structure */
     p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
     if( p_vout->p_sys == NULL )
     {
-        intf_ErrMsg("error: %s", strerror(ENOMEM) );
+        intf_ErrMsg("vout error: %s", strerror(ENOMEM) );
         return( 1 );
     }
 
-    /* Allocate MGA configuration structure */
-    p_vout->p_sys->p_mga = malloc( sizeof( mga_vid_config_t ) );
-    if( p_vout->p_sys->p_mga == NULL )
+    if( (p_vout->p_sys->i_fd = open( "/dev/mga_vid", O_RDWR )) == -1 )
     {
-        intf_ErrMsg("error: %s", strerror(ENOMEM) );
+        intf_ErrMsg( "vout error: can't open MGA driver /dev/mga_vid" );
         free( p_vout->p_sys );
         return( 1 );
     }
 
-    if( (p_vout->p_sys->i_fd = open("/dev/mga_vid",O_RDWR)) == -1 )
-    {
-        intf_ErrMsg("error: can't open MGA driver /dev/mga_vid" );
-        free( p_vout->p_sys->p_mga );
-        free( p_vout->p_sys );
-        return( 1 );
-    }
+    p_vout->i_width            = DUMMY_WIDTH;
+    p_vout->i_height           = DUMMY_HEIGHT;
+    p_vout->i_screen_depth     = DUMMY_BITS_PER_PLANE;
+    p_vout->i_bytes_per_pixel  = DUMMY_BYTES_PER_PIXEL;
+    p_vout->i_bytes_per_line   = DUMMY_WIDTH * DUMMY_BYTES_PER_PIXEL;
+
+    p_vout->p_sys->i_page_size = DUMMY_WIDTH * DUMMY_HEIGHT
+                                  * DUMMY_BYTES_PER_PIXEL;
 
-    /* Open and initialize device. This function issues its own error messages.
-     * Since XLib is usually not thread-safe, we can't use the same display
-     * pointer than the interface or another thread. However, the root window
-     * id is still valid. */
-    if( X11OpenDisplay( p_vout, psz_display, i_root_window ) )
+    /* Map two framebuffers a the very beginning of the fb */
+    p_vout->p_sys->p_video = malloc( 2 * p_vout->p_sys->i_page_size );
+    if( p_vout->p_sys->p_video == NULL )
     {
-        intf_ErrMsg("error: can't initialize X11 display" );
-        free( p_vout->p_sys->p_mga );
+        intf_ErrMsg( "vout error: can't map video memory (%s)",
+                     strerror(errno) );
         free( p_vout->p_sys );
         return( 1 );
     }
 
+    /* Set and initialize buffers */
+    vout_SetBuffers( p_vout, p_vout->p_sys->p_video,
+                     p_vout->p_sys->p_video + p_vout->p_sys->i_page_size );
+
     return( 0 );
 }
 
 /*****************************************************************************
- * vout_MGAInit: initialize X11 video thread output method
- *****************************************************************************
- * This function create the XImages needed by the output thread. It is called
- * at the beginning of the thread, but also each time the window is resized.
+ * vout_Init: initialize dummy video thread output method
  *****************************************************************************/
-int vout_MGAInit( vout_thread_t *p_vout )
+static int vout_Init( vout_thread_t *p_vout )
 {
-    int i_err;
-
     /* create the MGA output */
-    p_vout->p_sys->p_mga->src_width = p_vout->i_width;
-    p_vout->p_sys->p_mga->src_height = p_vout->i_height;
+    p_vout->p_sys->mga.src_width = p_vout->i_width;
+    p_vout->p_sys->mga.src_height = p_vout->i_height;
     /* FIXME: we should initialize these ones according to the streams */
-    p_vout->p_sys->p_mga->dest_width = p_vout->i_width;
-    p_vout->p_sys->p_mga->dest_height = p_vout->i_height;
-    //p_vout->p_sys->p_mga->dest_width = 400;
-    //p_vout->p_sys->p_mga->dest_height = 300;
-    p_vout->p_sys->p_mga->x_org = 100;
-    p_vout->p_sys->p_mga->y_org = 100;
-    p_vout->p_sys->p_mga->colkey_on = 0;
-
-    if( ioctl(p_vout->p_sys->i_fd, MGA_VID_CONFIG, p_vout->p_sys->p_mga) )
+    p_vout->p_sys->mga.dest_width = p_vout->i_width;
+    p_vout->p_sys->mga.dest_height = p_vout->i_height;
+    //p_vout->p_sys->mga?dest_width = 400;
+    //p_vout->p_sys->mga.dest_height = 300;
+    p_vout->p_sys->mga.x_org = 100;
+    p_vout->p_sys->mga.y_org = 100;
+    p_vout->p_sys->mga.colkey_on = 0;
+
+    if( ioctl(p_vout->p_sys->i_fd, MGA_VID_CONFIG, &p_vout->p_sys->mga) )
     {
         intf_ErrMsg("error in config ioctl");
     }
 
-    if (p_vout->p_sys->p_mga->card_type == MGA_G200)
+    if (p_vout->p_sys->mga.card_type == MGA_G200)
     {
         intf_Msg( "vout: detected MGA G200 (%d MB Ram)",
-                  p_vout->p_sys->p_mga->ram_size );
+                  p_vout->p_sys->mga.ram_size );
         p_vout->p_sys->b_g400 = 0;
     }
     else
     {
         intf_Msg( "vout: detected MGA G400 (%d MB Ram)",
-                  p_vout->p_sys->p_mga->ram_size );
+                  p_vout->p_sys->mga.ram_size );
         p_vout->p_sys->b_g400 = 1;
     }
 
     ioctl( p_vout->p_sys->i_fd, MGA_VID_ON, 0 );
 
-    p_vout->p_sys->i_size = ( (p_vout->p_sys->p_mga->src_width + 31) & ~31 )
-                             * p_vout->p_sys->p_mga->src_height;
+    p_vout->p_sys->i_size = ( (p_vout->p_sys->mga.src_width + 31) & ~31 )
+                             * p_vout->p_sys->mga.src_height;
 
     p_vout->p_sys->p_mga_vid_base = mmap( 0, p_vout->p_sys->i_size
                                              + p_vout->p_sys->i_size / 2,
@@ -160,526 +243,49 @@ int vout_MGAInit( vout_thread_t *p_vout )
     memset( p_vout->p_sys->p_mga_vid_base + p_vout->p_sys->i_size,
             0x80, p_vout->p_sys->i_size / 2 );
 
-    /* Create XImages using XShm extension - on failure, fall back to regular
-     * way (and destroy the first image if it was created successfully) */
-    if( p_vout->p_sys->b_shm )
-    {
-        /* Create first image */
-        i_err = X11CreateShmImage( p_vout, &p_vout->p_sys->p_ximage[0],
-                                   &p_vout->p_sys->shm_info[0] );
-        if( !i_err )                         /* first image has been created */
-        {
-            /* Create second image */
-            if( X11CreateShmImage( p_vout, &p_vout->p_sys->p_ximage[1],
-                                   &p_vout->p_sys->shm_info[1] ) )
-            {                             /* error creating the second image */
-                X11DestroyShmImage( p_vout, p_vout->p_sys->p_ximage[0],
-                                    &p_vout->p_sys->shm_info[0] );
-                i_err = 1;
-            }
-        }
-        if( i_err )                                      /* an error occured */
-        {
-            intf_Msg("vout: XShm video sextension deactivated" );
-            p_vout->p_sys->b_shm = 0;
-        }
-    }
-
-    /* Create XImages without XShm extension */
-    if( !p_vout->p_sys->b_shm )
-    {
-        if( X11CreateImage( p_vout, &p_vout->p_sys->p_ximage[0] ) )
-        {
-            intf_ErrMsg("error: can't create images");
-            p_vout->p_sys->p_ximage[0] = NULL;
-            p_vout->p_sys->p_ximage[1] = NULL;
-            return( 1 );
-        }
-        if( X11CreateImage( p_vout, &p_vout->p_sys->p_ximage[1] ) )
-        {
-            intf_ErrMsg("error: can't create images");
-            X11DestroyImage( p_vout->p_sys->p_ximage[0] );
-            p_vout->p_sys->p_ximage[0] = NULL;
-            p_vout->p_sys->p_ximage[1] = NULL;
-            return( 1 );
-        }
-    }
-
-    /* Set bytes per line and initialize buffers */
-    p_vout->i_bytes_per_line = p_vout->p_sys->p_ximage[0]->bytes_per_line;
-    vout_SetBuffers( p_vout, p_vout->p_sys->p_ximage[ 0 ]->data,
-                     p_vout->p_sys->p_ximage[ 1 ]->data );
     return( 0 );
 }
 
 /*****************************************************************************
- * vout_MGAEnd: terminate X11 video thread output method
- *****************************************************************************
- * Destroy the X11 XImages created by vout_MGAInit. It is called at the end of
- * the thread, but also each time the window is resized.
+ * vout_End: terminate dummy video thread output method
  *****************************************************************************/
-void vout_MGAEnd( vout_thread_t *p_vout )
+static void vout_End( vout_thread_t *p_vout )
 {
-    if( p_vout->p_sys->b_shm )                             /* Shm XImages... */
-    {
-        X11DestroyShmImage( p_vout, p_vout->p_sys->p_ximage[0],
-                            &p_vout->p_sys->shm_info[0] );
-        X11DestroyShmImage( p_vout, p_vout->p_sys->p_ximage[1],
-                            &p_vout->p_sys->shm_info[1] );
-    }
-    else                                          /* ...or regular XImages */
-    {
-        X11DestroyImage( p_vout->p_sys->p_ximage[0] );
-        X11DestroyImage( p_vout->p_sys->p_ximage[1] );
-    }
+    ioctl( p_vout->p_sys->i_fd, MGA_VID_OFF, 0 );
 }
 
 /*****************************************************************************
- * vout_MGADestroy: destroy X11 video thread output method
+ * vout_Destroy: destroy dummy video thread output method
  *****************************************************************************
- * Terminate an output method created by vout_CreateOutputMethod
+ * Terminate an output method created by DummyCreateOutputMethod
  *****************************************************************************/
-void vout_MGADestroy( vout_thread_t *p_vout )
+static void vout_Destroy( vout_thread_t *p_vout )
 {
-    X11CloseDisplay( p_vout );
-
-    ioctl( p_vout->p_sys->i_fd, MGA_VID_OFF, 0 );
     close( p_vout->p_sys->i_fd );
 
-    free( p_vout->p_sys->p_mga );
+    free( p_vout->p_sys->p_video );
     free( p_vout->p_sys );
 }
 
 /*****************************************************************************
- * vout_MGAManage: handle X11 events
+ * vout_Manage: handle dummy events
  *****************************************************************************
  * This function should be called regularly by video output thread. It manages
- * X11 events and allows window resizing. It returns a non null value on
- * error.
- *****************************************************************************/
-int vout_MGAManage( vout_thread_t *p_vout )
-{
-    /*
-     * Color/Grayscale or gamma change: in 8bpp, just change the colormap
-     */
-    if( (p_vout->i_changes & VOUT_GRAYSCALE_CHANGE) && (p_vout->i_screen_depth == 8) )
-    {
-        /* FIXME: clear flags ?? */
-    }
-
-    /*
-     * Size change
-     */
-    if( p_vout->i_changes & VOUT_SIZE_CHANGE )
-    {
-        intf_DbgMsg("resizing window");
-        p_vout->i_changes &= ~VOUT_SIZE_CHANGE;
-
-        /* Resize window */
-        XResizeWindow( p_vout->p_sys->p_display, p_vout->p_sys->window,
-                       p_vout->i_width, p_vout->i_height );
-
-        /* Destroy XImages to change their size */
-        vout_MGAEnd( p_vout );
-
-        /* Recreate XImages. If SysInit failed, the thread can't go on. */
-        if( vout_MGAInit( p_vout ) )
-        {
-            intf_ErrMsg("error: can't resize display");
-            return( 1 );
-        }
-
-        /* Tell the video output thread that it will need to rebuild YUV
-         * tables. This is needed since convertion buffer size may have changed */
-        p_vout->i_changes |= VOUT_YUV_CHANGE;
-        intf_Msg("vout: video display resized (%dx%d)", p_vout->i_width, p_vout->i_height);
-    }
-
-    return 0;
-}
-
-/*****************************************************************************
- * vout_MGADisplay: displays previously rendered output
- *****************************************************************************
- * This function send the currently rendered image to X11 server, wait until
- * it is displayed and switch the two rendering buffer, preparing next frame.
- *****************************************************************************/
-void vout_MGADisplay( vout_thread_t *p_vout )
-{
-    if( p_vout->p_sys->b_shm)                                /* XShm is used */
-    {
-        /* Display rendered image using shared memory extension */
-        XShmPutImage(p_vout->p_sys->p_display, p_vout->p_sys->window, p_vout->p_sys->gc,
-                     p_vout->p_sys->p_ximage[ p_vout->i_buffer_index ],
-                     0, 0, 0, 0,
-                     p_vout->p_sys->p_ximage[ p_vout->i_buffer_index ]->width,
-                     p_vout->p_sys->p_ximage[ p_vout->i_buffer_index ]->height, True);
-
-        /* Send the order to the X server */
-        XFlush(p_vout->p_sys->p_display);
-    }
-    else                                /* regular X11 capabilities are used */
-    {
-        XPutImage(p_vout->p_sys->p_display, p_vout->p_sys->window, p_vout->p_sys->gc,
-                  p_vout->p_sys->p_ximage[ p_vout->i_buffer_index ],
-                  0, 0, 0, 0,
-                  p_vout->p_sys->p_ximage[ p_vout->i_buffer_index ]->width,
-                  p_vout->p_sys->p_ximage[ p_vout->i_buffer_index ]->height);
-
-        /* Send the order to the X server */
-        XFlush(p_vout->p_sys->p_display);
-    }
-}
-
-/* following functions are local */
-
-/*****************************************************************************
- * X11OpenDisplay: open and initialize X11 device
- *****************************************************************************
- * Create a window according to video output given size, and set other
- * properties according to the display properties.
- *****************************************************************************/
-static int X11OpenDisplay( vout_thread_t *p_vout, char *psz_display, Window root_window )
-{
-    XPixmapFormatValues *       p_xpixmap_format;          /* pixmap formats */
-    XVisualInfo *               p_xvisual;           /* visuals informations */
-    XVisualInfo                 xvisual_template;         /* visual template */
-    int                         i_count;                       /* array size */
-
-    /* Open display */
-    p_vout->p_sys->p_display = XOpenDisplay( psz_display );
-    if( p_vout->p_sys->p_display == NULL )
-    {
-        intf_ErrMsg("error: can't open display %s", psz_display );
-        return( 1 );
-    }
-
-    /* Initialize structure */
-    p_vout->p_sys->root_window  = root_window;
-    p_vout->p_sys->b_shm        = (XShmQueryExtension(p_vout->p_sys->p_display) == True);
-    p_vout->p_sys->i_screen     = DefaultScreen( p_vout->p_sys->p_display );
-    if( !p_vout->p_sys->b_shm )
-    {
-        intf_Msg("vout: XShm video extension is not available");
-    }
-
-    /* Get screen depth */
-    p_vout->i_screen_depth = XDefaultDepth( p_vout->p_sys->p_display, p_vout->p_sys->i_screen );
-    switch( p_vout->i_screen_depth )
-    {
-    case 8:
-        /*
-         * Screen depth is 8bpp. Use PseudoColor visual with private colormap.
-         */
-        xvisual_template.screen =   p_vout->p_sys->i_screen;
-        xvisual_template.class =    DirectColor;
-        p_xvisual = XGetVisualInfo( p_vout->p_sys->p_display, VisualScreenMask | VisualClassMask,
-                                    &xvisual_template, &i_count );
-        if( p_xvisual == NULL )
-        {
-            intf_ErrMsg("error: no PseudoColor visual available");
-            XCloseDisplay( p_vout->p_sys->p_display );
-            return( 1 );
-        }
-        /* FIXME: SetColormap; ?? */
-        p_vout->i_bytes_per_pixel = 1;
-        break;
-    case 15:
-    case 16:
-    case 24:
-    default:
-        /*
-         * Screen depth is higher than 8bpp. TrueColor visual is used.
-         */
-        xvisual_template.screen =   p_vout->p_sys->i_screen;
-        xvisual_template.class =    TrueColor;
-        p_xvisual = XGetVisualInfo( p_vout->p_sys->p_display, VisualScreenMask | VisualClassMask,
-                                    &xvisual_template, &i_count );
-        if( p_xvisual == NULL )
-        {
-            intf_ErrMsg("error: no TrueColor visual available");
-            XCloseDisplay( p_vout->p_sys->p_display );
-            return( 1 );
-        }
-        p_vout->i_red_mask =        p_xvisual->red_mask;
-        p_vout->i_green_mask =      p_xvisual->green_mask;
-        p_vout->i_blue_mask =       p_xvisual->blue_mask;
-
-        /* There is no difference yet between 3 and 4 Bpp. The only way to find
-         * the actual number of bytes per pixel is to list supported pixmap
-         * formats. */
-        p_xpixmap_format = XListPixmapFormats( p_vout->p_sys->p_display, &i_count );
-        p_vout->i_bytes_per_pixel = 0;
-        for( ; i_count--; p_xpixmap_format++ )
-        {
-            if( p_xpixmap_format->bits_per_pixel / 8 > p_vout->i_bytes_per_pixel )
-            {
-                p_vout->i_bytes_per_pixel = p_xpixmap_format->bits_per_pixel / 8;
-            }
-        }
-        break;
-    }
-    p_vout->p_sys->p_visual = p_xvisual->visual;
-    XFree( p_xvisual );
-
-    /* Create a window */
-    if( X11CreateWindow( p_vout ) )
-    {
-        intf_ErrMsg("error: can't open a window");
-        XCloseDisplay( p_vout->p_sys->p_display );
-        return( 1 );
-    }
-    return( 0 );
-}
-
-/*****************************************************************************
- * X11CloseDisplay: close X11 device
- *****************************************************************************
- * Returns all resources allocated by X11OpenDisplay and restore the original
- * state of the display.
- *****************************************************************************/
-static void X11CloseDisplay( vout_thread_t *p_vout )
-{
-    /* Destroy colormap */
-    if( p_vout->i_screen_depth == 8 )
-    {
-        XFreeColormap( p_vout->p_sys->p_display, p_vout->p_sys->colormap );
-    }
-
-    /* Destroy window and close display */
-    X11DestroyWindow( p_vout );
-    XCloseDisplay( p_vout->p_sys->p_display );
-}
-
-/*****************************************************************************
- * X11CreateWindow: create X11 vout window
- *****************************************************************************
- * The video output window will be created. Normally, this window is wether
- * full screen or part of a parent window. Therefore, it does not need a
- * title or other hints. Thery are still supplied in case the window would be
- * spawned as a standalone one by the interface.
- *****************************************************************************/
-static int X11CreateWindow( vout_thread_t *p_vout )
-{
-    XSetWindowAttributes    xwindow_attributes;         /* window attributes */
-    XGCValues               xgcvalues;      /* graphic context configuration */
-    XEvent                  xevent;                          /* first events */
-    boolean_t               b_expose;             /* 'expose' event received */
-    boolean_t               b_map_notify;     /* 'map_notify' event received */
-
-    /* Prepare window attributes */
-    xwindow_attributes.backing_store = Always;       /* save the hidden part */
-
-    /* Create the window and set hints */
-    p_vout->p_sys->window = XCreateSimpleWindow( p_vout->p_sys->p_display,
-                                         p_vout->p_sys->root_window,
-                                         0, 0,
-                                         p_vout->i_width, p_vout->i_height,
-                                         0, 0, 0);
-    XSelectInput( p_vout->p_sys->p_display, p_vout->p_sys->window,
-                  ExposureMask | StructureNotifyMask );
-    XChangeWindowAttributes( p_vout->p_sys->p_display, p_vout->p_sys->window,
-                             CWBackingStore, &xwindow_attributes);
-
-    /* Creation of a graphic context that doesn't generate a GraphicsExpose event
-       when using functions like XCopyArea */
-    xgcvalues.graphics_exposures = False;
-    p_vout->p_sys->gc =  XCreateGC( p_vout->p_sys->p_display, p_vout->p_sys->window,
-                                    GCGraphicsExposures, &xgcvalues);
-
-    /* Send orders to server, and wait until window is displayed - two events
-     * must be received: a MapNotify event, an Expose event allowing drawing in the
-     * window */
-    b_expose = 0;
-    b_map_notify = 0;
-    XMapWindow( p_vout->p_sys->p_display, p_vout->p_sys->window);
-    do
-    {
-        XNextEvent( p_vout->p_sys->p_display, &xevent);
-        if( (xevent.type == Expose)
-            && (xevent.xexpose.window == p_vout->p_sys->window) )
-        {
-            b_expose = 1;
-        }
-        else if( (xevent.type == MapNotify)
-                 && (xevent.xmap.window == p_vout->p_sys->window) )
-        {
-            b_map_notify = 1;
-        }
-    }
-    while( !( b_expose && b_map_notify ) );
-    XSelectInput( p_vout->p_sys->p_display, p_vout->p_sys->window, 0 );
-
-    /* At this stage, the window is openned, displayed, and ready to receive
-     * data */
-    return( 0 );
-}
-
-/*****************************************************************************
- * X11DestroyWindow: destroy X11 window
- *****************************************************************************
- * Destroy an X11 window created by vout_CreateWindow
- *****************************************************************************/
-static void X11DestroyWindow( vout_thread_t *p_vout )
-{
-    XUnmapWindow( p_vout->p_sys->p_display, p_vout->p_sys->window );
-    XFreeGC( p_vout->p_sys->p_display, p_vout->p_sys->gc );
-    XDestroyWindow( p_vout->p_sys->p_display, p_vout->p_sys->window );
-}
-
-/*****************************************************************************
- * X11CreateImage: create an XImage
- *****************************************************************************
- * Create a simple XImage used as a buffer.
- *****************************************************************************/
-static int X11CreateImage( vout_thread_t *p_vout, XImage **pp_ximage )
-{
-    byte_t *    pb_data;                          /* image data storage zone */
-    int         i_quantum;                     /* XImage quantum (see below) */
-
-    /* Allocate memory for image */
-    p_vout->i_bytes_per_line = p_vout->i_width * p_vout->i_bytes_per_pixel;
-    pb_data = (byte_t *) malloc( p_vout->i_bytes_per_line * p_vout->i_height );
-    if( !pb_data )                                                  /* error */
-    {
-        intf_ErrMsg("error: %s", strerror(ENOMEM));
-        return( 1 );
-    }
-
-    /* Optimize the quantum of a scanline regarding its size - the quantum is
-       a diviser of the number of bits between the start of two scanlines. */
-    if( !(( p_vout->i_bytes_per_line ) % 32) )
-    {
-        i_quantum = 32;
-    }
-    else
-    {
-        if( !(( p_vout->i_bytes_per_line ) % 16) )
-        {
-            i_quantum = 16;
-        }
-        else
-        {
-            i_quantum = 8;
-        }
-    }
-
-    /* Create XImage */
-    *pp_ximage = XCreateImage( p_vout->p_sys->p_display, p_vout->p_sys->p_visual,
-                               p_vout->i_screen_depth, ZPixmap, 0, pb_data,
-                               p_vout->i_width, p_vout->i_height, i_quantum, 0);
-    if(! *pp_ximage )                                               /* error */
-    {
-        intf_ErrMsg( "error: XCreateImage() failed" );
-        free( pb_data );
-        return( 1 );
-    }
-
-    return 0;
-}
-
-/*****************************************************************************
- * X11CreateShmImage: create an XImage using shared memory extension
- *****************************************************************************
- * Prepare an XImage for DisplayX11ShmImage function.
- * The order of the operations respects the recommandations of the mit-shm
- * document by J.Corbet and K.Packard. Most of the parameters were copied from
- * there.
+ * console events. It returns a non null value on error.
  *****************************************************************************/
-static int X11CreateShmImage( vout_thread_t *p_vout, XImage **pp_ximage,
-                              XShmSegmentInfo *p_shm_info)
+static int vout_Manage( vout_thread_t *p_vout )
 {
-    /* Create XImage */
-    *pp_ximage = XShmCreateImage( p_vout->p_sys->p_display, p_vout->p_sys->p_visual,
-                                  p_vout->i_screen_depth, ZPixmap, 0,
-                                  p_shm_info, p_vout->i_width, p_vout->i_height );
-    if(! *pp_ximage )                                               /* error */
-    {
-        intf_ErrMsg("error: XShmCreateImage() failed");
-        return( 1 );
-    }
-
-    /* Allocate shared memory segment - 0777 set the access permission
-     * rights (like umask), they are not yet supported by X servers */
-    p_shm_info->shmid = shmget( IPC_PRIVATE,
-                                (*pp_ximage)->bytes_per_line * (*pp_ximage)->height,
-                                IPC_CREAT | 0777);
-    if( p_shm_info->shmid < 0)                                      /* error */
-    {
-        intf_ErrMsg("error: can't allocate shared image data (%s)",
-                    strerror(errno));
-        XDestroyImage( *pp_ximage );
-        return( 1 );
-    }
-
-    /* Attach shared memory segment to process (read/write) */
-    p_shm_info->shmaddr = (*pp_ximage)->data = shmat(p_shm_info->shmid, 0, 0);
-    if(! p_shm_info->shmaddr )
-    {                                                               /* error */
-        intf_ErrMsg("error: can't attach shared memory (%s)",
-                    strerror(errno));
-        shmctl( p_shm_info->shmid, IPC_RMID, 0 );      /* free shared memory */
-        XDestroyImage( *pp_ximage );
-        return( 1 );
-    }
-
-    /* Mark the shm segment to be removed when there will be no more
-     * attachements, so it is automatic on process exit or after shmdt */
-    shmctl( p_shm_info->shmid, IPC_RMID, 0 );
-
-    /* Attach shared memory segment to X server (read only) */
-    p_shm_info->readOnly = True;
-    if( XShmAttach( p_vout->p_sys->p_display, p_shm_info ) == False )    /* error */
-    {
-        intf_ErrMsg("error: can't attach shared memory to X11 server");
-        shmdt( p_shm_info->shmaddr );     /* detach shared memory from process
-                                           * and automatic free                */
-        XDestroyImage( *pp_ximage );
-        return( 1 );
-    }
-
-    /* Send image to X server. This instruction is required, since having
-     * built a Shm XImage and not using it causes an error on XCloseDisplay */
-    XFlush( p_vout->p_sys->p_display );
     return( 0 );
 }
 
 /*****************************************************************************
- * X11DestroyImage: destroy an XImage
+ * vout_Display: displays previously rendered output
  *****************************************************************************
- * Destroy XImage AND associated data. If pointer is NULL, the image won't be
- * destroyed (see vout_ManageOutputMethod())
+ * This function send the currently rendered image to dummy image, waits until
+ * it is displayed and switch the two rendering buffers, preparing next frame.
  *****************************************************************************/
-static void X11DestroyImage( XImage *p_ximage )
+static void vout_Display( vout_thread_t *p_vout )
 {
-    if( p_ximage != NULL )
-    {
-        XDestroyImage( p_ximage );                     /* no free() required */
-    }
-}
-
-/*****************************************************************************
- * X11DestroyShmImage
- *****************************************************************************
- * Destroy XImage AND associated data. Detach shared memory segment from
- * server and process, then free it. If pointer is NULL, the image won't be
- * destroyed (see vout_ManageOutputMethod())
- *****************************************************************************/
-static void X11DestroyShmImage( vout_thread_t *p_vout, XImage *p_ximage,
-                                XShmSegmentInfo *p_shm_info )
-{
-    /* If pointer is NULL, do nothing */
-    if( p_ximage == NULL )
-    {
-        return;
-    }
-
-    XShmDetach( p_vout->p_sys->p_display, p_shm_info );     /* detach from server */
-    XDestroyImage( p_ximage );
-    if( shmdt( p_shm_info->shmaddr ) )  /* detach shared memory from process */
-    {                                   /* also automatic freeing...         */
-        intf_ErrMsg("error: can't detach shared memory (%s)",
-                    strerror(errno));
-    }
+    ;
 }
 
index 7d23e8d68fe05a88ebbff2d5edfcb8ff45db2b1b..fb94e04f059ddd992b5ebe049522f83e637acf7c 100644 (file)
@@ -1,10 +1,9 @@
 /*****************************************************************************
  * vout_mga.h: MGA video output display method headers
  *****************************************************************************
- * Copyright (C) 1999 Aaron Holtzman
- * Copyright (C) 2000 VideoLAN
+ * Copyright (C) 1999 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
+ * Copyright (C) 2000, 2001 VideoLAN
  *
- * Authors:
  *
  * 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
@@ -49,52 +48,3 @@ typedef struct mga_vid_config_s
 
 #endif
 
-/*****************************************************************************
- * vout_sys_t: video output X11 method descriptor
- *****************************************************************************
- * This structure is part of the video output thread descriptor.
- * It describes the X11 specific properties of an output thread. X11 video
- * output is performed through regular resizable windows. Windows can be
- * dynamically resized to adapt to the size of the streams.
- *****************************************************************************/
-typedef struct vout_sys_s
-{
-    /* User settings */
-    boolean_t           b_shm;               /* shared memory extension flag */
-
-    /* Internal settings and properties */
-    Display *           p_display;                        /* display pointer */
-    Visual *            p_visual;                          /* visual pointer */
-    int                 i_screen;                           /* screen number */
-    Window              root_window;                          /* root window */
-    Window              window;                   /* window instance handler */
-    GC                  gc;              /* graphic context instance handler */
-    Colormap            colormap;               /* colormap used (8bpp only) */
-
-    /* Display buffers and shared memory information */
-    XImage *            p_ximage[2];                       /* XImage pointer */
-    XShmSegmentInfo     shm_info[2];       /* shared memory zone information */
-
-    /* MGA specific variables */
-    int                 i_fd;
-    int                 i_size;
-    mga_vid_config_t *  p_mga;
-    byte_t *            p_mga_vid_base;
-    boolean_t           b_g400;
-
-} vout_sys_t;
-
-/*****************************************************************************
- * Local prototypes
- *****************************************************************************/
-static int  X11OpenDisplay      ( vout_thread_t *p_vout, char *psz_display, Window root_window );
-static void X11CloseDisplay     ( vout_thread_t *p_vout );
-static int  X11CreateWindow     ( vout_thread_t *p_vout );
-static void X11DestroyWindow    ( vout_thread_t *p_vout );
-static int  X11CreateImage      ( vout_thread_t *p_vout, XImage **pp_ximage );
-static void X11DestroyImage     ( XImage *p_ximage );
-static int  X11CreateShmImage   ( vout_thread_t *p_vout, XImage **pp_ximage,
-                                  XShmSegmentInfo *p_shm_info );
-static void X11DestroyShmImage  ( vout_thread_t *p_vout, XImage *p_ximage,
-                                  XShmSegmentInfo *p_shm_info );
-
index c922bb7fbcb376e3cf381a992a285cf6c101905f..1edf768fe0f861434bb8459e72497b6f19f0f079 100644 (file)
@@ -21,6 +21,7 @@
  *****************************************************************************/
 
 #define MODULE_NAME motion
+#include "modules_inner.h"
 
 /*****************************************************************************
  * Preamble
 #include "video.h"
 
 #include "modules.h"
-#include "modules_inner.h"
 
 /*****************************************************************************
  * Local and extern prototypes.
  *****************************************************************************/
-extern void motion_getfunctions( function_list_t * p_function_list );
+void motion_getfunctions( function_list_t * p_function_list );
 
 /*****************************************************************************
  * Build configuration tree.
@@ -61,7 +61,7 @@ MODULE_CONFIG_END
  * be unloaded later to save memory, and we want to be able to access this
  * data even after the module has been unloaded.
  *****************************************************************************/
-int InitModule( module_t * p_module )
+MODULE_INIT
 {
     p_module->psz_name = MODULE_STRING;
     p_module->psz_longname = "motion compensation module";
@@ -81,7 +81,7 @@ int InitModule( module_t * p_module )
  * be set to 0 and calls to NeedModule() be made to increment it. To unload
  * the module, one has to wait until i_usage == 0 and call DeactivateModule().
  *****************************************************************************/
-int ActivateModule( module_t * p_module )
+MODULE_ACTIVATE
 {
     p_module->p_functions = malloc( sizeof( module_functions_t ) );
     if( p_module->p_functions == NULL )
@@ -103,7 +103,7 @@ int ActivateModule( module_t * p_module )
  * returns, i_usage can be set to -1 and the module unloaded. Be careful to
  * lock usage_lock during the whole process.
  *****************************************************************************/
-int DeactivateModule( module_t * p_module )
+MODULE_DEACTIVATE
 {
     free( p_module->p_functions );
 
index f50151ff132c9396c8085af19dc8dd13a92df31a..b6f8a9bd40383a81904b1a8c63f9df7eed8814a8 100644 (file)
@@ -21,6 +21,7 @@
  *****************************************************************************/
 
 #define MODULE_NAME motionmmx
+#include "modules_inner.h"
 
 /*****************************************************************************
  * Preamble
 #include "video.h"
 
 #include "modules.h"
-#include "modules_inner.h"
 
 /*****************************************************************************
  * Local and extern prototypes.
  *****************************************************************************/
-extern void motion_getfunctions( function_list_t * p_function_list );
+void motion_getfunctions( function_list_t * p_function_list );
 
 /*****************************************************************************
  * Build configuration tree.
@@ -61,7 +61,7 @@ MODULE_CONFIG_END
  * be unloaded later to save memory, and we want to be able to access this
  * data even after the module has been unloaded.
  *****************************************************************************/
-int InitModule( module_t * p_module )
+MODULE_INIT
 {
     p_module->psz_name = MODULE_STRING;
     p_module->psz_longname = "MMX motion compensation module";
@@ -81,7 +81,7 @@ int InitModule( module_t * p_module )
  * be set to 0 and calls to NeedModule() be made to increment it. To unload
  * the module, one has to wait until i_usage == 0 and call DeactivateModule().
  *****************************************************************************/
-int ActivateModule( module_t * p_module )
+MODULE_ACTIVATE
 {
     p_module->p_functions = malloc( sizeof( module_functions_t ) );
     if( p_module->p_functions == NULL )
@@ -103,7 +103,7 @@ int ActivateModule( module_t * p_module )
  * returns, i_usage can be set to -1 and the module unloaded. Be careful to
  * lock usage_lock during the whole process.
  *****************************************************************************/
-int DeactivateModule( module_t * p_module )
+MODULE_DEACTIVATE
 {
     free( p_module->p_functions );
 
index 583b7aa8c30a2c846a84e0baa68a822af268056f..93333a75b605944fae7c42be3dda0ecaa6e562f0 100644 (file)
@@ -21,6 +21,7 @@
  *****************************************************************************/
 
 #define MODULE_NAME motionmmxext
+#include "modules_inner.h"
 
 /*****************************************************************************
  * Preamble
 #include "video.h"
 
 #include "modules.h"
-#include "modules_inner.h"
 
 /*****************************************************************************
  * Local and extern prototypes.
  *****************************************************************************/
-extern void motion_getfunctions( function_list_t * p_function_list );
+void motion_getfunctions( function_list_t * p_function_list );
 
 /*****************************************************************************
  * Build configuration tree.
@@ -61,7 +61,7 @@ MODULE_CONFIG_END
  * be unloaded later to save memory, and we want to be able to access this
  * data even after the module has been unloaded.
  *****************************************************************************/
-int InitModule( module_t * p_module )
+MODULE_INIT
 {
     p_module->psz_name = MODULE_STRING;
     p_module->psz_longname = "MMX EXT motion compensation module";
@@ -81,7 +81,7 @@ int InitModule( module_t * p_module )
  * be set to 0 and calls to NeedModule() be made to increment it. To unload
  * the module, one has to wait until i_usage == 0 and call DeactivateModule().
  *****************************************************************************/
-int ActivateModule( module_t * p_module )
+MODULE_ACTIVATE
 {
     p_module->p_functions = malloc( sizeof( module_functions_t ) );
     if( p_module->p_functions == NULL )
@@ -103,7 +103,7 @@ int ActivateModule( module_t * p_module )
  * returns, i_usage can be set to -1 and the module unloaded. Be careful to
  * lock usage_lock during the whole process.
  *****************************************************************************/
-int DeactivateModule( module_t * p_module )
+MODULE_DEACTIVATE
 {
     free( p_module->p_functions );
 
index ba3dab37ce31b2129846fbf7ed209e9cec30fc54..970d58f409f0ce6961b7deaaf060bb45b497d9e7 100644 (file)
@@ -2,7 +2,7 @@
  * input_ps.c: PS demux and packet management
  *****************************************************************************
  * Copyright (C) 1998, 1999, 2000 VideoLAN
- * $Id: input_ps.c,v 1.7 2001/02/20 02:53:13 stef Exp $
+ * $Id: input_ps.c,v 1.8 2001/02/20 07:49:13 sam Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -21,6 +21,9 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
+#define MODULE_NAME ps
+#include "modules_inner.h"
+
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
@@ -76,7 +79,7 @@ static void DeletePES   ( void *, struct pes_packet_s * );
  * Functions exported as capabilities. They are declared as static so that
  * we don't pollute the namespace too much.
  *****************************************************************************/
-void input_getfunctions( function_list_t * p_function_list )
+void _M( input_getfunctions )( function_list_t * p_function_list )
 {
 #define input p_function_list->functions.input
     p_function_list->pf_probe = PSProbe;
index 4fd9a5e4cf6cce326ebbcf059de87d14127c78ab..d664906d08155c2f44910fb1a2ff2e98dc7b518b 100644 (file)
@@ -2,7 +2,7 @@
  * input_ts.c: TS demux and netlist management
  *****************************************************************************
  * Copyright (C) 1998, 1999, 2000 VideoLAN
- * $Id: input_ts.c,v 1.4 2001/02/20 02:53:13 stef Exp $
+ * $Id: input_ts.c,v 1.5 2001/02/20 07:49:13 sam Exp $
  *
  * Authors: 
  *
@@ -21,6 +21,9 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
+#define MODULE_NAME ts
+#include "modules_inner.h"
+
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
@@ -68,7 +71,7 @@ static void TSEnd       ( struct input_thread_s * );
  * Functions exported as capabilities. They are declared as static so that
  * we don't pollute the namespace too much.
  *****************************************************************************/
-void input_getfunctions( function_list_t * p_function_list )
+void _M( input_getfunctions )( function_list_t * p_function_list )
 {
 #define input p_function_list->functions.input
     p_function_list->pf_probe = TSProbe;
index 4b83f0759c5995dcd6e538693625ac5f30d4e972..77270f493a45482cafecf8176560f9b591f60435 100644 (file)
@@ -21,6 +21,7 @@
  *****************************************************************************/
 
 #define MODULE_NAME ps
+#include "modules_inner.h"
 
 /*****************************************************************************
  * Preamble
@@ -36,7 +37,6 @@
 #include "mtime.h"
 
 #include "modules.h"
-#include "modules_inner.h"
 
 /*****************************************************************************
  * Build configuration tree.
@@ -49,7 +49,7 @@ MODULE_CONFIG_END
 /*****************************************************************************
  * Capabilities defined in the other files.
  *****************************************************************************/
-extern void input_getfunctions( function_list_t * p_function_list );
+void _M( input_getfunctions )( function_list_t * p_function_list );
 
 /*****************************************************************************
  * InitModule: get the module structure and configuration.
@@ -59,7 +59,7 @@ extern void input_getfunctions( function_list_t * p_function_list );
  * be unloaded later to save memory, and we want to be able to access this
  * data even after the module has been unloaded.
  *****************************************************************************/
-int InitModule( module_t * p_module )
+MODULE_INIT
 {
     p_module->psz_name = MODULE_STRING;
     p_module->psz_longname = "ISO 13818-1 MPEG Program Stream input module";
@@ -79,7 +79,7 @@ int InitModule( module_t * p_module )
  * be set to 0 and calls to NeedModule() be made to increment it. To unload
  * the module, one has to wait until i_usage == 0 and call DeactivateModule().
  *****************************************************************************/
-int ActivateModule( module_t * p_module )
+MODULE_ACTIVATE
 {
     p_module->p_functions = malloc( sizeof( module_functions_t ) );
     if( p_module->p_functions == NULL )
@@ -87,7 +87,7 @@ int ActivateModule( module_t * p_module )
         return( -1 );
     }
 
-    input_getfunctions( &p_module->p_functions->input );
+    _M( input_getfunctions )( &p_module->p_functions->input );
 
     p_module->p_config = p_config;
 
@@ -101,7 +101,7 @@ int ActivateModule( module_t * p_module )
  * returns, i_usage can be set to -1 and the module unloaded. Be careful to
  * lock usage_lock during the whole process.
  *****************************************************************************/
-int DeactivateModule( module_t * p_module )
+MODULE_DEACTIVATE
 {
     free( p_module->p_functions );
 
index baa12a21e637beff0b75066a7b8495db0c08bf50..351dcee6e7f192e5e215cf92e80dbe9b9358da83 100644 (file)
@@ -21,6 +21,7 @@
  *****************************************************************************/
 
 #define MODULE_NAME ts
+#include "modules_inner.h"
 
 /*****************************************************************************
  * Preamble
@@ -36,7 +37,6 @@
 #include "mtime.h"
 
 #include "modules.h"
-#include "modules_inner.h"
 
 /*****************************************************************************
  * Build configuration tree.
@@ -49,7 +49,7 @@ MODULE_CONFIG_END
 /*****************************************************************************
  * Capabilities defined in the other files.
  *****************************************************************************/
-extern void input_getfunctions( function_list_t * p_function_list );
+void _M( input_getfunctions )( function_list_t * p_function_list );
 
 /*****************************************************************************
  * InitModule: get the module structure and configuration.
@@ -59,7 +59,7 @@ extern void input_getfunctions( function_list_t * p_function_list );
  * be unloaded later to save memory, and we want to be able to access this
  * data even after the module has been unloaded.
  *****************************************************************************/
-int InitModule( module_t * p_module )
+MODULE_INIT
 {
     p_module->psz_name = MODULE_STRING;
     p_module->psz_longname = "ISO 13818-1 MPEG Transport Stream input module";
@@ -79,7 +79,7 @@ int InitModule( module_t * p_module )
  * be set to 0 and calls to NeedModule() be made to increment it. To unload
  * the module, one has to wait until i_usage == 0 and call DeactivateModule().
  *****************************************************************************/
-int ActivateModule( module_t * p_module )
+MODULE_ACTIVATE
 {
     p_module->p_functions = malloc( sizeof( module_functions_t ) );
     if( p_module->p_functions == NULL )
@@ -87,7 +87,7 @@ int ActivateModule( module_t * p_module )
         return( -1 );
     }
 
-    input_getfunctions( &p_module->p_functions->input );
+    _M( input_getfunctions )( &p_module->p_functions->input );
 
     p_module->p_config = p_config;
 
@@ -101,7 +101,7 @@ int ActivateModule( module_t * p_module )
  * returns, i_usage can be set to -1 and the module unloaded. Be careful to
  * lock usage_lock during the whole process.
  *****************************************************************************/
-int DeactivateModule( module_t * p_module )
+MODULE_DEACTIVATE
 {
     free( p_module->p_functions );
 
index ec7c820ab7ff690ae7365e07c650be6ddcee5bf1..05190efc9a26d6633bc2a9cc0555589f453e92a0 100644 (file)
@@ -65,7 +65,7 @@ MODULE_CONFIG_END
  * be unloaded later to save memory, and we want to be able to access this
  * data even after the module has been unloaded.
  *****************************************************************************/
-int InitModule( module_t * p_module )
+MODULE_INIT
 {
     p_module->psz_name = MODULE_STRING;
     p_module->psz_longname = "the Null module that does nothing";
@@ -84,7 +84,7 @@ int InitModule( module_t * p_module )
  * be set to 0 and calls to NeedModule() be made to increment it. To unload
  * the module, one has to wait until i_usage == 0 and call DeactivateModule().
  *****************************************************************************/
-int ActivateModule( module_t * p_module )
+MODULE_ACTIVATE
 {
     /* Since the Null module can't do anything, there is no need to
      * fill the p_functions structure. */
@@ -101,7 +101,7 @@ int ActivateModule( module_t * p_module )
  * returns, i_usage can be set to -1 and the module unloaded. Be careful to
  * lock usage_lock during the whole process.
  *****************************************************************************/
-int DeactivateModule( module_t * p_module )
+MODULE_DEACTIVATE
 {
     /* We didn't allocate p_functions - so we don't have to free it */
     return( 0 );
index d16f59e4ff404e2fa46cf26a34dd2a59036135e3..6295f45b2f294cae1ebcc30ed36bad4972c41af6 100644 (file)
@@ -22,6 +22,9 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
+#define MODULE_NAME sdl
+#include "modules_inner.h"
+
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
@@ -86,7 +89,7 @@ static void    aout_SDLCallback ( void *userdata, Uint8 *stream, int len );
  * Functions exported as capabilities. They are declared as static so that
  * we don't pollute the namespace too much.
  *****************************************************************************/
-void aout_getfunctions( function_list_t * p_function_list )
+void _M( aout_getfunctions )( function_list_t * p_function_list )
 {
     p_function_list->pf_probe = aout_Probe;
     p_function_list->functions.aout.pf_open = aout_Open;
index 42c69988a0332905d0f7584cde04a44840cf7f4c..d96f5b56ec0c4721d854425c38d78df396da00ee 100644 (file)
@@ -23,6 +23,7 @@
  *****************************************************************************/
 
 #define MODULE_NAME sdl
+#include "modules_inner.h"
 
 /*****************************************************************************
  * Preamble
@@ -42,7 +43,6 @@
 #include "video_output.h"
 
 #include "modules.h"
-#include "modules_inner.h"
 
 /*****************************************************************************
  * Building configuration tree
@@ -55,8 +55,8 @@ MODULE_CONFIG_END
 /*****************************************************************************
  * Capabilities defined in the other files.
  ******************************************************************************/
-extern void aout_getfunctions( function_list_t * p_function_list );
-extern void vout_getfunctions( function_list_t * p_function_list );
+void _M( aout_getfunctions )( function_list_t * p_function_list );
+void _M( vout_getfunctions )( function_list_t * p_function_list );
 
 /*****************************************************************************
  * InitModule: get the module structure and configuration.
@@ -66,7 +66,7 @@ extern void vout_getfunctions( function_list_t * p_function_list );
  * be unloaded later to save memory, and we want to be able to access this
  * data even after the module has been unloaded.
  *****************************************************************************/
-int InitModule( module_t * p_module )
+MODULE_INIT
 {
     p_module->psz_name = MODULE_STRING;
     p_module->psz_longname = "Simple DirectMedia Layer module";
@@ -87,7 +87,7 @@ int InitModule( module_t * p_module )
  * be set to 0 and calls to NeedModule() be made to increment it. To unload
  * the module, one has to wait until i_usage == 0 and call DeactivateModule().
  *****************************************************************************/
-int ActivateModule( module_t * p_module )
+MODULE_ACTIVATE
 {
     p_module->p_functions = malloc( sizeof( module_functions_t ) );
     if( p_module->p_functions == NULL )
@@ -95,8 +95,8 @@ int ActivateModule( module_t * p_module )
         return( -1 );
     }
 
-    aout_getfunctions( &p_module->p_functions->aout );
-    vout_getfunctions( &p_module->p_functions->vout );
+    _M( aout_getfunctions )( &p_module->p_functions->aout );
+    _M( vout_getfunctions )( &p_module->p_functions->vout );
 
     p_module->p_config = p_config;
 
@@ -110,7 +110,7 @@ int ActivateModule( module_t * p_module )
  * returns, i_usage can be set to -1 and the module unloaded. Be careful to
  * lock usage_lock during the whole process.
  *****************************************************************************/
-int DeactivateModule( module_t * p_module )
+MODULE_DEACTIVATE
 {
     free( p_module->p_functions );
 
index a8bac09361a2a536528cf89e8ae89e9a77c7da0c..73a8a24137383c4201a7810f59a8f287ca9177c9 100644 (file)
@@ -22,6 +22,9 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
+#define MODULE_NAME sdl
+#include "modules_inner.h"
+
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
@@ -100,7 +103,7 @@ static void SDLCloseDisplay     ( vout_thread_t *p_vout );
  * Functions exported as capabilities. They are declared as static so that
  * we don't pollute the namespace too much.
  *****************************************************************************/
-void vout_getfunctions( function_list_t * p_function_list )
+void _M( vout_getfunctions )( function_list_t * p_function_list )
 {
     p_function_list->pf_probe = vout_Probe;
     p_function_list->functions.vout.pf_create     = vout_Create;
index e243e833088b7e19262158cbc1fe96d1d7957109..281e6b23f2ecd60f64458e1224d231cdd9af87bd 100644 (file)
@@ -20,6 +20,9 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
+#define MODULE_NAME ncurses
+#include "modules_inner.h"
+
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
@@ -69,7 +72,7 @@ static void intf_Run       ( intf_thread_t *p_intf );
  * Functions exported as capabilities. They are declared as static so that
  * we don't pollute the namespace too much.
  *****************************************************************************/
-void intf_getfunctions( function_list_t * p_function_list )
+void _M( intf_getfunctions )( function_list_t * p_function_list )
 {
     p_function_list->pf_probe = intf_Probe;
     p_function_list->functions.intf.pf_open  = intf_Open;
index 0ae3512e75a9193c113e4926069d8e30dd03d9d3..20ad92672d93c019cca161ba08297d66001933d1 100644 (file)
@@ -21,6 +21,7 @@
  *****************************************************************************/
 
 #define MODULE_NAME ncurses
+#include "modules_inner.h"
 
 /*****************************************************************************
  * Preamble
@@ -35,7 +36,6 @@
 #include "mtime.h"
 
 #include "modules.h"
-#include "modules_inner.h"
 
 /*****************************************************************************
  * Building configuration tree
@@ -48,7 +48,7 @@ MODULE_CONFIG_END
 /*****************************************************************************
  * Capabilities defined in the other files.
  ******************************************************************************/
-extern void intf_getfunctions( function_list_t * p_function_list );
+void _M( intf_getfunctions )( function_list_t * p_function_list );
 
 /*****************************************************************************
  * InitModule: get the module structure and configuration.
@@ -58,7 +58,7 @@ extern void intf_getfunctions( function_list_t * p_function_list );
  * be unloaded later to save memory, and we want to be able to access this
  * data even after the module has been unloaded.
  *****************************************************************************/
-int InitModule( module_t * p_module )
+MODULE_INIT
 {
     p_module->psz_name = MODULE_STRING;
     p_module->psz_longname = "ncurses interface module";
@@ -78,7 +78,7 @@ int InitModule( module_t * p_module )
  * be set to 0 and calls to NeedModule() be made to increment it. To unload
  * the module, one has to wait until i_usage == 0 and call DeactivateModule().
  *****************************************************************************/
-int ActivateModule( module_t * p_module )
+MODULE_ACTIVATE
 {
     p_module->p_functions = malloc( sizeof( module_functions_t ) );
     if( p_module->p_functions == NULL )
@@ -86,7 +86,7 @@ int ActivateModule( module_t * p_module )
         return( -1 );
     }
 
-    intf_getfunctions( &p_module->p_functions->intf );
+    _M( intf_getfunctions )( &p_module->p_functions->intf );
 
     p_module->p_config = p_config;
 
@@ -100,7 +100,7 @@ int ActivateModule( module_t * p_module )
  * returns, i_usage can be set to -1 and the module unloaded. Be careful to
  * lock usage_lock during the whole process.
  *****************************************************************************/
-int DeactivateModule( module_t * p_module )
+MODULE_DEACTIVATE
 {
     free( p_module->p_functions );
 
index f60cf14685900c46ce8ae5a4d49628452d07a4b2..0aa7b225302279d1152fade01060652ced9c4685 100644 (file)
@@ -2,7 +2,7 @@
  * vout_x11.c: X11 video output display method
  *****************************************************************************
  * Copyright (C) 1998, 1999, 2000 VideoLAN
- * $Id: vout_x11.c,v 1.14 2001/02/17 08:48:56 sam Exp $
+ * $Id: vout_x11.c,v 1.15 2001/02/20 07:49:13 sam Exp $
  *
  * Authors: Vincent Seguin <seguin@via.ecp.fr>
  *          Samuel Hocevar <sam@zoy.org>
@@ -22,6 +22,9 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
+#define MODULE_NAME x11
+#include "modules_inner.h"
+
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
@@ -132,7 +135,7 @@ static void X11DisableScreenSaver       ( vout_thread_t *p_vout );
  * Functions exported as capabilities. They are declared as static so that
  * we don't pollute the namespace too much.
  *****************************************************************************/
-void vout_getfunctions( function_list_t * p_function_list )
+void _M( vout_getfunctions )( function_list_t * p_function_list )
 {
     p_function_list->pf_probe = vout_Probe;
     p_function_list->functions.vout.pf_create     = vout_Create;
index a726c071676478d915680a0592e5b67bdbab09db..49197bd90435877f788bcb65cba7779cfa6860a8 100644 (file)
@@ -21,6 +21,7 @@
  *****************************************************************************/
 
 #define MODULE_NAME x11
+#include "modules_inner.h"
 
 /*****************************************************************************
  * Preamble
@@ -38,7 +39,6 @@
 #include "video_output.h"
 
 #include "modules.h"
-#include "modules_inner.h"
 
 /*****************************************************************************
  * Building configuration tree
@@ -51,7 +51,7 @@ MODULE_CONFIG_END
 /*****************************************************************************
  * Capabilities defined in the other files.
  ******************************************************************************/
-extern void vout_getfunctions( function_list_t * p_function_list );
+void _M( vout_getfunctions )( function_list_t * p_function_list );
 
 /*****************************************************************************
  * InitModule: get the module structure and configuration.
@@ -61,7 +61,7 @@ extern void vout_getfunctions( function_list_t * p_function_list );
  * be unloaded later to save memory, and we want to be able to access this
  * data even after the module has been unloaded.
  *****************************************************************************/
-int InitModule( module_t * p_module )
+MODULE_INIT
 {
     p_module->psz_name = MODULE_STRING;
     p_module->psz_longname = "X11 module";
@@ -81,7 +81,7 @@ int InitModule( module_t * p_module )
  * be set to 0 and calls to NeedModule() be made to increment it. To unload
  * the module, one has to wait until i_usage == 0 and call DeactivateModule().
  *****************************************************************************/
-int ActivateModule( module_t * p_module )
+MODULE_ACTIVATE
 {
     p_module->p_functions = malloc( sizeof( module_functions_t ) );
     if( p_module->p_functions == NULL )
@@ -89,7 +89,7 @@ int ActivateModule( module_t * p_module )
         return( -1 );
     }
 
-    vout_getfunctions( &p_module->p_functions->vout );
+    _M( vout_getfunctions )( &p_module->p_functions->vout );
 
     p_module->p_config = p_config;
 
@@ -103,7 +103,7 @@ int ActivateModule( module_t * p_module )
  * returns, i_usage can be set to -1 and the module unloaded. Be careful to
  * lock usage_lock during the whole process.
  *****************************************************************************/
-int DeactivateModule( module_t * p_module )
+MODULE_DEACTIVATE
 {
     free( p_module->p_functions );
 
index cdf8086b23c9250360833c0f728f2b42e3859f2a..d87a68f71199d6570ee6bb79f3b1b20083a4f186 100644 (file)
@@ -24,6 +24,9 @@
  * Boston, MA 02111-1307, USA.
  *****************************************************************************/
 
+#define MODULE_NAME yuv
+#include "modules_inner.h"
+
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
@@ -60,7 +63,7 @@ static void    SetYUV         ( vout_thread_t *p_vout );
  * Functions exported as capabilities. They are declared as static so that
  * we don't pollute the namespace too much.
  *****************************************************************************/
-void yuv_getfunctions( function_list_t * p_function_list )
+void _M( yuv_getfunctions )( function_list_t * p_function_list )
 {
     p_function_list->pf_probe = yuv_Probe;
     p_function_list->functions.yuv.pf_init = yuv_Init;
index 6beae71449fd416dce6e1be060232564846feaad..d34410f3f66b191667e7bdd48d96008cb5f7fb67 100644 (file)
@@ -22,6 +22,9 @@
  * Boston, MA 02111-1307, USA.
  *****************************************************************************/
 
+#define MODULE_NAME yuvmmx
+#include "modules_inner.h"
+
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
@@ -58,7 +61,7 @@ static void    SetYUV         ( vout_thread_t *p_vout );
  * Functions exported as capabilities. They are declared as static so that
  * we don't pollute the namespace too much.
  *****************************************************************************/
-void yuv_getfunctions( function_list_t * p_function_list )
+void _M( yuv_getfunctions )( function_list_t * p_function_list )
 {
     p_function_list->pf_probe = yuv_Probe;
     p_function_list->functions.yuv.pf_init = yuv_Init;
index 772665ea44cc2bd779844d1e0db9ba9020d22ab6..c714afe8b26456d63611969ae5aa4a6fd13bee78 100644 (file)
@@ -21,6 +21,7 @@
  *****************************************************************************/
 
 #define MODULE_NAME yuv
+#include "modules_inner.h"
 
 /*****************************************************************************
  * Preamble
 #include "video_output.h"
 
 #include "modules.h"
-#include "modules_inner.h"
 
 /*****************************************************************************
  * Local and extern prototypes.
  *****************************************************************************/
-extern void yuv_getfunctions( function_list_t * p_function_list );
+void _M( yuv_getfunctions )( function_list_t * p_function_list );
 
 /*****************************************************************************
  * Build configuration tree.
@@ -61,7 +61,7 @@ MODULE_CONFIG_END
  * be unloaded later to save memory, and we want to be able to access this
  * data even after the module has been unloaded.
  *****************************************************************************/
-int InitModule( module_t * p_module )
+MODULE_INIT
 {
     p_module->psz_name = MODULE_STRING;
     p_module->psz_longname = "YUV transformations module";
@@ -81,7 +81,7 @@ int InitModule( module_t * p_module )
  * be set to 0 and calls to NeedModule() be made to increment it. To unload
  * the module, one has to wait until i_usage == 0 and call DeactivateModule().
  *****************************************************************************/
-int ActivateModule( module_t * p_module )
+MODULE_ACTIVATE
 {
     p_module->p_functions = malloc( sizeof( module_functions_t ) );
     if( p_module->p_functions == NULL )
@@ -89,7 +89,7 @@ int ActivateModule( module_t * p_module )
         return( -1 );
     }
 
-    yuv_getfunctions( &p_module->p_functions->yuv );
+    _M( yuv_getfunctions )( &p_module->p_functions->yuv );
 
     p_module->p_config = p_config;
 
@@ -103,7 +103,7 @@ int ActivateModule( module_t * p_module )
  * returns, i_usage can be set to -1 and the module unloaded. Be careful to
  * lock usage_lock during the whole process.
  *****************************************************************************/
-int DeactivateModule( module_t * p_module )
+MODULE_DEACTIVATE
 {
     free( p_module->p_functions );
 
index b042e1987ff0c9ee004df533f36b849def2b5d55..c7e328a12b9abc57a70d17eeca0dda0374e71f8c 100644 (file)
@@ -21,6 +21,7 @@
  *****************************************************************************/
 
 #define MODULE_NAME yuvmmx
+#include "modules_inner.h"
 
 /*****************************************************************************
  * Preamble
 #include "video_output.h"
 
 #include "modules.h"
-#include "modules_inner.h"
 
 /*****************************************************************************
  * Local and extern prototypes.
  *****************************************************************************/
-extern void yuv_getfunctions( function_list_t * p_function_list );
+void _M( yuv_getfunctions )( function_list_t * p_function_list );
 
 /*****************************************************************************
  * Build configuration tree.
@@ -61,7 +61,7 @@ MODULE_CONFIG_END
  * be unloaded later to save memory, and we want to be able to access this
  * data even after the module has been unloaded.
  *****************************************************************************/
-int InitModule( module_t * p_module )
+MODULE_INIT
 {
     p_module->psz_name = MODULE_STRING;
     p_module->psz_longname = "MMX YUV transformations module";
@@ -81,7 +81,7 @@ int InitModule( module_t * p_module )
  * be set to 0 and calls to NeedModule() be made to increment it. To unload
  * the module, one has to wait until i_usage == 0 and call DeactivateModule().
  *****************************************************************************/
-int ActivateModule( module_t * p_module )
+MODULE_ACTIVATE
 {
     p_module->p_functions = malloc( sizeof( module_functions_t ) );
     if( p_module->p_functions == NULL )
@@ -89,7 +89,7 @@ int ActivateModule( module_t * p_module )
         return( -1 );
     }
 
-    yuv_getfunctions( &p_module->p_functions->yuv );
+    _M( yuv_getfunctions )( &p_module->p_functions->yuv );
 
     p_module->p_config = p_config;
 
@@ -103,7 +103,7 @@ int ActivateModule( module_t * p_module )
  * returns, i_usage can be set to -1 and the module unloaded. Be careful to
  * lock usage_lock during the whole process.
  *****************************************************************************/
-int DeactivateModule( module_t * p_module )
+MODULE_DEACTIVATE
 {
     free( p_module->p_functions );
 
index 64e454b8d19e02d51cc1b27c9ed3cb04a212265d..68c3b6301bd4f9d43bc8f58b6e7cb8ed2e404491 100644 (file)
@@ -5,7 +5,7 @@
  *****************************************************************************
  * Copyright (C) 1998, 1999, 2000 VideoLAN
  *
- * Authors:
+ * Authors: Vincent Seguin <seguin@via.ecp.fr>
  *
  * 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
@@ -392,7 +392,6 @@ static void QueueMsg( intf_msg_t *p_msg, int i_type, char *psz_format, va_list a
     vasprintf( &psz_str, psz_format, ap );
 #else
     psz_str = (char*) malloc( strlen(psz_format) + INTF_MAX_MSG_SIZE );
-    vsprintf( psz_str, psz_format, ap );
 #endif
     if( psz_str == NULL )
     {
@@ -402,6 +401,10 @@ static void QueueMsg( intf_msg_t *p_msg, int i_type, char *psz_format, va_list a
         fprintf(stderr, "\n" );
         exit( errno );
     }
+#ifdef HAVE_VASPRINTF
+#else
+    vsprintf( psz_str, psz_format, ap );
+#endif
 
 #ifdef INTF_MSG_QUEUE /*...................................... queue mode ...*/
     vlc_mutex_lock( &p_msg->lock );                              /* get lock */
@@ -421,7 +424,7 @@ static void QueueMsg( intf_msg_t *p_msg, int i_type, char *psz_format, va_list a
     p_msg_item->i_type =     i_type;
     p_msg_item->psz_msg =    psz_str;
 #ifdef DEBUG    
-    p_msg_item->date =         mdate();
+    p_msg_item->date =       mdate();
 #endif
 
 #ifdef INTF_MSG_QUEUE /*......................................... queue mode */
index 94b67231c775c73778195e08bc26bac2d04d5fe5..307ea544345f3fb8e7271232c8019a69f06edc9a 100644 (file)
@@ -87,13 +87,15 @@ module_bank_t * module_CreateBank( void )
  *****************************************************************************/
 void module_InitBank( module_bank_t * p_bank )
 {
-    static char * path[] = { ".", "lib", PLUGIN_PATH, NULL } ;
+    static char * path[] = { ".", "lib", PLUGIN_PATH, NULL };
 
     char **         ppsz_path = path;
+    char *          psz_fullpath;
     char *          psz_file;
 #ifdef SYS_BEOS
     char *          psz_vlcpath = beos_GetProgramPath();
     int             i_vlclen = strlen( psz_vlcpath );
+    boolean_t       b_notinroot;
 #endif
     DIR *           dir;
     struct dirent * file;
@@ -105,11 +107,35 @@ void module_InitBank( module_bank_t * p_bank )
 
     for( ; *ppsz_path != NULL ; ppsz_path++ )
     {
-        if( (dir = opendir( *ppsz_path )) )
+        /* Store strlen(*ppsz_path) for later use. */
+        int i_dirlen = strlen( *ppsz_path );
+
+#ifdef SYS_BEOS
+        b_notinroot = 0;
+        /* 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;
+
+            psz_fullpath = malloc( i_dirlen );
+            if( psz_fullpath == NULL )
+            {
+                continue;
+            }
+            sprintf( psz_fullpath, "%s/%s", psz_vlcpath, *ppsz_path );
+        }
+        else
+#endif
         {
-            /* Store strlen(*ppsz_path) for later use. */
-            int i_dirlen = strlen( *ppsz_path );
+            psz_fullpath = *ppsz_path;
+        }
 
+        intf_WarnMsgImm( 2, "module: browsing %s", psz_fullpath );
+
+        if( (dir = opendir( psz_fullpath )) )
+        {
             /* Parse the directory and try to load all files it contains. */
             while( (file = readdir( dir )) )
             {
@@ -119,30 +145,13 @@ void module_InitBank( module_bank_t * p_bank )
                 if( i_filelen > 3
                         && !strncmp( file->d_name + i_filelen - 3, ".so", 3 ) )
                 {
-#ifdef SYS_BEOS
-                    /* Under BeOS, we need to add beos_GetProgramPath() to
-                     * access files under the current directory */
-                    if( strncmp( file->d_name, "/", 1 ) )
+                    psz_file = malloc( i_dirlen + i_filelen + 2 );
+                    if( psz_file == NULL )
                     {
-                        psz_file = malloc( i_vlclen + i_dirlen
-                                               + i_filelen + 3 );
-                        if( psz_file == NULL )
-                        {
-                            continue;
-                        }
-                        sprintf( psz_file, "%s/%s/%s", psz_vlcpath,
-                                 *ppsz_path, file->d_name );
-                    }
-                    else
-#endif
-                    {
-                        psz_file = malloc( i_dirlen + i_filelen + 2 );
-                        if( psz_file == NULL )
-                        {
-                            continue;
-                        }
-                        sprintf( psz_file, "%s/%s", *ppsz_path, file->d_name );
+                        continue;
                     }
+                    sprintf( psz_file, "%s/%s", psz_fullpath, file->d_name );
+
                     /* We created a nice filename -- now we just try to load
                      * it as a dynamic module. */
                     AllocateDynModule( p_bank, psz_file );
@@ -151,7 +160,17 @@ void module_InitBank( module_bank_t * p_bank )
                     free( psz_file );
                 }
             }
+
+            /* Close the directory if successfully opened */
+            closedir( dir );
         }
+
+#ifdef SYS_BEOS
+        if( b_notinroot )
+        {
+            free( psz_fullpath );
+        }
+#endif
     }
 
     return;
index f0bad5a03706619945131068efb5b5942283a0c6..6d48fd4b7c1925cc6fa0b6767fb35bdc593b3933 100644 (file)
@@ -222,11 +222,7 @@ vout_thread_t * vout_CreateThread   ( int *pi_status )
 
     /* Load fonts - fonts must be initialized after the system method since
      * they may be dependant on screen depth and other thread properties */
-    p_vout->p_default_font = vout_LoadFont( DATA_PATH "/" VOUT_DEFAULT_FONT );
-    if( p_vout->p_default_font == NULL )
-    {
-        p_vout->p_default_font = vout_LoadFont( "share/" VOUT_DEFAULT_FONT );
-    }
+    p_vout->p_default_font = vout_LoadFont( VOUT_DEFAULT_FONT );
     if( p_vout->p_default_font == NULL )
     {
         intf_ErrMsg( "vout error: could not load default font" );
@@ -234,11 +230,8 @@ vout_thread_t * vout_CreateThread   ( int *pi_status )
         free( p_vout );
         return( NULL );
     }
-    p_vout->p_large_font = vout_LoadFont( DATA_PATH "/" VOUT_LARGE_FONT );
-    if( p_vout->p_large_font == NULL )
-    {
-        p_vout->p_large_font = vout_LoadFont( "share/" VOUT_LARGE_FONT );
-    }
+
+    p_vout->p_large_font = vout_LoadFont( VOUT_LARGE_FONT );
     if( p_vout->p_large_font == NULL )
     {
         intf_ErrMsg( "vout error: could not load large font" );
index 1938f321a5c6aad4a65132ab011ed368da47efdd..b1e3d8a04adbeb9b942e420650439356fb174a3e 100644 (file)
@@ -27,6 +27,7 @@
 
 #include <errno.h>                                                  /* errno */
 #include <stdlib.h>                                                /* free() */
+#include <stdio.h>                                              /* sprintf() */
 #include <string.h>                                            /* strerror() */
 #include <fcntl.h>                                                 /* open() */
 #include <unistd.h>                                       /* read(), close() */
@@ -203,16 +204,59 @@ static void PutByte32( u32 *p_pic, int i_byte, byte_t i_char, byte_t i_border,
  *****************************************************************************/
 vout_font_t *vout_LoadFont( const char *psz_name )
 {
+    static char * path[] = { "share", DATA_PATH, NULL };
+
+    char **             ppsz_path = path;
+    char *              psz_file;
+#ifdef SYS_BEOS
+    char *              psz_vlcpath = beos_GetProgramPath();
+    int                 i_vlclen = strlen( psz_vlcpath );
+#endif
     int                 i_char, i_line;        /* character and line indexes */
-    int                 i_file;                               /* source file */
+    int                 i_file = -1;                          /* source file */
     byte_t              pi_buffer[2];                         /* file buffer */
     vout_font_t *       p_font;                           /* the font itself */
 
-    /* Open file */
-    i_file = open( psz_name, O_RDONLY );
+    for( ; *ppsz_path != NULL ; ppsz_path++ )
+    {
+#ifdef SYS_BEOS
+        /* Under BeOS, we need to add beos_GetProgramPath() to access
+         * files under the current directory */
+        if( strncmp( *ppsz_path, "/", 1 ) )
+        {
+            psz_file = malloc( strlen( psz_name ) + strlen( *ppsz_path )
+                                + i_vlclen + 3 );
+            if( psz_file == NULL )
+            {
+                continue;
+            }
+            sprintf( psz_file, "%s/%s/%s", psz_vlcpath, *ppsz_path, psz_name );
+        }
+        else
+#endif
+        {
+            psz_file = malloc( strlen( psz_name ) + strlen( *ppsz_path ) + 2 );
+            if( psz_file == NULL )
+            {
+                continue;
+            }
+            sprintf( psz_file, "%s/%s", *ppsz_path, psz_name );
+        }
+
+        /* Open file */
+        i_file = open( psz_file, O_RDONLY );
+        free( psz_file );
+
+        if( i_file != -1 )
+        {
+            break;
+        }
+    }
+
     if( i_file == -1 )
     {
-        intf_DbgMsg("vout: can't open file '%s' (%s)", psz_name, strerror(errno));
+        intf_DbgMsg( "vout error: can't open file '%s' (%s)",
+                     psz_name, strerror(errno) );
         return( NULL );
     }