Commit 66f7daf3 authored by Christophe Massiot's avatar Christophe Massiot

* Pause function implemented ('p' key).

parent 34337317
......@@ -4,7 +4,7 @@
* control the pace of reading.
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: input_ext-intf.h,v 1.15 2001/02/08 07:24:25 sam Exp $
* $Id: input_ext-intf.h,v 1.16 2001/02/08 13:08:02 massiot Exp $
*
* Authors:
*
......@@ -158,6 +158,8 @@ typedef struct stream_descriptor_s
/* New status and rate requested by the interface */
int i_new_status, i_new_rate;
vlc_cond_t stream_wait; /* interface -> input in case of a
* status change request */
/* Demultiplexer data */
void * p_demux_data;
......@@ -299,7 +301,7 @@ typedef struct input_config_s
*****************************************************************************/
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_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 );
......@@ -2,7 +2,7 @@
* intf_sdl.c: SDL interface plugin
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: intf_sdl.c,v 1.30 2001/02/08 04:43:27 sam Exp $
* $Id: intf_sdl.c,v 1.31 2001/02/08 13:08:02 massiot Exp $
*
* Authors:
*
......@@ -145,13 +145,22 @@ void intf_SDLManage( intf_thread_t *p_intf )
/* FIXME : this is temporary */
case SDLK_p:
input_Play( p_intf->p_input );
if( p_intf->p_input->stream.control.i_status == PLAYING_S )
{
input_Pause( p_intf->p_input );
}
else
{
input_Play( p_intf->p_input );
}
break;
case SDLK_a:
i_rate = p_intf->p_input->stream.control.i_rate/2;
if ( i_rate >= MINIMAL_RATE )
{
input_Forward( p_intf->p_input, i_rate );
}
break;
case SDLK_z:
......
......@@ -4,7 +4,7 @@
* decoders.
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: input.c,v 1.76 2001/02/08 07:24:25 sam Exp $
* $Id: input.c,v 1.77 2001/02/08 13:08:02 massiot Exp $
*
* Authors:
*
......@@ -119,6 +119,7 @@ input_thread_t *input_CreateThread ( playlist_item_t *p_item, int *pi_status )
/* Create thread and set locks. */
vlc_mutex_init( &p_input->stream.stream_lock );
vlc_cond_init( &p_input->stream.stream_wait );
vlc_mutex_init( &p_input->stream.control.control_lock );
if( vlc_thread_create( &p_input->thread_id, "input", (void *) RunThread,
(void *) p_input ) )
......@@ -161,6 +162,11 @@ void input_DestroyThread( input_thread_t *p_input, int *pi_status )
/* Request thread destruction */
p_input->b_die = 1;
/* Make the thread exit of an eventual vlc_cond_wait() */
vlc_mutex_lock( &p_input->stream.stream_lock );
vlc_cond_signal( &p_input->stream.stream_wait );
vlc_mutex_unlock( &p_input->stream.stream_lock );
/* If status is NULL, wait until thread has been destroyed */
if( pi_status == NULL )
{
......
......@@ -2,7 +2,7 @@
* input_clock.c: Clock/System date convertions, stream management
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: input_clock.c,v 1.4 2001/02/07 17:56:21 massiot Exp $
* $Id: input_clock.c,v 1.5 2001/02/08 13:08:03 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -217,15 +217,23 @@ void input_ClockManageRef( input_thread_t * p_input,
vlc_mutex_lock( &p_input->stream.stream_lock );
if( p_input->stream.i_new_status != UNDEF_S )
{
/* For the moment, only PLAYING_S and FORWARD_S are
* supported. */
input_ClockNewRef( p_input, p_pgrm, i_clock,
ClockToSysdate( p_input, p_pgrm, i_clock ) );
if( p_input->stream.i_new_status == PAUSE_S )
{
vlc_cond_wait( &p_input->stream.stream_wait,
&p_input->stream.stream_lock );
input_ClockNewRef( p_input, p_pgrm, i_clock, mdate() );
}
else
{
input_ClockNewRef( p_input, p_pgrm, i_clock,
ClockToSysdate( p_input, p_pgrm, i_clock ) );
}
vlc_mutex_lock( &p_input->stream.control.control_lock );
p_input->stream.control.i_status = p_input->stream.i_new_status;
if( p_input->stream.control.i_status != PLAYING_S )
if( p_input->stream.control.i_status != PLAYING_S
&& p_input->stream.control.i_status != PAUSE_S )
{
p_input->stream.control.i_rate = p_input->stream.i_new_rate;
p_input->stream.control.b_mute = 1;
......
......@@ -46,6 +46,7 @@ void input_Play( input_thread_t * p_input )
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 );
}
......@@ -74,6 +75,17 @@ void input_Forward( input_thread_t * p_input, int i_rate )
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 );
}
/*****************************************************************************
* input_Pause: temporarily stops the reading of the stream
*****************************************************************************/
void input_Pause( input_thread_t * p_input )
{
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 );
}
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