Report OpenAL lifecycle errors
This commit is contained in:
committed by
Brandon McGinty
parent
c8ddb7a567
commit
2c636016b0
@@ -254,7 +254,7 @@ Priority 3: configuration, UI, and binding hardening
|
|||||||
vetted representation/pattern and re-run vet. Listener orientation uses a
|
vetted representation/pattern and re-run vet. Listener orientation uses a
|
||||||
global tempSlice without synchronization; use a local fixed array.
|
global tempSlice without synchronization; use a local fixed array.
|
||||||
|
|
||||||
33. OpenAL errors are mostly ignored
|
[x] 33. OpenAL errors are mostly ignored
|
||||||
Files: gumble/gumbleopenal/stream.go, gumble/go-openal/openal/*.go
|
Files: gumble/gumbleopenal/stream.go, gumble/go-openal/openal/*.go
|
||||||
Source/buffer/context/capture calls generally do not check AL/ALC errors,
|
Source/buffer/context/capture calls generally do not check AL/ALC errors,
|
||||||
so invalid device/context/buffer operations become silent audio failure.
|
so invalid device/context/buffer operations become silent audio failure.
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package gumbleopenal
|
|||||||
import (
|
import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
"runtime"
|
"runtime"
|
||||||
"sync"
|
"sync"
|
||||||
@@ -110,6 +111,10 @@ func New(client *gumble.Client, inputDevice *string, outputDevice *string, test
|
|||||||
log.Error("OpenAL capture: failed to open device %q", devName)
|
log.Error("OpenAL capture: failed to open device %q", devName)
|
||||||
return nil, ErrInputDevice
|
return nil, ErrInputDevice
|
||||||
}
|
}
|
||||||
|
if err := idev.Err(); err != nil {
|
||||||
|
idev.CaptureCloseDevice()
|
||||||
|
return nil, fmt.Errorf("%w: %v", ErrInputDevice, err)
|
||||||
|
}
|
||||||
log.Info("OpenAL capture: opened device %q format=%v channels=%d", devName, inputFormat, sourceChannels)
|
log.Info("OpenAL capture: opened device %q format=%v channels=%d", devName, inputFormat, sourceChannels)
|
||||||
|
|
||||||
outName := ""
|
outName := ""
|
||||||
@@ -121,6 +126,11 @@ func New(client *gumble.Client, inputDevice *string, outputDevice *string, test
|
|||||||
idev.CaptureCloseDevice()
|
idev.CaptureCloseDevice()
|
||||||
return nil, ErrOutputDevice
|
return nil, ErrOutputDevice
|
||||||
}
|
}
|
||||||
|
if err := odev.Err(); err != nil {
|
||||||
|
idev.CaptureCloseDevice()
|
||||||
|
odev.CloseDevice()
|
||||||
|
return nil, fmt.Errorf("%w: %v", ErrOutputDevice, err)
|
||||||
|
}
|
||||||
|
|
||||||
if test {
|
if test {
|
||||||
idev.CaptureCloseDevice()
|
idev.CaptureCloseDevice()
|
||||||
@@ -151,7 +161,11 @@ func New(client *gumble.Client, inputDevice *string, outputDevice *string, test
|
|||||||
}
|
}
|
||||||
s.contextSink = s.deviceSink.CreateContext()
|
s.contextSink = s.deviceSink.CreateContext()
|
||||||
if s.contextSink == nil {
|
if s.contextSink == nil {
|
||||||
|
err := s.deviceSink.Err()
|
||||||
s.Destroy()
|
s.Destroy()
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("%w: %v", ErrOutputDevice, err)
|
||||||
|
}
|
||||||
return nil, ErrOutputDevice
|
return nil, ErrOutputDevice
|
||||||
}
|
}
|
||||||
// OpenAL contexts are current to an OS thread. Move ownership to one
|
// OpenAL contexts are current to an OS thread. Move ownership to one
|
||||||
@@ -334,6 +348,9 @@ func (s *Stream) StartSource(inputDevice *string) error {
|
|||||||
return ErrMic
|
return ErrMic
|
||||||
}
|
}
|
||||||
s.deviceSource.CaptureStart()
|
s.deviceSource.CaptureStart()
|
||||||
|
if err := s.deviceSource.Err(); err != nil {
|
||||||
|
return fmt.Errorf("%w: %v", ErrMic, err)
|
||||||
|
}
|
||||||
stop := make(chan bool)
|
stop := make(chan bool)
|
||||||
done := make(chan struct{})
|
done := make(chan struct{})
|
||||||
s.sourceStop, s.sourceDone = stop, done
|
s.sourceStop, s.sourceDone = stop, done
|
||||||
@@ -357,6 +374,9 @@ func (s *Stream) StopSource() error {
|
|||||||
return ErrMic
|
return ErrMic
|
||||||
}
|
}
|
||||||
s.deviceSource.CaptureStop()
|
s.deviceSource.CaptureStop()
|
||||||
|
if err := s.deviceSource.Err(); err != nil {
|
||||||
|
return fmt.Errorf("%w: %v", ErrMic, err)
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user