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 /* workaround for AF volume gain tuning */
44 #define MM_SOUND_AF_FILE_PREFIX "/opt/ug/res/sounds/ug-camera-efl/sounds/af_"
47 /******************************************************************************************
48 Functions For handling request from client
49 ******************************************************************************************/
51 int _MMSoundMgrIpcPlayFile(char* filename,int tone, int repeat, int volume, int volume_config,
52 int priority, int session_type, int session_options, int client_pid, int handle_route,
53 gboolean enable_session, int *codechandle, char *stream_type, int stream_index)
55 mmsound_mgr_codec_param_t param = {0,};
56 MMSourceType *source = NULL;
57 int ret = MM_ERROR_NONE;
60 source = (MMSourceType*)malloc(sizeof(MMSourceType));
62 debug_error("malloc fail!!\n");
63 return MM_ERROR_OUT_OF_MEMORY;
66 ret = mm_source_open_file(filename, source, MM_SOURCE_CHECK_DRM_CONTENTS);
67 if(ret != MM_ERROR_NONE) {
68 debug_error("Fail to open file\n");
75 /* Set sound player parameter */
77 param.repeat_count = repeat;
78 param.volume = volume;
79 param.volume_config = volume_config;
80 param.priority = priority;
81 param.session_type = session_type;
82 param.param = (void*)client_pid;
83 param.source = source;
84 param.handle_route = handle_route;
85 param.enable_session = enable_session;
86 param.stream_index = stream_index;
87 MMSOUND_STRNCPY(param.stream_type, stream_type, MM_SOUND_STREAM_TYPE_LEN);
89 /* workaround for AF volume gain tuning */
90 if (strncmp(filename, MM_SOUND_AF_FILE_PREFIX, strlen(MM_SOUND_AF_FILE_PREFIX)) == 0) {
91 param.volume_config |= VOLUME_GAIN_AF;
92 debug_msg("Volume Gain AF\n");
96 debug_msg("File[%s] DTMF[%d] Loop[%d] Volume[%f] Priority[%d] VolCfg[0x%x] callback[%p] param[%d] src_type[%d] src_ptr[%p] keytone[%d] route[%d] enable_session[%d]",
98 param.tone, param.repeat_count, param.volume, param.priority, param.volume_config, param.callback,
99 (int)param.param, param.source->type, param.source->ptr, param.keytone, param.handle_route, param.enable_session);
102 ret = MMSoundMgrCodecPlay(codechandle, ¶m);
103 if (ret != MM_ERROR_NONE) {
104 debug_error("Will be closed a sources, codechandle : 0x%08X\n", *codechandle);
105 mm_source_close(source);
113 return MM_ERROR_NONE;
116 int _MMSoundMgrIpcStop(int handle)
118 int ret = MM_ERROR_NONE;
120 ret = MMSoundMgrCodecStop(handle);
122 if (ret != MM_ERROR_NONE) {
123 debug_error("Fail to stop sound\n");
127 return MM_ERROR_NONE;
130 int _MMSoundMgrIpcClearFocus(int pid)
132 int ret = MM_ERROR_NONE;
134 ret = MMSoundMgrCodecClearFocus(pid);
136 if (ret != MM_ERROR_NONE) {
137 debug_error("Fail to clear focus\n");
141 return MM_ERROR_NONE;
144 int _MMSoundMgrIpcPlayFileWithStreamInfo(char* filename, int repeat, int volume,
145 int priority, int client_pid, int handle_route, int *codechandle, char *stream_type, int stream_index)
147 mmsound_mgr_codec_param_t param = {0,};
148 MMSourceType *source = NULL;
149 int ret = MM_ERROR_NONE;
152 source = (MMSourceType*)malloc(sizeof(MMSourceType));
154 debug_error("malloc fail!!\n");
155 return MM_ERROR_OUT_OF_MEMORY;
158 ret = mm_source_open_file(filename, source, MM_SOURCE_CHECK_DRM_CONTENTS);
159 if(ret != MM_ERROR_NONE) {
160 debug_error("Fail to open file\n");
167 /* Set sound player parameter */
168 param.repeat_count = repeat;
169 param.volume = volume;
170 param.priority = priority;
171 param.param = (void*)client_pid;
172 param.source = source;
173 param.handle_route = handle_route;
174 param.stream_index = stream_index;
175 MMSOUND_STRNCPY(param.stream_type, stream_type, MM_SOUND_STREAM_TYPE_LEN);
177 /* workaround for AF volume gain tuning */
178 if (strncmp(filename, MM_SOUND_AF_FILE_PREFIX, strlen(MM_SOUND_AF_FILE_PREFIX)) == 0) {
179 param.volume_config |= VOLUME_GAIN_AF;
180 debug_msg("Volume Gain AF\n");
183 ret = MMSoundMgrCodecPlayWithStreamInfo(codechandle, ¶m);
184 if (ret != MM_ERROR_NONE) {
185 debug_error("Will be closed a sources, codechandle : 0x%08X\n", *codechandle);
186 mm_source_close(source);
194 return MM_ERROR_NONE;
198 int _MMSoundMgrIpcPlayDTMF(int tone, int repeat, int volume, int volume_config,
199 int session_type, int session_options, int client_pid,
200 gboolean enable_session, int *codechandle, char *stream_type, int stream_index)
202 mmsound_mgr_codec_param_t param = {0,};
203 int ret = MM_ERROR_NONE;
205 /* Set sound player parameter */
207 param.repeat_count = repeat;
208 param.volume = volume;
209 param.volume_config = volume_config;
211 param.param = (void*)client_pid;
212 param.session_type = session_type;
213 param.session_options = session_options;
214 param.enable_session = enable_session;
215 param.stream_index = stream_index;
216 MMSOUND_STRNCPY(param.stream_type, stream_type, MM_SOUND_STREAM_TYPE_LEN);
218 debug_msg("DTMF %d\n", param.tone);
219 debug_msg("Loop %d\n", param.repeat_count);
220 debug_msg("Volume %d\n",param.volume);
221 debug_msg("VolumeConfig %x\n",param.volume_config);
222 debug_msg("Priority %d\n", param.priority);
223 debug_msg("session %d\n", param.session_type);
224 debug_msg("session options %x\n", param.session_options);
225 debug_msg("enable_session %d\n", param.enable_session);
227 ret = MMSoundMgrCodecPlayDtmf(codechandle, ¶m);
228 if ( ret != MM_ERROR_NONE) {
229 debug_error("Will be closed a sources, codec handle : [0x%d]\n", *codechandle);
236 int _MMSoundMgrIpcPlayDTMFWithStreamInfo(int tone, int repeat, int volume, int client_pid, int *codechandle, char *stream_type, int stream_index)
238 mmsound_mgr_codec_param_t param = {0,};
239 int ret = MM_ERROR_NONE;
241 /* Set sound player parameter */
243 param.repeat_count = repeat;
244 param.volume = volume;
246 param.param = (void*)client_pid;
247 param.stream_index = stream_index;
248 MMSOUND_STRNCPY(param.stream_type, stream_type, MM_SOUND_STREAM_TYPE_LEN);
250 debug_msg("DTMF %d\n", param.tone);
251 debug_msg("Loop %d\n", param.repeat_count);
252 debug_msg("Volume %d\n",param.volume);
253 debug_msg("Priority %d\n", param.priority);
254 debug_msg("stream type %s\n", param.stream_type);
255 debug_msg("stream index %d\n", param.stream_index);
258 ret = MMSoundMgrCodecPlayDtmfWithStreamInfo(codechandle, ¶m);
259 if ( ret != MM_ERROR_NONE) {
260 debug_error("Will be closed a sources, codec handle : [0x%d]\n", *codechandle);
267 int __mm_sound_mgr_ipc_get_current_connected_device_list(int device_flags, mm_sound_device_t **device_list, int *total_num)
269 int ret = MM_ERROR_NONE;
271 // ret = _mm_sound_mgr_device_get_current_connected_dev_list(device_flags, device_list, total_num);
276 /******************************************************************************************
277 Functions For Server-Side to notify Clients
278 ******************************************************************************************/
280 int __mm_sound_mgr_ipc_notify_play_file_end (int handle)
282 return __mm_sound_mgr_ipc_dbus_notify_play_file_end(handle);
285 int __mm_sound_mgr_ipc_notify_device_connected (mm_sound_device_t *device, gboolean is_connected)
287 return __mm_sound_mgr_ipc_dbus_notify_device_connected(device, is_connected);
290 int __mm_sound_mgr_ipc_notify_device_info_changed (mm_sound_device_t *device, int changed_device_info_type)
292 return __mm_sound_mgr_ipc_dbus_notify_device_info_changed(device, changed_device_info_type);
295 int __mm_sound_mgr_ipc_notify_volume_changed(unsigned int vol_type, unsigned int value)
297 return __mm_sound_mgr_ipc_dbus_notify_volume_changed(vol_type, value);
300 int __mm_sound_mgr_ipc_notify_active_device_changed(int device_in, int device_out)
302 /* Not Implemented */
303 return __mm_sound_mgr_ipc_dbus_notify_active_device_changed(device_in, device_out);
306 int __mm_sound_mgr_ipc_notify_available_device_changed(int device_in, int device_out, int available)
308 /* Not Implemented */
309 return __mm_sound_mgr_ipc_dbus_notify_available_device_changed(device_in, device_out, available);
312 int MMSoundMgrIpcInit(void)
314 return MM_ERROR_NONE;
317 int MMSoundMgrIpcFini(void)
319 return MM_ERROR_NONE;