summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2024-12-08 19:56:52 +0100
committerxengineering <me@xengineering.eu>2024-12-15 13:00:13 +0100
commit04ed13ca73442d90a15d1b0b3816ed5ee8f130d8 (patch)
tree401bd5adfc53b43c96b66dd5c483bf3b351a17e8 /main.go
parent9fe390db8e63603a7bfb2e0c7cd77386cc6247ff (diff)
downloadsoundbox-app-04ed13ca73442d90a15d1b0b3816ed5ee8f130d8.tar
soundbox-app-04ed13ca73442d90a15d1b0b3816ed5ee8f130d8.tar.zst
soundbox-app-04ed13ca73442d90a15d1b0b3816ed5ee8f130d8.zip
Add experimental streaming with PipeWire
This allows to stream sound from a Linux PC with PipeWire sound system to soundboxes. Currently PipeWire capture nodes are used. They should be connected to the monitor output of the default sound sink manually.
Diffstat (limited to 'main.go')
-rw-r--r--main.go18
1 files changed, 13 insertions, 5 deletions
diff --git a/main.go b/main.go
index 060f76c..658f76b 100644
--- a/main.go
+++ b/main.go
@@ -42,7 +42,7 @@ type State struct {
Theme *material.Theme
IsPlaying bool
Title string
- UrlSelector widget.Enum
+ SourceSelector widget.Enum
PlayPauseButton widget.Clickable
PlayerContext context.Context
PlayerCancel context.CancelFunc
@@ -105,7 +105,7 @@ func (ui *Ui) HandleInputs(gtx layout.Context) {
if ui.State.IsPlaying {
ui.State.PlayerCancel()
} else {
- if ui.State.UrlSelector.Value == "" {
+ if ui.State.SourceSelector.Value == "" {
log.Println("A URL has to be selected.")
} else {
ui.State.PlayerContext, ui.State.PlayerCancel = context.WithCancel(context.Background())
@@ -115,7 +115,7 @@ func (ui *Ui) HandleInputs(gtx layout.Context) {
targets = append(targets, net.HardwareAddr(entry.Mac))
}
}
- go play(ui.State.PlayerContext, ui.State.UrlSelector.Value, targets, ui)
+ go play(ui.State.PlayerContext, ui.State.SourceSelector.Value, targets, ui)
}
}
}
@@ -149,9 +149,12 @@ func (ui *Ui) Layout(gtx layout.Context) layout.Dimensions {
layout.Rigid(layout.Spacer{Height: unit.Dp(25)}.Layout),
}
+ entries = append(entries, layout.Rigid(material.RadioButton(
+ ui.State.Theme, &ui.State.SourceSelector,
+ "PipeWire", "This device (experimental)").Layout))
for _, url := range ui.State.Config.URLs {
entries = append(entries, layout.Rigid(material.RadioButton(
- ui.State.Theme, &ui.State.UrlSelector,
+ ui.State.Theme, &ui.State.SourceSelector,
url.Url, url.Name).Layout))
}
@@ -174,7 +177,12 @@ func play(ctx context.Context, url string, targets []net.HardwareAddr, ui *Ui) {
setPlayingState(true)
defer setPlayingState(false)
- err := soundbox.StreamURLContext(ctx, url, targets)
+ var err error
+ if url == "PipeWire" {
+ err = soundbox.StreamPipewireContext(ctx, targets)
+ } else {
+ err = soundbox.StreamURLContext(ctx, url, targets)
+ }
if err != nil {
log.Println(err)
}