Skip to content

Commit

Permalink
Merge pull request #811 from samhocevar-forks/cfte/pause-music
Browse files Browse the repository at this point in the history
Pausing the game will also pause the music
  • Loading branch information
K4thos authored Jan 14, 2023
2 parents 0d5ebfe + 319cc70 commit 6d925c2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
5 changes: 2 additions & 3 deletions src/sound.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,12 @@ func (bgm *Bgm) Open(filename string, loop, bgmVolume, bgmLoopStart, bgmLoopEnd,
speaker.Play(bgm.ctrl)
}

func (bgm *Bgm) Pause() {
// FIXME: there is no method to unpause!
func (bgm *Bgm) SetPaused(paused bool) {
if bgm.ctrl == nil {
return
}
speaker.Lock()
bgm.ctrl.Paused = true
bgm.ctrl.Paused = paused
speaker.Unlock()
}

Expand Down
13 changes: 1 addition & 12 deletions src/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -555,18 +555,7 @@ func (s *System) tickSound() {
}
}

if !s.nomusic {
speaker.Lock()
if s.bgm.ctrl != nil && s.bgm.streamer != nil {
s.bgm.ctrl.Paused = false
// if s.bgm.bgmLoopEnd > 0 && s.bgm.streamer.Position() >= s.bgm.bgmLoopEnd {
// s.bgm.streamer.Seek(s.bgm.bgmLoopStart)
// }
}
speaker.Unlock()
} else {
s.bgm.Pause()
}
s.bgm.SetPaused(s.nomusic || s.paused)

//if s.FLAC_FrameWait >= 0 {
// if s.FLAC_FrameWait == 0 {
Expand Down

0 comments on commit 6d925c2

Please sign in to comment.