Skip to content

No audio output with SDL3 backend on PipeWire (FMOD_ERR_OUTPUT_INIT, unvalidated SDL defaults, missing AAudio hooks) #135

@brainAThome

Description

@brainAThome

Bug Report

Description

No audio output in Minecraft Bedrock when using the SDL3 audio backend. FMOD initialization fails with error code 28 (FMOD_ERR_OUTPUT_INIT). System audio works perfectly in all other applications.

Root Cause

Three bugs in fake_audio.cpp combine to cause audio failure:

1. Unvalidated SDL_GetAudioDeviceFormat return value

updateDefaults() calls SDL_GetAudioDeviceFormat() without checking the return value. On PipeWire with SDL3, this call can fail, leaving uninitialized stack values (e.g., freq=0, channels=11, sampleFrames=-495316880) which overwrite the sensible defaults.

2. Missing AAudio builder configuration hooks

FMOD calls AAudioStreamBuilder_setSampleRate(), setChannelCount(), and setFormat() to configure the audio stream — but these functions were not hooked. The requested configuration was silently discarded.

3. Wrong stream state for newly created streams

AAudioStream_getState() returns AAUDIO_STREAM_STATE_CLOSED when stream->s == NULL. But after openStream() and before requestStart(), the state should be AAUDIO_STREAM_STATE_OPEN. FMOD checks this and aborts when it sees CLOSED.

Log Output

getSampleRate: 0
getChannelCount: 11
getChannelCount: -495316880
FMOD_System_Init returned 28

Affected Systems

  • Any Linux system using PipeWire as audio server
  • Systems where SDL_GetAudioDeviceFormat(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, ...) fails
  • Some PulseAudio setups

Test System

Component Details
OS Kubuntu 24.04.4 LTS, Kernel 6.17.0-19-generic
Audio PipeWire 1.0.5
Audio Devices Yamaha ZG01, Astro A50, Razer Kiyo Pro, HDMI
MC Bedrock Edition 1.26.0.2 via mcpelauncher (ng branch, SDL3 audio)

Fix

PR #133 fixes all three issues:

  1. Zero-initializes SDL_AudioSpec and validates the return value — keeps defaults (48000 Hz, 2 ch, 512 frames) if SDL call fails
  2. Adds hooks for AAudioStreamBuilder_setSampleRate, setChannelCount, setFormat — stores and propagates builder config to the stream
  3. Returns AAUDIO_STREAM_STATE_OPEN instead of CLOSED for streams that exist but haven't started yet

See PR #133 for full implementation details and documentation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions