Restore mutex for MP4
This commit is contained in:
+7
-1
@@ -4,6 +4,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/AlexxIT/go2rtc/cmd/api"
|
"github.com/AlexxIT/go2rtc/cmd/api"
|
||||||
@@ -108,9 +109,14 @@ func handlerMP4(w http.ResponseWriter, r *http.Request) {
|
|||||||
Medias: core.ParseQuery(r.URL.Query()),
|
Medias: core.ParseQuery(r.URL.Query()),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var mu sync.Mutex
|
||||||
cons.Listen(func(msg any) {
|
cons.Listen(func(msg any) {
|
||||||
if data, ok := msg.([]byte); ok {
|
if data, ok := msg.([]byte); ok {
|
||||||
if _, err := w.Write(data); err != nil && exit != nil {
|
mu.Lock()
|
||||||
|
_, err := w.Write(data)
|
||||||
|
mu.Unlock()
|
||||||
|
|
||||||
|
if err != nil && exit != nil {
|
||||||
select {
|
select {
|
||||||
case exit <- err:
|
case exit <- err:
|
||||||
default:
|
default:
|
||||||
|
|||||||
Reference in New Issue
Block a user