* timer.cpp : wxWindows plugin for vlc
*****************************************************************************
* Copyright (C) 2000-2001 VideoLAN
- * $Id: timer.cpp,v 1.12 2003/03/30 19:56:11 gbazin Exp $
+ * $Id: timer.cpp,v 1.33 2003/10/14 22:41:41 gbazin Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
#include <stdio.h>
#include <vlc/vlc.h>
-
-#ifdef WIN32 /* mingw32 hack */
-#undef Yield
-#undef CreateDialog
-#endif
-
-/* Let vlc take care of the i18n stuff */
-#define WXINTL_NO_GETTEXT_MACRO
-
-#include <wx/wxprec.h>
-#include <wx/wx.h>
-#include <wx/timer.h>
-
+#include <vlc/aout.h>
#include <vlc/intf.h>
#include "wxwindows.h"
+#include <wx/timer.h>
-void DisplayStreamDate( wxControl *, intf_thread_t *, int );
+//void DisplayStreamDate( wxControl *, intf_thread_t *, int );
+
+/* Callback prototype */
+static int PopupMenuCB( vlc_object_t *p_this, const char *psz_variable,
+ vlc_value_t old_val, vlc_value_t new_val, void *param );
/*****************************************************************************
* Constructor.
p_intf = _p_intf;
p_main_interface = _p_main_interface;
i_old_playing_status = PAUSE_S;
+ i_old_rate = DEFAULT_RATE;
+
+ /* Register callback for the intf-popupmenu variable */
+ playlist_t *p_playlist =
+ (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
+ FIND_ANYWHERE );
+ if( p_playlist != NULL )
+ {
+ var_AddCallback( p_playlist, "intf-popupmenu", PopupMenuCB, p_intf );
+ vlc_object_release( p_playlist );
+ }
Start( 100 /*milliseconds*/, wxTIMER_CONTINUOUS );
}
/*****************************************************************************
* Private methods.
*****************************************************************************/
-/*****************************************************************************
- * wxModeManage: actualise the aspect of the interface whenever the input
- * changes.
- *****************************************************************************
- * The lock has to be taken before you call the function.
- *****************************************************************************/
-static int wxModeManage( intf_thread_t * p_intf )
-{
- return 0;
-}
-
-/*****************************************************************************
- * wxSetupMenus: function that generates title/chapter/audio/subpic
- * menus with help from preceding functions
- *****************************************************************************
- * Function called with the lock on stream
- *****************************************************************************/
-static int wxSetupMenus( intf_thread_t * p_intf )
-{
- return 0;
-}
/*****************************************************************************
* Manage: manage main thread messages
vlc_mutex_lock( &p_intf->change_lock );
- /* If the "display popup" flag has changed */
- if( p_intf->b_menu_change )
- {
- p_main_interface->p_popup_menu =
- new PopupMenu( p_intf, p_main_interface );
- p_intf->b_menu_change = 0;
- }
-
- /* Update the log window */
- p_intf->p_sys->p_messages_window->UpdateLog();
-
- /* Update the playlist */
- p_intf->p_sys->p_playlist_window->Manage();
-
/* Update the input */
if( p_intf->p_sys->p_input == NULL )
{
/* Show slider */
if( p_intf->p_sys->p_input )
{
- //if( p_intf->p_sys->p_input->stream.b_seekable )
+ //if( p_intf->p_sys->p_input->stream.b_seekable )
{
p_main_interface->slider_frame->Show();
p_main_interface->frame_sizer->Show(
}
p_main_interface->statusbar->SetStatusText(
- p_intf->p_sys->p_input->psz_source, 1 );
+ wxU(p_intf->p_sys->p_input->psz_source), 2 );
p_main_interface->TogglePlayButton( PLAYING_S );
i_old_playing_status = PLAYING_S;
- }
-
- /* control buttons for free pace streams */
- b_pace_control = p_intf->p_sys->p_input->stream.b_pace_control;
+ /* Take care of the volume */
+ audio_volume_t i_volume;
+ aout_VolumeGet( p_intf, &i_volume );
+ p_main_interface->volctrl->SetValue( i_volume * 200 * 2 /
+ AOUT_VOLUME_MAX );
+ p_main_interface->volctrl->SetToolTip(
+ wxString::Format((wxString)wxU(_("Volume")) + wxT(" %d"),
+ i_volume * 200 / AOUT_VOLUME_MAX ) );
+
+ /* control buttons for free pace streams */
+ b_pace_control = p_intf->p_sys->p_input->stream.b_pace_control;
+ }
}
else if( p_intf->p_sys->p_input->b_dead )
{
i_old_playing_status = PAUSE_S;
}
- p_main_interface->statusbar->SetStatusText( "", 1 );
+ p_main_interface->statusbar->SetStatusText( wxT(""), 2 );
vlc_object_release( p_intf->p_sys->p_input );
p_intf->p_sys->p_input = NULL;
}
+
+
if( p_intf->p_sys->p_input )
{
input_thread_t *p_input = p_intf->p_sys->p_input;
/* Manage the slider */
if( p_input->stream.b_seekable && p_intf->p_sys->b_playing )
{
- stream_position_t position;
-
/* Update the slider if the user isn't dragging it. */
if( p_intf->p_sys->b_slider_free )
{
+ vlc_value_t pos;
+ char psz_time[ OFFSETTOTIME_MAX_SIZE ];
+ vlc_value_t time;
+ mtime_t i_seconds;
+
/* Update the value */
- vlc_mutex_unlock( &p_input->stream.stream_lock );
- input_Tell( p_input, &position );
- vlc_mutex_lock( &p_input->stream.stream_lock );
- if( position.i_size )
+ var_Get( p_input, "position", &pos );
+ if( pos.f_float >= 0.0 )
{
- p_intf->p_sys->i_slider_pos =
- ( SLIDER_MAX_POS * position.i_tell ) / position.i_size;
+ p_intf->p_sys->i_slider_pos = (int)(SLIDER_MAX_POS * pos.f_float);
+
+ p_main_interface->slider->SetValue( p_intf->p_sys->i_slider_pos );
+
+ var_Get( p_intf->p_sys->p_input, "time", &time );
+ i_seconds = time.i_time / 1000000;
+
+ sprintf( psz_time, "%d:%02d:%02d",
+ (int) (i_seconds / (60 * 60)),
+ (int) (i_seconds / 60 % 60),
+ (int) (i_seconds % 60) );
- p_main_interface->slider->SetValue(
- p_intf->p_sys->i_slider_pos );
- DisplayStreamDate( p_main_interface->slider_box,p_intf,
- p_intf->p_sys->i_slider_pos );
+ p_main_interface->slider_box->SetLabel(wxU( psz_time ) );
}
}
}
- if( p_intf->p_sys->i_part !=
- p_input->stream.p_selected_area->i_part )
- {
- p_intf->p_sys->b_chapter_update = 1;
- wxSetupMenus( p_intf );
- }
-
/* Manage Playing status */
if( i_old_playing_status != p_input->stream.control.i_status )
{
}
i_old_playing_status = p_input->stream.control.i_status;
}
+
+ /* Manage Speed status */
+ if( i_old_rate != p_input->stream.control.i_rate )
+ {
+ p_main_interface->statusbar->SetStatusText(
+ wxString::Format(wxT("x%.2f"),
+ 1000.0 / p_input->stream.control.i_rate), 1 );
+ i_old_rate = p_input->stream.control.i_rate;
+ }
}
vlc_mutex_unlock( &p_input->stream.stream_lock );
}
else if( p_intf->p_sys->b_playing && !p_intf->b_die )
{
- wxModeManage( p_intf );
p_intf->p_sys->b_playing = 0;
p_main_interface->TogglePlayButton( PAUSE_S );
i_old_playing_status = PAUSE_S;
}
/*****************************************************************************
- * DisplayStreamDate: display stream date
- *****************************************************************************
- * This function displays the current date related to the position in
- * the stream. It is called whenever the slider changes its value.
- * The lock has to be taken before you call the function.
+ * PopupMenuCB: callback triggered by the intf-popupmenu playlist variable.
+ * We don't show the menu directly here because we don't want the
+ * caller to block for a too long time.
*****************************************************************************/
-void DisplayStreamDate( wxControl *p_slider_frame, intf_thread_t * p_intf ,
- int i_pos )
+static int PopupMenuCB( vlc_object_t *p_this, const char *psz_variable,
+ vlc_value_t old_val, vlc_value_t new_val, void *param )
{
- if( p_intf->p_sys->p_input )
- {
-#define p_area p_intf->p_sys->p_input->stream.p_selected_area
- char psz_time[ OFFSETTOTIME_MAX_SIZE ];
-
- p_slider_frame->SetLabel(
- input_OffsetToTime( p_intf->p_sys->p_input,
- psz_time,
- p_area->i_size * i_pos / SLIDER_MAX_POS ) );
-#undef p_area
- }
+ intf_thread_t *p_intf = (intf_thread_t *)param;
+
+ if( p_intf->p_sys->pf_show_dialog )
+ p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_POPUPMENU,
+ new_val.b_bool, 0 );
+
+ return VLC_SUCCESS;
}