Remove devices list and device vector length check

This commit is contained in:
NeilClack
2026-04-23 17:26:22 -05:00
parent 9575833392
commit 05a7098886
8 changed files with 71 additions and 80 deletions
+6
View File
@@ -103,13 +103,17 @@ func openDeviceLocked(name string) error {
// Play loads a WAV (as music) and plays it. If loopForever is true, loops forever.
// If something is already playing, it stops and replaces it.
func Play(path string, loopForever bool, cfg *db.AppConfig) error {
// Check if audio is enabled or disabled
if !cfg.AudioEnabled {
return nil
}
// Lock the mutex
mu.Lock()
defer mu.Unlock()
// Check if mixer has been initialized and that a device is open
// JUMP: This is where the issue is...
if !inited || !deviceOpen {
logger.Error("audio mixer not initialized")
return errors.New("audio mixer not initialized")
@@ -126,10 +130,12 @@ func Play(path string, loopForever bool, cfg *db.AppConfig) error {
currentMusic = nil
}
// Load the music file
m, err := mix.LoadMUS(path)
if err != nil {
return fmt.Errorf("LoadMUS(%q): %w", path, err)
}
// Set current music to the loaded music file
currentMusic = m
currentPath = path
if loopForever {