/* Thread: http and player */ int lastfm_scrobble(int id) { struct lastfm_command *cmd; int ret; DPRINTF(E_DBG, L_LASTFM, "Got LastFM scrobble request\n"); // LastFM is disabled because we already tried looking for a session key, but failed if (g_disabled) return -1; // No session key in mem or in db if (!g_session_key) g_session_key = db_admin_get("lastfm_sk"); if (!g_session_key) { DPRINTF(E_INFO, L_LASTFM, "No valid LastFM session key\n"); g_disabled = 1; return -1; } // Spawn LastFM thread ret = lastfm_init(); if (ret < 0) { g_disabled = 1; return -1; } g_initialized = 1; // Send scrobble command to the thread cmd = (struct lastfm_command *)malloc(sizeof(struct lastfm_command)); if (!cmd) { DPRINTF(E_LOG, L_LASTFM, "Could not allocate lastfm_command\n"); return -1; } memset(cmd, 0, sizeof(struct lastfm_command)); cmd->nonblock = 1; cmd->func = scrobble; cmd->arg.id = id; nonblock_command(cmd); return 0; }
/* Thread: worker */ int lastfm_scrobble(int id) { DPRINTF(E_DBG, L_LASTFM, "Got LastFM scrobble request\n"); // LastFM is disabled because we already tried looking for a session key, but failed if (lastfm_disabled) return -1; // No session key in mem or in db if (!lastfm_session_key) lastfm_session_key = db_admin_get("lastfm_sk"); if (!lastfm_session_key) { DPRINTF(E_INFO, L_LASTFM, "No valid LastFM session key\n"); lastfm_disabled = 1; return -1; } return scrobble(id); }