]> git.sesse.net Git - vlc/commitdiff
* Pause function implemented ('p' key).
authorChristophe Massiot <massiot@videolan.org>
Thu, 8 Feb 2001 13:08:03 +0000 (13:08 +0000)
committerChristophe Massiot <massiot@videolan.org>
Thu, 8 Feb 2001 13:08:03 +0000 (13:08 +0000)
include/input_ext-intf.h
plugins/sdl/intf_sdl.c
src/input/input.c
src/input/input_clock.c
src/input/input_ext-intf.c

index 7916dc1bc256727629d4b8914fd1ed589ad5b110..eb0fcc19726e2938888bbad480dadda787154c3d 100644 (file)
@@ -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 );
index 77555023f69ae0dc0ee3b618fc7951d3e8ac4031..d157ca82eaec5c22f663a2b3ba101c6df9a0fbd1 100644 (file)
@@ -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:
index 47f8c25b764557f4afe5b7a5f0a482506291dab4..3d15f429c109806f32612a7265729cad626d92b6 100644 (file)
@@ -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 )
     {
index 9f1b0bddddbb1c5b665db68795ce7125e42c31af..f603ccd252634ea0d81b8725f2f2fd9be43bfdf3 100644 (file)
@@ -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;
index 9e6245defc2acc59a3413b36402b7ac47362d9a5..dd56ed23c7a1560335a1dfc32f5f9aceba0dd666 100644 (file)
@@ -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 );
+}