diff options
| author | Franck Cuny <franck@fcuny.net> | 2021-10-10 11:34:07 -0700 |
|---|---|---|
| committer | Franck Cuny <franck@fcuny.net> | 2021-10-10 11:34:07 -0700 |
| commit | 5caeabc351feffb1769b842e8d79481f330c46d9 (patch) | |
| tree | 67552aa54c8ec822b9d836e738ab82248bd1554b /internal | |
| parent | mpd: rename function to create the player (diff) | |
| download | x-5caeabc351feffb1769b842e8d79481f330c46d9.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 'internal')
| -rw-r--r-- | internal/mpd/mpd.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/internal/mpd/mpd.go b/internal/mpd/mpd.go index ed9d3c2..cebf2b2 100644 --- a/internal/mpd/mpd.go +++ b/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 +} |
