Skip to content

Panic in xv.QueryAdaptors #9

@gen2brain

Description

@gen2brain

I am trying to use the XVideo extension, and the input I am getting is an image.YCbCr, so being able to directly copy YUV planes and use xv.ShmPutImage would be really nice, and I guess I could also use hardware scaling then.

I am getting panic when I query for adaptors:

panic: runtime error: slice bounds out of range [5388:45]

goroutine 1 [running]:
github.com/jezek/xgb/xv.AdaptorInfoRead({0xc0000b204b, 0x2d, 0x2d}, 0xc0000b4038)
	github.com/jezek/xgb@v1.0.1/xv/xv.go:83 +0x294
github.com/jezek/xgb/xv.AdaptorInfoReadList({0xc0000b2020, 0x58, 0x58}, {0xc0000b4000, 0x2, 0xc00018c060?})
	github.com/jezek/xgb@v1.0.1/xv/xv.go:93 +0x5d
github.com/jezek/xgb/xv.queryAdaptorsReply({0xc0000b2000, 0x78, 0x78})
	github.com/jezek/xgb@v1.0.1/xv/xv.go:2033 +0x1a8
github.com/jezek/xgb/xv.QueryAdaptorsCookie.Reply({0xc000122000?})
	github.com/jezek/xgb@v1.0.1/xv/xv.go:2011 +0x65
main.main()
	example/main.go:54 +0x471

Here is a simple example, Init and QueryExtension are successful. I tried to query before and after the window is mapped, but it makes no difference.

package main

import (
	"fmt"
	"os"

	"github.com/jezek/xgb"
	"github.com/jezek/xgb/xproto"
	"github.com/jezek/xgb/xv"
)

func main() {
	X, err := xgb.NewConn()
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
	defer X.Close()

	useXv := true
	err = xv.Init(X)
	if err != nil {
		useXv = false
	}
	fmt.Println(useXv)

	setup := xproto.Setup(X)
	screen := setup.DefaultScreen(X)

	r, err := xv.QueryExtension(X).Reply()
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
	fmt.Println(r.Major, r.Minor)

	window, err := xproto.NewWindowId(X)
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	xproto.CreateWindow(X, screen.RootDepth, window, screen.Root, 0, 0, 640, 480, 1,
		xproto.WindowClassInputOutput, screen.RootVisual,
		xproto.CwBackPixmap|xproto.CwBackPixel|xproto.CwEventMask,
		[]uint32{
			xproto.BackPixmapParentRelative,
			screen.BlackPixel,
			xproto.EventMaskKeyPress | xproto.EventMaskExposure | xproto.EventMaskStructureNotify,
		},
	)
	defer xproto.DestroyWindow(X, window)

	reply, err := xv.QueryAdaptors(X, window).Reply()
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
	fmt.Println(reply.NumAdaptors)

	xproto.MapWindow(X, window)

	for {
		X.WaitForEvent()
	}
}


Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions