diff --git a/internal/source/source.go b/internal/source/source.go index 4841877..28784d4 100644 --- a/internal/source/source.go +++ b/internal/source/source.go @@ -46,42 +46,59 @@ type Source struct { func Open(domain, flowID string) (*Source, error) { inst, err := mxl.NewInstance(domain, "") if err != nil { - return nil, fmt.Errorf("NewInstance: %w", err) + return nil, wrapError("new MXL instance", ErrorKindUnavailable, err) } r, err := inst.NewReader(flowID) if err != nil { inst.Close() - return nil, fmt.Errorf("NewReader: %w", err) + return nil, wrapError("open video reader", ErrorKindUnavailable, err) } info, err := r.Info() if err != nil { r.Close() inst.Close() - return nil, fmt.Errorf("Info: %w", err) + return nil, wrapError("get video info", ErrorKindUnavailable, err) } def, err := inst.FlowDef(flowID) if err != nil { r.Close() inst.Close() - return nil, fmt.Errorf("FlowDef: %w", err) + return nil, wrapError("read video flow definition", ErrorKindUnavailable, err) } var fd flowDef if err := json.Unmarshal([]byte(def), &fd); err != nil { r.Close() inst.Close() - return nil, fmt.Errorf("parse flow def: %w", err) + return nil, wrapError("parse flow definition JSON", ErrorKindInvalidConfig, err) } if fd.FrameWidth == 0 || fd.FrameHeight == 0 { r.Close() inst.Close() - return nil, fmt.Errorf("flow has no video dimensions (not a video flow?)") + return nil, wrapError( + "validate video flow", + ErrorKindInvalidConfig, + errors.New("flow has no video dimensions"), + ) } rate := info.Config.Common.GrainRate idx := mxl.CurrentIndex(rate) if idx == mxl.UndefinedIndex { r.Close() inst.Close() - return nil, fmt.Errorf("invalid grain rate: %d/%d", rate.Num, rate.Den) + return nil, wrapError( + "validate video flow", + ErrorKindInvalidConfig, + fmt.Errorf("invalid grain rate: %d/%d", rate.Num, rate.Den), + ) + } + if len(info.Config.Discrete.SliceSizes) == 0 { + r.Close() + inst.Close() + return nil, wrapError( + "validate video flow", + ErrorKindInvalidConfig, + errors.New("video flow has no slice sizes"), + ) } return &Source{ inst: inst, diff --git a/mxl-player b/mxl-player index 90c2687..6ebe0ba 100755 Binary files a/mxl-player and b/mxl-player differ