Browse Source

* ./modules/misc/gtk_main.c: created the gtk_main module, which simply runs

gtk_main() in its own thread, and does nothing on subsequent calls. This
    ensures that gtk_main is only running once.
  * ./modules/gui/familiar/*, modules/gui/gtk/*: the familiar, gtk and gnome
    modules are now fully reentrant thanks to their use of the gtk_main module.
  * ./src/libvlc.c: implemented vlc_set(), a wrapper for config_Put* available
    to external programs.
  * ./src/libvlc.c: removed vlc_stop() and vlc_end(), everything is now done
    by vlc_destroy().
  * ./modules/control/rc/rc.c: implemented a few new functions. For instance,
    run "vlc -I rc" and then type "intf gtk" or "intf gnome". You can even
    launch several of them. "segfault" works, too.
pull/2/head
Sam Hocevar 24 years ago
parent
commit
f0ec49dae5
  1. 2
      Makefile.opts.in
  2. 504
      configure
  3. 28
      configure.in
  4. 33
      debian/rules
  5. 4
      include/main.h
  6. 14
      include/vlc/vlc.h
  7. 230
      modules/control/rc/rc.c
  8. 116
      modules/gui/familiar/familiar.c
  9. 8
      modules/gui/familiar/familiar.h
  10. 8
      modules/gui/gtk/common.h
  11. 136
      modules/gui/gtk/gnome.c
  12. 138
      modules/gui/gtk/gtk.c
  13. 0
      modules/misc/.cvsignore
  14. 2
      modules/misc/Makefile
  15. 245
      modules/misc/gtk_main.c
  16. 2
      modules/misc/null.c
  17. 1
      modules/misc/null/Makefile
  18. 15
      mozilla/vlcplugin.c
  19. 443
      src/libvlc.c
  20. 10
      src/vlc.c

2
Makefile.opts.in

@ -72,6 +72,7 @@ ffmpeg_CFLAGS = @ffmpeg_CFLAGS@
glide_CFLAGS = @glide_CFLAGS@
gnome_CFLAGS = @gnome_CFLAGS@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_main_CFLAGS = @gtk_main_CFLAGS@
idctaltivec_CFLAGS = @idctaltivec_CFLAGS@
kde_CFLAGS = @kde_CFLAGS@
mad_CFLAGS = @mad_CFLAGS@
@ -113,6 +114,7 @@ ggi_LDFLAGS = @ggi_LDFLAGS@
glide_LDFLAGS = @glide_LDFLAGS@
gnome_LDFLAGS = @gnome_LDFLAGS@
gtk_LDFLAGS = @gtk_LDFLAGS@
gtk_main_LDFLAGS = @gtk_main_LDFLAGS@
http_LDFLAGS = @http_LDFLAGS@
idctaltivec_LDFLAGS = @idctaltivec_LDFLAGS@
imdct_LDFLAGS = @imdct_LDFLAGS@

504
configure

File diff suppressed because it is too large

28
configure.in

@ -260,6 +260,9 @@ if test "x${x_libraries}" = "xNONE"; then
x_libraries="/usr/X11R6/lib"
fi
dnl Build the gtk_main plugin?
NEED_GTK_MAIN=no
dnl Check for DPMS
if test "x${SYS}" != "xmingw32"
then
@ -437,7 +440,7 @@ dnl
dnl default modules
dnl
BUILTINS="${BUILTINS}"
PLUGINS="${PLUGINS} misc/dummy/dummy misc/null/null"
PLUGINS="${PLUGINS} misc/dummy/dummy misc/null"
PLUGINS="${PLUGINS} control/rc/rc misc/logger/logger access/file misc/memcpy/memcpy"
PLUGINS="${PLUGINS} demux/mpeg/es demux/mpeg/audio demux/mpeg/mpeg_system demux/mpeg/ps demux/mpeg/ts"
PLUGINS="${PLUGINS} codec/mpeg_video/idct/idct codec/mpeg_video/idct/idctclassic codec/mpeg_video/motion/motion codec/mpeg_video/mpeg_video codec/spudec/spudec codec/spdif codec/mpeg_audio/mpeg_audio"
@ -1594,8 +1597,8 @@ then
then
AC_MSG_ERROR([Your development package for Gtk+ is too old, you need at least version 1.2.0. Please upgrade and try again. Alternatively you can also configure with --disable-gtk.])
fi
gtk_CFLAGS="${gtk_CFLAGS} `${GTK_CONFIG} --cflags gtk`"
gtk_LDFLAGS="${gtk_LDFLAGS} `${GTK_CONFIG} --libs gtk | sed 's,-rdynamic,,'`"
gtk_CFLAGS="${gtk_CFLAGS} `${GTK_CONFIG} --cflags gtk gthread`"
gtk_LDFLAGS="${gtk_LDFLAGS} `${GTK_CONFIG} --libs gtk gthread | sed 's,-rdynamic,,'`"
# now look for the gtk.h header
CPPFLAGS="${save_CPPFLAGS} ${gtk_CFLAGS}"
ac_cv_gtk_headers=yes
@ -1606,6 +1609,7 @@ then
if test "x${ac_cv_gtk_headers}" = "xyes"
then
PLUGINS="${PLUGINS} gui/gtk/gtk"
NEED_GTK_MAIN=yes
ALIASES="${ALIASES} gvlc"
fi
CPPFLAGS="${save_CPPFLAGS}"
@ -1639,8 +1643,8 @@ then
then
AC_MSG_ERROR([Your development package for Gtk+ is too old, you need at least version 1.2.0. Please upgrade and try again. Alternatively you can also configure with --disable-familiar.])
fi
familiar_CFLAGS="${familiar_CFLAGS} `${GTK_CONFIG} --cflags gtk`"
familiar_LDFLAGS="${familiar_LDFLAGS} `${GTK_CONFIG} --libs gtk | sed 's,-rdynamic,,'`"
familiar_CFLAGS="${familiar_CFLAGS} `${GTK_CONFIG} --cflags gtk gthread`"
familiar_LDFLAGS="${familiar_LDFLAGS} `${GTK_CONFIG} --libs gtk gthread | sed 's,-rdynamic,,'`"
# now look for the gtk.h header
CPPFLAGS="${save_CPPFLAGS} ${familiar_CFLAGS}"
ac_cv_gtk_headers=yes
@ -1651,6 +1655,7 @@ then
if test "x${ac_cv_gtk_headers}" = "xyes"
then
PLUGINS="${PLUGINS} gui/familiar/familiar"
NEED_GTK_MAIN=yes
fi
CPPFLAGS="${save_CPPFLAGS}"
fi
@ -1673,6 +1678,7 @@ AC_ARG_ENABLE(gnome,
CPPFLAGS="${save_CPPFLAGS} ${gnome_CFLAGS}"
AC_CHECK_HEADERS(gnome.h, [
PLUGINS="${PLUGINS} gui/gtk/gnome"
NEED_GTK_MAIN=yes
ALIASES="${ALIASES} gnome-vlc"
],[
AC_MSG_ERROR([Can't find gnome headers. Please install the gnome
@ -1966,6 +1972,16 @@ then
fi
fi
dnl
dnl gtk_main plugin
dnl
if test "x${NEED_GTK_MAIN}" != "xno"
then
PLUGINS="${PLUGINS} misc/gtk_main"
gtk_main_CFLAGS="${gtk_main_CFLAGS} ${gtk_CFLAGS} ${familiar_CFLAGS} ${gnome_CFLAGS}"
gtk_main_LDFLAGS="${gtk_main_LDFLAGS} ${gtk_LDFLAGS} ${familiar_LDFLAGS} ${gnome_LDFLAGS}"
fi
dnl
dnl Plug-ins - this must be AT THE END
dnl
@ -2064,6 +2080,7 @@ AC_SUBST(ffmpeg_CFLAGS)
AC_SUBST(glide_CFLAGS)
AC_SUBST(gnome_CFLAGS)
AC_SUBST(gtk_CFLAGS)
AC_SUBST(gtk_main_CFLAGS)
AC_SUBST(kde_CFLAGS)
AC_SUBST(idctaltivec_CFLAGS)
AC_SUBST(macosx_CFLAGS)
@ -2104,6 +2121,7 @@ AC_SUBST(ggi_LDFLAGS)
AC_SUBST(glide_LDFLAGS)
AC_SUBST(gnome_LDFLAGS)
AC_SUBST(gtk_LDFLAGS)
AC_SUBST(gtk_main_LDFLAGS)
AC_SUBST(http_LDFLAGS)
AC_SUBST(idctaltivec_LDFLAGS)
AC_SUBST(imdct_LDFLAGS)

33
debian/rules

@ -11,7 +11,7 @@ export DH_COMPAT=3
# Compilation options
export FFMPEG_VERSION=cvs
export FAAD_VERSION=cvs
export CONFIG_FLAGS="--enable-release --prefix=/usr --enable-gnome --enable-gtk --enable-fb --enable-ggi --enable-sdl --enable-esd --enable-qt --enable-mad --enable-arts --enable-alsa --enable-lirc --enable-a52 --enable-aa --enable-dvbpsi --enable-xosd --enable-mozilla --enable-kde --enable-ffmpeg --with-ffmpeg-tree=ffmpeg-$(FFMPEG_VERSION) --enable-mp4 --enable-dvb --enable-dv --enable-faad --with-faad-tree=faad-$(FAAD_VERSION)"
export CONFIG_FLAGS="--enable-release --prefix=/usr --enable-gnome --enable-gtk --enable-familiar --enable-fb --enable-ggi --enable-sdl --enable-esd --enable-qt --enable-mad --enable-arts --enable-alsa --enable-lirc --enable-a52 --enable-aa --enable-dvbpsi --enable-xosd --enable-mozilla --enable-kde --enable-ffmpeg --with-ffmpeg-tree=ffmpeg-$(FFMPEG_VERSION) --enable-mp4 --enable-dvb --enable-dv --enable-faad --with-faad-tree=faad-$(FAAD_VERSION)"
# Remove --without-dvdcss here in non-totalitarian countries
export DVDCSS_FLAGS="--enable-dvd --without-dvdcss"
@ -78,7 +78,7 @@ install: build
# Package: gnome-vlc
mv debian/vlc/usr/bin/gnome-vlc debian/gnome-vlc/usr/bin/
ln -s vlc debian/gnome-vlc/usr/share/doc/gnome-vlc
-mv debian/vlc/usr/lib/vlc/gui/gnome.so debian/gnome-vlc/usr/lib/vlc/gui/
mv debian/vlc/usr/lib/vlc/gui/gnome.so debian/gnome-vlc/usr/lib/vlc/gui/
ln -s vlc.1.gz debian/gnome-vlc/usr/share/man/man1/gnome-vlc.1.gz
mv debian/vlc/$(VIDDIR)/gnome-vlc32x32.xpm debian/gnome-vlc/$(VIDDIR)/gnome-vlc.xpm
mv debian/vlc/$(VIDDIR)/gnome-vlc48x48.png debian/gnome-vlc/$(PIXDIR)/gnome-vlc.png
@ -86,71 +86,72 @@ install: build
# Package: gvlc
mv debian/vlc/usr/bin/gvlc debian/gvlc/usr/bin/
ln -s vlc debian/gvlc/usr/share/doc/gvlc
-mv debian/vlc/usr/lib/vlc/gui/gtk.so debian/gvlc/usr/lib/vlc/gui/
mv debian/vlc/usr/lib/vlc/gui/gtk.so debian/gvlc/usr/lib/vlc/gui/
mv debian/vlc/usr/lib/vlc/gui/familiar.so debian/gvlc/usr/lib/vlc/gui/
ln -s vlc.1.gz debian/gvlc/usr/share/man/man1/gvlc.1.gz
mv debian/vlc/$(VIDDIR)/gvlc32x32.xpm debian/gvlc/$(VIDDIR)/gvlc.xpm
mv debian/vlc/$(VIDDIR)/gvlc48x48.png debian/gvlc/$(PIXDIR)/gvlc.png
# Package: vlc-plugin-esd
ln -s vlc debian/vlc-plugin-esd/usr/share/doc/vlc-plugin-esd
-mv debian/vlc/usr/lib/vlc/audio_output/esd.so \
mv debian/vlc/usr/lib/vlc/audio_output/esd.so \
debian/vlc-plugin-esd/usr/lib/vlc/audio_output/
# Package: vlc-plugin-alsa
ln -s vlc debian/vlc-plugin-alsa/usr/share/doc/vlc-plugin-alsa
-mv debian/vlc/usr/lib/vlc/audio_output/alsa.so \
mv debian/vlc/usr/lib/vlc/audio_output/alsa.so \
debian/vlc-plugin-alsa/usr/lib/vlc/audio_output/
# Package: vlc-plugin-sdl
ln -s vlc debian/vlc-plugin-sdl/usr/share/doc/vlc-plugin-sdl
-mv debian/vlc/usr/lib/vlc/audio_output/sdl.so \
mv debian/vlc/usr/lib/vlc/audio_output/sdl.so \
debian/vlc-plugin-sdl/usr/lib/vlc/audio_output/
-mv debian/vlc/usr/lib/vlc/video_output/sdl.so \
mv debian/vlc/usr/lib/vlc/video_output/sdl.so \
debian/vlc-plugin-sdl/usr/lib/vlc/video_output/
# Package: vlc-plugin-ggi
ln -s vlc debian/vlc-plugin-ggi/usr/share/doc/vlc-plugin-ggi
-mv debian/vlc/usr/lib/vlc/video_output/ggi.so \
mv debian/vlc/usr/lib/vlc/video_output/ggi.so \
debian/vlc-plugin-ggi/usr/lib/vlc/video_output/
# Package: vlc-plugin-glide
ifeq ($(DEB_BUILD_ARCH),i386)
ln -s vlc debian/vlc-plugin-glide/usr/share/doc/vlc-plugin-glide
-mv debian/vlc/usr/lib/vlc/video_output/glide.so \
mv debian/vlc/usr/lib/vlc/video_output/glide.so \
debian/vlc-plugin-glide/usr/lib/vlc/video_output/
endif
# Package: qvlc
mv debian/vlc/usr/bin/qvlc debian/qvlc/usr/bin/
ln -s vlc debian/qvlc/usr/share/doc/qvlc
-mv debian/vlc/usr/lib/vlc/gui/qt.so debian/qvlc/usr/lib/vlc/gui/
mv debian/vlc/usr/lib/vlc/gui/qt.so debian/qvlc/usr/lib/vlc/gui/
ln -s vlc.1.gz debian/qvlc/usr/share/man/man1/qvlc.1.gz
mv debian/vlc/$(VIDDIR)/qvlc32x32.xpm debian/qvlc/$(VIDDIR)/qvlc.xpm
mv debian/vlc/$(VIDDIR)/qvlc48x48.png debian/qvlc/$(PIXDIR)/qvlc.png
# Package: vlc-plugin-mad
ln -s vlc debian/vlc-plugin-mad/usr/share/doc/vlc-plugin-mad
-mv debian/vlc/usr/lib/vlc/codec/mad.so \
mv debian/vlc/usr/lib/vlc/codec/mad.so \
debian/vlc-plugin-mad/usr/lib/vlc/codec/
# Package: vlc-plugin-arts
ln -s vlc debian/vlc-plugin-arts/usr/share/doc/vlc-plugin-arts
-mv debian/vlc/usr/lib/vlc/audio_output/arts.so \
mv debian/vlc/usr/lib/vlc/audio_output/arts.so \
debian/vlc-plugin-arts/usr/lib/vlc/audio_output/
# Package: vlc-plugin-lirc
ln -s vlc debian/vlc-plugin-lirc/usr/share/doc/vlc-plugin-lirc
-mv debian/vlc/usr/lib/vlc/control/lirc.so \
mv debian/vlc/usr/lib/vlc/control/lirc.so \
debian/vlc-plugin-lirc/usr/lib/vlc/control/
# Package: vlc-plugin-aa
ln -s vlc debian/vlc-plugin-aa/usr/share/doc/vlc-plugin-aa
-mv debian/vlc/usr/lib/vlc/video_output/aa.so \
mv debian/vlc/usr/lib/vlc/video_output/aa.so \
debian/vlc-plugin-aa/usr/lib/vlc/video_output/
# Package: vlc-plugin-xosd
ln -s vlc debian/vlc-plugin-xosd/usr/share/doc/vlc-plugin-xosd
-mv debian/vlc/usr/lib/vlc/visualization/xosd.so \
mv debian/vlc/usr/lib/vlc/visualization/xosd.so \
debian/vlc-plugin-xosd/usr/lib/vlc/visualization/
# Package: mozilla-plugin-vlc
@ -160,7 +161,7 @@ endif
# Package: kvlc
mv debian/vlc/usr/bin/kvlc debian/kvlc/usr/bin/
ln -s vlc debian/kvlc/usr/share/doc/kvlc
-mv debian/vlc/usr/lib/vlc/gui/kde.so debian/kvlc/usr/lib/vlc/gui/
mv debian/vlc/usr/lib/vlc/gui/kde.so debian/kvlc/usr/lib/vlc/gui/
ln -s vlc.1.gz debian/kvlc/usr/share/man/man1/kvlc.1.gz
mv debian/vlc/$(VIDDIR)/kvlc32x32.xpm debian/kvlc/$(VIDDIR)/kvlc.xpm
mv debian/vlc/$(VIDDIR)/kvlc48x48.png debian/kvlc/$(PIXDIR)/kvlc.png

4
include/main.h

@ -3,7 +3,7 @@
* Declaration and extern access to global program object.
*****************************************************************************
* Copyright (C) 1999, 2000, 2001, 2002 VideoLAN
* $Id: main.h,v 1.44 2002/08/12 09:34:15 sam Exp $
* $Id: main.h,v 1.45 2002/08/20 18:08:51 sam Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
*
@ -38,6 +38,7 @@ struct vlc_t
/* The vlc structure status */
int i_status;
int i_instance; /* p_vlc instance # */
/* Global properties */
int i_argc; /* command line arguments count */
@ -72,7 +73,6 @@ struct vlc_t
vlc_mutex_t structure_lock; /* lock for the p_vlc tree */
/* Object structure data */
int i_unique; /* p_vlc occurence # */
int i_counter; /* object counter */
int i_objects; /* Attached objects count */
vlc_object_t ** pp_objects; /* Array of all objects */

