2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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 #include <app_debug.h>
18 #include <sound_manager.h>
19 #include <sound_manager_internal.h>
27 void volume_init(void)
29 volume = VOLUME_DEFAULT;
30 sound_manager_get_master_volume(&volume);
35 int volume_set_mute(bool is_mute)
40 sound_manager_set_master_volume(MUTE_VALUE);
42 sound_manager_set_master_volume(volume);
47 bool volume_is_mute(void)
52 static int _volume_get_max_volume(void)
57 sound_manager_get_max_master_volume(&vol);
62 int volume_set_volume(int vol)
66 if (vol < VOLUME_MIN ||
68 _ERR("volume value out of range");
72 vol = (vol * _volume_get_max_volume()) / VOLUME_MAX;
74 r = sound_manager_set_master_volume(vol);
76 _ERR("failed to set volume");
85 int volume_get_volume(void)
89 if (volume_is_mute()) {
92 r = sound_manager_get_master_volume(&vol);
97 vol = (vol * VOLUME_MAX) / _volume_get_max_volume();