Skip to content

Expose internal device properties from audio backend#69

Merged
gen2brain merged 1 commit into
gen2brain:masterfrom
tphakala:expose-internal-device-properties
May 13, 2026
Merged

Expose internal device properties from audio backend#69
gen2brain merged 1 commit into
gen2brain:masterfrom
tphakala:expose-internal-device-properties

Conversation

@tphakala

Copy link
Copy Markdown
Contributor

After device initialization, miniaudio stores both the requested and the
actual (internal) format, channel count, and sample rate in ma_device. The
internal values reflect what the audio backend negotiated, which can differ
from what the application asked for.

A practical example: ALSA's dsnoop plugin locks the hardware at a fixed
sample rate (typically 48 kHz) and silently resamples everything else.
The existing SampleRate() returns the requested rate, so callers have no
way to detect the mismatch. CaptureInternalSampleRate() reads
capture.internalSampleRate from the underlying ma_device struct, giving
the actual hardware rate.

This adds six read-only accessors, three per direction (capture/playback):

  • CaptureInternalSampleRate / PlaybackInternalSampleRate
  • CaptureInternalFormat / PlaybackInternalFormat
  • CaptureInternalChannels / PlaybackInternalChannels

All are non-breaking additions that follow the same pattern as the existing
PlaybackFormat(), CaptureChannels(), etc.

After initialization, miniaudio's ma_device struct contains both the
requested and the actual (internal) format, channel count, and sample
rate for capture and playback. The internal values reflect what the
audio backend actually negotiated, which can differ from what the
application requested.

A common case is ALSA's dsnoop plugin, which locks the hardware at a
fixed sample rate and silently resamples. The existing SampleRate()
method returns the requested rate, hiding the mismatch. The new
CaptureInternalSampleRate() and PlaybackInternalSampleRate() methods
let callers detect this.

New methods:
  - CaptureInternalSampleRate / PlaybackInternalSampleRate
  - CaptureInternalFormat / PlaybackInternalFormat
  - CaptureInternalChannels / PlaybackInternalChannels
@gen2brain gen2brain merged commit dd586bd into gen2brain:master May 13, 2026
6 of 9 checks passed
@gen2brain

Copy link
Copy Markdown
Owner

Merged, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants