//	StuckBuffer.h - Class which will occasionally trigger a stuck buffer noise.
//  ----------------------------------------------------------------------------
//	This file is part of 'NiallsAVLib', base code for any kind of audiovisual
//	apps.
//	Copyright (C) 2012  Niall Moody
//	
//	This program is free software: you can redistribute it and/or modify
//	it under the terms of the GNU General Public License as published by
//	the Free Software Foundation, either version 3 of the License, or
//	(at your option) any later version.
//
//	This program is distributed in the hope that it will be useful,
//	but WITHOUT ANY WARRANTY; without even the implied warranty of
//	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//	GNU General Public License for more details.
//
//	You should have received a copy of the GNU General Public License
//	along with this program.  If not, see <http://www.gnu.org/licenses/>.
//	----------------------------------------------------------------------------

#ifndef STUCKBUFFER_H_
#define STUCKBUFFER_H_

#include "c0xHeaders.h"

///	Class which will occasionally trigger a stuck buffer noise.
class StuckBuffer
{
  public:
	///	Constructor.
	StuckBuffer();
	///	Destructor.
	~StuckBuffer();

	///	Generates audio.
	void getAudio(float *output, int numSamples);
  private:
	///	Our buffer.
	StdArray<float, 22050>::type buffer;

	///	True if the buffer is stuck.
	bool stuck;
	///	The size of the stuck buffer.
	int stuckSize;
	///	Our position within the buffer.
	int position;

	///	Used to unstick the buffer.
	int unstuckCount;

	///	Used to make sure we don't get stuck before we've fully faded in.
	float fadeIn;
};

#endif
