Support gcov build for coverage check
[platform/core/multimedia/libmm-sound.git] / server / mm_sound_mgr_ipc.c
1 /*
2  * libmm-sound
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Seungbae Shin <seungbae.shin@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21
22 #include "include/mm_sound_mgr_ipc.h"
23 #include "include/mm_sound_mgr_ipc_dbus.h"
24
25 #include "../include/mm_sound_common.h"
26 #include "include/mm_sound_mgr_codec.h"
27 #include <mm_debug.h>
28 #include <mm_error.h>
29
30 /******************************************************************************************
31         Functions For handling request from client
32 ******************************************************************************************/
33 // except msgid
34 int _MMSoundMgrIpcStop(int handle)
35 {
36         int ret = MM_ERROR_NONE;
37
38         ret = MMSoundMgrCodecStop(handle);
39
40         if (ret != MM_ERROR_NONE) {
41                 debug_error("Fail to stop sound");
42                 return ret;
43         }
44
45         return MM_ERROR_NONE;
46 }
47
48 int _MMSoundMgrIpcPlayFileWithStreamInfo(char *filename, int repeat, int volume,
49                            int client_pid, int *codechandle, char *stream_type, int stream_index)
50 {
51         mmsound_mgr_codec_param_t param = { 0, };
52         int ret = MM_ERROR_NONE;
53
54         /* Set sound player parameter */
55         param.repeat_count = repeat;
56         param.volume = volume;
57         param.param = (void*)client_pid;
58         param.pfilename = filename;
59         param.stream_index = stream_index;
60         MMSOUND_STRNCPY(param.stream_type, stream_type, MAX_STREAM_TYPE_LEN);
61
62         ret = MMSoundMgrCodecPlayWithStreamInfo(codechandle, &param);
63         if (ret != MM_ERROR_NONE) {
64                 debug_error("Will be closed a sources, codechandle : 0x%08X", *codechandle);
65                 return ret;
66         }
67
68         return MM_ERROR_NONE;
69
70 }
71
72 int _MMSoundMgrIpcPlayDTMFWithStreamInfo(int tone, int repeat, int volume, int client_pid, int *codechandle,
73                                                                                 char *stream_type, int stream_index)
74 {
75         mmsound_mgr_codec_param_t param = { 0, };
76         int ret = MM_ERROR_NONE;
77
78         /* Set sound player parameter */
79         param.tone = tone;
80         param.repeat_count = repeat;
81         param.volume = volume;
82         param.param = (void*)client_pid;
83         param.stream_index = stream_index;
84         MMSOUND_STRNCPY(param.stream_type, stream_type, MAX_STREAM_TYPE_LEN);
85
86         debug_msg("DTMF %d", param.tone);
87         debug_msg("Loop %d", param.repeat_count);
88         debug_msg("Volume %f", param.volume);
89         debug_msg("stream type %s", param.stream_type);
90         debug_msg("stream index %d", param.stream_index);
91
92
93         ret = MMSoundMgrCodecPlayDtmfWithStreamInfo(codechandle, &param);
94         if (ret != MM_ERROR_NONE) {
95                 debug_error("Will be closed a sources, codec handle : [0x%d]", *codechandle);
96                 return ret;
97         }
98
99         return ret;
100 }
101
102 /******************************************************************************************
103         Functions For Server-Side to notify Clients
104 ******************************************************************************************/
105
106 int __mm_sound_mgr_ipc_notify_play_file_end(int handle)
107 {
108         return __mm_sound_mgr_ipc_dbus_notify_play_file_end(handle);
109 }
110