Skip to content

Commit bed6387

Browse files
committed
streamd: make gmainloop blocking
1 parent a3c0719 commit bed6387

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

streamd/main.go

+6-12
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"os"
88
"os/signal"
99
"sync"
10-
"time"
1110

1211
"github.com/go-gst/go-glib/glib"
1312
"github.com/go-gst/go-gst/gst"
@@ -167,15 +166,10 @@ func main() {
167166
// floating around and move outside runPipeline
168167
go d.metricsProcess(ctx)
169168

170-
// bridge the mainloop with our go context
171-
for {
172-
select {
173-
case <-ctx.Done():
174-
return
175-
default:
176-
// this is essentially what g_main_loop_run does with some locking overhead
177-
d.mainloop.GetContext().Iteration(false)
178-
time.Sleep(time.Millisecond * 50)
179-
}
180-
}
169+
go func() {
170+
<-ctx.Done() // Wait until the context is cancelled
171+
// When the context is cancelled, break out of the main loop
172+
d.mainloop.Quit()
173+
}()
174+
d.mainloop.Run()
181175
}

0 commit comments

Comments
 (0)