Skip to content

Commit 71a81d5

Browse files
committed
simplify check of --raw need for pipewire.
1 parent b7f51af commit 71a81d5

File tree

1 file changed

+6
-36
lines changed

1 file changed

+6
-36
lines changed

input/pipewire/pipewire.go

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"log"
1010
"os"
1111
"os/exec"
12-
"strconv"
1312
"strings"
1413
"sync"
1514
"sync/atomic"
@@ -311,51 +310,22 @@ func shortEpoch() string {
311310
return base64.RawURLEncoding.EncodeToString(buf[:])
312311
}
313312

314-
func getPipewireVersion() (string, error) {
315-
cmd := exec.Command("pw-cat", "--version")
313+
func checkNeedRawArg() (bool, error) {
314+
cmd := exec.Command("pw-cat", "--help")
316315

317316
out, err := cmd.Output()
318317

319318
if err != nil {
320-
return "", err
319+
return false, err
321320
}
322321

323322
lines := strings.Split(string(out), "\n")
324323

325324
for _, line := range lines {
326-
if version, ok := strings.CutPrefix(line, "Compiled with libpipewire "); ok {
327-
return version, nil
328-
}
329-
}
330-
331-
return "unknown", nil
332-
}
333-
334-
func checkNeedRawArg() (bool, error) {
335-
versionCheck := []int{1, 4, 0}
336-
337-
version, err := getPipewireVersion()
338-
if err != nil {
339-
return false, errors.Wrap(err, "failed to get pipewire version")
340-
}
341-
342-
// only need the first three parts. the last bin can contain waste
343-
versionSplit := strings.SplitN(version, ".", 4)
344-
345-
if len(versionSplit) < len(versionCheck) {
346-
return false, errors.New("bad version string length")
347-
}
348-
349-
for i := range versionCheck {
350-
num, err := strconv.Atoi(versionSplit[i])
351-
if err != nil {
352-
return false, err
353-
}
354-
355-
if num < versionCheck[i] {
356-
return false, nil
325+
if strings.Contains(line, "--raw") {
326+
return true, nil
357327
}
358328
}
359329

360-
return true, nil
330+
return false, nil
361331
}

0 commit comments

Comments
 (0)