AVAudioRecorder Hell
AVAudioRecorder Hell
- Subject: AVAudioRecorder Hell
- From: Mr steve davis <email@hidden>
- Date: Mon, 19 Jun 2017 17:13:26 +0100
Hi guys, I’ve been on this list for years, and just realised you may be able
to help me out with a hellish bug in my app.
I have a problem with AVAudioRecorder
We have an app which works perfectly fine on all our devices, and in the
simulator, but the client gets a crash EVERY time he tries to record audio. It
seems like the audio is corrupted or a threading issue, as it passes all other
checks.
Could you please tell me if there is anything fundamentally wrong I’m doing in
the use of AVAudioRecorder.
I am using two instances of AVAudioRecorder, one for metering, one for
recording.
1) App starts, AVAudioSession with record option set. Metering AVAudioRecorder
instantiated.
2) Client presses record (I’m assuming I don’t have to create another Session
as we already have one open for the metering), a Record AVAudioRecorder
instantiated, which is reused for subsequent recordings.
Is using two instances of AVAudioRecorder a potential problem?
Is reusing the recording instance a potential problem, should I be releasing
the previously used one and instantiating a new one each time the client
presses ‘record’?
Any reason why data has not been fully written to file by the time the
completionBlock is called?
Any potential background processes running on his Mac which would compile the
project differently than all the other systems we have successfully ran it on?
Any ideas welcome I’m at a total loss.
-(void)audioRecorderDidFinishRecording: (AVAudioRecorder *)recorder
successfully:(BOOL)flag{
if(!self.recordCompletionBlock ){
return;
}
NSString * filePath = [recorder.url.path copy];
NSData *data = [[NSFileManager defaultManager] contentsAtPath:filePath];
[self.audioRecorder deleteRecording];
if(!data || !flag || !(data.length>0)){
DLog(@"Problem accessing recording data at path %@", filePath );
NSError * error = [VVErrorFactory createErrorWithDescription:@"No audio
data at stopRecordingAudioAtFilePath" code:GENERAL_ERROR fromInstance:self];
self.recordCompletionBlock(nil , error);
return ;
}
//
NSString *UUID = [[NSUUID UUID] UUIDString];
NSString * fileNameString = [UUID stringByAppendingString:@".caf"];
NSString *soundFilePath = [self.directory
stringByAppendingPathComponent:fileNameString];
if(![data writeToFile:soundFilePath atomically:YES]){
DLog(@"Problem accessing recording data at path %@", filePath );
NSError * error = [VVErrorFactory createErrorWithDescription:@"No audio
data at stopRecordingAudioAtFilePath" code:GENERAL_ERROR fromInstance:self];
self.recordCompletionBlock(nil , error);
return ;
}
[self.audioRecorder prepareToRecord];
self.recordCompletionBlock(soundFilePath , nil);
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden