gosu 0.7.45 → 0.7.46
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +6 -11
- data/Gosu/{ButtonsWin.hpp → Buttons.hpp} +91 -4
- data/Gosu/ButtonsMac.hpp +91 -4
- data/Gosu/Graphics.hpp +10 -0
- data/Gosu/ImageData.hpp +1 -0
- data/Gosu/Input.hpp +2 -3
- data/Gosu/Version.hpp +2 -2
- data/Gosu/Window.hpp +1 -1
- data/GosuImpl/Audio/AudioToolboxFile.hpp +4 -0
- data/GosuImpl/Graphics/BitmapApple.mm +5 -11
- data/GosuImpl/Graphics/ClipRectStack.hpp +2 -2
- data/GosuImpl/Graphics/Common.hpp +1 -1
- data/GosuImpl/Graphics/DrawOpQueue.hpp +30 -29
- data/GosuImpl/Graphics/Graphics.cpp +2 -3
- data/GosuImpl/Graphics/TextMac.cpp +9 -5
- data/GosuImpl/Graphics/TextTouch.mm +8 -4
- data/GosuImpl/Graphics/Texture.cpp +4 -1
- data/GosuImpl/InputMac.mm +24 -45
- data/GosuImpl/InputX.cpp +25 -39
- data/GosuImpl/RubyGosu.swg +11 -0
- data/GosuImpl/RubyGosu_wrap.cxx +109 -40
- data/GosuImpl/RubyGosu_wrap.h +1 -1
- data/GosuImpl/TextInputWin.cpp +1 -1
- data/GosuImpl/TextInputX.cpp +3 -1
- data/GosuImpl/WinMain.cpp +3 -4
- data/GosuImpl/WindowMac.mm +83 -73
- data/GosuImpl/WindowWin.cpp +65 -58
- data/dependencies/libogg/AUTHORS +4 -0
- data/dependencies/libogg/CHANGES +70 -0
- data/dependencies/libogg/COPYING +28 -0
- data/dependencies/libogg/include/ogg/ogg.h +209 -0
- data/dependencies/libogg/include/ogg/os_types.h +147 -0
- data/dependencies/libogg/src/bitwise.c +857 -0
- data/dependencies/libogg/src/framing.c +2089 -0
- data/dependencies/libvorbis/AUTHORS +3 -0
- data/dependencies/libvorbis/CHANGES +126 -0
- data/dependencies/libvorbis/COPYING +28 -0
- data/dependencies/libvorbis/include/vorbis/codec.h +243 -0
- data/dependencies/libvorbis/include/vorbis/vorbisenc.h +436 -0
- data/dependencies/libvorbis/include/vorbis/vorbisfile.h +206 -0
- data/dependencies/libvorbis/lib/analysis.c +120 -0
- data/dependencies/libvorbis/lib/backends.h +144 -0
- data/dependencies/libvorbis/lib/barkmel.c +64 -0
- data/dependencies/libvorbis/lib/bitrate.c +253 -0
- data/dependencies/libvorbis/lib/bitrate.h +59 -0
- data/dependencies/libvorbis/lib/block.c +1046 -0
- data/dependencies/libvorbis/lib/books/coupled/res_books_51.h +12257 -0
- data/dependencies/libvorbis/lib/books/coupled/res_books_stereo.h +15783 -0
- data/dependencies/libvorbis/lib/books/floor/floor_books.h +1547 -0
- data/dependencies/libvorbis/lib/books/uncoupled/res_books_uncoupled.h +7758 -0
- data/dependencies/libvorbis/lib/codebook.c +479 -0
- data/dependencies/libvorbis/lib/codebook.h +119 -0
- data/dependencies/libvorbis/lib/codec_internal.h +167 -0
- data/dependencies/libvorbis/lib/envelope.c +375 -0
- data/dependencies/libvorbis/lib/envelope.h +80 -0
- data/dependencies/libvorbis/lib/floor0.c +222 -0
- data/dependencies/libvorbis/lib/floor1.c +1099 -0
- data/dependencies/libvorbis/lib/highlevel.h +58 -0
- data/dependencies/libvorbis/lib/info.c +664 -0
- data/dependencies/libvorbis/lib/lookup.c +94 -0
- data/dependencies/libvorbis/lib/lookup.h +32 -0
- data/dependencies/libvorbis/lib/lookup_data.h +192 -0
- data/dependencies/libvorbis/lib/lpc.c +160 -0
- data/dependencies/libvorbis/lib/lpc.h +29 -0
- data/dependencies/libvorbis/lib/lsp.c +456 -0
- data/dependencies/libvorbis/lib/lsp.h +28 -0
- data/dependencies/libvorbis/lib/mapping0.c +816 -0
- data/dependencies/libvorbis/lib/masking.h +785 -0
- data/dependencies/libvorbis/lib/mdct.c +563 -0
- data/dependencies/libvorbis/lib/mdct.h +71 -0
- data/dependencies/libvorbis/lib/misc.h +57 -0
- data/dependencies/libvorbis/lib/modes/floor_all.h +260 -0
- data/dependencies/libvorbis/lib/modes/psych_11.h +51 -0
- data/dependencies/libvorbis/lib/modes/psych_16.h +133 -0
- data/dependencies/libvorbis/lib/modes/psych_44.h +642 -0
- data/dependencies/libvorbis/lib/modes/psych_8.h +101 -0
- data/dependencies/libvorbis/lib/modes/residue_16.h +163 -0
- data/dependencies/libvorbis/lib/modes/residue_44.h +292 -0
- data/dependencies/libvorbis/lib/modes/residue_44p51.h +451 -0
- data/dependencies/libvorbis/lib/modes/residue_44u.h +318 -0
- data/dependencies/libvorbis/lib/modes/residue_8.h +109 -0
- data/dependencies/libvorbis/lib/modes/setup_11.h +143 -0
- data/dependencies/libvorbis/lib/modes/setup_16.h +153 -0
- data/dependencies/libvorbis/lib/modes/setup_22.h +128 -0
- data/dependencies/libvorbis/lib/modes/setup_32.h +132 -0
- data/dependencies/libvorbis/lib/modes/setup_44.h +117 -0
- data/dependencies/libvorbis/lib/modes/setup_44p51.h +74 -0
- data/dependencies/libvorbis/lib/modes/setup_44u.h +74 -0
- data/dependencies/libvorbis/lib/modes/setup_8.h +149 -0
- data/dependencies/libvorbis/lib/modes/setup_X.h +225 -0
- data/dependencies/libvorbis/lib/os.h +186 -0
- data/dependencies/libvorbis/lib/psy.c +1203 -0
- data/dependencies/libvorbis/lib/psy.h +154 -0
- data/dependencies/libvorbis/lib/psytune.c +524 -0
- data/dependencies/libvorbis/lib/registry.c +45 -0
- data/dependencies/libvorbis/lib/registry.h +32 -0
- data/dependencies/libvorbis/lib/res0.c +889 -0
- data/dependencies/libvorbis/lib/scales.h +90 -0
- data/dependencies/libvorbis/lib/sharedbook.c +579 -0
- data/dependencies/libvorbis/lib/smallft.c +1255 -0
- data/dependencies/libvorbis/lib/smallft.h +34 -0
- data/dependencies/libvorbis/lib/synthesis.c +184 -0
- data/dependencies/libvorbis/lib/tone.c +54 -0
- data/dependencies/libvorbis/lib/vorbisenc.c +1215 -0
- data/dependencies/libvorbis/lib/vorbisfile.c +2337 -0
- data/dependencies/libvorbis/lib/window.c +2135 -0
- data/dependencies/libvorbis/lib/window.h +26 -0
- data/dependencies/ogg_vorbis.license +28 -0
- data/lib/gosu/swig_patches.rb +2 -2
- data/linux/extconf.rb +17 -3
- metadata +96 -17
- data/Gosu/ButtonsX.hpp +0 -141
- data/GosuImpl/Audio/AudioSDL.cpp +0 -315
data/GosuImpl/Audio/AudioSDL.cpp
DELETED
@@ -1,315 +0,0 @@
|
|
1
|
-
#include <Gosu/Audio.hpp>
|
2
|
-
#include <Gosu/Math.hpp>
|
3
|
-
#include <Gosu/IO.hpp>
|
4
|
-
#include <Gosu/Utility.hpp>
|
5
|
-
#include <cassert>
|
6
|
-
#include <cstdlib>
|
7
|
-
#include <algorithm>
|
8
|
-
#include <map>
|
9
|
-
#include <stdexcept>
|
10
|
-
#include <vector>
|
11
|
-
|
12
|
-
#include <SDL.h>
|
13
|
-
#include <SDL_mixer.h>
|
14
|
-
|
15
|
-
namespace Gosu {
|
16
|
-
namespace {
|
17
|
-
GOSU_NORETURN void throwLastSDLError() {
|
18
|
-
throw std::runtime_error(Mix_GetError());
|
19
|
-
}
|
20
|
-
|
21
|
-
bool noSound = false;
|
22
|
-
Song* curSong = NULL;
|
23
|
-
|
24
|
-
void requireSDLMixer()
|
25
|
-
{
|
26
|
-
static bool mixerInitialized = false;
|
27
|
-
if (mixerInitialized)
|
28
|
-
return;
|
29
|
-
if (SDL_Init(SDL_INIT_AUDIO) || Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 4096) < 0)
|
30
|
-
noSound = true;
|
31
|
-
std::atexit(Mix_CloseAudio);
|
32
|
-
mixerInitialized = true;
|
33
|
-
}
|
34
|
-
}
|
35
|
-
|
36
|
-
std::map<int, int> channelRegistry;
|
37
|
-
}
|
38
|
-
|
39
|
-
bool Gosu::SampleInstance::alive() const
|
40
|
-
{
|
41
|
-
return !noSound && channelRegistry[handle] == extra &&
|
42
|
-
Mix_Playing(handle) == 1;
|
43
|
-
}
|
44
|
-
|
45
|
-
Gosu::SampleInstance::SampleInstance(int handle, int extra)
|
46
|
-
: handle(handle), extra(extra)
|
47
|
-
{
|
48
|
-
}
|
49
|
-
|
50
|
-
bool Gosu::SampleInstance::playing() const
|
51
|
-
{
|
52
|
-
return alive() && !Mix_Paused(handle);
|
53
|
-
}
|
54
|
-
|
55
|
-
void Gosu::SampleInstance::resume()
|
56
|
-
{
|
57
|
-
if (alive())
|
58
|
-
Mix_Resume(handle);
|
59
|
-
}
|
60
|
-
|
61
|
-
void Gosu::SampleInstance::pause()
|
62
|
-
{
|
63
|
-
if (alive())
|
64
|
-
Mix_Pause(handle);
|
65
|
-
}
|
66
|
-
|
67
|
-
bool Gosu::SampleInstance::paused() const
|
68
|
-
{
|
69
|
-
return alive() && Mix_Paused(handle);
|
70
|
-
}
|
71
|
-
|
72
|
-
void Gosu::SampleInstance::stop()
|
73
|
-
{
|
74
|
-
if (alive())
|
75
|
-
Mix_HaltChannel(handle);
|
76
|
-
}
|
77
|
-
|
78
|
-
void Gosu::SampleInstance::changeVolume(double volume)
|
79
|
-
{
|
80
|
-
if (alive())
|
81
|
-
Mix_Volume(handle, clamp<int>(volume * 255, 0, 255));
|
82
|
-
}
|
83
|
-
|
84
|
-
void Gosu::SampleInstance::changePan(double pan)
|
85
|
-
{
|
86
|
-
int rightPan = clamp<int>(pan * 127, 0, 127);
|
87
|
-
if (alive())
|
88
|
-
Mix_SetPanning(handle, 254 - rightPan, rightPan);
|
89
|
-
}
|
90
|
-
|
91
|
-
void Gosu::SampleInstance::changeSpeed(double speed)
|
92
|
-
{
|
93
|
-
/* We ignore the speed for now as this seems to be non-trivial
|
94
|
-
* with SDL_mixer. */
|
95
|
-
}
|
96
|
-
|
97
|
-
struct Gosu::Sample::SampleData
|
98
|
-
{
|
99
|
-
Mix_Chunk* rep;
|
100
|
-
std::vector<Uint8> buffer;
|
101
|
-
|
102
|
-
SampleData(): rep(0) {}
|
103
|
-
~SampleData() {
|
104
|
-
if (rep != 0) Mix_FreeChunk(rep);
|
105
|
-
}
|
106
|
-
};
|
107
|
-
|
108
|
-
Gosu::Sample::Sample(const std::wstring& filename)
|
109
|
-
{
|
110
|
-
requireSDLMixer();
|
111
|
-
|
112
|
-
if (noSound)
|
113
|
-
return;
|
114
|
-
|
115
|
-
data.reset(new SampleData);
|
116
|
-
// Saved locally because Mix_LoadWAV is a macro, wouldn't trust it...
|
117
|
-
std::string filenameUTF8 = wstringToUTF8(filename);
|
118
|
-
data->rep = Mix_LoadWAV(filenameUTF8.c_str());
|
119
|
-
if (data->rep == NULL)
|
120
|
-
throwLastSDLError();
|
121
|
-
}
|
122
|
-
|
123
|
-
Gosu::Sample::Sample(Reader reader)
|
124
|
-
: data(new SampleData)
|
125
|
-
{
|
126
|
-
requireSDLMixer();
|
127
|
-
|
128
|
-
if (noSound)
|
129
|
-
return;
|
130
|
-
|
131
|
-
data->buffer.resize(reader.resource().size() - reader.position());
|
132
|
-
reader.read(&data->buffer[0], data->buffer.size());
|
133
|
-
|
134
|
-
data->rep = Mix_LoadWAV_RW(SDL_RWFromMem(&data->buffer[0], data->buffer.size()), 1);
|
135
|
-
if (data->rep == NULL)
|
136
|
-
throwLastSDLError();
|
137
|
-
}
|
138
|
-
|
139
|
-
Gosu::SampleInstance Gosu::Sample::play(double volume, double speed,
|
140
|
-
bool looping) const {
|
141
|
-
int channel;
|
142
|
-
|
143
|
-
if (noSound || (channel = Mix_PlayChannel(-1, data->rep, looping ? -1 : 0)) == -1)
|
144
|
-
return SampleInstance(-1, -1);
|
145
|
-
|
146
|
-
int extra = ++channelRegistry[channel];
|
147
|
-
SampleInstance result(channel, extra);
|
148
|
-
|
149
|
-
if (volume != 1)
|
150
|
-
result.changeVolume(volume);
|
151
|
-
|
152
|
-
return result;
|
153
|
-
|
154
|
-
/* We ignore the speed for now as this seems to be non-trivial
|
155
|
-
* with SDL_mixer. */
|
156
|
-
}
|
157
|
-
|
158
|
-
Gosu::SampleInstance Gosu::Sample::playPan(double pan, double volume,
|
159
|
-
double speed, bool looping) const {
|
160
|
-
int channel;
|
161
|
-
|
162
|
-
if (noSound || (channel = Mix_PlayChannel(-1, data->rep, looping ? -1 : 0)) == -1)
|
163
|
-
return SampleInstance(-1, -1);
|
164
|
-
|
165
|
-
int extra = ++channelRegistry[channel];
|
166
|
-
SampleInstance result(channel, extra);
|
167
|
-
|
168
|
-
result.changePan(pan);
|
169
|
-
|
170
|
-
if (volume != 1)
|
171
|
-
result.changeVolume(volume);
|
172
|
-
|
173
|
-
return result;
|
174
|
-
|
175
|
-
/* Speed ignored for now, as above. */
|
176
|
-
}
|
177
|
-
|
178
|
-
// No class hierarchy here; SDL_mixer abstracts this away for us.
|
179
|
-
class Gosu::Song::BaseData {
|
180
|
-
public:
|
181
|
-
Mix_Music* music;
|
182
|
-
// std::vector<Uint8> buffer; - used by constructor that has been commented out
|
183
|
-
double volume;
|
184
|
-
|
185
|
-
BaseData() : music(0), volume(1.0) {}
|
186
|
-
~BaseData() {
|
187
|
-
if (music) Mix_FreeMusic(music);
|
188
|
-
}
|
189
|
-
|
190
|
-
static void endSongCallback() {
|
191
|
-
curSong = 0;
|
192
|
-
}
|
193
|
-
};
|
194
|
-
|
195
|
-
Gosu::Song::Song(const std::wstring& filename)
|
196
|
-
: data(new BaseData)
|
197
|
-
{
|
198
|
-
requireSDLMixer();
|
199
|
-
|
200
|
-
if (noSound)
|
201
|
-
return;
|
202
|
-
|
203
|
-
data->music = Mix_LoadMUS(Gosu::wstringToUTF8(filename).c_str());
|
204
|
-
if (data->music == NULL)
|
205
|
-
throwLastSDLError();
|
206
|
-
|
207
|
-
Mix_HookMusicFinished(BaseData::endSongCallback);
|
208
|
-
}
|
209
|
-
|
210
|
-
Gosu::Song::Song(Reader reader)
|
211
|
-
: data(new BaseData)
|
212
|
-
{
|
213
|
-
requireSDLMixer();
|
214
|
-
|
215
|
-
if (noSound)
|
216
|
-
return;
|
217
|
-
#if 0
|
218
|
-
// This is traditionally broken in SDL_mixer. File bugs :)
|
219
|
-
|
220
|
-
data->buffer.resize(reader.resource().size() - reader.position());
|
221
|
-
reader.read(data->buffer.data(), data->buffer.size());
|
222
|
-
data->music = Mix_LoadMUS_RW(SDL_RWFromMem(data->buffer.data(), bufsize));
|
223
|
-
if (data->music == NULL)
|
224
|
-
throwLastSDLError();
|
225
|
-
|
226
|
-
Mix_HookMusicFinished(BaseData::endSongCallback);
|
227
|
-
#else
|
228
|
-
throw std::runtime_error("Loading files from memory not possible with libSDL_mixer");
|
229
|
-
#endif
|
230
|
-
}
|
231
|
-
|
232
|
-
Gosu::Song::~Song() {
|
233
|
-
stop();
|
234
|
-
}
|
235
|
-
|
236
|
-
Gosu::Song* Gosu::Song::currentSong() {
|
237
|
-
return curSong;
|
238
|
-
}
|
239
|
-
|
240
|
-
void Gosu::Song::play(bool looping) {
|
241
|
-
if (noSound)
|
242
|
-
return;
|
243
|
-
|
244
|
-
if (curSong && curSong != this)
|
245
|
-
{
|
246
|
-
curSong->stop();
|
247
|
-
assert(curSong == 0);
|
248
|
-
}
|
249
|
-
|
250
|
-
if (Mix_PausedMusic())
|
251
|
-
Mix_ResumeMusic();
|
252
|
-
if (!playing() && Mix_PlayMusic(data->music, looping ? -1 : 0) < 0)
|
253
|
-
throwLastSDLError();
|
254
|
-
changeVolume(data->volume);
|
255
|
-
curSong = this;
|
256
|
-
}
|
257
|
-
|
258
|
-
void Gosu::Song::pause()
|
259
|
-
{
|
260
|
-
if (curSong == this)
|
261
|
-
Mix_PauseMusic();
|
262
|
-
}
|
263
|
-
|
264
|
-
bool Gosu::Song::paused() const
|
265
|
-
{
|
266
|
-
return curSong == this && Mix_PausedMusic();
|
267
|
-
}
|
268
|
-
|
269
|
-
void Gosu::Song::stop() {
|
270
|
-
if (curSong == this) {
|
271
|
-
Mix_HaltMusic();
|
272
|
-
curSong = 0;
|
273
|
-
}
|
274
|
-
}
|
275
|
-
|
276
|
-
bool Gosu::Song::playing() const {
|
277
|
-
return curSong == this && !paused();
|
278
|
-
}
|
279
|
-
|
280
|
-
double Gosu::Song::volume() const {
|
281
|
-
return data->volume;
|
282
|
-
}
|
283
|
-
|
284
|
-
void Gosu::Song::changeVolume(double volume) {
|
285
|
-
data->volume = clamp(volume, 0.0, 1.0);
|
286
|
-
|
287
|
-
if (playing())
|
288
|
-
Mix_VolumeMusic(trunc(data->volume * MIX_MAX_VOLUME));
|
289
|
-
}
|
290
|
-
|
291
|
-
void Gosu::Song::update()
|
292
|
-
{
|
293
|
-
}
|
294
|
-
|
295
|
-
// Deprecated constructors.
|
296
|
-
|
297
|
-
Gosu::Sample::Sample(Audio& audio, const std::wstring& filename)
|
298
|
-
{
|
299
|
-
Sample(filename).data.swap(data);
|
300
|
-
}
|
301
|
-
|
302
|
-
Gosu::Sample::Sample(Audio& audio, Reader reader)
|
303
|
-
{
|
304
|
-
Sample(reader).data.swap(data);
|
305
|
-
}
|
306
|
-
|
307
|
-
Gosu::Song::Song(Audio& audio, const std::wstring& filename)
|
308
|
-
{
|
309
|
-
data = Song(filename).data;
|
310
|
-
}
|
311
|
-
|
312
|
-
Gosu::Song::Song(Audio& audio, Type type, Reader reader)
|
313
|
-
{
|
314
|
-
data = Song(reader).data;
|
315
|
-
}
|