mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
audio: Refactoring: Add loop
This commit is contained in:
parent
d6dee0815e
commit
ca2f85f3d1
@ -219,7 +219,11 @@ func NewPlayer(sampleRate, channelNum, bytesPerSample int) (*Player, error) {
|
|||||||
}); err != nil {
|
}); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
go func() {
|
go p.loop()
|
||||||
|
return p, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Player) loop() {
|
||||||
for bufInBytes := range p.chBuffer {
|
for bufInBytes := range p.chBuffer {
|
||||||
var bufInShorts []int16
|
var bufInShorts []int16
|
||||||
if p.bytesPerSample == 2 {
|
if p.bytesPerSample == 2 {
|
||||||
@ -250,8 +254,6 @@ func NewPlayer(sampleRate, channelNum, bytesPerSample int) (*Player, error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
|
||||||
return p, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Player) Proceed(data []byte) error {
|
func (p *Player) Proceed(data []byte) error {
|
||||||
|
Loading…
Reference in New Issue
Block a user