]> git.sesse.net Git - vlc/blob - src/input/input_ext-intf.c
* Pause function implemented ('p' key).
[vlc] / src / input / input_ext-intf.c
1 /*****************************************************************************
2  * input_ext-intf.c: services to the interface
3  *****************************************************************************
4  * Copyright (C) 1998, 1999, 2000 VideoLAN
5  *
6  * Authors: 
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  * 
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
21  *****************************************************************************/
22
23 /*****************************************************************************
24  * Preamble
25  *****************************************************************************/
26 #include "defs.h"
27
28 #include "config.h"
29 #include "common.h"
30 #include "threads.h"
31 #include "mtime.h"
32
33 #include "intf_msg.h"
34
35 #include "stream_control.h"
36 #include "input_ext-dec.h"
37 #include "input_ext-intf.h"
38
39 #include "input.h"
40
41 /*****************************************************************************
42  * input_Play: comes back to the normal pace of reading
43  *****************************************************************************/
44 void input_Play( input_thread_t * p_input )
45 {
46     intf_Msg( "input: playing at normal rate" );
47     vlc_mutex_lock( &p_input->stream.stream_lock );
48     p_input->stream.i_new_status = PLAYING_S;
49     vlc_cond_signal( &p_input->stream.stream_wait );
50     vlc_mutex_unlock( &p_input->stream.stream_lock );
51 }
52
53 /*****************************************************************************
54  * input_Forward: manages fast forward and slow motion
55  *****************************************************************************
56  * Note that if i_rate > DEFAULT_RATE, the pace is slower.
57  *****************************************************************************/
58 void input_Forward( input_thread_t * p_input, int i_rate )
59 {
60     if ( i_rate > DEFAULT_RATE )
61     {
62         intf_Msg( "input: playing at 1:%i slow motion", i_rate / 1000 );
63     }
64     else if( i_rate < DEFAULT_RATE )
65     {
66         intf_Msg( "input: playing at %i:1 fast forward", 1000 / i_rate );
67     }
68     else
69     {
70         /* Not very joli, but this is going to disappear soon anyway */
71         input_Play( p_input );
72         return;
73     }
74
75     vlc_mutex_lock( &p_input->stream.stream_lock );
76     p_input->stream.i_new_status = FORWARD_S;
77     p_input->stream.i_new_rate = i_rate;
78     vlc_cond_signal( &p_input->stream.stream_wait );
79     vlc_mutex_unlock( &p_input->stream.stream_lock );
80 }
81
82 /*****************************************************************************
83  * input_Pause: temporarily stops the reading of the stream
84  *****************************************************************************/
85 void input_Pause( input_thread_t * p_input )
86 {
87     vlc_mutex_lock( &p_input->stream.stream_lock );
88     p_input->stream.i_new_status = PAUSE_S;
89     vlc_cond_signal( &p_input->stream.stream_wait );
90     vlc_mutex_unlock( &p_input->stream.stream_lock );
91 }