listen.el icon indicating copy to clipboard operation
listen.el copied to clipboard

VLC player version 3.0.21 (other don't check) don't support float vol…

Open demoj1 opened this issue 1 year ago • 4 comments

VLC player version 3.0.21 (other don't check) don't support float volume control.

VLC media player 3.0.21 Vetinari
Command Line Interface initialized. Type `help' for help.
> volume 1.5
Error in `volume 1.5' lua/modules/common.lua:207: bad argument #1 to 'set' (number has no integer representation)

Changed vlc volume format from %s to %i. I can't imagine any case, that who control volume more precision that integer.

demoj1 avatar Oct 08 '24 06:10 demoj1

I have the same version of VLC and I don't have this problem.

alphapapa avatar Oct 09 '24 00:10 alphapapa

Anyway, if it potential problem, maybe merge this? How i wrote up, i can't imagine any case for float volume control.

demoj1 avatar Oct 09 '24 03:10 demoj1

Hmmm, i checked VLC source code, and find that volume must be integer. It's lua script: https://github.com/videolan/vlc/blob/master/share/lua/modules/common.lua#L202

function common.volume(value)
    if type(value)=="string" and string.sub(value,1,1) == "+" or string.sub(value,1,1) == "-" then
        vlc.volume.set(vlc.volume.get()+tonumber(value))
    else
        vlc.volume.set(tostring(value))
    end
end

which call C function https://github.com/videolan/vlc/blob/master/modules/lua/libs/volume.c#L49C43-L49C43, function check value on integer type:

static int vlclua_volume_set(lua_State *L)
{
    vlc_playlist_t *playlist = vlclua_get_playlist_internal(L);
    vlc_player_t *player = vlc_playlist_GetPlayer(playlist);

    int i_volume = luaL_checkinteger(L, 1); // <---------------------- HERE
    if (i_volume < 0)
        i_volume = 0;

    float volume = i_volume / (float) AOUT_VOLUME_DEFAULT;
    int ret = vlc_player_aout_SetVolume(player, volume);
    return vlclua_push_ret(L, ret);
}

demoj1 avatar Oct 09 '24 04:10 demoj1

It looks like the value passed to vlc_player_aout_SetVolume is a float, as shown by the line above that function call. The i_volume value is an integer, but I don't know what luaL_checkinteger does. From the Lua code, it appears that it may be called with a number or a string value, so I wouldn't be surprised if luaL_checkinteger converts a string of a float value into an integer.

You may want to do some research on the VLC bug tracker, where there are issues about volume values and types. Also, you can try running the VLC remote control interface from a terminal and try issuing volume commands with various values.

Obviously, I want this to work for you and all users. But since we have the same VLC version but don't both have this problem, I want to understand it before changing the code.

alphapapa avatar Oct 09 '24 23:10 alphapapa

This would be best handled as an issue, i.e. if a user is perceiving a bug, it should be filed as one.

alphapapa avatar Jan 31 '25 03:01 alphapapa