Refactoring #3
+16
-12
@@ -59,7 +59,7 @@ type appArgs struct {
|
||||
|
||||
func printCliHelp(fs *pflag.FlagSet) {
|
||||
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(" or: mxl-player [--list-playback] [--list-gpu]")
|
||||
fmt.Println(" or: mxl-player (and set everything in GUI)")
|
||||
@@ -68,13 +68,20 @@ func printCliHelp(fs *pflag.FlagSet) {
|
||||
}
|
||||
|
||||
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.")
|
||||
}
|
||||
|
||||
func checkMXLargs(args appArgs) {
|
||||
if args.VideoFlowId == "" && args.AudioFlowId == "" {
|
||||
return
|
||||
}
|
||||
|
||||
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)
|
||||
os.Exit(2)
|
||||
}
|
||||
@@ -86,11 +93,6 @@ func checkMXLargs(args appArgs) {
|
||||
printUsage(os.Stderr)
|
||||
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() {
|
||||
@@ -146,7 +148,7 @@ func main() {
|
||||
checkMXLargs(args)
|
||||
}
|
||||
// path selection
|
||||
useVideoSlot := args.VideoFlowId != "" && args.AudioFlowId == ""
|
||||
useVideoSlot := args.AudioFlowId == ""
|
||||
|
||||
runtime.LockOSThread()
|
||||
if err := sdl.Load(); err != nil {
|
||||
@@ -300,7 +302,7 @@ func main() {
|
||||
syncSrc.Width(), syncSrc.Height(), aChans, audioBatch)
|
||||
case args.VideoFlowId != "":
|
||||
// VideoSlot owns opening and closing the video reader.
|
||||
default:
|
||||
case args.AudioFlowId != "":
|
||||
audioSrc, err = source.OpenAudio(args.Domain, args.AudioFlowId)
|
||||
if err != nil {
|
||||
log.Fatalf("audio source: %v", err)
|
||||
@@ -320,6 +322,8 @@ func main() {
|
||||
}
|
||||
sdl.ResumeAudioStreamDevice(audioStream)
|
||||
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() {
|
||||
@@ -385,7 +389,7 @@ func main() {
|
||||
audioStr string = args.AudioFlowId
|
||||
showStats bool = true
|
||||
)
|
||||
videoActive := useVideoSlot
|
||||
videoActive := args.VideoFlowId != ""
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
@@ -529,7 +533,7 @@ func main() {
|
||||
playback.FeedConfig{
|
||||
Domain: args.Domain,
|
||||
UUID: args.VideoFlowId,
|
||||
Active: true,
|
||||
Active: args.VideoFlowId != "",
|
||||
},
|
||||
videoCommands,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user