2
votes

I'm developing a libspotify wrapper for C# and am in the process of writing unit tests. As such, I need to repeatedly create sessions, log in, perform actions, log out, release and clean up the session, ready for the next test.

I'm unsure what the correct 'shutdown' procedure for libspotify is. The 'jukebox' example performs no shutdown at all - the main function just exits without calling sp_session_release.

For example, should I turn all callbacks off before releasing? At the moment I get a crash whenever I try to call sp_session_release.

Cheers Tom

1
If you're interested, I've been doing much the same thing in the last few weeks (writing a C# libspotify wrapper). Maybe some of it will be useful? Have a look: github.com/openhome/ohLibSpotify I'm afraid I haven't yet tried creating then destroying sessions over and over again in one process, though. - Weeble

1 Answers

4
votes

At the moment (and it's very bad form), libspotify only supports "one instance of sp_session per process", and as you see it's unreliable when releasing. In theory, releasing the session after logging out (and waiting for the logout callback) should be fine, but we're seeing some reliability problems as you can see.

Our own internal libspotify unit tests create a process for each test to really make sure state is reset, which is why we missed this problem for libspotify 12.

CocoaLibSpotify's unit tests run all the tests in one process, but don't log out etc between them.