Page 1 of 1

"libvlc_audio_set_volume" problem with VLC 3.0+

Posted: 29 Nov 2018 13:29
by Moriquendi
Hello,

I have multiple embedded players in my application. I could change audio volume of each media seperately with VLC 2.2.8 plugins. With the exact same code, when I switch to VLC 3.0.3 or VLC 3.0.4 plugins, every time I call "libvlc_audio_set_volume", it changes the volume of every active media. I have 4 different media players in the code and here is what's happening roughly:

Code: Select all

libvlc_audio_set_volume(player1->core(), value);
* I open 1st player and change volume of the 1st media only --> mmdevice audio output debug: simple volume changed: 0.238328, muting disabled (the same message prints twice)

Code: Select all

libvlc_audio_set_volume(player2->core(), value);
* I open 2nd player and change volume of the 2nd media only --> mmdevice audio output debug: simple volume changed: 0.238328, muting disabled (the same message prints 8 times)

Code: Select all

libvlc_audio_set_volume(player3->core(), value);
* I open 3rd player and change volume of the 3rd media only --> mmdevice audio output debug: simple volume changed: 0.238328, muting disabled (the same message prints 18 times)

Code: Select all

libvlc_audio_set_volume(player4->core(), value);
* I open 4th player and change volume of the 4th media only --> mmdevice audio output debug: simple volume changed: 0.238328, muting disabled (the same message prints 32 times)

Every time I change the volume of any media, the volumes of all other media change to the same level. Also I dont understand why "mmdevice audio output debug: simple volume changed: 0.238328, muting disabled" log message is printed (probably vlc_AudioSessionEvents_OnSimpleVolumeChanged callback is called?) for 2,8,18 and 32 times respectively even though I call libvlc_audio_set_volume only once.

Again, the same code works perfectly with VLC 2.2.8 plugins. What am I doing wrong? Or is this a bug for VLC 3.0+?

Regards.

Re: "libvlc_audio_set_volume" problem with VLC 3.0+

Posted: 03 Dec 2018 02:36
by mfkl
Share full code please

Re: "libvlc_audio_set_volume" problem with VLC 3.0+

Posted: 03 Dec 2018 07:15
by Moriquendi
Hello mfkl,

Here is pretty much the core of my code.

Code: Select all

MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); /* VLC initialization*/ initVlc(); /* VLC audio sliders */ connect(ui->audioSlider1, SIGNAL(valueChanged(int)), this, SLOT(setVlcAudio(int))); connect(ui->audioSlider2, SIGNAL(valueChanged(int)), this, SLOT(setVlcAudio(int))); connect(ui->audioSlider3, SIGNAL(valueChanged(int)), this, SLOT(setVlcAudio(int))); connect(ui->audioSlider4, SIGNAL(valueChanged(int)), this, SLOT(setVlcAudio(int))); } void MainWindow::initVlc() { QStringList list; addVlcArgs(&list); VlcInstance vlcInstance = new VlcInstance(list, this); player1 = new VlcMediaPlayer(vlcInstance); player2 = new VlcMediaPlayer(vlcInstance); player3 = new VlcMediaPlayer(vlcInstance); player4 = new VlcMediaPlayer(vlcInstance); } void MainWindow::addVlcArgs(QStringList *list) { QString arg = "--no-stats"; *list << arg; arg = "--no-media-library"; *list << arg; arg = "--no-osd"; *list << arg; arg = "--no-video-title-show"; *list << arg; } void MainWindow::setVlcAudio(int value) { if (currentPlayer == PLAYER1) { qDebug() << "PLAYER1 -- LIBVLC SET VOLUME TRIGGERED! LEVEL:"<<value; libvlc_audio_set_volume(player1->core(), value); } else if (currentPlayer == PLAYER2) { qDebug() << "PLAYER2 -- LIBVLC SET VOLUME TRIGGERED! LEVEL:"<<value; libvlc_audio_set_volume(player2->core(), value); } else if (currentPlayer == PLAYER3) { qDebug() << "PLAYER3 -- LIBVLC SET VOLUME TRIGGERED! LEVEL:"<<value; libvlc_audio_set_volume(player3->core(), value); } else if (currentPlayer == PLAYER4) { qDebug() << "PLAYER4 -- LIBVLC SET VOLUME TRIGGERED! LEVEL:"<<value; libvlc_audio_set_volume(player4->core(), value); } }
And this is the application output. In this example, there two players (player1 and player2 are playing media) are active. But libvlc_audio_set_volume is requested once for player1 only. Even though i called libvlc_audio_set_volume only once, "mmdevice audio output debug: simple volume changed" called 8 times and the volumes of both player1 and player2 changes to the same level.

Code: Select all

