Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Stream.h
Go to the documentation of this file.
1 //
2 // C++ Interface: Audio::Codec
3 //
4 #ifndef __AUDIO_STREAM_H__INCLUDED__
5 #define __AUDIO_STREAM_H__INCLUDED__
6 
7 #include <string>
8 #include "Exceptions.h"
9 #include "Format.h"
10 
11 namespace Audio {
12 
21  class Stream
22  {
23  private:
24  std::string filePath;
25  Format streamFormat;
26 
27  void* curBufferPos;
28 
29  protected:
38  class NoBufferException : public Exception {
39  public:
41  NoBufferException(const NoBufferException &other) : Exception(other) {}
42  explicit NoBufferException(const std::string &message) : Exception(message) {}
43  };
44 
45  protected:
47  Stream(const std::string& path) throw(Exception);
48 
50  Format& getFormatInternal() throw() { return streamFormat; }
51 
52  public:
53  virtual ~Stream();
54 
56  const std::string& getPath() const throw() { return filePath; };
57 
59  const Format& getFormat() const throw() { return streamFormat; }
60 
67  double getLength() throw(Exception);
68 
78  unsigned int read(void *buffer, unsigned int bufferSize) throw(Exception);
79 
81  double getPosition() const throw();
82 
89  void seek(double position) throw(Exception);
90 
91  // The following section contains all the virtual functions that need be implemented
92  // by a concrete Stream class. All are protected, so the stream interface is independent
93  // of implementations.
94  protected:
95 
97  virtual double getLengthImpl() const throw(Exception) = 0;
98 
100  virtual double getPositionImpl() const throw() = 0;
101 
103  virtual void seekImpl(double position) throw(Exception) = 0;
104 
115  virtual void getBufferImpl(void *&buffer, unsigned int &bufferSize) throw(Exception) = 0;
116 
124  virtual void nextBufferImpl() throw(Exception) = 0;
125  };
126 
127 };
128 
129 #endif//__AUDIO_STREAM_H__INCLUDED__