2010-02-09 05:18:39 +01:00
|
|
|
// 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
|
|
|
|
|
2009-06-21 05:24:30 +02:00
|
|
|
#ifndef IAUDIODECODER_H
|
|
|
|
#define IAUDIODECODER_H
|
|
|
|
|
2009-12-07 23:25:08 +01:00
|
|
|
#include "IRefCounted.h"
|
2009-06-21 05:24:30 +02:00
|
|
|
#include "IDataSource.h"
|
2010-02-09 06:33:32 +01:00
|
|
|
#include "EAudioFormats.h"
|
2009-06-21 05:24:30 +02:00
|
|
|
|
|
|
|
namespace cAudio
|
|
|
|
{
|
2010-02-17 02:42:45 +01:00
|
|
|
//! Interface for all Audio Decoders in cAudio
|
2009-12-07 23:25:08 +01:00
|
|
|
class IAudioDecoder : public IRefCounted
|
|
|
|
{
|
|
|
|
public:
|
2010-02-17 02:42:45 +01:00
|
|
|
//! Default Constructor
|
|
|
|
/** \param stream: Data Source to attach to this decoder. */
|
2009-12-07 23:25:08 +01:00
|
|
|
IAudioDecoder(IDataSource* stream) : Stream(stream) { if(Stream) Stream->grab(); }
|
|
|
|
virtual ~IAudioDecoder() { if(Stream) Stream->drop(); }
|
2009-06-21 05:24:30 +02:00
|
|
|
|
2010-02-17 02:42:45 +01:00
|
|
|
//! Returns the format of the audio data
|
2009-12-07 23:25:08 +01:00
|
|
|
virtual AudioFormats getFormat() = 0;
|
2009-06-21 05:24:30 +02:00
|
|
|
|
2010-02-17 02:42:45 +01:00
|
|
|
//! Returns the frequency (sample rate) of the audio data
|
2009-12-07 23:25:08 +01:00
|
|
|
virtual int getFrequency() = 0;
|
2009-06-21 05:24:30 +02:00
|
|
|
|
2010-02-17 02:42:45 +01:00
|
|
|
//! Returns whether seeking is supported
|
2009-12-07 23:25:08 +01:00
|
|
|
virtual bool isSeekingSupported() = 0;
|
2009-06-21 05:24:30 +02:00
|
|
|
|
2010-02-17 02:42:45 +01:00
|
|
|
//! Returns whether the stream is valid for this codec
|
2009-12-07 23:25:08 +01:00
|
|
|
virtual bool isValid() = 0;
|
2009-06-21 05:24:30 +02:00
|
|
|
|
2010-02-17 02:42:45 +01:00
|
|
|
//! Reads a section of data out of the audio stream
|
|
|
|
/**
|
|
|
|
\param output: Pointer to the buffer to put the decoded audio.
|
|
|
|
\param amount: Amount of data in bytes to ask the decoder to output.
|
|
|
|
\return Number of bytes of audio data actually output. */
|
2009-12-07 23:25:08 +01:00
|
|
|
virtual int readAudioData(void* output, int amount) = 0;
|
2009-06-21 05:24:30 +02:00
|
|
|
|
2010-02-17 02:42:45 +01:00
|
|
|
//! Sets the position in the stream to read from
|
|
|
|
/**
|
|
|
|
\param position: Position to seek to.
|
|
|
|
\param relative: Whether the number in position is relative to the current position.
|
|
|
|
\return True on success, False on failure. */
|
2009-12-07 23:25:08 +01:00
|
|
|
virtual bool setPosition(int position, bool relative) = 0;
|
2009-06-21 05:24:30 +02:00
|
|
|
|
2010-02-17 02:42:45 +01:00
|
|
|
//! If seeking is supported, will seek the stream to seconds
|
|
|
|
/**
|
|
|
|
\param seconds: Time in seconds to seek.
|
|
|
|
\param relative: Whether the number in position is relative to the current position.
|
|
|
|
\return True on success, False on failure. */
|
2009-12-07 23:25:08 +01:00
|
|
|
virtual bool seek(float seconds, bool relative) = 0;
|
|
|
|
protected:
|
2010-02-17 02:42:45 +01:00
|
|
|
//! Pointer to the data source to take audio data from.
|
2009-12-07 23:25:08 +01:00
|
|
|
IDataSource* Stream;
|
|
|
|
};
|
2009-06-21 05:24:30 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif //! IAUDIODECODER_H
|