{"record":{"id":"d527dd211e7a6e84","repo":"FyroxEngine/Fyrox","slug":"unable-to-initialize-audio-output-device-reason","errorCode":null,"errorMessage":"Unable to initialize audio output device! Reason: {err:?}","messagePattern":"Unable to initialize audio output device! Reason: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"fyrox-impl/src/engine/mod.rs","lineNumber":1529,"sourceCode":"                params.window_attributes.clone(),\n                params.named_objects,\n            )?;\n            let frame_size = (window.inner_size().width, window.inner_size().height);\n\n            let renderer = Renderer::new(server, frame_size, &self.resource_manager)?;\n\n            for ui in self.user_interfaces.iter_mut() {\n                ui.set_screen_size(Vector2::new(frame_size.0 as f32, frame_size.1 as f32));\n            }\n\n            self.graphics_context = GraphicsContext::Initialized(InitializedGraphicsContext {\n                renderer,\n                window,\n                params: params.clone(),\n            });\n\n            if let Err(err) = self.sound_engine.initialize_audio_output_device() {\n                Log::err(format!(\n                    \"Unable to initialize audio output device! Reason: {err:?}\"\n                ));\n            }\n\n            Ok(())\n        } else {\n            Err(EngineError::Custom(\n                \"Graphics context is already initialized!\".to_string(),\n            ))\n        }\n    }\n\n    /// Returns current sample rate of the sound engine.\n    pub fn sound_sample_rate(&self) -> u32 {\n        self.sound_engine.sample_rate()\n    }\n\n    /// Normalizes given frequency using sampling rate of the sound output device. Normalized frequency","sourceCodeStart":1511,"sourceCodeEnd":1547,"githubUrl":"https://github.com/FyroxEngine/Fyrox/blob/76c91aad8eca488ce527b1af707be8b3b24ad72d/fyrox-impl/src/engine/mod.rs#L1511-L1547","documentation":"Fyrox logs this error when `SoundEngine::initialize_audio_output_device()` fails during engine initialization. The audio output device (via cpal) could not be opened, so the game will run without audio output. The engine continues running; this is logged, not fatal.","triggerScenarios":"Calling `Engine::new()` (or the engine init path) when no audio output device is available or can be opened: no sound hardware, all devices busy, audio subsystem unavailable (headless server/CI), or the audio driver rejects the requested configuration.","commonSituations":"Running a Fyrox game on a headless server or CI runner with no sound card; audio service not started (e.g. PulseAudio/PipeWire down on Linux); Bluetooth headset disconnected mid-boot; missing audio drivers on Windows; running inside containers/VMs without audio passthrough.","solutions":["Check that an audio output device exists and the OS audio service is running (PulseAudio/PipeWire/WASAPI/CoreAudio)","Inspect the logged `{err:?}` reason — it names the underlying cpal error (NoDevice, BackendSpecific, etc.)","On headless machines, run with a null/virtual audio sink (e.g. PulseAudio null sink) or accept silent operation","Update/ reinstall audio drivers or retry after freeing the busy device","Wrap engine creation so audio loss is non-fatal and surfaced to the user"],"exampleFix":"// before: headless CI crashes/confuses with no explanation\nlet engine = Engine::new(window_builder, event_loop, true).unwrap();\n\n// after: document that audio may be unavailable on headless systems\nmatch Engine::new(window_builder, event_loop, true) {\n    Ok(engine) => engine,\n    Err(e) => { eprintln!(\"Engine init failed: {e:?}\"); std::process::exit(1); }\n}\n// and treat 'Unable to initialize audio output device' in logs as expected on CI","handlingStrategy":"fallback","validationCode":"// Best-effort check before engine init: can cpal open a device?\nuse cpal::traits::{DeviceTrait, HostTrait};\nfn audio_device_available() -> bool {\n    cpal::default_host().default_output_device()\n        .map(|d| d.default_output_config().is_ok())\n        .unwrap_or(false)\n}","typeGuard":"fn has_audio_output() -> bool {\n    cpal::default_host().default_output_device().is_some()\n}","tryCatchPattern":null,"preventionTips":["Log-verify audio availability on startup in CI/headless environments","Provision a virtual audio sink for headless test machines","Keep audio drivers and OS audio services up to date","Treat missing audio as degraded mode, not a crash"],"tags":["audio","initialization","device","fyrox"],"backgroundTag":"module-init-failed","analyzedSha":"76c91aad8eca488ce527b1af707be8b3b24ad72d","analyzedAt":"2026-09-10T16:04:01.633Z","contentChangedAt":"2026-09-10T16:04:01.633Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}