mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-26 02:42:02 +01:00
audio: Don't check errors until making current context is done (#204)
This commit is contained in:
parent
509aa22bae
commit
702884acf5
@ -57,14 +57,19 @@ func alFormat(channelNum, bytesPerSample int) openal.Format {
|
|||||||
|
|
||||||
func NewPlayer(src io.Reader, sampleRate, channelNum, bytesPerSample int) (*Player, error) {
|
func NewPlayer(src io.Reader, sampleRate, channelNum, bytesPerSample int) (*Player, error) {
|
||||||
d := openal.OpenDevice("")
|
d := openal.OpenDevice("")
|
||||||
if err := openal.Err(); err != nil {
|
if d == nil {
|
||||||
return nil, fmt.Errorf("driver: OpenDevice: %v", err)
|
return nil, fmt.Errorf("driver: OpenDevice must not return nil")
|
||||||
}
|
}
|
||||||
c := d.CreateContext()
|
c := d.CreateContext()
|
||||||
if err := openal.Err(); err != nil {
|
if c == nil {
|
||||||
return nil, fmt.Errorf("driver: CreateContext: %v", err)
|
return nil, fmt.Errorf("driver: CreateContext must not return nil")
|
||||||
}
|
}
|
||||||
|
// Don't check openal.Err until making the current context is done.
|
||||||
|
// Linux might fail this check even though it succeeds (#204).
|
||||||
c.Activate()
|
c.Activate()
|
||||||
|
if err := openal.Err(); err != nil {
|
||||||
|
return nil, fmt.Errorf("driver: Activate: %v", err)
|
||||||
|
}
|
||||||
s := openal.NewSource()
|
s := openal.NewSource()
|
||||||
if err := openal.Err(); err != nil {
|
if err := openal.Err(); err != nil {
|
||||||
return nil, fmt.Errorf("driver: NewSource: %v", err)
|
return nil, fmt.Errorf("driver: NewSource: %v", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user