VirtualBox

Ticket #20431 (new defect)

Opened 14 months ago

Last modified 4 months ago

Sound lost after a couple of changes of host audio output device

Reported by: boxer01 Owned by:
Component: audio Version: VirtualBox 6.1.22
Keywords: Cc:
Guest type: Windows Host type: Windows

Description

I have found another bug, which looks similar to an old one from #17225: if I change the host output from speaker to the Bluetooth headphones, the sound of VBox goes to the headphones. Then I change back and the VBox sounds also goes to the speakers. But the next time I repeat the change to Bluetooth, the VBox ignores it. The sound form the host and programs, running on the host played in the Bluetooth headphones, but the sound from VBox is lost. If I turn the BT headphones off, the VBox sound returns to the speakers, but I can't get the VBox sound to the Bluetooth anymore. The only way is to save and restore the VM state or to turn the VM off and then on (restart).

All information about how I test the sound in VBox is in other ticket. I'm on 6.1.23 version 145326 now.

Attachments

vbox_old_sound_logs_6.1.23_145326.7z Download (59.5 KB) - added by boxer01 14 months ago.
Logs without audio debug from the previous day,6.1.23 version 145326
vbox_new_sound_logs_6.1.23_145326.7z Download (112.1 KB) - added by boxer01 14 months ago.
Current logs with audio debug, 6.1.23 version 145326

Change History

Changed 14 months ago by boxer01

Logs without audio debug from the previous day,6.1.23 version 145326

Changed 14 months ago by boxer01

Current logs with audio debug, 6.1.23 version 145326

comment:1 Changed 14 months ago by boxer01

Debug sounds before and after the save state. Same in the new logs.

 sound before

 sound after

comment:2 Changed 14 months ago by boxer01

This is followup for #20273.

comment:3 Changed 12 months ago by boxer01

Still here as of 6.1.24, 6.1.25, 6.1.26, 6.1.27 rev. 146035.

comment:4 Changed 11 months ago by Pier Paolo

Same problem, host: windows 10 virtualbox version 6.1.26 r145957 ubuntu guest with guest extensions 6.1.26 I have a wireless headphones, when I turn them off windows changes the primary output device to external speakers, virtualbox sound go out from the speakers. If I turn on again the headphones windows use them again as primary output device, the sound every other program goes out from the headphones, but virtualbox sound is not audible (in the headphones or from the speakers). If I turn off the headphones again, the sound is again audible through the speakers. Virtualbox vm become again able to make sound go out from the headphones only if I restart the vm.

comment:5 follow-up: ↓ 6 Changed 11 months ago by allenb

I'm seeing the same (v6.1.26 on Win 10 host, Ubuntu 20.04 guest with extensions). I start the VM and get audio out my speakers. I then power on my bluetooth headset (paired with the host, not the guest) and get audio through the headset. Now, I power off the headset and lose all audio output. The first device switchover worked transparently, but the second does not.

My logs and the other logs posted above have this bit in common that appears when the current audio device is removed:

03:39:59.262856 Audio: Device configuration of driver 'WasAPI' has changed
03:39:59.266898 WasAPI: Failed to get default input device (OnDefaultDeviceChange): ERROR_NOT_FOUND 0x80070490
03:39:59.266961 Audio: Device configuration of driver 'WasAPI' has changed
03:39:59.611150 Audio: Found 3 devices for driver 'WasAPI'
03:39:59.611209 Audio: Device 'Speakers (Realtek High Definition Audio)':
03:39:59.611210 Audio:   ID              = {0.0.0.00000000}.{adeae8a7-b2b2-4b5a-bfc0-7e2e34875ede}
03:39:59.611210 Audio:   Usage           = output
03:39:59.611211 Audio:   Flags           = DEFAULT_OUT
03:39:59.611212 Audio:   Input channels  = 0
03:39:59.611213 Audio:   Output channels = 2
03:39:59.611224 Audio: Device 'Realtek Digital Output (Realtek High Definition Audio)':
03:39:59.611225 Audio:   ID              = {0.0.0.00000000}.{2230f5f5-c368-4cb0-8712-dcfb5d3248a7}
03:39:59.611226 Audio:   Usage           = output
03:39:59.611226 Audio:   Flags           = NONE
03:39:59.611227 Audio:   Input channels  = 0
03:39:59.611228 Audio:   Output channels = 2
03:39:59.611240 Audio: Device 'Speakers (Realtek High Definition Audio)':
03:39:59.611241 Audio:   ID              = {0.0.0.00000000}.{adeae8a7-b2b2-4b5a-bfc0-7e2e34875ede}
03:39:59.611242 Audio:   Usage           = output
03:39:59.611242 Audio:   Flags           = NONE
03:39:59.611242 Audio:   Input channels  = 0
03:39:59.611243 Audio:   Output channels = 2
04:52:38.518910 WasAPI: GetCurrentPadding([WasAPI] Output:0) failed during playback: AUDCLNT_E_DEVICE_INVALIDATED (@0x0)
04:52:38.524375 WasAPI: GetCurrentPadding failed on '[WasAPI] Output:0': AUDCLNT_E_DEVICE_INVALIDATED
 [[[ last 2 lines repeat 64 times ]]]
