From 7bdda4e9caeafea88c5283948f3d3ca074259128 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Tue, 5 Apr 2016 02:37:29 +0900 Subject: [PATCH] audio: Refactoring: Remove context.sampleRate --- exp/audio/audio.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/exp/audio/audio.go b/exp/audio/audio.go index 02f08bb94..8f67c60fa 100644 --- a/exp/audio/audio.go +++ b/exp/audio/audio.go @@ -173,22 +173,21 @@ 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 + stream *mixingStream + errorCh chan error } func NewContext(sampleRate int) (*Context, error) { // TODO: Panic if one context exists. c := &Context{ - sampleRate: sampleRate, - errorCh: make(chan error), + 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.