git-svn-id: https://scorched3d.svn.sourceforge.net/svnroot/scorched3d/trunk/scorched...
[scorched3d/parasti.git] / src / client / sound / SoundBufferOV.h
blob6fd59e93a6849aad3d75f4e98036f833dfbc7221
1 ////////////////////////////////////////////////////////////////////////////////
2 // Scorched3D (c) 2000-2009
3 //
4 // This file is part of Scorched3D.
5 //
6 // Scorched3D is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
11 // Scorched3D is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with Scorched3D; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 ////////////////////////////////////////////////////////////////////////////////
21 #ifndef _SoundBufferOV_H_
22 #define _SoundBufferOV_H_
24 #ifdef HAVE_OGG
26 #include <sound/SoundBuffer.h>
27 #include <ogg/ogg.h>
28 #include <vorbis/codec.h>
29 #include <vorbis/vorbisfile.h>
31 #define OGG_BUFFER_SIZE (1024 * 1024)
33 class SoundBufferOV : public SoundBuffer
35 public:
36 SoundBufferOV(const char *wavFileName);
37 virtual ~SoundBufferOV();
39 SoundBufferSourceInstance *createSourceInstance(unsigned int source);
41 static bool openStream(const char *fileName, OggVorbis_File &oggStream);
42 static int readData(OggVorbis_File &oggStream, char *data, int dataSize);
43 static bool addDataToBuffer(vorbis_info *vorbisInfo, int buffer, char *dataBuffer, int size);
45 static const char *errorString(int code);
46 static size_t read_func(void *ptr, size_t size, size_t nmemb, void *datasource);
47 static int seek_func(void *datasource, ogg_int64_t offset, int whence);
48 static int close_func(void *datasource);
49 static long tell_func(void *datasource);
51 protected:
52 unsigned int buffer_;
55 #endif // HAVE_OGG
57 #endif /* _SoundBufferOV_H_ */