Hi, we have report from Google. Below is what they say. Do you know about such problem?
We've discovered a bug specific to your application running on Android 13 builds. Please see the following details:
Reproduce steps:
==============
1. Install the app
2. Open the app and play
3. Plug and unplug a headset
Expected results:
==============
Audio to work fine
Observed results:
==============
No audio, it becomes muted
Engineering Analysis :
=================
The app does not properly handle the error code returned from AAudioStream_requestStart().
It is possible for a headset to become disconnected between the opening of a stream and the start of a stream. When that happens, AAudioStream_requestStart() will return an error code. If you see an error code it is important that you call AAudioStream_close(stream) and then reopen and start a new stream.
It is a very short time period between open and start. So it is hard to reproduce the error. But we are seeing it in repeated tests. You can reproduce this by putting this HACK in your code:
// FIXME: Temporary HACK. Remove when finished testing.
static bool sFirstTime = true;
if (sFirstTime) {
sFirstTime = false;
return AAUDIO_ERROR_DISCONNECTED;
} else {
return AAudioStream_requestStart(stream);
}
That will cause the audio in appto die. it should be able to recover.