apply new version of audio-io for tizen 3.0
[platform/core/api/audio-io.git] / include / audio_io.h
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #ifndef __TIZEN_MEDIA_AUDIO_IO_H__
18 #define __TIZEN_MEDIA_AUDIO_IO_H__
19
20 #include <tizen.h>
21 #include <sound_manager.h>
22 #include <sys/types.h>
23
24 #ifdef __cplusplus
25 extern "C"
26 {
27 #endif
28
29 /**
30  * @file audio_io.h
31  * @brief This file contains the Audio Input and Audio Output API.
32  */
33
34 /**
35  * @addtogroup CAPI_MEDIA_AUDIO_IN_MODULE
36  * @{
37  */
38
39 /**
40  * @brief The audio input handle.
41  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
42  */
43 typedef struct audio_io_s *audio_in_h;
44
45 /**
46  * @}
47  */
48
49 /**
50  * @addtogroup CAPI_MEDIA_AUDIO_OUT_MODULE
51  * @{
52  */
53
54 /**
55  * @brief The audio output handle.
56  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
57  */
58 typedef struct audio_io_s *audio_out_h;
59
60  /**
61  * @}
62  */
63
64 /**
65  * @addtogroup CAPI_MEDIA_AUDIO_IO_MODULE
66  * @{
67  */
68
69 /**
70  * @brief Enumeration for audio sample type with bit depth.
71  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
72  */
73 typedef enum
74 {
75     AUDIO_SAMPLE_TYPE_U8 = 0x70,    /**< Unsigned 8-bit audio samples */
76     AUDIO_SAMPLE_TYPE_S16_LE,       /**< Signed 16-bit audio samples */
77 } audio_sample_type_e;
78
79 /**
80  * @brief Enumeration for audio channel.
81  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
82  */
83 typedef enum {
84     AUDIO_CHANNEL_MONO = 0x80,                  /**< 1 channel, mono */
85     AUDIO_CHANNEL_STEREO,                       /**< 2 channel, stereo */
86 } audio_channel_e;
87
88 /**
89  * @brief Enumeration for audio input and output state.
90  * @since_tizen 3.0
91  */
92 typedef enum
93 {
94     AUDIO_IO_STATE_IDLE,      /**< Audio-io handle is created, but not prepared */
95     AUDIO_IO_STATE_RUNNING,   /**< Audio-io handle is ready and the stream is running */
96     AUDIO_IO_STATE_PAUSED,    /**< Audio-io handle is ready and the stream is paused */
97 } audio_io_state_e;
98
99 /**
100  * @brief Enumeration for audio input and output error.
101  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
102  */
103 typedef enum{
104     AUDIO_IO_ERROR_NONE                = TIZEN_ERROR_NONE,              /**< Successful */
105     AUDIO_IO_ERROR_OUT_OF_MEMORY       = TIZEN_ERROR_OUT_OF_MEMORY,     /**< Out of memory */
106     AUDIO_IO_ERROR_INVALID_PARAMETER   = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
107     AUDIO_IO_ERROR_INVALID_OPERATION   = TIZEN_ERROR_INVALID_OPERATION, /**< Invalid operation */
108     AUDIO_IO_ERROR_PERMISSION_DENIED   = TIZEN_ERROR_PERMISSION_DENIED, /**< Device open error by security */
109     AUDIO_IO_ERROR_NOT_SUPPORTED       = TIZEN_ERROR_NOT_SUPPORTED,     /**< Not supported */
110     AUDIO_IO_ERROR_DEVICE_NOT_OPENED   = TIZEN_ERROR_AUDIO_IO | 0x01,   /**< Device open error */
111     AUDIO_IO_ERROR_DEVICE_NOT_CLOSED   = TIZEN_ERROR_AUDIO_IO | 0x02,   /**< Device close error */
112     AUDIO_IO_ERROR_INVALID_BUFFER      = TIZEN_ERROR_AUDIO_IO | 0x03,   /**< Invalid buffer pointer */
113     AUDIO_IO_ERROR_SOUND_POLICY        = TIZEN_ERROR_AUDIO_IO | 0x04,   /**< Sound policy error */
114     AUDIO_IO_ERROR_INVALID_STATE       = TIZEN_ERROR_AUDIO_IO | 0x05,   /**< Invalid state (Since 3.0) */
115 } audio_io_error_e;
116
117 /**
118  * @deprecated Deprecated since 3.0
119  * @brief Enumeration for audio IO interrupted messages.
120  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
121  */
122 typedef enum
123 {
124     AUDIO_IO_INTERRUPTED_COMPLETED = 0,         /**< Interrupt completed */
125     AUDIO_IO_INTERRUPTED_BY_MEDIA,              /**< Interrupted by a media application */
126     AUDIO_IO_INTERRUPTED_BY_CALL,               /**< Interrupted by an incoming call */
127     AUDIO_IO_INTERRUPTED_BY_EARJACK_UNPLUG,     /**< Interrupted by unplugging headphones */
128     AUDIO_IO_INTERRUPTED_BY_RESOURCE_CONFLICT,  /**< Interrupted by a resource conflict */
129     AUDIO_IO_INTERRUPTED_BY_ALARM,              /**< Interrupted by an alarm */
130     AUDIO_IO_INTERRUPTED_BY_EMERGENCY,          /**< Interrupted by an emergency */
131     AUDIO_IO_INTERRUPTED_BY_NOTIFICATION,       /**< Interrupted by a notification */
132 } audio_io_interrupted_code_e;
133
134 /**
135  * @deprecated Deprecated since 3.0. Use sound_stream_focus_state_changed_cb instead.
136  * @brief Called when audio input or output is interrupted.
137  *
138  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
139  * @param[in] error_code The interrupted error code
140  * @param[in] user_data The user data passed from the callback registration function
141  *
142  * @see audio_in_set_interrupted_cb()
143  * @see audio_out_set_interrupted_cb()
144  * @see audio_in_unset_interrupted_cb()
145  * @see audio_out_unset_interrupted_cb()
146  */
147 typedef void (*audio_io_interrupted_cb)(audio_io_interrupted_code_e code, void *user_data);
148
149 /**
150  * @}
151  */
152
153 /**
154  * @addtogroup CAPI_MEDIA_AUDIO_IN_MODULE
155  * @{
156  */
157
158 //
159 //AUDIO INPUT
160 //
161
162 /**
163  * @brief Called when audio input data is available in asynchronous(event) mode.
164  *
165  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
166  *
167  * @remarks @a use audio_in_peek() to get audio in data inside callback, use audio_in_drop() after use of peeked data.
168  *
169  * @param[in] handle The handle to the audio input
170  * @param[in] nbytes The amount of available audio in data which can be peeked.
171  * @param[in] user_data The user data passed from the callback registration function
172  *
173  * @see audio_in_set_stream_cb()
174  */
175 typedef void (*audio_in_stream_cb)(audio_in_h handle, size_t nbytes, void *user_data);
176
177 /**
178  * @brief Called when the state of audio input is changed.
179  *
180  * @since_tizen 3.0
181  *
182  * @param[in] handle The handle of the audio input
183  * @param[in] previous The previous state of the audio input
184  * @param[in] current The current state of the audio input
185  * @param[in] by_policy @c true if the state is changed by policy, otherwise @c false if the state is not changed by policy
186  * @param[in] user_data The user data passed from the callback registration function
187  *
188  * @see audio_in_set_state_changed_cb()
189  * @see audio_in_unset_state_changed_cb()
190  */
191 typedef void (*audio_in_state_changed_cb)(audio_in_h handle, audio_io_state_e previous, audio_io_state_e current, bool by_policy, void *user_data);
192
193 /**
194  * @brief Creates an audio device instance and returns an input handle to record PCM (pulse-code modulation) data.
195  *
196  * @details This function is used for audio input initialization.
197  *
198  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
199  * @privlevel public
200  * @privilege %http://tizen.org/privilege/recorder
201  *
202  * @remarks @a input must be released using audio_in_destroy().
203  *
204  * @param[in] sample_rate The audio sample rate in 8000[Hz] ~ 48000[Hz]
205  * @param[in] channel The audio channel type (mono or stereo)
206  * @param[in] type The type of audio sample (8- or 16-bit)
207  * @param[out] input An audio input handle is created on success
208  * @return @c 0 on success,
209  *         otherwise a negative error value
210  * @retval #AUDIO_IO_ERROR_NONE Successful
211  * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
212  * @retval #AUDIO_IO_ERROR_PERMISSION_DENIED Permission denied
213  * @retval #AUDIO_IO_ERROR_OUT_OF_MEMORY Out of memory
214  * @retval #AUDIO_IO_ERROR_DEVICE_NOT_OPENED Device not opened
215  * @retval #AUDIO_IO_ERROR_SOUND_POLICY Sound policy error
216  * @retval #AUDIO_IO_ERROR_NOT_SUPPORTED Not supported
217  *
218  * @post The state will be #AUDIO_IO_STATE_IDLE.\n
219  *       audio_in_set_stream_info() is recommended to be called after this API.
220  * @see audio_in_destroy()
221  */
222 int audio_in_create(int sample_rate, audio_channel_e channel, audio_sample_type_e type, audio_in_h *input);
223
224 /**
225  * @deprecated Deprecated since 3.0. Use sound_manager_create_stream_information() instead.
226  * @brief Creates an audio loopback device instance and returns an input handle to record PCM (pulse-code modulation) data.
227  *
228  * @details This function is used for audio loopback input initialization.
229  *
230  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
231  * @privlevel public
232  * @privilege %http://tizen.org/privilege/recorder
233  *
234  * @remarks @a input must be released using audio_in_destroy().
235  *
236  * @param[in] sample_rate The audio sample rate in 8000[Hz] ~ 48000[Hz]
237  * @param[in] channel The audio channel type, mono, or stereo
238  * @param[in] type The type of audio sample (8- or 16-bit)
239  * @param[out] input An audio input handle will be created, if successful
240  * @return @c 0 on success,
241  *         otherwise a negative error value
242  * @retval #AUDIO_IO_ERROR_NONE Successful
243  * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
244  * @retval #AUDIO_IO_ERROR_PERMISSION_DENIED Permission denied
245  * @retval #AUDIO_IO_ERROR_OUT_OF_MEMORY Out of memory
246  * @retval #AUDIO_IO_ERROR_DEVICE_NOT_OPENED Device not opened
247  * @retval #AUDIO_IO_ERROR_SOUND_POLICY Sound policy error
248  * @retval #AUDIO_IO_ERROR_NOT_SUPPORTED Not supported
249  *
250  * @see audio_in_destroy()
251  */
252 int audio_in_create_loopback(int sample_rate, audio_channel_e channel, audio_sample_type_e type , audio_in_h* input);
253
254 /**
255  * @brief Releases the audio input handle and all its resources associated with an audio stream.
256  *
257  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
258  *
259  * @param[in] input The handle to the audio input to destroy
260  * @return @c 0 on success,
261  *         otherwise a negative error value
262  * @retval #AUDIO_IO_ERROR_NONE Successful
263  * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
264  * @retval #AUDIO_IO_ERROR_DEVICE_NOT_CLOSED Device not closed
265  * @retval #AUDIO_IO_ERROR_NOT_SUPPORTED Not supported
266  *
267  * @see audio_in_create()
268  */
269 int audio_in_destroy(audio_in_h input);
270
271 /**
272  * @brief Sets the sound stream information to the audio input.
273  *
274  * @since_tizen 3.0
275  *
276  * @remarks @a the sound stream information includes audio routing and volume type.
277  *          For more details, you can refer to @ref CAPI_MEDIA_SOUND_MANAGER_MODULE
278  *
279  * @param[in] input The handle to the audio input
280  * @param[in] stream_info The handle of stream information
281  * @return @c 0 on success,
282  *         otherwise a negative error value
283  * @retval #AUDIO_IO_ERROR_NONE Successful
284  * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
285  * @retval #AUDIO_IO_ERROR_NOT_SUPPORTED Not supported
286  * @retval #AUDIO_IO_ERROR_INVALID_STATE Invalid state
287  *
288  * @pre The state should be #AUDIO_IO_STATE_IDLE.\n
289  *      Call audio_in_create() before calling this function.
290  * @post Call audio_in_prepare() after calling this function.
291  * @see sound_manager_create_stream_information()
292  * @see sound_manager_destroy_stream_information()
293  */
294 int audio_in_set_stream_info(audio_in_h input, sound_stream_info_h stream_info);
295
296 /**
297  * @brief Prepares the audio input for reading audio data by starting buffering of audio data from the device.
298  *
299  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
300  *
301  * @param[in] input The handle to the audio input
302  * @return @c 0 on success,
303  *         otherwise a negative error value
304  * @retval #AUDIO_IO_ERROR_NONE Successful
305  * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
306  * @retval #AUDIO_IO_ERROR_NOT_SUPPORTED Not supported
307  * @retval #AUDIO_IO_ERROR_INVALID_STATE Invalid state
308  *
309  * @post The state will be #AUDIO_IO_STATE_RUNNING.
310  * @see audio_in_unprepare()
311  */
312 int audio_in_prepare(audio_in_h input);
313
314 /**
315  * @brief Unprepares the audio input.
316  *
317  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
318  *
319  * @param[in] input The handle to the audio input
320  * @return @c 0 on success,
321  *         otherwise a negative error value
322  * @retval #AUDIO_IO_ERROR_NONE Successful
323  * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
324  * @retval #AUDIO_IO_ERROR_NOT_SUPPORTED Not supported
325  * @retval #AUDIO_IO_ERROR_INVALID_STATE Invalid state
326  *
327  * @post The state will be #AUDIO_IO_STATE_IDLE.
328  * @see audio_in_prepare()
329  */
330 int audio_in_unprepare(audio_in_h input);
331
332 /**
333  * @brief Pauses buffering of audio data from the device.
334  *
335  * @since_tizen 3.0
336  *
337  * @param[in] input The handle to the audio input
338  * @return @c 0 on success,
339  *         otherwise a negative error value
340  * @retval #AUDIO_IO_ERROR_NONE Successful
341  * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
342  * @retval #AUDIO_IO_ERROR_NOT_SUPPORTED Not supported
343  * @retval #AUDIO_IO_ERROR_INVALID_STATE Invalid state
344  *
345  * @pre The state should be #AUDIO_IO_STATE_RUNNING.
346  * @post The state will be #AUDIO_IO_STATE_PAUSED.
347  * @see audio_in_resume()
348  */
349 int audio_in_pause(audio_in_h input);
350
351 /**
352  * @brief Resumes buffering audio data from the device.
353  *
354  * @since_tizen 3.0
355  *
356  * @param[in] input The handle to the audio input
357  * @return @c 0 on success,
358  *         otherwise a negative error value
359  * @retval #AUDIO_IO_ERROR_NONE Successful
360  * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
361  * @retval #AUDIO_IO_ERROR_NOT_SUPPORTED Not supported
362  * @retval #AUDIO_IO_ERROR_INVALID_STATE Invalid state
363  *
364  * @pre The state should be #AUDIO_IO_STATE_PAUSED.
365  * @post The state will be #AUDIO_IO_STATE_RUNNING.
366  * @see audio_in_pause()
367  */
368 int audio_in_resume(audio_in_h input);
369
370 /**
371  * @brief Flushes and discards buffered audio data from the input stream.
372  *
373  * @since_tizen 2.4
374  *
375  * @param[in] input The handle to the audio input
376  * @return @c 0 on success,
377  *         otherwise a negative error value
378  * @retval #AUDIO_IO_ERROR_NONE Successful
379  * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
380  * @retval #AUDIO_IO_ERROR_NOT_SUPPORTED Not supported
381  * @retval #AUDIO_IO_ERROR_INVALID_STATE Invalid state
382  *
383  * @pre The state should be #AUDIO_IO_STATE_RUNNING or #AUDIO_IO_STATE_PAUSED.
384  */
385 int audio_in_flush(audio_in_h input);
386
387 /**
388  * @brief Reads audio data from the audio input buffer.
389  *
390  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
391  *
392  * @param[in] input The handle to the audio input
393  * @param[out] buffer The PCM buffer address
394  * @param[in] length The length of the PCM data buffer (in bytes)
395  * @return The number of read bytes on success,
396  *         otherwise a negative error value
397  * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
398  * @retval #AUDIO_IO_ERROR_INVALID_BUFFER Invalid buffer pointer
399  * @retval #AUDIO_IO_ERROR_SOUND_POLICY Sound policy error
400  * @retval #AUDIO_IO_ERROR_INVALID_OPERATION Invalid operation
401  * @retval #AUDIO_IO_ERROR_NOT_SUPPORTED Not supported
402  *
403  * @pre The state should be #AUDIO_IO_STATE_RUNNING.
404  */
405 int audio_in_read(audio_in_h input, void *buffer, unsigned int length);
406
407 /**
408  * @brief Gets the size to be allocated for the audio input buffer.
409  *
410  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
411  *
412  * @param[in] input The handle to the audio input
413  * @param[out] size The buffer size (in bytes, the maximum size is 1 MB)
414  * @return @c 0 on success,
415  *         otherwise a negative error value
416  * @retval #AUDIO_IO_ERROR_NONE Successful
417  * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
418  * @retval #AUDIO_IO_ERROR_NOT_SUPPORTED Not supported
419  * @see audio_in_read()
420  */
421 int audio_in_get_buffer_size(audio_in_h input, int *size);
422
423 /**
424  * @brief Gets the sample rate of the audio input data stream.
425  *
426  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
427  *
428  * @param[in] input The handle to the audio input
429  * @param[out] sample_rate The audio sample rate in Hertz (8000 ~ 48000)
430  * @return @c 0 on success,
431  *         otherwise a negative error value
432  * @retval #AUDIO_IO_ERROR_NONE Successful
433  * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
434  * @retval #AUDIO_IO_ERROR_NOT_SUPPORTED Not supported
435  */
436 int audio_in_get_sample_rate(audio_in_h input, int *sample_rate);
437
438 /**
439  * @brief Gets the channel type of the audio input data stream.
440  *
441  * @details The audio channel type defines whether the audio is mono or stereo.
442  *
443  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
444  *
445  * @param[in] input The handle to the audio input
446  * @param[out] channel The audio channel type
447  * @return @c 0 on success,
448  *         otherwise a negative error value
449  * @retval #AUDIO_IO_ERROR_NONE Successful
450  * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
451  * @retval #AUDIO_IO_ERROR_NOT_SUPPORTED Not supported
452  */
453 int audio_in_get_channel(audio_in_h input, audio_channel_e *channel);
454
455 /**
456  * @brief Gets the sample audio format (8-bit or 16-bit) of the audio input data stream.
457  *
458  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
459  *
460  * @param[in] input The handle to the audio input
461  * @param[out] type The audio sample type
462  * @return @c 0 on success,
463  *         otherwise a negative error value
464  * @retval #AUDIO_IO_ERROR_NONE Successful
465  * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
466  * @retval #AUDIO_IO_ERROR_NOT_SUPPORTED Not supported
467  */
468 int audio_in_get_sample_type(audio_in_h input, audio_sample_type_e *type);
469
470 /**
471  * @deprecated Deprecated since 3.0. Use sound_manager_create_stream_information() instead.
472  * @brief Registers a callback function to be invoked when the audio input handle is interrupted or the interrupt is completed.
473  *
474  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
475  *
476  * @param[in] input The handle to the audio input
477  * @param[in] callback The callback function to register
478  * @param[in] user_data The user data to be passed to the callback function
479  * @return @c 0 on success,
480  *         otherwise a negative error value
481  * @retval #AUDIO_IO_ERROR_NONE Successful
482  * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
483  * @retval #AUDIO_IO_ERROR_INVALID_OPERATION Invalid operation
484  * @retval #AUDIO_IO_ERROR_NOT_SUPPORTED Not supported
485  * @post audio_io_interrupted_cb() will be invoked.
486  *
487  * @see audio_in_unset_interrupted_cb()
488  * @see audio_io_interrupted_cb()
489  */
490 int audio_in_set_interrupted_cb(audio_in_h input, audio_io_interrupted_cb callback, void *user_data);
491
492 /**
493  * @deprecated Deprecated since 3.0
494  * @brief Unregisters the callback function.
495  *
496  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
497  *
498  * @param[in] input The handle to the audio input
499  * @return @c 0 on success,
500  *         otherwise a negative error value
501  * @retval #AUDIO_IO_ERROR_NONE Successful
502  * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
503  * @retval #AUDIO_IO_ERROR_INVALID_OPERATION Invalid operation
504  * @retval #AUDIO_IO_ERROR_NOT_SUPPORTED Not supported
505  *
506  * @see audio_in_set_interrupted_cb()
507  */
508 int audio_in_unset_interrupted_cb(audio_in_h input);
509
510 /**
511  * @deprecated Deprecated since 3.0
512  * @brief Ignores session for input.
513  *
514  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
515  *
516  * @param[in] input The handle to the audio input
517  * @return @c 0 on success,
518  *         otherwise a negative error value
519  * @retval #AUDIO_IO_ERROR_NONE Successful
520  * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
521  * @retval #AUDIO_IO_ERROR_INVALID_OPERATION Invalid operation
522  * @retval #AUDIO_IO_ERROR_NOT_SUPPORTED Not supported
523  */
524 int audio_in_ignore_session(audio_in_h input);
525
526 /**
527  * @brief Sets an asynchronous(event) callback function to handle recording PCM (pulse-code modulation) data.
528  *
529  * @details @a callback will be called when you can read a PCM data.
530  * It might cause dead lock if change the state of audio handle in callback.
531  * (ex: audio_in_destroy, audio_in_prepare, audio_in_unprepare)
532  * Recommend to use as a VOIP only.
533  * Recommend not to hold callback too long.(it affects latency)
534  *
535  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
536  *
537  * @remarks @a input must be created using audio_in_create().
538  *
539  * @param[in] input    An audio input handle
540  * @param[in] callback notify stream callback when user can read data (#audio_in_stream_cb)
541  * @param[in] user_data user data to be retrieved when callback is called
542  * @return @c 0 on success,
543  *         otherwise a negative error value
544  * @retval #AUDIO_IO_ERROR_NONE Successful
545  * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
546  * @retval #AUDIO_IO_ERROR_OUT_OF_MEMORY Out of memory
547  * @retval #AUDIO_IO_ERROR_DEVICE_NOT_OPENED Device not opened
548  * @retval #AUDIO_IO_ERROR_SOUND_POLICY Sound policy error
549  * @retval #AUDIO_IO_ERROR_NOT_SUPPORTED Not supported
550  *
551  * @see audio_out_set_stream_cb()
552  */
553 int audio_in_set_stream_cb(audio_in_h input, audio_in_stream_cb callback, void* user_data);
554
555 /**
556  * @brief Unregisters the callback function.
557  *
558  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
559  *
560  * @param[in] input The handle to the audio input
561  * @return @c 0 on success,
562  *         otherwise a negative error value
563  * @retval #AUDIO_IO_ERROR_NONE Successful
564  * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
565  * @retval #AUDIO_IO_ERROR_INVALID_OPERATION Invalid operation
566  * @retval #AUDIO_IO_ERROR_NOT_SUPPORTED Not supported
567  *
568  * @see audio_in_set_interrupted_cb()
569  */
570 int audio_in_unset_stream_cb(audio_in_h input);
571
572 /**
573  * @brief peek from audio in buffer
574  *
575  * @details This function works correctly only with read, write callback. Otherwise it won't operate as intended.
576  *
577  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
578  *
579  * @remarks @a Works only in asynchronous(event) mode. This will just retrieve buffer pointer from audio in buffer. Drop after use.
580  *
581  * @param[in] input The handle to the audio input
582  * @param[out] buffer start buffer pointer of peeked audio in data
583  * @param[in,out] length amount of audio in data to be peeked
584  * @return @c 0 on success,
585  *         otherwise a negative error value
586  * @retval #AUDIO_IO_ERROR_NONE Successful
587  * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
588  * @retval #AUDIO_IO_ERROR_INVALID_OPERATION Invalid operation
589  * @retval #AUDIO_IO_ERROR_NOT_SUPPORTED Not supported
590  * @retval #AUDIO_IO_ERROR_INVALID_STATE Invalid state
591  *
592  * @pre The state should be #AUDIO_IO_STATE_RUNNING.
593  * @see audio_in_drop()
594  */
595 int audio_in_peek(audio_in_h input, const void **buffer, unsigned int *length);
596
597 /**
598  * @brief drop peeked audio buffer.
599  *
600  * @details This function works correctly only with read, write callback. Otherwise it won't operate as intended.
601  *
602  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
603  *
604  * @remarks @a Works only in asynchronous(event) mode. This will remove audio in data from actual stream buffer. Use this if peeked data is not needed anymore.
605  *
606  * @param[in] input The handle to the audio input
607  * @return 0 on success, otherwise a negative error value
608  * @retval #AUDIO_IO_ERROR_NONE Successful
609  * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
610  * @retval #AUDIO_IO_ERROR_INVALID_OPERATION Invalid operation
611  * @retval #AUDIO_IO_ERROR_NOT_SUPPORTED Not supported
612  * @retval #AUDIO_IO_ERROR_INVALID_STATE Invalid state
613  *
614  * @pre The state should be #AUDIO_IO_STATE_RUNNING.
615  * @see audio_in_peek()
616  */
617 int audio_in_drop(audio_in_h input);
618
619 /**
620  * @brief Sets the state changed callback function to the audio input handle.
621  *
622  * @since_tizen 3.0
623  *
624  * @remarks @a input must be created using audio_in_create().
625  *
626  * @param[in] input    The audio input handle
627  * @param[in] callback the state changed callback called when the state of the handle is changed (#audio_in_state_changed_cb)
628  * @param[in] user_data user data to be retrieved when callback is called
629  * @return @c 0 on success,
630  *         otherwise a negative error value
631  * @retval #AUDIO_IO_ERROR_NONE Successful
632  * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
633  * @retval #AUDIO_IO_ERROR_NOT_SUPPORTED Not supported
634  *
635  * @see audio_in_unset_state_changed_cb()
636  */
637 int audio_in_set_state_changed_cb(audio_in_h input, audio_in_state_changed_cb callback, void* user_data);
638
639 /**
640  * @brief Unregisters the state changed callback function of the audio input handle.
641  *
642  * @since_tizen 3.0
643  *
644  * @param[in] input The handle to the audio input
645  * @return @c 0 on success,
646  *         otherwise a negative error value
647  * @retval #AUDIO_IO_ERROR_NONE Successful
648  * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
649  * @retval #AUDIO_IO_ERROR_NOT_SUPPORTED Not supported
650  *
651  * @see audio_in_set_state_changed_cb()
652  */
653 int audio_in_unset_state_changed_cb(audio_in_h input);
654
655 /**
656  * @}
657  */
658
659 //
660 // AUDIO OUTPUT
661 //
662
663 /**
664  * @addtogroup CAPI_MEDIA_AUDIO_OUT_MODULE
665  * @{
666  */
667
668 /**
669  * @brief Called when audio out data can be written in asynchronous(event) mode.
670  *
671  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
672  *
673  * @remarks @a use audio_out_write() to write pcm data inside this callback.
674  * @param[in] handle The handle to the audio output
675  * @param[in] nbytes The amount of audio in data which can be written.
676  * @param[in] user_data The user data passed from the callback registration function
677  *
678  * @see audio_out_set_stream_cb()
679  */
680 typedef void (*audio_out_stream_cb)(audio_out_h handle, size_t nbytes, void *user_data);
681
682 /**
683  * @brief Called when the state of audio output is changed.
684  *
685  * @since_tizen 3.0
686  *
687  * @param[in] handle The handle of the audio output
688  * @param[in] previous The previous state of the audio output
689  * @param[in] current The current state of the audio output
690  * @param[in] by_policy @c true if the state is changed by policy, otherwise @c false if the state is not changed by policy
691  * @param[in] user_data The user data passed from the callback registration function
692  *
693  * @see audio_out_set_state_changed_cb()
694  * @see audio_out_unset_state_changed_cb()
695  */
696 typedef void (*audio_out_state_changed_cb)(audio_out_h handle, audio_io_state_e previous, audio_io_state_e current, bool by_policy, void *user_data);
697
698 /**
699  * @deprecated Deprecated since 3.0. Use audio_out_create_new() instead.
700  * @brief Creates an audio device instance and returns an output handle to play PCM (pulse-code modulation) data.
701  *
702  * @details This function is used for audio output initialization.
703  *
704  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
705  *
706  * @remarks @a output must be released by audio_out_destroy().
707  *
708  * @param[in] sample_rate The audio sample rate in 8000[Hz] ~ 48000[Hz]
709  * @param[in] channel The audio channel type (mono or stereo)
710  * @param[in] type The type of audio sample (8-bit or 16-bit)
711  * @param[in] sound_type The type of sound (#sound_type_e)
712  * @param[out] output An audio output handle is created on success
713  * @return @c 0 on success,
714  *         otherwise a negative error value
715  * @retval #AUDIO_IO_ERROR_NONE Successful
716  * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
717  * @retval #AUDIO_IO_ERROR_OUT_OF_MEMORY Out of memory
718  * @retval #AUDIO_IO_ERROR_DEVICE_NOT_OPENED Device not opened
719  * @retval #AUDIO_IO_ERROR_SOUND_POLICY Sound policy error
720  *
721  * @see audio_out_destroy()
722  */
723 int audio_out_create(int sample_rate, audio_channel_e channel, audio_sample_type_e type, sound_type_e sound_type, audio_out_h *output);
724
725 /**
726  * @brief Creates an audio device instance and returns an output handle to play PCM (pulse-code modulation) data.
727  *
728  * @details This function is used for audio output initialization.
729  *
730  * @since_tizen 3.0
731  *
732  * @remarks @a output must be released by audio_out_destroy().
733  *          It is recommended to call audio_out_set_stream_info() after this API.
734  *
735  * @param[in] sample_rate The audio sample rate in 8000[Hz] ~ 48000[Hz]
736  * @param[in] channel The audio channel type (mono or stereo)
737  * @param[in] type The type of audio sample (8-bit or 16-bit)
738  * @param[out] output An audio output handle is created on success
739  * @return @c 0 on success,
740  *         otherwise a negative error value
741  * @retval #AUDIO_IO_ERROR_NONE Successful
742  * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
743  * @retval #AUDIO_IO_ERROR_OUT_OF_MEMORY Out of memory
744  * @retval #AUDIO_IO_ERROR_DEVICE_NOT_OPENED Device not opened
745  * @retval #AUDIO_IO_ERROR_SOUND_POLICY Sound policy error
746  *
747  * @post The state will be #AUDIO_IO_STATE_IDLE.\n
748  *       audio_out_set_stream_info() is recommended to be called after this API.
749  * @see audio_out_destroy()
750  */
751 int audio_out_create_new(int sample_rate, audio_channel_e channel, audio_sample_type_e type, audio_out_h *output);
752
753 /**
754  * @brief Releases the audio output handle, along with all its resources.
755  *
756  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
757  *
758  * @param[in] output The handle to the audio output to destroy
759  * @return @c 0 on success,
760  *         otherwise a negative error value
761  * @retval #AUDIO_IO_ERROR_NONE Successful
762  * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
763  * @retval #AUDIO_IO_ERROR_OUT_OF_MEMORY Out of memory
764  * @retval #AUDIO_IO_ERROR_DEVICE_NOT_CLOSED Device not closed
765  *
766  * @see audio_out_create()
767  */
768 int audio_out_destroy(audio_out_h output);
769
770 /**
771  * @brief Sets the sound stream information to the audio output.
772  *
773  * @since_tizen 3.0
774  *
775  * @remarks @a the sound stream information includes audio routing and volume type.
776  *          For more details, you can refer to sound_manager.h
777  *
778  * @param[in] output The handle to the audio output
779  * @param[in] stream_info The handle of stream information
780  * @return @c 0 on success,
781  *         otherwise a negative error value
782  * @retval #AUDIO_IO_ERROR_NONE Successful
783  * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
784  * @retval #AUDIO_IO_ERROR_NOT_SUPPORTED Not supported
785  * @retval #AUDIO_IO_ERROR_INVALID_STATE Invalid state
786  *
787  * @pre The state should be #AUDIO_IO_STATE_IDLE.\n
788  *      Call audio_out_create_new() before calling this function.
789  * @post Call audio_out_prepare() after calling this function.
790  * @see sound_manager_create_stream_information()
791  * @see sound_manager_destroy_stream_information()
792  */
793 int audio_out_set_stream_info(audio_out_h output, sound_stream_info_h stream_info);
794
795 /**
796  * @brief Prepares the audio output for playback, this must be called before audio_out_write().
797  *
798  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
799  *
800  * @param[in] output The handle to the audio output
801  * @return @c 0 on success,
802  *         otherwise a negative error value
803  * @retval #AUDIO_IO_ERROR_NONE Successful
804  * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
805  * @retval #AUDIO_IO_ERROR_INVALID_STATE Invalid state
806  *
807  * @post The state will be #AUDIO_IO_STATE_RUNNING.
808  * @see audio_out_unprepare()
809  */
810 int audio_out_prepare(audio_out_h output);
811
812 /**
813  * @brief Unprepares the audio output.
814  *
815  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
816  *
817  * @param[in] output The handle to the audio output
818  * @return @c 0 on success,
819  *         otherwise a negative error value
820  * @retval #AUDIO_IO_ERROR_NONE Successful
821  * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
822  * @retval #AUDIO_IO_ERROR_INVALID_STATE Invalid state
823  *
824  * @post The state will be #AUDIO_IO_STATE_IDLE.
825  * @see audio_out_prepare()
826  */
827 int audio_out_unprepare(audio_out_h output);
828
829 /**
830  * @brief Pauses feeding of audio data to the device.
831  *
832  * @since_tizen 3.0
833  *
834  * @param[in] output The handle to the audio output
835  * @return @c 0 on success,
836  *         otherwise a negative error value
837  * @retval #AUDIO_IO_ERROR_NONE Successful
838  * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
839  * @retval #AUDIO_IO_ERROR_INVALID_STATE Invalid state
840  *
841  * @pre The state should be #AUDIO_IO_STATE_RUNNING.
842  * @post The state will be #AUDIO_IO_STATE_PAUSED.
843  * @see audio_out_resume()
844  */
845 int audio_out_pause(audio_out_h output);
846
847 /**
848  * @brief Resumes feeding of audio data to the device.
849  *
850  * @since_tizen 3.0
851  *
852  * @param[in] output The handle to the audio output
853  * @return @c 0 on success,
854  *         otherwise a negative error value
855  * @retval #AUDIO_IO_ERROR_NONE Successful
856  * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
857  * @retval #AUDIO_IO_ERROR_INVALID_STATE Invalid state
858  *
859  * @pre The state should be #AUDIO_IO_STATE_PAUSED.
860  * @post The state will be #AUDIO_IO_STATE_RUNNING.
861  * @see audio_out_pause()
862  */
863 int audio_out_resume(audio_out_h output);
864
865 /**
866  * @brief Drains buffered audio data from the output stream.
867  *
868  * @details This function waits until drains stream buffer completely. (e.g end of playback)
869  *
870  * @since_tizen 2.4
871  *
872  * @param[in] output The handle to the audio output
873  * @return @c 0 on success,
874  *         otherwise a negative error value
875  * @retval #AUDIO_IO_ERROR_NONE Successful
876  * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
877  * @retval #AUDIO_IO_ERROR_INVALID_STATE Invalid state
878  *
879  * @pre The state should be #AUDIO_IO_STATE_RUNNING or #AUDIO_IO_STATE_PAUSED.
880  * @see audio_out_flush()
881  */
882 int audio_out_drain(audio_out_h output);
883
884 /**
885  * @brief Flushes and discards buffered audio data from the output stream.
886  *
887  * @since_tizen 2.4
888  *
889  * @param[in] output The handle to the audio output
890  * @return @c 0 on success,
891  *         otherwise a negative error value
892  * @retval #AUDIO_IO_ERROR_NONE Successful
893  * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
894  * @retval #AUDIO_IO_ERROR_INVALID_STATE Invalid state
895  *
896  * @pre The state should be #AUDIO_IO_STATE_RUNNING or #AUDIO_IO_STATE_PAUSED.
897  * @see audio_out_drain()
898  */
899 int audio_out_flush(audio_out_h output);
900
901 /**
902  * @brief Starts writing the audio data to the device.
903  *
904  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
905  *
906  * @param[in] output The handle to the audio output
907  * @param[in,out] buffer The PCM buffer address
908  * @param[in] length The length of the PCM buffer (in bytes)
909  * @return The written data size on success,
910  *         otherwise a negative error value
911  * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
912  * @retval #AUDIO_IO_ERROR_INVALID_BUFFER Invalid buffer pointer
913  * @retval #AUDIO_IO_ERROR_SOUND_POLICY Sound policy error
914  * @retval #AUDIO_IO_ERROR_INVALID_STATE Invalid state
915  *
916  * @pre The state should be #AUDIO_IO_STATE_RUNNING.
917  */
918 int audio_out_write(audio_out_h output, void *buffer, unsigned int length);
919
920 /**
921  * @brief Gets the size to be allocated for the audio output buffer.
922  *
923  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
924  *
925  * @param[in] output The handle to the audio output
926  * @param[out] size The suggested buffer size (in bytes, the maximum size is 1 MB)
927  * @return  @c 0 on success,
928  *          otherwise a negative error value
929  * @retval  #AUDIO_IO_ERROR_NONE Successful
930  * @retval  #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
931  *
932  * @see audio_out_write()
933  */
934 int audio_out_get_buffer_size(audio_out_h output, int *size);
935
936 /**
937  * @brief Gets the sample rate of the audio output data stream.
938  *
939  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
940  *
941  * @param[in] output The handle to the audio output
942  * @param[out] sample_rate The audio sample rate in Hertz (8000 ~ 48000)
943  * @return  @c 0 on success,
944  *          otherwise a negative error value
945  * @retval  #AUDIO_IO_ERROR_NONE Successful
946  * @retval  #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
947  */
948 int audio_out_get_sample_rate(audio_out_h output, int *sample_rate);
949
950 /**
951  * @brief Gets the channel type of the audio output data stream.
952  *
953  * @details The audio channel type defines whether the audio is mono or stereo.
954  *
955  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
956  *
957  * @param[in] output The handle to the audio output
958  * @param[out] channel The audio channel type
959  * @return @c 0 on success,
960  *         otherwise a negative error value
961  * @retval #AUDIO_IO_ERROR_NONE Successful
962  * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
963  */
964 int audio_out_get_channel(audio_out_h output, audio_channel_e *channel);
965
966 /**
967  * @brief Gets the sample audio format (8-bit or 16-bit) of the audio output data stream.
968  *
969  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
970  *
971  * @param[in] output The handle to the audio output
972  * @param[out] type The audio sample type
973  * @return @c 0 on success,
974  *         otherwise a negative error value
975  * @retval #AUDIO_IO_ERROR_NONE Successful
976  * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
977  */
978 int audio_out_get_sample_type(audio_out_h output, audio_sample_type_e *type);
979
980 /**
981  * @brief Gets the sound type supported by the audio output device.
982  *
983  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
984  *
985  * @param[in] output The handle to the audio output
986  * @param[out] type The sound type
987  * @return @c 0 on success,
988  *         otherwise a negative error value
989  * @retval #AUDIO_IO_ERROR_NONE Successful
990  * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
991  */
992 int audio_out_get_sound_type(audio_out_h output, sound_type_e *type);
993
994 /**
995  * @deprecated Deprecated since 3.0. Use sound_manager_create_stream_information() instead.
996  * @brief Registers a callback function to be invoked when the audio output handle is interrupted or the interrupt is completed.
997  *
998  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
999  *
1000  * @param[in] output The handle to the audio output
1001  * @param[in] callback The callback function to register
1002  * @param[in] user_data The user data to be passed to the callback function
1003  * @return @c 0 on success,
1004  *         otherwise a negative error value
1005  * @retval #AUDIO_IO_ERROR_NONE Successful
1006  * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
1007  * @retval #AUDIO_IO_ERROR_INVALID_OPERATION Invalid operation
1008  *
1009  * @post audio_io_interrupted_cb() will be invoked.
1010  * @see audio_out_unset_interrupted_cb()
1011  * @see audio_io_interrupted_cb()
1012  */
1013 int audio_out_set_interrupted_cb(audio_out_h output, audio_io_interrupted_cb callback, void *user_data);
1014
1015 /**
1016  * @deprecated Deprecated since 3.0
1017  * @brief Unregisters the callback function.
1018  *
1019  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
1020  *
1021  * @param[in] output The handle to the audio output
1022  * @return @c 0 on success,
1023  *         otherwise a negative error value
1024  * @retval #AUDIO_IO_ERROR_NONE Successful
1025  * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
1026  * @retval #AUDIO_IO_ERROR_INVALID_OPERATION Invalid operation
1027  *
1028  * @see audio_out_set_interrupted_cb()
1029  */
1030 int audio_out_unset_interrupted_cb(audio_out_h output);
1031
1032 /**
1033  * @deprecated Deprecated since 3.0
1034  * @brief Ignores session for output.
1035  *
1036  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
1037  *
1038  * @param[in] output The handle to the audio output
1039  * @return @c 0 on success,
1040  *         otherwise a negative error value
1041  * @retval #AUDIO_IO_ERROR_NONE Successful
1042  * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
1043  * @retval #AUDIO_IO_ERROR_INVALID_OPERATION Invalid operation
1044  */
1045 int audio_out_ignore_session(audio_out_h output);
1046
1047 /**
1048  * @brief Sets an asynchronous(event) callback function to handle playing PCM (pulse-code modulation) data.
1049  *
1050  * @details @a callback will be called when you can write a PCM data.
1051  * It might cause dead lock if change the state of audio handle in callback.
1052  * (ex: audio_in_destroy, audio_in_prepare, audio_in_unprepare)
1053  * Recommend to use as a VOIP only.
1054  * Recommend not to hold callback too long.(it affects latency)
1055  *
1056  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
1057  *
1058  * @remarks @a output must be created using audio_out_create().
1059  *
1060  * @param[in] output   An audio output handle
1061  * @param[in] callback notify stream callback when user can write data (#audio_out_stream_cb)
1062  * @param[in] user_data user data to be retrieved when callback is called
1063  * @return 0 on success, otherwise a negative error value
1064  * @retval #AUDIO_IO_ERROR_NONE Successful
1065  * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
1066  * @retval #AUDIO_IO_ERROR_OUT_OF_MEMORY Out of memory
1067  * @retval #AUDIO_IO_ERROR_DEVICE_NOT_OPENED Device not opened
1068  * @retval #AUDIO_IO_ERROR_SOUND_POLICY Sound policy error
1069  *
1070  * @see audio_in_set_stream_cb()
1071  */
1072 int audio_out_set_stream_cb(audio_out_h output, audio_out_stream_cb callback, void* user_data);
1073
1074 /**
1075  * @brief Unregisters the callback function.
1076  *
1077  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
1078  *
1079  * @param[in] output The handle to the audio output
1080  * @return 0 on success, otherwise a negative error value
1081  * @retval #AUDIO_IO_ERROR_NONE Successful
1082  * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
1083  * @retval #AUDIO_IO_ERROR_INVALID_OPERATION Invalid operation
1084  *
1085  * @see audio_out_set_stream_cb()
1086  */
1087 int audio_out_unset_stream_cb(audio_out_h output);
1088
1089 /**
1090  * @brief Sets the state changed callback function to the audio output handle.
1091  *
1092  * @since_tizen 3.0
1093  *
1094  * @remarks @a input must be created using audio_out_create_new().
1095  *
1096  * @param[in] output    The audio output handle
1097  * @param[in] callback the state changed callback called when the state of the handle is changed (#audio_out_state_changed_cb)
1098  * @param[in] user_data user data to be retrieved when callback is called
1099  * @return @c 0 on success,
1100  *         otherwise a negative error value
1101  * @retval #AUDIO_IO_ERROR_NONE Successful
1102  * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
1103  *
1104  * @see audio_out_unset_state_changed_cb()
1105  */
1106 int audio_out_set_state_changed_cb(audio_out_h output, audio_out_state_changed_cb callback, void* user_data);
1107
1108 /**
1109  * @brief Unregisters the state changed callback function of the audio output handle.
1110  *
1111  * @since_tizen 3.0
1112  *
1113  * @param[in] output The handle to the audio output
1114  * @return @c 0 on success,
1115  *         otherwise a negative error value
1116  * @retval #AUDIO_IO_ERROR_NONE Successful
1117  * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
1118  *
1119  * @see audio_out_set_state_changed_cb()
1120  */
1121 int audio_out_unset_state_changed_cb(audio_out_h output);
1122
1123 /**
1124  * @}
1125  */
1126
1127 #ifdef __cplusplus
1128 }
1129 #endif
1130
1131 #endif /* __TIZEN_MEDIA_AUDIO_IO_H__ */