* 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>
*
#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 );
+
if( p_intf->p_input != NULL )
{
- input_Play( p_intf->p_input );
+ input_SetRate( p_intf->p_input, INPUT_RATE_PLAY );
}
}
if( p_intf->p_input != NULL )
{
- input_Pause( p_intf->p_input );
+ input_SetRate( p_intf->p_input, INPUT_RATE_PAUSE );
}
}
if( p_intf->p_input != NULL )
{
- input_Play( p_intf->p_input );
+ input_SetRate( p_intf->p_input, INPUT_RATE_PLAY );
}
}
if( p_intf->p_input != NULL )
{
- input_Pause( p_intf->p_input );
+ input_SetRate( p_intf->p_input, INPUT_RATE_PAUSE );
}
}
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 );
}
}
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 );
}
}
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 );
}
}
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 );
}
}
{
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;
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;
#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 );
}