audio: SetVolume now rejects NaN

This commit is contained in:
Hajime Hoshi 2016-04-03 02:46:18 +09:00
parent 54f0e30fe6
commit e631714a43

View File

@ -262,12 +262,9 @@ func (p *Player) Volume() float64 {
} }
func (p *Player) SetVolume(volume float64) { func (p *Player) SetVolume(volume float64) {
// TODO: What if volume is NaN? // The condition must be true when volume is NaN.
if 1 < volume { if !(0 <= volume && volume <= 1) {
panic("audio: volume must <= 1") panic("audio: volume must be in between 0 and 1")
}
if volume < 0 {
panic("audio: volume must >= 0")
} }
p.volume = volume p.volume = volume
} }