---
name: "SDL_GetAudioDeviceFormat"
section: "3"
platform: "linux"
package: "libsdl3-doc"
version: "3.2.10+ds-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/SDL_GetAudioDeviceFormat"
---

# SDL\_GetAudioDeviceFormat(3)

Get the current audio format of a specific audio device.

## NAME

SDL\_GetAudioDeviceFormat - Get the current audio format of a specific audio device.

## HEADER FILE

Defined in SDL3/SDL\_audio.h

## SYNOPSIS

```
#include "SDL3/SDL.h"
```

**bool SDL\_GetAudioDeviceFormat(SDL\_AudioDeviceID devid, SDL\_AudioSpec \*spec, int \*sample\_frames);**

## DESCRIPTION

For an opened device, this will report the format the device is currently using. If the device isn't yet opened, this will report the device's preferred format (or a reasonable default if this can't be determined).

You may also specify

**SDL\_AUDIO\_DEVICE\_DEFAULT\_PLAYBACK**\
  or

**SDL\_AUDIO\_DEVICE\_DEFAULT\_RECORDING**

here, which is useful for getting a reasonable recommendation before opening the system-recommended default device.

You can also use this to request the current device buffer size. This is specified in sample frames and represents the amount of data SDL will feed to the physical hardware in each chunk. This can be converted to milliseconds of audio with the following equation: **ms**=**(int)**((((Sint64)**frames)**\***1000)**/**spec.freq);** Buffer size is only important if you need low-level control over the audio playback timing. Most apps do not need this.

## FUNCTION PARAMETERS

- *devid*

  the instance ID of the device to query.

- *spec*

  on return, will be filled with device details.

- *sample\_frames*

  pointer to store device buffer size, in sample frames. Can be NULL.

## RETURN VALUE

Returns true on success or false on failure; call

**SDL\_GetError** () for more information.

## THREAD SAFETY

It is safe to call this function from any thread.

## AVAILABILITY

This function is available since SDL 3.2.0.
