caudio/Headers/cFileSource.h
Joshua Jones 3f06749573 Minor API changes to the manager, release is now releaseAllSources, createFromFile is now create.
Added the ability for the user to provide a DataSourceFactory, which cAudio will use to get audio data.  This interface can be overridden to provide cAudio the ability to read from zip archives, TCP streams, potentially any location.  DataSourceFactories can also be prioritized.
Made the existing FileSource a factory and registered it by default with the manager.  If the user wishes to prevent cAudio from reading from disk, unRegister the "FileSystem" data source.
Made tutorials conform with the changes to the API.
2010-02-13 05:48:19 +00:00

50 lines
1.2 KiB
C++

// Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
// This file is part of the "cAudio Engine"
// For conditions of distribution and use, see copyright notice in cAudio.h
#ifndef CFILESOURCE_H
#define CFILESOURCE_H
#include "../include/IDataSource.h"
#include <string>
#include <iostream>
#include <fstream>
namespace cAudio
{
class cFileSource : public IDataSource
{
public:
cFileSource(const char* filename);
~cFileSource();
//!Returns whether the source is valid (in case of an error, like the file couldn't be found)
virtual bool isValid();
//!Get the current location in the data stream
virtual int getCurrentPos();
//!Get the total size of the data stream
virtual int getSize();
//!Read out a section of the data stream
virtual int read(void* output, int size);
//!Seek to a position in the data stream
virtual bool seek(int amount, bool relative);
protected:
//!Hold if valid
bool Valid;
//!Holds file size
int Filesize;
//!File stream
FILE* pFile;
private:
};
};
#endif //! CFILESOURCE_H