Commit f0ec49da authored by Sam Hocevar's avatar Sam Hocevar

* ./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.
parent a890c0ee
......@@ -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@
......
This diff is collapsed.
......@@ -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)
......
......@@ -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
......
......@@ -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 */
......
......@@ -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 );
......
......@@ -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;
}
}
}
......@@ -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 */