jfreymuth/pulse

Cannot use RawRequest with GetPlaybackLatency

Closed this issue · 3 comments

Doing this:

latRequest := proto.GetPlaybackLatency{
        StreamIndex: stream.StreamIndex(),
        Time:        proto.Time{0, 0},
}
var latReply proto.GetPlaybackLatencyReply
pc.RawRequest(&latRequest, &latReply)

Fails like this:

panic: reflect: reflect.flag.mustBeAssignable using value obtained using unexported field

goroutine 7 [running]:
reflect.flag.mustBeAssignableSlow(0x1ab)
        /usr/lib/go-1.13/src/reflect/value.go:244 +0x1b9
reflect.flag.mustBeAssignable(...)
        /usr/lib/go-1.13/src/reflect/value.go:234
reflect.Value.SetUint(0x53d580, 0xc00022e008, 0x1ab, 0x0)
        /usr/lib/go-1.13/src/reflect/value.go:1685 +0x3b
github.com/jfreymuth/pulse/proto.(*ProtocolReader).value(0xc0000a60c0, 0x549d40, 0xc00022e000, 0xc000000020)
        /home/andrew/go/pkg/mod/github.com/jfreymuth/pulse@v0.0.0-20200423184951-8c039b863e8e/proto/reader.go:249 +0xd2e
github.com/jfreymuth/pulse/proto.(*Client).readLoop(0xc0000a60c0)
        /home/andrew/go/pkg/mod/github.com/jfreymuth/pulse@v0.0.0-20200423184951-8c039b863e8e/proto/client.go:138 +0x448
created by github.com/jfreymuth/pulse/proto.(*Client).Open
        /home/andrew/go/pkg/mod/github.com/jfreymuth/pulse@v0.0.0-20200423184951-8c039b863e8e/proto/client.go:49 +0x163

I think that this is because of the _ field in GetPlaybackLatencyReply. Perhaps (*ProtocolReader).value should have

if !f.CanSet() {
    continue
}

Nope, that's not the right fix, because it would fail to read the data from the packet.

I pushed before testing, should be fixed now

Looks good, thanks