libspotify: Access violation reading location 0x00000000. (Windows)

140 views Asked by At

So, I try to get a specific playlist via the URI like this:

sp_link *link;
sp_playlist *playlist;
sp_playlist_callbacks playlist_callbacks = { 0 };

link = sp_link_create_from_string("spotify:user:spotify:playlist:2iY4BLINjMOGJX4qHCWNju");
playlist_callbacks.playlist_state_changed = playlist_state_changed;

WaitForSingleObject(lib_lock, INFINITE);
playlist = sp_playlist_create(session, link);              // <- Program crashes here
sp_playlist_add_callbacks(playlist, &playlist_callbacks, NULL);
WaitForSingleObject(lib_event_call_finished, INFINITE);
ReleaseMutex(lib_lock);

The callback is the following:

void SP_CALLCONV playlist_state_changed(sp_playlist *playlist, void *user_data)
{
    if (sp_playlist_is_loaded(playlist)) {
        SetEvent(lib_event_call_finished);
    }
}

lib_lock is a mutex (CreateMutex(NULL, FALSE, NULL);)

lib_event_call_finshed is an event (CreateEvent(NULL, FALSE, FALSE, NULL);)


One word about my program's architecture:

I have a thread executing the above commands, which is created in the main function. The main function then executes the main loop:

while (true) {
    result = WaitForSingleObject(lib_event_notify, next_timeout);
    if (result == WAIT_OBJECT_0 || result == WAIT_TIMEOUT) {
        do {
            sp_session_process_events(session, &next_timeout);
        } while (next_timeout == 0);
    } else {
        ERR_MSG("WaitForSingleObject has failed");
    }
}

lib_event_notify is another event, which is called when notify_main_thread is called.


When the marked line is executed I get following error from Visual Studio:

Unhandled exception at 0x100A5550 (libspotify.dll) in prog.exe:
0xC0000005: Access violation reading location 0x00000000.
0

There are 0 answers