# SDL: audio: Make sure to set \`device-\>spec\` before actually opening the device.

**URL:** <https://discourse.libsdl.org/t/sdl-audio-make-sure-to-set-device-spec-before-actually-opening-the-device/69555>\
**Category:** SDL Commits\
**Created:** [October 14, 2026, 2:41pm UTC](https://discourse.libsdl.org/t/sdl-audio-make-sure-to-set-device-spec-before-actually-opening-the-device/69555 "2026-10-14T14:41:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![SDLPushPostBot](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/sdlpushpostbot/32/4370_2.png) [@SDLPushPostBot](https://discourse.libsdl.org/u/SDLPushPostBot)\
**Post date:** [October 14, 2026, 2:41pm UTC](https://discourse.libsdl.org/t/sdl-audio-make-sure-to-set-device-spec-before-actually-opening-the-device/69555/1 "2026-10-14T14:41:53Z")

</div>

> <https://github.com/libsdl-org/SDL/commit/ab5541ec5d4377dcc20a701897437f07ba71566f>
>
> This was a regression introduced in 36fed09edb7b8fd8eb808769c6896309ee6c36ec.
> 
> (…slouken actually caught this one, but I'm committing the fix.)

```diff
From ab5541ec5d4377dcc20a701897437f07ba71566f Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Tue, 13 Oct 2026 12:34:34 -0400
Subject: [PATCH] audio: Make sure to set `device->spec` before actually
 opening the device.

This was a regression introduced in 36fed09edb7b8fd8eb808769c6896309ee6c36ec.

(slouken actually caught this one, but I'm committing the fix.)
---
 src/audio/SDL_audio.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c
index 905438ed45857..242595c50083e 100644
--- a/src/audio/SDL_audio.c
+++ b/src/audio/SDL_audio.c
@@ -1932,6 +1932,7 @@ static bool OpenPhysicalAudioDevice(SDL_AudioDevice *device, const SDL_AudioSpec
         return true; // carry on with the reconfigured device!
     }
 
+ SDL_copyp(&device->spec, &spec); // this is what current_audio.impl.OpenDevice() will use for the requested format. !!! FIXME: maybe we should move this to a param instead of changing state, though.
 
     // These start with the backend's implementation, but we might swap them out with zombie versions later.
     device->WaitDevice = current_audio.impl.WaitDevice;

```
