#ifndef __MP3SOURCE_H
#define __MP3SOURCE_H

#ifdef __cplusplus
extern "C" {
#endif

#include "mpg123.h"
#include "soundsource.h"

class Mp3Source : public SoundSource
{
	public:
		Mp3Source();
		virtual ~Mp3Source();
		
		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:
		mpg123_handle *mh;
		
		long frequency;
		int channels;
		off_t samples;
		
		off_t fileLength;
		int rendered;
};

#ifdef __cplusplus
}
#endif

#endif
