mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-27 11:12:44 +01:00
audio: Refactoring: Remove context.sampleRate
This commit is contained in:
parent
805e6b7b36
commit
7bdda4e9ca
@ -173,22 +173,21 @@ func (s *mixingStream) playerCurrent(player *Player) time.Duration {
|
|||||||
// TODO: Enable to specify the format like Mono8?
|
// TODO: Enable to specify the format like Mono8?
|
||||||
|
|
||||||
type Context struct {
|
type Context struct {
|
||||||
sampleRate int
|
stream *mixingStream
|
||||||
stream *mixingStream
|
errorCh chan error
|
||||||
errorCh chan error
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewContext(sampleRate int) (*Context, error) {
|
func NewContext(sampleRate int) (*Context, error) {
|
||||||
// TODO: Panic if one context exists.
|
// TODO: Panic if one context exists.
|
||||||
c := &Context{
|
c := &Context{
|
||||||
sampleRate: sampleRate,
|
errorCh: make(chan error),
|
||||||
errorCh: make(chan error),
|
|
||||||
}
|
}
|
||||||
c.stream = &mixingStream{
|
c.stream = &mixingStream{
|
||||||
sampleRate: sampleRate,
|
sampleRate: sampleRate,
|
||||||
players: map[*Player]struct{}{},
|
players: map[*Player]struct{}{},
|
||||||
}
|
}
|
||||||
p, err := newPlayer(c.stream, c.sampleRate)
|
// TODO: Rename this other than player
|
||||||
|
p, err := newPlayer(c.stream, sampleRate)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -229,7 +228,7 @@ func (c *Context) Update() error {
|
|||||||
// SampleRate returns the sample rate.
|
// SampleRate returns the sample rate.
|
||||||
// All audio source must have the same sample rate.
|
// All audio source must have the same sample rate.
|
||||||
func (c *Context) SampleRate() int {
|
func (c *Context) SampleRate() int {
|
||||||
return c.sampleRate
|
return c.stream.sampleRate
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReadSeekCloser is an io.ReadSeeker and io.Closer.
|
// ReadSeekCloser is an io.ReadSeeker and io.Closer.
|
||||||
|
Loading…
Reference in New Issue
Block a user