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_focus.h"
31 #include "focus_server/include/mm_sound_mgr_focus.h"
34 int mm_sound_focus_get_id(int *id)
36 int ret = MM_ERROR_NONE;
40 ret = mm_sound_client_get_uniq_id(id);
42 debug_error("Failed to mm_sound_client_get_uniq_id(), ret[0x%x]\n", ret);
51 int mm_sound_register_focus(int id, const char *stream_type, mm_sound_focus_changed_cb callback, void *user_data)
53 int ret = MM_ERROR_NONE;
57 if (id < 0 || callback == NULL) {
58 debug_error("argument is not valid\n");
59 return MM_ERROR_INVALID_ARGUMENT;
62 ret = mm_sound_client_register_focus(id, stream_type, callback, user_data);
64 debug_error("Could not register focus, ret[0x%x]\n", ret);
73 int mm_sound_unregister_focus(int id)
75 int ret = MM_ERROR_NONE;
80 debug_error("argument is not valid\n");
81 return MM_ERROR_INVALID_ARGUMENT;
84 ret = mm_sound_client_unregister_focus(id);
86 debug_error("Could not unregister focus, ret = %x\n", ret);
95 int mm_sound_acquire_focus(int id, mm_sound_focus_type_e focus_type, const char *additional_info)
97 int ret = MM_ERROR_NONE;
102 debug_error("argument is not valid\n");
103 return MM_ERROR_INVALID_ARGUMENT;
105 if (focus_type < FOCUS_FOR_PLAYBACK || focus_type > FOCUS_FOR_BOTH) {
106 debug_error("argument is not valid\n");
107 return MM_ERROR_INVALID_ARGUMENT;
110 ret = mm_sound_client_acquire_focus(id, focus_type, additional_info);
112 debug_error("Could not acquire focus, ret[0x%x]\n", ret);
121 int mm_sound_release_focus(int id, mm_sound_focus_type_e focus_type, const char *additional_info)
123 int ret = MM_ERROR_NONE;
128 debug_error("argument is not valid\n");
129 return MM_ERROR_INVALID_ARGUMENT;
131 if (focus_type < FOCUS_FOR_PLAYBACK || focus_type > FOCUS_FOR_BOTH) {
132 debug_error("argument is not valid\n");
133 return MM_ERROR_INVALID_ARGUMENT;
136 ret = mm_sound_client_release_focus(id, focus_type, additional_info);
138 debug_error("Could not release focus, ret[0x%x]\n", ret);
147 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)
149 int ret = MM_ERROR_NONE;
153 if (callback == NULL || id == NULL) {
154 debug_error("argument is not valid\n");
155 return MM_ERROR_INVALID_ARGUMENT;
157 ret = mm_sound_client_set_focus_watch_callback(focus_type, callback, user_data, id);
159 debug_error("Could not set focus watch callback, ret[0x%x]\n", ret);
168 int mm_sound_unset_focus_watch_callback(int id)
170 int ret = MM_ERROR_NONE;
174 ret = mm_sound_client_unset_focus_watch_callback(id);
176 debug_error("Could not unset focus watch callback, id(%d), ret = %x\n", id, ret);