Skip to content

Commit

Permalink
Merge pull request #11781 from marcelofg55/iphone_crashfix
Browse files Browse the repository at this point in the history
Fix possible crash at exit on iOS
  • Loading branch information
akien-mga authored Oct 9, 2017
2 parents 1a934a5 + 116e735 commit 87afd18
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
13 changes: 11 additions & 2 deletions platform/iphone/audio_driver_iphone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,17 @@ void AudioDriverIphone::unlock() {
};

void AudioDriverIphone::finish() {

memdelete_arr(samples_in);
AURenderCallbackStruct callback;
zeromem(&callback, sizeof(AURenderCallbackStruct));
OSStatus result = AudioUnitSetProperty(audio_unit, kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Input, 0, &callback, sizeof(callback));
if (result != noErr) {
ERR_PRINT("AudioUnitSetProperty failed");
}

if (samples_in) {
memdelete_arr(samples_in);
samples_in = NULL;
}
};

AudioDriverIphone::AudioDriverIphone() {
Expand Down
14 changes: 8 additions & 6 deletions platform/iphone/os_iphone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,14 @@ void OSIPhone::finalize() {
if (main_loop) // should not happen?
memdelete(main_loop);

spatial_sound_server->finish();
memdelete(spatial_sound_server);
spatial_sound_2d_server->finish();
memdelete(spatial_sound_2d_server);

audio_server->finish();
memdelete(audio_server);

visual_server->finish();
memdelete(visual_server);
memdelete(rasterizer);
Expand All @@ -381,13 +389,7 @@ void OSIPhone::finalize() {
physics_2d_server->finish();
memdelete(physics_2d_server);

spatial_sound_server->finish();
memdelete(spatial_sound_server);

memdelete(input);

spatial_sound_2d_server->finish();
memdelete(spatial_sound_2d_server);
};

void OSIPhone::set_mouse_show(bool p_show){};
Expand Down
3 changes: 2 additions & 1 deletion servers/audio/audio_server_sw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,8 @@ void AudioServerSW::_thread_func(void *self) {

while (!as->exit_update_thread) {
as->_update_streams(true);
OS::get_singleton()->delay_usec(5000);
if (OS::get_singleton())
OS::get_singleton()->delay_usec(5000);
}
}

Expand Down

0 comments on commit 87afd18

Please sign in to comment.