From a3d172d759a1dcae33ebf534ccaffeba397f30c9 Mon Sep 17 00:00:00 2001 From: melpon Date: Thu, 31 Aug 2023 23:53:50 +0900 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E5=9B=9E=E3=81=AE=E3=81=BF=20IosAudio?= =?UTF-8?q?Init=20=E3=82=92=E5=91=BC=E3=81=B6=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/sora.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/sora.cpp b/src/sora.cpp index 1621341..a880340 100644 --- a/src/sora.cpp +++ b/src/sora.cpp @@ -152,14 +152,18 @@ void Sora::Connect(const sora_conf::internal::ConnectConfig& cc) { return; } - IosAudioInit( - [this, on_disconnect = std::move(on_disconnect)](std::string error) { - if (!error.empty()) { - RTC_LOG(LS_ERROR) << "Failed to IosAudioInit: error=" << error; - on_disconnect((int)sora_conf::ErrorCode::INTERNAL_ERROR, - "Failed to IosAudioInit: error=" + error); - } - }); + static bool ios_audio_init = false; + if (!ios_audio_init) { + IosAudioInit( + [this, on_disconnect = std::move(on_disconnect)](std::string error) { + if (!error.empty()) { + RTC_LOG(LS_ERROR) << "Failed to IosAudioInit: error=" << error; + on_disconnect((int)sora_conf::ErrorCode::INTERNAL_ERROR, + "Failed to IosAudioInit: error=" + error); + } + ios_audio_init = true; + }); + } DoConnect(cc, std::move(on_disconnect)); #else DoConnect(cc, std::move(on_disconnect));