2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 #ifndef __TIZEN_MEDIA_SOUND_MANAGER_H__
21 #define __TIZEN_MEDIA_SOUND_MANAGER_H__
30 #define SOUND_MANAGER_ERROR_CLASS TIZEN_ERROR_MULTIMEDIA_CLASS | 0x30
33 * @file sound_manager.h
34 * @brief This file contains the Sound Manager API
38 * @addtogroup CAPI_MEDIA_SOUND_MANAGER_MODULE
43 * @brief Enumerations of sound type
47 SOUND_TYPE_SYSTEM, /**< Sound type for system */
48 SOUND_TYPE_NOTIFICATION, /**< Sound type for notifications */
49 SOUND_TYPE_ALARM, /**< Sound type for alarm */
50 SOUND_TYPE_RINGTONE, /**< Sound type for ringtones */
51 SOUND_TYPE_MEDIA, /**< Sound type for media */
52 SOUND_TYPE_CALL, /**< Sound type for call */
56 * @brief Enumerations of volume key type
60 VOLUME_KEY_TYPE_NONE=-1, /**< Volume key type for current played sound */
61 VOLUME_KEY_TYPE_SYSTEM=0, /**< Volume key type for system sound */
62 VOLUME_KEY_TYPE_NOTIFICATION, /**< Volume key type for notifications sound*/
63 VOLUME_KEY_TYPE_ALARM, /**< Volume key type for alarm sound */
64 VOLUME_KEY_TYPE_RINGTONE, /**< Volume key type for ringtones sound */
65 VOLUME_KEY_TYPE_MEDIA, /**< Volume key type for media sound */
66 VOLUME_KEY_TYPE_CALL, /**< Volume key type for call sound */
70 * @brief Enumerations of sound route policy
73 SOUND_ROUTE_DEFAULT, /**< Audio device priority: 1. bluetooth headset, 2. wired headset 3. built-in speaker and microphone. */
74 SOUND_ROUTE_IGNORE_A2DP, /**< Audio device priority: 1. wired headset, 2. built-in speaker and microphone. */
75 SOUND_ROUTE_HANDSET_ONLY /**< Use only built-in speaker and microphone */
76 } sound_route_policy_e;
79 * @brief Enumerations of sound device
82 SOUND_DEVICE_NONE, /**< Abnormal case */
83 SOUND_DEVICE_HANDSET, /**< Speaker, Wired headset, Wired earpiece */
84 SOUND_DEVICE_BLUETOOTH /**< Bluetooth */
88 * @brief error codes for sound manager
91 SOUND_MANAGER_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
92 SOUND_MANAGER_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
93 SOUND_MANAGER_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
94 SOUND_MANAGER_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION, /**< Invalid operation */
95 SOUND_MANAGER_ERROR_NO_PLAYING_SOUND = SOUND_MANAGER_ERROR_CLASS | 01, /**< No playing sound */
96 } sound_manager_error_e;
99 * @brief Enumerations of session type
102 SOUND_SESSION_TYPE_SHARE = 0, /**< Share type : shares it's session with other share type application. */
103 SOUND_SESSION_TYPE_EXCLUSIVE, /**< Exclusive type : make previous session stop.*/
104 } sound_session_type_e;
107 * @brief Enumerations of session notification
110 SOUND_SESSION_NOTIFY_STOP = 0, /**< Stop : session of application has interrupted by policy. */
111 SOUND_SESSION_NOTIFY_RESUME, /**< Resume : session interrupt of application has ended. */
112 } sound_session_notify_e;
115 * @brief Enumerations of audio input device type.
118 SOUND_DEVICE_IN_MIC = 0x01, /**< Device builtin mic. */
119 SOUND_DEVICE_IN_WIRED_ACCESSORY = 0x02, /**< Wired input devices */
120 SOUND_DEVICE_IN_BT_SCO = 0x04, /**< Bluetooth SCO device */
124 * @brief Enumerations of audio output device type.
127 SOUND_DEVICE_OUT_SPEAKER = 0x01<<8, /**< Device builtin speaker */
128 SOUND_DEVICE_OUT_RECEIVER = 0x02<<8, /**< Device builtin receiver */
129 SOUND_DEVICE_OUT_WIRED_ACCESSORY = 0x04<<8, /**< Wired output devices such as headphone, headset, and so on. */
130 SOUND_DEVICE_OUT_BT_SCO = 0x08<<8, /**< Bluetooth SCO device */
131 SOUND_DEVICE_OUT_BT_A2DP = 0x10<<8, /**< Bluetooth A2DP device */
132 } sound_device_out_e;
135 * @brief Enumerations of route type.
138 SOUND_ROUTE_OUT_SPEAKER = SOUND_DEVICE_OUT_SPEAKER, /**< Routing audio output to builtin device such as internal speaker. */
139 SOUND_ROUTE_OUT_WIRED_ACCESSORY = SOUND_DEVICE_OUT_WIRED_ACCESSORY,/**< Routing audio output to wired accessory such as headphone, headset, and so on. */
140 SOUND_ROUTE_OUT_BLUETOOTH = SOUND_DEVICE_OUT_BT_A2DP, /**< Routing audio output to bluetooth A2DP. */
141 SOUND_ROUTE_IN_MIC = SOUND_DEVICE_IN_MIC, /**< Routing audio input to device builtin mic. */
142 SOUND_ROUTE_IN_WIRED_ACCESSORY = SOUND_DEVICE_IN_WIRED_ACCESSORY, /**< Routing audio input to wired accessory. */
143 SOUND_ROUTE_IN_MIC_OUT_RECEIVER = SOUND_DEVICE_IN_MIC |SOUND_DEVICE_OUT_RECEIVER, /**< Routing audio input to device builtin mic and routing audio output to builtin receiver*/
144 SOUND_ROUTE_IN_MIC_OUT_SPEAKER = SOUND_DEVICE_IN_MIC |SOUND_DEVICE_OUT_SPEAKER , /**< Routing audio input to device builtin mic and routing audio output to builtin speaker */
145 SOUND_ROUTE_IN_MIC_OUT_HEADPHONE = SOUND_DEVICE_IN_MIC | SOUND_DEVICE_OUT_WIRED_ACCESSORY,/**< Routing audio input to device builtin mic and routing audio output to headphone */
146 SOUND_ROUTE_INOUT_HEADSET = SOUND_DEVICE_IN_WIRED_ACCESSORY | SOUND_DEVICE_OUT_WIRED_ACCESSORY, /**< Routing audio input and output to headset*/
147 SOUND_ROUTE_INOUT_BLUETOOTH = SOUND_DEVICE_IN_BT_SCO |SOUND_DEVICE_OUT_BT_SCO /**< Routing audio input and output to bluetooth SCO */
151 * @brief Enumerations of call session type
154 SOUND_SESSION_TYPE_CALL = 0, /**< call type */
155 SOUND_SESSION_TYPE_VOIP, /**< voip type */
156 } sound_call_session_type_e;
159 * @brief Enumerations of communication session type
162 SOUND_CALL_SESSION_MODE_VOICE = 0, /**< normal voicecall mode */
163 SOUND_CALL_SESSION_MODE_RINGTONE, /**< ringtone mode */
164 SOUND_CALL_SESSION_MODE_MEDIA, /**< media on call mode */
165 } sound_call_session_mode_e;
168 * @brief Enumerations of sound interrupted type
172 SOUND_INTERRUPTED_COMPLETED = 0, /**< Interrupt completed*/
173 SOUND_INTERRUPTED_BY_OTHER_APP, /**< Interrupted by another application*/
174 SOUND_INTERRUPTED_BY_CALL, /**< Interrupted by incoming call*/
175 SOUND_INTERRUPTED_BY_EARJACK_UNPLUG, /**< Interrupted by unplugging headphone*/
176 SOUND_INTERRUPTED_BY_RESOURCE_CONFLICT, /**< Interrupted by resource conflict*/
177 SOUND_INTERRUPTED_BY_ALARM, /**< Interrupted by alarm*/
178 } sound_interrupted_code_e;
181 * @brief Sound call session handle type.
183 typedef struct sound_call_session_s *sound_call_session_h;
186 * @brief Called when the sound session notification has occured.
187 * @param[in] notify The sound session notification
188 * @param[in] user_data The user data passed from the callback registration function
189 * @pre You should register this callback by sound_manager_set_session_notify_cb()
190 * @see sound_manager_set_session_notify_cb()
192 typedef void (*sound_session_notify_cb) (sound_session_notify_e notify, void *user_data);
195 * @brief Called when the playing sound was interrupted.
196 * @param[in] code The interrupted code
197 * @param[in] user_data The user data passed from the callback registration function
198 * @pre You should register this callback by sound_manager_set_interrupted_cb()
199 * @see sound_manager_set_interrupted_cb()
201 typedef void(* sound_interrupted_cb)(sound_interrupted_code_e code, void *user_data);
205 * @brief Called when the system volume has changed.
206 * @param[in] type The sound type of changed volume
207 * @param[in] volume The new volume value
208 * @param[in] user_data The user data passed from the callback registration function
209 * @pre sound_manager_set_volume() will invoke this callback if you register it using sound_manager_set_volume_changed_cb()
210 * @see sound_manager_set_volume_changed_cb()
211 * @see sound_manager_unset_volume_changed_cb()
213 typedef void (*sound_manager_volume_changed_cb)(sound_type_e type, unsigned int volume, void *user_data);
216 * @brief Called when the sound route policy has changes.
217 * @param[in] route The new sound route policy
218 * @param[in] user_data The user data passed from the callback registration function
219 * @pre sound_manager_set_route_policy() will invoke this callback if you register it using sound_manager_set_route_policy_changed_cb()
220 * @see sound_manager_set_route_policy_changed_cb()
221 * @see sound_manager_unset_route_policy_changed_cb()
223 typedef void (*sound_manager_route_policy_changed_cb)(sound_route_policy_e route, void *user_data);
226 * @brief Gets the maximum volume level supported for a particular sound type
227 * @param[in] type The sound type
228 * @param[out] max The maximum volume level
229 * @return 0 on success, otherwise a negative error value.
230 * @retval #SOUND_MANAGER_ERROR_NONE Success
231 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
232 * @see sound_manager_set_volume()
234 int sound_manager_get_max_volume(sound_type_e type, int *max);
237 * @brief Sets the volume level specified for a particular sound type
238 * @param[in] type The sound type
239 * @param[out] volume The volume level to be set
240 * @return 0 on success, otherwise a negative error value.
241 * @retval #SOUND_MANAGER_ERROR_NONE Success
242 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
243 * @see sound_manager_get_max_volume()
244 * @see sound_manager_get_volume()
246 int sound_manager_set_volume(sound_type_e type, int volume);
249 * @brief Gets the volume level specified for a particular sound type
250 * @param[in] type The sound type
251 * @param[out] volume The current volume level
252 * @return 0 on success, otherwise a negative error value.
253 * @retval #SOUND_MANAGER_ERROR_NONE Success
254 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
255 * @see sound_manager_get_max_volume()
256 * @see sound_manager_set_volume()
258 int sound_manager_get_volume(sound_type_e type, int *volume);
261 * @brief Gets the current playing sound type
262 * @param[out] type The current sound type
263 * @return 0 on success, otherwise a negative error value.
264 * @retval #SOUND_MANAGER_ERROR_NONE Success
265 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
266 * @retval #SOUND_MANAGER_ERROR_NO_PLAYING_SOUND No playing sound
267 * @see sound_manager_get_current_sound_device()
268 * @see player_set_sound_type()
269 * @see audio_out_create()
270 * @see wav_player_start()
272 int sound_manager_get_current_sound_type(sound_type_e *type);
275 * @brief Gets the current device type
276 * @param[out] device The current sound device
277 * @return 0 on success, otherwise a negative error value.
278 * @retval #SOUND_MANAGER_ERROR_NONE Success
279 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
280 * @retval #SOUND_MANAGER_ERROR_NO_PLAYING_SOUND No playing sound
281 * @see sound_manager_get_current_sound_type()
283 int sound_manager_get_current_sound_device(sound_device_e *device);
286 * @brief Registers a callback function to be invoked when the volume level is changed.
287 * @param[in] callback Callback function to indicate change in volume
288 * @param[in] user_data The user data to be passed to the callback function
289 * @return 0 on success, otherwise a negative error value.
290 * @retval #SOUND_MANAGER_ERROR_NONE Success
291 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
292 * @post sound_manager_volume_changed_cb() will be invoked
293 * @see sound_manager_unset_volume_changed_cb()
294 * @see sound_manager_volume_changed_cb()
296 int sound_manager_set_volume_changed_cb(sound_manager_volume_changed_cb callback, void *user_data);
299 * @brief Unregisters the volume change callback
300 * @see sound_manager_set_volume_changed_cb()
302 void sound_manager_unset_volume_changed_cb(void);
305 * @brief Gets the A2DP activation information.
306 * @remarks If @a connected is @c true, @a bt_name must be released with free() by you. If @a connected is @c false, @a bt_name is set to NULL.
307 * @param[out] connected The Bluetooth A2DP connection status (@c true = connected, @c false = disconnected)
308 * @param[out] bt_name The Bluetooth A2DP connected device name
309 * @return 0 on success, otherwise a negative error value.
310 * @retval #SOUND_MANAGER_ERROR_NONE Success
311 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
312 * @retval #SOUND_MANAGER_ERROR_INVALID_OPERATION Invalid operation
314 int sound_manager_get_a2dp_status(bool *connected, char **bt_name);
318 * @brief Sets the application's sound session type
319 * @param[in] type The session type to set
320 * @return 0 on success, otherwise a negative error value.
321 * @retval #SOUND_MANAGER_ERROR_NONE Success
322 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
324 int sound_manager_set_session_type(sound_session_type_e type);
327 * @brief Registers a callback function to be invoked when the sound session notification is occured.
328 * @param[in] callback The session notify callback function
329 * @param[in] user_data The user data to be passed to the callback function
330 * @return 0 on success, otherwise a negative error value.
331 * @retval #SOUND_MANAGER_ERROR_NONE Success
332 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
333 * @post sound_session_notify_cb() will be invoked
334 * @see sound_manager_unset_session_notify_cb()
335 * @see sound_session_notify_cb()
337 int sound_manager_set_session_notify_cb(sound_session_notify_cb callback, void *user_data);
340 * @brief Unregisters the callback function which is called when the session notification is occured
341 * @see sound_manager_set_session_notify_cb()
343 void sound_manager_unset_session_notify_cb(void);
346 * @brief Registers a callback function to be invoked when the playing sound was interrupted.
347 * @param[in] callback The interrupted callback function
348 * @param[in] user_data The user data to be passed to the callback function
349 * @return 0 on success, otherwise a negative error value.
350 * @retval #SOUND_MANAGER_ERROR_NONE Success
351 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
352 * @post sound_interrupted_cb() will be invoked
353 * @see sound_manager_unset_interrupted_cb()
354 * @see sound_interrupted_cb()
356 int sound_manager_set_interrupted_cb(sound_interrupted_cb callback, void *user_data);
359 * @brief Unregisters the callback function which is called when the playing sound was interrupted
360 * @see sound_manager_set_interrupted_cb()
362 void sound_manager_unset_interrupted_cb(void);
367 * @brief Sets the volume key type
368 * @param[in] type The volume key type to set
369 * @return 0 on success, otherwise a negative error value.
370 * @retval #SOUND_MANAGER_ERROR_NONE Success
371 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
373 int sound_manager_set_volume_key_type(volume_key_type_e type);
376 * @brief Gets called iteratively to notify you of available route.
377 * @param[in] route The available route
378 * @param[in] user_data The user data passed from the foreach function
379 * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop
380 * @pre sound_manager_foreach_available_route() will invoke this callback.
381 * @see sound_manager_foreach_available_route()
383 typedef bool(* sound_available_route_cb)(sound_route_e route, void *user_data);
386 * @brief Called when the available audio route is changed.
387 * @param[in] route The audio route
388 * @param[in] available The status of given route
389 * @param[in] user_data The user data passed from the foreach function
390 * @pre sound_manager_foreach_available_route() will invoke this callback.
391 * @see sound_manager_foreach_available_route()
393 typedef void(* sound_available_route_changed_cb)(sound_route_e route, bool available, void *user_data);
396 * @brief Called when the audio route is changed.
397 * @param[in] route The audio route
398 * @param[in] user_data The user data passed from the callback registration function
399 * @pre You should register this callback by sound_manager_set_active_device_changed_cb()
400 * @see sound_manager_set_active_device_changed_cb()
402 typedef void(* sound_active_device_changed_cb)(sound_device_in_e in, sound_device_out_e out, void *user_data);
405 * @brief Retrieves all available audio routes by invoking a specific callback for each valid route.
406 * @param[in] callback The session notify callback function
407 * @param[in] user_data The user data to be passed to the callback function
408 * @return 0 on success, otherwise a negative error value.
409 * @retval #SOUND_MANAGER_ERROR_NONE Success
410 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
411 * @post sound_available_route_cb() will be invoked
412 * @see sound_available_route_cb()
414 int sound_manager_foreach_available_route (sound_available_route_cb callback, void *user_data);
417 * @brief Changes the audio routes.
418 * @param[in] route The route to set
419 * @return 0 on success, otherwise a negative error value.
420 * @retval #SOUND_MANAGER_ERROR_NONE Success
421 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
422 * @see sound_manager_get_active_device()
424 int sound_manager_set_active_route (sound_route_e route);
427 * @brief Changes the audio route.
428 * @param[out] in The current sound input device
429 * @param[out] in The current sound output device
430 * @return 0 on success, otherwise a negative error value.
431 * @retval #SOUND_MANAGER_ERROR_NONE Success
432 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
433 * @see sound_manager_set_active_route()
435 int sound_manager_get_active_device (sound_device_in_e *in, sound_device_out_e *out);
438 * @brief Check if given audio route is available or not.
439 * @param[in] route The route to set
440 * @return 0 on success, otherwise a negative error value.
441 * @return @c true if the specified route is supported, \n else @c false
442 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
444 bool sound_manager_is_route_available (sound_route_e route);
447 * @brief Registers a callback function to be invoked when the available status is changed.
448 * @param[in] callback The available status changed callback function
449 * @param[in] user_data The user data to be passed to the callback function
450 * @return 0 on success, otherwise a negative error value.
451 * @retval #SOUND_MANAGER_ERROR_NONE Success
452 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
453 * @post sound_available_route_changed_cb() will be invoked
454 * @see sound_manager_unset_available_route_changed_cb()
455 * @see sound_available_route_changed_cb()
457 int sound_manager_set_available_route_changed_cb (sound_available_route_changed_cb callback, void *user_data);
460 * @brief Unregisters the callback function.
461 * @see sound_manager_set_available_route_changed_cb()
463 void sound_manager_unset_available_route_changed_cb (void);
466 * @brief Registers a callback function to be invoked when the audio device is changed.
467 * @param[in] callback The session notify callback function
468 * @param[in] user_data The user data to be passed to the callback function
469 * @return 0 on success, otherwise a negative error value.
470 * @retval #SOUND_MANAGER_ERROR_NONE Success
471 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
472 * @post sound_active_device_changed_cb() will be invoked
473 * @see sound_manager_unset_active_device_changed_cb()
474 * @see sound_active_device_changed_cb()
476 int sound_manager_set_active_device_changed_cb (sound_active_device_changed_cb callback, void *user_data);
479 * @brief Unregisters the callback function which is called when the route notification is occured.
480 * @see sound_manager_set_active_device_changed_cb()
482 void sound_manager_unset_active_device_changed_cb (void);
485 * @brief Creates a call session handle.
486 * @remarks @a session must be released sound_manager_call_session_destroy() by you.
487 * @param[out] session A new handle to call session
488 * @retval #SOUND_MANAGER_ERROR_NONE Successful
489 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
490 * @retval #SOUND_MANAGER_OUT_OF_MEMORY Out of memory
491 * @see sound_manager_call_session_destroy()
493 int sound_manager_call_session_create(sound_call_session_type_e type, sound_call_session_h *session);
496 * @brief Sets the call session mode.
498 * @param[in] session The handle to call session
499 * @param[in] mode The call session mode
500 * @return 0 on success, otherwise a negative error value.
501 * @retval #SOUND_MANAGER_ERROR_NONE Successful
502 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
503 * @see sound_manager_call_session_get_mode()
505 int sound_manager_call_session_set_mode(sound_call_session_h session, sound_call_session_mode_e mode);
508 * @brief Gets the call session mode.
510 * @param[in] session The handle to call session
511 * @param[out] mode The call session mode
512 * @return 0 on success, otherwise a negative error value.
513 * @retval #SOUND_MANAGER_ERROR_NONE Successful
514 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
515 * @see sound_manager_call_session_set_mode()
517 int sound_manager_call_session_get_mode(sound_call_session_h session, sound_call_session_mode_e *mode);
520 * @brief Destroys the call session handle.
522 * @param[in] session The handle to call session to be destroyed
523 * @return 0 on success, otherwise a negative error value.
524 * @retval #SOUND_MANAGER_ERROR_NONE Successful
525 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
526 * @see sound_manager_call_session_create()
528 int sound_manager_call_session_destroy(sound_call_session_h session);
534 __attribute__ ((deprecated)) int sound_manager_set_route_policy (sound_route_policy_e route);
535 __attribute__ ((deprecated)) int sound_manager_get_route_policy (sound_route_policy_e *route);
536 __attribute__ ((deprecated)) int sound_manager_set_route_policy_changed_cb(sound_manager_route_policy_changed_cb callback, void *user_data);
537 __attribute__ ((deprecated)) void sound_manager_unset_route_policy_changed_cb(void);
544 #endif /* __TIZEN_MEDIA_SOUND_MANAGER_H__ */