vlc | branch: master | Rémi Denis-Courmont <[email protected]> | Sun Nov 22 17:57:55 2020 +0200| [80b8c8254cb2fddd59d31ba3a46a6640d7ef23da] | committer: Rémi Denis-Courmont
cli: mostly restore 3.0 volume scale Integers 2...512 use the old scale (mostly fixes #25143). Floating point values are taken as is. > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=80b8c8254cb2fddd59d31ba3a46a6640d7ef23da --- modules/control/cli/player.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/modules/control/cli/player.c b/modules/control/cli/player.c index 557a0d31b8..4528475c2f 100644 --- a/modules/control/cli/player.c +++ b/modules/control/cli/player.c @@ -610,14 +610,28 @@ static int PlayerFullscreen(intf_thread_t *intf, const char *const *args, static int Volume(intf_thread_t *intf, const char *const *args, size_t count) { - const char *arg = count > 1 ? args[1] : ""; vlc_player_t *player = vlc_playlist_GetPlayer(intf->p_sys->playlist); vlc_player_Lock(player); - if ( *arg ) + if (count == 2) { - /* Set. */ - float volume = atol(arg) / 100.f; + /* NOTE: For unfortunate hysterical raisins, integer value above 1 are + * interpreted in a scale of 256 parts. Floating point values are taken + * as ratio as usual in the VLC code. + * Yes, this sucks (hopefully nobody uses volume 1/256). + */ + char *end; + unsigned long ul = strtoul(args[1], &end, 10); + float volume; + + static_assert ((AOUT_VOLUME_DEFAULT & (AOUT_VOLUME_DEFAULT - 1)) == 0, + "AOUT_VOLUME_DEFAULT must be a power of two."); + + if (*end == '\0' && ul > 1 && ul <= AOUT_VOLUME_MAX) + volume = ldexpf(ul, -ctz(AOUT_VOLUME_DEFAULT)); + else + volume = atof(args[1]); + vlc_player_aout_SetVolume(player, volume); } else _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
