Skip to content

Commit

Permalink
streamd: make gmainloop blocking
Browse files Browse the repository at this point in the history
  • Loading branch information
hmelder committed Dec 5, 2024
1 parent a3c0719 commit bed6387
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions streamd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"os"
"os/signal"
"sync"
"time"

"github.com/go-gst/go-glib/glib"
"github.com/go-gst/go-gst/gst"
Expand Down Expand Up @@ -167,15 +166,10 @@ func main() {
// floating around and move outside runPipeline
go d.metricsProcess(ctx)

// bridge the mainloop with our go context
for {
select {
case <-ctx.Done():
return
default:
// this is essentially what g_main_loop_run does with some locking overhead
d.mainloop.GetContext().Iteration(false)
time.Sleep(time.Millisecond * 50)
}
}
go func() {
<-ctx.Done() // Wait until the context is cancelled
// When the context is cancelled, break out of the main loop
d.mainloop.Quit()
}()
d.mainloop.Run()
}

0 comments on commit bed6387

Please sign in to comment.