libspotify:访问冲突读取位置0x00000000。 (视窗)

时间:2015-06-14 20:56:09

标签: c++ windows visual-studio libspotify

因此,我尝试通过URI获取特定的播放列表,如下所示:

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);

回调如下:

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是一个互斥锁(CreateMutex(NULL, FALSE, NULL);

lib_event_call_finshed是一个事件(CreateEvent(NULL, FALSE, FALSE, NULL);

关于我的程序架构的一句话:

我有一个线程执行上面的命令,这是在main函数中创建的。然后main函数执行主循环:

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是另一个事件,在调用notify_main_thread时调用。

当执行标记的行时,我从Visual Studio得到以下错误:

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

0 个答案:

没有答案