1 /* 2 * Copyright (c) 2024 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 #include "adapter/ohos/entrance/picker/picker_haptic_factory.h" 17 #if defined(AUDIO_FRAMEWORK_EXISTS) && defined(PLAYER_FRAMEWORK_EXISTS) 18 #include "adapter/ohos/entrance/picker/picker_haptic_impl.h" 19 #endif 20 21 namespace OHOS::Ace::NG { 22 std::shared_ptr<IPickerAudioHaptic> PickerAudioHapticFactory::instance_ { nullptr }; 23 std::mutex PickerAudioHapticFactory::mutex_; 24 GetInstance(const std::string & uri,const std::string & effectId)25std::shared_ptr<IPickerAudioHaptic> PickerAudioHapticFactory::GetInstance( 26 const std::string& uri, const std::string& effectId) 27 { 28 if (instance_ == nullptr) { 29 std::lock_guard<std::mutex> lock(mutex_); 30 if (instance_ == nullptr) { 31 #if defined(AUDIO_FRAMEWORK_EXISTS) && defined(PLAYER_FRAMEWORK_EXISTS) 32 instance_ = std::make_shared<PickerAudioHapticImpl>(uri, effectId); 33 #endif 34 } 35 } 36 return instance_; 37 } 38 } // namespace OHOS::Ace::NG 39