@Override
public void run() {
while (true) {
try {
SubmissionData data;
synchronized (submitQueue) {
while (!config.getBoolean("lastfm.enabled", false) ||
submitQueue.isEmpty()) {
submitQueue.wait();
}
data = submitQueue.peek();
}
if (!authorized) {
auth();
if (!authorized) {
Thread.sleep(waitTime);
waitTime = Math.min(waitTime * 2, MAX_WAIT_TIME);
continue;
}
}
logger.fine("Submitting data: " + data.toString());
ResponseStatus status = scrobbler.submit(data);
if (status.ok()) {
waitTime = MIN_WAIT_TIME;
synchronized (submitQueue) {
submitQueue.poll();