gosu 0.10.6 → 0.10.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/COPYING +1 -1
- data/Gosu/Gosu.hpp +1 -1
- data/Gosu/Version.hpp +3 -3
- data/README.md +4 -0
- data/ext/gosu/extconf.rb +8 -8
- data/ext/gosu/gosu_wrap.cxx +12 -7
- data/src/AppleUtility.hpp +19 -62
- data/src/Audio/Audio.cpp +31 -23
- data/src/Audio/AudioToolboxFile.hpp +19 -18
- data/src/Bitmap/BitmapIO.cpp +32 -17
- data/src/DirectoriesApple.mm +36 -41
- data/src/Input/Input.cpp +22 -6
- data/src/Input/InputUIKit.mm +37 -29
- data/src/Text/Font.cpp +1 -1
- data/src/Text/TextApple.mm +50 -41
- data/src/UIKit/GosuAppDelegate.mm +1 -1
- data/src/UIKit/GosuGLView.mm +0 -2
- data/src/UIKit/GosuViewController.mm +7 -10
- data/src/UtilityApple.mm +26 -19
- data/src/WindowUIKit.mm +22 -12
- data/src/stb_image.h +499 -253
- data/src/stb_image_write.h +98 -43
- data/src/stb_vorbis.c +188 -232
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 59c5dceec74b7859dc96acf2a9e32f20dd3b62c3
|
4
|
+
data.tar.gz: 8ac26d8b8d1e74459c29e96b69079a5ba011c5df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e25c8c25c6590a2e7edff4a85c6117b0713ae2777cc876960f35205f0e28b2db62dc9cf763659c092781f015dd1cce133b6d11653e1fc4825406f9a2b4e84b44
|
7
|
+
data.tar.gz: 5e91b843c9f632277ee54546d9c97dda40b6067ca49b6ee1cca1230c7a1b710eb0b0df9006b6903ec5a3f62d3888e5e367d88fe899da1f06945be6d57c8b509f
|
data/COPYING
CHANGED
data/Gosu/Gosu.hpp
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
//!
|
6
6
|
//! These pages serve as a reference on the C++ interface of Gosu. For a higher-level
|
7
7
|
//! discussion of concepts and ideas behind the library, see the Wiki entries linked
|
8
|
-
//! from the official website,
|
8
|
+
//! from the official website, https://www.libgosu.org/.
|
9
9
|
|
10
10
|
#ifndef GOSU_GOSU_HPP
|
11
11
|
#define GOSU_GOSU_HPP
|
data/Gosu/Version.hpp
CHANGED
@@ -3,13 +3,13 @@
|
|
3
3
|
|
4
4
|
#define GOSU_MAJOR_VERSION 0
|
5
5
|
#define GOSU_MINOR_VERSION 10
|
6
|
-
#define GOSU_POINT_VERSION
|
7
|
-
#define GOSU_VERSION "0.10.
|
6
|
+
#define GOSU_POINT_VERSION 7
|
7
|
+
#define GOSU_VERSION "0.10.7"
|
8
8
|
|
9
9
|
#define GOSU_COPYRIGHT_NOTICE \
|
10
10
|
"This software uses the following third-party libraries:\n" \
|
11
11
|
"\n" \
|
12
|
-
"Gosu,
|
12
|
+
"Gosu, https://www.libgosu.org, MIT License, http://opensource.org/licenses/MIT\n" \
|
13
13
|
"SDL 2, http://www.libsdl.org, MIT License, http://opensource.org/licenses/MIT\n" \
|
14
14
|
"libsndfile, http://www.mega-nerd.com/libsndfile, GNU LGPL 3, http://www.gnu.org/copyleft/lesser.html\n" \
|
15
15
|
"OpenAL Soft, http://kcat.strangesoft.net/openal.html, GNU LGPL 2, http://www.gnu.org/licenses/old-licenses/lgpl-2.0.html\n"
|
data/README.md
CHANGED
@@ -14,3 +14,7 @@ Complaints, questions, feedback?
|
|
14
14
|
- Visit the [boards](https://www.libgosu.org/)
|
15
15
|
- Try your luck in the (mostly idle) [IRC channel](https://webchat.freenode.net/?channels=gosu)
|
16
16
|
- Or [email me](mailto:julian@raschke.de) :)
|
17
|
+
|
18
|
+
[![Build Status](https://travis-ci.org/gosu/gosu.svg?branch=master)](https://travis-ci.org/gosu/gosu) Linux and OS X builds
|
19
|
+
|
20
|
+
[![Build status](https://ci.appveyor.com/api/projects/status/v0liohs47jono1eq?svg=true)](https://ci.appveyor.com/project/gosu-ci/gosu) Windows builds
|
data/ext/gosu/extconf.rb
CHANGED
@@ -11,9 +11,9 @@ end
|
|
11
11
|
puts 'The Gosu gem requires some libraries to be installed system-wide.'
|
12
12
|
puts 'See the following site for a list:'
|
13
13
|
if `uname`.chomp == "Darwin" then
|
14
|
-
puts 'https://github.com/
|
14
|
+
puts 'https://github.com/gosu/gosu/wiki/Getting-Started-on-OS-X'
|
15
15
|
else
|
16
|
-
puts 'https://github.com/
|
16
|
+
puts 'https://github.com/gosu/gosu/wiki/Getting-Started-on-Linux'
|
17
17
|
end
|
18
18
|
puts
|
19
19
|
|
@@ -134,8 +134,8 @@ end
|
|
134
134
|
# inside folders, it will not find the resulting .o files during linking.
|
135
135
|
# So we create a shim .c/.cpp file for each file that we want to compile, ensuring
|
136
136
|
# that all .o files are built into the current directory, without any nesting.
|
137
|
-
# TODO
|
138
|
-
#
|
137
|
+
# TODO: Just move all of Gosu's source files back into a flat hierarchy again.
|
138
|
+
# The nested directory structure has really not been worth it.
|
139
139
|
SOURCE_FILES.each do |file|
|
140
140
|
shim_name = file.gsub('/', '-').sub(/\.mm$/, '.cpp')
|
141
141
|
File.open(shim_name, "w") do |shim|
|
@@ -143,11 +143,11 @@ SOURCE_FILES.each do |file|
|
|
143
143
|
end
|
144
144
|
end
|
145
145
|
|
146
|
-
if RUBY_VERSION >= '2.
|
147
|
-
# In some versions of Ruby
|
148
|
-
#
|
149
|
-
# modify CONFIG instead, and our changes will end up in the Makefile.
|
146
|
+
if RUBY_VERSION >= '1.9.3' and RUBY_VERSION < '2.2.0' then
|
147
|
+
# In some versions of Ruby and mkmf, the $CXXFLAGS variable is badly broken.
|
148
|
+
# We can modify CONFIG instead, and our changes will end up in the Makefile.
|
150
149
|
# See http://bugs.ruby-lang.org/issues/8315
|
150
|
+
# The lower bound was reduced to 1.9.3 here: https://github.com/gosu/gosu/issues/321
|
151
151
|
CONFIG['CXXFLAGS'] = "#$CFLAGS #$CXXFLAGS"
|
152
152
|
end
|
153
153
|
|
data/ext/gosu/gosu_wrap.cxx
CHANGED
@@ -3098,14 +3098,14 @@ bool SwigDirector_Window::tick() {
|
|
3098
3098
|
void SwigDirector_Window::update() {
|
3099
3099
|
VALUE result;
|
3100
3100
|
|
3101
|
-
result = rb_funcall(swig_get_self(), rb_intern("
|
3101
|
+
result = rb_funcall(swig_get_self(), rb_intern("update"), 0, NULL);
|
3102
3102
|
}
|
3103
3103
|
|
3104
3104
|
|
3105
3105
|
void SwigDirector_Window::draw() {
|
3106
3106
|
VALUE result;
|
3107
3107
|
|
3108
|
-
result = rb_funcall(swig_get_self(), rb_intern("
|
3108
|
+
result = rb_funcall(swig_get_self(), rb_intern("draw"), 0, NULL);
|
3109
3109
|
}
|
3110
3110
|
|
3111
3111
|
|
@@ -3113,7 +3113,7 @@ bool SwigDirector_Window::needsRedraw() const {
|
|
3113
3113
|
bool c_result ;
|
3114
3114
|
VALUE result;
|
3115
3115
|
|
3116
|
-
result = rb_funcall(swig_get_self(), rb_intern("
|
3116
|
+
result = rb_funcall(swig_get_self(), rb_intern("needs_redraw?"), 0, NULL);
|
3117
3117
|
bool swig_val;
|
3118
3118
|
int swig_res = SWIG_AsVal_bool(result, &swig_val);
|
3119
3119
|
if (!SWIG_IsOK(swig_res)) {
|
@@ -3128,7 +3128,7 @@ bool SwigDirector_Window::needsCursor() const {
|
|
3128
3128
|
bool c_result ;
|
3129
3129
|
VALUE result;
|
3130
3130
|
|
3131
|
-
result = rb_funcall(swig_get_self(), rb_intern("
|
3131
|
+
result = rb_funcall(swig_get_self(), rb_intern("needs_cursor?"), 0, NULL);
|
3132
3132
|
bool swig_val;
|
3133
3133
|
int swig_res = SWIG_AsVal_bool(result, &swig_val);
|
3134
3134
|
if (!SWIG_IsOK(swig_res)) {
|
@@ -3142,7 +3142,7 @@ bool SwigDirector_Window::needsCursor() const {
|
|
3142
3142
|
void SwigDirector_Window::loseFocus() {
|
3143
3143
|
VALUE result;
|
3144
3144
|
|
3145
|
-
result = rb_funcall(swig_get_self(), rb_intern("
|
3145
|
+
result = rb_funcall(swig_get_self(), rb_intern("lose_focus"), 0, NULL);
|
3146
3146
|
}
|
3147
3147
|
|
3148
3148
|
|
@@ -3163,7 +3163,7 @@ void SwigDirector_Window::buttonDown(Gosu::Button arg0) {
|
|
3163
3163
|
else
|
3164
3164
|
obj0 = LONG2NUM((&arg0)->id());
|
3165
3165
|
}
|
3166
|
-
result = rb_funcall(swig_get_self(), rb_intern("
|
3166
|
+
result = rb_funcall(swig_get_self(), rb_intern("button_down"), 1,obj0);
|
3167
3167
|
}
|
3168
3168
|
|
3169
3169
|
|
@@ -3177,7 +3177,7 @@ void SwigDirector_Window::buttonUp(Gosu::Button arg0) {
|
|
3177
3177
|
else
|
3178
3178
|
obj0 = LONG2NUM((&arg0)->id());
|
3179
3179
|
}
|
3180
|
-
result = rb_funcall(swig_get_self(), rb_intern("
|
3180
|
+
result = rb_funcall(swig_get_self(), rb_intern("button_up"), 1,obj0);
|
3181
3181
|
}
|
3182
3182
|
|
3183
3183
|
|
@@ -11342,6 +11342,11 @@ SWIGEXPORT void Init_gosu(void) {
|
|
11342
11342
|
rb_define_const(mGosu, "Gp3Button13", SWIG_From_int(static_cast< int >(Gosu::gp3Button13)));
|
11343
11343
|
rb_define_const(mGosu, "Gp3Button14", SWIG_From_int(static_cast< int >(Gosu::gp3Button14)));
|
11344
11344
|
rb_define_const(mGosu, "Gp3Button15", SWIG_From_int(static_cast< int >(Gosu::gp3Button15)));
|
11345
|
+
|
11346
|
+
// Call srand() so that Gosu::random() is actually random in Ruby scripts
|
11347
|
+
std::srand(static_cast<unsigned int>(std::time(0)));
|
11348
|
+
std::rand(); // and flush the first value
|
11349
|
+
|
11345
11350
|
rb_define_module_function(mGosu, "disown_TextInput", VALUEFUNC(_wrap_disown_TextInput), -1);
|
11346
11351
|
|
11347
11352
|
SwigClassTextInput.klass = rb_define_class_under(mGosu, "TextInput", rb_cObject);
|
data/src/AppleUtility.hpp
CHANGED
@@ -2,72 +2,27 @@
|
|
2
2
|
#define GOSU_APPLEUTILITY_HPP
|
3
3
|
|
4
4
|
#include <Gosu/Platform.hpp>
|
5
|
+
#include <CoreFoundation/CoreFoundation.h>
|
5
6
|
|
6
7
|
#ifdef __OBJC__
|
7
8
|
|
8
|
-
#include <iostream>
|
9
|
-
#include <ostream>
|
10
|
-
#include <sstream>
|
11
9
|
#include <string>
|
12
10
|
#include <stdexcept>
|
13
|
-
#include <objc/objc.h>
|
14
|
-
#import <CoreFoundation/CoreFoundation.h>
|
15
11
|
#import <Foundation/Foundation.h>
|
16
12
|
|
17
|
-
|
13
|
+
inline static void throwOSError(OSStatus status, unsigned line)
|
18
14
|
{
|
19
|
-
|
20
|
-
{
|
21
|
-
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
15
|
+
@autoreleasepool {
|
22
16
|
NSError *error = [NSError errorWithDomain:NSOSStatusErrorDomain code:status userInfo:nil];
|
23
|
-
std::
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
[pool release];
|
28
|
-
throw std::runtime_error(str.str());
|
17
|
+
throw std::runtime_error("Error on line " + std::to_string(line) +
|
18
|
+
" (Code " + std::to_string(status) + "): " +
|
19
|
+
error.localizedDescription.UTF8String +
|
20
|
+
" (" + error.description.UTF8String + ")");
|
29
21
|
}
|
30
|
-
|
31
|
-
#define CHECK_OS(status) if (!(status)) {} else Gosu::throwOSError(status, __LINE__)
|
32
|
-
|
33
|
-
template<typename T>
|
34
|
-
class ObjCRef
|
35
|
-
{
|
36
|
-
ObjCRef(const ObjCRef&);
|
37
|
-
ObjCRef& operator=(const ObjCRef&);
|
38
|
-
|
39
|
-
T* ptr;
|
40
|
-
|
41
|
-
public:
|
42
|
-
ObjCRef(T* ptr = nil)
|
43
|
-
: ptr(ptr)
|
44
|
-
{
|
45
|
-
}
|
46
|
-
|
47
|
-
~ObjCRef()
|
48
|
-
{
|
49
|
-
[ptr release];
|
50
|
-
}
|
51
|
-
|
52
|
-
void reset(T* newPtr = nil)
|
53
|
-
{
|
54
|
-
[ptr release];
|
55
|
-
ptr = newPtr;
|
56
|
-
}
|
57
|
-
|
58
|
-
T* get() const
|
59
|
-
{
|
60
|
-
return ptr;
|
61
|
-
}
|
62
|
-
|
63
|
-
T* obj() const
|
64
|
-
{
|
65
|
-
if (!ptr)
|
66
|
-
throw std::logic_error("Objective-C reference is nil");
|
67
|
-
return ptr;
|
68
|
-
}
|
69
|
-
};
|
70
22
|
}
|
23
|
+
|
24
|
+
#define CHECK_OS(status) do { if (status) throwOSError(status, __LINE__); } while (0)
|
25
|
+
|
71
26
|
#endif
|
72
27
|
|
73
28
|
namespace Gosu
|
@@ -75,23 +30,24 @@ namespace Gosu
|
|
75
30
|
template<typename CFRefType = CFTypeRef>
|
76
31
|
class CFRef
|
77
32
|
{
|
78
|
-
CFRef(const CFRef&);
|
79
|
-
CFRef& operator=(const CFRef&);
|
80
|
-
|
81
33
|
CFRefType ref;
|
82
34
|
|
83
35
|
public:
|
84
36
|
CFRef(CFRefType ref)
|
85
|
-
:
|
37
|
+
: ref(ref)
|
86
38
|
{
|
87
39
|
}
|
88
40
|
|
89
41
|
~CFRef()
|
90
42
|
{
|
91
|
-
if (ref)
|
43
|
+
if (ref) {
|
92
44
|
CFRelease(ref);
|
45
|
+
}
|
93
46
|
}
|
94
|
-
|
47
|
+
|
48
|
+
CFRef(const CFRef&) = delete;
|
49
|
+
CFRef& operator=(const CFRef&) = delete;
|
50
|
+
|
95
51
|
CFRefType get() const
|
96
52
|
{
|
97
53
|
return ref;
|
@@ -99,8 +55,9 @@ namespace Gosu
|
|
99
55
|
|
100
56
|
CFRefType obj() const
|
101
57
|
{
|
102
|
-
if (!ref)
|
58
|
+
if (!ref) {
|
103
59
|
throw std::logic_error("CoreFoundation reference is NULL");
|
60
|
+
}
|
104
61
|
return ref;
|
105
62
|
}
|
106
63
|
};
|
data/src/Audio/Audio.cpp
CHANGED
@@ -58,15 +58,18 @@ namespace
|
|
58
58
|
// TODO: What is this NSAutoreleasePool good for?
|
59
59
|
#ifdef GOSU_IS_MAC
|
60
60
|
#include "../AppleUtility.hpp"
|
61
|
-
#define
|
62
|
-
|
61
|
+
#define CONSTRUCTOR_BEGIN \
|
62
|
+
@autoreleasepool { \
|
63
63
|
if (!alChannelManagement.get()) \
|
64
64
|
alChannelManagement.reset(new ALChannelManagement)
|
65
|
+
#define CONSTRUCTOR_END \
|
66
|
+
}
|
65
67
|
#else
|
66
|
-
#define
|
68
|
+
#define CONSTRUCTOR_BEGIN \
|
67
69
|
if (!alChannelManagement.get()) \
|
68
70
|
alChannelManagement.reset(new ALChannelManagement)
|
69
|
-
#
|
71
|
+
#define CONSTRUCTOR_END
|
72
|
+
#endif
|
70
73
|
|
71
74
|
Gosu::SampleInstance::SampleInstance(int handle, int extra)
|
72
75
|
: handle(handle), extra(extra)
|
@@ -175,7 +178,7 @@ private:
|
|
175
178
|
|
176
179
|
Gosu::Sample::Sample(const std::wstring& filename)
|
177
180
|
{
|
178
|
-
|
181
|
+
CONSTRUCTOR_BEGIN;
|
179
182
|
|
180
183
|
if (isOggFile(filename))
|
181
184
|
{
|
@@ -189,11 +192,13 @@ Gosu::Sample::Sample(const std::wstring& filename)
|
|
189
192
|
WAVE_FILE audioFile(filename);
|
190
193
|
data.reset(new SampleData(audioFile));
|
191
194
|
}
|
195
|
+
|
196
|
+
CONSTRUCTOR_END
|
192
197
|
}
|
193
198
|
|
194
199
|
Gosu::Sample::Sample(Reader reader)
|
195
200
|
{
|
196
|
-
|
201
|
+
CONSTRUCTOR_BEGIN;
|
197
202
|
|
198
203
|
if (isOggFile(reader))
|
199
204
|
{
|
@@ -205,6 +210,8 @@ Gosu::Sample::Sample(Reader reader)
|
|
205
210
|
WAVE_FILE audioFile(reader);
|
206
211
|
data.reset(new SampleData(audioFile));
|
207
212
|
}
|
213
|
+
|
214
|
+
CONSTRUCTOR_END
|
208
215
|
}
|
209
216
|
|
210
217
|
Gosu::SampleInstance Gosu::Sample::play(double volume, double speed,
|
@@ -219,7 +226,7 @@ Gosu::SampleInstance Gosu::Sample::playPan(double pan, double volume,
|
|
219
226
|
std::pair<int, int> channelAndToken = alChannelManagement->reserveChannel();
|
220
227
|
if (channelAndToken.first == ALChannelManagement::NO_FREE_CHANNEL)
|
221
228
|
return Gosu::SampleInstance(channelAndToken.first, channelAndToken.second);
|
222
|
-
|
229
|
+
|
223
230
|
ALuint source = alChannelManagement->sourceIfStillPlaying(channelAndToken.first,
|
224
231
|
channelAndToken.second);
|
225
232
|
assert(source != ALChannelManagement::NO_SOURCE);
|
@@ -272,49 +279,49 @@ public:
|
|
272
279
|
// AVAudioPlayer impl
|
273
280
|
class Gosu::Song::ModuleData : public BaseData
|
274
281
|
{
|
275
|
-
|
282
|
+
AVAudioPlayer *player;
|
276
283
|
|
277
284
|
void applyVolume()
|
278
285
|
{
|
279
|
-
player.
|
286
|
+
player.volume = volume();
|
280
287
|
}
|
281
288
|
|
282
289
|
public:
|
283
290
|
ModuleData(const std::wstring& filename)
|
284
291
|
{
|
285
292
|
std::string utf8Filename = Gosu::wstringToUTF8(filename);
|
286
|
-
|
287
|
-
|
288
|
-
player.reset([[AVAudioPlayer alloc] initWithContentsOfURL:url.obj() error:NULL]);
|
293
|
+
NSURL *URL = [NSURL fileURLWithPath:[NSString stringWithUTF8String:utf8Filename.c_str()]];
|
294
|
+
player = [[AVAudioPlayer alloc] initWithContentsOfURL:URL error:NULL];
|
289
295
|
}
|
290
296
|
|
291
297
|
void play(bool looping)
|
292
298
|
{
|
293
|
-
if (paused())
|
299
|
+
if (paused()) {
|
294
300
|
stop();
|
295
|
-
|
296
|
-
|
301
|
+
}
|
302
|
+
player.numberOfLoops = looping ? -1 : 0;
|
303
|
+
[player play];
|
297
304
|
}
|
298
305
|
|
299
306
|
void pause()
|
300
307
|
{
|
301
|
-
[player
|
308
|
+
[player pause];
|
302
309
|
}
|
303
310
|
|
304
311
|
void resume()
|
305
312
|
{
|
306
|
-
[player
|
313
|
+
[player play];
|
307
314
|
}
|
308
315
|
|
309
316
|
bool paused() const
|
310
317
|
{
|
311
|
-
return !player.
|
318
|
+
return !player.playing;
|
312
319
|
};
|
313
320
|
|
314
321
|
void stop()
|
315
322
|
{
|
316
|
-
[player
|
317
|
-
player.
|
323
|
+
[player stop];
|
324
|
+
player.currentTime = 0;
|
318
325
|
}
|
319
326
|
|
320
327
|
void update()
|
@@ -507,16 +514,17 @@ Gosu::Song::Song(const std::wstring& filename)
|
|
507
514
|
else
|
508
515
|
#endif
|
509
516
|
{
|
510
|
-
|
517
|
+
CONSTRUCTOR_BEGIN;
|
511
518
|
data.reset(new StreamData(filename));
|
519
|
+
CONSTRUCTOR_END
|
512
520
|
}
|
513
521
|
}
|
514
522
|
|
515
523
|
Gosu::Song::Song(Reader reader)
|
516
524
|
{
|
517
|
-
|
518
|
-
|
525
|
+
CONSTRUCTOR_BEGIN;
|
519
526
|
data.reset(new StreamData(reader));
|
527
|
+
CONSTRUCTOR_END
|
520
528
|
}
|
521
529
|
|
522
530
|
Gosu::Song::~Song()
|
@@ -29,7 +29,7 @@ namespace Gosu
|
|
29
29
|
ALuint sampleRate_;
|
30
30
|
UInt32 bytesPerFrame_;
|
31
31
|
bool bigEndian_;
|
32
|
-
|
32
|
+
|
33
33
|
static OSStatus AudioFile_ReadProc(void* inClientData, SInt64 inPosition,
|
34
34
|
UInt32 requestCount, void* buffer, UInt32* actualCount)
|
35
35
|
{
|
@@ -81,9 +81,7 @@ namespace Gosu
|
|
81
81
|
|
82
82
|
initSeekOffset();
|
83
83
|
|
84
|
-
format_ = clientData.mChannelsPerFrame == 1 ?
|
85
|
-
AL_FORMAT_MONO16 :
|
86
|
-
AL_FORMAT_STEREO16;
|
84
|
+
format_ = clientData.mChannelsPerFrame == 1 ? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16;
|
87
85
|
}
|
88
86
|
|
89
87
|
void init()
|
@@ -124,26 +122,28 @@ namespace Gosu
|
|
124
122
|
}
|
125
123
|
|
126
124
|
if (format_ == 0 ||
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
125
|
+
// If format not native for OpenAL, set client data format
|
126
|
+
// to enable conversion
|
127
|
+
desc.mFormatFlags & kAudioFormatFlagIsBigEndian ||
|
128
|
+
desc.mFormatFlags & kAudioFormatFlagIsFloat ||
|
129
|
+
!(desc.mFormatFlags & kAudioFormatFlagIsSignedInteger)) {
|
130
|
+
initClientFormatBasedOn(desc);
|
131
|
+
}
|
132
|
+
else {
|
134
133
|
// Just set the old format as the client format so
|
135
134
|
// ExtAudioFileSeek will work for us.
|
136
135
|
CHECK_OS(ExtAudioFileSetProperty(file_,
|
137
136
|
kExtAudioFileProperty_ClientDataFormat,
|
138
137
|
sizeof desc, &desc));
|
138
|
+
}
|
139
139
|
}
|
140
140
|
|
141
141
|
public:
|
142
142
|
AudioToolboxFile(const std::wstring& filename)
|
143
143
|
{
|
144
|
-
|
145
|
-
|
146
|
-
CHECK_OS(ExtAudioFileOpenURL((CFURLRef)
|
144
|
+
NSString *utf8Filename = [NSString stringWithUTF8String:wstringToUTF8(filename).c_str()];
|
145
|
+
NSURL *URL = [NSURL fileURLWithPath:utf8Filename];
|
146
|
+
CHECK_OS(ExtAudioFileOpenURL((__bridge CFURLRef)URL, &file_));
|
147
147
|
|
148
148
|
fileID_ = 0;
|
149
149
|
|
@@ -155,14 +155,14 @@ namespace Gosu
|
|
155
155
|
buffer_.resize(reader.resource().size() - reader.position());
|
156
156
|
reader.read(buffer_.data(), buffer_.size());
|
157
157
|
|
158
|
-
// TODO:
|
159
|
-
//
|
160
|
-
// used which works for non-compressed formats at least.
|
158
|
+
// TODO: This fails on iOS with MP3 files.
|
159
|
+
// TODO: ^ Is the comment above still true on non-ancient iOS versions?
|
161
160
|
|
162
161
|
void* clientData = &buffer_;
|
163
162
|
CHECK_OS(AudioFileOpenWithCallbacks(clientData, AudioFile_ReadProc, 0,
|
164
163
|
AudioFile_GetSizeProc, 0, 0, &fileID_));
|
165
164
|
CHECK_OS(ExtAudioFileWrapAudioFileID(fileID_, false, &file_));
|
165
|
+
|
166
166
|
init();
|
167
167
|
}
|
168
168
|
|
@@ -170,8 +170,9 @@ namespace Gosu
|
|
170
170
|
{
|
171
171
|
ExtAudioFileDispose(file_);
|
172
172
|
|
173
|
-
if (fileID_)
|
173
|
+
if (fileID_) {
|
174
174
|
AudioFileClose(fileID_);
|
175
|
+
}
|
175
176
|
}
|
176
177
|
|
177
178
|
ALenum format() const
|