2 * audio-session-manager
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.
26 * @ingroup AUDIO_SESSION_MANAGER
27 * @defgroup AUDIO_SESSION_MANAGER Audio Session Manager
33 #define ERR_ASM_THREAD_CREATE_ERROR 0x01
34 #define ERR_ASM_THREAD_CANCEL_ERROR 0x02
35 #define ERR_ASM_MSG_QUEUE_MSGID_GET_FAILED 0x03
36 #define ERR_ASM_MSG_QUEUE_SND_ERROR 0x04
37 #define ERR_ASM_MSG_QUEUE_RCV_ERROR 0x05
38 #define ERR_ASM_ALREADY_REGISTERED 0x06
39 #define ERR_ASM_ALREADY_UNREGISTERED 0x07
40 #define ERR_ASM_EVENT_IS_INVALID 0x08
41 #define ERR_ASM_EVENT_IS_FULL 0x09
42 #define ERR_ASM_POLICY_CANNOT_PLAY 0x10
43 #define ERR_ASM_POLICY_CANNOT_PLAY_BY_CALL 0x11 /* CALL / VIDEOCALL / RICH_CALL */
44 #define ERR_ASM_POLICY_CANNOT_PLAY_BY_ALARM 0x12
45 #define ERR_ASM_POLICY_INVALID_HANDLE 0x1f
46 #define ERR_ASM_INVALID_PARAMETER 0x20
47 #define ERR_ASM_VCONF_ERROR 0x21
48 #define ERR_ASM_UNKNOWN_ERROR 0x2F
49 #define ERR_ASM_HANDLE_IS_FULL 0x30
51 #define ERR_ASM_CHECK_PRIVILEGE_FAILED 0x40
52 #define COOKIE_SIZE 20
56 #define ASM_PRIORITY_MATRIX_MIN (ASM_EVENT_MAX-1)
57 #define ASM_SERVER_HANDLE_MAX 256
60 #define SOUND_STATUS_KEY "memory/Sound/SoundStatus"
62 * This enumeration defines sound request.
66 ASM_REQUEST_REGISTER = 0,
67 ASM_REQUEST_UNREGISTER,
69 ASM_REQUEST_GETMYSTATE,
71 ASM_REQUEST_EMERGENT_EXIT,
73 ASM_REQUEST_SET_SUBSESSION,
74 ASM_REQUEST_GET_SUBSESSION,
78 * This enumeration defines sound event for Sound Scenario in Multimedia Resources Conflict Manager.
83 ASM_EVENT_NONE = -1, // [Notice] Don't use it in application (Never use it), it is internal sound event
84 ASM_EVENT_SHARE_MMPLAYER = 0,
85 ASM_EVENT_SHARE_MMCAMCORDER,
86 ASM_EVENT_SHARE_MMSOUND,
87 ASM_EVENT_SHARE_OPENAL,
88 ASM_EVENT_SHARE_AVSYSTEM,
89 ASM_EVENT_EXCLUSIVE_MMPLAYER,
90 ASM_EVENT_EXCLUSIVE_MMCAMCORDER,
91 ASM_EVENT_EXCLUSIVE_MMSOUND,
92 ASM_EVENT_EXCLUSIVE_OPENAL,
93 ASM_EVENT_EXCLUSIVE_AVSYSTEM,
96 ASM_EVENT_SHARE_FMRADIO,
97 ASM_EVENT_EXCLUSIVE_FMRADIO,
98 ASM_EVENT_EARJACK_UNPLUG,
104 ASM_EVENT_EXCLUSIVE_RESOURCE,
106 } ASM_sound_events_t;
109 * This enumeration defines event source for sound conflict scenario
113 ASM_EVENT_SOURCE_MEDIA = 0,
114 ASM_EVENT_SOURCE_CALL_START,
115 ASM_EVENT_SOURCE_EARJACK_UNPLUG,
116 ASM_EVENT_SOURCE_RESOURCE_CONFLICT,
117 ASM_EVENT_SOURCE_ALARM_START,
118 ASM_EVENT_SOURCE_ALARM_END,
119 ASM_EVENT_SOURCE_EMERGENCY_START,
120 ASM_EVENT_SOURCE_EMERGENCY_END,
121 ASM_EVENT_SOURCE_OTHER_PLAYER_APP,
122 ASM_EVENT_SOURCE_RESUMABLE_MEDIA,
123 } ASM_event_sources_t;
126 * This enumeration defines sound case between playing sound and request sound
127 * ALTER_PLAY : DTMF tone
132 ASM_CASE_1PLAY_2STOP = 1,
133 ASM_CASE_1STOP_2PLAY = 5,
134 ASM_CASE_1PAUSE_2PLAY = 6,
135 ASM_CASE_1PLAY_2PLAY_MIX = 8,
136 ASM_CASE_RESOURCE_CHECK = 9
142 * This enumeration defines Sound Playing Status Information
143 * Each bit is Sound Status Type( 0 : None , 1 : Playing)
147 ASM_STATUS_NONE = 0x00000000,
148 ASM_STATUS_SHARE_MMPLAYER = 0x00000001,
149 ASM_STATUS_SHARE_MMCAMCORDER = 0x00000002,
150 ASM_STATUS_SHARE_MMSOUND = 0x00000004,
151 ASM_STATUS_SHARE_OPENAL = 0x00000008,
152 ASM_STATUS_SHARE_AVSYSTEM = 0x00000010,
153 ASM_STATUS_EXCLUSIVE_MMPLAYER = 0x00000020,
154 ASM_STATUS_EXCLUSIVE_MMCAMCORDER = 0x00000040,
155 ASM_STATUS_EXCLUSIVE_MMSOUND = 0x00000080,
156 ASM_STATUS_EXCLUSIVE_OPENAL = 0x00000100,
157 ASM_STATUS_EXCLUSIVE_AVSYSTEM = 0x00000200,
158 ASM_STATUS_NOTIFY = 0x00000400,
159 ASM_STATUS_CALL = 0x10000000, //Watch out
160 ASM_STATUS_SHARE_FMRADIO = 0x00000800,
161 ASM_STATUS_EXCLUSIVE_FMRADIO = 0x00001000,
162 ASM_STATUS_EARJACK_UNPLUG = 0x00002000,
163 ASM_STATUS_ALARM = 0x00100000,
164 ASM_STATUS_VIDEOCALL = 0x20000000, //Watch out
165 ASM_STATUS_MONITOR = 0x80000000, //watch out
166 ASM_STATUS_RICH_CALL = 0x40000000, //Watch out
167 ASM_STATUS_EMERGENCY = 0x00004000,
168 ASM_STATUS_EXCLUSIVE_RESOURCE = 0x00008000,
169 } ASM_sound_status_t;
173 * This enumeration defines sound state.
178 ASM_STATE_PLAYING = 1,
179 ASM_STATE_WAITING = 2,
182 ASM_STATE_PAUSE_BY_APP = 5,
183 ASM_STATE_IGNORE = 6,
184 } ASM_sound_states_t;
188 * This enumeration defines resume state
192 ASM_NEED_NOT_RESUME = 0,
194 }ASM_resume_states_t;
196 * This enumeration defines state return of client.
200 ASM_CB_RES_IGNORE = -1,
202 ASM_CB_RES_PLAYING = 1,
204 ASM_CB_RES_PAUSE = 3,
208 * This enumeration defines type of multimedia resource
213 ASM_RESOURCE_NONE = 0x0000,
214 ASM_RESOURCE_CAMERA = 0x0001,
215 ASM_RESOURCE_VIDEO_OVERLAY = 0x0002,
216 ASM_RESOURCE_HW_DECORDER = 0x0100, //this should be removed. miss type
217 ASM_RESOURCE_HW_ENCORDER = 0x0200, //this should be removed. miss type
218 ASM_RESOURCE_HW_DECODER = 0x0100,
219 ASM_RESOURCE_HW_ENCODER = 0x0200,
220 ASM_RESOURCE_RADIO_TUNNER = 0x1000,
221 ASM_RESOURCE_TV_TUNNER = 0x2000,
225 /* Sound command for applications */
228 ASM_COMMAND_NONE = 0x0,
229 ASM_COMMAND_PLAY = 0x2,
230 ASM_COMMAND_STOP = 0x3,
231 ASM_COMMAND_PAUSE = 0x4,
232 ASM_COMMAND_RESUME = 0x5,
233 } ASM_sound_commands_t;
237 * This structure defines the message data from library to conflict manager.
242 ASM_requests_t request_id;
243 ASM_sound_events_t sound_event;
244 ASM_sound_states_t sound_state;
245 ASM_resource_t system_resource;
247 unsigned char cookie [COOKIE_SIZE];
249 } __ASM_msg_data_lib_to_asm_t;
252 * This structure defines the message data from conflict manager to library.
258 ASM_sound_commands_t result_sound_command;
259 ASM_sound_states_t result_sound_state;
260 ASM_sound_events_t former_sound_event;
264 } __ASM_msg_data_asm_to_lib_t;
267 * This structure defines the message data from conflict manager to library.
272 ASM_sound_commands_t result_sound_command;
273 } __ASM_msg_data_asm_to_cb_t;
276 * This structure defines the message from library to conflict manager.
280 long int instance_id;
281 __ASM_msg_data_lib_to_asm_t data;
282 } ASM_msg_lib_to_asm_t;
285 * This structure defines the message from conflict manager to library.
289 long int instance_id;
290 __ASM_msg_data_asm_to_lib_t data;
291 } ASM_msg_asm_to_lib_t;
294 * This structure defines the message from conflict manager to library.
298 long int instance_id;
299 __ASM_msg_data_asm_to_cb_t data;
300 } ASM_msg_asm_to_cb_t;
305 ASM_sound_events_t sound_event;
306 ASM_sound_status_t sound_status;
307 }ASM_sound_event_type_t;
310 static const ASM_sound_event_type_t ASM_sound_type[] = {
311 { ASM_EVENT_NONE, ASM_STATUS_NONE },
312 { ASM_EVENT_SHARE_MMPLAYER, ASM_STATUS_SHARE_MMPLAYER },
313 { ASM_EVENT_SHARE_MMCAMCORDER, ASM_STATUS_SHARE_MMCAMCORDER },
314 { ASM_EVENT_SHARE_MMSOUND, ASM_STATUS_SHARE_MMSOUND },
315 { ASM_EVENT_SHARE_OPENAL, ASM_STATUS_SHARE_OPENAL },
316 { ASM_EVENT_SHARE_AVSYSTEM, ASM_STATUS_SHARE_AVSYSTEM },
317 { ASM_EVENT_EXCLUSIVE_MMPLAYER, ASM_STATUS_EXCLUSIVE_MMPLAYER },
318 { ASM_EVENT_EXCLUSIVE_MMCAMCORDER, ASM_STATUS_EXCLUSIVE_MMCAMCORDER },
319 { ASM_EVENT_EXCLUSIVE_MMSOUND, ASM_STATUS_EXCLUSIVE_MMSOUND },
320 { ASM_EVENT_EXCLUSIVE_OPENAL, ASM_STATUS_EXCLUSIVE_OPENAL },
321 { ASM_EVENT_EXCLUSIVE_AVSYSTEM, ASM_STATUS_EXCLUSIVE_AVSYSTEM },
322 { ASM_EVENT_NOTIFY, ASM_STATUS_NOTIFY },
323 { ASM_EVENT_CALL, ASM_STATUS_CALL },
324 { ASM_EVENT_SHARE_FMRADIO, ASM_STATUS_SHARE_FMRADIO },
325 { ASM_EVENT_EXCLUSIVE_FMRADIO, ASM_STATUS_EXCLUSIVE_FMRADIO },
326 { ASM_EVENT_EARJACK_UNPLUG, ASM_STATUS_EARJACK_UNPLUG },
327 { ASM_EVENT_ALARM, ASM_STATUS_ALARM },
328 { ASM_EVENT_VIDEOCALL, ASM_STATUS_VIDEOCALL },
329 { ASM_EVENT_MONITOR, ASM_STATUS_MONITOR },
330 { ASM_EVENT_RICH_CALL, ASM_STATUS_RICH_CALL },
331 { ASM_EVENT_EMERGENCY, ASM_STATUS_EMERGENCY },
332 { ASM_EVENT_EXCLUSIVE_RESOURCE, ASM_STATUS_EXCLUSIVE_RESOURCE },
341 * This callback function is called when sound status of other sound event is changed
343 * @return No return value
344 * @param[in] sound_status Argument passed when callback was set
346 typedef ASM_cb_result_t (*ASM_sound_cb_t) (int handle, ASM_event_sources_t event_source, ASM_sound_commands_t command, unsigned int sound_status, void* cb_data);