allow player startup without feeds

This commit is contained in:
Dmitry Sergeev
2026-08-27 23:45:46 +03:00
parent 743e1680c1
commit 0c4bacb798
2 changed files with 17 additions and 13 deletions
+16 -12
View File
@@ -59,7 +59,7 @@ type appArgs struct {
func printCliHelp(fs *pflag.FlagSet) { func printCliHelp(fs *pflag.FlagSet) {
fmt.Printf("%s %s\n", APP_NAME, APP_VER) fmt.Printf("%s %s\n", APP_NAME, APP_VER)
fmt.Println("Usage: mxl-player -d <domain> (-v <uuid> | -a <uuid>) [--max-attempts <count>] [-f] [-h]") fmt.Println("Usage: mxl-player [-d <domain>] [-v <uuid>] [-a <uuid>] [options]")
fmt.Println(" [-g <gpu-id>] [-p <playback-id>] [--verbose]") fmt.Println(" [-g <gpu-id>] [-p <playback-id>] [--verbose]")
fmt.Println(" or: mxl-player [--list-playback] [--list-gpu]") fmt.Println(" or: mxl-player [--list-playback] [--list-gpu]")
fmt.Println(" or: mxl-player (and set everything in GUI)") fmt.Println(" or: mxl-player (and set everything in GUI)")
@@ -68,13 +68,20 @@ func printCliHelp(fs *pflag.FlagSet) {
} }
func printUsage(w io.Writer) { func printUsage(w io.Writer) {
fmt.Fprintln(w, "Usage: mxl-player -d <domain> (-v <uuid> | -a <uuid>) [-f] [-h]") fmt.Fprintln(w, "Usage: mxl-player [-d <domain>] [-v <uuid>] [-a <uuid>] [options]")
fmt.Fprintln(w, "Try 'mxl-player -h' for more information.") fmt.Fprintln(w, "Try 'mxl-player -h' for more information.")
} }
func checkMXLargs(args appArgs) { func checkMXLargs(args appArgs) {
if args.VideoFlowId == "" && args.AudioFlowId == "" {
return
}
if args.Domain == "" { if args.Domain == "" {
fmt.Fprintln(os.Stderr, "You should provide valid MXL domain and UUID of at least one flow") fmt.Fprintln(
os.Stderr,
"You must provide a domain when a feed UUID is configured",
)
printUsage(os.Stderr) printUsage(os.Stderr)
os.Exit(2) os.Exit(2)
} }
@@ -86,11 +93,6 @@ func checkMXLargs(args appArgs) {
printUsage(os.Stderr) printUsage(os.Stderr)
os.Exit(2) os.Exit(2)
} }
if args.VideoFlowId == "" && args.AudioFlowId == "" {
fmt.Fprintln(os.Stderr, "You must provide at least 1 MXL flow UUID")
printUsage(os.Stderr)
os.Exit(2)
}
} }
func main() { func main() {
@@ -146,7 +148,7 @@ func main() {
checkMXLargs(args) checkMXLargs(args)
} }
// path selection // path selection
useVideoSlot := args.VideoFlowId != "" && args.AudioFlowId == "" useVideoSlot := args.AudioFlowId == ""
runtime.LockOSThread() runtime.LockOSThread()
if err := sdl.Load(); err != nil { if err := sdl.Load(); err != nil {
@@ -300,7 +302,7 @@ func main() {
syncSrc.Width(), syncSrc.Height(), aChans, audioBatch) syncSrc.Width(), syncSrc.Height(), aChans, audioBatch)
case args.VideoFlowId != "": case args.VideoFlowId != "":
// VideoSlot owns opening and closing the video reader. // VideoSlot owns opening and closing the video reader.
default: case args.AudioFlowId != "":
audioSrc, err = source.OpenAudio(args.Domain, args.AudioFlowId) audioSrc, err = source.OpenAudio(args.Domain, args.AudioFlowId)
if err != nil { if err != nil {
log.Fatalf("audio source: %v", err) log.Fatalf("audio source: %v", err)
@@ -320,6 +322,8 @@ func main() {
} }
sdl.ResumeAudioStreamDevice(audioStream) sdl.ResumeAudioStreamDevice(audioStream)
fmt.Printf("audio: %dch %d/%d Hz\n", aChans, audioSrc.Rate().Num, audioSrc.Rate().Den) fmt.Printf("audio: %dch %d/%d Hz\n", aChans, audioSrc.Rate().Num, audioSrc.Rate().Den)
default:
// No configured feeds. Renderer and GUI use the placeholder.
} }
defer func() { defer func() {
@@ -385,7 +389,7 @@ func main() {
audioStr string = args.AudioFlowId audioStr string = args.AudioFlowId
showStats bool = true showStats bool = true
) )
videoActive := useVideoSlot videoActive := args.VideoFlowId != ""
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
defer cancel() defer cancel()
@@ -529,7 +533,7 @@ func main() {
playback.FeedConfig{ playback.FeedConfig{
Domain: args.Domain, Domain: args.Domain,
UUID: args.VideoFlowId, UUID: args.VideoFlowId,
Active: true, Active: args.VideoFlowId != "",
}, },
videoCommands, videoCommands,
) )
+1 -1
View File
@@ -14,7 +14,7 @@ Size=200,200
Collapsed=0 Collapsed=0
[Window][Connection] [Window][Connection]
Pos=202,343 Pos=74,351
Size=799,226 Size=799,226
Collapsed=0 Collapsed=0