2 * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
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 * http://www.apache.org/licenses/LICENSE-2.0
7 * Unless required by applicable law or agreed to in writing, software
8 * distributed under the License is distributed on an "AS IS" BASIS,
9 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 * See the License for the specific language governing permissions and
11 * limitations under the License.
14 #ifndef __TTSD_BACKGROUND_VOLUME_H_
15 #define __TTSD_BACKGROUND_VOLUME_H_
23 #include <sound_manager.h>
27 class BackgroundVolume {
29 BackgroundVolume(long long int duckingDuration);
32 void setVolumeRatio(double ratio);
33 double getVolumeRatio();
34 void applyVolumeRatio();
35 void recoverVolumeRatio();
38 static void changeVolumeOnMainThread(void* data);
39 static void modifyVolumeOnMainThread(void* data);
40 static void recoverVolumeOnMainThread(void* data);
41 static Eina_Bool postponedRecoverTimerCb(void* data);
42 static Eina_Bool postponedModifyTimerCb(void* data);
44 long long int getDurationAfterDucking();
45 sound_stream_ducking_h getStreamDuckingHandle(sound_stream_type_e type);
47 void activateDuckingAll(unsigned int duration, double ratio);
48 bool activateDucking(sound_stream_type_e type, unsigned int duration, double ratio);
49 void deactivateDuckingAll();
50 void deactivateDucking(sound_stream_type_e type);
53 const long long int __duckingDuration;
54 sound_stream_ducking_h __mediaStream;
55 sound_stream_ducking_h __notificationStream;
56 sound_stream_ducking_h __alarmStream;
57 std::atomic<double> __volumeRatio;
58 std::atomic<bool> __isVolumeDucked;
60 std::chrono::time_point<std::chrono::steady_clock> __changeVolumeTime;
61 Ecore_Timer* __postponedRecoverTimer;
62 Ecore_Timer* __postponedModifyTimer;
66 #endif /* __TTSD_BACKGROUND_VOLUME_H_ */