X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=plugins%2Fqt%2Fintf_qt.cpp;h=d4a28ae7d880e5e22329242247c7d0077a08a941;hb=bf9b62a4ea50a2ac124711378775c1def87243ca;hp=06352553991a8718c1416a431c8cfecf12ddee18;hpb=79a45f72ac0e4bda8f2796bf7ffed7ef7fc7f3f8;p=vlc diff --git a/plugins/qt/intf_qt.cpp b/plugins/qt/intf_qt.cpp index 0635255399..d4a28ae7d8 100644 --- a/plugins/qt/intf_qt.cpp +++ b/plugins/qt/intf_qt.cpp @@ -2,7 +2,7 @@ * intf_qt.cpp: Qt interface ***************************************************************************** * Copyright (C) 1999, 2000 VideoLAN - * $Id: intf_qt.cpp,v 1.3 2001/04/15 10:54:46 sam Exp $ + * $Id: intf_qt.cpp,v 1.17 2002/07/20 18:01:43 sam Exp $ * * Authors: Samuel Hocevar * @@ -21,39 +21,16 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. *****************************************************************************/ -extern "C" -{ - -#define MODULE_NAME qt -#include "modules_inner.h" - /***************************************************************************** * Preamble *****************************************************************************/ -#include "defs.h" - #include /* ENOMEM */ #include /* free() */ #include /* strerror() */ #include -#include "config.h" -#include "common.h" -#include "threads.h" -#include "mtime.h" -#include "tests.h" -#include "modules.h" - -#include "stream_control.h" -#include "input_ext-intf.h" - -#include "intf_msg.h" -#include "intf_playlist.h" -#include "interface.h" - -#include "main.h" - -} /* extern "C" */ +#include +#include #include #include @@ -111,10 +88,10 @@ public: ~IntfWindow(); private slots: - void Manage( void ); + void Manage ( void ); void FileOpen ( void ); - void FileQuit ( void ) { p_intf->b_die = 1; }; + void FileQuit ( void ); void PlaybackPlay ( void ); void PlaybackPause ( void ); @@ -127,8 +104,7 @@ private slots: void DateDisplay ( int ); void About ( void ); - void Unimplemented( void ) { intf_WarnMsg( 3, "intf warning: " - "unimplemented function" ); }; + void Unimplemented( void ) { msg_Warn( p_intf, "unimplemented" ); }; private: intf_thread_t *p_intf; @@ -140,11 +116,7 @@ private: QLabel *p_date; }; -#ifdef BUILTIN -# include "intf_qt-BUILTIN.moc" -#else -# include "intf_qt.moc" -#endif +#include "intf_qt.moc" #define SLIDER_MIN 0x00000 #define SLIDER_MAX 0x10000 @@ -153,17 +125,17 @@ private: /***************************************************************************** * intf_sys_t: description and status of Qt interface *****************************************************************************/ -typedef struct intf_sys_s +struct intf_sys_t { QApplication *p_app; IntfWindow *p_window; -} intf_sys_t; + input_thread_t *p_input; +}; /***************************************************************************** * Local prototypes. *****************************************************************************/ -static int intf_Probe ( probedata_t *p_data ); static int intf_Open ( intf_thread_t *p_intf ); static void intf_Close ( intf_thread_t *p_intf ); static void intf_Run ( intf_thread_t *p_intf ); @@ -177,7 +149,6 @@ extern "C" void _M( intf_getfunctions )( function_list_t * p_function_list ) { - p_function_list->pf_probe = intf_Probe; p_function_list->functions.intf.pf_open = intf_Open; p_function_list->functions.intf.pf_close = intf_Close; p_function_list->functions.intf.pf_run = intf_Run; @@ -185,27 +156,6 @@ void _M( intf_getfunctions )( function_list_t * p_function_list ) } -/***************************************************************************** - * intf_Probe: probe the interface and return a score - ***************************************************************************** - * This function tries to initialize Qt and returns a score to the - * plugin manager so that it can select the best plugin. - *****************************************************************************/ -static int intf_Probe( probedata_t *p_data ) -{ - if( TestMethod( INTF_METHOD_VAR, "qt" ) ) - { - return( 999 ); - } - - if( TestProgram( "qvlc" ) ) - { - return( 180 ); - } - - return( 80 ); -} - /***************************************************************************** * intf_Open: initialize and create window *****************************************************************************/ @@ -218,8 +168,8 @@ static int intf_Open( intf_thread_t *p_intf ) p_intf->p_sys = (intf_sys_t *)malloc( sizeof( intf_sys_t ) ); if( p_intf->p_sys == NULL ) { - intf_ErrMsg( "intf error: %s", strerror(ENOMEM) ); - return( 1 ); + msg_Err( p_intf, "out of memory" ); + return 1; } /* Create the C++ objects */ @@ -229,7 +179,9 @@ static int intf_Open( intf_thread_t *p_intf ) /* Tell the world we are here */ p_intf->p_sys->p_window->setCaption( VOUT_TITLE " (Qt interface)" ); - return( 0 ); + p_intf->p_sys->p_input = NULL; + + return 0; } /***************************************************************************** @@ -237,6 +189,11 @@ static int intf_Open( intf_thread_t *p_intf ) *****************************************************************************/ static void intf_Close( intf_thread_t *p_intf ) { + if( p_intf->p_sys->p_input ) + { + vlc_object_release( p_intf->p_sys->p_input ); + } + /* Get rid of the C++ objects */ delete p_intf->p_sys->p_window; delete p_intf->p_sys->p_app; @@ -405,15 +362,15 @@ IntfWindow::~IntfWindow( void ) *****************************************************************************/ void IntfWindow::DateDisplay( int i_range ) { - if( p_intf->p_input != NULL ) + if( p_intf->p_sys->p_input ) { char psz_time[ OFFSETTOTIME_MAX_SIZE ]; - vlc_mutex_lock( &p_intf->p_input->stream.stream_lock ); - p_date->setText( input_OffsetToTime( p_intf->p_input, psz_time, - ( p_intf->p_input->stream.p_selected_area->i_size * i_range ) - / SLIDER_MAX ) ); - vlc_mutex_unlock( &p_intf->p_input->stream.stream_lock ); + vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock ); + p_date->setText( input_OffsetToTime( p_intf->p_sys->p_input, psz_time, + ( p_intf->p_sys->p_input->stream.p_selected_area->i_size * i_range ) + / SLIDER_MAX ) ); + vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock ); } } @@ -425,6 +382,7 @@ void IntfWindow::DateDisplay( int i_range ) *****************************************************************************/ void IntfWindow::FileOpen( void ) { + playlist_t *p_playlist; QString file = QFileDialog::getOpenFileName( QString::null, QString::null, this ); @@ -434,10 +392,27 @@ void IntfWindow::FileOpen( void ) } else { - intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, file.latin1() ); + p_playlist = (playlist_t *) + vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); + if( p_playlist == NULL ) + { + return; + } + + playlist_Add( p_playlist, file.latin1(), + PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END ); + vlc_object_release( p_playlist ); } } +/***************************************************************************** + * FileQuit: terminate vlc + *****************************************************************************/ +void IntfWindow::FileQuit( void ) +{ + p_intf->p_vlc->b_die = VLC_TRUE; +} + /***************************************************************************** * About: display the "about" box ***************************************************************************** @@ -447,7 +422,7 @@ void IntfWindow::About( void ) { QMessageBox::about( this, "About", "VideoLAN Client\n" - "(C) 1996, 1997, 1998, 1999, 2000, 2001 - the VideoLAN Team\n" + "(C) 1996, 1997, 1998, 1999, 2000, 2001, 2002 - the VideoLAN Team\n" "\n" "This is the VideoLAN client, a DVD and MPEG player.\n" "It can play MPEG and MPEG 2 files from a file " @@ -464,12 +439,24 @@ void IntfWindow::About( void ) *****************************************************************************/ void IntfWindow::Manage( void ) { + /* Update the input */ + if( p_intf->p_sys->p_input == NULL ) + { + p_intf->p_sys->p_input = (input_thread_t *) + vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE ); + } + else if( p_intf->p_sys->p_input->b_dead ) + { + vlc_object_release( p_intf->p_sys->p_input ); + p_intf->p_sys->p_input = NULL; + } + /* Manage the slider */ - if( p_intf->p_input != NULL ) + if( p_intf->p_sys->p_input && p_intf->p_sys->p_input->stream.b_seekable ) { int i_value = p_slider->value(); -#define p_area p_intf->p_input->stream.p_selected_area +#define p_area p_intf->p_sys->p_input->stream.p_selected_area /* If the user hasn't touched the slider since the last time, * then the input can safely change it */ if( i_value == p_slider->oldvalue() ) @@ -485,7 +472,7 @@ void IntfWindow::Manage( void ) { off_t i_seek = ( i_value * p_area->i_size ) / SLIDER_MAX; - input_Seek( p_intf->p_input, i_seek ); + input_Seek( p_intf->p_sys->p_input, i_seek, INPUT_SEEK_SET ); /* Update the old value */ p_slider->setOldValue( i_value ); @@ -500,16 +487,9 @@ void IntfWindow::Manage( void ) p_intf->b_menu_change = 0; } - /* Manage core vlc functions through the callback */ - p_intf->pf_manage( p_intf ); - if( p_intf->b_die ) { - /* Prepare to die, young Skywalker */ qApp->quit(); - - /* Just in case */ - return; } } @@ -518,9 +498,9 @@ void IntfWindow::Manage( void ) *****************************************************************************/ void IntfWindow::PlaybackPlay( void ) { - if( p_intf->p_input != NULL ) + if( p_intf->p_sys->p_input != NULL ) { - input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY ); + input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY ); } } @@ -529,9 +509,9 @@ void IntfWindow::PlaybackPlay( void ) *****************************************************************************/ void IntfWindow::PlaybackPause( void ) { - if( p_intf->p_input != NULL ) + if( p_intf->p_sys->p_input != NULL ) { - input_SetStatus( p_intf->p_input, INPUT_STATUS_PAUSE ); + input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PAUSE ); } } @@ -540,9 +520,9 @@ void IntfWindow::PlaybackPause( void ) *****************************************************************************/ void IntfWindow::PlaybackSlow( void ) { - if( p_intf->p_input != NULL ) + if( p_intf->p_sys->p_input != NULL ) { - input_SetStatus( p_intf->p_input, INPUT_STATUS_SLOWER ); + input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_SLOWER ); } } @@ -551,9 +531,9 @@ void IntfWindow::PlaybackSlow( void ) *****************************************************************************/ void IntfWindow::PlaybackFast( void ) { - if( p_intf->p_input != NULL ) + if( p_intf->p_sys->p_input != NULL ) { - input_SetStatus( p_intf->p_input, INPUT_STATUS_FASTER ); + input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_FASTER ); } } @@ -562,13 +542,16 @@ void IntfWindow::PlaybackFast( void ) *****************************************************************************/ void IntfWindow::PlaylistPrev( void ) { - if( p_intf->p_input != NULL ) + playlist_t *p_playlist = (playlist_t *) + vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); + + if( p_playlist == NULL ) { - /* FIXME: temporary hack */ - intf_PlaylistPrev( p_main->p_playlist ); - intf_PlaylistPrev( p_main->p_playlist ); - p_intf->p_input->b_eof = 1; + return; } + + playlist_Prev( p_playlist ); + vlc_object_release( p_playlist ); } /***************************************************************************** @@ -576,11 +559,16 @@ void IntfWindow::PlaylistPrev( void ) *****************************************************************************/ void IntfWindow::PlaylistNext( void ) { - if( p_intf->p_input != NULL ) + playlist_t *p_playlist = (playlist_t *) + vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); + + if( p_playlist == NULL ) { - /* FIXME: temporary hack */ - p_intf->p_input->b_eof = 1; + return; } + + playlist_Next( p_playlist ); + vlc_object_release( p_playlist ); } /*****************************************************************************