audio: use NewContextWithOptions

Upates #2534
This commit is contained in:
Hajime Hoshi 2023-01-09 18:45:36 +09:00
parent 6bce8fea2d
commit 8ef52841bc
4 changed files with 10 additions and 6 deletions

View File

@ -20,8 +20,12 @@ import (
"github.com/hajimehoshi/oto/v2"
)
func newContext(sampleRate, channelCount, bitDepthInBytes int) (context, chan struct{}, error) {
ctx, ready, err := oto.NewContext(sampleRate, channelCount, bitDepthInBytes)
func newContext(sampleRate int) (context, chan struct{}, error) {
ctx, ready, err := oto.NewContextWithOptions(&oto.NewContextOptions{
SampleRate: sampleRate,
ChannelCount: channelCount,
Format: bitDepthInBytes,
})
err = addErrorInfoForContextCreation(err)
return &contextProxy{ctx}, ready, err
}

View File

@ -124,7 +124,7 @@ func (f *playerFactory) initContextIfNeeded() (<-chan struct{}, error) {
return nil, nil
}
c, ready, err := newContext(f.sampleRate, channelCount, bitDepthInBytes)
c, ready, err := newContext(f.sampleRate)
if err != nil {
return nil, err
}

2
go.mod
View File

@ -7,7 +7,7 @@ require (
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20221017161538-93cebf72946b
github.com/hajimehoshi/bitmapfont/v2 v2.2.3
github.com/hajimehoshi/go-mp3 v0.3.4
github.com/hajimehoshi/oto/v2 v2.4.0-alpha.10.0.20230107095450-7e07d2d07898
github.com/hajimehoshi/oto/v2 v2.4.0-alpha.10.0.20230109090240-83efbbaa8024
github.com/jakecoffman/cp v1.2.1
github.com/jezek/xgb v1.1.0
github.com/jfreymuth/oggvorbis v1.0.4

4
go.sum
View File

@ -8,8 +8,8 @@ github.com/hajimehoshi/bitmapfont/v2 v2.2.3/go.mod h1:sWM8ejdkGSXaQGlZcegMRx4DyE
github.com/hajimehoshi/go-mp3 v0.3.4 h1:NUP7pBYH8OguP4diaTZ9wJbUbk3tC0KlfzsEpWmYj68=
github.com/hajimehoshi/go-mp3 v0.3.4/go.mod h1:fRtZraRFcWb0pu7ok0LqyFhCUrPeMsGRSVop0eemFmo=
github.com/hajimehoshi/oto/v2 v2.3.1/go.mod h1:seWLbgHH7AyUMYKfKYT9pg7PhUu9/SisyJvNTT+ASQo=
github.com/hajimehoshi/oto/v2 v2.4.0-alpha.10.0.20230107095450-7e07d2d07898 h1:vXa8jrvtwSYYoCg10X0xcpE84Tqw6HfvYkMoNKRnma4=
github.com/hajimehoshi/oto/v2 v2.4.0-alpha.10.0.20230107095450-7e07d2d07898/go.mod h1:wre+KgbOrKDXpgk6W/JC6KoFqZnVC/VtX5ZFRkJuxO4=
github.com/hajimehoshi/oto/v2 v2.4.0-alpha.10.0.20230109090240-83efbbaa8024 h1:o9DkHJHwms3ZlLTpZ9psAfY9ttSCTltSlzj3XwEliw0=
github.com/hajimehoshi/oto/v2 v2.4.0-alpha.10.0.20230109090240-83efbbaa8024/go.mod h1:wre+KgbOrKDXpgk6W/JC6KoFqZnVC/VtX5ZFRkJuxO4=
github.com/jakecoffman/cp v1.2.1 h1:zkhc2Gpo9l4NLUZfeG3j33+3bQD7MkqPa+n5PdX+5mI=
github.com/jakecoffman/cp v1.2.1/go.mod h1:JjY/Fp6d8E1CHnu74gWNnU0+b9VzEdUVPoJxg2PsTQg=
github.com/jezek/xgb v1.1.0 h1:wnpxJzP1+rkbGclEkmwpVFQWpuE2PUGNUzP8SbfFobk=