4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Seungbae Shin <seungbae.shin@samsung.com>
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include "include/mm_sound_mgr_ipc.h"
23 #include "include/mm_sound_mgr_ipc_dbus.h"
25 #include "../include/mm_sound_common.h"
26 #include "include/mm_sound_mgr_codec.h"
30 /******************************************************************************************
31 Functions For handling request from client
32 ******************************************************************************************/
34 int _MMSoundMgrIpcPlayFile(char* filename, int tone, int repeat, int volume, int volume_config,
35 int session_type, int session_options, int client_pid, gboolean enable_session,
36 int *codechandle, char *stream_type, int stream_index)
38 mmsound_mgr_codec_param_t param = { 0, };
39 int ret = MM_ERROR_NONE;
41 /* Set sound player parameter */
43 param.repeat_count = repeat;
44 param.volume = volume;
45 param.volume_config = volume_config;
46 param.session_type = session_type;
47 param.session_options = session_options;
48 param.param = (void*)client_pid;
49 param.pfilename = filename;
50 param.enable_session = enable_session;
51 param.stream_index = stream_index;
52 MMSOUND_STRNCPY(param.stream_type, stream_type, MAX_STREAM_TYPE_LEN);
54 ret = MMSoundMgrCodecPlay(codechandle, ¶m);
55 if (ret != MM_ERROR_NONE) {
56 debug_error("Will be closed a sources, codechandle : 0x%08X", *codechandle);
63 int _MMSoundMgrIpcStop(int handle)
65 int ret = MM_ERROR_NONE;
67 ret = MMSoundMgrCodecStop(handle);
69 if (ret != MM_ERROR_NONE) {
70 debug_error("Fail to stop sound");
77 #ifdef FOCUS_INTEGRATION
78 int _MMSoundMgrIpcClearFocus(int pid)
80 int ret = MM_ERROR_NONE;
82 ret = MMSoundMgrCodecClearFocus(pid);
84 if (ret != MM_ERROR_NONE) {
85 debug_error("Fail to clear focus");
93 int _MMSoundMgrIpcPlayFileWithStreamInfo(char *filename, int repeat, int volume,
94 int client_pid, int *codechandle, char *stream_type, int stream_index)
96 mmsound_mgr_codec_param_t param = { 0, };
97 int ret = MM_ERROR_NONE;
99 /* Set sound player parameter */
100 param.repeat_count = repeat;
101 param.volume = volume;
102 param.param = (void*)client_pid;
103 param.pfilename = filename;
104 param.stream_index = stream_index;
105 MMSOUND_STRNCPY(param.stream_type, stream_type, MAX_STREAM_TYPE_LEN);
107 ret = MMSoundMgrCodecPlayWithStreamInfo(codechandle, ¶m);
108 if (ret != MM_ERROR_NONE) {
109 debug_error("Will be closed a sources, codechandle : 0x%08X", *codechandle);
113 return MM_ERROR_NONE;
117 int _MMSoundMgrIpcPlayDTMF(int tone, int repeat, int volume, int volume_config,
118 int session_type, int session_options, int client_pid,
119 gboolean enable_session, int *codechandle,
120 char *stream_type, int stream_index)
122 mmsound_mgr_codec_param_t param = { 0, };
123 int ret = MM_ERROR_NONE;
125 /* Set sound player parameter */
127 param.repeat_count = repeat;
128 param.volume = volume;
129 param.volume_config = volume_config;
130 param.param = (void*)client_pid;
131 param.session_type = session_type;
132 param.session_options = session_options;
133 param.enable_session = enable_session;
134 param.stream_index = stream_index;
135 MMSOUND_STRNCPY(param.stream_type, stream_type, MAX_STREAM_TYPE_LEN);
137 debug_msg("DTMF %d", param.tone);
138 debug_msg("Loop %d", param.repeat_count);
139 debug_msg("Volume %f", param.volume);
140 debug_msg("VolumeConfig %x", param.volume_config);
141 debug_msg("session %d", param.session_type);
142 debug_msg("session options %x", param.session_options);
143 debug_msg("enable_session %d", param.enable_session);
145 ret = MMSoundMgrCodecPlayDtmf(codechandle, ¶m);
146 if (ret != MM_ERROR_NONE) {
147 debug_error("Will be closed a sources, codec handle : [0x%d]", *codechandle);
154 int _MMSoundMgrIpcPlayDTMFWithStreamInfo(int tone, int repeat, int volume, int client_pid, int *codechandle,
155 char *stream_type, int stream_index)
157 mmsound_mgr_codec_param_t param = { 0, };
158 int ret = MM_ERROR_NONE;
160 /* Set sound player parameter */
162 param.repeat_count = repeat;
163 param.volume = volume;
164 param.param = (void*)client_pid;
165 param.stream_index = stream_index;
166 MMSOUND_STRNCPY(param.stream_type, stream_type, MAX_STREAM_TYPE_LEN);
168 debug_msg("DTMF %d", param.tone);
169 debug_msg("Loop %d", param.repeat_count);
170 debug_msg("Volume %f", param.volume);
171 debug_msg("stream type %s", param.stream_type);
172 debug_msg("stream index %d", param.stream_index);
175 ret = MMSoundMgrCodecPlayDtmfWithStreamInfo(codechandle, ¶m);
176 if (ret != MM_ERROR_NONE) {
177 debug_error("Will be closed a sources, codec handle : [0x%d]", *codechandle);
184 /******************************************************************************************
185 Functions For Server-Side to notify Clients
186 ******************************************************************************************/
188 int __mm_sound_mgr_ipc_notify_play_file_end(int handle)
190 return __mm_sound_mgr_ipc_dbus_notify_play_file_end(handle);