From d861c4af6826951783dfd797c87817df44892b8d Mon Sep 17 00:00:00 2001 From: Burcu Dogan Date: Thu, 7 May 2015 19:54:46 -0400 Subject: [PATCH] mobile/audio: rename (*Player).Destroy to (*Player).Close Destroy sounds like C, we should use Close in Go. Change-Id: I73da732300a955e458513f15ad898b7f34c8ed7c Reviewed-on: https://go-review.googlesource.com/9875 Reviewed-by: Nigel Tao --- audio/audio.go | 10 ++++++---- audio/audio_test.go | 2 +- example/audio/main.go | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/audio/audio.go b/audio/audio.go index 9312b15..de79e0c 100644 --- a/audio/audio.go +++ b/audio/audio.go @@ -302,11 +302,12 @@ func (p *Player) State() State { return codeToState[p.source.State()] } -// Destroy frees the underlying resources used by the player. +// Close closes the device and frees the underlying resources +// used by the player. // It should be called as soon as the player is not in-use anymore. -func (p *Player) Destroy() { +func (p *Player) Close() error { if p == nil { - return + return nil } if p.source != 0 { al.DeleteSources(p.source) @@ -317,6 +318,7 @@ func (p *Player) Destroy() { } p.mu.Unlock() p.t.src.Close() + return nil } func byteOffsetToDur(t *track, offset int64) time.Duration { @@ -336,4 +338,4 @@ func lastErr() error { return nil } -// TODO(jbd): Destroy context, close the device. +// TODO(jbd): Close the device. diff --git a/audio/audio_test.go b/audio/audio_test.go index 1d96e3c..51f047b 100644 --- a/audio/audio_test.go +++ b/audio/audio_test.go @@ -36,5 +36,5 @@ func TestNoOp(t *testing.T) { } p.SetVolume(0.1) p.Seek(1 * time.Second) - p.Destroy() + p.Close() } diff --git a/example/audio/main.go b/example/audio/main.go index 0f86eb5..e504c20 100644 --- a/example/audio/main.go +++ b/example/audio/main.go @@ -83,7 +83,7 @@ func start() { } func stop() { - player.Destroy() + player.Close() } func draw() {