syedhali / EZAudio

An iOS and macOS audio visualization framework built upon Core Audio useful for anyone doing real-time, low-latency audio processing and visualizations.
Other
4.96k stars 822 forks source link

Audio plot crashes when entering foreground #314

Open magnus80a opened 8 years ago

magnus80a commented 8 years ago

Something is wrong with the buffer that I send to updateBuffer:withBufferSize:. When I try to print buffer[0] I get error: Couldn't apply expression side effects : Couldn't dematerialize a result variable: couldn't read its memory.

This only happens once every five times I bring the app back into foreground. It never happen the first time I run the app. This makes me believe buffer has been released somehow, but that doesn't explain why it doesn't happen every time.

screen shot 2016-05-12 at 19 45 52
magnus80a commented 8 years ago

I'm running EZAudio 1.1.5

magnus80a commented 8 years ago

I think this can be resolved by retaining the data before passing it on to the audio plot. Like this:

let samples: [Float] = self.convertToSamples(buffer, withBufferSize: bufferSize)
self.audioPlot?.updateBuffer(&samples, withBufferSize: UInt32(samples.count))

This seems to solve the problem for me. Or at least make it a lot less probable to crash.