14
include/vlc/vlc.h

@ -2,7 +2,7 @@
* vlc.h: global header for vlc
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: vlc.h,v 1.9 2002/08/19 11:13:44 sam Exp $
* $Id: vlc.h,v 1.10 2002/08/20 18:08:51 sam Exp $
*
* 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
@ -41,10 +41,12 @@ typedef int vlc_status_t;
* Error values
*****************************************************************************/
#define VLC_SUCCESS -0 /* No error */
#define VLC_EGENERIC -1 /* Generic error */
#define VLC_ENOMEM -2 /* Not enough memory */
#define VLC_ENOMEM -1 /* Not enough memory */
#define VLC_EMODULE -2 /* Module not found */
#define VLC_ESTATUS -3 /* Invalid status */
#define VLC_ETHREAD -4 /* Could not spawn thread */
#define VLC_EEXIT -255 /* Program exited */
#define VLC_EGENERIC -666 /* Generic error */
/*****************************************************************************
* Booleans
@ -115,10 +117,9 @@ vlc_error_t vlc_create ( void );
vlc_error_t vlc_init ( int, char *[] );
vlc_error_t vlc_run ( void );
vlc_error_t vlc_die ( void );
vlc_error_t vlc_stop ( void );
vlc_error_t vlc_end ( void );
vlc_error_t vlc_destroy ( void );
vlc_error_t vlc_set ( const char *, const char * );
vlc_error_t vlc_add_intf ( const char *, vlc_bool_t );
vlc_error_t vlc_add_target ( const char *, int, int );
@ -131,10 +132,9 @@ vlc_t * vlc_create_r ( void );
vlc_error_t vlc_init_r ( vlc_t *, int, char *[] );
vlc_error_t vlc_run_r ( vlc_t * );
vlc_error_t vlc_die_r ( vlc_t * );
vlc_error_t vlc_stop_r ( vlc_t * );
vlc_error_t vlc_end_r ( vlc_t * );
vlc_error_t vlc_destroy_r ( vlc_t * );
vlc_error_t vlc_set_r ( vlc_t *, const char *, const char * );
vlc_error_t vlc_add_intf_r ( vlc_t *, const char *, vlc_bool_t );
vlc_error_t vlc_add_target_r ( vlc_t *, const char *, int, int );

230
modules/control/rc/rc.c

@ -2,7 +2,7 @@
* rc.c : remote control stdin/stdout plugin for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: rc.c,v 1.3 2002/08/14 08:17:24 sam Exp $
* $Id: rc.c,v 1.4 2002/08/20 18:08:51 sam Exp $
*
* Authors: Peter Surda <shurdeek@panorama.sth.ac.at>
*
@ -30,6 +30,7 @@
#include <errno.h> /* ENOMEM */
#include <stdio.h>
#include <ctype.h>
#include <signal.h>
#include <vlc/vlc.h>
#include <vlc/intf.h>
@ -59,7 +60,12 @@ static void Run ( intf_thread_t *p_intf );
/*****************************************************************************
* Module descriptor
*****************************************************************************/
#define POS_TEXT N_("show stream position")
#define POS_LONGTEXT N_("Show the current position in seconds within the stream from time to time.")
vlc_module_begin();
add_category_hint( N_("Remote control"), NULL );
add_bool( "rc-show-pos", 0, NULL, POS_TEXT, POS_LONGTEXT );
set_description( _("remote control interface module") );
set_capability( "interface", 20 );
set_callbacks( Activate, NULL );
@ -107,9 +113,11 @@ static int Activate( vlc_object_t *p_this )
static void Run( intf_thread_t *p_intf )
{
input_thread_t * p_input;
playlist_t * p_playlist;
char p_buffer[ MAX_LINE_LENGTH + 1 ];
vlc_bool_t b_complete = 0;
vlc_bool_t b_showpos = config_GetInt( p_intf, "rc-show-pos" );
input_info_category_t * p_category;
input_info_t * p_info;
@ -120,12 +128,9 @@ static void Run( intf_thread_t *p_intf )
struct timeval tv; /* how long to wait */
double f_ratio = 1;
char psz_dashes[81];
memset(psz_dashes, '-', 80);
psz_dashes[80] = '\0';
p_input = NULL;
p_playlist = NULL;
while( !p_intf->b_die )
{
@ -163,8 +168,21 @@ static void Run( intf_thread_t *p_intf )
/* Manage the input part */
if( p_input == NULL )
{
p_input = vlc_object_find( p_intf, VLC_OBJECT_INPUT,
FIND_ANYWHERE );
if( p_playlist )
{
p_input = vlc_object_find( p_playlist, VLC_OBJECT_INPUT,
FIND_CHILD );
}
else
{
p_input = vlc_object_find( p_intf, VLC_OBJECT_INPUT,
FIND_ANYWHERE );
if( p_input )
{
p_playlist = vlc_object_find( p_input, VLC_OBJECT_PLAYLIST,
FIND_PARENT );
}
}
}
else if( p_input->b_dead )
{
@ -172,7 +190,7 @@ static void Run( intf_thread_t *p_intf )
p_input = NULL;
}
if( p_input )
if( p_input && b_showpos )
{
/* Get position */
vlc_mutex_lock( &p_input->stream.stream_lock );
@ -197,40 +215,114 @@ static void Run( intf_thread_t *p_intf )
if( b_complete == 1 )
{
char *p_cmd = p_buffer;
//char *p_tmp;
switch( p_cmd[0] )
if( !strcmp( p_cmd, "quit" ) )
{
case 'a':
case 'A':
if( p_cmd[1] == ' ' )
p_intf->p_vlc->b_die = VLC_TRUE;
}
else if( !strcmp( p_cmd, "segfault" ) )
{
raise( SIGSEGV );
}
else if( !strcmp( p_cmd, "prev" ) )
{
if( p_playlist ) playlist_Prev( p_playlist );
}
else if( !strcmp( p_cmd, "next" ) )
{
if( p_playlist ) playlist_Next( p_playlist );
}
else if( !strcmp( p_cmd, "play" ) )
{
if( p_playlist ) playlist_Play( p_playlist );
}
else if( !strcmp( p_cmd, "stop" ) )
{
if( p_playlist ) playlist_Stop( p_playlist );
}
else if( !strcmp( p_cmd, "pause" ) )
{
if( p_input ) input_SetStatus( p_input, INPUT_STATUS_PAUSE );
}
else if( !strcmp( p_cmd, "tree" ) )
{
vlc_dumpstructure( p_intf->p_vlc );
}
else if( !strcmp( p_cmd, "list" ) )
{
vlc_liststructure( p_intf->p_vlc );
}
else if( !strncmp( p_cmd, "set ", 4 ) )
{
#if 0
// vlc_set_r( p_intf->p_vlc, p_cmd + 4, strstr( p_cmd + 4, " " ) );
p_tmp = strstr( p_cmd + 4, " " );
p_tmp[0] = '\0';
config_PutPsz( p_intf->p_vlc, p_cmd + 4, p_tmp + 1 );
config_PutInt( p_intf->p_vlc, p_cmd + 4, atoi(p_tmp + 1) );
#endif
}
else if( !strncmp( p_cmd, "intf ", 5 ) )
{
intf_thread_t *p_newintf;
char *psz_oldmodule = config_GetPsz( p_intf->p_vlc, "intf" );
config_PutPsz( p_intf->p_vlc, "intf", p_cmd + 5 );
p_newintf = intf_Create( p_intf->p_vlc );
config_PutPsz( p_intf->p_vlc, "intf", psz_oldmodule );
if( psz_oldmodule )
{
free( psz_oldmodule );
}
if( p_newintf )
{
playlist_t *p_playlist;
p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( p_playlist )
p_newintf->b_block = VLC_FALSE;
if( intf_RunThread( p_newintf ) )
{
playlist_Add( p_playlist, p_cmd + 2,
PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
vlc_object_release( p_playlist );
vlc_object_detach( p_newintf );
intf_Destroy( p_newintf );
}
}
break;
case 'l':
case 'L':
vlc_liststructure( p_intf->p_vlc );
break;
case 'd':
case 'D':
vlc_dumpstructure( p_intf->p_vlc );
break;
case 'p':
case 'P':
if( p_input )
}
else if( !strcmp( p_cmd, "info" ) )
{
if ( p_input )
{
input_SetStatus( p_input, INPUT_STATUS_PAUSE );
vlc_mutex_lock( &p_input->stream.stream_lock );
p_category = p_input->stream.p_info;
while ( p_category )
{
printf( "+----[ %s ]\n", p_category->psz_name );
printf( "| \n" );
p_info = p_category->p_info;
while ( p_info )
{
printf( "| %s: %s\n", p_info->psz_name,
p_info->psz_value );
p_info = p_info->p_next;
}
p_category = p_category->p_next;
printf( "| \n" );
}
printf( "+----[ end of stream info ]\n" );
vlc_mutex_unlock( &p_input->stream.stream_lock );
}
else
{
printf( "no input\n" );
}
}
else switch( p_cmd[0] )
{
case 'a':
case 'A':
if( p_cmd[1] == ' ' && p_playlist )
{
playlist_Add( p_playlist, p_cmd + 2,
PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
}
break;
@ -255,11 +347,6 @@ static void Run( intf_thread_t *p_intf )
;
break;
case 'q':
case 'Q':
p_intf->p_vlc->b_die = VLC_TRUE;
break;
case 'r':
case 'R':
if( p_input )
@ -282,50 +369,29 @@ static void Run( intf_thread_t *p_intf )
case '?':
case 'h':
case 'H':
printf( "help for remote control commands\n" );
printf( "h . . . . . . . . . . . . . . . . . . . . . help\n" );
printf( "a XYZ . . . . . . . . . . append XYZ to playlist\n" );
printf( "p . . . . . . . . . . . . . . . . . toggle pause\n" );
printf( "f . . . . . . . . . . . . . . toggle fullscreen\n" );
printf( "r X . . . seek in seconds, for instance `r 3.5'\n" );
printf( "q . . . . . . . . . . . . . . . . . . . . . quit\n" );
printf( "end of help\n" );
break;
case 'i':
case 'I':
if ( p_input ) {
printf( "Dumping stream info\n" );
vlc_mutex_lock( &p_input->stream.stream_lock );
p_category = p_input->stream.p_info;
while ( p_category )
{
psz_dashes[72 - strlen(p_category->psz_name) ] = '\0';
printf( "+--| %s |%s+\n", p_category->psz_name, psz_dashes);
psz_dashes[72 - strlen(p_category->psz_name) ] = '-';
p_info = p_category->p_info;
while ( p_info )
{
printf( "| %s: %s\n", p_info->psz_name,
p_info->psz_value );
p_info = p_info->p_next;
}
printf("|\n");
p_category = p_category->p_next;
}
psz_dashes[78] = '\0';
printf( "+%s+\n", psz_dashes );
vlc_mutex_unlock( &p_input->stream.stream_lock );
}
else
{
printf( "no input" );
}
printf("+----[ remote control commands ]\n");
printf("| \n");
printf("| a XYZ . . . . . . . . . . . add XYZ to playlist\n");
printf("| play . . . . . . . . . . . . . . . . play stream\n");
printf("| stop . . . . . . . . . . . . . . . . stop stream\n");
printf("| next . . . . . . . . . . . . next playlist item\n");
printf("| prev . . . . . . . . . . previous playlist item\n");
printf("| \n");
printf("| r X . . . seek in seconds, for instance `r 3.5'\n");
printf("| pause . . . . . . . . . . . . . . toggle pause\n");
printf("| f . . . . . . . . . . . . . . toggle fullscreen\n");
printf("| info . . . information about the current stream\n");
printf("| \n");
printf("| help . . . . . . . . . . . . . this help message\n");
printf("| quit . . . . . . . . . . . . . . . . . quit vlc\n");
printf("| \n");
printf("+----[ end of help ]\n");
break;
case '\0':
/* Ignore empty lines */
break;
default:
printf( "unknown command `%s'\n", p_cmd );
printf( "unknown command `%s', type `help' for help\n", p_cmd );
break;
}
}
@ -337,6 +403,12 @@ static void Run( intf_thread_t *p_intf )
{
vlc_object_release( p_input );
p_input = NULL;
if( p_playlist )
{
vlc_object_release( p_playlist );
p_playlist = NULL;
}
}
}

116
modules/gui/familiar/familiar.c

@ -2,7 +2,7 @@
* familiar.c : familiar plugin for vlc
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: familiar.c,v 1.5 2002/08/20 12:32:01 sam Exp $
* $Id: familiar.c,v 1.6 2002/08/20 18:08:51 sam Exp $
*
* Authors: Jean-Paul Saman <jpsaman@wxs.nl>
*
@ -39,54 +39,6 @@
#include "support.h"
#include "familiar.h"
/*****************************************************************************
* Local variables (mutex-protected).
*****************************************************************************/
static void ** pp_global_data = NULL;
/*****************************************************************************
* g_atexit: kludge to avoid the Gtk+ thread to segfault at exit
*****************************************************************************
* gtk_init() makes several calls to g_atexit() which calls atexit() to
* register tidying callbacks to be called at program exit. Since the Gtk+
* plugin is likely to be unloaded at program exit, we have to export this
* symbol to intercept the g_atexit() calls. Talk about crude hack.
*****************************************************************************/
void g_atexit( GVoidFunc func )
{
intf_thread_t *p_intf;
int i_dummy;
if( pp_global_data == NULL )
{
atexit( func );
return;
}
p_intf = (intf_thread_t *)*pp_global_data;
if( p_intf == NULL )
{
return;
}
for( i_dummy = 0;
i_dummy < MAX_ATEXIT && p_intf->p_sys->pf_callback[i_dummy] != NULL;
i_dummy++ )
{
;
}
if( i_dummy >= MAX_ATEXIT - 1 )
{
msg_Err( p_intf, "too many atexit() callbacks to register" );
return;
}
p_intf->p_sys->pf_callback[i_dummy] = func;
p_intf->p_sys->pf_callback[i_dummy + 1] = NULL;
}
/*****************************************************************************
* Local prototypes.
*****************************************************************************/
@ -94,7 +46,6 @@ static int Open ( vlc_object_t * );
static void Close ( vlc_object_t * );
static void Run ( intf_thread_t * );
static gint Manage ( gpointer );
/*****************************************************************************
* Module descriptor
@ -117,7 +68,14 @@ static int Open( vlc_object_t *p_this )
if( p_intf->p_sys == NULL )
{
msg_Err( p_intf, "out of memory" );
return( 1 );
return VLC_ENOMEM;
}
p_intf->p_sys->p_gtk_main = module_Need( p_this, "gtk_main", "gtk" );
if( p_intf->p_sys->p_gtk_main == NULL )
{
free( p_intf->p_sys );
return VLC_EMODULE;
}
/* Initialize Gtk+ thread */
@ -127,7 +85,7 @@ static int Open( vlc_object_t *p_this )
p_intf->pf_run = Run;
return( 0 );
return VLC_SUCCESS;
}
/*****************************************************************************
@ -142,8 +100,10 @@ static void Close( vlc_object_t *p_this )
vlc_object_release( p_intf->p_sys->p_input );
}
module_Unneed( p_intf, p_intf->p_sys->p_gtk_main );
/* Destroy structure */
if (p_intf->p_sys) free( p_intf->p_sys );
free( p_intf->p_sys );
}
/*****************************************************************************
@ -151,27 +111,10 @@ static void Close( vlc_object_t *p_this )
*****************************************************************************
* this part of the interface is in a separate thread so that we can call
* gtk_main() from within it without annoying the rest of the program.
* XXX: the approach may look kludgy, and probably is, but I could not find
* a better way to dynamically load a Gtk+ interface at runtime.
*****************************************************************************/
static void Run( intf_thread_t *p_intf )
{
/* gtk_init needs to know the command line. We don't care, so we
* give it an empty one */
char *p_args[] = { "" };
char **pp_args = p_args;
int i_args = 1;
int i_dummy;
/* Initialize Gtk+ */
gtk_set_locale ();
/* gtk_init will register stuff with g_atexit, so we need to take
* the global lock if we want to be able to intercept the calls */
vlc_mutex_lock( p_intf->p_vlc->p_global_lock );
*p_intf->p_vlc->pp_global_data = p_intf;
gtk_init( &i_args, &pp_args );
vlc_mutex_unlock( p_intf->p_vlc->p_global_lock );
gdk_threads_enter();
/* Create some useful widgets that will certainly be used */
// FIXME: magic path
@ -203,30 +146,17 @@ static void Run( intf_thread_t *p_intf )
/* Show the control window */
gtk_widget_show( p_intf->p_sys->p_window );
/* Add a check for termination */
i_dummy = gtk_timeout_add( INTF_IDLE_SLEEP / 1000, Manage, p_intf );
/* Enter Gtk mode */
gtk_main();
/* Remove the timeout */
gtk_timeout_remove( i_dummy );
}
/*****************************************************************************
* Manage: check for termination
*****************************************************************************
* In this function, called approx. 10 times a second, we check whether the
* main program asked us to die by setting b_die to VLC_TRUE.
*****************************************************************************/
static gint Manage( gpointer p_data )
{
if( ((intf_thread_t *)p_data)->b_die )
/* Sleep to avoid using all CPU - since some interfaces need to
* access keyboard events, a 100ms delay is a good compromise */
while( !p_intf->b_die )
{
gtk_main_quit();
return FALSE;
gdk_threads_leave();
msleep( INTF_IDLE_SLEEP );
gdk_threads_enter();
}
return TRUE;
gtk_object_destroy( GTK_OBJECT(p_intf->p_sys->p_window) );
gdk_threads_leave();
}

8
modules/gui/familiar/familiar.h

@ -2,7 +2,7 @@
* familiar.h: private Gtk+ interface description
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: familiar.h,v 1.4 2002/08/18 20:36:04 jpsaman Exp $
* $Id: familiar.h,v 1.5 2002/08/20 18:08:51 sam Exp $
*
* Authors: Jean-Paul Saman <jpsaman@wxs.nl>
*
@ -28,6 +28,9 @@
*****************************************************************************/
struct intf_sys_t
{
/* The gtk_main module */
module_t * p_gtk_main;
/* windows and widgets */
GtkWidget * p_window; /* main window */
GtkNotebook * p_notebook;
@ -39,9 +42,6 @@ struct intf_sys_t
vlc_bool_t b_autoplayfile;
/* The input thread */
input_thread_t * p_input;
/* XXX: Ugly kludge, see gtk.c */
void ( *pf_callback[MAX_ATEXIT] ) ( void );
};
/*****************************************************************************

8
modules/gui/gtk/common.h

@ -2,7 +2,7 @@
* gtk_common.h: private Gtk+ interface description
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: common.h,v 1.1 2002/08/04 17:23:43 sam Exp $
* $Id: common.h,v 1.2 2002/08/20 18:08:51 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
@ -35,6 +35,9 @@
*****************************************************************************/
struct intf_sys_t
{
/* the gtk_main module */
module_t * p_gtk_main;
/* special actions */
vlc_bool_t b_playing;
vlc_bool_t b_popup_changed; /* display menu ? */
@ -82,9 +85,6 @@ struct intf_sys_t
GtkLabel * p_label_title;
GtkLabel * p_label_chapter;
gint i_part; /* current chapter */
/* XXX: Ugly kludge, see gtk.c */
void ( *pf_callback[MAX_ATEXIT] ) ( void );
};
/*****************************************************************************

136
modules/gui/gtk/gnome.c

@ -2,7 +2,7 @@
* gnome.c : Gnome plugin for vlc
*****************************************************************************
* Copyright (C) 2000 VideoLAN
* $Id: gnome.c,v 1.1 2002/08/04 17:23:43 sam Exp $
* $Id: gnome.c,v 1.2 2002/08/20 18:08:51 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
@ -47,12 +47,7 @@ static int Open ( vlc_object_t * );
static void Close ( vlc_object_t * );
static void Run ( intf_thread_t * );
static gint Manage ( gpointer );
/*****************************************************************************
* Local variables (mutex-protected).
*****************************************************************************/
static void ** pp_global_data = NULL;
static void Manage ( intf_thread_t * );
/*****************************************************************************
* Module descriptor
@ -74,9 +69,7 @@ vlc_module_begin();
#else
int i = getenv( "DISPLAY" ) == NULL ? 15 : 100;
#endif
pp_global_data = p_module->p_vlc->pp_global_data;
add_category_hint( N_("Miscellaneous"), NULL );
add_category_hint( N_("GNOME"), NULL );
add_bool( "gnome-tooltips", 1, GtkHideTooltips,
TOOLTIPS_TEXT, TOOLTIPS_LONGTEXT );
add_bool( "gnome-toolbartext", 1, GtkHideToolbarText, TOOLBAR_TEXT,
@ -90,49 +83,6 @@ vlc_module_begin();
set_program( "gnome-vlc" );
vlc_module_end();
/*****************************************************************************
* g_atexit: kludge to avoid the Gnome thread to segfault at exit
*****************************************************************************
* gtk_init() makes several calls to g_atexit() which calls atexit() to
* register tidying callbacks to be called at program exit. Since the Gnome
* plugin is likely to be unloaded at program exit, we have to export this
* symbol to intercept the g_atexit() calls. Talk about crude hack.
*****************************************************************************/
void g_atexit( GVoidFunc func )
{
intf_thread_t *p_intf;
int i_dummy;
if( pp_global_data == NULL )
{
atexit( func );
return;
}
p_intf = (intf_thread_t *)*pp_global_data;
if( p_intf == NULL )
{
return;
}
for( i_dummy = 0;
i_dummy < MAX_ATEXIT && p_intf->p_sys->pf_callback[i_dummy] != NULL;
i_dummy++ )
{
;
}
if( i_dummy >= MAX_ATEXIT - 1 )
{
msg_Err( p_intf, "too many atexit() callbacks to register" );
return;
}
p_intf->p_sys->pf_callback[i_dummy] = func;
p_intf->p_sys->pf_callback[i_dummy + 1] = NULL;
}
/*****************************************************************************
* Open: initialize and create window
*****************************************************************************/
@ -145,7 +95,14 @@ static int Open( vlc_object_t *p_this )
if( p_intf->p_sys == NULL )
{
msg_Err( p_intf, "out of memory" );
return( 1 );
return VLC_ENOMEM;
}
p_intf->p_sys->p_gtk_main = module_Need( p_this, "gtk_main", "gnome" );
if( p_intf->p_sys->p_gtk_main == NULL )
{
free( p_intf->p_sys );
return VLC_EMODULE;
}
p_intf->pf_run = Run;
@ -162,11 +119,9 @@ static int Open( vlc_object_t *p_this )
p_intf->p_sys->i_playing = -1;
p_intf->p_sys->b_slider_free = 1;
p_intf->p_sys->pf_callback[0] = NULL;
p_intf->p_sys->i_part = 0;
return( 0 );
return VLC_SUCCESS;
}
/*****************************************************************************
@ -183,6 +138,8 @@ static void Close( vlc_object_t *p_this )
msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
module_Unneed( p_intf, p_intf->p_sys->p_gtk_main );
/* Destroy structure */
free( p_intf->p_sys );
}
@ -197,12 +154,6 @@ static void Close( vlc_object_t *p_this )
*****************************************************************************/
static void Run( intf_thread_t *p_intf )
{
/* gnome_init needs to know the command line. We don't care, so we
* give it an empty one */
char *p_args[] = { "" };
int i_args = 1;
int i_dummy;
/* The data types we are allowed to receive */
static GtkTargetEntry target_table[] =
{
@ -211,20 +162,14 @@ static void Run( intf_thread_t *p_intf )
{ "text/plain", 0, DROP_ACCEPT_TEXT_PLAIN }
};
/* Initialize Gnome */
/* gnome_init will register stuff with g_atexit, so we need to take
* the global lock if we want to be able to intercept the calls */
vlc_mutex_lock( p_intf->p_vlc->p_global_lock );
*p_intf->p_vlc->pp_global_data = p_intf;
gnome_init( p_intf->p_vlc->psz_object_name, VERSION, i_args, p_args );
vlc_mutex_unlock( p_intf->p_vlc->p_global_lock );
gdk_threads_enter();
/* Create some useful widgets that will certainly be used */
p_intf->p_sys->p_window = create_intf_window( );
p_intf->p_sys->p_popup = create_intf_popup( );
p_intf->p_sys->p_playwin = create_intf_playlist();
p_intf->p_sys->p_messages = create_intf_messages();
p_intf->p_sys->p_tooltips = gtk_tooltips_new();
/* Set the title of the main window */
gtk_window_set_title( GTK_WINDOW(p_intf->p_sys->p_window),
@ -267,8 +212,6 @@ static void Run( intf_thread_t *p_intf )
p_intf->p_sys->f_adj_oldvalue = 0;
#undef P_SLIDER
p_intf->p_sys->p_tooltips = gtk_tooltips_new();
/* We don't create these ones yet because we perhaps won't need them */
p_intf->p_sys->p_about = NULL;
p_intf->p_sys->p_modules = NULL;
@ -308,26 +251,25 @@ static void Run( intf_thread_t *p_intf )
/* Show the control window */
gtk_widget_show( p_intf->p_sys->p_window );
/* Sleep to avoid using all CPU - since some interfaces needs to access
* keyboard events, a 100ms delay is a good compromise */
i_dummy = gtk_timeout_add( INTF_IDLE_SLEEP / 1000, Manage, p_intf );
/* Enter gnome mode */
gtk_main();
while( !p_intf->b_die )
{
Manage( p_intf );
/* Remove the timeout */
gtk_timeout_remove( i_dummy );
/* Sleep to avoid using all CPU - since some interfaces need to
* access keyboard events, a 100ms delay is a good compromise */
gdk_threads_leave();
msleep( INTF_IDLE_SLEEP );
gdk_threads_enter();
}
/* Destroy the Tooltips structure */
gtk_object_destroy( GTK_OBJECT(p_intf->p_sys->p_tooltips) );
gtk_object_destroy( GTK_OBJECT(p_intf->p_sys->p_messages) );
gtk_object_destroy( GTK_OBJECT(p_intf->p_sys->p_playwin) );
gtk_object_destroy( GTK_OBJECT(p_intf->p_sys->p_popup) );
gtk_object_destroy( GTK_OBJECT(p_intf->p_sys->p_window) );
/* Get rid of stored callbacks so we can unload the plugin */
for( i_dummy = 0;
i_dummy < MAX_ATEXIT && p_intf->p_sys->pf_callback[i_dummy] != NULL;
i_dummy++ )
{
p_intf->p_sys->pf_callback[i_dummy]();
}
gdk_threads_leave();
}
/* following functions are local */
@ -338,9 +280,8 @@ static void Run( intf_thread_t *p_intf )
* In this function, called approx. 10 times a second, we check what the
* main program wanted to tell us.
*****************************************************************************/
static gint Manage( gpointer p_data )
static void Manage( intf_thread_t *p_intf )
{
#define p_intf ((intf_thread_t *)p_data)
int i_start, i_stop;
vlc_mutex_lock( &p_intf->change_lock );
@ -492,21 +433,8 @@ static gint Manage( gpointer p_data )
p_intf->p_sys->b_playing = 0;
}
if( p_intf->b_die )
{
vlc_mutex_unlock( &p_intf->change_lock );
/* Prepare to die, young Skywalker */
gtk_main_quit();
/* Just in case */
return( FALSE );
}
vlc_mutex_unlock( &p_intf->change_lock );
return( TRUE );
#undef p_intf
return;
}

