]> git.sesse.net Git - vlc/blobdiff - modules/gui/wince/interface.cpp
s/pl_Yield/pl_Hold/
[vlc] / modules / gui / wince / interface.cpp
index 599eb6ba2882e26b84bc6690f0682ccc9d63432f..be5cc402eed1a4f10fa314270fe104668ba4ca29 100644 (file)
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include <vlc/vlc.h>
-#include <vlc/aout.h>
-#include <vlc/vout.h>
-#include <vlc/intf.h>
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#define __STDC_CONSTANT_MACROS 1
+#include <inttypes.h>
+
+#include <vlc_common.h>
+#include <vlc_aout.h>
+#include <vlc_vout.h>
+#include <vlc_interface.h>
+#include <vlc_input.h>
+#include <vlc_playlist.h>
 
 #include "wince.h"
+#define INT64_C(val) val##LL
 
 #include <windowsx.h>
 #include <commctrl.h>
 #include <commdlg.h>
 
-#define NUMIMAGES     9   // Number of buttons in the toolbar           
-#define IMAGEWIDTH    17   // Width of the buttons in the toolbar  
-#define IMAGEHEIGHT   16   // Height of the buttons in the toolbar  
+#define NUMIMAGES     9   // Number of buttons in the toolbar
+#define IMAGEWIDTH    17   // Width of the buttons in the toolbar
+#define IMAGEHEIGHT   16   // Height of the buttons in the toolbar
 #define BUTTONWIDTH   0    // Width of the button images in the toolbar
 #define BUTTONHEIGHT  0    // Height of the button images in the toolbar
 #define ID_TOOLBAR    2000 // Identifier of the main tool bar
@@ -75,7 +85,7 @@
 #define HELP_FAST _T("Play faster")
 
 // The TBBUTTON structure contains information the toolbar buttons.
-static TBBUTTON tbButton[] =      
+static TBBUTTON tbButton[] =
 {
   {0, ID_FILE_QUICKOPEN,        TBSTATE_ENABLED, TBSTYLE_BUTTON},
   {1, ID_FILE_OPENNET,       TBSTATE_ENABLED, TBSTYLE_BUTTON},
@@ -93,7 +103,7 @@ static TBBUTTON tbButton[] =
 };
 
 // Toolbar ToolTips
-TCHAR * szToolTips[] = 
+TCHAR * szToolTips[] =
 {
     HELP_SIMPLE, HELP_NET, HELP_STOP, HELP_PLAY, HELP_PLO, HELP_PLP,
     HELP_PLN, HELP_SLOW, HELP_FAST
@@ -112,8 +122,8 @@ Interface::Interface( intf_thread_t *p_intf, CBaseWindow *p_parent,
 
 Interface::~Interface()
 {
-    if( timer ) delete timer;
-    if( video ) delete video;
+    delete timer;
+    delete video;
 }
 
 BOOL Interface::InitInstance()
@@ -142,10 +152,10 @@ BOOL Interface::InitInstance()
 }
 
 /***********************************************************************
-FUNCTION: 
+FUNCTION:
   CreateMenuBar
 
-PURPOSE: 
+PURPOSE:
   Creates a menu bar.
 ***********************************************************************/
 HWND Interface::CreateMenuBar( HWND hwnd, HINSTANCE hInst )
@@ -241,10 +251,10 @@ HWND Interface::CreateMenuBar( HWND hwnd, HINSTANCE hInst )
 }
 
 /***********************************************************************
-FUNCTION: 
+FUNCTION:
   CreateToolBar
 
-PURPOSE: 
+PURPOSE:
   Registers the TOOLBAR control class and creates a toolbar.
 ***********************************************************************/
 HWND CreateToolBar( HWND hwnd, HINSTANCE hInst )
@@ -269,15 +279,15 @@ HWND CreateToolBar( HWND hwnd, HINSTANCE hInst )
         BUTTONWIDTH, BUTTONHEIGHT, IMAGEWIDTH, IMAGEHEIGHT, sizeof(TBBUTTON) );
 
     if( !hwndTB ) return NULL;
-  
     // Add ToolTips to the toolbar.
