Windows Guest sound muted is ignored when loaded from a saved state

Discussions related to using VirtualBox on Windows hosts.
Post Reply
idgdpc
Posts: 3
Joined: 10. May 2022, 22:51

Windows Guest sound muted is ignored when loaded from a saved state

Post by idgdpc »

Recently, because of a frequent notification from a demo software, I have noticed that on my Windows Guests when I have the sound muted i still get sound on the host when the Guest is loaded from a saved state.
When I first noticed the mute wasn't applied as expected I updated to 6.1.34 and I thought the problem was resolved but realized that when I restarted the guest the mute was applied and it was only when I loaded it from a saved state that the mute was not.

My Host is Windows 10 and it happens on Windows 10 guests. I think it also happens with Windows 7 guests, but I can't remember at the moment.

I searched the forum but did not find anything similar.

Anyone have a suggestion or is this a bug?
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Windows Guest sound muted is ignored when loaded from a saved state

Post by mpack »

Disable audio in the VM settings if you don't need audio. AFAIK muting is a guest OS function, not a VM setting.
idgdpc
Posts: 3
Joined: 10. May 2022, 22:51

Re: Windows Guest sound muted is ignored when loaded from a saved state

Post by idgdpc »

mpack wrote:Disable audio in the VM settings if you don't need audio. AFAIK muting is a guest OS function, not a VM setting.
I don't always want the sound muted, I just want it to stay muted until I want to unmute it. The guest OS shows that the sound is muted. If I restart the sound stays muted. If I save the machine state and then load it back the Guest OS still shows that the sound is muted but My host OS plays the Guest OS sounds.Same if I shutdown and the start the Guest OS.

Windows 10 and 7 do this. Out of curiosity I tried XP and Debian . XP mute doesn't do anything anymore. Debian Muted just fine.

VirtualBox should be able to monitor the mute state of the Guest.
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Windows Guest sound muted is ignored when loaded from a saved state

Post by scottgus1 »

Could be a bug.

Start the VM from full normal shutdown, not save-state. Run through the save-state procedure to get to where the muted VM still makes noise, then shut down the VM from within the VM's OS so the VM fully powers off and is no longer save-stated.

Right-click the VM in the main Virtualbox window's VM list, choose Show Log. Save the far left tab's 'vbox.log' and the third tab's 'vbox.log.1', zip the files, and post the zip file, using the forum's Upload Attachment tab.
idgdpc
Posts: 3
Joined: 10. May 2022, 22:51

Re: Windows Guest sound muted is ignored when loaded from a saved state

Post by idgdpc »

I started from a complete shutdown and mute was on but not working. I turned off and back on mute and then the sound was muted. I saved the state and then loaded the saved state and the sound was playing again with mute still on.
Attachments
VboxLogTest1.zip
(74.08 KiB) Downloaded 4 times
Nicolas-MEAE
Posts: 8
Joined: 25. May 2022, 09:21

Re: Windows Guest sound muted is ignored when loaded from a saved state

Post by Nicolas-MEAE »

Hi,
Had a similar problem for a while, likely related to a VB bug. Worked arround it by running the powershell script automaticaly at every windows logon. Hope that helps !

Please note that initialy I made a loop that was running permanently in background to check and correctly apply the mute state to the speakers. However, from 6.1.34, it seems that running it "only once" at logon fixes the problem for any subsequent problem. Could not understand why...

Best regards,
Nicolas

Code: Select all

Add-Type -TypeDefinition @'
using System.Runtime.InteropServices;

[Guid("5CDF2C82-841E-4546-9722-0CF74078229A"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
interface IAudioEndpointVolume {
  // f(), g(), ... are unused COM method slots. Define these if you care
  int f(); int g(); int h(); int i();
  int SetMasterVolumeLevelScalar(float fLevel, System.Guid pguidEventContext);
  int j();
  int GetMasterVolumeLevelScalar(out float pfLevel);
  int k(); int l(); int m(); int n();
  int SetMute([MarshalAs(UnmanagedType.Bool)] bool bMute, System.Guid pguidEventContext);
  int GetMute(out bool pbMute);
}
[Guid("D666063F-1587-4E43-81F1-B948E807363F"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
interface IMMDevice {
  int Activate(ref System.Guid id, int clsCtx, int activationParams, out IAudioEndpointVolume aev);
}
[Guid("A95664D2-9614-4F35-A746-DE8DB63617E6"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
interface IMMDeviceEnumerator {
  int f(); // Unused
  int GetDefaultAudioEndpoint(int dataFlow, int role, out IMMDevice endpoint);
}
[ComImport, Guid("BCDE0395-E52F-467C-8E3D-C4579291692E")] class MMDeviceEnumeratorComObject { }

public class Audio {
  static IAudioEndpointVolume Vol() {
    var enumerator = new MMDeviceEnumeratorComObject() as IMMDeviceEnumerator;
    IMMDevice dev = null;
    Marshal.ThrowExceptionForHR(enumerator.GetDefaultAudioEndpoint(/*eRender*/ 0, /*eMultimedia*/ 1, out dev));
    IAudioEndpointVolume epv = null;
    var epvid = typeof(IAudioEndpointVolume).GUID;
    Marshal.ThrowExceptionForHR(dev.Activate(ref epvid, /*CLSCTX_ALL*/ 23, 0, out epv));
    return epv;
  }
  public static float Volume {
    get {float v = -1; Marshal.ThrowExceptionForHR(Vol().GetMasterVolumeLevelScalar(out v)); return v;}
    set {Marshal.ThrowExceptionForHR(Vol().SetMasterVolumeLevelScalar(value, System.Guid.Empty));}
  }
  public static bool Mute {
    get { bool mute; Marshal.ThrowExceptionForHR(Vol().GetMute(out mute)); return mute; }
    set { Marshal.ThrowExceptionForHR(Vol().SetMute(value, System.Guid.Empty)); }
  }
}
'@


VBoxControl version | out-null
if ($LASTEXITCODE -ne 0) { Exit }


if ([Audio]::Mute) 
{
    [Audio]::Mute = $False
	[Audio]::Mute = $True
}
Post Reply