138
modules/gui/gtk/gtk.c

@ -2,7 +2,7 @@
* gtk.c : Gtk+ plugin for vlc
*****************************************************************************
* Copyright (C) 2000-2001 VideoLAN
* $Id: gtk.c,v 1.1 2002/08/04 17:23:43 sam Exp $
* $Id: gtk.c,v 1.2 2002/08/20 18:08:51 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
@ -49,12 +49,7 @@ static int Open ( vlc_object_t * );
static void Close ( vlc_object_t * );
static void Run ( intf_thread_t * );
static gint Manage ( gpointer );
/*****************************************************************************
* Local variables (mutex-protected).
*****************************************************************************/
static void ** pp_global_data = NULL;
static void Manage ( intf_thread_t * );
/*****************************************************************************
* Module descriptor
@ -73,9 +68,7 @@ vlc_module_begin();
#else
int i = getenv( "DISPLAY" ) == NULL ? 10 : 90;
#endif
pp_global_data = p_module->p_vlc->pp_global_data;
add_category_hint( N_("Miscellaneous"), NULL );
add_category_hint( N_("Gtk+"), NULL );
add_bool( "gtk-tooltips", 1, GtkHideTooltips,
TOOLTIPS_TEXT, TOOLTIPS_LONGTEXT );
add_integer( "gtk-prefs-maxh", 480, NULL,
@ -87,49 +80,6 @@ vlc_module_begin();
set_program( "gvlc" );
vlc_module_end();
/*****************************************************************************
* g_atexit: kludge to avoid the Gtk+ thread to segfault at exit
*****************************************************************************
* gtk_init() makes several calls to g_atexit() which calls atexit() to
* register tidying callbacks to be called at program exit. Since the Gtk+
* plugin is likely to be unloaded at program exit, we have to export this
* symbol to intercept the g_atexit() calls. Talk about crude hack.
*****************************************************************************/
void g_atexit( GVoidFunc func )
{
intf_thread_t *p_intf;
int i_dummy;
if( pp_global_data == NULL )
{
atexit( func );
return;
}
p_intf = (intf_thread_t *)*pp_global_data;
if( p_intf == NULL )
{
return;
}
for( i_dummy = 0;
i_dummy < MAX_ATEXIT && p_intf->p_sys->pf_callback[i_dummy] != NULL;
i_dummy++ )
{
;
}
if( i_dummy >= MAX_ATEXIT - 1 )
{
msg_Err( p_intf, "too many atexit() callbacks to register" );
return;
}
p_intf->p_sys->pf_callback[i_dummy] = func;
p_intf->p_sys->pf_callback[i_dummy + 1] = NULL;
}
/*****************************************************************************
* Open: initialize and create window
*****************************************************************************/
@ -142,7 +92,14 @@ static int Open( vlc_object_t *p_this )
if( p_intf->p_sys == NULL )
{
msg_Err( p_intf, "out of memory" );
return( 1 );
return VLC_ENOMEM;
}
p_intf->p_sys->p_gtk_main = module_Need( p_this, "gtk_main", "gtk" );
if( p_intf->p_sys->p_gtk_main == NULL )
{
free( p_intf->p_sys );
return VLC_EMODULE;
}
p_intf->pf_run = Run;
@ -159,11 +116,9 @@ static int Open( vlc_object_t *p_this )
p_intf->p_sys->i_playing = -1;
p_intf->p_sys->b_slider_free = 1;
p_intf->p_sys->pf_callback[0] = NULL;
p_intf->p_sys->i_part = 0;
return( 0 );
return VLC_SUCCESS;
}
/*****************************************************************************
@ -180,6 +135,8 @@ static void Close( vlc_object_t *p_this )
msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
module_Unneed( p_intf, p_intf->p_sys->p_gtk_main );
/* Destroy structure */
free( p_intf->p_sys );
}
@ -189,18 +146,9 @@ static void Close( vlc_object_t *p_this )
*****************************************************************************
* this part of the interface is in a separate thread so that we can call
* gtk_main() from within it without annoying the rest of the program.
* XXX: the approach may look kludgy, and probably is, but I could not find
* a better way to dynamically load a Gtk+ interface at runtime.
*****************************************************************************/
static void Run( intf_thread_t *p_intf )
{
/* gtk_init needs to know the command line. We don't care, so we
* give it an empty one */
char *p_args[] = { "" };
char **pp_args = p_args;
int i_args = 1;
int i_dummy;
/* The data types we are allowed to receive */
static GtkTargetEntry target_table[] =
{
@ -209,14 +157,7 @@ static void Run( intf_thread_t *p_intf )
{ "text/plain", 0, DROP_ACCEPT_TEXT_PLAIN }
};
/* Initialize Gtk+ */
/* gtk_init will register stuff with g_atexit, so we need to take
* the global lock if we want to be able to intercept the calls */
vlc_mutex_lock( p_intf->p_vlc->p_global_lock );
*p_intf->p_vlc->pp_global_data = p_intf;
gtk_init( &i_args, &pp_args );
vlc_mutex_unlock( p_intf->p_vlc->p_global_lock );
gdk_threads_enter();
/* Create some useful widgets that will certainly be used */
p_intf->p_sys->p_window = create_intf_window();
@ -298,26 +239,25 @@ static void Run( intf_thread_t *p_intf )
/* Show the control window */
gtk_widget_show( p_intf->p_sys->p_window );
/* Sleep to avoid using all CPU - since some interfaces needs to access
* keyboard events, a 100ms delay is a good compromise */
i_dummy = gtk_timeout_add( INTF_IDLE_SLEEP / 1000, Manage, p_intf );
/* Enter Gtk mode */
gtk_main();
while( !p_intf->b_die )
{
Manage( p_intf );
/* Remove the timeout */
gtk_timeout_remove( i_dummy );
/* Sleep to avoid using all CPU - since some interfaces need to
* access keyboard events, a 100ms delay is a good compromise */
gdk_threads_leave();
msleep( INTF_IDLE_SLEEP );
gdk_threads_enter();
}
/* Destroy the Tooltips structure */
gtk_object_destroy( GTK_OBJECT(p_intf->p_sys->p_tooltips) );
gtk_object_destroy( GTK_OBJECT(p_intf->p_sys->p_messages) );
gtk_object_destroy( GTK_OBJECT(p_intf->p_sys->p_playwin) );
gtk_object_destroy( GTK_OBJECT(p_intf->p_sys->p_popup) );
gtk_object_destroy( GTK_OBJECT(p_intf->p_sys->p_window) );
/* Launch stored callbacks */
for( i_dummy = 0;
i_dummy < MAX_ATEXIT && p_intf->p_sys->pf_callback[i_dummy] != NULL;
i_dummy++ )
{
p_intf->p_sys->pf_callback[i_dummy]();
}
gdk_threads_leave();
}
/* following functions are local */
@ -328,9 +268,8 @@ static void Run( intf_thread_t *p_intf )
* In this function, called approx. 10 times a second, we check what the
* main program wanted to tell us.
*****************************************************************************/
static gint Manage( gpointer p_data )
static void Manage( intf_thread_t *p_intf )
{
#define p_intf ((intf_thread_t *)p_data)
int i_start, i_stop;
vlc_mutex_lock( &p_intf->change_lock );
@ -394,7 +333,7 @@ static gint Manage( gpointer p_data )
}
/* Update the playlist */
GtkPlayListManage( p_data );
GtkPlayListManage( p_intf );
/* Update the input */
if( p_intf->p_sys->p_input == NULL )
@ -475,20 +414,5 @@ static gint Manage( gpointer p_data )
p_intf->p_sys->b_playing = 0;
}
if( p_intf->b_die )
{
vlc_mutex_unlock( &p_intf->change_lock );
/* Prepare to die, young Skywalker */
gtk_main_quit();
/* Just in case */
return( FALSE );
}
vlc_mutex_unlock( &p_intf->change_lock );
return( TRUE );
#undef p_intf
}

