]> git.sesse.net Git - vlc/commitdiff
. removed tests against i_rate and i_new_rate calculation from the
authorSam Hocevar <sam@videolan.org>
Mon, 12 Feb 2001 09:39:15 +0000 (09:39 +0000)
committerSam Hocevar <sam@videolan.org>
Mon, 12 Feb 2001 09:39:15 +0000 (09:39 +0000)
   plugins and hid this complexity into input_ext-intf.c

include/input_ext-intf.h
plugins/gnome/gnome_callbacks.c
plugins/sdl/vout_sdl.c
src/input/input_ext-intf.c

index 49bd4fa2a4546df2c5a4e43520326624db34026d..32b7a3f34e787e0177598a1fb3906224b667bcb9 100644 (file)
@@ -4,7 +4,7 @@
  * control the pace of reading. 
  *****************************************************************************
  * Copyright (C) 1999, 2000 VideoLAN
- * $Id: input_ext-intf.h,v 1.18 2001/02/08 17:44:12 massiot Exp $
+ * $Id: input_ext-intf.h,v 1.19 2001/02/12 09:39:15 sam Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -294,13 +294,19 @@ typedef struct input_config_s
 #define INPUT_METHOD_BCAST         22                       /* UDP broadcast */
 #define INPUT_METHOD_VLAN_BCAST    32            /* UDP broadcast with VLANs */
 
+/* Rate changing methods */
+#define INPUT_RATE_PLAY             0
+#define INPUT_RATE_PAUSE            1
+#define INPUT_RATE_FASTER           2
+#define INPUT_RATE_SLOWER           3
+
 /*****************************************************************************
  * Prototypes
  *****************************************************************************/
 struct input_thread_s * input_CreateThread ( struct playlist_item_s *,
                                              int *pi_status );
 void input_DestroyThread( struct input_thread_s *, int *pi_status );
-void input_Play   ( struct input_thread_s * );
-void input_Pause  ( struct input_thread_s * );
-void input_Forward( struct input_thread_s *, int );
+
+void input_SetRate( struct input_thread_s *, int );
 void input_Seek   ( struct input_thread_s *, off_t );
+
index 6708c13f7af80a30fe0a791d55c20792068b1ce6..d3cfc91ed65cb9050fe94825d1f9253be3a7dfb0 100644 (file)
@@ -177,7 +177,7 @@ on_toolbar_play_clicked                (GtkButton       *button,
 
     if( p_intf->p_input != NULL )
     {
-        input_Play( p_intf->p_input );
+        input_SetRate( p_intf->p_input, INPUT_RATE_PLAY );
     }
 }
 
@@ -190,7 +190,7 @@ on_toolbar_pause_clicked               (GtkButton       *button,
 
     if( p_intf->p_input != NULL )
     {
-        input_Pause( p_intf->p_input );
+        input_SetRate( p_intf->p_input, INPUT_RATE_PAUSE );
     }
 }
 
@@ -249,7 +249,7 @@ on_popup_play_activate                 (GtkMenuItem     *menuitem,
 
     if( p_intf->p_input != NULL )
     {
-        input_Play( p_intf->p_input );
+        input_SetRate( p_intf->p_input, INPUT_RATE_PLAY );
     }
 }
 
@@ -262,7 +262,7 @@ on_popup_pause_activate                (GtkMenuItem     *menuitem,
 
     if( p_intf->p_input != NULL )
     {
-        input_Pause( p_intf->p_input );
+        input_SetRate( p_intf->p_input, INPUT_RATE_PAUSE );
     }
 }
 
@@ -380,18 +380,10 @@ on_popup_slow_activate                 (GtkMenuItem     *menuitem,
                                         gpointer         user_data)
 {
     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
-    int i_rate;
 
     if( p_intf->p_input != NULL )
     {
-        i_rate = p_intf->p_input->stream.control.i_rate * 2;
-        if ( i_rate <= MAXIMAL_RATE )
-        {
-             if ( i_rate > 500 && i_rate < 1000 )
-                 i_rate = 1000;
-
-             input_Forward( p_intf->p_input, i_rate );
-        }
+        input_SetRate( p_intf->p_input, INPUT_RATE_SLOWER );
     }
 }
 
