Remove devices list and device vector length check
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user