about summary refs log tree commit diff
path: root/tools/mpd-stats/internal
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2021-10-10 11:34:07 -0700
committerFranck Cuny <franck@fcuny.net>2022-06-11 14:32:07 -0700
commit14744fe82699d39b56d1acf795c7ffef38139b95 (patch)
tree8fada8cbbcc7b2eae807621eb143f1ca15574642 /tools/mpd-stats/internal
parentmpd: rename function to create the player (diff)
downloadworld-14744fe82699d39b56d1acf795c7ffef38139b95.tar.gz
mpd: add function `Close` to the player
Let's close both the watcher and the client, instead of leaking this
interface to the user.
Diffstat (limited to 'tools/mpd-stats/internal')
-rw-r--r--tools/mpd-stats/internal/mpd/mpd.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/tools/mpd-stats/internal/mpd/mpd.go b/tools/mpd-stats/internal/mpd/mpd.go
index ed9d3c2..cebf2b2 100644
--- a/tools/mpd-stats/internal/mpd/mpd.go
+++ b/tools/mpd-stats/internal/mpd/mpd.go
@@ -36,3 +36,13 @@ func NewPlayer(net string, addr string) (*player, error) {
 
 	return &p, nil
 }
+
+func (p *player) Close() error {
+	if err := p.Watcher.Close(); err != nil {
+		return err
+	}
+	if err := p.Client.Close(); err != nil {
+		return err
+	}
+	return nil
+}