0
modules/misc/null/.cvsignore → modules/misc/.cvsignore

2
modules/misc/Makefile

@ -0,0 +1,2 @@
null_SOURCES = null.c
gtk_main_SOURCES = gtk_main.c

245
modules/misc/gtk_main.c

@ -0,0 +1,245 @@
/*****************************************************************************
* gtk_main.c : Gtk+ wrapper for gtk_main
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: gtk_main.c,v 1.1 2002/08/20 18:08:51 sam Exp $
*
* 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
* 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 <vlc/vlc.h>
#include <stdlib.h> /* atexit() */
#include <gtk/gtk.h>
#ifdef HAVE_GNOME_H
# include <gnome.h>
#endif
/*****************************************************************************
* Local prototypes.
*****************************************************************************/
static int Open ( vlc_object_t * );
static void Close ( vlc_object_t * );
static void GtkMain ( vlc_object_t * );
/*****************************************************************************
* The gtk_main_t object.
*****************************************************************************/
#define MAX_ATEXIT 10
typedef struct gtk_main_t
{
VLC_COMMON_MEMBERS
/* XXX: Ugly kludge, see g_atexit */
void ( *pf_callback[MAX_ATEXIT] ) ( void );
} gtk_main_t;
/*****************************************************************************
* Local variables (mutex-protected).
*****************************************************************************/
static void ** pp_global_data = NULL;
static int i_refcount = 0;
static gtk_main_t * p_gtk_main = NULL;
/*****************************************************************************
* Module descriptor
*****************************************************************************/
vlc_module_begin();
pp_global_data = p_module->p_vlc->pp_global_data;
set_description( _("Gtk+ helper module") );
set_capability( "gtk_main", 100 );
add_shortcut( "gtk" );
#ifdef HAVE_GNOME_H
add_shortcut( "gnome" );
#endif
set_callbacks( Open, Close );
vlc_module_end();
/*****************************************************************************
* g_atexit: kludge to avoid the Gtk+ thread to segfault at exit
*****************************************************************************
* gtk_init() makes several calls to g_atexit() which calls atexit() to
* register tidying callbacks to be called at program exit. Since the Gtk+
* plugin is likely to be unloaded at program exit, we have to export this
* symbol to intercept the g_atexit() calls. Talk about crude hack.
*****************************************************************************/
void g_atexit( GVoidFunc func )
{
gtk_main_t *p_this;
int i_dummy;
if( pp_global_data == NULL )
{
atexit( func );
return;
}
p_this = (gtk_main_t *)*pp_global_data;
if( p_this == NULL )
{
/* Looks like this atexit() call wasn't for us. */
return;
}
for( i_dummy = 0;
i_dummy < MAX_ATEXIT && p_this->pf_callback[i_dummy] != NULL;
i_dummy++ )
{
;
}
if( i_dummy >= MAX_ATEXIT - 1 )
{
msg_Err( p_this, "too many atexit() callbacks to register" );
return;
}
p_this->pf_callback[i_dummy] = func;
p_this->pf_callback[i_dummy + 1] = NULL;
}
/*****************************************************************************
* Open: initialize and create window
*****************************************************************************/
static int Open( vlc_object_t *p_this )
{
/* Initialize Gtk+ */
vlc_mutex_lock( p_this->p_vlc->p_global_lock );
if( i_refcount > 0 )
{
i_refcount++;
vlc_mutex_unlock( p_this->p_vlc->p_global_lock );
return VLC_SUCCESS;
}
p_gtk_main = vlc_object_create( p_this, sizeof(gtk_main_t) );
p_gtk_main->pf_callback[0] = NULL;
/* Only initialize gthreads if it's the first time we do it */
if( !g_thread_supported() )
{
g_thread_init( NULL );
}
/* Launch the gtk_main() thread. It will not return until it has
* called gdk_threads_enter(), which ensures us thread safety. */
if( vlc_thread_create( p_gtk_main, "gtk_main", GtkMain, VLC_TRUE ) )
{
vlc_object_destroy( p_gtk_main );
i_refcount--;
vlc_mutex_unlock( p_this->p_vlc->p_global_lock );
return VLC_ETHREAD;
}
i_refcount++;
vlc_mutex_unlock( p_this->p_vlc->p_global_lock );
return VLC_SUCCESS;
}
/*****************************************************************************
* Close: destroy interface window
*****************************************************************************/
static void Close( vlc_object_t *p_this )
{
int i_dummy;
vlc_mutex_lock( p_this->p_vlc->p_global_lock );
i_refcount--;
if( i_refcount > 0 )
{
vlc_mutex_unlock( p_this->p_vlc->p_global_lock );
return;
}
gtk_main_quit();
vlc_thread_join( p_gtk_main );
/* Launch stored callbacks */
for( i_dummy = 0;
i_dummy < MAX_ATEXIT && p_gtk_main->pf_callback[i_dummy] != NULL;
i_dummy++ )
{
p_gtk_main->pf_callback[i_dummy]();
}
vlc_object_destroy( p_gtk_main );
p_gtk_main = NULL;
vlc_mutex_unlock( p_this->p_vlc->p_global_lock );
}
static gint foo(gpointer foo)
{
return TRUE;
}
/*****************************************************************************
* GtkMain: Gtk+ thread
*****************************************************************************
* this part of the interface is in a separate thread so that we can call
* gtk_main() from within it without annoying the rest of the program.
*****************************************************************************/
static void GtkMain( vlc_object_t *p_this )
{
/* gtk_init needs to know the command line. We don't care, so we
* give it an empty one */
static char *p_args[] = { "" };
static char **pp_args = p_args;
static int i_args = 1;
/* gtk_init will register stuff with g_atexit, so we need to have
* the global lock if we want to be able to intercept the calls */
*p_this->p_vlc->pp_global_data = p_gtk_main;
/* FIXME: deprecated ? */
/* gdk_threads_init(); */
#ifdef HAVE_GNOME_H
gnome_init( p_this->p_vlc->psz_object_name, VERSION, i_args, p_args );
#else
gtk_set_locale();
gtk_init( &i_args, &pp_args );
#endif
gdk_threads_enter();
vlc_thread_ready( p_this );
/* If we don't add this simple timeout, gtk_main remains stuck ... */
gtk_timeout_add( INTF_IDLE_SLEEP / 1000, foo, p_this );
/* Enter Gtk mode */
gtk_main();
gdk_threads_leave();
}

