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.
33 #include "include/mm_sound_mgr_common.h"
34 #include "include/mm_sound_mgr_ipc.h"
35 #include "include/mm_sound_mgr_ipc_dbus.h"
37 #include "../include/mm_sound_common.h"
38 #include "include/mm_sound_mgr_codec.h"
43 /******************************************************************************************
44 Functions For handling request from client
45 ******************************************************************************************/
47 int _MMSoundMgrIpcPlayFile(char* filename,int tone, int repeat, int volume, int volume_config,
48 int session_type, int session_options, int client_pid, gboolean enable_session,
49 int *codechandle, char *stream_type, int stream_index)
51 mmsound_mgr_codec_param_t param = {0,};
52 MMSourceType *source = NULL;
53 int ret = MM_ERROR_NONE;
56 source = (MMSourceType*)malloc(sizeof(MMSourceType));
58 debug_error("malloc fail!!\n");
59 return MM_ERROR_OUT_OF_MEMORY;
62 ret = mm_source_open_file(filename, source, MM_SOURCE_CHECK_DRM_CONTENTS);
63 if(ret != MM_ERROR_NONE) {
64 debug_error("Fail to open file\n");
71 /* Set sound player parameter */
73 param.repeat_count = repeat;
74 param.volume = volume;
75 param.volume_config = volume_config;
76 param.session_type = session_type;
77 param.session_options = session_options;
78 param.param = (void*)client_pid;
79 param.source = source;
80 param.enable_session = enable_session;
81 param.stream_index = stream_index;
82 MMSOUND_STRNCPY(param.stream_type, stream_type, MM_SOUND_STREAM_TYPE_LEN);
85 debug_msg("File[%s] DTMF[%d] Loop[%d] Volume[%f] VolCfg[0x%x] callback[%p] param[%d] src_type[%d] src_ptr[%p] keytone[%d] enable_session[%d]",
87 param.tone, param.repeat_count, param.volume, param.volume_config, param.callback,
88 (int)param.param, param.source->type, param.source->ptr, param.keytone, param.enable_session);
91 ret = MMSoundMgrCodecPlay(codechandle, ¶m);
92 if (ret != MM_ERROR_NONE) {
93 debug_error("Will be closed a sources, codechandle : 0x%08X\n", *codechandle);
94 mm_source_close(source);
102 return MM_ERROR_NONE;
105 int _MMSoundMgrIpcStop(int handle)
107 int ret = MM_ERROR_NONE;
109 ret = MMSoundMgrCodecStop(handle);
111 if (ret != MM_ERROR_NONE) {
112 debug_error("Fail to stop sound\n");
116 return MM_ERROR_NONE;
119 #ifdef FOCUS_INTEGRATION
120 int _MMSoundMgrIpcClearFocus(int pid)
122 int ret = MM_ERROR_NONE;
124 ret = MMSoundMgrCodecClearFocus(pid);
126 if (ret != MM_ERROR_NONE) {
127 debug_error("Fail to clear focus\n");
131 return MM_ERROR_NONE;
135 int _MMSoundMgrIpcPlayFileWithStreamInfo(char* filename, int repeat, int volume,
136 int client_pid, int *codechandle, char *stream_type, int stream_index)
138 mmsound_mgr_codec_param_t param = {0,};
139 MMSourceType *source = NULL;
140 int ret = MM_ERROR_NONE;
143 source = (MMSourceType*)malloc(sizeof(MMSourceType));
145 debug_error("malloc fail!!\n");
146 return MM_ERROR_OUT_OF_MEMORY;
149 ret = mm_source_open_file(filename, source, MM_SOURCE_CHECK_DRM_CONTENTS);
150 if(ret != MM_ERROR_NONE) {
151 debug_error("Fail to open file\n");
158 /* Set sound player parameter */
159 param.repeat_count = repeat;
160 param.volume = volume;
161 param.param = (void*)client_pid;
162 param.source = source;
163 param.stream_index = stream_index;
164 MMSOUND_STRNCPY(param.stream_type, stream_type, MM_SOUND_STREAM_TYPE_LEN);
166 ret = MMSoundMgrCodecPlayWithStreamInfo(codechandle, ¶m);
167 if (ret != MM_ERROR_NONE) {
168 debug_error("Will be closed a sources, codechandle : 0x%08X\n", *codechandle);
169 mm_source_close(source);
177 return MM_ERROR_NONE;
181 int _MMSoundMgrIpcPlayDTMF(int tone, int repeat, int volume, int volume_config,
182 int session_type, int session_options, int client_pid,
183 gboolean enable_session, int *codechandle, char *stream_type, int stream_index)
185 mmsound_mgr_codec_param_t param = {0,};
186 int ret = MM_ERROR_NONE;
188 /* Set sound player parameter */
190 param.repeat_count = repeat;
191 param.volume = volume;
192 param.volume_config = volume_config;
193 param.param = (void*)client_pid;
194 param.session_type = session_type;
195 param.session_options = session_options;
196 param.enable_session = enable_session;
197 param.stream_index = stream_index;
198 MMSOUND_STRNCPY(param.stream_type, stream_type, MM_SOUND_STREAM_TYPE_LEN);
200 debug_msg("DTMF %d\n", param.tone);
201 debug_msg("Loop %d\n", param.repeat_count);
202 debug_msg("Volume %d\n",param.volume);
203 debug_msg("VolumeConfig %x\n",param.volume_config);
204 debug_msg("session %d\n", param.session_type);
205 debug_msg("session options %x\n", param.session_options);
206 debug_msg("enable_session %d\n", param.enable_session);
208 ret = MMSoundMgrCodecPlayDtmf(codechandle, ¶m);
209 if ( ret != MM_ERROR_NONE) {
210 debug_error("Will be closed a sources, codec handle : [0x%d]\n", *codechandle);
217 int _MMSoundMgrIpcPlayDTMFWithStreamInfo(int tone, int repeat, int volume, int client_pid, int *codechandle, char *stream_type, int stream_index)
219 mmsound_mgr_codec_param_t param = {0,};
220 int ret = MM_ERROR_NONE;
222 /* Set sound player parameter */
224 param.repeat_count = repeat;
225 param.volume = volume;
226 param.param = (void*)client_pid;
227 param.stream_index = stream_index;
228 MMSOUND_STRNCPY(param.stream_type, stream_type, MM_SOUND_STREAM_TYPE_LEN);
230 debug_msg("DTMF %d\n", param.tone);
231 debug_msg("Loop %d\n", param.repeat_count);
232 debug_msg("Volume %d\n",param.volume);
233 debug_msg("stream type %s\n", param.stream_type);
234 debug_msg("stream index %d\n", param.stream_index);
237 ret = MMSoundMgrCodecPlayDtmfWithStreamInfo(codechandle, ¶m);
238 if ( ret != MM_ERROR_NONE) {
239 debug_error("Will be closed a sources, codec handle : [0x%d]\n", *codechandle);
246 int __mm_sound_mgr_ipc_get_current_connected_device_list(int device_flags, mm_sound_device_t **device_list, int *total_num)
248 int ret = MM_ERROR_NONE;
250 // ret = _mm_sound_mgr_device_get_current_connected_dev_list(device_flags, device_list, total_num);
255 /******************************************************************************************
256 Functions For Server-Side to notify Clients
257 ******************************************************************************************/
259 int __mm_sound_mgr_ipc_notify_play_file_end (int handle)
261 return __mm_sound_mgr_ipc_dbus_notify_play_file_end(handle);
264 int __mm_sound_mgr_ipc_notify_device_connected (mm_sound_device_t *device, gboolean is_connected)
266 return __mm_sound_mgr_ipc_dbus_notify_device_connected(device, is_connected);
269 int __mm_sound_mgr_ipc_notify_device_info_changed (mm_sound_device_t *device, int changed_device_info_type)
271 return __mm_sound_mgr_ipc_dbus_notify_device_info_changed(device, changed_device_info_type);
274 int __mm_sound_mgr_ipc_notify_volume_changed(unsigned int vol_type, unsigned int value)
276 return __mm_sound_mgr_ipc_dbus_notify_volume_changed(vol_type, value);
279 int __mm_sound_mgr_ipc_notify_active_device_changed(int device_in, int device_out)
281 /* Not Implemented */
282 return __mm_sound_mgr_ipc_dbus_notify_active_device_changed(device_in, device_out);
285 int __mm_sound_mgr_ipc_notify_available_device_changed(int device_in, int device_out, int available)
287 /* Not Implemented */
288 return __mm_sound_mgr_ipc_dbus_notify_available_device_changed(device_in, device_out, available);
291 int MMSoundMgrIpcInit(void)
293 return MM_ERROR_NONE;
296 int MMSoundMgrIpcFini(void)
298 return MM_ERROR_NONE;