Work around hang in AAudioStream_write() during extended shared object loading while running in a debugger. Observed on a OnePlus 8T (KB2005) running Oxygen OS 11.0.10.10.KB05AA.

The observed behavior is that any nonzero timeout value would hang until the device was paused and resumed. And a zero timeout value would always return 0 frames written even when audio fragments could be heard. Making a manual timeout system unworkable.
None of the straightforward systems imply that there's a detectable problem before the call to AAudioStream_write(). And the callback set within AAudioStreamBuilder_setErrorCallback() does not get called as we enter the hang state.
I've found that AAudioStream_getTimestamp() will report an error state from another thread. So this change codifies that behavior a bit until a better fix or more root cause can be found.
This commit is contained in:
Sam Lantinga
2021-10-13 09:33:51 -07:00
parent 325ae5c35d
commit 2423c51471
4 changed files with 52 additions and 4 deletions

View File

@@ -51,9 +51,11 @@ static void openslES_PauseDevices(void) {}
#if !SDL_AUDIO_DISABLED && SDL_AUDIO_DRIVER_AAUDIO
extern void aaudio_ResumeDevices(void);
extern void aaudio_PauseDevices(void);
SDL_bool aaudio_DetectBrokenPlayState( void );
#else
static void aaudio_ResumeDevices(void) {}
static void aaudio_PauseDevices(void) {}
static SDL_bool aaudio_DetectBrokenPlayState( void ) { return SDL_FALSE; }
#endif
@@ -168,6 +170,11 @@ Android_PumpEvents_Blocking(_THIS)
}
}
}
if ( aaudio_DetectBrokenPlayState() ) {
aaudio_PauseDevices();
aaudio_ResumeDevices();
}
}
void
@@ -246,6 +253,11 @@ Android_PumpEvents_NonBlocking(_THIS)
}
}
}
if ( aaudio_DetectBrokenPlayState() ) {
aaudio_PauseDevices();
aaudio_ResumeDevices();
}
}
#endif /* SDL_VIDEO_DRIVER_ANDROID */