From 68908eebbec50ed8f4343f93fd8cd52427ea7ca8 Mon Sep 17 00:00:00 2001 From: "Deal(一线灵)" Date: Fri, 26 May 2023 00:23:24 +0800 Subject: Improve oboe backend (#848) * Improve oboe backend This change should handle handphone call event properly and fix crash at stop (because the mStream was disconnected by system when handphone call income) * Invoke mDevice->handleDisconnect when AAudio stream disconnected --- alc/backends/oboe.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'alc/backends/oboe.cpp') diff --git a/alc/backends/oboe.cpp b/alc/backends/oboe.cpp index c74b0180..01d6fb85 100644 --- a/alc/backends/oboe.cpp +++ b/alc/backends/oboe.cpp @@ -5,7 +5,6 @@ #include #include -#include #include #include "alnumeric.h" @@ -29,6 +28,8 @@ struct OboePlayback final : public BackendBase, public oboe::AudioStreamCallback oboe::DataCallbackResult onAudioReady(oboe::AudioStream *oboeStream, void *audioData, int32_t numFrames) override; + void onErrorAfterClose(oboe::AudioStream* /* audioStream */, oboe::Result /* error */) override; + void open(const char *name) override; bool reset() override; void start() override; @@ -47,6 +48,13 @@ oboe::DataCallbackResult OboePlayback::onAudioReady(oboe::AudioStream *oboeStrea return oboe::DataCallbackResult::Continue; } +void OboePlayback::onErrorAfterClose(oboe::AudioStream* audioStream, oboe::Result error) +{ + if (error == oboe::Result::ErrorDisconnected) { + mDevice->handleDisconnect("Oboe AudioStream was disconnected: %s", oboe::convertToText(error)); + } + TRACE("Error was %s", oboe::convertToText(error)); +} void OboePlayback::open(const char *name) { -- cgit v1.2.3