FyroxEngine/Fyrox · warning

Unable to initialize audio output device! Reason

Error message

Unable to initialize audio output device! Reason: {err:?}

What it means

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.

Solutions

  1. Check that an audio output device exists and the OS audio service is running (PulseAudio/PipeWire/WASAPI/CoreAudio)
  2. Inspect the logged `{err:?}` reason — it names the underlying cpal error (NoDevice, BackendSpecific, etc.)
  3. On headless machines, run with a null/virtual audio sink (e.g. PulseAudio null sink) or accept silent operation
  4. Update/ reinstall audio drivers or retry after freeing the busy device
  5. Wrap engine creation so audio loss is non-fatal and surfaced to the user

Example fix

// before: headless CI crashes/confuses with no explanation
let engine = Engine::new(window_builder, event_loop, true).unwrap();

// after: document that audio may be unavailable on headless systems
match Engine::new(window_builder, event_loop, true) {
    Ok(engine) => engine,
    Err(e) => { eprintln!("Engine init failed: {e:?}"); std::process::exit(1); }
}
// and treat 'Unable to initialize audio output device' in logs as expected on CI
Defensive patterns

Strategy: fallback

Validate before calling

// Best-effort check before engine init: can cpal open a device?
use cpal::traits::{DeviceTrait, HostTrait};
fn audio_device_available() -> bool {
    cpal::default_host().default_output_device()
        .map(|d| d.default_output_config().is_ok())
        .unwrap_or(false)
}

Type guard

fn has_audio_output() -> bool {
    cpal::default_host().default_output_device().is_some()
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of FyroxEngine/Fyrox@76c91aad8e (2026-09-10). Data as JSON: /api/errors/d527dd211e7a6e84. Report an issue: GitHub.

Appendix: source

Thrown at fyrox-impl/src/engine/mod.rs:1529

                params.window_attributes.clone(),
                params.named_objects,
            )?;
            let frame_size = (window.inner_size().width, window.inner_size().height);

            let renderer = Renderer::new(server, frame_size, &self.resource_manager)?;

            for ui in self.user_interfaces.iter_mut() {
                ui.set_screen_size(Vector2::new(frame_size.0 as f32, frame_size.1 as f32));
            }

            self.graphics_context = GraphicsContext::Initialized(InitializedGraphicsContext {
                renderer,
                window,
                params: params.clone(),
            });

            if let Err(err) = self.sound_engine.initialize_audio_output_device() {
                Log::err(format!(
                    "Unable to initialize audio output device! Reason: {err:?}"
                ));
            }

            Ok(())
        } else {
            Err(EngineError::Custom(
                "Graphics context is already initialized!".to_string(),
            ))
        }
    }

    /// Returns current sample rate of the sound engine.
    pub fn sound_sample_rate(&self) -> u32 {
        self.sound_engine.sample_rate()
    }

    /// Normalizes given frequency using sampling rate of the sound output device. Normalized frequency

View on GitHub (pinned to 76c91aad8e)