#ifndef __FLACSOURCE_H
#define __FLACSOURCE_H

#ifdef __cplusplus
extern "C" {
#endif

#include "soundsource.h"
#include "ringbuffer.h"
#include "flac/stream_decoder.h"

typedef struct
{
	int frequency;
	int samples;
	int channels;
	int bits;
	
	int fLen;
	
	File *tFile;
	RingBuffer outBuf;
} FlacInfo;

class FlacSource : public SoundSource
{
	public:
		FlacSource();
		virtual ~FlacSource();
		
		virtual OpenStatus openLocation(File *sourceFile);
		virtual int renderChunk(uint8_t *buf, int &renderSamples);
		virtual void seekSeconds(int seconds);
		virtual int tellSeconds();
		virtual int getLength();
		virtual uint32_t getFrequency();
		virtual void close();
		virtual void readAhead();
		
		virtual void getNowPlaying(const char *fmtString, char *output);
		virtual int supportsFormat(const char *ext);
	private:
		FLAC__StreamDecoder *decoder;
		
		FlacInfo fInfo;
		
		int rendered;
};

#ifdef __cplusplus
}
#endif

#endif
