From a5ee53f77453343410be793192b3a7cacb2ce08d Mon Sep 17 00:00:00 2001 From: Gildas Bazin Date: Tue, 20 Apr 2004 15:05:24 +0000 Subject: [PATCH] * include/vlc/vlc.h: added a b_play parameter to the libvlc VLC_AddIntf() prototype. When true, the interface will automatically start playing the playlist when (and only when) it is ready. (particularly useful for embedded vouts). * src/libvlc.c, src/vlc.c: new VLC_AddIntf() prototype. * src/interface/interface.c: if the interface doesn't support "playing on start", do it ourselves. * modules/gui/wxwindows/wxwindows.cpp: implement "play on start". --- include/vlc/vlc.h | 2 +- include/vlc_interface.h | 1 + modules/gui/wxwindows/wxwindows.cpp | 16 ++++++++++++++++ src/interface/interface.c | 3 +++ src/libvlc.c | 14 ++++++++++---- src/vlc.c | 9 +++------ 6 files changed, 34 insertions(+), 11 deletions(-) diff --git a/include/vlc/vlc.h b/include/vlc/vlc.h index 3017b3ad10..091872af5a 100644 --- a/include/vlc/vlc.h +++ b/include/vlc/vlc.h @@ -226,7 +226,7 @@ int VLC_Set ( int, char const *, vlc_value_t ); */ int VLC_Get ( int, char const *, vlc_value_t * ); -int VLC_AddIntf ( int, char const *, vlc_bool_t ); +int VLC_AddIntf ( int, char const *, vlc_bool_t, vlc_bool_t ); int VLC_AddTarget ( int, char const *, const char **, int, int, int ); int VLC_Play ( int ); diff --git a/include/vlc_interface.h b/include/vlc_interface.h index 7474df5e76..e2af220641 100644 --- a/include/vlc_interface.h +++ b/include/vlc_interface.h @@ -50,6 +50,7 @@ struct intf_thread_t /* Thread properties and locks */ vlc_bool_t b_block; + vlc_bool_t b_play; /* Specific interfaces */ intf_console_t * p_console; /** console */ diff --git a/modules/gui/wxwindows/wxwindows.cpp b/modules/gui/wxwindows/wxwindows.cpp index fc52d1c2c9..0454ef5481 100644 --- a/modules/gui/wxwindows/wxwindows.cpp +++ b/modules/gui/wxwindows/wxwindows.cpp @@ -148,6 +148,9 @@ static int Open( vlc_object_t *p_this ) p_intf->pf_show_dialog = NULL; + /* We support play on start */ + p_intf->b_play = VLC_TRUE; + return VLC_SUCCESS; } @@ -306,6 +309,19 @@ bool Instance::OnInit() /* OK, initialization is over */ vlc_thread_ready( p_intf ); + /* Check if we need to start playing */ + if( p_intf->b_play ) + { + playlist_t *p_playlist = + (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, + FIND_ANYWHERE ); + if( p_playlist ) + { + playlist_Play( p_playlist ); + vlc_object_release( p_playlist ); + } + } + /* Return TRUE to tell program to continue (FALSE would terminate) */ return TRUE; } diff --git a/src/interface/interface.c b/src/interface/interface.c index fc95c5d935..d2de9a84c2 100644 --- a/src/interface/interface.c +++ b/src/interface/interface.c @@ -278,6 +278,9 @@ static void RunInterface( intf_thread_t *p_intf ) /* Give control to the interface */ p_intf->pf_run( p_intf ); + /* Reset play on start status */ + p_intf->b_play = VLC_FALSE; + /* Provide ability to switch the main interface on the fly */ while( p_intf->psz_switch_intf ) { diff --git a/src/libvlc.c b/src/libvlc.c index d488aa9bb8..51b9fad3bd 100644 --- a/src/libvlc.c +++ b/src/libvlc.c @@ -616,7 +616,7 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] ) if( psz_temp ) { sprintf( psz_temp, "%s,none", psz_module ); - VLC_AddIntf( 0, psz_temp, VLC_FALSE ); + VLC_AddIntf( 0, psz_temp, VLC_FALSE, VLC_FALSE ); free( psz_temp ); } } @@ -628,7 +628,7 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] ) /* * Allways load the hotkeys interface if it exists */ - VLC_AddIntf( 0, "hotkeys,none", VLC_FALSE ); + VLC_AddIntf( 0, "hotkeys,none", VLC_FALSE, VLC_FALSE ); /* * FIXME: kludge to use a p_vlc-local variable for the Mozilla plugin @@ -661,9 +661,11 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] ) * This function opens an interface plugin and runs it. If b_block is set * to 0, VLC_AddIntf will return immediately and let the interface run in a * separate thread. If b_block is set to 1, VLC_AddIntf will continue until - * user requests to quit. + * user requests to quit. If b_play is set to 1, VLC_AddIntf will start playing + * the playlist when it is completely initialised. *****************************************************************************/ -int VLC_AddIntf( int i_object, char const *psz_module, vlc_bool_t b_block ) +int VLC_AddIntf( int i_object, char const *psz_module, + vlc_bool_t b_block, vlc_bool_t b_play ) { int i_err; intf_thread_t *p_intf; @@ -684,7 +686,11 @@ int VLC_AddIntf( int i_object, char const *psz_module, vlc_bool_t b_block ) return VLC_EGENERIC; } + /* Interface doesn't handle play on start so do it ourselves */ + if( !p_intf->b_play && b_play ) VLC_Play( i_object ); + /* Try to run the interface */ + p_intf->b_play = b_play; p_intf->b_block = b_block; i_err = intf_RunThread( p_intf ); if( i_err ) diff --git a/src/vlc.c b/src/vlc.c index 1e4d9adea8..e9ab65fa3c 100644 --- a/src/vlc.c +++ b/src/vlc.c @@ -2,7 +2,7 @@ * vlc.c: the vlc player ***************************************************************************** * Copyright (C) 1998-2004 VideoLAN - * $Id: vlc.c,v 1.21 2004/01/25 17:16:05 zorglub Exp $ + * $Id$ * * Authors: Vincent Seguin * Samuel Hocevar @@ -98,11 +98,8 @@ int main( int i_argc, char *ppsz_argv[] ) return i_ret; } - /* Run libvlc, in non-blocking mode */ - i_ret = VLC_Play( 0 ); - - /* Add a blocking interface and keep the return value */ - i_ret = VLC_AddIntf( 0, NULL, VLC_TRUE ); + /* Add a blocking interface, start playing, and keep the return value */ + i_ret = VLC_AddIntf( 0, NULL, VLC_TRUE, VLC_TRUE ); /* Finish the threads */ VLC_Stop( 0 ); -- 2.39.2