2 // Tizen Web Device API
3 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
18 #ifndef __TIZEN_SOUND_UTIL_H__
19 #define __TIZEN_SOUND_UTIL_H__
23 #include <sound_manager.h>
24 #include <PlatformException.h>
31 const std::string SYSTEM = "SYSTEM";
32 const std::string NOTIFICATION = "NOTIFICATION";
33 const std::string ALARM = "ALARM";
34 const std::string MEDIA = "MEDIA";
35 const std::string VOICE = "VOICE";
36 const std::string RINGTONE = "RINGTONE";
38 const std::string SOUND = "SOUND";
39 const std::string VIBRATE = "VIBRATE";
40 const std::string MUTE = "MUTE";
43 const std::string SPEAKER = "SPEAKER";
44 const std::string RECEIVER = "RECEIVER";
45 const std::string AUDIO_JACK = "AUDIO_JACK";
46 const std::string BLUETOOTH = "BLUETOOTH";
47 const std::string HDMI = "HDMI";
48 const std::string MIRRORING = "MIRRORING";
49 const std::string USB_AUDIO = "USB_AUDIO";
50 const std::string MIC = "MIC";
53 const std::string IN = "IN";
54 const std::string OUT = "OUT";
55 const std::string BOTH = "BOTH";
58 static std::string errOutOfMemory = "Out of memory";
59 static std::string errInvalidParameter = "Invalid parameter";
60 static std::string errInvalidOperation = "Invalid Operation";
61 static std::string errPermissionDenied = "Permission denied";
62 static std::string errNotSupported = "Not supported";
63 static std::string errNoData = "No data";
64 static std::string errNoPlayingSound = "No playing sound";
65 static std::string errInternal = "Internal Error";
66 static std::string errPolicy = "Policy Error";
67 static std::string errUnknown = "Unknown error";
72 SOUND_MODE_TYPE_SOUND,
73 SOUND_MODE_TYPE_VIBRATE,
80 static std::string soundTypeToString(sound_type_e sound_type);
81 static sound_type_e stringToSoundType(std::string sound_type_str);
83 static std::string soundModeToString(SoundModeType sound_mode);
84 static SoundModeType stringToSoundMode(std::string sound_mode_str);
86 static std::string soundDeviceTypeToString(sound_device_type_e soundDevice);
87 static sound_device_type_e stringToSoundDeviceType(std::string soundDevice);
89 static std::string soundIOTypeToString(sound_device_io_direction_e IOType);
90 static sound_device_io_direction_e stringToSoundIOType(std::string IOType);
92 template <class T = DeviceAPI::Common::UnknownException>
93 static void throwSoundException(const int errorCode, const std::string& hint) {
94 std::string message = SoundUtil::getSoundLogMessage(errorCode, hint);
95 LOGE("%s", message.c_str());
96 throw T(message.c_str());
99 template <class T = DeviceAPI::Common::UnknownException>
100 static void throwSoundException(const std::string& hint) {
101 LOGE("%s", hint.c_str());
102 throw T(hint.c_str());
105 static std::string& getSoundErrorMessage(const int errorCode);
106 static std::string getSoundLogMessage(const int errorCode, const std::string& hint);
114 #endif // __TIZEN_SOUND_UTIL_H__