2 * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef SOUND_SOUND_MANAGER_H_
18 #define SOUND_SOUND_MANAGER_H_
20 #include <sound_manager.h>
22 #include "common/picojson.h"
23 #include "common/platform_result.h"
29 class SoundManagerSoundModeChangedListener {
31 virtual ~SoundManagerSoundModeChangedListener() {}
32 virtual void OnSoundModeChange(const std::string& newmode) = 0;
39 explicit SoundManager(SoundInstance& instance);
42 common::PlatformResult GetSoundMode(std::string* sound_mode_type);
43 common::PlatformResult SetVolume(const picojson::object& args);
44 common::PlatformResult GetVolume(const picojson::object& args,
46 common::PlatformResult SetSoundModeChangeListener(
47 SoundManagerSoundModeChangedListener* listener);
48 common::PlatformResult UnsetSoundModeChangeListener();
49 common::PlatformResult SetVolumeChangeListener();
50 common::PlatformResult UnsetVolumeChangeListener();
51 void GetDeviceList(sound_device_mask_e mask, picojson::object& out);
52 void DeviceChangeCB(sound_device_h device, bool is_connected, bool check_connection);
53 common::PlatformResult AddDeviceStateChangeListener();
54 common::PlatformResult RemoveDeviceStateChangeListener();
58 std::map<sound_type_e, int> max_volume_map_;
59 bool is_volume_change_listener_;
61 static const std::map<std::string, sound_type_e> platform_enum_map_;
63 void FillMaxVolumeMap();
64 common::PlatformResult GetMaxVolume(sound_type_e type, int* max_volume);
65 void VolumeChangeCallback(sound_type_e type, unsigned int value);
67 static common::PlatformResult StrToPlatformEnum(const std::string& key,
68 sound_type_e* sound_type);
69 static common::PlatformResult PlatformEnumToStr(const sound_type_e value,
70 std::string* sound_type);
72 common::PlatformResult GetDeviceInfo(sound_device_h device,
74 bool check_connection,
75 picojson::object* obj);
76 common::PlatformResult IsDeviceConnected(sound_device_type_e type,
77 sound_device_io_direction_e direction,
78 picojson::object* obj);
79 static std::string SoundDeviceTypeToString(sound_device_type_e type);
80 static std::string SoundIOTypeToString(sound_device_io_direction_e type);
81 static double ConvertToSystemVolume(int max_volume, int volume);
82 static void soundModeChangedCb(keynode_t* node, void* user_data);
83 bool soundModeChangeListening;
84 bool sound_device_change_listener_;
85 SoundInstance& instance_;
86 SoundManagerSoundModeChangedListener* soundModeListener;
90 } // namespace extension
92 #endif // SOUND_SOUND_MANAGER_H_