2
modules/misc/null/null.c → modules/misc/null.c

@ -2,7 +2,7 @@
* null.c : NULL module for vlc
*****************************************************************************
* Copyright (C) 2000-2001 VideoLAN
* $Id: null.c,v 1.1 2002/08/04 17:23:43 sam Exp $
* $Id: null.c,v 1.1 2002/08/20 18:08:51 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*

1
modules/misc/null/Makefile

@ -1 +0,0 @@
null_SOURCES = null.c

15
mozilla/vlcplugin.c

@ -2,7 +2,7 @@
* vlcplugin.c: a VideoLAN Client plugin for Mozilla
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: vlcplugin.c,v 1.4 2002/08/08 22:28:23 sam Exp $
* $Id: vlcplugin.c,v 1.5 2002/08/20 18:08:51 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
@ -137,10 +137,13 @@ NPError NPP_New( NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc,
return NPERR_GENERIC_ERROR;
}
vlc_set_r( This->p_vlc, "vout", "xvideo,x11,dummy" );
vlc_set_r( This->p_vlc, "intf", "dummy" );
vlc_set_r( This->p_vlc, "audio", 0 );
i_ret = vlc_run_r( This->p_vlc );
if( i_ret )
{
vlc_end_r( This->p_vlc );
vlc_destroy_r( This->p_vlc );
This->p_vlc = NULL;
return NPERR_GENERIC_ERROR;
@ -159,7 +162,7 @@ NPError NPP_New( NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc,
}
else
{
/*__config_PutPsz( This->psz_target, argn[i], argv[i] );*/
/*vlc_set_r( This->psz_target, argn[i], argv[i] );*/
}
}
@ -179,8 +182,6 @@ NPError NPP_Destroy( NPP instance, NPSavedData** save )
if( This->p_vlc != NULL )
{
vlc_stop_r( This->p_vlc );
vlc_end_r( This->p_vlc );
vlc_destroy_r( This->p_vlc );
This->p_vlc = NULL;
}
@ -211,8 +212,8 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
This = (PluginInstance*) instance->pdata;
__config_PutInt( This->p_vlc, "x11-drawable", window->window );
__config_PutInt( This->p_vlc, "xvideo-drawable", window->window );
vlc_set_r( This->p_vlc, "x11-drawable", window->window );
vlc_set_r( This->p_vlc, "xvideo-drawable", window->window );
/*
* PLUGIN DEVELOPERS:
* Before setting window to point to the

443
src/libvlc.c

@ -2,7 +2,7 @@
* libvlc.c: main libvlc source
*****************************************************************************
* Copyright (C) 1998-2002 VideoLAN
* $Id: libvlc.c,v 1.28 2002/08/19 11:13:45 sam Exp $
* $Id: libvlc.c,v 1.29 2002/08/20 18:08:51 sam Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
@ -40,14 +40,6 @@
#include <vlc/vlc.h>
#ifdef HAVE_GETOPT_LONG
# ifdef HAVE_GETOPT_H
# include <getopt.h> /* getopt() */
# endif
#else
# include "GNUgetopt/getopt.h"
#endif
#ifndef WIN32
# include <netinet/in.h> /* BSD: struct in_addr */
#endif
@ -89,8 +81,7 @@ static vlc_mutex_t global_lock;
void * p_global_data;
/* A list of all the currently allocated vlc objects */
static int volatile i_vlc = 0;
static int volatile i_unique = 0;
static int volatile i_vlc = 0;
static vlc_t ** volatile pp_vlc = NULL;
/*****************************************************************************
@ -152,6 +143,7 @@ vlc_error_t vlc_create( void )
vlc_t * vlc_create_r( void )
{
static int i_instance = 0;
vlc_t * p_vlc = NULL;
/* Allocate the main structure */
@ -181,8 +173,8 @@ vlc_t * vlc_create_r( void )
pp_vlc = realloc( pp_vlc, (i_vlc+1) * sizeof( vlc_t * ) );
pp_vlc[ i_vlc ] = p_vlc;
i_vlc++;
p_vlc->i_unique = i_unique;
i_unique++;
p_vlc->i_instance = i_instance;
i_instance++;
vlc_mutex_unlock( p_vlc->p_global_lock );
/* Update the handle status */
@ -207,10 +199,11 @@ vlc_error_t vlc_init( int i_argc, char *ppsz_argv[] )
vlc_error_t vlc_init_r( vlc_t *p_vlc, int i_argc, char *ppsz_argv[] )
{
char p_capabilities[200];
char *p_tmp;
module_t *p_help_module;
playlist_t *p_playlist;
char p_capabilities[200];
char * p_tmp;
vlc_bool_t b_exit;
module_t *p_help_module;
playlist_t *p_playlist;
/* Check that the handle is valid */
if( !p_vlc || p_vlc->i_status != VLC_STATUS_CREATED )
@ -304,27 +297,30 @@ vlc_error_t vlc_init_r( vlc_t *p_vlc, int i_argc, char *ppsz_argv[] )
return VLC_EGENERIC;
}
b_exit = VLC_FALSE;
/* Check for short help option */
if( config_GetInt( p_vlc, "help" ) )
{
fprintf( stderr, _("Usage: %s [options] [parameters] [file]...\n"),
fprintf( stderr, _("Usage: %s [options] [parameters] [files]...\n\n"),
p_vlc->psz_object_name );
Usage( p_vlc, "help" );
Usage( p_vlc, "main" );
vlc_object_detach( p_help_module );
config_Free( p_help_module );
vlc_object_destroy( p_help_module );
module_EndBank( p_vlc );
msg_Destroy( p_vlc );
return VLC_EEXIT;
Usage( p_vlc, "help" );
b_exit = VLC_TRUE;
}
/* Check for version option */
if( config_GetInt( p_vlc, "version" ) )
else if( config_GetInt( p_vlc, "version" ) )
{
Version();
vlc_object_detach( p_help_module );
b_exit = VLC_TRUE;
}
/* Hack: remove the help module here */
vlc_object_detach( p_help_module );
/* End hack */
if( b_exit )
{
config_Free( p_help_module );
vlc_object_destroy( p_help_module );
module_EndBank( p_vlc );
@ -332,10 +328,6 @@ vlc_error_t vlc_init_r( vlc_t *p_vlc, int i_argc, char *ppsz_argv[] )
return VLC_EEXIT;
}
/* Hack: remove the help module here */
vlc_object_detach( p_help_module );
/* End hack */
/*
* Load the builtins and plugins into the module_bank.
* We have to do it before config_Load*() because this also gets the
@ -356,36 +348,19 @@ vlc_error_t vlc_init_r( vlc_t *p_vlc, int i_argc, char *ppsz_argv[] )
{
Usage( p_vlc, p_tmp );
free( p_tmp );
vlc_object_detach( p_help_module );
config_Free( p_help_module );
vlc_object_destroy( p_help_module );
module_EndBank( p_vlc );
msg_Destroy( p_vlc );
return VLC_EGENERIC;
b_exit = VLC_TRUE;
}
/* Check for long help option */
if( config_GetInt( p_vlc, "longhelp" ) )
else if( config_GetInt( p_vlc, "longhelp" ) )
{
Usage( p_vlc, NULL );
vlc_object_detach( p_help_module );
config_Free( p_help_module );
vlc_object_destroy( p_help_module );
module_EndBank( p_vlc );
msg_Destroy( p_vlc );
return VLC_EEXIT;
b_exit = VLC_TRUE;
}
/* Check for module list option */
if( config_GetInt( p_vlc, "list" ) )
else if( config_GetInt( p_vlc, "list" ) )
{
ListModules( p_vlc );
vlc_object_detach( p_help_module );
config_Free( p_help_module );
vlc_object_destroy( p_help_module );
module_EndBank( p_vlc );
msg_Destroy( p_vlc );
return VLC_EEXIT;
b_exit = VLC_TRUE;
}
/* Hack: remove the help module here */
@ -394,6 +369,13 @@ vlc_error_t vlc_init_r( vlc_t *p_vlc, int i_argc, char *ppsz_argv[] )
vlc_object_destroy( p_help_module );
/* End hack */
if( b_exit )
{
module_EndBank( p_vlc );
msg_Destroy( p_vlc );
return VLC_EEXIT;
}
/*
* Override default configuration with config file settings
*/
@ -615,160 +597,126 @@ vlc_error_t vlc_add_intf_r( vlc_t *p_vlc, const char *psz_module,
}
/*****************************************************************************
* vlc_stop: stop playing.
* vlc_destroy: stop playing and destroy everything.
*****************************************************************************
* This function requests the interface threads to finish, waits for their
* This function requests the running threads to finish, waits for their
* termination, and destroys their structure.
*****************************************************************************/
vlc_error_t vlc_stop( void )
vlc_error_t vlc_destroy( void )
{
return vlc_stop_r( ( i_vlc == 1 ) ? pp_vlc[0] : NULL );
return vlc_destroy_r( ( i_vlc == 1 ) ? pp_vlc[0] : NULL );
}
vlc_error_t vlc_stop_r( vlc_t *p_vlc )
vlc_error_t vlc_destroy_r( vlc_t *p_vlc )
{
intf_thread_t *p_intf;
playlist_t *p_playlist;
vout_thread_t *p_vout;
aout_instance_t *p_aout;
int i_index;
intf_thread_t * p_intf;
playlist_t * p_playlist;
vout_thread_t * p_vout;
aout_instance_t * p_aout;
/* Check that the handle is valid */
if( !p_vlc || p_vlc->i_status != VLC_STATUS_RUNNING )
if( !p_vlc || (p_vlc->i_status != VLC_STATUS_RUNNING
&& p_vlc->i_status != VLC_STATUS_STOPPED
&& p_vlc->i_status != VLC_STATUS_CREATED) )
{
fprintf( stderr, "error: invalid status (!RUNNING)\n" );
fprintf( stderr, "error: invalid status "
"(!RUNNING&&!STOPPED&&!CREATED)\n" );
return VLC_ESTATUS;
}
/*
* Ask the interfaces to stop and destroy them
*/
msg_Dbg( p_vlc, "removing all interfaces" );
while( (p_intf = vlc_object_find( p_vlc, VLC_OBJECT_INTF, FIND_CHILD )) )
{
intf_StopThread( p_intf );
vlc_object_detach( p_intf );
vlc_object_release( p_intf );
intf_Destroy( p_intf );
}
/*
* Free playlists
*/
msg_Dbg( p_vlc, "removing all playlists" );
while( (p_playlist = vlc_object_find( p_vlc, VLC_OBJECT_PLAYLIST,
FIND_CHILD )) )
{
vlc_object_detach( p_playlist );
vlc_object_release( p_playlist );
playlist_Destroy( p_playlist );
}
/*
* Free video outputs
*/
msg_Dbg( p_vlc, "removing all video outputs" );
while( (p_vout = vlc_object_find( p_vlc, VLC_OBJECT_VOUT, FIND_CHILD )) )
if( p_vlc->i_status == VLC_STATUS_RUNNING )
{
vlc_object_detach( p_vout );
vlc_object_release( p_vout );
vout_DestroyThread( p_vout );
}
/*
* Free audio outputs
*/
msg_Dbg( p_vlc, "removing all audio outputs" );
while( (p_aout = vlc_object_find( p_vlc, VLC_OBJECT_AOUT, FIND_CHILD )) )
{
vlc_object_detach( (vlc_object_t *)p_aout );
vlc_object_release( (vlc_object_t *)p_aout );
aout_DeleteInstance( p_aout );
}
/*
* Ask the interfaces to stop and destroy them
*/
msg_Dbg( p_vlc, "removing all interfaces" );
while( (p_intf = vlc_object_find( p_vlc, VLC_OBJECT_INTF,
FIND_CHILD )) )
{
intf_StopThread( p_intf );
vlc_object_detach( p_intf );
vlc_object_release( p_intf );
intf_Destroy( p_intf );
}
/* Update the handle status */
p_vlc->i_status = VLC_STATUS_STOPPED;
/*
* Free playlists
*/
msg_Dbg( p_vlc, "removing all playlists" );
while( (p_playlist = vlc_object_find( p_vlc, VLC_OBJECT_PLAYLIST,
FIND_CHILD )) )
{
vlc_object_detach( p_playlist );
vlc_object_release( p_playlist );
playlist_Destroy( p_playlist );
}
return VLC_SUCCESS;
}
/*
* Free video outputs
*/
msg_Dbg( p_vlc, "removing all video outputs" );
while( (p_vout = vlc_object_find( p_vlc, VLC_OBJECT_VOUT,
FIND_CHILD )) )
{
vlc_object_detach( p_vout );
vlc_object_release( p_vout );
vout_DestroyThread( p_vout );
}
/*****************************************************************************
* vlc_end: uninitialize everything.
*****************************************************************************
* This function uninitializes every vlc component that was activated in
* vlc_init: audio and video outputs, playlist, module bank and message queue.
*****************************************************************************/
vlc_error_t vlc_end( void )
{
return vlc_end_r( ( i_vlc == 1 ) ? pp_vlc[0] : NULL );
}
/*
* Free audio outputs
*/
msg_Dbg( p_vlc, "removing all audio outputs" );
while( (p_aout = vlc_object_find( p_vlc, VLC_OBJECT_AOUT,
FIND_CHILD )) )
{
vlc_object_detach( (vlc_object_t *)p_aout );
vlc_object_release( (vlc_object_t *)p_aout );
aout_DeleteInstance( p_aout );
}
vlc_error_t vlc_end_r( vlc_t *p_vlc )
{
/* Check that the handle is valid */
if( !p_vlc || p_vlc->i_status != VLC_STATUS_STOPPED )
{
fprintf( stderr, "error: invalid status (!STOPPED)\n" );
return VLC_ESTATUS;
/* Update the handle status */
p_vlc->i_status = VLC_STATUS_STOPPED;
}
/*
* Go back into channel 0 which is the network
*/
if( config_GetInt( p_vlc, "network-channel" ) && p_vlc->p_channel )
if( p_vlc->i_status == VLC_STATUS_STOPPED )
{
network_ChannelJoin( p_vlc, COMMON_CHANNEL );
}
/*
* Free allocated memory
*/
if( p_vlc->p_memcpy_module != NULL )
{
module_Unneed( p_vlc, p_vlc->p_memcpy_module );
}
free( p_vlc->psz_homedir );
/*
* Free module bank
*/
module_EndBank( p_vlc );
/*
* System specific cleaning code
*/
system_End( p_vlc );
/*
* Terminate messages interface and program
*/
msg_Destroy( p_vlc );
/* Update the handle status */
p_vlc->i_status = VLC_STATUS_CREATED;
return VLC_SUCCESS;
}
/*****************************************************************************
* vlc_destroy: free allocated resources.
*****************************************************************************
* This function frees the previously allocated vlc_t structure.
*****************************************************************************/
vlc_error_t vlc_destroy( void )
{
return vlc_destroy_r( ( i_vlc == 1 ) ? pp_vlc[0] : NULL );
}
vlc_error_t vlc_destroy_r( vlc_t *p_vlc )
{
int i_index;
/*
* Go back into channel 0 which is the network
*/
if( config_GetInt( p_vlc, "network-channel" ) && p_vlc->p_channel )
{
network_ChannelJoin( p_vlc, COMMON_CHANNEL );
}
/*
* Free allocated memory
*/
if( p_vlc->p_memcpy_module != NULL )
{
module_Unneed( p_vlc, p_vlc->p_memcpy_module );
}
free( p_vlc->psz_homedir );
/*
* Free module bank
*/
module_EndBank( p_vlc );
/*
* System specific cleaning code
*/
system_End( p_vlc );
/*
* Terminate messages interface and program
*/
msg_Destroy( p_vlc );
/* Check that the handle is valid */
if( !p_vlc || p_vlc->i_status != VLC_STATUS_CREATED )
{
fprintf( stderr, "error: invalid status (!CREATED)\n" );
return VLC_ESTATUS;
/* Update the handle status */
p_vlc->i_status = VLC_STATUS_CREATED;
}
/* Update the handle status, just in case */
@ -913,6 +861,108 @@ vlc_error_t vlc_add_target_r( vlc_t *p_vlc, const char *psz_target,
return err;
}
/*****************************************************************************
* vlc_set: set a vlc variable
*****************************************************************************
*
*****************************************************************************/
vlc_error_t vlc_set( const char *psz_var, const char *psz_val )
{
return vlc_set_r( ( i_vlc == 1 ) ? pp_vlc[0] : NULL, psz_var, psz_val );
}
vlc_error_t vlc_set_r( vlc_t *p_vlc, const char *psz_var, const char *psz_val )
{
module_config_t *p_config;
if( !p_vlc )
{
fprintf( stderr, "error: invalid status\n" );
return VLC_ESTATUS;
}
p_config = config_FindConfig( VLC_OBJECT(p_vlc), psz_var );
if( !p_config )
{
msg_Err( p_vlc, "option %s does not exist", psz_var );
return VLC_EGENERIC;
}
vlc_mutex_lock( p_config->p_lock );
switch( p_config->i_type )
{
case CONFIG_ITEM_BOOL:
if( psz_val && *psz_val )
{
if( !strcmp( psz_val, "off" ) || !strcmp( psz_val, "no" ) )
{
p_config->i_value = VLC_FALSE;
}
else
{
p_config->i_value = atoi( psz_val );
}
}
else
{
p_config->i_value = VLC_TRUE;
}
break;
case CONFIG_ITEM_INTEGER:
if( psz_val && *psz_val )
{
p_config->i_value = atoi( psz_val );
}
else
{
p_config->i_value = 0;
}
break;
case CONFIG_ITEM_FLOAT:
if( psz_val && *psz_val )
{
p_config->f_value = (float)atof( psz_val );
}
else
{
p_config->f_value = 0.0;
}
break;
case CONFIG_ITEM_STRING:
case CONFIG_ITEM_FILE:
case CONFIG_ITEM_MODULE:
default:
if( p_config->psz_value )
{
free( p_config->psz_value );
}
if( psz_val )
{
p_config->psz_value = strdup( psz_val );
}
else
{
p_config->psz_value = NULL;
}
break;
}
if( p_config->pf_callback )
{
vlc_mutex_unlock( p_config->p_lock );
p_config->pf_callback( VLC_OBJECT(p_vlc) );
}
else
{
vlc_mutex_unlock( p_config->p_lock );
}
return VLC_SUCCESS;
}
/* following functions are local */
/*****************************************************************************
@ -977,8 +1027,7 @@ static void Usage( vlc_t *p_this, const char *psz_module_name )
*pp_parser ;
pp_parser++ )
{
vlc_bool_t b_help_module =
!strcmp( "help", (*pp_parser)->psz_object_name );
vlc_bool_t b_help_module;
if( psz_module_name && strcmp( psz_module_name,
(*pp_parser)->psz_object_name ) )
@ -992,10 +1041,9 @@ static void Usage( vlc_t *p_this, const char *psz_module_name )
continue;
}
/* Print module name */
fprintf( stderr, _("%s module options:\n\n"),
(*pp_parser)->psz_object_name );
b_help_module = !strcmp( "help", (*pp_parser)->psz_object_name );
/* Print module options */
for( p_item = (*pp_parser)->p_config;
p_item->i_type != CONFIG_HINT_END;
p_item++ )
@ -1049,7 +1097,7 @@ static void Usage( vlc_t *p_this, const char *psz_module_name )
break;
}
/* Add short option */
/* Add short option if any */
if( p_item->i_short )
{
psz_format[2] = '-';
@ -1071,6 +1119,10 @@ static void Usage( vlc_t *p_this, const char *psz_module_name )
if( p_item->i_type == CONFIG_ITEM_BOOL
&& !b_help_module )
{
/* If option is of type --foo-bar, we print its counterpart
* as --no-foo-bar, but if it is of type --foobar (without
* dashes in the name) we print it as --nofoobar. Both
* values are of course valid, only the display changes. */
vlc_bool_t b_dash = VLC_FALSE;
psz_prefix = p_item->psz_name;
while( *psz_prefix )
@ -1124,9 +1176,6 @@ static void Usage( vlc_t *p_this, const char *psz_module_name )
}
}
}
fprintf( stderr, "\n" );
}
/* Release the module list */
@ -1157,7 +1206,7 @@ static void ListModules( vlc_t *p_this )
#endif
/* Usage */
fprintf( stderr, _("Usage: %s [options] [parameters] [file]...\n\n"),
fprintf( stderr, _("Usage: %s [options] [parameters] [files]...\n\n"),
p_this->p_vlc->psz_object_name );
fprintf( stderr, _("[module] [description]\n") );

10
src/vlc.c

@ -2,7 +2,7 @@
* vlc.c: the vlc player
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
* $Id: vlc.c,v 1.9 2002/08/19 11:13:45 sam Exp $
* $Id: vlc.c,v 1.10 2002/08/20 18:08:51 sam Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
@ -103,13 +103,7 @@ int main( int i_argc, char *ppsz_argv[] )
/* Add a blocking interface and keep the return value */
err = vlc_add_intf( NULL, VLC_TRUE );
/* Finish the interface */
vlc_stop();
/* Finish all threads */
vlc_end();
/* Destroy the libvlc structure */
/* Finish the threads and destroy the libvlc structure */
vlc_destroy();
return err;

Loading…
Cancel
Save