#ifndef __WAVSOURCE_H
#define __WAVSOURCE_H

#ifdef __cplusplus
extern "C" {
#endif

#include "soundsource.h"

class WavSource : public SoundSource
{
	public:
		WavSource();
		virtual ~WavSource();
		
		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 getNowPlaying(const char *fmtString, char *output);
		virtual int supportsFormat(const char *ext);
	private:
		u32 dataChunkStart;
		u32 dataChunkEnd;
		
		int numChannels;
		int sampleBytes;
		u32 frequency;
};

typedef struct 
{
	char chunkID[4];
	long chunkSize;

	short wFormatTag;
	unsigned short wChannels;
	unsigned long dwSamplesPerSec;
	unsigned long dwAvgBytesPerSec;
	unsigned short wBlockAlign;
	unsigned short wBitsPerSample;
} WavFormatChunk;

#ifdef __cplusplus
}
#endif

#endif
