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 "core/components_ng/pattern/time_picker/timepicker_haptic_factory.h"
17 #if defined(AUDIO_FRAMEWORK_EXISTS) && defined(PLAYER_FRAMEWORK_EXISTS)
18 #include "adapter/ohos/entrance/timepicker/timepicker_haptic_impl.h"
19 #endif
20 
21 namespace OHOS::Ace::NG {
22 std::shared_ptr<ITimepickerAudioHaptic> TimepickerAudioHapticFactory::instance_ { nullptr };
23 std::mutex TimepickerAudioHapticFactory::mutex_;
24 
GetInstance()25 std::shared_ptr<ITimepickerAudioHaptic> TimepickerAudioHapticFactory::GetInstance()
26 {
27     if (instance_ == nullptr) {
28         std::lock_guard<std::mutex> lock(mutex_);
29         if (instance_ == nullptr) {
30 #if defined(AUDIO_FRAMEWORK_EXISTS) && defined(PLAYER_FRAMEWORK_EXISTS)
31             instance_ = std::make_shared<TimepickerAudioHapticImpl>();
32 #endif
33         }
34     }
35     return instance_;
36 }
37 } // namespace OHOS::Ace::NG
38