croissanne / portaudio_opensles

android opensles hostapi for portaudio
Other
48 stars 17 forks source link

Fix crash when calling Pa_CloseStream and fix compiler warnings #9

Closed darksylinc closed 3 years ago

darksylinc commented 3 years ago

Crash fixed

Calling Pa_CloseStream would result in a crash because of attempting to free an invalid ptr.

Pa_CloseStream would call pa_opensles.c's StopStream This would in turn call PaUnixThread_Terminate which looks at the thread's returns value via pthread_join.

If the thread's return value is not 0, portaudio interprets there's a pointer to free.

However because StreamProcessingCallback never returns a value nor calls PaUnixThreading_EXIT, there's only garbage; causing a crash when attempting to free that garbage ptr.

Warnings fixed

Trying to build with a modern version of the NDK would give a couple:

portaudio_opensles/src/hostapi/opensles/pa_opensles.c:1146: warning: implicitly declaring library function 'memset' with type 'void *(void *, int, unsigned long)' [-Wimplicit-function-declaration]
            memset( stream->outputBuffers[stream->currentOutputBuffer], 0,
            ^

This PR fixes that warning

darksylinc commented 3 years ago

I changed the title because it's now fixing a critical crash.

croissanne commented 3 years ago

Again thank you!