-
Notifications
You must be signed in to change notification settings - Fork 565
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
problem with calling oboe::AudioStream-functions #48
Comments
What is the crash? Presumably a null pointer dereference? Please could you post the stack trace. |
The last line in android studio logcat is: So, do you think that's from my code? |
Please post everything that comes after the SIGSEGV line, that should give more of a clue as to where the crash is coming from. |
You're right, it is a null pointer dereference. What I don't understand is why I get this problem under the described circumstances (I still think it's not a fault in my code). working:
} problem:
} In both cases pOboeAudioStream and oboeClassWithCallback are like this (immediately written after the #include-lines): I think it's also possible that the bug was always there but in the way for example hello-aaudio is written, it hard to see. Because, if I got it right, in hello-audio the callback is always running and when the output should be silenced it works with memset 0, an this way something like requestStop is never called. |
I suspect the problem is in not passing a pointer to the stream pointer: This code:
should use "**stream" not "*stream":
Then call with an &: Let me know if that helps. |
Thanks for the help. |
I just notice that GitHub removed the double star from my message! The code that I see now in my email is wrong! If I try to fix it then I see the proper code. I will try to edit it with the code tag. openStreamRequestStart() must be declared with a double star, a pointer to a pointer. But I can't seem to type that without it getting removed. The builder->openStream() call passes back a pointer to an AudioStream. So you must pass it a pointer to a pointer. If Preview looks out of sync with the real code, try adding a comment to your CMakeLists.txt file and doing a gradle sync. That can sometime kick it back into sync. |
@philburk Really have to learn the basics better, never would have thought of that. Thanks a lot. |
You were passing Oboe a pointer to a pointer. That's good. But you were passing a pointer to the variable declared in your function. After the fix, you passed a pointer to the variable declared in your object. |
Experienced the following problem and I think (hope) it's not a fault in my code:
I have "static oboe::AudioStream* pOboeAudioStream(nullptr);" after my #include-lines in the native-lib.cpp.
When I call "oboe::AudioStreamBuilder.open(&pOboeAudioStream);" directly in a native function, it works as expected, stream is opened and I can call the stream functions also outside this specific function.
But when I go one step further nested I'm getting troubles.
So when I try something like:
JNIEXPORT jint JNICALL
Java_schmaden_programme_android_test_MainActivity_makeOboeAudioStream()
{
callFunctionThatDoesAllTheBuilderSetUpAndOpensStream(pOboeAudioStream);
return 0;
}
I get a crash with the first call that uses pOboeAudioStream outside of callFunctionThatD... . So I can call requestStart() or any other function related to pOboeAudioStream only inside this function.
The only way to get some sound is to call requestStart() inside of callFunctionThatD... .
If I call requestStop() outside callFunctionThatD... in the following way:
if(pOboeAudioStream != nullptr) pOboeAudioStream->requestStop();
nothing happens, no stopping, no crash.
As said before it works with the first method, so it's not a problem when you know it, otherwise it's pretty unexpected.
I set up a callback in the builder (if that matter), the code was executed on Android emulator API 27.
The text was updated successfully, but these errors were encountered: