1 /*****************************************************************************
2 * input_ext-intf.c: services to the interface
3 *****************************************************************************
4 * Copyright (C) 1998, 1999, 2000 VideoLAN
6 * Authors: Christophe Massiot <massiot@via.ecp.fr>
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.
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.
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 *****************************************************************************/
23 /*****************************************************************************
25 *****************************************************************************/
35 #include "stream_control.h"
36 #include "input_ext-dec.h"
37 #include "input_ext-intf.h"
41 /*****************************************************************************
42 * input_SetStatus: change the reading status
43 *****************************************************************************/
44 void input_SetStatus( input_thread_t * p_input, int i_mode )
46 vlc_mutex_lock( &p_input->stream.stream_lock );
50 case INPUT_STATUS_END:
51 p_input->stream.i_new_status = PLAYING_S;
53 intf_Msg( "input: end of stream" );
56 case INPUT_STATUS_PLAY:
57 p_input->stream.i_new_status = PLAYING_S;
58 intf_Msg( "input: playing at normal rate" );
61 case INPUT_STATUS_PAUSE:
62 /* XXX: we don't need to check i_status, because input_clock.c
64 p_input->stream.i_new_status = PAUSE_S;
65 intf_Msg( "input: toggling pause" );
68 case INPUT_STATUS_FASTER:
69 /* If we are already going too fast, go back to default rate */
70 if( p_input->stream.control.i_rate * 8 <= DEFAULT_RATE )
72 p_input->stream.i_new_status = PLAYING_S;
73 intf_Msg( "input: playing at normal rate" );
77 p_input->stream.i_new_status = FORWARD_S;
79 if( p_input->stream.control.i_rate < DEFAULT_RATE
80 && p_input->stream.control.i_status == FORWARD_S )
82 p_input->stream.i_new_rate =
83 p_input->stream.control.i_rate / 2;
87 p_input->stream.i_new_rate = DEFAULT_RATE / 2;
89 intf_Msg( "input: playing at %i:1 fast forward",
90 DEFAULT_RATE / p_input->stream.i_new_rate );
94 case INPUT_STATUS_SLOWER:
95 /* If we are already going too slow, go back to default rate */
96 if( p_input->stream.control.i_rate >= 8 * DEFAULT_RATE )
98 p_input->stream.i_new_status = PLAYING_S;
99 intf_Msg( "input: playing at normal rate" );
103 p_input->stream.i_new_status = FORWARD_S;
105 if( p_input->stream.control.i_rate > DEFAULT_RATE
106 && p_input->stream.control.i_status == FORWARD_S )
108 p_input->stream.i_new_rate =
109 p_input->stream.control.i_rate * 2;
113 p_input->stream.i_new_rate = DEFAULT_RATE * 2;
115 intf_Msg( "input: playing at 1:%i slow motion",
116 p_input->stream.i_new_rate / DEFAULT_RATE );
123 vlc_cond_signal( &p_input->stream.stream_wait );
124 vlc_mutex_unlock( &p_input->stream.stream_lock );
127 /*****************************************************************************
128 * input_SetRate: change the reading rate
129 *****************************************************************************/
130 void input_SetRate( input_thread_t * p_input, int i_mode )
135 /*****************************************************************************
136 * input_Seek: changes the stream postion
137 *****************************************************************************/
138 void input_Seek( input_thread_t * p_input, off_t i_position )
140 vlc_mutex_lock( &p_input->stream.stream_lock );
141 p_input->stream.pp_areas[0]->i_seek = i_position;
143 intf_Msg( "input: seeking position %lld/%lld", i_position,
144 p_input->stream.pp_areas[0]->i_size );
146 vlc_cond_signal( &p_input->stream.stream_wait );
147 vlc_mutex_unlock( &p_input->stream.stream_lock );