Commit 3b3156e1 authored by Sam Hocevar's avatar Sam Hocevar

 . removed tests against i_rate and i_new_rate calculation from the
   plugins and hid this complexity into input_ext-intf.c
parent c3e2bf1d
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* control the pace of reading. * control the pace of reading.
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * 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> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -294,13 +294,19 @@ typedef struct input_config_s ...@@ -294,13 +294,19 @@ typedef struct input_config_s
#define INPUT_METHOD_BCAST 22 /* UDP broadcast */ #define INPUT_METHOD_BCAST 22 /* UDP broadcast */
#define INPUT_METHOD_VLAN_BCAST 32 /* UDP broadcast with VLANs */ #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 * Prototypes
*****************************************************************************/ *****************************************************************************/
struct input_thread_s * input_CreateThread ( struct playlist_item_s *, struct input_thread_s * input_CreateThread ( struct playlist_item_s *,
int *pi_status ); int *pi_status );
void input_DestroyThread( struct input_thread_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_SetRate( struct input_thread_s *, int );
void input_Forward( struct input_thread_s *, int );
void input_Seek ( struct input_thread_s *, off_t ); void input_Seek ( struct input_thread_s *, off_t );
...@@ -177,7 +177,7 @@ on_toolbar_play_clicked (GtkButton *button, ...@@ -177,7 +177,7 @@ on_toolbar_play_clicked (GtkButton *button,
if( p_intf->p_input != NULL ) 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, ...@@ -190,7 +190,7 @@ on_toolbar_pause_clicked (GtkButton *button,
if( p_intf->p_input != NULL ) 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, ...@@ -249,7 +249,7 @@ on_popup_play_activate (GtkMenuItem *menuitem,
if( p_intf->p_input != NULL ) 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, ...@@ -262,7 +262,7 @@ on_popup_pause_activate (GtkMenuItem *menuitem,
if( p_intf->p_input != NULL ) 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, ...@@ -380,18 +380,10 @@ on_popup_slow_activate (GtkMenuItem *menuitem,
gpointer user_data) gpointer user_data)
{ {
intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" ); intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
int i_rate;
if( p_intf->p_input != NULL ) if( p_intf->p_input != NULL )
{ {
i_rate = p_intf->p_input->stream.control.i_rate * 2; input_SetRate( p_intf->p_input, INPUT_RATE_SLOWER );
if ( i_rate <= MAXIMAL_RATE )
{
if ( i_rate > 500 && i_rate < 1000 )
i_rate = 1000;
input_Forward( p_intf->p_input, i_rate );
}
} }
} }
...@@ -401,15 +393,10 @@ on_popup_fast_activate (GtkMenuItem *menuitem, ...@@ -401,15 +393,10 @@ on_popup_fast_activate (GtkMenuItem *menuitem,
gpointer user_data) gpointer user_data)
{ {
intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" ); intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
int i_rate;
if( p_intf->p_input != NULL ) if( p_intf->p_input != NULL )
{ {
i_rate = p_intf->p_input->stream.control.i_rate / 2; input_SetRate( p_intf->p_input, INPUT_RATE_FASTER );
if ( i_rate >= MINIMAL_RATE )
{
input_Forward( p_intf->p_input, i_rate );
}
} }
} }
...@@ -419,18 +406,10 @@ on_toolbar_slow_clicked (GtkButton *button, ...@@ -419,18 +406,10 @@ on_toolbar_slow_clicked (GtkButton *button,
gpointer user_data) gpointer user_data)
{ {
intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" ); intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
int i_rate;
if( p_intf->p_input != NULL ) if( p_intf->p_input != NULL )
{ {
i_rate = p_intf->p_input->stream.control.i_rate * 2; input_SetRate( p_intf->p_input, INPUT_RATE_SLOWER );
if ( i_rate <= MAXIMAL_RATE )
{
if ( i_rate > 500 && i_rate < 1000 )
i_rate = 1000;
input_Forward( p_intf->p_input, i_rate );
}
} }
} }
...@@ -440,15 +419,10 @@ on_toolbar_fast_clicked (GtkButton *button, ...@@ -440,15 +419,10 @@ on_toolbar_fast_clicked (GtkButton *button,
gpointer user_data) gpointer user_data)
{ {
intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" ); intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
int i_rate;
if( p_intf->p_input != NULL ) if( p_intf->p_input != NULL )
{ {
i_rate = p_intf->p_input->stream.control.i_rate / 2; input_SetRate( p_intf->p_input, INPUT_RATE_FASTER );
if ( i_rate >= MINIMAL_RATE )
{
input_Forward( p_intf->p_input, i_rate );
}
} }
} }
...@@ -251,7 +251,6 @@ int vout_Manage( vout_thread_t *p_vout ) ...@@ -251,7 +251,6 @@ int vout_Manage( vout_thread_t *p_vout )
{ {
SDL_Event event; /* SDL event */ SDL_Event event; /* SDL event */
Uint8 i_key; Uint8 i_key;
int i_rate;
/* FIXME: do this nicely */ /* FIXME: do this nicely */
input_thread_t * p_input = p_main->p_intf->p_input; input_thread_t * p_input = p_main->p_intf->p_input;
...@@ -321,39 +320,21 @@ int vout_Manage( vout_thread_t *p_vout ) ...@@ -321,39 +320,21 @@ int vout_Manage( vout_thread_t *p_vout )
case SDLK_p: case SDLK_p:
if( p_input != NULL ) if( p_input != NULL )
{ {
if( p_input->stream.control.i_status == PLAYING_S ) input_SetRate( p_input, INPUT_RATE_PAUSE );
{
input_Pause( p_input );
}
else
{
input_Play( p_input );
}
} }
break; break;
case SDLK_a: case SDLK_a:
if( p_input != NULL ) if( p_input != NULL )
{ {
i_rate = p_input->stream.control.i_rate/2; input_SetRate( p_input, INPUT_RATE_FASTER );
if ( i_rate >= MINIMAL_RATE )
{
input_Forward( p_input, i_rate );
}
} }
break; break;
case SDLK_z: case SDLK_z:
if( p_input != NULL ) if( p_input != NULL )
{ {
i_rate = p_input->stream.control.i_rate*2; input_SetRate( p_input, INPUT_RATE_SLOWER );
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 );
}
} }
break; break;
......
...@@ -39,54 +39,81 @@ ...@@ -39,54 +39,81 @@
#include "input.h" #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 ); 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 );
}
/***************************************************************************** switch( i_mode )
* 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 )
{ {
intf_Msg( "input: playing at 1:%i slow motion", i_rate / 1000 ); case INPUT_RATE_PLAY:
} p_input->stream.i_new_status = PLAYING_S;
else if( i_rate < DEFAULT_RATE ) intf_Msg( "input: playing at normal rate" );
{ break;
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;
}
vlc_mutex_lock( &p_input->stream.stream_lock ); case INPUT_RATE_PAUSE:
p_input->stream.i_new_status = FORWARD_S; /* XXX: we don't need to check i_status, because input_clock.c
p_input->stream.i_new_rate = i_rate; * does it for us */
vlc_cond_signal( &p_input->stream.stream_wait ); p_input->stream.i_new_status = PAUSE_S;
vlc_mutex_unlock( &p_input->stream.stream_lock ); 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_cond_signal( &p_input->stream.stream_wait );
vlc_mutex_unlock( &p_input->stream.stream_lock ); vlc_mutex_unlock( &p_input->stream.stream_lock );
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment