Fixing svace issue
[apps/native/boot-animation.git] / src / boot_sound.c
1 /*
2  * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 #include <vconf.h>
19 #include <app.h>
20 #include <stdio.h>
21 #include <stdlib.h>
22
23 #include "boot.h"
24 #include "app_log.h"
25
26 static const int is_supported = 0;
27 static bool __get_wav_file(int animation_type, char *wavpath)
28 {
29         __D("Get wav file");
30         if (animation_type == TYPE_ON) {
31                 snprintf(wavpath, FILE_PATH_MAX-1, "%s", DEFAULT_POWERON_WAV);
32                 __D("Wav file: %s", wavpath);
33
34                 return true;
35         }
36
37         return false;
38 }
39
40 static int __get_sound_status(void)
41 {
42         int soundon = 1;
43
44         if (vconf_get_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &soundon) < 0)
45                 __D("VCONFKEY_SETAPPL_SOUND_STATUS_BOOL ==> FAIL!!");
46
47         __D("Sound status: %d", soundon);
48
49         return soundon;
50 }
51
52 void play_boot_sound(int boot_type)
53 {
54         if (!is_supported)
55                 return;
56
57         int soundon = __get_sound_status();
58         if (soundon) {
59                 __D("Sound on!!");
60
61                 char wav_path[256];
62                 if (__get_wav_file(boot_type, wav_path)) {
63                         __D("File path: %s", wav_path);
64 #ifdef MM_SOUND
65                         mm_sound_boot_ready(3);
66                         mm_sound_boot_play_sound(wav_path);
67 #endif
68                 }
69         }
70 }
71