1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-11-22 16:45:58 +01:00

Warn when writing to disk fails.

This commit is contained in:
Juliusz Chroboczek 2020-12-23 21:51:25 +01:00
parent d9dbb50bf5
commit 6969ae7d68

View file

@ -5,6 +5,7 @@ import (
"encoding/hex" "encoding/hex"
"errors" "errors"
"fmt" "fmt"
"log"
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
@ -112,6 +113,7 @@ func (client *Client) PushConn(g *group.Group, id string, up conn.Up, tracks []c
directory := filepath.Join(Directory, client.group.Name()) directory := filepath.Join(Directory, client.group.Name())
err := os.MkdirAll(directory, 0700) err := os.MkdirAll(directory, 0700)
if err != nil { if err != nil {
g.WallOps("Write to disk: " + err.Error())
return err return err
} }
@ -121,6 +123,7 @@ func (client *Client) PushConn(g *group.Group, id string, up conn.Up, tracks []c
down, err := newDiskConn(client, directory, label, up, tracks) down, err := newDiskConn(client, directory, label, up, tracks)
if err != nil { if err != nil {
g.WallOps("Write to disk: " + err.Error())
return err return err
} }
@ -139,6 +142,18 @@ type diskConn struct {
remote conn.Up remote conn.Up
tracks []*diskTrack tracks []*diskTrack
width, height uint32 width, height uint32
lastWarning time.Time
}
// called locked
func (conn *diskConn) warn(message string) {
now := time.Now()
if now.Sub(conn.lastWarning) < 10*time.Second {
return
}
log.Println(message)
conn.client.group.WallOps(message)
conn.lastWarning = now
} }
// called locked // called locked
@ -325,6 +340,9 @@ func (t *diskTrack) WriteRTP(packet *rtp.Packet) error {
if keyframe { if keyframe {
err := t.initWriter(sample.Data) err := t.initWriter(sample.Data)
if err != nil { if err != nil {
t.conn.warn(
"Write to disk " + err.Error(),
)
return err return err
} }
t.lastKf = ts t.lastKf = ts
@ -341,6 +359,10 @@ func (t *diskTrack) WriteRTP(packet *rtp.Packet) error {
if !t.conn.hasVideo { if !t.conn.hasVideo {
err := t.conn.initWriter(0, 0) err := t.conn.initWriter(0, 0)
if err != nil { if err != nil {
t.conn.warn(
"Write to disk " +
err.Error(),
)
return err return err
} }
} }