mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
audio: Refactoring: Remove newPlayerFromCache
This commit is contained in:
parent
62af947368
commit
9c097c73f5
@ -42,8 +42,14 @@ type player struct {
|
||||
|
||||
var m sync.Mutex
|
||||
|
||||
// TODO: Unify this to newPlayer
|
||||
func newPlayerFromCache(src io.Reader, sampleRate int) (*player, error) {
|
||||
func newPlayer(src io.Reader, sampleRate int) (*player, error) {
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
|
||||
if e := al.OpenDevice(); e != nil {
|
||||
m.Unlock()
|
||||
return nil, fmt.Errorf("audio: OpenAL initialization failed: %v", e)
|
||||
}
|
||||
s := al.GenSources(1)
|
||||
if err := al.Error(); err != 0 {
|
||||
panic(fmt.Sprintf("audio: al.GenSources error: %d", err))
|
||||
@ -58,21 +64,6 @@ func newPlayerFromCache(src io.Reader, sampleRate int) (*player, error) {
|
||||
return p, nil
|
||||
}
|
||||
|
||||
func newPlayer(src io.Reader, sampleRate int) (*player, error) {
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
|
||||
if e := al.OpenDevice(); e != nil {
|
||||
m.Unlock()
|
||||
return nil, fmt.Errorf("audio: OpenAL initialization failed: %v", e)
|
||||
}
|
||||
p, err := newPlayerFromCache(src, sampleRate)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return p, nil
|
||||
}
|
||||
|
||||
const bufferSize = 1024
|
||||
|
||||
func (p *player) proceed() error {
|
||||
|
Loading…
Reference in New Issue
Block a user