Error at set InPut to AVCaptureSession in Firemonkey

  

I am try to capture audio in IOS by translating this : Play audio from AVCaptureAudioDataOutputSampleBufferDelegate . and here is my code :

var
{$IFDEF IOS}
FileName : string;
captureSession : AVCaptureSession;
audioDevice : AVCaptureDevice;
captureAudioInput : AVCaptureDeviceInput;
err : PPointer;
audioCaptureOutput : AVCaptureAudioDataOutput;
audioQueue : dispatch_queue_t;
data : NSData;
M : TMemoryStream;
{$ENDIF}
begin
{$IFDEF IOS}
captureSession := TAVCaptureSession.Wrap(TAVCaptureSession.Alloc.init);
captureSession.setSessionPreset(AVCaptureSessionPresetLow);
audioDevice := TAVCaptureDevice.Wrap(TAVCaptureDevice.OCClass.defaultDeviceWithMediaType(AVMediaTypeAudio));
captureAudioInput := TAVCaptureDeviceInput.Wrap(TAVCaptureDeviceInput.OCClass.deviceInputWithDevice(AudioDevice , err));

if err = nil then
begin
if captureSession.canAddInput(captureAudioInput) then
begin
captureSession.addInput(captureAudioInput);
end;
end;

{$ENDIF}
end;

my problem is

captureSession.canAddInput(captureAudioInput);

it return false and when i do

captureSession.AddInput(captureAudioInput);

whitout checking , the app exit and return to OS . After when i debug it , i found it back

SIGABRT(6) Error code.

Please help me to solve it …

Comments are closed.