#include <string.h>
#include "soundsource.h"

SoundSource::SoundSource()
{
	// Ensure no bad open causes a false success on reading
	_length = 0;
	
	// Ensure no new format
	newFormat[0] = 0;
}

SoundSource::~SoundSource()
{
	// Empty destructor
}

OpenStatus SoundSource::openLocation(File *sourceFile)
{
	// Do nothing!
	_sourceFile = sourceFile;
	
	return OPEN_SUCCESS;
}

int SoundSource::renderChunk(uint8_t *buf, int &renderSamples)
{
	// Render blank data (16bit stereo, so 2 bytes per sample, 2 channels)
	memset(buf, 0, renderSamples * 4);
	
	// Signify more data available
	return 1;
}

void SoundSource::seekSeconds(int seconds)
{
	// No seeking here
}

int SoundSource::tellSeconds()
{
	// No length
	return -1;
}

int SoundSource::getLength()
{
	// No length
	return -1;
}

uint32_t SoundSource::getFrequency()
{
	// Standard frequency
	return 48000;
}

void SoundSource::close()
{
	// No cleanup here
}

void SoundSource::getNowPlaying(const char *fmtString, char *output)
{
	// Nothing
	strcpy(output, "Nothing!");
}

int SoundSource::supportsFormat(const char *ext)
{
	// We support no formats, so this function always fails
	return 0;
}

void SoundSource::getFormat(char *fmt)
{
	// Copy out the new format for this file
	strcpy(fmt, newFormat);
}

void SoundSource::readAhead()
{
	// Nothing for this control
}
