EZAudio icon indicating copy to clipboard operation
EZAudio copied to clipboard

Audio plot crashes when entering foreground

Open magnus80a opened this issue 8 years ago • 2 comments

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 avatar May 12 '16 17:05 magnus80a

I'm running EZAudio 1.1.5

magnus80a avatar May 12 '16 17:05 magnus80a

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.

magnus80a avatar May 21 '16 20:05 magnus80a