iphone - AVCaptureSession for Audio and Video combined - Audio part gives EXC_BAD_ACCESS -


i've made wonderful little app called night cam can record night vision effect videos. i'm in process of updating @ moment.

the video capture works absolutely fine audio not. there problem occurs turn on application when no recording file taking place (i change activate audio when recording later).

here relevant code:

session = [[avcapturesession alloc] init]; session.sessionpreset = avcapturesessionpresetmedium; camera = [avcapturedevice defaultdevicewithmediatype:avmediatypevideo]; microphone = [avcapturedevice defaultdevicewithmediatype:avmediatypeaudio]; avcapturedeviceinput * camera_input = [avcapturedeviceinput deviceinputwithdevice:camera error:nil]; [session addinput:camera_input]; avcapturedeviceinput * microphone_input = [avcapturedeviceinput deviceinputwithdevice:microphone error:nil]; [session addinput:microphone_input]; avcapturevideodataoutput * output = [[avcapturevideodataoutput alloc] init]; output.videosettings = [nsdictionary dictionarywithobject: [nsnumber numberwithint:kcvpixelformattype_32bgra] forkey:(id)kcvpixelbufferpixelformattypekey]; [session addoutput:output]; output.minframeduration = cmtimemake(1,30); dispatch_queue_t queue = dispatch_queue_create("my queue", null); [output setsamplebufferdelegate:self queue:queue]; dispatch_release(queue); avcaptureaudiodataoutput * audio_output = [[avcaptureaudiodataoutput alloc] init]; [session addoutput:audio_output]; queue = dispatch_queue_create("my queue", null); audiooutputbufferdelegate * special_delegate = [[[audiooutputbufferdelegate alloc] init] autorelease]; special_delegate->normal_delegate = self; [audio_output setsamplebufferdelegate:special_delegate queue:queue]; dispatch_release(queue); 

the "special delegate" this:

 @implementation audiooutputbufferdelegate     -(void)captureoutput: (avcaptureoutput *) captureoutput didoutputsamplebuffer: (cmsamplebufferref) samplebuffer fromconnection: (avcaptureconnection *) conenction{         if (normal_delegate->recording) {             [normal_delegate->audio_writer_input appendsamplebuffer: samplebuffer];         }     } @end 

the recording boolean not set nothing appended. don't need worry setup of avassestwriter either because doesn't set @ @ point app crashes. must setup of audio input.

here call stack when crashes:

> #0    0x33479464 in objc_msgsend > #1    0x348154b2 in -[avcaptureaudiodataoutput _avcaptureaudiodataoutput_audiodatabecameready] > #2    0x34815690 in avcaptureaudiodataoutput_audiodatabecameready > #3    0x33cc5984 in figrecorderremotecallbacksserver_samplebuffersarepending > #4    0x33cc2adc in _xsamplebuffersarepending > #5    0x33ca42ba in figrecordercallbacks_server > #6    0x33ca3238 in remrec_clientportcallback > #7    0x33a5dbe6 in __cfmachportperform > #8    0x33a556fe in __cfrunloop_is_calling_out_to_a_source1_perform_function__ > #9    0x33a556c2 in __cfrunloopdosource1 > #10   0x33a47f7c in __cfrunlooprun > #11   0x33a47c86 in cfrunlooprunspecific > #12   0x33a47b8e in cfrunloopruninmode > #13   0x33b0e4aa in gseventrunmodal > #14   0x33b0e556 in gseventrun > #15   0x32099328 in -[uiapplication _run] > #16   0x32096e92 in uiapplicationmain > #17   0x000023e0 in main @ main.m:14 

thank help.

it sounds program accessing bad memory of sort. have tried enable nszombieenabled property in settings? found exc_bad_access problem last week. should break @ call causes crash when that.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -