4 * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Sangchul Lee <sc11.lee@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.
29 #include "include/mm_sound.h"
30 #include "include/mm_sound_client.h"
31 #include "include/mm_sound_focus.h"
32 #include "focus_server/include/mm_sound_mgr_focus.h"
35 int mm_sound_focus_set_session_interrupt_callback(mm_sound_focus_session_interrupt_cb callback, void *user_data)
37 int ret = MM_ERROR_NONE;
41 return MM_ERROR_INVALID_ARGUMENT;
43 ret = mm_sound_client_set_session_interrupt_callback (callback, user_data);
51 int mm_sound_focus_unset_session_interrupt_callback(void)
53 int ret = MM_ERROR_NONE;
56 ret = mm_sound_client_unset_session_interrupt_callback ();
58 debug_error("Failed to mm_sound_client_unset_session_interrupt_callback(), ret[0x%x]\n", ret);
67 int mm_sound_focus_get_id(int *id)
69 int ret = MM_ERROR_NONE;
73 ret = mm_sound_client_get_uniq_id(id);
75 debug_error("Failed to mm_sound_client_get_uniq_id(), ret[0x%x]\n", ret);
84 int mm_sound_register_focus(int id, const char *stream_type, mm_sound_focus_changed_cb callback, void *user_data)
86 int ret = MM_ERROR_NONE;
90 if (id < 0 || callback == NULL) {
91 debug_error("argument is not valid\n");
92 return MM_ERROR_INVALID_ARGUMENT;
95 ret = mm_sound_client_register_focus(id, stream_type, callback, user_data);
97 debug_error("Could not register focus, ret[0x%x]\n", ret);
106 int mm_sound_unregister_focus(int id)
108 int ret = MM_ERROR_NONE;
113 debug_error("argument is not valid\n");
114 return MM_ERROR_INVALID_ARGUMENT;
117 ret = mm_sound_client_unregister_focus(id);
119 debug_error("Could not unregister focus, ret = %x\n", ret);
128 int mm_sound_acquire_focus(int id, mm_sound_focus_type_e focus_type, const char *additional_info)
130 int ret = MM_ERROR_NONE;
135 debug_error("argument is not valid\n");
136 return MM_ERROR_INVALID_ARGUMENT;
138 if (focus_type < FOCUS_FOR_PLAYBACK || focus_type > FOCUS_FOR_BOTH) {
139 debug_error("argument is not valid\n");
140 return MM_ERROR_INVALID_ARGUMENT;
143 ret = mm_sound_client_acquire_focus(id, focus_type, additional_info);
145 debug_error("Could not acquire focus, ret[0x%x]\n", ret);
154 int mm_sound_release_focus(int id, mm_sound_focus_type_e focus_type, const char *additional_info)
156 int ret = MM_ERROR_NONE;
161 debug_error("argument is not valid\n");
162 return MM_ERROR_INVALID_ARGUMENT;
164 if (focus_type < FOCUS_FOR_PLAYBACK || focus_type > FOCUS_FOR_BOTH) {
165 debug_error("argument is not valid\n");
166 return MM_ERROR_INVALID_ARGUMENT;
169 ret = mm_sound_client_release_focus(id, focus_type, additional_info);
171 debug_error("Could not release focus, ret[0x%x]\n", ret);
180 int mm_sound_set_focus_watch_callback(mm_sound_focus_type_e focus_type, mm_sound_focus_changed_watch_cb callback, void *user_data, int *id)
182 int ret = MM_ERROR_NONE;
186 if (callback == NULL || id == NULL) {
187 debug_error("argument is not valid\n");
188 return MM_ERROR_INVALID_ARGUMENT;
190 ret = mm_sound_client_set_focus_watch_callback(focus_type, callback, user_data, id);
192 debug_error("Could not set focus watch callback, ret[0x%x]\n", ret);
201 int mm_sound_unset_focus_watch_callback(int id)
203 int ret = MM_ERROR_NONE;
207 ret = mm_sound_client_unset_focus_watch_callback(id);
209 debug_error("Could not unset focus watch callback, id(%d), ret = %x\n", id, ret);