]> git.sesse.net Git - vlc/blob - src/input/input_ext-intf.c
. removed tests against i_rate and i_new_rate calculation from the
[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: Christophe Massiot <massiot@via.ecp.fr>
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_SetRate: change the reading pace
43  *****************************************************************************/
44 void input_SetRate( input_thread_t * p_input, int i_mode )
45 {
46     vlc_mutex_lock( &p_input->stream.stream_lock );
47
48     switch( i_mode )
49     {
50     case INPUT_RATE_PLAY:
51         p_input->stream.i_new_status = PLAYING_S;
52         intf_Msg( "input: playing at normal rate" );
53         break;
54
55     case INPUT_RATE_PAUSE:
56         /* XXX: we don't need to check i_status, because input_clock.c
57          * does it for us */
58         p_input->stream.i_new_status = PAUSE_S;
59         intf_Msg( "input: toggling pause" );
60         break;
61
62     case INPUT_RATE_FASTER:
63         /* If we are already going too fast, go back to default rate */
64         if( p_input->stream.control.i_rate * 8 <= DEFAULT_RATE )
65         {
66             p_input->stream.i_new_status = PLAYING_S;
67             intf_Msg( "input: playing at normal rate" );
68         }
69         else
70         {
71             p_input->stream.i_new_status = FORWARD_S;
72
73             if( p_input->stream.control.i_rate < DEFAULT_RATE
74                     && p_input->stream.control.i_status == FORWARD_S )
75             {
76                 p_input->stream.i_new_rate =
77                                     p_input->stream.control.i_rate / 2;
78             }
79             else
80             {
81                 p_input->stream.i_new_rate = DEFAULT_RATE / 2;
82             }
83             intf_Msg( "input: playing at %i:1 fast forward",
84                       DEFAULT_RATE / p_input->stream.i_new_rate );
85         }
86         break;
87
88     case INPUT_RATE_SLOWER:
89         /* If we are already going too slow, go back to default rate */
90         if( p_input->stream.control.i_rate >= 8 * DEFAULT_RATE )
91         {
92             p_input->stream.i_new_status = PLAYING_S;
93             intf_Msg( "input: playing at normal rate" );
94         }
95         else
96         {
97             p_input->stream.i_new_status = FORWARD_S;
98
99             if( p_input->stream.control.i_rate > DEFAULT_RATE
100                     && p_input->stream.control.i_status == FORWARD_S )
101             {
102                 p_input->stream.i_new_rate =
103                                     p_input->stream.control.i_rate * 2;
104             }
105             else
106             {
107                 p_input->stream.i_new_rate = DEFAULT_RATE * 2;
108             }
109             intf_Msg( "input: playing at 1:%i slow motion",
110                       p_input->stream.i_new_rate / DEFAULT_RATE );
111         }
112         break;
113
114     default:
115     }
116
117     vlc_cond_signal( &p_input->stream.stream_wait );
118     vlc_mutex_unlock( &p_input->stream.stream_lock );
119 }
120
121 /*****************************************************************************
122  * input_Seek: changes the stream postion
123  *****************************************************************************/
124 void input_Seek( input_thread_t * p_input, off_t i_position )
125 {
126     intf_Msg( "input: seeking position %lld/%lld", i_position,
127                                                    p_input->stream.i_size );
128     vlc_mutex_lock( &p_input->stream.stream_lock );
129     p_input->stream.i_seek = i_position;
130     vlc_cond_signal( &p_input->stream.stream_wait );
131     vlc_mutex_unlock( &p_input->stream.stream_lock );
132 }
133