Page 1 of 1
libvlc_audio_set_volume crashes libvlccore 2.1.0
Posted: 06 Oct 2013 13:37
by r21514
I get floating point error from libvlccore when using libvlc_audio_set_volume while playback, no crash if playback is stopped. On 2.0.x there is no problem. Tested on Win8x86 and Win7x64.
Maybe parameters changed and somebody forgot to update documentation?
Re: libvlc_audio_set_volume crashes libvlccore 2.1.0
Posted: 07 Oct 2013 14:17
by mangokm40
You might need to provide more information. I'm not having any problem. I'm using:
libvlc_audio_set_volume(vlcPlayer, vol);
...where vol is int from 0 to 200.
It's compiled using 32-bit libvlc, running in WinXP (32bit) and Win7 (32 and 64bit).
Re: libvlc_audio_set_volume crashes libvlccore 2.1.0
Posted: 07 Oct 2013 15:12
by r21514
I'm doing exactly the same as you.
libvlc_audio_set_volume : function(p_media_player : Plibvlc_media_player_t; volume : Integer) : Integer; cdecl;
All worked on 1.1.x and 2.0.x, but with 2.1.0 I get floating point error from module libvlccore.dll when calling libvlc_audio_set_volume with any value >0 while playback is active.
I'm using delphi7 and this wrapper -
https://code.google.com/p/utlibvlc/
BTW what lang/compiler are you using?
Re: libvlc_audio_set_volume crashes libvlccore 2.1.0
Posted: 07 Oct 2013 16:14
by mangokm40
I guess you can look into the delphi wrapper, then. I'm writing in C.
Re: libvlc_audio_set_volume crashes libvlccore 2.1.0
Posted: 07 Oct 2013 16:26
by r21514
MSVC or QT ? I tested a C# .NET 3.5 wrapper in MSVC and it crashes with the same floating point error.
But my friend compiled demo QtVLC by QT-Creator and it worked without errors.
The thing is call to function is exactly the same everywhere...
BTW function libvlc_audio_set_volume always returns 0 in my situation
Re: libvlc_audio_set_volume crashes libvlccore 2.1.0
Posted: 07 Oct 2013 17:07
by mangokm40
I don't use a "wrapper". My code is C/C++. I'm not having any problem with libvlc_audio_set_volume() calls during playback.
Re: libvlc_audio_set_volume crashes libvlccore 2.1.0
Posted: 07 Oct 2013 17:32
by r21514
vvv
Re: libvlc_audio_set_volume crashes libvlccore 2.1.0
Posted: 08 Oct 2013 05:26
by r21514
Here is my code. No wrappers, just direct calls. It can be easy rewritten to any language:
Code: Select all
program Test;
function AllocConsole:LongBool; stdcall; external 'kernel32.dll';
function libvlc_new(argc:integer; args:ppchar):pointer; cdecl; external 'libvlc.dll';
function libvlc_media_new_path(vlc: pointer; mrl : pchar):pointer;cdecl; external 'libvlc.dll';
function libvlc_media_player_new_from_media(media: pointer): pointer; cdecl; external 'libvlc.dll';
procedure libvlc_media_player_play(mediaplayer: pointer); cdecl; external 'libvlc.dll';
procedure libvlc_audio_set_volume(mediaplayer: pointer; volume:integer); cdecl; external 'libvlc.dll';
var
args:array of pchar;
fn:string;
v:integer;
p_libvlc,p_media,p_player:pointer;
begin
AllocConsole;
SetLength(args,5);
args[0]:=pchar('--plugin-path=..\plugins');
args[1]:=pchar('--no-osd');
args[2]:=pchar('--no-media-library');
args[3]:=pchar('--no-video-title-show');
args[4]:=nil;
p_libvlc:=libvlc_new(System.Length(args)-1,@args[0]);
if p_libvlc=nil then begin WriteLn('p_libvlc is nil');ReadLn;Halt;end;
fn:='e:\bla-bla.avi'; // whatever
p_media:=libvlc_media_new_path(p_libvlc,pchar(fn));
if p_media=nil then begin WriteLn('p_media is nil');ReadLn;Halt;end;
p_player:=libvlc_media_player_new_from_media(p_media);
if p_player=nil then begin WriteLn('p_player is nil');ReadLn;Halt;end;
libvlc_media_player_play(p_player);
WriteLn('Press ENTER when video playback starts');
ReadLn;
v:=30;
libvlc_audio_set_volume(p_player,v); // crash right here with error 207 (floating point) from libvlccore
WriteLn('Vol 30');
ReadLn;
v:=50;
libvlc_audio_set_volume(p_player,v);
WriteLn('Vol 50');
WriteLn('Press ENTER to end');
ReadLn;
end.
Comiled binary and source here -
http://rghost.ru/49230940
Works with 1.1.x and 2.0.x, crashes 2.1.x and 2.2.x (nightly)
audio.c (libvlc)
Code: Select all
int libvlc_audio_set_volume( libvlc_media_player_t *mp, int volume )
{
float vol = volume / 100.f;
if (vol < 0.f)
{
libvlc_printerr( "Volume out of range" );
return -1;
}
int ret = -1;
audio_output_t *aout = GetAOut( mp );
if( aout != NULL )
{
ret = aout_VolumeSet( aout, vol );
vlc_object_release( aout );
}
return ret;
}
output.c (libvlccore)
Code: Select all
int aout_VolumeSet (audio_output_t *aout, float vol)
{
aout_owner_t *owner = aout_owner (aout);
assert (vol >= 0.f);
vlc_mutex_lock (&owner->req.lock);
owner->req.volume = vol;
vlc_mutex_unlock (&owner->req.lock);
if (aout_OutputTryLock (aout) == 0)
aout_OutputUnlock (aout);
return 0;
}
I don't get how can that assert from second function happen when there is an "if" with same condition in first one?
Re: libvlc_audio_set_volume crashes libvlccore 2.1.0
Posted: 13 Oct 2013 14:37
by BoDan
Same Problem with set audio volume in delphi:
I can reproduce the failure with the provided sample console program from r21514
Is there a need to do additional calls bevore using set audio volume (set audio mute works fine though)..
Re: libvlc_audio_set_volume crashes libvlccore 2.1.0
Posted: 27 Oct 2013 09:43
by DsChAeK
The same here with Win7 64bit and Delphi 5. (Exception EInvalidOp)
If this error happens the stream freezes and if I call libvlc_media_player_stop() my program hangs up.
Re: libvlc_audio_set_volume crashes libvlccore 2.1.0
Posted: 13 Nov 2013 10:33
by r21514
There is no crash with "aout=waveout", so the problem in only with directsound.
I went through binaries from nightlies.videolan.org and that's what I've found:
vlc-2.1.0-git-20130204-0002-win32 - works ok like old 2.0.x
vlc-2.1.0-git-20130211-0003-win32 - crashes like 2.1.0 release
I've read diff report on difference between 20130204 and 20130211 sources.
There are some changes in modules\audio_output\directx.c about type of "directx-volume" variable, it changed from integer to
float (and we have floating point error, remember?).
Anyway I took plugins\audio_output\libdirectsound_plugin.dll from vlc-2.1.0-20130204-0002 and put into vlc-2.1.0-release and I have no crash, everything works.
So that's temporary solution. Dll can be downloaded
here.
Re: libvlc_audio_set_volume crashes libvlccore 2.1.0
Posted: 13 Nov 2013 19:46
by DsChAeK
Nice workaround, thx for finding it out!
Re: libvlc_audio_set_volume crashes libvlccore 2.1.0
Posted: 18 Nov 2013 23:42
by Jean-Baptiste Kempf
That's only temporary. Finding the real fix would be nice.
Re: libvlc_audio_set_volume crashes libvlccore 2.1.0
Posted: 19 Nov 2013 18:47
by r21514
Sorry, I don't have enough knowledge of C/C++ and VLC architecture to understand massive changes in directx.c between those two dates.
I understood that type of volume level variable was changed, but that led to many other changes, and I can't debug VLC code from delphi to get exact crash line.
Re: libvlc_audio_set_volume crashes libvlccore 2.1.0
Posted: 19 Apr 2014 17:02
by celeburdi
Delphi Solution:
Some of drivers cause floating point
errors, which are converted to exceptions. These exceptions can be disabled with the
SetExceptionMask function of the Math unit, as follows:
SetExceptionMask([exInvalidOp, exDenormalized, exZeroDivide,
exOverflow, exUnderflow, exPrecision]); //<= default c runtime fpu exception handling
Then You can use libvlc_audio_set_volume without exception.
Re: libvlc_audio_set_volume crashes libvlccore 2.1.0
Posted: 05 Mar 2015 13:30
by r21514
Problem with DirectSound is still present in VLC 2.2
Re: libvlc_audio_set_volume crashes libvlccore 2.1.0
Posted: 05 Mar 2015 15:14
by RĂ©mi Denis-Courmont
This rather looks like a bug in the Delphi wrapper that you are using. Maths exception handling is the most likely problem.
Re: libvlc_audio_set_volume crashes libvlccore 2.1.0
Posted: 18 Mar 2015 19:45
by r21514
I'm not using any wrapper, just direct calls to dll functions. So the bug is delphi itself.
My solution is:
Code: Select all
Set8087CW((Get8087CW and $FFC0) or $003F);
It must be the same that
celeburdi recomended.
[SOLVED]
But still there in an unsafe floating point operation somewhere in libdirectsound...