From e87a0b2749990d575b2a3426dfdb769d984c1fcf Mon Sep 17 00:00:00 2001 From: g0t mi1k Date: Sat, 13 Jun 2026 15:54:37 +0100 Subject: [PATCH] vagrantfile: Improve audio support on non-windows (QEMU/VBOX) --- vagrant/vagrantfile | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/vagrant/vagrantfile b/vagrant/vagrantfile index ef27f88..f6ce0f1 100644 --- a/vagrant/vagrantfile +++ b/vagrant/vagrantfile @@ -5,6 +5,13 @@ Vagrant.configure('2') do |config| dev_arg = ENV.fetch('DEV', 'false').to_s location_arg = ENV.fetch('LOCATION', 'remote').to_s + host_os = + case RUBY_PLATFORM + when /mswin|mingw|cygwin/ then :windows + when /darwin/ then :macos + else :linux + end + config.vm.boot_timeout = 600 # ---------- Hyper-V ---------- @@ -53,6 +60,14 @@ Vagrant.configure('2') do |config| vb_vm.vm.box = 'generic/debian12' vb_vm.vm.hostname = 'WiFiChallengeLab' + # Host-side audio backend + vbox_audio = + case host_os + when :windows then 'dsound' + when :macos then 'coreaudio' + else 'pulse' # Alt: 'alsa', 'none' + end + vb_vm.vm.provider 'virtualbox' do |vb| vb.memory = 4096 vb.cpus = 4 @@ -60,7 +75,7 @@ Vagrant.configure('2') do |config| vb.customize ['modifyvm', :id, '--graphicscontroller', 'vmsvga'] vb.check_guest_additions = false vb.functional_vboxsf = false - vb.customize ['modifyvm', :id, '--audio', 'dsound'] + vb.customize ['modifyvm', :id, '--audio', vbox_audio] vb.customize ['modifyvm', :id, '--audiocontroller', 'hda'] # If you ever need a fallback, swap controller to ac97: # vb.customize ['modifyvm', :id, '--audiocontroller', 'ac97'] @@ -213,6 +228,14 @@ Vagrant.configure('2') do |config| qemu_vm.vm.box = 'generic/debian12' qemu_vm.vm.hostname = 'WiFiChallengeLab' + # Host-side audio backend + qemu_audio = + case host_os + when :windows then 'dsound,id=snd0' + when :macos then 'coreaudio,id=snd0' + else 'pa,id=snd0' # Alt: alsa,id=snd0 + end + qemu_vm.vm.provider 'qemu' do |qemu| qemu.memory = 4096 qemu.cpus = 4 @@ -228,7 +251,7 @@ Vagrant.configure('2') do |config| qemu.uefi = 'C:/Program Files/qemu/share/edk2-x86_64-code.fd' qemu.gui = true qemu.extra_qemu_args = [ - '-audiodev', 'dsound,id=snd0', + '-audiodev', qemu_audio, '-device', 'ich9-intel-hda', '-device', 'hda-duplex,audiodev=snd0' ] @@ -273,4 +296,4 @@ Vagrant.configure('2') do |config| privileged: true, run: 'once' end -end \ No newline at end of file +end