media.NewMediaPlayer1 panics
Vladius25 opened this issue · comments
Vladislav Kazakov commented
The next line of code leads to panic:
player, err := media.NewMediaPlayer1(playerPath)
Part of stacktrace:
panic: reflect: Elem of invalid type media.Track
goroutine 1 [running]:
reflect.(*rtype).Elem(0x559ca0?)
/usr/lib/golang/src/reflect/type.go:972 +0x134
github.com/muka/go-bluetooth/util.mapStructField({0x5460c0, 0xc0001b6780}, {0xc00001c82a, 0x5}, {{{0xc00001cac0?, 0x510433?}}, {0x53a800?, 0xc000079020?}})
/home/vladius/go/pkg/mod/github.com/muka/go-bluetooth@v0.0.0-20220830075246-0746e3a1ea53/util/map_struct.go:92 +0x388
github.com/muka/go-bluetooth/util.MapToStruct({0x5460c0, 0xc0001b6780}, 0x26?)
/home/vladius/go/pkg/mod/github.com/muka/go-bluetooth@v0.0.0-20220830075246-0746e3a1ea53/util/map_struct.go:128 +0xad
github.com/muka/go-bluetooth/bluez.(*Client).GetProperties(0xc0001d8c40, {0x5460c0, 0xc0001b6780})
/home/vladius/go/pkg/mod/github.com/muka/go-bluetooth@v0.0.0-20220830075246-0746e3a1ea53/bluez/client.go:119 +0x21d
github.com/muka/go-bluetooth/bluez/profile/media.(*MediaPlayer1).GetProperties(0xc0001cd200)
The actual problem locates on line 92:
go-bluetooth/util/map_struct.go
Lines 90 to 93 in 0746e3a
The reason is Elem()
doesn't support structs and causes panic during processing field Track
(type media.Track
) of media.MediaPlayer1Properties
.
Luca Capra commented
Thank you, merged your PR let me know if this still happens