From 30dd5ffdcb94e4f445f9cd89326cb65c5954eed7 Mon Sep 17 00:00:00 2001 From: NeilClack Date: Tue, 23 Jun 2026 11:22:21 -0500 Subject: [PATCH] Create objects for tracking audio devices --- internal/page/AudioOptions.go | 51 ++++++++++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 7 deletions(-) diff --git a/internal/page/AudioOptions.go b/internal/page/AudioOptions.go index 82acc6e..020ad55 100644 --- a/internal/page/AudioOptions.go +++ b/internal/page/AudioOptions.go @@ -37,20 +37,34 @@ var AudioFileList = []db.AudioFile{ const triangleSize = float32(16) +type AudioDevice struct { + Label string + ID int +} + type AudioOptions struct { + // Page Attributes Base - font *fontManager.FontEntry - textShader *shaderManager.Shader - solidShader *shaderManager.Shader - title StringItem - prompt StringItem + font *fontManager.FontEntry + textShader *shaderManager.Shader + solidShader *shaderManager.Shader + CfgPtr *db.AppConfig + + // Page Textures + title StringItem + prompt StringItem + + // Layout verticalMargin int32 ItemScale float32 - CfgPtr *db.AppConfig // Audio toggle AudioStatusToggle StringItem + // Audio Devices + AudioDevices []AudioDevice + AudioDeviceTextures []StringItem + // Volume row VolumeLabel StringItem volumePercent StringItem @@ -187,6 +201,29 @@ func (p *AudioOptions) CreateAudioStatusItem() error { return nil } +// ── Audio Output Devices ────────────────────────────────────────────────────── +func (p *AudioOptions) GetAudioDevices() error { + numAudioDevices := sdl.GetNumAudioDevices(false) + if numAudioDevices == 0 { + return nil + } + var audioDevices = make([]AudioDevice, numAudioDevices) + for i := range numAudioDevices { + audioDevice := sdl.GetAudioDeviceName(i, false) + audioDevices = append(audioDevices, AudioDevice{Label: audioDevice, ID: i}) + } + p.AudioDevices = audioDevices + + for i := range audioDevices { + newAudioDeviceStringItem, err := NewStringItem(p.AudioDevices[i].Label, p.font, colors.White) + if err != nil { + return err + } + p.AudioDeviceTextures = append(p.AudioDeviceTextures, newAudioDeviceStringItem) + } + return nil +} + // ── Volume ──────────────────────────────────────────────────────────────────── func (p *AudioOptions) CreateVolumePercentItem() error { @@ -335,7 +372,7 @@ func (p *AudioOptions) renderVolumeBar() error { {{bx, by}, {bw, thickness}}, {{bx, by + bh - thickness}, {bw, thickness}}, {{bx, by}, {thickness, bh}}, - {{bx + bw - thickness}, {thickness, bh}}, + {{bx + bw - thickness, by}, {thickness, bh}}, } for _, r := range outlineRects { if err := p.RenderSolidColorQuad(p.solidShader, r[0], r[1], colors.Green); err != nil {