Code Monkey home page Code Monkey logo

Comments (9)

dturner avatar dturner commented on May 16, 2024

What is the crash? Presumably a null pointer dereference? Please could you post the stack trace.

from oboe.

SchmadenSchmuki avatar SchmadenSchmuki commented on May 16, 2024

The last line in android studio logcat is:
01-12 11:29:12.894 29799-29799/jogi.programme.android.testrequeststartproblem A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 29799 (eststartproblem), pid 29799 (eststartproblem)
Everything before is normal.
Looks like it could be what you said.
For a stack trace, can I get that easily, do I have to use systrace. If so, then that would take some time, I'm not into that yet (though I'm planning to get to know it at some point).

So, do you think that's from my code?

from oboe.

dturner avatar dturner commented on May 16, 2024

Please post everything that comes after the SIGSEGV line, that should give more of a clue as to where the crash is coming from.

from oboe.

SchmadenSchmuki avatar SchmadenSchmuki commented on May 16, 2024

You're right, it is a null pointer dereference.
Wenn I log the pointer it prints 0x0. So the behaviour from that point is consistent.

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).
The difference between working and not working code is (exactly) like this:

working:
JNIEXPORT jint JNICALL
Java_schmaden_programme_android_test_MainActivity_makeOboeAudioStream(
JNIEnv env,
jobject /
this */)
{
OpenOboeStreamFunctions openOboeStreamFunctions;
oboe::AudioStreamBuilder localBuilder;

openOboeStreamFunctions.configureCallbackStreamBuilder(&localBuilder, &oboeClassWithCallback);
oboe::Result result(localBuilder.openStream(&pOboeAudioStream));

return 0;

}

problem:
JNIEXPORT jint JNICALL
Java_schmaden_programme_android_test_MainActivity_makeOboeAudioStream(
JNIEnv env,
jobject /
this */)
{
OpenOboeStreamFunctions openOboeStreamFunctions;
oboe::AudioStreamBuilder localBuilder;

openOboeStreamFunctions.configureCallbackStreamBuilder(&localBuilder, &oboeClassWithCallback);
openOboeStreamFunctions.openStreamRequestStart(pOboeAudioStream, &localBuilder); 

return 0;

}
with openStreamRequestStart being:
int16_t OpenOboeStreamFunctions::openStreamRequestStart(oboe::AudioStream* stream,
oboe::AudioStreamBuilder* builder)
{
oboe::Result result(builder->openStream(&stream));
if (result != oboe::Result::OK)
{
__android_log_print(ANDROID_LOG_ERROR, "AudioEngine", "Error opening stream %s",
oboe::convertToText(result));
return -108;
}
result= stream->requestStart(); // so sound output is started and heard
return 0;
} // from here stream is a nullpointer

In both cases pOboeAudioStream and oboeClassWithCallback are like this (immediately written after the #include-lines):
static oboe::AudioStream* pOboeAudioStream(nullptr);
static CallbackForTest oboeClassWithCallback;

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.

from oboe.

philburk avatar philburk commented on May 16, 2024

I suspect the problem is in not passing a pointer to the stream pointer:

This code:

  int16_t OpenOboeStreamFunctions::openStreamRequestStart(oboe::AudioStream* stream,
  oboe::AudioStreamBuilder* builder) {
     oboe::Result result(builder->openStream(&stream));

should use "**stream" not "*stream":
(UPDATED 1/13/18 to restore double star removed by editor)

  int16_t OpenOboeStreamFunctions::openStreamRequestStart(oboe::AudioStream** stream,
  oboe::AudioStreamBuilder* builder) {
     oboe::Result result(builder->openStream(stream));         // <== NO & !!!!!

Then call with an &:
openOboeStreamFunctions.openStreamRequestStart(&pOboeAudioStream, &localBuilder);

Let me know if that helps.

from oboe.

SchmadenSchmuki avatar SchmadenSchmuki commented on May 16, 2024

Thanks for the help.
Tried
oboe::Result result(builder->openStream(stream)); // <== NO & !!!!!
but it doesn't compile, I get the following error:
Error:(57, 45) error: cannot initialize a parameter of type 'oboe::AudioStream **' with an lvalue of type 'oboe::AudioStream *'
Strange thing is, when press ctrl and hover over openStream, the preview I get says declared in "AudioStreamBuilder.h" and "oboe::AudioStream *" is needed.
When I follow the link, android studio shows me "AudioStreamBuilder.cpp" and "oboe::AudioStream **"
for calling the function.

from oboe.

philburk avatar philburk commented on May 16, 2024

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.

from oboe.

SchmadenSchmuki avatar SchmadenSchmuki commented on May 16, 2024

@philburk
Thanks you, that worked, will make my life a lot easier.

Really have to learn the basics better, never would have thought of that.
(To be honest, I still don't get it, because in the working case I also used openStream(&pOboeAudioStream);.
The only difference I see is one time the function was called over the instance (the working version localBuilder.openStream(&pOboeAudioStream);), the other time with pointer dereference of builderpointer (the problemversion builder->openStream(&stream);), with pOboeAudioStream and stream both being an oboe::AudioStream*.
But I have to read about, think on and play with that tomorrow.)

Thanks a lot.

from oboe.

philburk avatar philburk commented on May 16, 2024

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.
It received the pointer to the new stream. But it was immediately discarded.

After the fix, you passed a pointer to the variable declared in your object.
That is the one that needed to be set.

from oboe.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.