04:52:40.158486 AssertLogRel F:\tinderbox\win-6.1\src\VBox\Devices\Audio\DrvAudio.cpp(3351) unsigned int __cdecl drvAudioStreamGetWritable(struct PDMIAUDIOCONNECTOR *,struct PDMAUDIOSTREAM *): cbWritable
 [[[ last line gets spammed every ms or so ]]]
04:52:44.076609 32768 messages from group DRV_AUDIO (#91), muting it.

After that point, I got no guest audio output on any device. Audio played from within the host OS functioned normally. Disabling audio output and re-enabling from the mini-toolbar didn't change anything, neither does re-connecting the headset or changing the default audio output device in the host. Adding or removing a device no longer generates "Device configuration of driver 'WasAPI' has changed" log messages at this point.

It looks like the audio subsystem is trying to use the output device after it is removed and the device is invalidated. Inside the function `drvHostAudioWasHA_StreamPlay()`, the code that generates the log message looks like this:

else
{
    LogRelMax(64, ("WasAPI: GetCurrentPadding(%s) failed during playback: %Rhrc (@%#RX64)\n",
    pStreamWas->Cfg.szName, hrc, pStreamWas->offInternal));
    /** @todo reinit on AUDCLNT_E_DEVICEINVALIDATED? */
    rc = VERR_AUDIO_STREAM_NOT_READY;
    break;
}

Implementing that "todo" may solve this issue.

comment:6 in reply to: ↑ 5 Changed 10 months ago by boxer01

Replying to allenb:

It looks like the audio subsystem is trying to use the output device after it is removed and the device is invalidated. Inside the function `drvHostAudioWasHA_StreamPlay()`, the code that generates the log message looks like this:

else
{
    LogRelMax(64, ("WasAPI: GetCurrentPadding(%s) failed during playback: %Rhrc (@%#RX64)\n",
    pStreamWas->Cfg.szName, hrc, pStreamWas->offInternal));
    /** @todo reinit on AUDCLNT_E_DEVICEINVALIDATED? */
    rc = VERR_AUDIO_STREAM_NOT_READY;
    break;
}

Implementing that "todo" may solve this issue.

Hi allenb!

Thank you (very much) for this deep analysis. I opened a duplicate ticket for this issue (#20630), because this is still an issue in the current 6.1.28 and .29 build. Socratis wouldn't like this (me opening the duplicate), but I have kind of no other way to point on this problem, and he is not around for a long time (R.I.P.)

As I probably already wrote in some other sound tickets, the trouble here is a sound backend refactoring in the last 5 years. It started with version 5.1 back in 2016, they tried to separate the sound from the main thread to the thread of its own. But this attempt was so botched, that they have to scrap it altogether and return to the 5.0 version of the sound system.

But a year later the attempt was repeated, and now they nearly succeeded. It also has some error, like timing problems and some other small things, but they were corrected in September 2018 with the version 5.1.22. I still use it as a productive one.

After the rest of issues were ignored over 2 years, somebody started yet another rewrite this (2021) February - March. It almost succeeded also, major errors were corrected back then, but we still see small issues like this one. The big trouble here: if you take a look at the SVN for the last 6 month (since April), you'll find out that 95% of audio change sets are about Validation Kit. I wouldn't like to tell, that proper testing and proper testing platform isn't important (I'm developer myself), but it looks like that developers here have no time to resolve some bugs from current running audio system, spending nearly all the time for testing platform development.

Let us hope, that this will be addressed soon.

comment:7 follow-up: ↓ 8 Changed 8 months ago by PavloUnn

(duplicating here in addition to #20630): @boxer01, it looks like the issue is not bound specifically to Bluetooth devices. It's for any detachable device. I've opened #20723, just in case.

comment:8 in reply to: ↑ 7 Changed 4 months ago by boxer01

Replying to PavloUnn:

(duplicating here in addition to #20630):

Thank you for finding my other tickets about this issue. As you correctly assumes, this is not about BT, this is about another device. So this issue wouldn't be triggered if I switch from the built-in speakers to the headphones on the built-in jack, because this is the same device. Only switches to another device would provoke this.

With the current version, I know the only working workaround - to save the VM and to start it again. One can also shut down and start the VM. No other tricks are working right now. And you already found the comment in the other ticket, which shows the part of the source code, which probably causes all of this. We just have no time, knowledge and other possibilities to correct it.

You may also take a look on my other sound-related tickets, which are still open. And the tickets I mentioned in my comments. A small overview: the sound troubles started about 5 years ago. We now in the third version (rewrite) or wave of it. Some old bugs were fixed, but the new arrived. So the last rewrite was done in March 2021, and so this issue is already slightly over one-year-old. As you may see from other tickets from other waves, it takes time to fix it. Sound isn't probably on the top of the list, and scenarios like this has even lower priority. All we can do is hope and pray.

Note: See TracTickets for help on using tickets.

www.oracle.com
ContactPrivacy policyTerms of Use