Commit 73713727 authored by Laurent Aimar's avatar Laurent Aimar

Added hotkeys for fine playback rate control.

parent bbbebb32
......@@ -345,6 +345,8 @@ typedef enum vlc_key {
ACTIONID_SCALE_DOWN,
/* */
ACTIONID_RATE_NORMAL,
ACTIONID_RATE_SLOWER_FINE,
ACTIONID_RATE_FASTER_FINE,
} vlc_key_t;
#endif
......@@ -39,6 +39,7 @@
#include <vlc_osd.h>
#include <vlc_playlist.h>
#include "vlc_keys.h"
#include "math.h"
#define BUFFER_SIZE 10
......@@ -773,7 +774,34 @@ static void Run( intf_thread_t *p_intf )
{
var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT );
vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN,
_("1x") );
_("1.00x") );
}
else if( i_action == ACTIONID_RATE_FASTER_FINE ||
i_action == ACTIONID_RATE_SLOWER_FINE )
{
/* The playback rate is defined by INPUT_RATE_DEFAULT / "rate"
* and we want to increase/decrease it by 0.1 while making sure
* that the resulting playback rate is a multiple of 0.1
*/
int i_rate = var_GetInteger( p_input, "rate" );
if( i_rate == 0 )
i_rate = INPUT_RATE_MIN;
int i_sign = i_rate < 0 ? -1 : 1;
const int i_dir = i_action == ACTIONID_RATE_FASTER_FINE ? 1 : -1;
const double f_speed = floor( ( (double)INPUT_RATE_DEFAULT / abs(i_rate) + 0.05 ) / 0.1 + i_dir ) * 0.1;
if( f_speed <= (double)INPUT_RATE_DEFAULT / INPUT_RATE_MAX ) /* Needed to avoid infinity */
i_rate = INPUT_RATE_MAX;
else
i_rate = INPUT_RATE_DEFAULT / f_speed + 0.5;
i_rate = i_sign * __MIN( __MAX( i_rate, INPUT_RATE_MIN ), INPUT_RATE_MAX );
var_SetInteger( p_input, "rate", i_rate );
char psz_msg[7+1];
snprintf( psz_msg, sizeof(psz_msg), _("%.2fx"), (double)INPUT_RATE_DEFAULT / i_rate );
vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN, psz_msg );
}
else if( i_action == ACTIONID_POSITION && b_seekable )
{
......
......@@ -1217,6 +1217,10 @@ static const char *const ppsz_albumart_descriptions[] =
#define SLOWER_KEY_LONGTEXT N_("Select the hotkey to use for slow motion playback.")
#define RATE_NORMAL_KEY_TEXT N_("Normal rate")
#define RATE_NORMAL_KEY_LONGTEXT N_("Select the hotkey to set the playback rate back to normal.")
#define RATE_FASTER_FINE_KEY_TEXT N_("Faster (fine)")
#define RATE_FASTER_FINE_KEY_LONGTEXT N_("Select the hotkey to use for fast forward playback.")
#define RATE_SLOWER_FINE_KEY_TEXT N_("Slower (fine)")
#define RATE_SLOWER_FINE_KEY_LONGTEXT N_("Select the hotkey to use for slow motion playback.")
#define NEXT_KEY_TEXT N_("Next")
#define NEXT_KEY_LONGTEXT N_("Select the hotkey to use to skip to the next item in the playlist.")
#define PREV_KEY_TEXT N_("Previous")
......@@ -2117,6 +2121,8 @@ vlc_module_begin ()
# define KEY_FASTER KEY_MODIFIER_COMMAND|'='
# define KEY_SLOWER KEY_MODIFIER_COMMAND|'-'
# define KEY_RATE_NORMAL KEY_UNSET
# define KEY_RATE_FASTER_FINE KEY_UNSET
# define KEY_RATE_SLOWER_FINE KEY_UNSET
# define KEY_NEXT KEY_MODIFIER_COMMAND|KEY_RIGHT
# define KEY_PREV KEY_MODIFIER_COMMAND|KEY_LEFT
# define KEY_STOP KEY_MODIFIER_COMMAND|'.'
......@@ -2229,6 +2235,8 @@ vlc_module_begin ()
# define KEY_FASTER '+'
# define KEY_SLOWER '-'
# define KEY_RATE_NORMAL KEY_UNSET
# define KEY_RATE_FASTER_FINE KEY_UNSET
# define KEY_RATE_SLOWER_FINE KEY_UNSET
# define KEY_NEXT 'n'
# define KEY_PREV 'p'
# define KEY_STOP 's'
......@@ -2351,6 +2359,10 @@ vlc_module_begin ()
SLOWER_KEY_LONGTEXT, false )
add_key( "key-rate-normal", KEY_RATE_NORMAL, NULL, RATE_NORMAL_KEY_TEXT,
RATE_NORMAL_KEY_LONGTEXT, false )
add_key( "key-rate-faster-fine", KEY_RATE_FASTER_FINE, NULL, RATE_FASTER_FINE_KEY_TEXT,
RATE_FASTER_FINE_KEY_LONGTEXT, false )
add_key( "key-rate-slower-fine", KEY_RATE_SLOWER_FINE, NULL, RATE_SLOWER_FINE_KEY_TEXT,
RATE_SLOWER_FINE_KEY_LONGTEXT, false )
add_key( "key-next", KEY_NEXT, NULL, NEXT_KEY_TEXT,
NEXT_KEY_LONGTEXT, false )
add_key( "key-prev", KEY_PREV, NULL, PREV_KEY_TEXT,
......@@ -2694,6 +2706,8 @@ const struct hotkey libvlc_hotkeys[] =
{ "key-faster", ACTIONID_FASTER, 0, },
{ "key-slower", ACTIONID_SLOWER, 0, },
{ "key-rate-normal", ACTIONID_RATE_NORMAL, 0, },
{ "key-rate-faster-fine", ACTIONID_RATE_FASTER_FINE, 0, },
{ "key-rate-slower-fine", ACTIONID_RATE_SLOWER_FINE, 0, },
{ "key-toggle-fullscreen", ACTIONID_TOGGLE_FULLSCREEN, 0, },
{ "key-leave-fullscreen", ACTIONID_LEAVE_FULLSCREEN, 0, },
{ "key-vol-up", ACTIONID_VOL_UP, 0, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment