Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

audioIn crashing when exiting app #11

Open
ImanolGo opened this issue Apr 30, 2017 · 15 comments
Open

audioIn crashing when exiting app #11

ImanolGo opened this issue Apr 30, 2017 · 15 comments

Comments

@ImanolGo
Copy link

Hi!

My app is sometimes crashing when exiting the application in the com.apple.audio.IOThread.client;
Apparently the rtStreamPtr pointer is already null;

-> rtStreamPtr->soundInputPtr->audioIn(rtStreamPtr->inputBuffer);

Before exiting the app I call the functions:

ofSoundStreamStop();
audioAnalyzer.exit();

But it still crashes every two times. The inconsistency makes me think it can be a multithread issue, but I don't know where else should I call it.

Any thoughts?

Imanol

@leozimmerman
Copy link
Owner

Do you know which line causes the error?
ofSoundStreamStop(); audioAnalyzer.exit();

If you comment or turn off the audio analyzer does it work ok?

@ImanolGo
Copy link
Author

ImanolGo commented May 8, 2017

It happens after I call audioAnalyzer.exit();

@leozimmerman
Copy link
Owner

Does this error happen also running rmsInput example?
It's weird, because audioAnalyzer.exit() just delete algorithms, no relation to the soundStream

@ImanolGo
Copy link
Author

ImanolGo commented May 8, 2017

Yes, it also happens in the rmsInput example.

FYI, I'm running it under macOS Sierra 10.12.4, MacBook Pro 15" late 2015.

It also doesn't happen always. So I imagine it has to do with the audio thread.

This is what the debugger shows.

screen shot 2017-05-08 at 16 50 41

@leozimmerman
Copy link
Owner

leozimmerman commented May 8, 2017

Ok, I´ll check it out.
compute() shouldn't be called once soundStream stopped...
Can you send me the console error log?
And also could you try changing the lines order in the exit function?
first
audioAnalyzer.exit();
and then
ofSoundStreamStop();

@ImanolGo
Copy link
Author

ImanolGo commented May 8, 2017

I had already try to do first
audioAnalyzer.exit();
and then
ofSoundStreamStop();

with the same result

screen shot 2017-05-08 at 17 00 50

@leozimmerman
Copy link
Owner

If you comment audioAnalyzer.exit() or remove audioAnalyzer funcs it works fine?
Which version of OF are you using?

@ImanolGo
Copy link
Author

ImanolGo commented May 8, 2017

Good point! If I skip audioAnalyzer.exit() it doesn't crash.
I'm using OF 0.9.8

@ImanolGo
Copy link
Author

ImanolGo commented May 8, 2017

Could it be the essentia::shutdown(), that creates the problem?

@leozimmerman
Copy link
Owner

If I had to guess, it seems that the audioAnalyzer.analyze() function is called once again after the analyzer has exit. It shouldn't because the soundStream is supposed to be stopped.
Does this happen with all examples?

@ImanolGo
Copy link
Author

ImanolGo commented May 8, 2017

It only happens when I use the audio input.

What happens if you exit without deleting all algorithms and stopping essentia?

@leozimmerman
Copy link
Owner

leozimmerman commented May 8, 2017

It seems there's something wrong with the soundStream audioIn thread: Not really stopping.

There shouldn't be a problem since you´re closing the app.

The other workaround if to add some buffer check to the audioIn, something like:
if (inBuffer != NULL) {audioAnalyzer.analyze(inBuffer);}

@ImanolGo
Copy link
Author

ImanolGo commented May 8, 2017

The compiler doesn't let me treat inBuffer or inBuffer.getBuffer() as a pointer. It says it is an invalid operand to binary expression..

@leozimmerman
Copy link
Owner

Oh, right, I would have to check to ofSoundBuffer reference. But could be something like inBuffer.size() != 0 or whatever function to check it its empty

@ImanolGo
Copy link
Author

ImanolGo commented May 8, 2017

hmmmm...

I tried

if (&inBuffer != NULL) {audioAnalyzer.analyze(inBuffer);} and the compiler give me a warning that it might always be true. It still failed in the same place.

Unfortunately inBuffer.size() != 0 also had the same result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants