cAudio  2.3.0
3d Audio Engine
IAudioDecoder.h
1 // Copyright (c) 2008-2011 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones, Murat (wolfmanfx) Sari
2 // This file is part of the "cAudio Engine"
3 // For conditions of distribution and use, see copyright notice in cAudio.h
4 
5 #pragma once
6 
7 #include "IRefCounted.h"
8 #include "IDataSource.h"
9 #include "EAudioFormats.h"
10 #include "cAudioString.h"
11 
12 namespace cAudio
13 {
15  class IAudioDecoder : public IRefCounted
16  {
17  public:
19 
20  IAudioDecoder(IDataSource* stream) : Stream(stream) { if(Stream) Stream->grab(); }
21  virtual ~IAudioDecoder() { if(Stream) Stream->drop(); }
22 
24  virtual AudioFormats getFormat() = 0;
25 
27  virtual int getFrequency() = 0;
28 
30  virtual bool isSeekingSupported() = 0;
31 
33  virtual bool isValid() = 0;
34 
36 
40  virtual int readAudioData(void* output, int amount) = 0;
41 
43 
47  virtual bool setPosition(int position, bool relative) = 0;
48 
50 
54  virtual bool seek(float seconds, bool relative) = 0;
55 
57  virtual float getTotalTime() = 0;
58 
60  virtual int getTotalSize() = 0;
61 
63  virtual int getCompressedSize() = 0;
64 
66  virtual float getCurrentTime() = 0;
67 
69  virtual int getCurrentPosition() = 0;
70 
72  virtual int getCurrentCompressedPosition() = 0;
73 
75  virtual cAudioString getType() const = 0;
76 
77  protected:
80  };
81 };
virtual bool seek(float seconds, bool relative)=0
If seeking is supported, will seek the stream to seconds.
Interface for data providers in cAudio.
Definition: IDataSource.h:12
virtual bool setPosition(int position, bool relative)=0
Sets the position in the stream to read from.
virtual cAudioString getType() const =0
Returns the IAudioDecoderType.
IAudioDecoder(IDataSource *stream)
Default Constructor.
Definition: IAudioDecoder.h:20
virtual int getCurrentPosition()=0
If available, returns the current position in the decoded audio stream in bytes. Returns a negative n...
virtual bool isValid()=0
Returns whether the stream is valid for this codec.
virtual int getTotalSize()=0
If available, returns the total decoded size of the audio stream. Returns a negative number if this c...
virtual float getCurrentTime()=0
If seeking is supported, will return the current position in the stream in seconds. Returns a negative number if the current time cannot be determined.
Applies reference counting to certain cAudio objects.
Definition: IRefCounted.h:12
virtual int getCompressedSize()=0
Returns the compressed (original) size of the audio stream, before decoding.
virtual void grab()
Increments the reference count by one.
Definition: IRefCounted.h:19
virtual bool isSeekingSupported()=0
Returns whether seeking is supported.
virtual bool drop()
Decrements the reference count by one. If it hits zero, this object is deleted.
Definition: IRefCounted.h:25
virtual float getTotalTime()=0
If seeking is supported, will return the length of the audio steam in seconds. Returns a negative num...
virtual int getCurrentCompressedPosition()=0
Returns the position in the compressed (original) audio stream before decoding.
virtual int getFrequency()=0
Returns the frequency (sample rate) of the audio data.
IDataSource * Stream
Pointer to the data source to take audio data from.
Definition: IAudioDecoder.h:79
virtual AudioFormats getFormat()=0
Returns the format of the audio data.
virtual int readAudioData(void *output, int amount)=0
Reads a section of data out of the audio stream.
Interface for all Audio Decoders in cAudio.
Definition: IAudioDecoder.h:15
AudioFormats
Enumeration of audio formats supported by the engine.
Definition: EAudioFormats.h:10
Main namespace for the entire cAudio library.
Definition: cAudioCapture.h:15