1 /*
2  * Copyright (c) 2023 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 AUDIO_HAPTIC_VIBRATOR_H
17 #define AUDIO_HAPTIC_VIBRATOR_H
18 
19 #include <mutex>
20 #include <string>
21 
22 #include "audio_haptic_player.h"
23 
24 namespace OHOS {
25 namespace Media {
26 class AudioHapticVibrator {
27 public:
28     virtual ~AudioHapticVibrator() = default;
29 
30     static std::shared_ptr<AudioHapticVibrator> CreateAudioHapticVibrator(AudioHapticPlayer &audioHapticPlayer);
31 
32     virtual int32_t PreLoad(const HapticSource &hapticSource, const AudioStandard::StreamUsage &streamUsage) = 0;
33     virtual int32_t Release() = 0;
34     virtual void ResetStopState() = 0;
35     virtual int32_t StartVibrate(const AudioLatencyMode &latencyMode) = 0;
36     virtual int32_t SetHapticIntensity(float intensity) = 0;
37     virtual int32_t StopVibrate() = 0;
38     virtual int32_t GetDelayTime() = 0;
39 
40 private:
41     static std::mutex createVibratorMutex_;
42 };
43 } // Media
44 } // OHOS
45 #endif // AUDIO_HAPTIC_VIBRATOR_H
46