objective c - release Vs free - why won’t the ARC version of an iOS audio app exit gracefully? -
i’m revising audio app. when converted arc discovered old code release
timer, audio session , devicemotion deprecated. xcode suggests replacing release
free
i’m having trouble making audio session release properly.
edit believe question has been answered here.
here code
- (void)fromescbutton:(uibutton*)button { [self stopclock]; [self exitgracefully]; [self gotoglobal]; } - (void)stopclock { [_synthlock lock]; [_synth stopallnotes]; [_player stop]; [motionlistener stopmotionlistener]; [_synthlock unlock]; [timer invalidate]; timer = nil; } -(void)exitgracefully { free((__bridge void *)(lasteventchangetime)); // [lasteventchangetime release]; free((__bridge void *)(timer)); // [timer release]; free((__bridge void *)(motionlistener)); // [motionlistener release]; free((__bridge void *)(player)); // [player release]; free((__bridge void *)(_synth)); // [synth release]; free((__bridge void *)(_synthlock)); // [synthlock release]; } - (void)gotoglobal { multiviewappdelegate *appdelegate = [[uiapplication sharedapplication] delegate]; [appdelegate displayview:display_help]; }
the method exitgracefully
(above) shows way free
compile. don’t understand (__bridge void *)
suspect might wrong.
when hit escape button, clock , sound stop app lingers buffers running , crashes
2017-08-18 08:51:30.015004+1000 satgam2[4846:577981] [aqme] 254: aqdefaultdevice (173): skipping input stream 0 0 0x0 2017-08-18 08:51:32.023461+1000 satgam2[4846:577981] [aqme] 254: aqdefaultdevice (173): skipping input stream 0 0 0x0 2017-08-18 08:51:34.031960+1000 satgam2[4846:577981] [aqme] 254: aqdefaultdevice (173): skipping input stream 0 0 0x0 2017-08-18 08:51:35.474 satgam2[4846:576397] esc button (2) (lldb) bt satgam2 compiled optimization - stepping may behave oddly; variables may not available. * thread #9, name = 'com.apple.coreaudio.aqclient', stop reason = exc_bad_access (code=1, address=0xb000000c) frame #0: 0x0318c4b6 libobjc.a.dylib`objc_msgsend + 14 * frame #1: 0x000f9452 satgam2`__39-[playviewcontroller startaudiosession]_block_invoke((null)=0x78f3b6b0, buffer=<unavailable>, audioformat=audiostreambasicdescription @ 0xb0a25ab8) @ playviewcontroller.m:347 [opt] frame #2: 0x000f7d87 satgam2`playcallback(inuserdata=0x7ab30970, inaudioqueue=<unavailable>, inbuffer=<unavailable>) @ audiobufferplayer.m:30 [opt]
the message in frame #2 inaudioqueue=<unavailable>, inbuffer=<unavailable>
suggests audio session found synth , player have stopped.
edits
i commented out method
exitgracefully
allowing arc manage release on own. symptoms continue until crashed different messageframe #2: 0x000d9d90 satgam2`-[playviewcontroller .cxx_destruct](self=0x7e249000, _cmd=".cxx_destruct") @ playviewcontroller.m:20 [opt]
playviewcontroller
mentioned in xcode log viewcontroller
running before crash. simulator shows app has switched new viewcontroller (the new tenant complaining rubbish left previous tenant ?)
i set pointers
nil
(as suggested marcio). crashed same way again different messageframe #2: 0x000000010c6c6e6d satgam2`__39-[playviewcontroller startaudiosession]_block_invoke((null)=<unavailable>, buffer=0x00006000002e1500, audioformat=audiostreambasicdescription @ 0x000070000c31e920) @ playviewcontroller.m:353 [opt]
the question might be: can message - [playviewcontroller startaudiosession]_block_invoke((null)=<unavailable>
- explain why arc cannot handle condition ?
can explain latest crash , audio player exit gracefully ?
thanks in anticipation.
Comments
Post a Comment