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

Possible crash on disconnect with streams using Oboe sample rate conversion #2035

Closed
philburk opened this issue Jun 11, 2024 · 1 comment · Fixed by #2037
Closed

Possible crash on disconnect with streams using Oboe sample rate conversion #2035

philburk opened this issue Jun 11, 2024 · 1 comment · Fixed by #2037
Assignees
Labels
bug P0 very high priority

Comments

@philburk
Copy link
Collaborator

philburk commented Jun 11, 2024

If a stream was opened using setSampleRate() and the setSampleRateConversionQuality() was not None,
then if a headset was plugged in or unplugged,
and another thread or the user closed the stream,
then it was possible to get a crash in oboe_aaudio_error_thread_proc().

Note that this bug could also occur if any of these other conversion functions were enabled:

builder.setChannelConversionAllowed(true);
builder.setFormatConversionAllowed(true);

To avoid this bug, use Oboe v1.9.0 or later.

Note that the bug was due to not using shared_ptr when calling builder->openStream().
Because it is so dangerous, we are disabling the openStream(AudioStream **streamPP)
method. It was deprecated a long time ago. Now if you call it you will get an error and no stream.

The root cause was because the AudioStreamBuilder.openStream() was not using a shared_ptr
when creating a child stream. buggy code

Using a shared_ptr is necessary to prevent an error callback from using a raw pointer and referencing a deleted stream.
It also prevents the stream from being deleted while a data callback is active.

@philburk philburk added bug P0 very high priority labels Jun 11, 2024
@philburk philburk self-assigned this Jun 11, 2024
@philburk
Copy link
Collaborator Author

This is related to:
#2007, question from flamme
#1990, crash found by Xiaotong

Internally tracked in:
b/330947899 | P1 | Oboe Tester - TEST DISCONNECT quit after the test, test result not shown

philburk added a commit that referenced this issue Jun 12, 2024
This is used when Oboe does sample rate conversion.
Or format or channel count conversion.

It used to use a raw pointer, which could cause crashes.

Fixes #2035
philburk added a commit that referenced this issue Jun 12, 2024
This is used when Oboe does sample rate conversion. Or format or channel count conversion.

It used to use a raw pointer, which could cause crashes.

Fixes #2035
philburk added a commit that referenced this issue Jun 12, 2024
This is used when Oboe does sample rate conversion. Or format or channel count conversion.

It used to use a raw pointer, which could cause crashes.

Fixes #2035
philburk added a commit that referenced this issue Jun 13, 2024
to reflect the fix to #2035 for the shared_ptr when using Oboe SRC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug P0 very high priority
Projects
None yet
1 participant