@@ -401,15 +393,10 @@ on_popup_fast_activate                 (GtkMenuItem     *menuitem,
                                         gpointer         user_data)
 {
     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
-    int i_rate;
 
     if( p_intf->p_input != NULL )
     {
-        i_rate = p_intf->p_input->stream.control.i_rate / 2;
-        if ( i_rate >= MINIMAL_RATE )
-        {
-             input_Forward( p_intf->p_input, i_rate );
-        }
+        input_SetRate( p_intf->p_input, INPUT_RATE_FASTER );
     }
 }
 
@@ -419,18 +406,10 @@ on_toolbar_slow_clicked                (GtkButton       *button,
                                         gpointer         user_data)
 {
     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
-    int i_rate;
 
     if( p_intf->p_input != NULL )
     {
-        i_rate = p_intf->p_input->stream.control.i_rate * 2;
-        if ( i_rate <= MAXIMAL_RATE )
-        {
-             if ( i_rate > 500 && i_rate < 1000 )
-                 i_rate = 1000;
-
-             input_Forward( p_intf->p_input, i_rate );
-        }
+        input_SetRate( p_intf->p_input, INPUT_RATE_SLOWER );
     }
 }
 
@@ -440,15 +419,10 @@ on_toolbar_fast_clicked                (GtkButton       *button,
                                         gpointer         user_data)
 {
     intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
-    int i_rate;
 
     if( p_intf->p_input != NULL )
     {
-        i_rate = p_intf->p_input->stream.control.i_rate / 2;
-        if ( i_rate >= MINIMAL_RATE )
-        {
-             input_Forward( p_intf->p_input, i_rate );
-        }
+        input_SetRate( p_intf->p_input, INPUT_RATE_FASTER );
     }
 }
 
