audio: Refactoring: Remove context.sampleRate

This commit is contained in:
Hajime Hoshi 2016-04-05 02:37:29 +09:00
parent 805e6b7b36
commit 7bdda4e9ca

View File

@ -173,7 +173,6 @@ func (s *mixingStream) playerCurrent(player *Player) time.Duration {
// TODO: Enable to specify the format like Mono8?
type Context struct {
sampleRate int
stream *mixingStream
errorCh chan error
}
@ -181,14 +180,14 @@ type Context struct {
func NewContext(sampleRate int) (*Context, error) {
// TODO: Panic if one context exists.
c := &Context{
sampleRate: sampleRate,
errorCh: make(chan error),
}
c.stream = &mixingStream{
sampleRate: sampleRate,
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 {
return nil, err
}
@ -229,7 +228,7 @@ func (c *Context) Update() error {
// SampleRate returns the sample rate.
// All audio source must have the same sample rate.
func (c *Context) SampleRate() int {
return c.sampleRate
return c.stream.sampleRate
}
// ReadSeekCloser is an io.ReadSeeker and io.Closer.