Fix issue in Rocket.lua script.
[Cafu-Engine.git] / Libs / SoundSystem / Common / MP3Stream.hpp
blobd7cf2fe81b8fc70e7b463b615b2cadad1a4a6cae
1 /*
2 Cafu Engine, http://www.cafu.de/
3 Copyright (c) Carsten Fuchs and other contributors.
4 This project is licensed under the terms of the MIT license.
5 */
7 #ifndef CAFU_SOUNDSYS_MP3_STREAM_HPP_INCLUDED
8 #define CAFU_SOUNDSYS_MP3_STREAM_HPP_INCLUDED
10 #include "SoundStream.hpp"
13 struct mpg123_handle_struct;
14 typedef struct mpg123_handle_struct mpg123_handle;
15 namespace cf { namespace FileSys { class InFileI; } }
18 /// Represents an MP3 stream.
19 /// Audio data is decompressed and readable as 16 bit enconded mono or stereo raw PCM data.
20 /// This class uses the mpg123 library to read PCM data from an MP3 file.
21 class MP3StreamT : public SoundStreamT
23 public:
25 /// The constructor. Throws an exception of type std::runtime_error on failure.
26 /// Creates an audio data stream from an MP3 file.
27 /// @param FileName The path to the file from which the stream should be created.
28 MP3StreamT(const std::string& FileName);
30 /// Destructor.
31 ~MP3StreamT();
33 // SoundStream implementation.
34 int Read(unsigned char* Buffer, unsigned int Size);
35 bool Rewind();
36 unsigned int GetChannels();
37 unsigned int GetRate();
40 private:
42 mpg123_handle* StreamHandle; ///< Handle to the mpg123 stream.
43 cf::FileSys::InFileI* StreamFile; ///< The file handle from which the mp3 data is streamed.
45 long Rate; ///< Sampling rate of this stream in Hz.
46 int Channels; ///< Number of channels in this stream.
49 #endif