private synchronized void nextSource() {
		if (closeCurrentSource) {
			try {
				currentSource.close();
			} catch (Exception e) {
				log.error("Error closing source", e);
			} finally {
				closeCurrentSource = false;
			}
		}
		if (fixContinuity) {
			continuityFixer.nextSource();
		}
		idx++;
		if (idx >= sources.size()) {
			currentLoop++;
			if (maxLoops > 0 && currentLoop > maxLoops) {
				currentSource = null;
			} else {
				idx = 0;
				for (MTSSource source : sources) {
					try {
						((ResettableMTSSource) source).reset();
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
				currentSource = sources.get(idx);
			}
		} else {
			currentSource = sources.get(idx);
		}
		if (idx < sources.size()) {
			log.info("Switched to source #{}", idx);
		}
	}