libvlc_audio_set_volume crashes libvlccore 2.1.0

This forum is about all development around libVLC.
r21514
Blank Cone
Blank Cone
Posts: 50
Joined: 17 Sep 2009 08:45

libvlc_audio_set_volume crashes libvlccore 2.1.0

Postby r21514 » 06 Oct 2013 13:37

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?

mangokm40
Cone that earned his stripes
Cone that earned his stripes
Posts: 130
Joined: 20 May 2010 20:00

Re: libvlc_audio_set_volume crashes libvlccore 2.1.0

Postby mangokm40 » 07 Oct 2013 14:17

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).

r21514
Blank Cone
Blank Cone
Posts: 50
Joined: 17 Sep 2009 08:45

Re: libvlc_audio_set_volume crashes libvlccore 2.1.0

Postby r21514 » 07 Oct 2013 15:12

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?
Last edited by r21514 on 07 Oct 2013 15:34, edited 1 time in total.

mangokm40
Cone that earned his stripes
Cone that earned his stripes
Posts: 130
Joined: 20 May 2010 20:00

Re: libvlc_audio_set_volume crashes libvlccore 2.1.0

Postby mangokm40 » 07 Oct 2013 16:14

I guess you can look into the delphi wrapper, then. I'm writing in C.

r21514
Blank Cone
Blank Cone
Posts: 50
Joined: 17 Sep 2009 08:45

Re: libvlc_audio_set_volume crashes libvlccore 2.1.0

Postby r21514 » 07 Oct 2013 16:26

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
Last edited by r21514 on 07 Oct 2013 17:09, edited 1 time in total.

mangokm40
Cone that earned his stripes
Cone that earned his stripes
Posts: 130
Joined: 20 May 2010 20:00

Re: libvlc_audio_set_volume crashes libvlccore 2.1.0

Postby mangokm40 » 07 Oct 2013 17:07

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.

r21514
Blank Cone
Blank Cone
Posts: 50
Joined: 17 Sep 2009 08:45

Re: libvlc_audio_set_volume crashes libvlccore 2.1.0

Postby r21514 » 07 Oct 2013 17:32

vvv
Last edited by r21514 on 08 Oct 2013 05:39, edited 1 time in total.

r21514
Blank Cone
Blank Cone
Posts: 50
Joined: 17 Sep 2009 08:45

Re: libvlc_audio_set_volume crashes libvlccore 2.1.0

Postby r21514 » 08 Oct 2013 05:26

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?

BoDan
Blank Cone
Blank Cone
Posts: 11
Joined: 04 Apr 2012 14:20

Re: libvlc_audio_set_volume crashes libvlccore 2.1.0

Postby BoDan » 13 Oct 2013 14:37

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)..

DsChAeK
Blank Cone
Blank Cone
Posts: 59
Joined: 01 Mar 2008 14:54
VLC version: newest
Operating System: windows

Re: libvlc_audio_set_volume crashes libvlccore 2.1.0

Postby DsChAeK » 27 Oct 2013 09:43

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.

r21514
Blank Cone
Blank Cone
Posts: 50
Joined: 17 Sep 2009 08:45

Re: libvlc_audio_set_volume crashes libvlccore 2.1.0

Postby r21514 » 13 Nov 2013 10:33

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.

DsChAeK
Blank Cone
Blank Cone
Posts: 59
Joined: 01 Mar 2008 14:54
VLC version: newest
Operating System: windows

Re: libvlc_audio_set_volume crashes libvlccore 2.1.0

Postby DsChAeK » 13 Nov 2013 19:46

Nice workaround, thx for finding it out!

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: libvlc_audio_set_volume crashes libvlccore 2.1.0

Postby Jean-Baptiste Kempf » 18 Nov 2013 23:42

That's only temporary. Finding the real fix would be nice.
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.

r21514
Blank Cone
Blank Cone
Posts: 50
Joined: 17 Sep 2009 08:45

Re: libvlc_audio_set_volume crashes libvlccore 2.1.0

Postby r21514 » 19 Nov 2013 18:47

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.

celeburdi
New Cone
New Cone
Posts: 1
Joined: 19 Apr 2014 16:25

Re: libvlc_audio_set_volume crashes libvlccore 2.1.0

Postby celeburdi » 19 Apr 2014 17:02

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.

r21514
Blank Cone
Blank Cone
Posts: 50
Joined: 17 Sep 2009 08:45

Re: libvlc_audio_set_volume crashes libvlccore 2.1.0

Postby r21514 » 05 Mar 2015 13:30

Problem with DirectSound is still present in VLC 2.2

Rémi Denis-Courmont
Developer
Developer
Posts: 15266
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: libvlc_audio_set_volume crashes libvlccore 2.1.0

Postby Rémi Denis-Courmont » 05 Mar 2015 15:14

This rather looks like a bug in the Delphi wrapper that you are using. Maths exception handling is the most likely problem.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

r21514
Blank Cone
Blank Cone
Posts: 50
Joined: 17 Sep 2009 08:45

Re: libvlc_audio_set_volume crashes libvlccore 2.1.0

Postby r21514 » 18 Mar 2015 19:45

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...


Return to “Development around libVLC”

Who is online

Users browsing this forum: Bing [Bot] and 13 guests