- /* Problem with this way: the "rate" variable is update after the input thread do the change */
- if( !strcmp( psz_cmd, "rate-slower" ) )
- {
- input_ControlPush( p_input, INPUT_CONTROL_SET_RATE_SLOWER, NULL );
- }
- else if( !strcmp( psz_cmd, "rate-faster" ) )
+ newval.i_int = INPUT_RATE_DEFAULT / newval.f_float;
+ input_ControlPush( p_input, INPUT_CONTROL_SET_RATE, &newval );
+
+ return VLC_SUCCESS;
+}
+
+static int RateOffsetCallback( vlc_object_t *p_this, char const *psz_cmd,
+ vlc_value_t oldval, vlc_value_t newval, void *p_data )
+{
+ input_thread_t *p_input = (input_thread_t*)p_this;
+ VLC_UNUSED(oldval); VLC_UNUSED(p_data); VLC_UNUSED(newval);
+
+ static const float pf_rate[] = {
+ 1.0/64, 1.0/32, 1.0/16, 1.0/8, 1.0/4, 1.0/3, 1.0/2, 2.0/3,
+ 1.0/1,
+ 3.0/2, 2.0/1, 3.0/1, 4.0/1, 8.0/1, 16.0/1, 32.0/1, 64.0/1,
+ };
+ const unsigned i_rate_count = sizeof(pf_rate)/sizeof(*pf_rate);
+
+ const float f_rate = var_GetFloat( p_input, "rate" );
+
+ /* Determine the factor closest to the current rate */
+ float f_error;
+ int i_idx;
+ for( unsigned i = 0; i < i_rate_count; i++ )