op / go-libspotify Goto Github PK
View Code? Open in Web Editor NEWLanguage bindings for libspotify in Go (Golang)
License: Apache License 2.0
Language bindings for libspotify in Go (Golang)
License: Apache License 2.0
Go 1.6 cgo has new rules about passing pointers.
https://github.com/golang/proposal/blob/master/design/12416-cgo-pointers.md
When compiling go-libspotify with 1.6 I'm getting this error:
panic: runtime error: cgo argument has Go pointer to Go pointer
Triggered by this line https://github.com/op/go-libspotify/blob/master/spotify/libspotify.go#L238
err := spError(C.sp_session_create(&session.config, &session.sp_session))
Just to register as I didn't have too much time to looking into this yet.
Hi,
The library throws a panic when playlist is not PlaylistTypePlaylist
or PlaylistTypePlaceholder
.
https://github.com/op/go-libspotify/blob/master/spotify/libspotify.go#L1411
So it doesn't support PlaylistTypeStartFolder
/PlaylistTypeEndFolder
.
Is that designed or was just not investigated enough in how process PlaylistTypeStartFolder
/PlaylistTypeEndFolder
?
My issue if you want to look at it: fabiofalci/sconsify#5
I'm encountering the following error when requesting any toplist with my own code and with the gospshell example:
waiting for toplist 0xc2080238c0
panic: spotify: unhandled toplist type
goroutine 20 [running]:
runtime.panic(0x6bd500, 0xc208000f20)
/usr/lib/go/src/pkg/runtime/panic.c:279 +0xf5
github.com/op/go-libspotify/spotify.go_toplistbrowse_complete(0x7fe424000de0, 0xc20803a0d0)
/.../_vendor/src/github.com/op/go-libspotify/spotify/libspotify.go:1164 +0xa5
github.com/op/go-libspotify/spotify._Cfunc_sp_session_process_events(0x7fe43400b030, 0xc208000ee8, 0x7fe43ad59ec0)
github.com/op/go-libspotify/spotify/_obj/_cgo_defun.c:1016 +0x31
github.com/op/go-libspotify/spotify.(*Session).processEvents(0xc208042640)
/.../_vendor/src/github.com/op/go-libspotify/spotify/libspotify.go:799 +0xdf
github.com/op/go-libspotify/spotify.func·001()
/.../_vendor/src/github.com/op/go-libspotify/spotify/libspotify.go:218 +0x134
created by github.com/op/go-libspotify/spotify.NewSession
/.../_vendor/src/github.com/op/go-libspotify/spotify/libspotify.go:219 +0x2da
goroutine 16 [IO wait]:
net.runtime_pollWait(0x7fe43aee9818, 0x72, 0x0)
/usr/lib/go/src/pkg/runtime/netpoll.goc:146 +0x66
net.(*pollDesc).Wait(0xc208028450, 0x72, 0x0, 0x0)
/usr/lib/go/src/pkg/net/fd_poll_runtime.go:84 +0x46
net.(*pollDesc).WaitRead(0xc208028450, 0x0, 0x0)
/usr/lib/go/src/pkg/net/fd_poll_runtime.go:89 +0x42
net.(*netFD).accept(0xc2080283f0, 0x85cb18, 0x0, 0x7fe43aee8400, 0xb)
/usr/lib/go/src/pkg/net/fd_unix.go:409 +0x343
net.(*TCPListener).AcceptTCP(0xc20803a020, 0x4d2343, 0x0, 0x0)
/usr/lib/go/src/pkg/net/tcpsock_posix.go:234 +0x5d
net/http.tcpKeepAliveListener.Accept(0xc20803a020, 0x0, 0x0, 0x0, 0x0)
/usr/lib/go/src/pkg/net/http/server.go:1947 +0x4b
net/http.(*Server).Serve(0xc2080041e0, 0x7fe43aee9a80, 0xc20803a020, 0x0, 0x0)
/usr/lib/go/src/pkg/net/http/server.go:1698 +0x91
net/http.(*Server).ListenAndServe(0xc2080041e0, 0x0, 0x0)
/usr/lib/go/src/pkg/net/http/server.go:1688 +0x14d
net/http.ListenAndServe(0xc208000a40, 0x6, 0x0, 0x0, 0x0, 0x0)
/usr/lib/go/src/pkg/net/http/server.go:1778 +0x79
main.main()
/.../main.go:72 +0xe82
goroutine 19 [finalizer wait]:
runtime.park(0x421c70, 0xba6510, 0xb92ce9)
/usr/lib/go/src/pkg/runtime/proc.c:1369 +0x89
runtime.parkunlock(0xba6510, 0xb92ce9)
/usr/lib/go/src/pkg/runtime/proc.c:1385 +0x3b
runfinq()
/usr/lib/go/src/pkg/runtime/mgc0.c:2644 +0xcf
runtime.goexit()
/usr/lib/go/src/pkg/runtime/proc.c:1445
goroutine 17 [syscall]:
runtime.cgocallbackg()
/usr/lib/go/src/pkg/runtime/cgocall.c:244 +0x4c
runtime.cgocallback_gofunc(0x0, 0x0, 0x0)
/usr/lib/go/src/pkg/runtime/asm_amd64.s:785 +0x67
runtime.goexit()
/usr/lib/go/src/pkg/runtime/proc.c:1445
goroutine 22 [select]:
github.com/op/go-libspotify/spotify.(*Session).processBackground(0xc208042640)
/.../_vendor/src/github.com/op/go-libspotify/spotify/libspotify.go:822 +0x25f
created by github.com/op/go-libspotify/spotify.NewSession
/.../_vendor/src/github.com/op/go-libspotify/spotify/libspotify.go:225 +0x363
goroutine 23 [select]:
main.ProcessSpotifyEvents()
/.../spotify.go:55 +0x593
created by main.main
/.../main.go:41 +0x5be
goroutine 24 [sleep]:
time.Sleep(0x3b9aca00)
/usr/lib/go/src/pkg/runtime/time.goc:39 +0x31
main.(*Broadcaster).Run(0xc2080227e0)
/.../broadcaster.go:46 +0x26
created by main.main
/.../main.go:59 +0xc3e
goroutine 25 [select]:
main.(*Hub).Run(0xba7ba0)
/.../hub.go:19 +0x601
created by main.main
/.../main.go:60 +0xc59
goroutine 18 [syscall]:
runtime.goexit()
/usr/lib/go/src/pkg/runtime/proc.c:1445
goroutine 26 [IO wait]:
net.runtime_pollWait(0x7fe43aee9768, 0x72, 0x0)
/usr/lib/go/src/pkg/runtime/netpoll.goc:146 +0x66
net.(*pollDesc).Wait(0xc2080291e0, 0x72, 0x0, 0x0)
/usr/lib/go/src/pkg/net/fd_poll_runtime.go:84 +0x46
net.(*pollDesc).WaitRead(0xc2080291e0, 0x0, 0x0)
/usr/lib/go/src/pkg/net/fd_poll_runtime.go:89 +0x42
net.(*netFD).Read(0xc208029180, 0xc20800ec00, 0x400, 0x400, 0x0, 0x7fe43aee8400, 0xb)
/usr/lib/go/src/pkg/net/fd_unix.go:232 +0x34c
net.(*conn).Read(0xc20803a088, 0xc20800ec00, 0x400, 0x400, 0x0, 0x0, 0x0)
/usr/lib/go/src/pkg/net/net.go:122 +0xe7
bufio.(*Reader).fill(0xc208004840)
/usr/lib/go/src/pkg/bufio/bufio.go:97 +0x1b3
bufio.(*Reader).Read(0xc208004840, 0xc208000e88, 0x2, 0x8, 0x2, 0x0, 0x0)
/usr/lib/go/src/pkg/bufio/bufio.go:175 +0x230
github.com/gorilla/websocket.(*Conn).readFull(0xc208058000, 0xc208000e88, 0x2, 0x8, 0x0, 0x0)
/.../_vendor/src/github.com/gorilla/websocket/conn.go:524 +0xb0
github.com/gorilla/websocket.(*Conn).advanceFrame(0xc208058000, 0x26, 0x0, 0x0)
/.../_vendor/src/github.com/gorilla/websocket/conn.go:548 +0x166
github.com/gorilla/websocket.(*Conn).NextReader(0xc208058000, 0x85c9d0, 0x0, 0x0, 0x0, 0x0)
/.../_vendor/src/github.com/gorilla/websocket/conn.go:688 +0x77
github.com/gorilla/websocket.(*Conn).ReadMessage(0xc208058000, 0xc208000e60, 0x0, 0x0, 0x0, 0x0, 0x0)
/.../_vendor/src/github.com/gorilla/websocket/conn.go:751 +0x6e
main.(*Connection).ReadPump(0xc208000db0)
/.../connection.go:44 +0x180
main.HandleWebSocket(0x7fe43aee9cf8, 0xc20803c320, 0xc2080269c0)
/.../main.go:101 +0x3fe
net/http.HandlerFunc.ServeHTTP(0x85c9e8, 0x7fe43aee9cf8, 0xc20803c320, 0xc2080269c0)
/usr/lib/go/src/pkg/net/http/server.go:1235 +0x40
net/http.(*ServeMux).ServeHTTP(0xc208022bd0, 0x7fe43aee9cf8, 0xc20803c320, 0xc2080269c0)
/usr/lib/go/src/pkg/net/http/server.go:1511 +0x1a3
net/http.serverHandler.ServeHTTP(0xc2080041e0, 0x7fe43aee9cf8, 0xc20803c320, 0xc2080269c0)
/usr/lib/go/src/pkg/net/http/server.go:1673 +0x19f
net/http.(*conn).serve(0xc208048480)
/usr/lib/go/src/pkg/net/http/server.go:1174 +0xa7e
created by net/http.(*Server).Serve
/usr/lib/go/src/pkg/net/http/server.go:1721 +0x313
goroutine 27 [select]:
main.(*Connection).WritePump(0xc208000db0)
/.../connection.go:84 +0x2e5
created by main.HandleWebSocket
/.../main.go:100 +0x3ee
goroutine 28 [semacquire]:
sync.runtime_Semacquire(0xc208000f18)
/usr/lib/go/src/pkg/runtime/sema.goc:199 +0x30
sync.(*WaitGroup).Wait(0xc2080238d8)
/usr/lib/go/src/pkg/sync/waitgroup.go:129 +0x14b
github.com/op/go-libspotify/spotify.(*toplist).Wait(0xc2080238c0)
/.../_vendor/src/github.com/op/go-libspotify/spotify/libspotify.go:2401 +0x66
main.NewAlbumsToplistMessage(0xc208000e86, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0)
/.../messages.go:141 +0x185
main.HandleAlbumsToplist(0xc208000db0, 0xc208000e60, 0xe, 0x6b99e0, 0xc2080237a0)
/.../messages.go:222 +0x183
created by main.(*Connection).ReadPump
/.../connection.go:63 +0x43b
Are you guys interested in a silent mode?
Because I'm using the library but I'd like to hide any debug/error message coming from go-libspotify.
Please let met know if yes then I can create a PR.
Hi.
I'm getting "track artist index out of range" while using sconsify. Any ideas why? My username is the same as I use on Spotify, have a look at my playlists if that helps (they're public).
panic: spotify: track artist index out of range
goroutine 19 [running]:
github.com/fabiofalci/sconsify/vendor/github.com/op/go-libspotify/spotify.(*Track).Artist(0xc820398120, 0x0, 0x4e03518)
/Users/fabio/go/src/github.com/fabiofalci/sconsify/vendor/github.com/op/go-libspotify/spotify/libspotify.go:1901 +0xd3
github.com/fabiofalci/sconsify/sconsify.ToSconsifyTrack(0xc820398120, 0x10)
/Users/fabio/go/src/github.com/fabiofalci/sconsify/sconsify/track.go:48 +0x39
github.com/fabiofalci/sconsify/spotify.(*Spotify).initTrack(0xc820062850, 0xc82045d7c0, 0xc82045d7c0)
/Users/fabio/go/src/github.com/fabiofalci/sconsify/spotify/spotify_playlists.go:195 +0x216
github.com/fabiofalci/sconsify/spotify.(*Spotify).initPlaylist(0xc820062850, 0x0, 0x0)
/Users/fabio/go/src/github.com/fabiofalci/sconsify/spotify/spotify_playlists.go:52 +0x8d0
github.com/fabiofalci/sconsify/spotify.(*Spotify).finishInitialisation(0xc820062850, 0xc8200f64b0, 0xc82002e0e0, 0x0, 0x0)
/Users/fabio/go/src/github.com/fabiofalci/sconsify/spotify/spotify.go:162 +0x1c7
github.com/fabiofalci/sconsify/spotify.(*Spotify).checkIfLoggedIn(0xc820062850, 0xc8200f64b0, 0xc82002e0e0, 0x0, 0x0)
/Users/fabio/go/src/github.com/fabiofalci/sconsify/spotify/spotify.go:120 +0x121
github.com/fabiofalci/sconsify/spotify.initialiseSpotify(0xc8200f64b0, 0xc8200f04d0, 0xf, 0xc8200f0500, 0x8, 0x8, 0xc820104770, 0x0, 0x0)
/Users/fabio/go/src/github.com/fabiofalci/sconsify/spotify/spotify.go:60 +0x2af
github.com/fabiofalci/sconsify/spotify.Initialise(0xc8200f64b0, 0xc8200f04d0, 0xf, 0xc8200f0500, 0x8, 0x8, 0xc820104770)
/Users/fabio/go/src/github.com/fabiofalci/sconsify/spotify/spotify.go:39 +0x7e
created by main.main
/Users/fabio/go/src/github.com/fabiofalci/sconsify/sconsify.go:85 +0x10db
Well, firstly I want you to forgive me cause of opening an issue to ask you this question.
Is there any way of embedding libspotify inside a go binary?
Thank you and sorry for asking :(
Sometimes when waiting for a track track.Wait()
I get this panic:
...
playlistcontainer loaded
playlist container loaded
panic: sync: negative WaitGroup counter
goroutine 7 [running, locked to thread]:
sync.(*WaitGroup).Add(0xc2080384c0, 0xffffffffffffffff)
/usr/lib/go/src/sync/waitgroup.go:67 +0x96
sync.(*WaitGroup).Done(0xc2080384c0)
/usr/lib/go/src/sync/waitgroup.go:85 +0x31
github.com/op/go-libspotify/spotify.(*Track).cbUpdated(0xc2080384b0)
/home/fabio/go/src/github.com/op/go-libspotify/spotify/libspotify.go:1788 +0x4c
github.com/op/go-libspotify/spotify.(*Session).sendUpdates(0xc208092000, 0xc208092098, 0xc208038570)
/home/fabio/go/src/github.com/op/go-libspotify/spotify/libspotify.go:959 +0xb6
github.com/op/go-libspotify/spotify.(*Session).cbMetadataUpdated(0xc208092000)
/home/fabio/go/src/github.com/op/go-libspotify/spotify/libspotify.go:980 +0x4a
github.com/op/go-libspotify/spotify.sessionCall(0x7feea4079b70, 0x636848)
/home/fabio/go/src/github.com/op/go-libspotify/spotify/libspotify.go:185 +0x3b
github.com/op/go-libspotify/spotify.go_metadata_updated(0x7feea4079b70)
/home/fabio/go/src/github.com/op/go-libspotify/spotify/libspotify.go:1115 +0x34
github.com/op/go-libspotify/spotify._Cfunc_sp_session_process_events(0x7feea4079b70, 0xc208055e30, 0x0)
/home/fabio/go/src/github.com/op/go-libspotify/spotify/:905 +0x43
github.com/op/go-libspotify/spotify.(*Session).processEvents(0xc208092000)
/home/fabio/go/src/github.com/op/go-libspotify/spotify/libspotify.go:878 +0xd6
github.com/op/go-libspotify/spotify.func·001()
/home/fabio/go/src/github.com/op/go-libspotify/spotify/libspotify.go:243 +0x141
created by github.com/op/go-libspotify/spotify.NewSession
/home/fabio/go/src/github.com/op/go-libspotify/spotify/libspotify.go:244 +0x819
goroutine 6 [runnable]:
sync.(*WaitGroup).Wait(0xc2080384c0)
/usr/lib/go/src/sync/waitgroup.go:132 +0x169
github.com/op/go-libspotify/spotify.(*Track).Wait(0xc2080384b0)
/home/fabio/go/src/github.com/op/go-libspotify/spotify/libspotify.go:1793 +0x38
github.com/fabiofalci/sconsify/sconsify.ToSconsifyTrack(0xc2080384b0, 0xc2080384b0)
/home/fabio/go/src/github.com/fabiofalci/sconsify/sconsify/track.go:26 +0x33
github.com/fabiofalci/sconsify/spotify.(*Spotify).initPlaylist(0xc2080107e0)
/home/fabio/go/src/github.com/fabiofalci/sconsify/spotify/spotify.go:172 +0x208
github.com/fabiofalci/sconsify/spotify.(*Spotify).finishInitialisation(0xc2080107e0)
/home/fabio/go/src/github.com/fabiofalci/sconsify/spotify/spotify.go:135 +0x28
github.com/fabiofalci/sconsify/spotify.(*Spotify).checkIfLoggedIn(0xc2080107e0, 0x0, 0x0)
/home/fabio/go/src/github.com/fabiofalci/sconsify/spotify/spotify.go:109 +0x122
github.com/fabiofalci/sconsify/spotify.initialiseSpotify(0xc20802a2ca, 0xa, 0xc20800a8f8, 0x8, 0x8, 0xc20801e7e0, 0xc20800a860, 0x0, 0x0)
/home/fabio/go/src/github.com/fabiofalci/sconsify/spotify/spotify.go:47 +0x1ea
github.com/fabiofalci/sconsify/spotify.Initialise(0xc20802a2ca, 0xa, 0xc20800a8f8, 0x8, 0x8, 0xc20801e7e0, 0xc20800a860)
/home/fabio/go/src/github.com/fabiofalci/sconsify/spotify/spotify.go:26 +0x81
created by main.main
/home/fabio/go/src/github.com/fabiofalci/sconsify/sconsify.go:36 +0x26a
After some debugging I can see the follow behavior when things go right when loading one Track at the time:
newTrack
track.Wait()
and gets blockedcbUpdated
will be called when cbMetadataUpdated
gets updates. If track is loaded then WaitGroup.Done()
, else do nothing (waiting for more update)WaitGroup.Done()
then track.Wait()
will get unblockedAnd when I get the panic:
newTrack
track.Wait()
and gets blockedcbUpdated
is called then WaitGroup.Done()
cbUpdated
is called then WaitGroup.Done()
. Here it panics.The problem is that cbUpdated
is called twice and in both the track is already loaded so it calls WaitGroup
to unblock Wait
but WaitGroup.Add(1)
is called only once by newTrack
so only one call is expected.
I'll try to understand more about this issue but if I'm missing something please let me know.
Thanks
Crashes when trying it out:
libspotify 12.1.51.g86c92b43 Release Linux-x86_64
fatal error: unexpected signal during runtime execution
[signal 0xb code=0x1 addr=0x230 pc=0x7f7fc737f3b9]
runtime stack:
runtime.gothrow(0x5cb550, 0x2a)
/usr/lib/go/src/runtime/panic.go:503 +0x8e
runtime.sigpanic()
/usr/lib/go/src/runtime/sigpanic_unix.go:14 +0x5e
goroutine 6 [syscall, locked to thread]:
runtime.cgocall_errno(0x409e70, 0xc208019750, 0x0)
/usr/lib/go/src/runtime/cgocall.go:130 +0xf5 fp=0xc208019730 sp=0xc208019708
github.com/op/go-libspotify/spotify._Cfunc_sp_session_create(0xc208082000, 0xc208082078, 0x0)
/home/muesli/Sources/go/src/github.com/op/go-libspotify/spotify/:803 +0x43 fp=0xc208019750 sp=0xc208019730
github.com/op/go-libspotify/spotify.func·001()
/home/muesli/Sources/go/src/github.com/op/go-libspotify/spotify/libspotify.go:238 +0x6f fp=0xc2080197e0 sp=0xc208019750
runtime.goexit()
/usr/lib/go/src/runtime/asm_amd64.s:2232 +0x1 fp=0xc2080197e8 sp=0xc2080197e0
created by github.com/op/go-libspotify/spotify.NewSession
/home/muesli/Sources/go/src/github.com/op/go-libspotify/spotify/libspotify.go:244 +0x819
goroutine 1 [chan receive]:
github.com/op/go-libspotify/spotify.NewSession(0xc208010930, 0x7ffc949e57d5, 0x0, 0x0)
/home/muesli/Sources/go/src/github.com/op/go-libspotify/spotify/libspotify.go:246 +0x860
main.main()
/home/muesli/Sources/go/src/go-libspotify/examples/gospshell/gospshell.go:71 +0x310
goroutine 5 [syscall]:
os/signal.loop()
/usr/lib/go/src/os/signal/signal_unix.go:21 +0x1f
created by os/signal.init·1
/usr/lib/go/src/os/signal/signal_unix.go:27 +0x35
goroutine 17 [syscall, locked to thread]:
runtime.goexit()
/usr/lib/go/src/runtime/asm_amd64.s:2232 +0x1
When building the portaudio example, playback of tracks on my Raspberry Pi 2 B are "choppy or stutter" (best way I can describe it).
I have tested just go with portaudio I/O examples and those play audio correctly on the Pi.
when commenting out or removing these lines, it seams to fix the issue.
I have built the same example on my amd64 box and everything works fine, both before and after removing those lines.
Thank you for the great lib 👍
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.