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.
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>
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>
* Makefile and configure patches.
+
+Markus Kuespert <ltlBeBoy@beosmail.com>
+
+ * BeOS port of the DVD ioctls.
+
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
INSTALL=@INSTALL@
ARCH=@ARCH@
+exec_prefix=@exec_prefix@
prefix=@prefix@
bindir=@bindir@
datadir=@datadir@
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
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 \
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 \
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
[ 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 ])
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
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.
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)
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/ ; \
# 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
# dh_makeshlibs
dh_installdeb
# dh_perl
- dh_shlibdeps
+ dh_shlibdeps -Nvlc-glide
dh_gencontrol
dh_md5sums
dh_builddeb
AUTHORS
-INSTALL
+CONTRIBUTORS
README
TODO
/* 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.
*****************************************************************************/
#define MODULE_NAME alsa
+#include "modules_inner.h"
/*****************************************************************************
* Preamble
#include "main.h"
#include "modules.h"
-#include "modules_inner.h"
/*****************************************************************************
* Build configuration tree.
/*****************************************************************************
* 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.
* 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";
* 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 )
return( -1 );
}
- aout_getfunctions( &p_module->p_functions->aout );
+ _M( aout_getfunctions )( &p_module->p_functions->aout );
p_module->p_config = p_config;
* 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 );
}
+
*****************************************************************************/
#define MODULE_NAME alsa
+#include "modules_inner.h"
/*****************************************************************************
* Preamble
#include "main.h"
#include "modules.h"
-#include "modules_inner.h"
-
-
typedef struct alsa_device_s
{
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;
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
* 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>
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
+#define MODULE_NAME beos
+#include "modules_inner.h"
+
/*****************************************************************************
* Preamble
*****************************************************************************/
* 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;
*****************************************************************************/
#define MODULE_NAME beos
+#include "modules_inner.h"
/*****************************************************************************
* Preamble
#include "mtime.h"
#include "modules.h"
-#include "modules_inner.h"
/*****************************************************************************
* Build configuration tree.
/*****************************************************************************
* 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.
* 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";
* 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 ) );
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;
* 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 );
* 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>
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
+#define MODULE_NAME beos
+#include "modules_inner.h"
+
/*****************************************************************************
* Preamble
*****************************************************************************/
* 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;
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
+#define MODULE_NAME beos
+#include "modules_inner.h"
+
/*****************************************************************************
* Preamble
*****************************************************************************/
* 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;
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
+#define MODULE_NAME dsp
+#include "modules_inner.h"
+
/* TODO:
*
* - an aout_GetFormats() function
* 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;
*****************************************************************************/
#define MODULE_NAME dsp
+#include "modules_inner.h"
/*****************************************************************************
* Preamble
#include "mtime.h"
#include "modules.h"
-#include "modules_inner.h"
/*****************************************************************************
* Build configuration tree.
/*****************************************************************************
* 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.
* 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";
* 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 )
return( -1 );
}
- aout_getfunctions( &p_module->p_functions->aout );
+ _M( aout_getfunctions )( &p_module->p_functions->aout );
p_module->p_config = p_config;
* 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 );
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
+#define MODULE_NAME dummy
+#include "modules_inner.h"
+
/*****************************************************************************
* Preamble
*****************************************************************************/
* 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;
*****************************************************************************/
#define MODULE_NAME dummy
+#include "modules_inner.h"
/*****************************************************************************
* Preamble
#include "mtime.h"
#include "modules.h"
-#include "modules_inner.h"
/*****************************************************************************
* Build configuration tree.
/*****************************************************************************
* 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.
* 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";
* 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 )
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;
* 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 );
* 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"
/*****************************************************************************
* 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;
* 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
* 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;
*****************************************************************************/
#define MODULE_NAME dvd
+#include "modules_inner.h"
/*****************************************************************************
* Preamble
#include "mtime.h"
#include "modules.h"
-#include "modules_inner.h"
/*****************************************************************************
* Build configuration tree.
/*****************************************************************************
* 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.
* 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";
* 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 )
return( -1 );
}
- input_getfunctions( &p_module->p_functions->input );
+ _M( input_getfunctions )( &p_module->p_functions->input );
p_module->p_config = p_config;
* 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 );
* 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>
*
*****************************************************************************/
#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"
/*****************************************************************************
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 " );
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;
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
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 */
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;
}
/* 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;
}
/* 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;
/* 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;
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;
* 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>
*
#include "intf_msg.h"
#include "dvd_ifo.h"
#include "dvd_udf.h"
+#include "dvd_css.h"
#include "input_dvd.h"
/*
--- /dev/null
+/*****************************************************************************
+ * 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
+
--- /dev/null
+/*****************************************************************************
+ * 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 */
+
* 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
*/
* -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>
*
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
+#define MODULE_NAME dvd
+#include "modules_inner.h"
+
/*****************************************************************************
* Preamble
*****************************************************************************/
*****************************************************************************/
static struct
{
- char p_code[3];
+ char p_code[3];
char p_lang_long[20];
} lang_tbl[] =
{
* 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;
*****************************************************************************/
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.
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;
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 ) )
/* 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++ )
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
/*****************************************************************************
* 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 * );
* 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
* 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;
*****************************************************************************/
#define MODULE_NAME esd
+#include "modules_inner.h"
/*****************************************************************************
* Preamble
#include "mtime.h"
#include "modules.h"
-#include "modules_inner.h"
/*****************************************************************************
* Build configuration tree.
/*****************************************************************************
* 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.
* 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";
* 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 )
return( -1 );
}
- aout_getfunctions( &p_module->p_functions->aout );
+ _M( aout_getfunctions )( &p_module->p_functions->aout );
p_module->p_config = p_config;
* 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 );
*****************************************************************************/
#define MODULE_NAME fb
+#include "modules_inner.h"
/*****************************************************************************
* Preamble
#include "video_output.h"
#include "modules.h"
-#include "modules_inner.h"
/*****************************************************************************
* Building configuration tree
/*****************************************************************************
* 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.
* 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";
* 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 )
return( -1 );
}
- vout_getfunctions( &p_module->p_functions->vout );
+ _M( vout_getfunctions )( &p_module->p_functions->vout );
p_module->p_config = p_config;
* 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 );
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
+#define MODULE_NAME fb
+#include "modules_inner.h"
+
/*****************************************************************************
* Preamble
*****************************************************************************/
* 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;
*****************************************************************************/
#define MODULE_NAME ggi
+#include "modules_inner.h"
/*****************************************************************************
* Preamble
#include "video_output.h"
#include "modules.h"
-#include "modules_inner.h"
/*****************************************************************************
* Building configuration tree
/*****************************************************************************
* 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.
* 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";
* 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 )
return( -1 );
}
- vout_getfunctions( &p_module->p_functions->vout );
+ _M( vout_getfunctions )( &p_module->p_functions->vout );
p_module->p_config = p_config;
* 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 );
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
+#define MODULE_NAME ggi
+#include "modules_inner.h"
+
/*****************************************************************************
* Preamble
*****************************************************************************/
* 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;
/*****************************************************************************
* 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
* 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 );
}
+++ /dev/null
-/*****************************************************************************
- * 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 );
- }
- }
-}
-
/*****************************************************************************
* 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
* 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
} 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 ) );
}
/*****************************************************************************
- * 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 );
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;
*****************************************************************************/
#define MODULE_NAME gnome
+#include "modules_inner.h"
/*****************************************************************************
* Preamble
#include "mtime.h"
#include "modules.h"
-#include "modules_inner.h"
/*****************************************************************************
* Building configuration tree
/*****************************************************************************
* 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.
* 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";
* 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 )
return( -1 );
}
- intf_getfunctions( &p_module->p_functions->intf );
+ _M( intf_getfunctions )( &p_module->p_functions->intf );
p_module->p_config = p_config;
* 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 );
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
+#define MODULE_NAME gnome
+#include "modules_inner.h"
+
/*****************************************************************************
* Preamble
*****************************************************************************/
* 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
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
+#define MODULE_NAME gnome
+#include "modules_inner.h"
+
/*****************************************************************************
* Preamble
*****************************************************************************/
* 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;
* 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>
*
*****************************************************************************/
#define MODULE_NAME idct
+#include "modules_inner.h"
/*****************************************************************************
* Preamble
#include "video_decoder.h"
#include "modules.h"
-#include "modules_inner.h"
#include "idct.h"
* 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";
* 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 )
* 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 );
* 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>
*
* 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";
* 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 )
* 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 );
* 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>
* 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";
* 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 )
* 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 );
* 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>
* 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";
* 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 )
* 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 );
+++ /dev/null
-/*****************************************************************************
- * 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 );
- }
-}
/*****************************************************************************
* 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
* 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 );
}
/*****************************************************************************
* 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,
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));
- }
+ ;
}
/*****************************************************************************
* 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
#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 );
-
*****************************************************************************/
#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.
* 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";
* 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 )
* 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 );
*****************************************************************************/
#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.
* 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";
* 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 )
* 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 );
*****************************************************************************/
#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.
* 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";
* 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 )
* 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 );
* 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>
*
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
+#define MODULE_NAME ps
+#include "modules_inner.h"
+
/*****************************************************************************
* Preamble
*****************************************************************************/
* 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;
* 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:
*
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
+#define MODULE_NAME ts
+#include "modules_inner.h"
+
/*****************************************************************************
* Preamble
*****************************************************************************/
* 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;
*****************************************************************************/
#define MODULE_NAME ps
+#include "modules_inner.h"
/*****************************************************************************
* Preamble
#include "mtime.h"
#include "modules.h"
-#include "modules_inner.h"
/*****************************************************************************
* Build configuration tree.
/*****************************************************************************
* 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.
* 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";
* 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 )
return( -1 );
}
- input_getfunctions( &p_module->p_functions->input );
+ _M( input_getfunctions )( &p_module->p_functions->input );
p_module->p_config = p_config;
* 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 );
*****************************************************************************/
#define MODULE_NAME ts
+#include "modules_inner.h"
/*****************************************************************************
* Preamble
#include "mtime.h"
#include "modules.h"
-#include "modules_inner.h"
/*****************************************************************************
* Build configuration tree.
/*****************************************************************************
* 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.
* 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";
* 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 )
return( -1 );
}
- input_getfunctions( &p_module->p_functions->input );
+ _M( input_getfunctions )( &p_module->p_functions->input );
p_module->p_config = p_config;
* 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 );
* 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";
* 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. */
* 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 );
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
+#define MODULE_NAME sdl
+#include "modules_inner.h"
+
/*****************************************************************************
* Preamble
*****************************************************************************/
* 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;
*****************************************************************************/
#define MODULE_NAME sdl
+#include "modules_inner.h"
/*****************************************************************************
* Preamble
#include "video_output.h"
#include "modules.h"
-#include "modules_inner.h"
/*****************************************************************************
* Building configuration tree
/*****************************************************************************
* 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.
* 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";
* 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 )
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;
* 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 );
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
+#define MODULE_NAME sdl
+#include "modules_inner.h"
+
/*****************************************************************************
* Preamble
*****************************************************************************/
* 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;
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
+#define MODULE_NAME ncurses
+#include "modules_inner.h"
+
/*****************************************************************************
* Preamble
*****************************************************************************/
* 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;
*****************************************************************************/
#define MODULE_NAME ncurses
+#include "modules_inner.h"
/*****************************************************************************
* Preamble
#include "mtime.h"
#include "modules.h"
-#include "modules_inner.h"
/*****************************************************************************
* Building configuration tree
/*****************************************************************************
* 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.
* 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";
* 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 )
return( -1 );
}
- intf_getfunctions( &p_module->p_functions->intf );
+ _M( intf_getfunctions )( &p_module->p_functions->intf );
p_module->p_config = p_config;
* 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 );
* 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>
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
+#define MODULE_NAME x11
+#include "modules_inner.h"
+
/*****************************************************************************
* Preamble
*****************************************************************************/
* 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;
*****************************************************************************/
#define MODULE_NAME x11
+#include "modules_inner.h"
/*****************************************************************************
* Preamble
#include "video_output.h"
#include "modules.h"
-#include "modules_inner.h"
/*****************************************************************************
* Building configuration tree
/*****************************************************************************
* 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.
* 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";
* 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 )
return( -1 );
}
- vout_getfunctions( &p_module->p_functions->vout );
+ _M( vout_getfunctions )( &p_module->p_functions->vout );
p_module->p_config = p_config;
* 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 );
* Boston, MA 02111-1307, USA.
*****************************************************************************/
+#define MODULE_NAME yuv
+#include "modules_inner.h"
+
/*****************************************************************************
* Preamble
*****************************************************************************/
* 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;
* Boston, MA 02111-1307, USA.
*****************************************************************************/
+#define MODULE_NAME yuvmmx
+#include "modules_inner.h"
+
/*****************************************************************************
* Preamble
*****************************************************************************/
* 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;
*****************************************************************************/
#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.
* 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";
* 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 )
return( -1 );
}
- yuv_getfunctions( &p_module->p_functions->yuv );
+ _M( yuv_getfunctions )( &p_module->p_functions->yuv );
p_module->p_config = p_config;
* 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 );
*****************************************************************************/
#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.
* 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";
* 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 )
return( -1 );
}
- yuv_getfunctions( &p_module->p_functions->yuv );
+ _M( yuv_getfunctions )( &p_module->p_functions->yuv );
p_module->p_config = p_config;
* 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 );
*****************************************************************************
* 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
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 )
{
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 */
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 */
*****************************************************************************/
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;
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 )) )
{
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 );
free( psz_file );
}
}
+
+ /* Close the directory if successfully opened */
+ closedir( dir );
}
+
+#ifdef SYS_BEOS
+ if( b_notinroot )
+ {
+ free( psz_fullpath );
+ }
+#endif
}
return;
/* 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" );
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" );
#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() */
*****************************************************************************/
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 );
}