* input_ext-intf.c: services to the interface
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
- * $Id: input_ext-intf.c,v 1.43 2002/11/11 14:39:12 sam Exp $
+ * $Id: input_ext-intf.c,v 1.50 2003/05/31 12:24:39 titer Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
break;
case INPUT_STATUS_FASTER:
- /* If we are already going too fast, go back to default rate */
if( p_input->stream.control.i_rate * 8 <= DEFAULT_RATE )
{
- p_input->stream.i_new_status = PLAYING_S;
- msg_Dbg( p_input, "playing at normal rate" );
+ msg_Dbg( p_input, "can not play any faster" );
}
else
{
p_input->stream.i_new_status = FORWARD_S;
+ p_input->stream.i_new_rate =
+ p_input->stream.control.i_rate / 2;
- if( p_input->stream.control.i_rate < DEFAULT_RATE
- && p_input->stream.control.i_status == FORWARD_S )
+ if ( p_input->stream.i_new_rate < DEFAULT_RATE )
{
- p_input->stream.i_new_rate =
- p_input->stream.control.i_rate / 2;
+ msg_Dbg( p_input, "playing at %i:1 fast forward",
+ DEFAULT_RATE / p_input->stream.i_new_rate );
}
- else
+ else if ( p_input->stream.i_new_rate > DEFAULT_RATE )
{
- p_input->stream.i_new_rate = DEFAULT_RATE / 2;
+ msg_Dbg( p_input, "playing at 1:%i slow motion",
+ p_input->stream.i_new_rate / DEFAULT_RATE );
+ }
+ else if ( p_input->stream.i_new_rate == DEFAULT_RATE )
+ {
+ p_input->stream.i_new_status = PLAYING_S;
+ msg_Dbg( p_input, "playing at normal rate" );
}
- msg_Dbg( p_input, "playing at %i:1 fast forward",
- DEFAULT_RATE / p_input->stream.i_new_rate );
}
break;
case INPUT_STATUS_SLOWER:
- /* If we are already going too slow, go back to default rate */
if( p_input->stream.control.i_rate >= 8 * DEFAULT_RATE )
{
- p_input->stream.i_new_status = PLAYING_S;
- msg_Dbg( p_input, "playing at normal rate" );
+ msg_Dbg( p_input, "can not play any slower" );
}
else
{
p_input->stream.i_new_status = FORWARD_S;
+ p_input->stream.i_new_rate =
+ p_input->stream.control.i_rate * 2;
- if( p_input->stream.control.i_rate > DEFAULT_RATE
- && p_input->stream.control.i_status == FORWARD_S )
+ if ( p_input->stream.i_new_rate < DEFAULT_RATE )
{
- p_input->stream.i_new_rate =
- p_input->stream.control.i_rate * 2;
+ msg_Dbg( p_input, "playing at %i:1 fast forward",
+ DEFAULT_RATE / p_input->stream.i_new_rate );
}
- else
+ else if ( p_input->stream.i_new_rate > DEFAULT_RATE )
{
- p_input->stream.i_new_rate = DEFAULT_RATE * 2;
- }
- msg_Dbg( p_input, "playing at 1:%i slow motion",
+ msg_Dbg( p_input, "playing at 1:%i slow motion",
p_input->stream.i_new_rate / DEFAULT_RATE );
+ }
+ else if ( p_input->stream.i_new_rate == DEFAULT_RATE )
+ {
+ p_input->stream.i_new_status = PLAYING_S;
+ msg_Dbg( p_input, "playing at normal rate" );
+ }
}
break;
vlc_object_release( p_input );
}
+void __input_SetRate( vlc_object_t * p_this, int i_rate )
+{
+ input_thread_t *p_input;
+
+ p_input = vlc_object_find( p_this, VLC_OBJECT_INPUT, FIND_PARENT );
+
+ if( p_input == NULL )
+ {
+ msg_Err( p_this, "no input found" );
+ return;
+ }
+
+ vlc_mutex_lock( &p_input->stream.stream_lock );
+
+ if( i_rate * 8 < DEFAULT_RATE )
+ {
+ msg_Dbg( p_input, "can not play faster than 8x" );
+ vlc_mutex_unlock( &p_input->stream.stream_lock );
+ return;
+ }
+ if( i_rate > DEFAULT_RATE * 8 )
+ {
+ msg_Dbg( p_input, "can not play slower than 1/8x" );
+ vlc_mutex_unlock( &p_input->stream.stream_lock );
+ return;
+ }
+
+ p_input->stream.i_new_status = FORWARD_S;
+ p_input->stream.i_new_rate = i_rate;
+
+ if ( p_input->stream.i_new_rate < DEFAULT_RATE )
+ {
+ msg_Dbg( p_input, "playing at %i:1 fast forward",
+ DEFAULT_RATE / p_input->stream.i_new_rate );
+ }
+ else if ( p_input->stream.i_new_rate > DEFAULT_RATE )
+ {
+ msg_Dbg( p_input, "playing at 1:%i slow motion",
+ p_input->stream.i_new_rate / DEFAULT_RATE );
+ }
+ else if ( p_input->stream.i_new_rate == DEFAULT_RATE )
+ {
+ p_input->stream.i_new_status = PLAYING_S;
+ msg_Dbg( p_input, "playing at normal rate" );
+ }
+
+ vlc_cond_signal( &p_input->stream.stream_wait );
+ vlc_mutex_unlock( &p_input->stream.stream_lock );
+
+ vlc_object_release( p_input );
+}
+
/*****************************************************************************
* input_Seek: changes the stream postion
*****************************************************************************/
*****************************************************************************/
void input_DumpStream( input_thread_t * p_input )
{
- int i, j;
- char psz_time1[OFFSETTOTIME_MAX_SIZE];
- char psz_time2[OFFSETTOTIME_MAX_SIZE];
+ char psz_time1[OFFSETTOTIME_MAX_SIZE];
+ char psz_time2[OFFSETTOTIME_MAX_SIZE];
+ unsigned int i, j;
#define S p_input->stream
- msg_Dbg( p_input, "dumping stream ID 0x%x [OK:%d/D:%d]", S.i_stream_id,
+ msg_Dbg( p_input, "dumping stream ID 0x%x [OK:%ld/D:%ld]", S.i_stream_id,
S.c_packets_read, S.c_packets_trashed );
if( S.b_seekable )
msg_Dbg( p_input, "seekable stream, position: "I64Fd"/"I64Fd" (%s/%s)",
for( j = 0; j < p_input->stream.pp_programs[i]->i_es_number; j++ )
{
#define ES p_input->stream.pp_programs[i]->pp_es[j]
- msg_Dbg( p_input,
- "ES 0x%x, stream 0x%x, fourcc `%4.4s', %s [OK:%d/ERR:%d]",
+ msg_Dbg( p_input, "ES 0x%x, "
+ "stream 0x%x, fourcc `%4.4s', %s [OK:%ld/ERR:%ld]",
ES->i_id, ES->i_stream_id, (char*)&ES->i_fourcc,
ES->p_decoder_fifo != NULL ? "selected" : "not selected",
ES->c_packets, ES->c_invalid_packets );
/****************************************************************************
* input_ChangeProgram: interface request a program change
****************************************************************************/
-int input_ChangeProgram( input_thread_t * p_input, u16 i_program_number )
+int input_ChangeProgram( input_thread_t * p_input, uint16_t i_program_number )
{
pgrm_descriptor_t * p_program;
-
+ vlc_value_t val;
+
vlc_mutex_lock( &p_input->stream.stream_lock );
p_program = input_FindProgram( p_input, i_program_number );
}
p_input->stream.p_new_program = p_program;
-
+
vlc_mutex_unlock( &p_input->stream.stream_lock );
+ /* Update the navigation variables without triggering a callback */
+ val.i_int = i_program_number;
+ var_Change( p_input, "program", VLC_VAR_SETVALUE, &val, NULL );
+
return 0;
}