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_get_id(int *id)
37 int ret = MM_ERROR_NONE;
41 ret = mm_sound_client_get_uniq_id(id);
43 debug_error("Failed to mm_sound_client_get_uniq_id(), ret[0x%x]\n", ret);
52 int mm_sound_register_focus(int id, const char *stream_type, mm_sound_focus_changed_cb callback, void *user_data)
54 int ret = MM_ERROR_NONE;
58 if (id < 0 || callback == NULL) {
59 debug_error("argument is not valid\n");
60 return MM_ERROR_INVALID_ARGUMENT;
63 ret = mm_sound_client_register_focus(id, stream_type, callback, user_data);
65 debug_error("Could not register focus, ret[0x%x]\n", ret);
74 int mm_sound_unregister_focus(int id)
76 int ret = MM_ERROR_NONE;
81 debug_error("argument is not valid\n");
82 return MM_ERROR_INVALID_ARGUMENT;
85 ret = mm_sound_client_unregister_focus(id);
87 debug_error("Could not unregister focus, ret = %x\n", ret);
96 int mm_sound_acquire_focus(int id, mm_sound_focus_type_e focus_type, const char *additional_info)
98 int ret = MM_ERROR_NONE;
103 debug_error("argument is not valid\n");
104 return MM_ERROR_INVALID_ARGUMENT;
106 if (focus_type < FOCUS_FOR_PLAYBACK || focus_type > FOCUS_FOR_BOTH) {
107 debug_error("argument is not valid\n");
108 return MM_ERROR_INVALID_ARGUMENT;
111 ret = mm_sound_client_acquire_focus(id, focus_type, additional_info);
113 debug_error("Could not acquire focus, ret[0x%x]\n", ret);
122 int mm_sound_release_focus(int id, mm_sound_focus_type_e focus_type, const char *additional_info)
124 int ret = MM_ERROR_NONE;
129 debug_error("argument is not valid\n");
130 return MM_ERROR_INVALID_ARGUMENT;
132 if (focus_type < FOCUS_FOR_PLAYBACK || focus_type > FOCUS_FOR_BOTH) {
133 debug_error("argument is not valid\n");
134 return MM_ERROR_INVALID_ARGUMENT;
137 ret = mm_sound_client_release_focus(id, focus_type, additional_info);
139 debug_error("Could not release focus, ret[0x%x]\n", ret);
148 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)
150 int ret = MM_ERROR_NONE;
154 if (callback == NULL || id == NULL) {
155 debug_error("argument is not valid\n");
156 return MM_ERROR_INVALID_ARGUMENT;
158 ret = mm_sound_client_set_focus_watch_callback(focus_type, callback, user_data, id);
160 debug_error("Could not set focus watch callback, ret[0x%x]\n", ret);
169 int mm_sound_unset_focus_watch_callback(int id)
171 int ret = MM_ERROR_NONE;
175 ret = mm_sound_client_unset_focus_watch_callback(id);
177 debug_error("Could not unset focus watch callback, id(%d), ret = %x\n", id, ret);