Handle init(int sampleCount, int minimumBuffers, int preferredBuffers) throws InterruptedException {
		if (sampleCount < 1) {
			throw new IllegalStateException("Sample count should be at least one");
		}
		if (minimumBuffers < 1) {
			throw new IllegalArgumentException("Minimum buffers must be at least 1");
		}
		if (preferredBuffers < minimumBuffers) {
			throw new IllegalArgumentException("Preferred number of buffers (" + preferredBuffers + ") should be bigger than minimum (" + minimumBuffers + ")");
		}
		List<BufferAndState> newBuffers;
		synchronized (mutex) {
			pendingBuffersRequested += minimumBuffers;
			try {
				if (this.sampleCount != -1 && this.sampleCount != sampleCount) {
					throw new IllegalStateException("Already initialized with buffer size " + this.sampleCount);
				}
				newBuffers = unsafeTryAllocate(sampleCount, minimumBuffers, preferredBuffers);
				if (first && newBuffers == null) {
					throw new IllegalStateException("Cannot allocate enough buffers to work with");
				}
				 
				while (newBuffers == null) {
					waitForMutex();
					newBuffers = unsafeTryAllocate(sampleCount, minimumBuffers, preferredBuffers);
				}
				if (first) {
					this.sampleCount = sampleCount;
					first = false;
				}
			}
			finally {
				pendingBuffersRequested -= minimumBuffers;
				mutex.notifyAll();
			}
		}
		return new MyHandle(newBuffers);
	}