-    SendMessage( hwndTB, TB_SETTOOLTIPS, (WPARAM)NUMIMAGES, 
+    SendMessage( hwndTB, TB_SETTOOLTIPS, (WPARAM)NUMIMAGES,
                  (LPARAM)szToolTips );
 
     // Reposition the toolbar.
     GetClientRect( hwnd, &rect );
     GetWindowRect( hwndTB, &rectTB );
-    MoveWindow( hwndTB, rect.left, rect.bottom - rect.top - 2*MENU_HEIGHT, 
+    MoveWindow( hwndTB, rect.left, rect.bottom - rect.top - 2*MENU_HEIGHT,
                 rect.right - rect.left, MENU_HEIGHT, TRUE );
 
     return hwndTB;
@@ -285,10 +295,10 @@ HWND CreateToolBar( HWND hwnd, HINSTANCE hInst )
 
 /***********************************************************************
 
-FUNCTION: 
+FUNCTION:
   CreateSliderBar
 
-PURPOSE: 
+PURPOSE:
   Registers the TRACKBAR_CLASS control class and creates a trackbar.
 
 ***********************************************************************/
@@ -317,8 +327,8 @@ HWND CreateSliderBar( HWND hwnd, HINSTANCE hInst )
 
     // Reposition the trackbar
     GetClientRect( hwnd, &rect );
-    MoveWindow( hwndSlider, rect.left, 
-                rect.bottom - rect.top - 2*(MENU_HEIGHT-1) - SLIDER_HEIGHT, 
+    MoveWindow( hwndSlider, rect.left,
+                rect.bottom - rect.top - 2*(MENU_HEIGHT-1) - SLIDER_HEIGHT,
                 rect.right - rect.left - 40, 30, TRUE );
 
     ShowWindow( hwndSlider, SW_HIDE );
@@ -350,10 +360,10 @@ HWND CreateStaticText( HWND hwnd, HINSTANCE hInst )
 
 /***********************************************************************
 
-FUNCTION: 
+FUNCTION:
   CreateVolTrackBar
 
-PURPOSE: 
+PURPOSE:
   Registers the TRACKBAR_CLASS control class and creates a trackbar.
 
 ***********************************************************************/
@@ -379,12 +389,12 @@ HWND CreateVolTrackBar( HWND hwnd, HINSTANCE hInst )
     SendMessage( hwndVol, TBM_SETRANGEMIN, 1, 0 );
     SendMessage( hwndVol, TBM_SETRANGEMAX, 1, 200 );
     SendMessage( hwndVol, TBM_SETPOS, 1, 100 );
-    SendMessage( hwndVol, TBM_SETTICFREQ, 50, 0 );  
+    SendMessage( hwndVol, TBM_SETTICFREQ, 50, 0 );
 
     // Reposition the trackbar
     GetClientRect( hwnd, &rect );
-    MoveWindow( hwndVol, rect.right - rect.left - 40, 
-                rect.bottom - rect.top - 2*(MENU_HEIGHT-1) - SLIDER_HEIGHT, 
+    MoveWindow( hwndVol, rect.right - rect.left - 40,
+                rect.bottom - rect.top - 2*(MENU_HEIGHT-1) - SLIDER_HEIGHT,
                 40, SLIDER_HEIGHT, TRUE );
 
     ShowWindow( hwndVol, SW_HIDE );
@@ -394,10 +404,10 @@ HWND CreateVolTrackBar( HWND hwnd, HINSTANCE hInst )
 
 /***********************************************************************
 
-FUNCTION: 
+FUNCTION:
   CreateStatusBar
 
-PURPOSE: 
+PURPOSE:
   Registers the StatusBar control class and creates a Statusbar.
 
 ***********************************************************************/
@@ -424,7 +434,7 @@ HWND CreateStatusBar( HWND hwnd, HINSTANCE hInst )
 
     if (!hwndSB ) return NULL;
 
-    // Get the coordinates of the parent window's client area. 
+    // Get the coordinates of the parent window's client area.
     GetClientRect( hwnd, &rect );
 
     // allocate memory for the panes of status bar
@@ -442,10 +452,10 @@ HWND CreateStatusBar( HWND hwnd, HINSTANCE hInst )
 }
 
 /***********************************************************************
-FUNCTION: 
+FUNCTION:
   WndProc
 
-PURPOSE: 
+PURPOSE:
   Processes messages sent to the main window.
 ***********************************************************************/
 LRESULT Interface::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
@@ -472,8 +482,8 @@ LRESULT Interface::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
     case WM_COMMAND:
         switch( GET_WM_COMMAND_ID(wp,lp) )
         {
-        case ID_FILE_QUICKOPEN: 
-        case ID_FILE_OPENFILE: 
+        case ID_FILE_QUICKOPEN:
+        case ID_FILE_OPENFILE:
         case ID_FILE_OPENDIR:
         case ID_FILE_OPENNET:
         case ID_VIEW_STREAMINFO:
@@ -490,17 +500,15 @@ LRESULT Interface::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
         case SlowStream_Event: OnSlowStream(); break;
         case FastStream_Event: OnFastStream(); break;
 
-        case ID_FILE_ABOUT: 
+        case ID_FILE_ABOUT:
         {
             string about = (string)"VLC media player " PACKAGE_VERSION +
                 _("\n(WinCE interface)\n\n") +
-                _("(c) 1996-2006 - the VideoLAN Team\n\n") +
+                _("(c) 1996-2008 - the VideoLAN Team\n\n") +
                 _("Compiled by ") + VLC_CompileBy() + "@" +
                 VLC_CompileHost() + "." + VLC_CompileDomain() + ".\n" +
                 _("Compiler: ") + VLC_Compiler() + ".\n" +
-#ifndef HAVE_SHARED_LIBVLC
-                _("Based on SVN revision: ") + VLC_Changeset() + ".\n\n" +
-#endif
+                _("Based on Git commit: ") + VLC_Changeset() + ".\n\n" +
                 _("The VideoLAN team <videolan@videolan.org>\n"
                   "http://www.videolan.org/");
 
@@ -518,20 +526,20 @@ LRESULT Interface::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
             // we should test if it is a menu command
         }
         break;
-  
     case WM_TIMER:
         timer->Notify();
         break;
 
-    case WM_CTLCOLORSTATIC: 
+    case WM_CTLCOLORSTATIC:
         if( ( (HWND)lp == hwndSlider ) || ( (HWND)lp == hwndVol ) )
-        { 
-            return( (LRESULT)::GetSysColorBrush(COLOR_3DFACE) ); 
+        {
+            return( (LRESULT)::GetSysColorBrush(COLOR_3DFACE) );
         }
         if( (HWND)lp == hwndLabel )
         {
-            SetBkColor( (HDC)wp, RGB (192, 192, 192) ); 
-            return( (LRESULT)::GetSysColorBrush(COLOR_3DFACE) ); 
+            SetBkColor( (HDC)wp, RGB (192, 192, 192) );
+            return( (LRESULT)::GetSysColorBrush(COLOR_3DFACE) );
         }
         break;
 
@@ -562,7 +570,7 @@ LRESULT Interface::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
         break;
 
     case WM_SETFOCUS:
-        SHSipPreference( hwnd, SIP_DOWN ); 
+        SHSipPreference( hwnd, SIP_DOWN );
         SHFullScreen( GetForegroundWindow(), SHFS_HIDESIPBUTTON );
     case WM_EXITMENULOOP:
         if( video && video->hWnd )
@@ -632,11 +640,10 @@ void Interface::OnShowDialog( int i_dialog_event )
 
 void Interface::OnPlayStream( void )
 {
-    playlist_t *p_playlist = (playlist_t *)
-        vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
+    playlist_t *p_playlist = pl_Hold( p_intf );
     if( p_playlist == NULL ) return;
 
-    if( p_playlist->i_size && p_playlist->i_enabled )
+    if( !playlist_IsEmpty(p_playlist) )
     {
         vlc_value_t state;
 
@@ -648,7 +655,7 @@ void Interface::OnPlayStream( void )
             /* No stream was playing, start one */
             playlist_Play( p_playlist );
             TogglePlayButton( PLAYING_S );
-            vlc_object_release( p_playlist );
+            pl_Release( p_intf );
             return;
         }
 
@@ -668,14 +675,13 @@ void Interface::OnPlayStream( void )
 
         TogglePlayButton( state.i_int );
         vlc_object_release( p_input );
-        vlc_object_release( p_playlist );
     }
     else
     {
         /* If the playlist is empty, open a file requester instead */
-        vlc_object_release( p_playlist );
         OnShowDialog( ID_FILE_QUICKOPEN );
     }
+    pl_Release( p_intf );
 }
 
 void Interface::TogglePlayButton( int i_playing_status )
@@ -731,7 +737,7 @@ void Interface::OnSliderUpdate( int wp )
     vlc_mutex_lock( &p_intf->change_lock );
     input_thread_t *p_input = p_intf->p_sys->p_input;
 
-    int dwPos = SendMessage( hwndSlider, TBM_GETPOS, 0, 0 ); 
+    int dwPos = SendMessage( hwndSlider, TBM_GETPOS, 0, 0 );
 
     if( (int)LOWORD(wp) == SB_THUMBPOSITION ||
         (int)LOWORD(wp) == SB_ENDSCROLL )
@@ -743,11 +749,11 @@ void Interface::OnSliderUpdate( int wp )
             var_Set( p_input, "position", pos );
         }
 
-        p_intf->p_sys->b_slider_free = VLC_TRUE;
+        p_intf->p_sys->b_slider_free = true;
     }
     else
     {
-        p_intf->p_sys->b_slider_free = VLC_FALSE;
+        p_intf->p_sys->b_slider_free = false;
 
         if( p_input )
         {
@@ -755,10 +761,10 @@ void Interface::OnSliderUpdate( int wp )
             char psz_time[ MSTRTIME_MAX_SIZE ], psz_total[ MSTRTIME_MAX_SIZE ];
             mtime_t i_seconds;
 
-            i_seconds = var_GetTime( p_input, "length" ) / I64C(1000000 );
+            i_seconds = var_GetTime( p_input, "length" ) / INT64_C(1000000 );
             secstotimestr( psz_total, i_seconds );
 
-            i_seconds = var_GetTime( p_input, "time" ) / I64C(1000000 );
+            i_seconds = var_GetTime( p_input, "time" ) / INT64_C(1000000 );
             secstotimestr( psz_time, i_seconds );
 
             SendMessage( hwndLabel, WM_SETTEXT, (WPARAM)1,
@@ -776,11 +782,11 @@ void Interface::OnChange( int wp )
     if( LOWORD(wp) == SB_THUMBPOSITION || LOWORD(wp) == SB_ENDSCROLL )
     {
         VolumeChange( 200 - (int)dwPos );
-        b_volume_hold = VLC_FALSE;
+        b_volume_hold = false;
     }
     else
     {
-        b_volume_hold = VLC_TRUE;
+        b_volume_hold = true;
     }
 }
 
@@ -807,33 +813,30 @@ void Interface::VolumeUpdate()
 
 void Interface::OnStopStream( void )
 {
-    playlist_t * p_playlist = (playlist_t *)
-        vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
+    playlist_t * p_playlist = pl_Hold( p_intf );
     if( p_playlist == NULL ) return;
 
     playlist_Stop( p_playlist );
     TogglePlayButton( PAUSE_S );
-    vlc_object_release( p_playlist );
+    pl_Release( p_intf );
 }
 
 void Interface::OnPrevStream( void )
 {
-    playlist_t * p_playlist = (playlist_t *)
-        vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
+    playlist_t * p_playlist = pl_Hold( p_intf );
     if( p_playlist == NULL ) return;
 
     playlist_Prev( p_playlist );
-    vlc_object_release( p_playlist );
+    pl_Release( p_intf );
 }
 
 void Interface::OnNextStream( void )
 {
-    playlist_t * p_playlist = (playlist_t *)
-        vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
+    playlist_t * p_playlist = pl_Hold( p_intf );
     if( p_playlist == NULL ) return;
 
     playlist_Next( p_playlist );
-    vlc_object_release( p_playlist );
+    pl_Release( p_intf );
 }
 
 void Interface::OnSlowStream( void )
@@ -843,7 +846,7 @@ void Interface::OnSlowStream( void )
 
     if( p_input == NULL ) return;
 
-    vlc_value_t val; val.b_bool = VLC_TRUE;
+    vlc_value_t val; val.b_bool = true;
     var_Set( p_input, "rate-slower", val );
     vlc_object_release( p_input );
 }
@@ -855,7 +858,7 @@ void Interface::OnFastStream( void )
 
     if( p_input == NULL ) return;
 
-    vlc_value_t val; val.b_bool = VLC_TRUE;
+    vlc_value_t val; val.b_bool = true;
     var_Set( p_input, "rate-faster", val );
     vlc_object_release( p_input );
 }