Mercurial > fife-parpg
comparison engine/core/audio/soundclip.h @ 0:4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
author | mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Sun, 29 Jun 2008 18:44:17 +0000 |
parents | |
children | 90005975cdbb |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4a0efb7baf70 |
---|---|
1 /*************************************************************************** | |
2 * Copyright (C) 2005-2008 by the FIFE team * | |
3 * http://www.fifengine.de * | |
4 * This file is part of FIFE. * | |
5 * * | |
6 * FIFE 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. * | |
10 * * | |
11 * This program 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. * | |
15 * * | |
16 * You should have received a copy of the GNU General Public License * | |
17 * along with this program; if not, write to the * | |
18 * Free Software Foundation, Inc., * | |
19 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * | |
20 ***************************************************************************/ | |
21 | |
22 #ifndef FIFE_SOUNDCLIP_H_ | |
23 #define FIFE_SOUNDCLIP_H_ | |
24 | |
25 // Standard C++ library includes | |
26 #include <vector> | |
27 | |
28 // Platform specific includes | |
29 | |
30 // 3rd party library includes | |
31 | |
32 // FIFE includes | |
33 // These includes are split up in two parts, separated by one empty line | |
34 // First block: files included from the FIFE root src directory | |
35 // Second block: files included from the same folder | |
36 #include "util/base/resourceclass.h" | |
37 | |
38 #include "sounddecoder.h" | |
39 | |
40 namespace FIFE { | |
41 | |
42 /** Different types of audio-file positions | |
43 */ | |
44 enum SoundPositionType { | |
45 SD_SAMPLE_POS, | |
46 SD_TIME_POS, | |
47 SD_BYTE_POS | |
48 }; | |
49 | |
50 struct SoundBufferEntry { | |
51 ALuint buffers[BUFFER_NUM]; | |
52 unsigned int usedbufs; | |
53 unsigned long deccursor; | |
54 }; | |
55 | |
56 /** Class to handle the buffers of an audio file | |
57 */ | |
58 class SoundClip : public ResourceClass { | |
59 public: | |
60 | |
61 SoundClip(SoundDecoder* decptr, bool deletedecoder = true); | |
62 | |
63 ~SoundClip(); | |
64 | |
65 // TODO: fill in these stubs! Note: m_location is _not_ properly initialized. | |
66 virtual const ResourceLocation& getResourceLocation() { return m_location; } | |
67 | |
68 virtual void setResourceLocation(const ResourceLocation& location) { } | |
69 virtual void setResourceFile(const std::string& filename) { } | |
70 | |
71 /** Does this SoundClip require a streaming mechanism? | |
72 * | |
73 * @return Returns true if streaming is required, false if not. | |
74 */ | |
75 bool isStream() { | |
76 return m_isstream; | |
77 } | |
78 | |
79 /** Returns the number of buffers used by the SoundClip | |
80 * (only for non-streaming sound clips) | |
81 * | |
82 * @return Returns the number of buffers. | |
83 */ | |
84 unsigned int countBuffers() { | |
85 return m_buffervec.at(0)->usedbufs; | |
86 } | |
87 | |
88 /** Returns the array of buffers for queuing | |
89 * | |
90 */ | |
91 ALuint* getBuffers(unsigned int streamid = 0) { | |
92 return m_buffervec.at(streamid)->buffers; | |
93 } | |
94 | |
95 /** Starts streaming the soundclip | |
96 * @return Returns the streamid | |
97 */ | |
98 unsigned int beginStreaming(); | |
99 | |
100 /** Fills the streaming-buffers with initial data | |
101 * | |
102 * @param streamid The stream ID | |
103 */ | |
104 void acquireStream(unsigned int streamid); | |
105 | |
106 /** Sets the stream position | |
107 * @return True if position is invalid (EOF has been reached) | |
108 */ | |
109 bool setStreamPos(unsigned int streamid, SoundPositionType type, float value); | |
110 | |
111 /** Gets the stream position | |
112 */ | |
113 float getStreamPos(unsigned int streamid, SoundPositionType type); | |
114 | |
115 /** Refill a processed buffer with new data | |
116 * | |
117 * @return True if file was EOF | |
118 * @param streamid The stream ID | |
119 */ | |
120 bool getStream(unsigned int streamid, ALuint buffer); | |
121 | |
122 /** Quits Streaming | |
123 */ | |
124 void quitStreaming(unsigned int streamid); | |
125 | |
126 //void addRef() { | |
127 // m_refcount++; | |
128 //} | |
129 //void decRef() { | |
130 // m_refcount--; | |
131 //} | |
132 // unsigned int getRefCount() { | |
133 // return m_refcount; | |
134 // } | |
135 | |
136 /** Returns the attached decoder | |
137 */ | |
138 SoundDecoder* getDecoder() { | |
139 return m_decoder; | |
140 } | |
141 | |
142 private: | |
143 ResourceLocation m_location; | |
144 //unsigned int m_refcount; // Reference count of that soundclip | |
145 bool m_isstream; // is stream? | |
146 SoundDecoder* m_decoder; // attached decoder | |
147 bool m_deletedecoder; // when loadFromDecoder-method is used, decoder shouldn't be deleted | |
148 std::vector<SoundBufferEntry*> m_buffervec; | |
149 }; | |
150 } | |
151 | |
152 #endif |