2
0
mirror of synced 2025-02-23 06:48:15 +00:00

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 <nigeltao@golang.org>
This commit is contained in:
Burcu Dogan 2015-05-07 19:54:46 -04:00
parent 2aa4da50c5
commit d861c4af68
3 changed files with 8 additions and 6 deletions

View File

@ -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.

View File

@ -36,5 +36,5 @@ func TestNoOp(t *testing.T) {
}
p.SetVolume(0.1)
p.Seek(1 * time.Second)
p.Destroy()
p.Close()
}

View File

@ -83,7 +83,7 @@ func start() {
}
func stop() {
player.Destroy()
player.Close()
}
func draw() {