bool despotify_deinit(AppData* appdata) { if(appdata->ds) despotify_exit(appdata->ds); if (!despotify_cleanup()) { printf("despotify_cleanup() failed\n"); return 1; } return 0; }
void clean_and_exit(struct despotify_session* ds, int sig) { if (!sig) sig = 0; despotify_exit(ds); if (!despotify_cleanup()) { wrapper_printf("despotify_cleanup() failed"); sig = -1; } exit(sig); }
int main(int argc, char** argv) { setlocale(LC_ALL, ""); if (argc < 3) { wprintf(L"Usage: %s <username> <password>\n", argv[0]); return 1; } if (!despotify_init()) { wprintf(L"despotify_init() failed\n"); return 1; } struct despotify_session* ds = despotify_init_client(callback); if (!ds) { wprintf(L"despotify_init_client() failed\n"); return 1; } if (!despotify_authenticate(ds, argv[1], argv[2])) { printf( "Authentication failed: %s\n", despotify_get_error(ds)); despotify_exit(ds); return 1; } print_info(ds); command_loop(ds); despotify_exit(ds); if (!despotify_cleanup()) { wprintf(L"despotify_cleanup() failed\n"); return 1; } return 0; }
void sess_cleanup() { sess_disconnect(); audio_exit(audio_device); log_append("Destroyed audio output"); // Free search results. for (sess_search_t *s = g_session.search; s;) { despotify_free_search(s->res); sess_search_t *p = s; s = s->next; free(p); } if (!despotify_cleanup()) panic("despotify_cleanup() failed"); free(g_session.username); g_session.username = 0; free(g_session.password); g_session.password = 0; }
int main(int argc, char** argv) { setlocale(LC_ALL, ""); if (argc < 3) { wrapper_wprintf(L"Usage: %s <username> <password> [remote control port]\n", argv[0]); return 1; } DSFYDEBUG("$Id$\n"); if (!despotify_init()) { wrapper_wprintf(L"despotify_init() failed\n"); return 1; } struct despotify_session* ds = despotify_init_client(callback, NULL, true, true); if (!ds) { wrapper_wprintf(L"despotify_init_client() failed\n"); return 1; } pthread_create(&thread, NULL, &thread_loop, ds); if(argc == 4 && wrapper_listen(atoi(argv[3]))) { wrapper_wprintf(L"wrapper_listen() failed to listen on local port %s\n", argv[3]); return 1; } if (!despotify_authenticate(ds, argv[1], argv[2])) { printf( "Authentication failed: %s\n", despotify_get_error(ds)); despotify_exit(ds); return 1; } audio_device = audio_init(); #if 0 { struct ds_track* t = despotify_get_track(ds, "d1b264bb6bcd46be852ceba8ac5e6582"); despotify_play(ds, t, false); thread_play(); while(1) { sleep(1); } } #else print_info(ds); command_loop(ds); #endif thread_exit(); audio_exit(audio_device); despotify_exit(ds); if (!despotify_cleanup()) { wrapper_wprintf(L"despotify_cleanup() failed\n"); return 1; } return 0; }