summaryrefslogtreecommitdiff
path: root/platform/iphone
diff options
context:
space:
mode:
Diffstat (limited to 'platform/iphone')
-rw-r--r--platform/iphone/SCsub2
-rw-r--r--platform/iphone/app_delegate.mm4
-rw-r--r--platform/iphone/audio_driver_iphone.cpp39
-rw-r--r--platform/iphone/audio_driver_iphone.h4
-rw-r--r--platform/iphone/detect.py13
-rwxr-xr-xplatform/iphone/gl_view.mm6
-rw-r--r--platform/iphone/globals/global_defaults.cpp1
-rw-r--r--platform/iphone/in_app_store.h2
-rw-r--r--platform/iphone/in_app_store.mm31
9 files changed, 89 insertions, 13 deletions
diff --git a/platform/iphone/SCsub b/platform/iphone/SCsub
index 0113f75697..d30d101e1b 100644
--- a/platform/iphone/SCsub
+++ b/platform/iphone/SCsub
@@ -35,7 +35,7 @@ if env['ios_appirater'] == "yes":
obj = env_ios.Object('godot_iphone.cpp')
prog = None
-if env["target"]=="release":
+if env["target"]=="release" or env["target"] == "release_debug":
prog = env_ios.Program('#bin/godot_opt', [obj] + iphone_lib)
#action = "dsymutil "+File(prog)[0].path+" -o ../build/script_exec/build/Debug-iphoneos/script_exec.app.dSYM"
#env.AddPostAction(prog, action)
diff --git a/platform/iphone/app_delegate.mm b/platform/iphone/app_delegate.mm
index 9ba95ff0c5..9877e09ade 100644
--- a/platform/iphone/app_delegate.mm
+++ b/platform/iphone/app_delegate.mm
@@ -257,18 +257,21 @@ static int frame_count = 0;
- (void)applicationDidEnterBackground:(UIApplication *)application
{
printf("********************* did enter background\n");
+ OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT);
[view_controller.view stopAnimation];
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
printf("********************* did enter foreground\n");
+ //OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_FOCUS_IN);
[view_controller.view startAnimation];
}
- (void) applicationWillResignActive:(UIApplication *)application
{
printf("********************* will resign active\n");
+ //OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT);
[view_controller.view stopAnimation]; // FIXME: pause seems to be recommended elsewhere
}
@@ -279,6 +282,7 @@ static int frame_count = 0;
printf("********************* mobile app tracker found\n");
[MobileAppTracker measureSession];
#endif
+ OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_FOCUS_IN);
[view_controller.view startAnimation]; // FIXME: resume seems to be recommended elsewhere
}
diff --git a/platform/iphone/audio_driver_iphone.cpp b/platform/iphone/audio_driver_iphone.cpp
index d39b8f3c4d..c3ba0e6944 100644
--- a/platform/iphone/audio_driver_iphone.cpp
+++ b/platform/iphone/audio_driver_iphone.cpp
@@ -99,7 +99,16 @@ OSStatus AudioDriverIphone::output_callback(void *inRefCon,
AudioBuffer *abuf;
AudioDriverIphone* ad = (AudioDriverIphone*)inRefCon;
- if (!ad->active) {
+ bool mix = true;
+
+ if (!ad->active)
+ mix = false;
+ else if (ad->mutex) {
+ mix = ad->mutex->try_lock() == OK;
+ };
+
+
+ if (!mix) {
for (unsigned int i = 0; i < ioData->mNumberBuffers; i++) {
abuf = &ioData->mBuffers[i];
zeromem(abuf->mData, abuf->mDataByteSize);
@@ -118,9 +127,9 @@ OSStatus AudioDriverIphone::output_callback(void *inRefCon,
while (frames_left) {
int frames = MIN(frames_left, ad->buffer_frames);
- ad->lock();
+ //ad->lock();
ad->audio_server_process(frames, ad->samples_in);
- ad->unlock();
+ //ad->unlock();
for(int i = 0; i < frames * ad->channels; i++) {
@@ -132,6 +141,9 @@ OSStatus AudioDriverIphone::output_callback(void *inRefCon,
};
};
+ if (ad->mutex)
+ ad->mutex->unlock();
+
return 0;
};
@@ -147,11 +159,28 @@ AudioDriverSW::OutputFormat AudioDriverIphone::get_output_format() const {
return OUTPUT_STEREO;
};
-void AudioDriverIphone::lock() {};
-void AudioDriverIphone::unlock() {};
+void AudioDriverIphone::lock() {
+
+ if (active && mutex)
+ mutex->lock();
+};
+
+void AudioDriverIphone::unlock() {
+ if (active && mutex)
+ mutex->unlock();
+};
void AudioDriverIphone::finish() {
memdelete_arr(samples_in);
};
+
+AudioDriverIphone::AudioDriverIphone() {
+
+ mutex=Mutex::create();//NULL;
+};
+
+AudioDriverIphone::~AudioDriverIphone() {
+
+};
diff --git a/platform/iphone/audio_driver_iphone.h b/platform/iphone/audio_driver_iphone.h
index eec54d9ee3..05fa741282 100644
--- a/platform/iphone/audio_driver_iphone.h
+++ b/platform/iphone/audio_driver_iphone.h
@@ -34,6 +34,7 @@ class AudioDriverIphone : public AudioDriverSW {
AudioComponentInstance audio_unit;
bool active;
+ Mutex *mutex;
int channels;
int32_t* samples_in;
@@ -59,5 +60,8 @@ public:
virtual void lock();
virtual void unlock();
virtual void finish();
+
+ AudioDriverIphone();
+ ~AudioDriverIphone();
};
diff --git a/platform/iphone/detect.py b/platform/iphone/detect.py
index ec6e4c98f1..2065d459cd 100644
--- a/platform/iphone/detect.py
+++ b/platform/iphone/detect.py
@@ -28,14 +28,14 @@ def get_opts():
('ios_gles22_override', 'Force GLES2.0 on iOS', 'yes'),
('ios_GLES1_override', 'Force legacy GLES (1.1) on iOS', 'no'),
('ios_appirater', 'Enable Appirater', 'no'),
- ('ios_exceptions', 'Use exceptions when compiling on playbook', 'no'),
+ ('ios_exceptions', 'Use exceptions when compiling on playbook', 'yes'),
]
def get_flags():
return [
('lua', 'no'),
- ('tools', 'yes'),
+ ('tools', 'no'),
('nedmalloc', 'no'),
('webp', 'yes'),
('openssl','builtin'), #use builtin openssl
@@ -104,10 +104,17 @@ def configure(env):
env['OBJSUFFIX'] = "_opt"+env['OBJSUFFIX']
env['LIBSUFFIX'] = "_opt"+env['LIBSUFFIX']
+ elif env["target"] == "release_debug":
+ env.Append(CCFLAGS=['-Os', '-ffast-math', '-DNS_BLOCK_ASSERTIONS=1','-Wall','-DDEBUG_ENABLED'])
+ env.Append(LINKFLAGS=['-Os', '-ffast-math'])
+ env.Append(CPPFLAGS=['-DDEBUG_MEMORY_ENABLED'])
+ env['OBJSUFFIX'] = "_opt"+env['OBJSUFFIX']
+ env['LIBSUFFIX'] = "_opt"+env['LIBSUFFIX']
+
elif (env["target"]=="debug"):
env.Append(CCFLAGS=['-D_DEBUG', '-DDEBUG=1', '-gdwarf-2', '-Wall', '-O0', '-DDEBUG_ENABLED'])
- env.Append(CPPFLAGS=['-DDEBUG_MEMORY_ALLOC'])
+ env.Append(CPPFLAGS=['-DDEBUG_MEMORY_ENABLED'])
elif (env["target"]=="profile"):
diff --git a/platform/iphone/gl_view.mm b/platform/iphone/gl_view.mm
index 500c7c7174..06b679c305 100755
--- a/platform/iphone/gl_view.mm
+++ b/platform/iphone/gl_view.mm
@@ -70,7 +70,7 @@ bool _play_video(String p_path, float p_volume) {
float player_volume = p_volume * AudioServer::get_singleton()->get_singleton()->get_stream_global_volume_scale();
video_previous_volume = [[MPMusicPlayerController applicationMusicPlayer] volume];
- [[MPMusicPlayerController applicationMusicPlayer] setVolume: player_volume];
+ //[[MPMusicPlayerController applicationMusicPlayer] setVolume: player_volume];
p_path = Globals::get_singleton()->globalize_path(p_path);
@@ -113,7 +113,7 @@ void _pause_video() {
void _stop_video() {
[_instance.moviePlayerController stop];
[_instance.moviePlayerController.view removeFromSuperview];
- [[MPMusicPlayerController applicationMusicPlayer] setVolume: video_previous_volume];
+ //[[MPMusicPlayerController applicationMusicPlayer] setVolume: video_previous_volume];
video_playing = false;
}
@@ -554,7 +554,7 @@ static void clear_touches() {
[_instance.moviePlayerController stop];
[_instance.moviePlayerController.view removeFromSuperview];
- [[MPMusicPlayerController applicationMusicPlayer] setVolume: video_previous_volume];
+ //[[MPMusicPlayerController applicationMusicPlayer] setVolume: video_previous_volume];
video_playing = false;
}
diff --git a/platform/iphone/globals/global_defaults.cpp b/platform/iphone/globals/global_defaults.cpp
index 63463ab366..a4929c57dc 100644
--- a/platform/iphone/globals/global_defaults.cpp
+++ b/platform/iphone/globals/global_defaults.cpp
@@ -6,6 +6,7 @@
void register_iphone_global_defaults() {
GLOBAL_DEF("rasterizer.iOS/use_fragment_lighting",false);
+ GLOBAL_DEF("rasterizer.iOS/fp16_framebuffer",false);
GLOBAL_DEF("display.iOS/driver","GLES2");
Globals::get_singleton()->set_custom_property_info("display.iOS/driver",PropertyInfo(Variant::STRING,"display.iOS/driver",PROPERTY_HINT_ENUM,"GLES1,GLES2"));
}
diff --git a/platform/iphone/in_app_store.h b/platform/iphone/in_app_store.h
index dba1a1a5a1..656d126ead 100644
--- a/platform/iphone/in_app_store.h
+++ b/platform/iphone/in_app_store.h
@@ -49,6 +49,8 @@ public:
int get_pending_event_count();
Variant pop_pending_event();
+ void finish_transaction(String product_id);
+ void set_auto_finish_transaction(bool b);
void _post_event(Variant p_event);
void _record_purchase(String product_id);
diff --git a/platform/iphone/in_app_store.mm b/platform/iphone/in_app_store.mm
index 9b932d147b..f3640c3076 100644
--- a/platform/iphone/in_app_store.mm
+++ b/platform/iphone/in_app_store.mm
@@ -32,8 +32,12 @@
extern "C" {
#import <StoreKit/StoreKit.h>
+#import <Foundation/Foundation.h>
};
+bool auto_finish_transactions = true;
+NSMutableDictionary* pending_transactions = [NSMutableDictionary dictionary];
+
@interface SKProduct (LocalizedPrice)
@property (nonatomic, readonly) NSString *localizedPrice;
@end
@@ -63,6 +67,8 @@ void InAppStore::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_pending_event_count"),&InAppStore::get_pending_event_count);
ObjectTypeDB::bind_method(_MD("pop_pending_event"),&InAppStore::pop_pending_event);
+ ObjectTypeDB::bind_method(_MD("finish_transaction"),&InAppStore::finish_transaction);
+ ObjectTypeDB::bind_method(_MD("set_auto_finish_transaction"),&InAppStore::set_auto_finish_transaction);
};
@interface ProductsDelegate : NSObject<SKProductsRequestDelegate> {
@@ -162,11 +168,13 @@ Error InAppStore::request_product_info(Variant p_params) {
case SKPaymentTransactionStatePurchased: {
printf("status purchased!\n");
String pid = String::utf8([transaction.payment.productIdentifier UTF8String]);
+ String transactionId = String::utf8([transaction.transactionIdentifier UTF8String]);
InAppStore::get_singleton()->_record_purchase(pid);
Dictionary ret;
ret["type"] = "purchase";
ret["result"] = "ok";
ret["product_id"] = pid;
+ ret["transaction_id"] = transactionId;
NSData* receipt = nil;
int sdk_version = 6;
@@ -207,7 +215,13 @@ Error InAppStore::request_product_info(Variant p_params) {
ret["receipt"] = receipt_ret;
InAppStore::get_singleton()->_post_event(ret);
- [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
+
+ if (auto_finish_transactions){
+ [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
+ }
+ else{
+ [pending_transactions setObject:transaction forKey:transaction.payment.productIdentifier];
+ }
} break;
case SKPaymentTransactionStateFailed: {
printf("status transaction failed!\n");
@@ -290,11 +304,26 @@ InAppStore* InAppStore::get_singleton() {
InAppStore::InAppStore() {
ERR_FAIL_COND(instance != NULL);
instance = this;
+ auto_finish_transactions = false;
TransObserver* observer = [[TransObserver alloc] init];
[[SKPaymentQueue defaultQueue] addTransactionObserver:observer];
+ //pending_transactions = [NSMutableDictionary dictionary];
};
+void InAppStore::finish_transaction(String product_id){
+ NSString* prod_id = [NSString stringWithCString:product_id.utf8().get_data() encoding:NSUTF8StringEncoding];
+
+ if ([pending_transactions objectForKey:prod_id]){
+ [[SKPaymentQueue defaultQueue] finishTransaction:[pending_transactions objectForKey:prod_id]];
+ [pending_transactions removeObjectForKey:prod_id];
+ }
+};
+
+void InAppStore::set_auto_finish_transaction(bool b){
+ auto_finish_transactions = b;
+}
+
InAppStore::~InAppStore() {
};