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 error codes for sound manager
73 SOUND_MANAGER_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
74 SOUND_MANAGER_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
75 SOUND_MANAGER_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
76 SOUND_MANAGER_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION, /**< Invalid operation */
77 SOUND_MANAGER_ERROR_NO_PLAYING_SOUND = SOUND_MANAGER_ERROR_CLASS | 01, /**< No playing sound */
78 } sound_manager_error_e;
81 * @brief Enumerations of session type
84 SOUND_SESSION_TYPE_SHARE = 0, /**< Share type : shares it's session with other share type application. */
85 SOUND_SESSION_TYPE_EXCLUSIVE, /**< Exclusive type : make previous session stop.*/
86 SOUND_SESSION_TYPE_ALARM, /**< Alarm type */
87 SOUND_SESSION_TYPE_EMERGENCY, /**< Emergency type */
88 } sound_session_type_e;
91 * @brief Enumerations of session notification
94 SOUND_SESSION_NOTIFY_STOP = 0, /**< Stop : session of application has interrupted by policy. */
95 SOUND_SESSION_NOTIFY_RESUME, /**< Resume : session interrupt of application has ended. */
96 } sound_session_notify_e;
99 * @brief Enumerations of audio input device type.
102 SOUND_DEVICE_IN_MIC = 0x01, /**< Device builtin mic. */
103 SOUND_DEVICE_IN_WIRED_ACCESSORY = 0x02, /**< Wired input devices */
104 SOUND_DEVICE_IN_BT_SCO = 0x04, /**< Bluetooth SCO device */
108 * @brief Enumerations of audio output device type.
111 SOUND_DEVICE_OUT_SPEAKER = 0x01<<8, /**< Device builtin speaker */
112 SOUND_DEVICE_OUT_RECEIVER = 0x02<<8, /**< Device builtin receiver */
113 SOUND_DEVICE_OUT_WIRED_ACCESSORY = 0x04<<8, /**< Wired output devices such as headphone, headset, and so on. */
114 SOUND_DEVICE_OUT_BT_SCO = 0x08<<8, /**< Bluetooth SCO device */
115 SOUND_DEVICE_OUT_BT_A2DP = 0x10<<8, /**< Bluetooth A2DP device */
116 SOUND_DEVICE_OUT_DOCK = 0x020<<8, /**< DOCK device */
117 SOUND_DEVICE_OUT_HDMI = 0x040<<8, /**< HDMI device */
118 SOUND_DEVICE_OUT_WFD = 0x080<<8, /**< WFD device */
119 SOUND_DEVICE_OUT_USB_AUDIO = 0x100<<8, /**< USB Audio device */
120 } sound_device_out_e;
123 * @brief Enumerations of route type.
126 SOUND_ROUTE_OUT_SPEAKER = SOUND_DEVICE_OUT_SPEAKER, /**< Routing audio output to builtin device such as internal speaker. */
127 SOUND_ROUTE_OUT_WIRED_ACCESSORY = SOUND_DEVICE_OUT_WIRED_ACCESSORY,/**< Routing audio output to wired accessory such as headphone, headset, and so on. */
128 SOUND_ROUTE_OUT_BLUETOOTH = SOUND_DEVICE_OUT_BT_A2DP, /**< Routing audio output to bluetooth A2DP. */
129 SOUND_ROUTE_OUT_DOCK = SOUND_DEVICE_OUT_DOCK, /**< Routing audio output to DOCK */
130 SOUND_ROUTE_OUT_HDMI = SOUND_DEVICE_OUT_HDMI, /**< Routing audio output to HDMI */
131 SOUND_ROUTE_OUT_WFD = SOUND_DEVICE_OUT_WFD, /**< Routing audio output to WFD */
132 SOUND_ROUTE_OUT_USB_AUDIO = SOUND_DEVICE_OUT_USB_AUDIO, /**< Routing audio output to USB Audio */
133 SOUND_ROUTE_IN_MIC = SOUND_DEVICE_IN_MIC, /**< Routing audio input to device builtin mic. */
134 SOUND_ROUTE_IN_WIRED_ACCESSORY = SOUND_DEVICE_IN_WIRED_ACCESSORY, /**< Routing audio input to wired accessory. */
135 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*/
136 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 */
137 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 */
138 SOUND_ROUTE_INOUT_HEADSET = SOUND_DEVICE_IN_WIRED_ACCESSORY | SOUND_DEVICE_OUT_WIRED_ACCESSORY, /**< Routing audio input and output to headset*/
139 SOUND_ROUTE_INOUT_BLUETOOTH = SOUND_DEVICE_IN_BT_SCO |SOUND_DEVICE_OUT_BT_SCO /**< Routing audio input and output to bluetooth SCO */
143 * @brief Enumerations of call session type
146 SOUND_CALL_SESSION_TYPE_CALL = 0, /**< call type */
147 SOUND_CALL_SESSION_TYPE_VOIP = 1, /**< voip type */
148 SOUND_SESSION_TYPE_CALL = 0,
149 SOUND_SESSION_TYPE_VOIP = 1,
150 } sound_call_session_type_e;
153 * @brief Enumerations of communication session type
156 SOUND_CALL_SESSION_MODE_VOICE = 0, /**< normal talking mode */
157 SOUND_CALL_SESSION_MODE_RINGTONE, /**< ringtone mode */
158 SOUND_CALL_SESSION_MODE_MEDIA, /**< notification sound in call*/
159 } sound_call_session_mode_e;
162 * @brief Enumerations of sound interrupted type
166 SOUND_INTERRUPTED_COMPLETED = 0, /**< Interrupt completed*/
167 SOUND_INTERRUPTED_BY_MEDIA, /**< Interrupted by non-resumable media application*/
168 SOUND_INTERRUPTED_BY_CALL, /**< Interrupted by incoming call*/
169 SOUND_INTERRUPTED_BY_EARJACK_UNPLUG, /**< Interrupted by unplugging headphone*/
170 SOUND_INTERRUPTED_BY_RESOURCE_CONFLICT, /**< Interrupted by resource conflict*/
171 SOUND_INTERRUPTED_BY_ALARM, /**< Interrupted by alarm*/
172 SOUND_INTERRUPTED_BY_EMERGENCY, /**< Interrupted by emergency*/
173 SOUND_INTERRUPTED_BY_RESUMABLE_MEDIA, /**< Interrupted by resumable media application*/
174 } sound_interrupted_code_e;
177 * @brief Sound call session handle type.
179 typedef struct sound_call_session_s *sound_call_session_h;
182 * @brief Called when the sound session notification has occured.
183 * @param[in] notify The sound session notification
184 * @param[in] user_data The user data passed from the callback registration function
185 * @pre You should register this callback by sound_manager_set_session_notify_cb()
186 * @see sound_manager_set_session_notify_cb()
188 typedef void (*sound_session_notify_cb) (sound_session_notify_e notify, void *user_data);
191 * @brief Called when the playing sound was interrupted.
192 * @param[in] code The interrupted code
193 * @param[in] user_data The user data passed from the callback registration function
194 * @pre You should register this callback by sound_manager_set_interrupted_cb()
195 * @see sound_manager_set_interrupted_cb()
197 typedef void(* sound_interrupted_cb)(sound_interrupted_code_e code, void *user_data);
201 * @brief Called when the system volume has changed.
202 * @param[in] type The sound type of changed volume
203 * @param[in] volume The new volume value
204 * @param[in] user_data The user data passed from the callback registration function
205 * @pre sound_manager_set_volume() will invoke this callback if you register it using sound_manager_set_volume_changed_cb()
206 * @see sound_manager_set_volume_changed_cb()
207 * @see sound_manager_unset_volume_changed_cb()
209 typedef void (*sound_manager_volume_changed_cb)(sound_type_e type, unsigned int volume, void *user_data);
212 * @brief Gets the maximum volume level supported for a particular sound type
213 * @param[in] type The sound type
214 * @param[out] max The maximum volume level
215 * @return 0 on success, otherwise a negative error value.
216 * @retval #SOUND_MANAGER_ERROR_NONE Success
217 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
218 * @see sound_manager_set_volume()
220 int sound_manager_get_max_volume(sound_type_e type, int *max);
223 * @brief Sets the volume level specified for a particular sound type
224 * @param[in] type The sound type
225 * @param[out] volume The volume level to be set
226 * @return 0 on success, otherwise a negative error value.
227 * @retval #SOUND_MANAGER_ERROR_NONE Success
228 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
229 * @see sound_manager_get_max_volume()
230 * @see sound_manager_get_volume()
232 int sound_manager_set_volume(sound_type_e type, int volume);
235 * @brief Gets the volume level specified for a particular sound type
236 * @param[in] type The sound type
237 * @param[out] volume The current volume level
238 * @return 0 on success, otherwise a negative error value.
239 * @retval #SOUND_MANAGER_ERROR_NONE Success
240 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
241 * @see sound_manager_get_max_volume()
242 * @see sound_manager_set_volume()
244 int sound_manager_get_volume(sound_type_e type, int *volume);
247 * @brief Gets the current playing sound type
248 * @param[out] type The current sound type
249 * @return 0 on success, otherwise a negative error value.
250 * @retval #SOUND_MANAGER_ERROR_NONE Success
251 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
252 * @retval #SOUND_MANAGER_ERROR_NO_PLAYING_SOUND No playing sound
253 * @see player_set_sound_type()
254 * @see audio_out_create()
255 * @see wav_player_start()
257 int sound_manager_get_current_sound_type(sound_type_e *type);
260 * @brief Registers a callback function to be invoked when the volume level is changed.
261 * @param[in] callback Callback function to indicate change in volume
262 * @param[in] user_data The user data to be passed to the callback function
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 * @post sound_manager_volume_changed_cb() will be invoked
267 * @see sound_manager_unset_volume_changed_cb()
268 * @see sound_manager_volume_changed_cb()
270 int sound_manager_set_volume_changed_cb(sound_manager_volume_changed_cb callback, void *user_data);
273 * @brief Unregisters the volume change callback
274 * @see sound_manager_set_volume_changed_cb()
276 void sound_manager_unset_volume_changed_cb(void);
279 * @brief Gets the A2DP activation information.
280 * @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.
281 * @param[out] connected The Bluetooth A2DP connection status (@c true = connected, @c false = disconnected)
282 * @param[out] bt_name The Bluetooth A2DP connected device name
283 * @return 0 on success, otherwise a negative error value.
284 * @retval #SOUND_MANAGER_ERROR_NONE Success
285 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
286 * @retval #SOUND_MANAGER_ERROR_INVALID_OPERATION Invalid operation
288 int sound_manager_get_a2dp_status(bool *connected, char **bt_name);
292 * @brief Sets the application's sound session type
293 * @param[in] type The session type to set
294 * @return 0 on success, otherwise a negative error value.
295 * @retval #SOUND_MANAGER_ERROR_NONE Success
296 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
298 int sound_manager_set_session_type(sound_session_type_e type);
302 * @brief Gets the application's sound session type
303 * @param[in] type The session type
304 * @return 0 on success, otherwise a negative error value.
305 * @retval #SOUND_MANAGER_ERROR_NONE Success
306 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
308 int sound_manager_get_session_type(sound_session_type_e *type);
312 * @brief Registers a callback function to be invoked when the sound session notification is occured.
313 * @param[in] callback The session notify callback function
314 * @param[in] user_data The user data to be passed to the callback function
315 * @return 0 on success, otherwise a negative error value.
316 * @retval #SOUND_MANAGER_ERROR_NONE Success
317 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
318 * @post sound_session_notify_cb() will be invoked
319 * @see sound_manager_unset_session_notify_cb()
320 * @see sound_session_notify_cb()
322 int sound_manager_set_session_notify_cb(sound_session_notify_cb callback, void *user_data);
325 * @brief Unregisters the callback function which is called when the session notification is occured
326 * @see sound_manager_set_session_notify_cb()
328 void sound_manager_unset_session_notify_cb(void);
331 * @brief Registers a callback function to be invoked when the playing sound was interrupted.
332 * @param[in] callback The interrupted callback function
333 * @param[in] user_data The user data to be passed to the callback function
334 * @return 0 on success, otherwise a negative error value.
335 * @retval #SOUND_MANAGER_ERROR_NONE Success
336 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
337 * @post sound_interrupted_cb() will be invoked
338 * @see sound_manager_unset_interrupted_cb()
339 * @see sound_interrupted_cb()
341 int sound_manager_set_interrupted_cb(sound_interrupted_cb callback, void *user_data);
344 * @brief Unregisters the callback function which is called when the playing sound was interrupted
345 * @see sound_manager_set_interrupted_cb()
347 void sound_manager_unset_interrupted_cb(void);
352 * @brief Sets the volume key type
353 * @param[in] type The volume key type to set
354 * @return 0 on success, otherwise a negative error value.
355 * @retval #SOUND_MANAGER_ERROR_NONE Success
356 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
358 int sound_manager_set_volume_key_type(volume_key_type_e type);
361 * @brief Gets called iteratively to notify you of available route.
362 * @param[in] route The available route
363 * @param[in] user_data The user data passed from the foreach function
364 * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop
365 * @pre sound_manager_foreach_available_route() will invoke this callback.
366 * @see sound_manager_foreach_available_route()
368 typedef bool(* sound_available_route_cb)(sound_route_e route, void *user_data);
371 * @brief Called when the available audio route is changed.
372 * @param[in] route The audio route
373 * @param[in] available The status of given route
374 * @param[in] user_data The user data passed from the foreach function
375 * @pre sound_manager_foreach_available_route() will invoke this callback.
376 * @see sound_manager_foreach_available_route()
378 typedef void(* sound_available_route_changed_cb)(sound_route_e route, bool available, void *user_data);
381 * @brief Called when the audio route is changed.
382 * @param[in] route The audio route
383 * @param[in] user_data The user data passed from the callback registration function
384 * @pre You should register this callback by sound_manager_set_active_device_changed_cb()
385 * @see sound_manager_set_active_device_changed_cb()
387 typedef void(* sound_active_device_changed_cb)(sound_device_in_e in, sound_device_out_e out, void *user_data);
390 * @brief Retrieves all available audio routes by invoking a specific callback for each valid route.
391 * @param[in] callback The session notify callback function
392 * @param[in] user_data The user data to be passed to the callback function
393 * @return 0 on success, otherwise a negative error value.
394 * @retval #SOUND_MANAGER_ERROR_NONE Success
395 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
396 * @post sound_available_route_cb() will be invoked
397 * @see sound_available_route_cb()
399 int sound_manager_foreach_available_route (sound_available_route_cb callback, void *user_data);
402 * @brief Changes the audio routes.
403 * @param[in] route The route to set
404 * @return 0 on success, otherwise a negative error value.
405 * @retval #SOUND_MANAGER_ERROR_NONE Success
406 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
407 * @see sound_manager_get_active_device()
409 int sound_manager_set_active_route (sound_route_e route);
412 * @brief Changes the audio route.
413 * @param[out] in The current sound input device
414 * @param[out] in The current sound output device
415 * @return 0 on success, otherwise a negative error value.
416 * @retval #SOUND_MANAGER_ERROR_NONE Success
417 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
418 * @see sound_manager_set_active_route()
420 int sound_manager_get_active_device (sound_device_in_e *in, sound_device_out_e *out);
423 * @brief Check if given audio route is available or not.
424 * @param[in] route The route to set
425 * @return 0 on success, otherwise a negative error value.
426 * @return @c true if the specified route is supported, \n else @c false
427 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
429 bool sound_manager_is_route_available (sound_route_e route);
432 * @brief Registers a callback function to be invoked when the available status is changed.
433 * @param[in] callback The available status changed callback function
434 * @param[in] user_data The user data to be passed to the callback function
435 * @return 0 on success, otherwise a negative error value.
436 * @retval #SOUND_MANAGER_ERROR_NONE Success
437 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
438 * @post sound_available_route_changed_cb() will be invoked
439 * @see sound_manager_unset_available_route_changed_cb()
440 * @see sound_available_route_changed_cb()
442 int sound_manager_set_available_route_changed_cb (sound_available_route_changed_cb callback, void *user_data);
445 * @brief Unregisters the callback function.
446 * @see sound_manager_set_available_route_changed_cb()
448 void sound_manager_unset_available_route_changed_cb (void);
451 * @brief Registers a callback function to be invoked when the audio device is changed.
452 * @param[in] callback The session notify callback function
453 * @param[in] user_data The user data to be passed to the callback function
454 * @return 0 on success, otherwise a negative error value.
455 * @retval #SOUND_MANAGER_ERROR_NONE Success
456 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
457 * @post sound_active_device_changed_cb() will be invoked
458 * @see sound_manager_unset_active_device_changed_cb()
459 * @see sound_active_device_changed_cb()
461 int sound_manager_set_active_device_changed_cb (sound_active_device_changed_cb callback, void *user_data);
464 * @brief Unregisters the callback function which is called when the route notification is occured.
465 * @see sound_manager_set_active_device_changed_cb()
467 void sound_manager_unset_active_device_changed_cb (void);
470 * @brief Creates a call session handle.
471 * @remarks @a session must be released sound_manager_call_session_destroy() by you.
472 * @param[out] session A new handle to call session
473 * @retval #SOUND_MANAGER_ERROR_NONE Successful
474 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
475 * @retval #SOUND_MANAGER_OUT_OF_MEMORY Out of memory
476 * @see sound_manager_call_session_destroy()
478 int sound_manager_call_session_create(sound_call_session_type_e type, sound_call_session_h *session);
481 * @brief Sets the call session mode.
483 * @param[in] session The handle to call session
484 * @param[in] mode The call session mode
485 * @return 0 on success, otherwise a negative error value.
486 * @retval #SOUND_MANAGER_ERROR_NONE Successful
487 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
488 * @see sound_manager_call_session_get_mode()
490 int sound_manager_call_session_set_mode(sound_call_session_h session, sound_call_session_mode_e mode);
493 * @brief Gets the call session mode.
495 * @param[in] session The handle to call session
496 * @param[out] mode The call session mode
497 * @return 0 on success, otherwise a negative error value.
498 * @retval #SOUND_MANAGER_ERROR_NONE Successful
499 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
500 * @see sound_manager_call_session_set_mode()
502 int sound_manager_call_session_get_mode(sound_call_session_h session, sound_call_session_mode_e *mode);
505 * @brief Destroys the call session handle.
507 * @param[in] session The handle to call session to be destroyed
508 * @return 0 on success, otherwise a negative error value.
509 * @retval #SOUND_MANAGER_ERROR_NONE Successful
510 * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
511 * @see sound_manager_call_session_create()
513 int sound_manager_call_session_destroy(sound_call_session_h session);
523 #endif /* __TIZEN_MEDIA_SOUND_MANAGER_H__ */