index fbdfa845a9f4b781ae176f12a70b447bd8153577..4caac8f79f19101b780463037e059d5701aaad99 100644 (file)
@@ -251,7 +251,6 @@ int vout_Manage( vout_thread_t *p_vout )
 {
     SDL_Event event;                                            /* SDL event */
     Uint8   i_key;
-    int     i_rate;
 
     /* FIXME: do this nicely */
     input_thread_t * p_input = p_main->p_intf->p_input;
@@ -321,39 +320,21 @@ int vout_Manage( vout_thread_t *p_vout )
             case SDLK_p:
                 if( p_input != NULL )
                 {
-                    if( p_input->stream.control.i_status == PLAYING_S )
-                    {
-                        input_Pause( p_input );
-                    }
-                    else
-                    {
-                        input_Play( p_input );
-                    }
+                    input_SetRate( p_input, INPUT_RATE_PAUSE );
                 }
                 break;
 
             case SDLK_a:
                 if( p_input != NULL )
                 {
-                    i_rate = p_input->stream.control.i_rate/2;
-                    if ( i_rate >= MINIMAL_RATE )
-                    {
-                        input_Forward( p_input, i_rate );
-                    }
+                    input_SetRate( p_input, INPUT_RATE_FASTER );
                 }
                 break;
 
             case SDLK_z:
                 if( p_input != NULL )
                 {
-                    i_rate = p_input->stream.control.i_rate*2;
-                    if ( i_rate <= MAXIMAL_RATE )
-                    {
-                        /* Compensation of int truncature */
-                        if ( i_rate > 500 && i_rate < 1000 )
-                            i_rate = 1000;
-                        input_Forward( p_input, i_rate );
-                    }
+                    input_SetRate( p_input, INPUT_RATE_SLOWER );
                 }
                 break;
 
index 1da1ec7f4407f079c9904b8319bebf386eaa6673..31afe0127e52bc2dab7f9dcb6d95c589a646059e 100644 (file)
 #include "input.h"
 
 /*****************************************************************************
- * input_Play: comes back to the normal pace of reading
+ * input_SetRate: change the reading pace
  *****************************************************************************/
-void input_Play( input_thread_t * p_input )
+void input_SetRate( input_thread_t * p_input, int i_mode )
 {
-    intf_Msg( "input: playing at normal rate" );
     vlc_mutex_lock( &p_input->stream.stream_lock );
-    p_input->stream.i_new_status = PLAYING_S;
-    vlc_cond_signal( &p_input->stream.stream_wait );
-    vlc_mutex_unlock( &p_input->stream.stream_lock );
-}
 
-/*****************************************************************************
- * input_Forward: manages fast forward and slow motion
- *****************************************************************************
- * Note that if i_rate > DEFAULT_RATE, the pace is slower.
- *****************************************************************************/
-void input_Forward( input_thread_t * p_input, int i_rate )
-{
-    if ( i_rate > DEFAULT_RATE )
+    switch( i_mode )
     {
-        intf_Msg( "input: playing at 1:%i slow motion", i_rate / 1000 );
-    }
-    else if( i_rate < DEFAULT_RATE )
-    {
-        intf_Msg( "input: playing at %i:1 fast forward", 1000 / i_rate );
-    }
-    else
-    {
-        /* Not very joli, but this is going to disappear soon anyway */
-        input_Play( p_input );
-        return;
-    }
+    case INPUT_RATE_PLAY:
+        p_input->stream.i_new_status = PLAYING_S;
+        intf_Msg( "input: playing at normal rate" );
+        break;
 
-    vlc_mutex_lock( &p_input->stream.stream_lock );
-    p_input->stream.i_new_status = FORWARD_S;
-    p_input->stream.i_new_rate = i_rate;
-    vlc_cond_signal( &p_input->stream.stream_wait );
-    vlc_mutex_unlock( &p_input->stream.stream_lock );
-}
+    case INPUT_RATE_PAUSE:
+        /* XXX: we don't need to check i_status, because input_clock.c
+         * does it for us */
+        p_input->stream.i_new_status = PAUSE_S;
+        intf_Msg( "input: toggling pause" );
+        break;
+
+    case INPUT_RATE_FASTER:
+        /* If we are already going too fast, go back to default rate */
+        if( p_input->stream.control.i_rate * 8 <= DEFAULT_RATE )
+        {
+            p_input->stream.i_new_status = PLAYING_S;
+            intf_Msg( "input: playing at normal rate" );
+        }
+        else
+        {
+            p_input->stream.i_new_status = FORWARD_S;
+
+            if( p_input->stream.control.i_rate < DEFAULT_RATE
+                    && p_input->stream.control.i_status == FORWARD_S )
+            {
+                p_input->stream.i_new_rate =
+                                    p_input->stream.control.i_rate / 2;
+            }
+            else
+            {
+                p_input->stream.i_new_rate = DEFAULT_RATE / 2;
+            }
+            intf_Msg( "input: playing at %i:1 fast forward",
+                      DEFAULT_RATE / p_input->stream.i_new_rate );
+        }
+        break;
+
+    case INPUT_RATE_SLOWER:
+        /* If we are already going too slow, go back to default rate */
+        if( p_input->stream.control.i_rate >= 8 * DEFAULT_RATE )
+        {
+            p_input->stream.i_new_status = PLAYING_S;
+            intf_Msg( "input: playing at normal rate" );
+        }
+        else
+        {
+            p_input->stream.i_new_status = FORWARD_S;
+
+            if( p_input->stream.control.i_rate > DEFAULT_RATE
+                    && p_input->stream.control.i_status == FORWARD_S )
+            {
+                p_input->stream.i_new_rate =
+                                    p_input->stream.control.i_rate * 2;
+            }
+            else
+            {
+                p_input->stream.i_new_rate = DEFAULT_RATE * 2;
+            }
+            intf_Msg( "input: playing at 1:%i slow motion",
+                      p_input->stream.i_new_rate / DEFAULT_RATE );
+        }
+        break;
+
+    default:
+    }
 
-/*****************************************************************************
- * input_Pause: temporarily stops the reading of the stream
- *****************************************************************************/
-void input_Pause( input_thread_t * p_input )
-{
-    intf_Msg( "input: paused" );
-    vlc_mutex_lock( &p_input->stream.stream_lock );
-    p_input->stream.i_new_status = PAUSE_S;
     vlc_cond_signal( &p_input->stream.stream_wait );
     vlc_mutex_unlock( &p_input->stream.stream_lock );
 }