Add option to disable audio pass-though (#728)

This commit is contained in:
Tor Arne Vestbø 2024-02-19 18:26:31 +01:00 committed by GitHub
parent a48f4d4ec9
commit f6c56ed8eb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 5 deletions

View File

@ -36,6 +36,9 @@ struct Run: AsyncParsableCommand {
@Flag(help: ArgumentHelp("Force open a UI window, even when VNC is enabled.", visibility: .hidden))
var graphics: Bool = false
@Flag(help: "Disable audio pass-through to host.")
var noAudio: Bool = false
#if arch(arm64)
@Flag(help: "Boot into recovery mode")
#endif
@ -210,7 +213,8 @@ struct Run: AsyncParsableCommand {
additionalStorageDevices: additionalDiskAttachments,
directorySharingDevices: directoryShares() + rosettaDirectoryShare(),
serialPorts: serialPorts,
suspendable: suspendable
suspendable: suspendable,
audio: !noAudio
)
let vncImpl: VNC? = try {

View File

@ -45,7 +45,8 @@ class VM: NSObject, VZVirtualMachineDelegate, ObservableObject {
additionalStorageDevices: [VZStorageDeviceConfiguration] = [],
directorySharingDevices: [VZDirectorySharingDeviceConfiguration] = [],
serialPorts: [VZSerialPortConfiguration] = [],
suspendable: Bool = false
suspendable: Bool = false,
audio: Bool = true
) throws {
name = vmDir.name
config = try VMConfig.init(fromURL: vmDir.configURL)
@ -61,7 +62,8 @@ class VM: NSObject, VZVirtualMachineDelegate, ObservableObject {
network: network, additionalStorageDevices: additionalStorageDevices,
directorySharingDevices: directorySharingDevices,
serialPorts: serialPorts,
suspendable: suspendable
suspendable: suspendable,
audio: audio
)
virtualMachine = VZVirtualMachine(configuration: configuration)
@ -274,7 +276,8 @@ class VM: NSObject, VZVirtualMachineDelegate, ObservableObject {
additionalStorageDevices: [VZStorageDeviceConfiguration],
directorySharingDevices: [VZDirectorySharingDeviceConfiguration],
serialPorts: [VZSerialPortConfiguration],
suspendable: Bool = false
suspendable: Bool = false,
audio: Bool = true
) throws -> VZVirtualMachineConfiguration {
let configuration = VZVirtualMachineConfiguration()
@ -292,7 +295,7 @@ class VM: NSObject, VZVirtualMachineDelegate, ObservableObject {
configuration.graphicsDevices = [vmConfig.platform.graphicsDevice(vmConfig: vmConfig)]
// Audio
if !suspendable {
if audio && !suspendable {
let soundDeviceConfiguration = VZVirtioSoundDeviceConfiguration()
let inputAudioStreamConfiguration = VZVirtioSoundDeviceInputStreamConfiguration()
inputAudioStreamConfiguration.source = VZHostAudioInputStreamSource()