]> git.tdb.fi Git - libs/al.git/blob - source/source.cpp
fec965c5d8ede45e6487b8a2f0e70a03ab233624
[libs/al.git] / source / source.cpp
1 /* $Id$
2
3 This file is part of libmspal
4 Copyright © 2008 Mikko Rasa, Mikkosoft Productions
5 Diestributed under the LGPL
6 */
7
8 #include "buffer.h"
9 #include "source.h"
10
11 using namespace std;
12
13 namespace Msp {
14 namespace AL {
15
16 Source::Source()
17 {
18         alGenSources(1, &id);
19 }
20
21 Source::~Source()
22 {
23         alDeleteSources(1, &id);
24 }
25
26 void Source::attribute(ALenum attr, int v)
27 {
28         alSourcei(id, attr, v);
29 }
30
31 void Source::attribute(ALenum attr, float v)
32 {
33         alSourcef(id, attr, v);
34 }
35
36 void Source::attribute(ALenum attr, float v0, float v1, float v2)
37 {
38         alSource3f(id, attr, v0, v1, v2);
39 }
40
41 void Source::attribute(ALenum attr, const float *v)
42 {
43         alSourcefv(id, attr, v);
44 }
45
46 void Source::set_buffer(Buffer &buffer)
47 {
48         attribute(AL_BUFFER, static_cast<int>(buffer.get_id()));
49 }
50
51 void Source::queue_buffers(const vector<Buffer *> &buffers)
52 {
53         vector<uint> ids;
54         ids.reserve(buffers.size());
55         for(vector<Buffer *>::const_iterator i=buffers.begin(); i!=buffers.end(); ++i)
56                 ids.push_back((*i)->get_id());
57         alSourceQueueBuffers(id, ids.size(), &ids.front());
58 }
59
60 void Source::queue_buffer(Buffer &buffer)
61 {
62         uint bid=buffer.get_id();
63         alSourceQueueBuffers(id, 1, &bid);
64 }
65
66 } // namespace AL
67 } // namespace Msp