Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
blob: 1086a5cff29b93b4fa020c897bc6bce0b4e73a61 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
   audio/buffers.h
   This file is part of the Osirion project and is distributed under
   the terms of the GNU General Public License version 2
*/

#ifndef __INCLUDED_AUDIO_BUFFERS_H__
#define __INCLUDED_AUDIO_BUFFERS_H__

#include "sys/sys.h"

#ifdef _OSX
#include "OpenAL/al.h"
#include "OpenAL/alc.h"
#else
#include "AL/al.h"
#include "AL/alc.h"
#endif

#include <string>
#include <map>

namespace audio
{

const size_t MAXBUFFERS		= 1024;

/// OpenAL buffers wrapper class

class Buffers
{
public:
	static void init();
	static void shutdown();

	/// find previously loaded PCM data
	static size_t find(std::string name);

	/// load audio data into a buffer ans return the buffer index
	static size_t load(std::string name);

	/// bind a buffer to a source
	static void bind(ALuint source, std::string name);

	/// bind a specific buffer to a source
	static void bind(ALuint source, size_t id);

private:
	static void clear();

	typedef std::map<std::string, size_t>::iterator iterator;

	static std::map<std::string, size_t> registry;
	static size_t index;
	static ALuint buffers[MAXBUFFERS];
};

}

#endif // __INCLUDED_AUDIO_BUFFERS_H__