EZAudio icon indicating copy to clipboard operation
EZAudio copied to clipboard

Resetting EZAudioFile and EZRecorder for New Re-Recording Leads To Crash

Open vadymus opened this issue 11 years ago • 9 comments

Imagine I have one view controller that handles multiple recordings, that is: record once, re-record again, navigate away and come back to reload existing recording.

So... when I record using most of EZAudio sample code - all works good. However, when I record a new recording I have to reset EZRecorder:

self.audioFile = [EZAudioFile audioFileWithURL:[self getFilePathURL] andDelegate:self ]; self.recorder = [EZRecorder recorderWithDestinationURL:[self getFilePathURL] andSourceFormat:self.audioFile.clientFormat];

However that leads to app crash: "Error: Failed to open audio file for reading" at some point.

How to reload EZAudioFile and EZRecorder correctly?

vadymus avatar Feb 06 '14 18:02 vadymus

I need that same functionality, I'd be interested in knowing how to do that too. Did you find a safe way to reset EZRecorder yet? I also need to reset EZAudioPlot.

jbouaziz avatar Feb 15 '14 05:02 jbouaziz

Currently on the master branch I added a closeAudioFile function to the EZRecorder. I'm finishing up adding a clear function to the EZAudioPlot that may be helpful.

syedhali avatar Feb 15 '14 05:02 syedhali

I am using the closeAudioFile function with EZRecorder and the clear function with the EZAudioPlot. I am still having crashes when trying to begin recording a second file. Has anyone else solved this? I get the error EXC_BAD_ACCESS associated with the function AudioRingBuffer::GetTimeBounds. I have tried lots of debugging strategies, including NSZombies, trying to catch some over-released object. No dice. Admittedly, I am not an extremely experienced iOS programmer. Any suggestions are welcome.

Wahoozaboo avatar Aug 14 '15 18:08 Wahoozaboo

@Wahoozaboo are you using the same instance of the EZRecorder? Technically, if you close the audio file and create a new instance for your second recording you should be fine.

syedhali avatar Aug 14 '15 22:08 syedhali

@syedhali Thanks for responding. I am not not using the same instance. But I was monkeying around with little changes all morning, and switched the order of the methods within the stopRecording call. I think the problem was that I was calling [self.microphone stopFetchingAudio] after [self.recorder closeAudioFile]. Now that I stop fetching audio from the microphone BEFORE closing the audio file, it isn't crashing. I'm going to do some more rigorous testing to make sure that's really all there is to it... Feeling optimistic!

Wahoozaboo avatar Aug 17 '15 16:08 Wahoozaboo

@Wahoozaboo was this the case? Did [self.microphone stopFetchingAudio] before you close the file [self.recorder closeAudioFile] resolve this issue?

rosiematt avatar Oct 05 '15 08:10 rosiematt

@rosiematt Yes, it works for me. Are you having a similar issue? Now my struggle is getting audio monitoring working (I want to be able to play and record, simultaneously. Making a smart phone stethoscope - I want the user to be able to listen while recording a heart sound).

Wahoozaboo avatar Oct 06 '15 14:10 Wahoozaboo

I am still facing this issue, Any updates?

vin-the-dev avatar Dec 18 '15 13:12 vin-the-dev

I am still facing this issue, Any updates?

dhosny avatar Nov 14 '18 13:11 dhosny