1 /* 2 * Copyright (c) 2025-2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef LOG_TAG 17 #define LOG_TAG "AudioServiceAdapter" 18 #endif 19 20 #include "pro_audio_service_adapter_impl.h" 21 #if defined(_WIN32) || defined(_WIN64) 22 #include <windows.h> 23 #endif 24 #include <sstream> 25 #include <thread> 26 27 #include "audio_errors.h" 28 #include "audio_common_log.h" 29 #include "audio_info.h" 30 #include "audio_utils.h" 31 #include <set> 32 #include <unordered_map> 33 #ifdef SUPPORT_OLD_ENGINE 34 #include "pulse_audio_service_adapter_impl.h" 35 #endif // SUPPORT_OLD_ENGINE 36 using namespace std; 37 38 namespace OHOS { 39 namespace AudioStandard { 40 41 AudioServiceAdapter::~AudioServiceAdapter() = default; 42 43 // LCOV_EXCL_START CreateAudioAdapter(std::unique_ptr<AudioServiceAdapterCallback> cb,bool isAudioEngine)44std::shared_ptr<AudioServiceAdapter> AudioServiceAdapter::CreateAudioAdapter( 45 std::unique_ptr<AudioServiceAdapterCallback> cb, bool isAudioEngine) 46 { 47 CHECK_AND_RETURN_RET_LOG(cb != nullptr, nullptr, "CreateAudioAdapter cb is nullptr!"); 48 AUDIO_INFO_LOG("CreateAudioAdapter"); 49 #ifdef SUPPORT_OLD_ENGINE 50 int32_t engineFlag = GetEngineFlag(); 51 if (engineFlag == 1 || isAudioEngine) { 52 return make_shared<ProAudioServiceAdapterImpl>(cb); 53 } else { 54 return make_shared<PulseAudioServiceAdapterImpl>(cb); 55 } 56 #else 57 return make_shared<ProAudioServiceAdapterImpl>(cb); 58 #endif 59 } 60 // LCOV_EXCL_STOP 61 } // namespace AudioStandard 62 } // namespace OHOS