Skip to content

Commit

Permalink
Rename Write to TryWrite to avoid confusion
Browse files Browse the repository at this point in the history
  • Loading branch information
hajimehoshi committed Dec 28, 2017
1 parent a1e3e88 commit 029232d
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion player.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func (p *Player) SetUnderrunCallback(f func()) {
func (p *Player) Write(data []byte) (int, error) {
written := 0
for len(data) > 0 {
n, err := p.player.Write(data)
n, err := p.player.TryWrite(data)
written += n
if err != nil {
return written, err
Expand Down
2 changes: 1 addition & 1 deletion player_android.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ func (p *player) SetUnderrunCallback(f func()) {
//TODO
}

func (p *player) Write(data []byte) (int, error) {
func (p *player) TryWrite(data []byte) (int, error) {
n := min(len(data), p.bufferSize-len(p.tmp))
p.tmp = append(p.tmp, data[:n]...)

Expand Down
2 changes: 1 addition & 1 deletion player_js.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func nowInSeconds() float64 {
return js.Global.Get("performance").Call("now").Float() / 1000.0
}

func (p *player) Write(data []byte) (int, error) {
func (p *player) TryWrite(data []byte) (int, error) {
n := min(len(data), max(0, p.bufferSize-len(p.tmp)))
p.tmp = append(p.tmp, data[:n]...)

Expand Down
2 changes: 1 addition & 1 deletion player_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (p *player) SetUnderrunCallback(f func()) {
p.underrun = f
}

func (p *player) Write(data []byte) (n int, err error) {
func (p *player) TryWrite(data []byte) (n int, err error) {
bufSize := p.bufSamples * p.numChans * p.bytesPerSample
for len(data) > 0 {
toWrite := min(len(data), max(0, bufSize-len(p.buf)))
Expand Down
2 changes: 1 addition & 1 deletion player_openal.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func (p *player) SetUnderrunCallback(f func()) {
//TODO
}

func (p *player) Write(data []byte) (int, error) {
func (p *player) TryWrite(data []byte) (int, error) {
if err := p.alDevice.getError(); err != nil {
return 0, fmt.Errorf("oto: starting Write: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion player_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (p *player) SetUnderrunCallback(f func()) {
//TODO
}

func (p *player) Write(data []byte) (int, error) {
func (p *player) TryWrite(data []byte) (int, error) {
n := min(len(data), max(0, p.bufferSize-len(p.tmp)))
p.tmp = append(p.tmp, data[:n]...)
if len(p.tmp) < p.bufferSize {
Expand Down

0 comments on commit 029232d

Please sign in to comment.