PLAYER1 -- LIBVLC SET VOLUME TRIGGERED! LEVEL: 40 mmdevice audio output debug: simple volume changed: 0.064000, muting disabled mmdevice audio output debug: simple volume changed: 0.064000, muting disabled mmdevice audio output debug: simple volume changed: 0.064000, muting disabled mmdevice audio output debug: simple volume changed: 0.064000, muting disabled mmdevice audio output debug: simple volume changed: 0.064000, muting disabled mmdevice audio output debug: simple volume changed: 0.064000, muting disabled mmdevice audio output debug: simple volume changed: 0.064000, muting disabled mmdevice audio output debug: simple volume changed: 0.064000, muting disabled

Re: "libvlc_audio_set_volume" problem with VLC 3.0+

Posted: 03 Dec 2018 14:34
by mangokm40
If I remember correctly (rare), with 3.0.x, there were changes in the audio code. Since VLC 3, when my program runs, an application shows up in my volume mixer. When I change the volume from code, that volume is changed. If I change the volume from my Windows mixer, the volume in my application is changed.
Maybe, if you have a single instance of libvlc, a single application will show up in your volume mixer. That would mean volume change to all media (maybe?). :)

Re: "libvlc_audio_set_volume" problem with VLC 3.0+

Posted: 03 Dec 2018 14:50
by Moriquendi
If I remember correctly (rare), with 3.0.x, there were changes in the audio code. Since VLC 3, when my program runs, an application shows up in my volume mixer. When I change the volume from code, that volume is changed. If I change the volume from my Windows mixer, the volume in my application is changed.
Maybe, if you have a single instance of libvlc, a single application will show up in your volume mixer. That would mean volume change to all media (maybe?). :)

Hi mangokm40,
Actually I tried that long ago and it didnt help either.

Instead of :

Code: Select all

player1 = new VlcMediaPlayer(vlcInstance); player2 = new VlcMediaPlayer(vlcInstance); player3 = new VlcMediaPlayer(vlcInstance); player4 = new VlcMediaPlayer(vlcInstance);
I passed different instances for each player,

Code: Select all

player1 = new VlcMediaPlayer(vlcInstance1); player2 = new VlcMediaPlayer(vlcInstance2); player3 = new VlcMediaPlayer(vlcInstance3); player4 = new VlcMediaPlayer(vlcInstance4);
Unfortunately same results. As you said, audio core of VLC changed in 3.0.x but I am not sure if this behaviour is intended or not. Maybe I can pass some parameters to vlc instances and it should fix it, not sure.

Re: "libvlc_audio_set_volume" problem with VLC 3.0+

Posted: 03 Dec 2018 17:11
by Rémi Denis-Courmont
It seems that your OS is set up to effect volume change on all streams within the application. VLC is definitely not doing that by itself. Maybe running different instances in different processes will fix it, or maybe it won't.

Re: "libvlc_audio_set_volume" problem with VLC 3.0+

Posted: 04 Dec 2018 06:19
by Moriquendi
It seems that your OS is set up to effect volume change on all streams within the application. VLC is definitely not doing that by itself. Maybe running different instances in different processes will fix it, or maybe it won't.
Hi Remi,

I still think VLC 3.0.x has something to do with it. Because when I use VLC 2.2.8, there is no problem. But if I use the very same .exe file and only change libvlc.dll, libvlccore.dll and plugins folder for VLC 3.0.4, the problem arises. Maybe it is something to do with the default parameters vlc instance is created with libvlc_new, not sure. Also the debug log for mmdevice looks suspicious:

1 player is active --> Call "libvlc_audio_set_volume" once --> mmdevice audio output debug: simple volume changed: 0.064000, muting disabled (called twice)
2 players are active --> Call "libvlc_audio_set_volume" once (lets say for player 2) --> mmdevice audio output debug: simple volume changed: 0.064000, muting disabled (called 8 times)
3 players are active --> Call "libvlc_audio_set_volume" once (lets say for player 2) --> mmdevice audio output debug: simple volume changed: 0.064000, muting disabled (called 18 times)
4 players are active --> Call "libvlc_audio_set_volume" once (lets say for player 3) --> mmdevice audio output debug: simple volume changed: 0.064000, muting disabled (called 32 times)

Do you have any suggestions for further debugging the issue?

Re: "libvlc_audio_set_volume" problem with VLC 3.0+

Posted: 04 Dec 2018 20:47
by Rémi Denis-Courmont
You're comparing apples and oranges there. VLC 2.2.x uses old and slow DirectSound by default, while VLC 3.0 adds hot plug events and uses MMDevice by default.

Re: "libvlc_audio_set_volume" problem with VLC 3.0+

Posted: 05 Dec 2018 07:08
by Moriquendi
You're comparing apples and oranges there. VLC 2.2.x uses old and slow DirectSound by default, while VLC 3.0 adds hot plug events and uses MMDevice by default.

That's it! I passed --aout=direcsound to vlc instance and it solved the problem. Still dont know why mmdevice doesnt work with multiple instances. I mean it certainly works with multiple VLC applications. But maybe thats because every VLC runs its own process as you mentioned where in my application I have single process and 4 VLC instances. Anyway, thanks for the support.