aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlawl <github@dumbinter.net>2020-07-19 12:03:43 +0200
committerlawl <github@dumbinter.net>2020-07-19 12:03:43 +0200
commit93fe38ec41037aa869d8c752ec96b7b7776e184b (patch)
tree23b7720127858c4e341fa299b3e0c3cba32962aa
parent35e353775b2b3f9683b3d2dc8d32118470f4b551 (diff)
downloadnoisetorch-93fe38ec41037aa869d8c752ec96b7b7776e184b.tar.gz
noisetorch-93fe38ec41037aa869d8c752ec96b7b7776e184b.zip
Update pulseaudio module to respect XDG
-rw-r--r--go.mod2
-rw-r--r--go.sum2
-rw-r--r--vendor/github.com/lawl/pulseaudio/README.md6
-rw-r--r--vendor/github.com/lawl/pulseaudio/client.go57
-rw-r--r--vendor/modules.txt2
5 files changed, 44 insertions, 25 deletions
diff --git a/go.mod b/go.mod
index aeede58..3e8e221 100644
--- a/go.mod
+++ b/go.mod
@@ -6,6 +6,6 @@ require (
gioui.org v0.0.0-20200630184602-223f8fd40ae4 // indirect
github.com/BurntSushi/toml v0.3.1
github.com/aarzilli/nucular v0.0.0-20200615134801-81910c722bba
- github.com/lawl/pulseaudio v0.0.0-20200704145757-7d4b4b92e7b7
+ github.com/lawl/pulseaudio v0.0.0-20200719094555-c019d8a2304f
golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899
)
diff --git a/go.sum b/go.sum
index b773f61..e7083ab 100644
--- a/go.sum
+++ b/go.sum
@@ -19,6 +19,8 @@ github.com/hashicorp/golang-lru v0.0.0-20160813221303-0a025b7e63ad h1:eMxs9EL0Pv
github.com/hashicorp/golang-lru v0.0.0-20160813221303-0a025b7e63ad/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/lawl/pulseaudio v0.0.0-20200704145757-7d4b4b92e7b7 h1:LjLOowMTfYESP3XW5/KV6TaQVuhdvkBHJoEaReGds6M=
github.com/lawl/pulseaudio v0.0.0-20200704145757-7d4b4b92e7b7/go.mod h1:9h36x4KH7r2V8DOCKoPMt87IXZ++X90y8D5nnuwq290=
+github.com/lawl/pulseaudio v0.0.0-20200719094555-c019d8a2304f h1:MA90ko9/uptNdk2wRHAqm1fpyCogyFTKo162qPv2FgA=
+github.com/lawl/pulseaudio v0.0.0-20200719094555-c019d8a2304f/go.mod h1:9h36x4KH7r2V8DOCKoPMt87IXZ++X90y8D5nnuwq290=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529 h1:iMGN4xG0cnqj3t+zOM8wUB0BiPKHEwSxEZCvzcbZuvk=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
diff --git a/vendor/github.com/lawl/pulseaudio/README.md b/vendor/github.com/lawl/pulseaudio/README.md
index 17eb764..372f6ff 100644
--- a/vendor/github.com/lawl/pulseaudio/README.md
+++ b/vendor/github.com/lawl/pulseaudio/README.md
@@ -1,4 +1,4 @@
-# pulseaudio
+# pulseaudio [![GoDoc](https://godoc.org/github.com/lawl/pulseaudio?status.svg)](https://godoc.org/github.com/lawl/pulseaudio)
Package pulseaudio is a pure-Go (no libpulse) implementation of the PulseAudio native protocol.
Download:
@@ -12,4 +12,6 @@ Package pulseaudio is a pure-Go (no libpulse) implementation of the PulseAudio n
This library is a fork of https://github.com/mafik/pulseaudio
The original library deliberately tries to hide pulseaudio internals and doesn't expose them.
-For my usecase I needed the exact opposite, access to pulseaudio internals. \ No newline at end of file
+For my usecase I needed the exact opposite, access to pulseaudio internals.
+I will most likely only maintain this as far as is required for [noisetorch](https://github.com/lawl/NoiseTorch) to work.
+Pull Requests are however welcome.
diff --git a/vendor/github.com/lawl/pulseaudio/client.go b/vendor/github.com/lawl/pulseaudio/client.go
index 6740182..ab8c347 100644
--- a/vendor/github.com/lawl/pulseaudio/client.go
+++ b/vendor/github.com/lawl/pulseaudio/client.go
@@ -1,24 +1,12 @@
// Package pulseaudio is a pure-Go (no libpulse) implementation of the PulseAudio native protocol.
//
-// Rather than exposing the PulseAudio protocol directly this library attempts to hide
-// the PulseAudio complexity behind a Go interface.
-// Some of the things which are deliberately not exposed in the API are:
-//
-// → backwards compatibility for old PulseAudio servers
-//
-// → transport mechanism used for the connection (Unix sockets / memfd / shm)
-//
-// → encoding used in the pulseaudio-native protocol
-//
-// Working features
-//
-// Querying and setting the volume.
-//
-// Listing audio outputs.
-//
-// Changing the default audio output.
-//
-// Notifications on config updates.
+// Package pulseaudio is a pure-Go (no libpulse) implementation of the PulseAudio native protocol.
+
+// This library is a fork of https://github.com/mafik/pulseaudio
+// The original library deliberately tries to hide pulseaudio internals and doesn't expose them.
+
+// For my usecase I needed the exact opposite, access to pulseaudio internals.
+
package pulseaudio
import (
@@ -27,10 +15,12 @@ import (
"fmt"
"io"
"io/ioutil"
+ "log"
"net"
"os"
"os/user"
"path"
+ "path/filepath"
)
const version = 32
@@ -67,7 +57,7 @@ type Client struct {
// NewClient establishes a connection to the PulseAudio server.
func NewClient(addressArr ...string) (*Client, error) {
if len(addressArr) < 1 {
- addressArr = []string{defaultAddr}
+ addressArr = []string{filepath.Join(xdgOrFallback("XDG_RUNTIME_DIR", fmt.Sprintf("/run/user/%d", os.Getuid())), "pulse/native")}
}
conn, err := net.Dial("unix", addressArr[0])
@@ -264,7 +254,7 @@ func (c *Client) addPacket(data packet) (err error) {
func (c *Client) auth() error {
const protocolVersionMask = 0x0000FFFF
- cookiePath := os.Getenv("HOME") + "/.config/pulse/cookie"
+ cookiePath := filepath.Join(xdgOrFallback("XDG_CONFIG_HOME", filepath.Join(os.Getenv("HOME"), "/.config")), "pulse/cookie")
cookie, err := ioutil.ReadFile(cookiePath)
if err != nil {
return err
@@ -324,3 +314,28 @@ func (c *Client) Close() {
close(c.packets)
c.conn.Close()
}
+
+func exists(path string) (bool, error) {
+ _, err := os.Stat(path)
+ if err == nil {
+ return true, nil
+ }
+ if os.IsNotExist(err) {
+ return false, nil
+ }
+ return false, err
+}
+
+func xdgOrFallback(xdg string, fallback string) string {
+ dir := os.Getenv(xdg)
+ if dir != "" {
+ if ok, err := exists(dir); ok && err == nil {
+ log.Printf("Resolved $%s to '%s'\n", xdg, dir)
+ return dir
+ }
+
+ }
+
+ log.Printf("Couldn't resolve $%s falling back to '%s'\n", xdg, fallback)
+ return fallback
+}
diff --git a/vendor/modules.txt b/vendor/modules.txt
index c785aeb..4dc3e93 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -62,7 +62,7 @@ github.com/golang/freetype/truetype
# github.com/hashicorp/golang-lru v0.0.0-20160813221303-0a025b7e63ad
github.com/hashicorp/golang-lru
github.com/hashicorp/golang-lru/simplelru
-# github.com/lawl/pulseaudio v0.0.0-20200704145757-7d4b4b92e7b7
+# github.com/lawl/pulseaudio v0.0.0-20200719094555-c019d8a2304f
## explicit
github.com/lawl/pulseaudio
# golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899