audio playing from within python crashes due to msvcr90.dll exception

234 Views Asked by At

I wrote a program that uses pyaudio to record and play audio signal simultaneously. for some unknown reason sometimes when playing signals the program crashes with this error:

Unhandled exception at 0x72A6AE7A (msvcr90.dll) in python.exe: 0xC0000005: Access violation reading location 0x02F4DB94.

the program uses the libraries pygame, pyaudio, numpy

is there a way to understand where exactly is the problem ? Thank you, Netanel

1

There are 1 best solutions below

0
On

This is more a workaroud than a proper answer, but: The problem ceased to exist when the signal was played by using the "blocking" mechanism of pyaudio, ie: opening a stream something like:

stream = self.player.open(format = pyaudio.paFloat32, channels = 2, rate = FS, output = True, frames_per_buffer = CHUNK)

and then playing with something like:

while True:
    a = self.chunk_queue.get_nowait()
    self.stream.write(a)

the use of the non blocking mode play (by configuring a callback function for the stream) seems to have be the source for the crashes.