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.
17 #ifndef __TIZEN_MEDIA_AUDIO_IO_H__
18 #define __TIZEN_MEDIA_AUDIO_IO_H__
21 #include <sound_manager.h>
22 #include <sys/types.h>
31 * @brief This file contains the Audio Input and Audio Output API.
35 * @addtogroup CAPI_MEDIA_AUDIO_IN_MODULE
40 * @brief The audio input handle.
43 typedef struct audio_in_s *audio_in_h;
50 * @addtogroup CAPI_MEDIA_AUDIO_OUT_MODULE
55 * @brief The audio output handle.
58 typedef struct audio_out_s *audio_out_h;
65 * @addtogroup CAPI_MEDIA_AUDIO_IO_MODULE
70 * @brief Enumeration for audio sample type with bit depth.
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;
80 * @brief Enumeration for audio channel.
84 AUDIO_CHANNEL_MONO = 0x80, /**< 1 channel, mono */
85 AUDIO_CHANNEL_STEREO, /**< 2 channel, stereo */
89 * @brief Enumeration for audio input and output error.
93 AUDIO_IO_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
94 AUDIO_IO_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
95 AUDIO_IO_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
96 AUDIO_IO_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION, /**< Invalid operation */
97 AUDIO_IO_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Device open error by security */
98 AUDIO_IO_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported */
99 AUDIO_IO_ERROR_DEVICE_NOT_OPENED = TIZEN_ERROR_AUDIO_IO | 0x01, /**< Device open error */
100 AUDIO_IO_ERROR_DEVICE_NOT_CLOSED = TIZEN_ERROR_AUDIO_IO | 0x02, /**< Device close error */
101 AUDIO_IO_ERROR_INVALID_BUFFER = TIZEN_ERROR_AUDIO_IO | 0x03, /**< Invalid buffer pointer */
102 AUDIO_IO_ERROR_SOUND_POLICY = TIZEN_ERROR_AUDIO_IO | 0x04, /**< Sound policy error */
106 * @brief Enumeration for audio IO interrupted messages.
111 AUDIO_IO_INTERRUPTED_COMPLETED = 0, /**< Interrupt completed */
112 AUDIO_IO_INTERRUPTED_BY_MEDIA, /**< Interrupted by a media application */
113 AUDIO_IO_INTERRUPTED_BY_CALL, /**< Interrupted by an incoming call */
114 AUDIO_IO_INTERRUPTED_BY_EARJACK_UNPLUG, /**< Interrupted by unplugging headphones */
115 AUDIO_IO_INTERRUPTED_BY_RESOURCE_CONFLICT, /**< Interrupted by a resource conflict */
116 AUDIO_IO_INTERRUPTED_BY_ALARM, /**< Interrupted by an alarm */
117 AUDIO_IO_INTERRUPTED_BY_EMERGENCY, /**< Interrupted by an emergency */
118 AUDIO_IO_INTERRUPTED_BY_NOTIFICATION, /**< Interrupted by a notification */
119 } audio_io_interrupted_code_e;
122 * @brief Called when audio input or output is interrupted.
125 * @param[in] error_code The interrupted error code
126 * @param[in] user_data The user data passed from the callback registration function
128 * @see audio_in_set_interrupted_cb()
129 * @see audio_out_set_interrupted_cb()
130 * @see audio_in_unset_interrupted_cb()
131 * @see audio_out_unset_interrupted_cb()
133 typedef void (*audio_io_interrupted_cb)(audio_io_interrupted_code_e code, void *user_data);
140 * @addtogroup CAPI_MEDIA_AUDIO_IN_MODULE
149 * @brief Called when audio input data is available in asynchronous(event) mode.
153 * @remarks @a use audio_in_peek() to get audio in data inside callback, use audio_in_drop() after use of peeked data.
155 * @param[in] handle The handle to the audio input
156 * @param[in] nbytes The amount of available audio in data which can be peeked.
157 * @param[in] userdata The user data passed from the callback registration function
159 * @see audio_in_set_stream_cb()
161 typedef void (*audio_in_stream_cb)(audio_in_h handle, size_t nbytes, void *userdata);
164 * @brief Creates an audio device instance and returns an input handle to record PCM (pulse-code modulation) data.
168 * @privilege %http://tizen.org/privilege/recorder
170 * @details This function is used for audio input initialization.
172 * @remarks @a input must be released using audio_in_destroy().
174 * @param[in] sample_rate The audio sample rate in 8000[Hz] ~ 48000[Hz]
175 * @param[in] channel The audio channel type (mono or stereo)
176 * @param[in] type The type of audio sample (8- or 16-bit)
177 * @param[out] input An audio input handle is created on success
178 * @return @c 0 on success,
179 * otherwise a negative error value
180 * @retval #AUDIO_IO_ERROR_NONE Successful
181 * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
182 * @retval #AUDIO_IO_ERROR_PERMISSION_DENIED Permission denied
183 * @retval #AUDIO_IO_ERROR_OUT_OF_MEMORY Out of memory
184 * @retval #AUDIO_IO_ERROR_DEVICE_NOT_OPENED Device not opened
185 * @retval #AUDIO_IO_ERROR_SOUND_POLICY Sound policy error
186 * @retval #AUDIO_IO_ERROR_NOT_SUPPORTED Not supported
187 * @see audio_in_destroy()
189 int audio_in_create(int sample_rate, audio_channel_e channel, audio_sample_type_e type, audio_in_h *input);
192 * @brief Creates an audio loopback device instance and returns an input handle to record PCM (pulse-code modulation) data.
196 * @privilege %http://tizen.org/privilege/recorder
198 * @details This function is used for audio loopback input initialization.
200 * @remarks @a input must be released using audio_in_destroy().
202 * @param[in] sample_rate The audio sample rate in 8000[Hz] ~ 48000[Hz]
203 * @param[in] channel The audio channel type, mono, or stereo
204 * @param[in] type The type of audio sample (8- or 16-bit)
205 * @param[out] input An audio input handle will be created, if successful
206 * @return @c 0 on success,
207 * otherwise a negative error value
208 * @retval #AUDIO_IO_ERROR_NONE Successful
209 * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
210 * @retval #AUDIO_IO_ERROR_PERMISSION_DENIED Permission denied
211 * @retval #AUDIO_IO_ERROR_OUT_OF_MEMORY Out of memory
212 * @retval #AUDIO_IO_ERROR_DEVICE_NOT_OPENED Device not opened
213 * @retval #AUDIO_IO_ERROR_SOUND_POLICY Sound policy error
214 * @retval #AUDIO_IO_ERROR_NOT_SUPPORTED Not supported
215 * @see audio_in_destroy()
217 int audio_in_create_loopback(int sample_rate, audio_channel_e channel, audio_sample_type_e type , audio_in_h* input);
220 * @brief Releases the audio input handle and all its resources associated with an audio stream.
224 * @param[in] input The handle to the audio input to destroy
225 * @return @c 0 on success,
226 * otherwise a negative error value
227 * @retval #AUDIO_IO_ERROR_NONE Successful
228 * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
229 * @retval #AUDIO_IO_ERROR_DEVICE_NOT_CLOSED Device not closed
230 * @retval #AUDIO_IO_ERROR_NOT_SUPPORTED Not supported
231 * @see audio_in_create()
233 int audio_in_destroy(audio_in_h input);
236 * @brief Prepares reading audio input by starting buffering of audio data from the device.
240 * @param[in] input The handle to the audio input
241 * @return @c 0 on success,
242 * otherwise a negative error value
243 * @retval #AUDIO_IO_ERROR_NONE Successful
244 * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
245 * @retval #AUDIO_IO_ERROR_NOT_SUPPORTED Not supported
247 * @see audio_in_unprepare()
249 int audio_in_prepare(audio_in_h input);
252 * @brief Unprepares reading audio input by stopping buffering the audio data from the device.
256 * @param[in] input The handle to the audio input
257 * @return @c 0 on success,
258 * otherwise a negative error value
259 * @retval #AUDIO_IO_ERROR_NONE Successful
260 * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
261 * @retval #AUDIO_IO_ERROR_NOT_SUPPORTED Not supported
262 * @see audio_in_prepare()
264 int audio_in_unprepare(audio_in_h input);
267 * @brief Flushes and discards buffered audio data from the input stream.
271 * @param[in] input The handle to the audio input
272 * @return @c 0 on success,
273 * otherwise a negative error value
274 * @retval #AUDIO_IO_ERROR_NONE Successful
275 * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
276 * @retval #AUDIO_IO_ERROR_NOT_SUPPORTED Not supported
277 * @retval #AUDIO_IO_ERROR_INVALID_STATE Invalid state
279 * @pre The state should be #AUDIO_IO_STATE_RUNNING or #AUDIO_IO_STATE_PAUSED.
281 int audio_in_flush(audio_in_h input);
284 * @brief Reads audio data from the audio input buffer.
288 * @param[in] input The handle to the audio input
289 * @param[out] buffer The PCM buffer address
290 * @param[in] length The length of the PCM data buffer (in bytes)
291 * @return The number of read bytes on success,
292 * otherwise a negative error value
293 * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
294 * @retval #AUDIO_IO_ERROR_INVALID_BUFFER Invalid buffer pointer
295 * @retval #AUDIO_IO_ERROR_SOUND_POLICY Sound policy error
296 * @retval #AUDIO_IO_ERROR_INVALID_OPERATION Invalid operation
297 * @retval #AUDIO_IO_ERROR_NOT_SUPPORTED Not supported
298 * @pre audio_in_start_recording().
300 int audio_in_read(audio_in_h input, void *buffer, unsigned int length);
303 * @brief Gets the size to be allocated for the audio input buffer.
307 * @param[in] input The handle to the audio input
308 * @param[out] size The buffer size (in bytes, the maximum size is 1 MB)
309 * @return @c 0 on success,
310 * otherwise a negative error value
311 * @retval #AUDIO_IO_ERROR_NONE Successful
312 * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
313 * @retval #AUDIO_IO_ERROR_NOT_SUPPORTED Not supported
314 * @see audio_in_read()
316 int audio_in_get_buffer_size(audio_in_h input, int *size);
319 * @brief Gets the sample rate of the audio input data stream.
323 * @param[in] input The handle to the audio input
324 * @param[out] sample_rate The audio sample rate in Hertz (8000 ~ 48000)
325 * @return @c 0 on success,
326 * otherwise a negative error value
327 * @retval #AUDIO_IO_ERROR_NONE Successful
328 * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
329 * @retval #AUDIO_IO_ERROR_NOT_SUPPORTED Not supported
331 int audio_in_get_sample_rate(audio_in_h input, int *sample_rate);
334 * @brief Gets the channel type of the audio input data stream.
338 * @details The audio channel type defines whether the audio is mono or stereo.
340 * @param[in] input The handle to the audio input
341 * @param[out] channel The audio channel type
342 * @return @c 0 on success,
343 * otherwise a negative error value
344 * @retval #AUDIO_IO_ERROR_NONE Successful
345 * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
346 * @retval #AUDIO_IO_ERROR_NOT_SUPPORTED Not supported
348 int audio_in_get_channel(audio_in_h input, audio_channel_e *channel);
351 * @brief Gets the sample audio format (8-bit or 16-bit) of the audio input data stream.
355 * @param[in] input The handle to the audio input
356 * @param[out] type The audio sample type
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
363 int audio_in_get_sample_type(audio_in_h input, audio_sample_type_e *type);
366 * @brief Registers a callback function to be invoked when the audio input handle is interrupted or the interrupt is completed.
370 * @param[in] input The handle to the audio input
371 * @param[in] callback The callback function to register
372 * @param[in] user_data The user data to be passed to the callback function
373 * @return @c 0 on success,
374 * otherwise a negative error value
375 * @retval #AUDIO_IO_ERROR_NONE Successful
376 * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
377 * @retval #AUDIO_IO_ERROR_INVALID_OPERATION Invalid operation
378 * @retval #AUDIO_IO_ERROR_NOT_SUPPORTED Not supported
379 * @post audio_io_interrupted_cb() will be invoked.
381 * @see audio_in_unset_interrupted_cb()
382 * @see audio_io_interrupted_cb()
384 int audio_in_set_interrupted_cb(audio_in_h input, audio_io_interrupted_cb callback, void *user_data);
387 * @brief Unregisters the callback function.
391 * @param[in] input The handle to the audio input
392 * @return @c 0 on success,
393 * otherwise a negative error value
394 * @retval #AUDIO_IO_ERROR_NONE Successful
395 * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
396 * @retval #AUDIO_IO_ERROR_INVALID_OPERATION Invalid operation
397 * @retval #AUDIO_IO_ERROR_NOT_SUPPORTED Not supported
399 * @see audio_in_set_interrupted_cb()
401 int audio_in_unset_interrupted_cb(audio_in_h input);
404 * @brief Ignores session for input.
408 * @param[in] input The handle to the audio input
409 * @return @c 0 on success,
410 * otherwise a negative error value
411 * @retval #AUDIO_IO_ERROR_NONE Successful
412 * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
413 * @retval #AUDIO_IO_ERROR_INVALID_OPERATION Invalid operation
414 * @retval #AUDIO_IO_ERROR_NOT_SUPPORTED Not supported
416 int audio_in_ignore_session(audio_in_h input);
419 * @brief Sets an asynchronous(event) callback function to handle recording PCM (pulse-code modulation) data.
423 * @details @a callback will be called when you can read a PCM data.
424 * It might cause dead lock if change the state of audio handle in callback.
425 * (ex: audio_in_destroy, audio_in_prepare, audio_in_unprepare)
426 * Recommend to use as a VOIP only.
427 * Recommend not to hold callback too long.(it affects latency)
429 * @remarks @a input must be created using audio_in_create().
431 * @param[in] input An audio input handle
432 * @param[in] callback notify stream callback when user can read data (#audio_in_stream_cb)
433 * @param[in] userdata user data to be retrieved when callback is called
434 * @return @c 0 on success,
435 * otherwise a negative error value
436 * @retval #AUDIO_IO_ERROR_NONE Successful
437 * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
438 * @retval #AUDIO_IO_ERROR_OUT_OF_MEMORY Out of memory
439 * @retval #AUDIO_IO_ERROR_DEVICE_NOT_OPENED Device not opened
440 * @retval #AUDIO_IO_ERROR_SOUND_POLICY Sound policy error
441 * @retval #AUDIO_IO_ERROR_NOT_SUPPORTED Not supported
443 * @see audio_out_set_stream_cb()
445 int audio_in_set_stream_cb(audio_in_h input, audio_in_stream_cb callback, void* userdata);
448 * @brief Unregisters the callback function.
452 * @param[in] input The handle to the audio input
453 * @return @c 0 on success,
454 * otherwise a negative error value
455 * @retval #AUDIO_IO_ERROR_NONE Successful
456 * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
457 * @retval #AUDIO_IO_ERROR_INVALID_OPERATION Invalid operation
458 * @retval #AUDIO_IO_ERROR_NOT_SUPPORTED Not supported
460 * @see audio_in_set_interrupted_cb()
462 int audio_in_unset_stream_cb(audio_in_h input);
465 * @brief peek from audio in buffer
469 * @details This function works correctly only with read, write callback. Otherwise it won't operate as intended.
471 * @remarks @a Works only in asynchronous(event) mode. This will just retrieve buffer pointer from audio in buffer. Drop after use.
473 * @param[in] input The handle to the audio input
474 * @param[out] buffer start buffer pointer of peeked audio in data
475 * @param[in,out] length amount of audio in data to be peeked
476 * @return @c 0 on success,
477 * otherwise a negative error value
478 * @retval #AUDIO_IO_ERROR_NONE Successful
479 * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
480 * @retval #AUDIO_IO_ERROR_INVALID_OPERATION Invalid operation
481 * @retval #AUDIO_IO_ERROR_NOT_SUPPORTED Not supported
483 * @see audio_in_drop()
485 int audio_in_peek(audio_in_h input, const void **buffer, unsigned int *length);
488 * @brief drop peeked audio buffer.
490 * @details This function works correctly only with read, write callback. Otherwise it won't operate as intended.
494 * @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.
496 * @param[in] input The handle to the audio input
497 * @return 0 on success, otherwise a negative error value
498 * @retval #AUDIO_IO_ERROR_NONE Successful
499 * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
500 * @retval #AUDIO_IO_ERROR_INVALID_OPERATION Invalid operation
501 * @retval #AUDIO_IO_ERROR_NOT_SUPPORTED Not supported
503 * @see audio_in_peek()
505 int audio_in_drop(audio_in_h input);
518 * @addtogroup CAPI_MEDIA_AUDIO_OUT_MODULE
523 * @brief Called when audio out data can be written in asynchronous(event) mode.
527 * @remarks @a use audio_out_write() to write pcm data inside this callback.
528 * @param[in] handle The handle to the audio output
529 * @param[in] nbytes The amount of audio in data which can be written.
530 * @param[in] userdata The user data passed from the callback registration function
532 * @see audio_out_set_stream_cb()
534 typedef void (*audio_out_stream_cb)(audio_out_h handle, size_t nbytes, void *userdata);
537 * @brief Creates an audio device instance and returns an output handle to play PCM (pulse-code modulation) data.
541 * @details This function is used for audio output initialization.
543 * @remarks @a output must be released by audio_out_destroy().
545 * @param[in] sample_rate The audio sample rate in 8000[Hz] ~ 48000[Hz]
546 * @param[in] channel The audio channel type (mono or stereo)
547 * @param[in] type The type of audio sample (8- or 16-bit)
548 * @param[in] sound_type The type of sound (#sound_type_e)
549 * @param[out] output An audio output handle is created on success
550 * @return @c 0 on success,
551 * otherwise a negative error value
552 * @retval #AUDIO_IO_ERROR_NONE Successful
553 * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
554 * @retval #AUDIO_IO_ERROR_OUT_OF_MEMORY Out of memory
555 * @retval #AUDIO_IO_ERROR_DEVICE_NOT_OPENED Device not opened
556 * @retval #AUDIO_IO_ERROR_SOUND_POLICY Sound policy error
558 * @see audio_out_destroy()
560 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);
563 * @brief Releases the audio output handle, along with all its resources.
567 * @param[in] output The handle to the audio output to destroy
568 * @return @c 0 on success,
569 * otherwise a negative error value
570 * @retval #AUDIO_IO_ERROR_NONE Successful
571 * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
572 * @retval #AUDIO_IO_ERROR_OUT_OF_MEMORY Out of memory
573 * @retval #AUDIO_IO_ERROR_DEVICE_NOT_CLOSED Device not closed
575 * @see audio_out_create()
577 int audio_out_destroy(audio_out_h output);
580 * @brief Prepares playing audio output, this must be called before audio_out_write().
584 * @param[in] output The handle to the audio output
585 * @return @c 0 on success,
586 * otherwise a negative error value
587 * @retval #AUDIO_IO_ERROR_NONE Successful
588 * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
590 * @see audio_out_unprepare()
592 int audio_out_prepare(audio_out_h output);
595 * @brief Unprepares playing audio output.
599 * @param[in] output The handle to the audio output
600 * @return @c 0 on success,
601 * otherwise a negative error value
602 * @retval #AUDIO_IO_ERROR_NONE Successful
603 * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
605 * @see audio_out_prepare()
607 int audio_out_unprepare(audio_out_h output);
610 * @brief Drains buffered audio data from the output stream.
612 * @details This function waits until drains stream buffer completely. (e.g end of playback)
616 * @param[in] output The handle to the audio output
617 * @return @c 0 on success,
618 * otherwise a negative error value
619 * @retval #AUDIO_IO_ERROR_NONE Successful
620 * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
621 * @retval #AUDIO_IO_ERROR_INVALID_STATE Invalid state
623 * @pre The state should be #AUDIO_IO_STATE_RUNNING or #AUDIO_IO_STATE_PAUSED.
624 * @see audio_out_flush()
626 int audio_out_drain(audio_out_h output);
629 * @brief Flushes and discards buffered audio data from the output stream.
633 * @param[in] output The handle to the audio output
634 * @return @c 0 on success,
635 * otherwise a negative error value
636 * @retval #AUDIO_IO_ERROR_NONE Successful
637 * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
638 * @retval #AUDIO_IO_ERROR_INVALID_STATE Invalid state
640 * @pre The state should be #AUDIO_IO_STATE_RUNNING or #AUDIO_IO_STATE_PAUSED.
641 * @see audio_out_drain()
643 int audio_out_flush(audio_out_h output);
646 * @brief Starts writing the audio data to the device.
650 * @param[in] output The handle to the audio output
651 * @param[in,out] buffer The PCM buffer address
652 * @param[in] length The length of the PCM buffer (in bytes)
653 * @return The written data size on success,
654 * otherwise a negative error value
655 * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
656 * @retval #AUDIO_IO_ERROR_INVALID_BUFFER Invalid buffer pointer
657 * @retval #AUDIO_IO_ERROR_SOUND_POLICY Sound policy error
659 int audio_out_write(audio_out_h output, void *buffer, unsigned int length);
662 * @brief Gets the size to be allocated for the audio output buffer.
666 * @param[in] output The handle to the audio output
667 * @param[out] size The suggested buffer size (in bytes, the maximum size is 1 MB)
668 * @return @c 0 on success,
669 * otherwise a negative error value
670 * @retval #AUDIO_IO_ERROR_NONE Successful
671 * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
673 * @see audio_out_write()
675 int audio_out_get_buffer_size(audio_out_h output, int *size);
678 * @brief Gets the sample rate of the audio output data stream.
682 * @param[in] output The handle to the audio output
683 * @param[out] sample_rate The audio sample rate in Hertz (8000 ~ 48000)
684 * @return @c 0 on success,
685 * otherwise a negative error value
686 * @retval #AUDIO_IO_ERROR_NONE Successful
687 * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
689 int audio_out_get_sample_rate(audio_out_h output, int *sample_rate);
692 * @brief Gets the channel type of the audio output data stream.
693 * @details The audio channel type defines whether the audio is mono or stereo.
697 * @param[in] output The handle to the audio output
698 * @param[out] channel The audio channel type
699 * @return @c 0 on success,
700 * otherwise a negative error value
701 * @retval #AUDIO_IO_ERROR_NONE Successful
702 * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
704 int audio_out_get_channel(audio_out_h output, audio_channel_e *channel);
707 * @brief Gets the sample audio format (8-bit or 16-bit) of the audio output data stream.
711 * @param[in] output The handle to the audio output
712 * @param[out] type The audio sample type
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
718 int audio_out_get_sample_type(audio_out_h output, audio_sample_type_e *type);
722 * @brief Gets the sound type supported by the audio output device.
726 * @param[in] output The handle to the audio output
727 * @param[out] type The sound type
728 * @return @c 0 on success,
729 * otherwise a negative error value
730 * @retval #AUDIO_IO_ERROR_NONE Successful
731 * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
733 int audio_out_get_sound_type(audio_out_h output, sound_type_e *type);
736 * @brief Registers a callback function to be invoked when the audio output handle is interrupted or the interrupt is completed.
740 * @param[in] output The handle to the audio output
741 * @param[in] callback The callback function to register
742 * @param[in] user_data The user data to be passed to the callback function
743 * @return @c 0 on success,
744 * otherwise a negative error value
745 * @retval #AUDIO_IO_ERROR_NONE Successful
746 * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
747 * @retval #AUDIO_IO_ERROR_INVALID_OPERATION Invalid operation
749 * @post audio_io_interrupted_cb() will be invoked.
750 * @see audio_out_unset_interrupted_cb()
751 * @see audio_io_interrupted_cb()
753 int audio_out_set_interrupted_cb(audio_out_h output, audio_io_interrupted_cb callback, void *user_data);
756 * @brief Unregisters the callback function.
760 * @param[in] output The handle to the audio output
761 * @return @c 0 on success,
762 * otherwise a negative error value
763 * @retval #AUDIO_IO_ERROR_NONE Successful
764 * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
765 * @retval #AUDIO_IO_ERROR_INVALID_OPERATION Invalid operation
767 * @see audio_out_set_interrupted_cb()
769 int audio_out_unset_interrupted_cb(audio_out_h output);
772 * @brief Ignores session for output.
776 * @param[in] output The handle to the audio output
777 * @return @c 0 on success,
778 * otherwise a negative error value
779 * @retval #AUDIO_IO_ERROR_NONE Successful
780 * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
781 * @retval #AUDIO_IO_ERROR_INVALID_OPERATION Invalid operation
783 int audio_out_ignore_session(audio_out_h output);
786 * @brief Sets an asynchronous(event) callback function to handle playing PCM (pulse-code modulation) data.
790 * @details @a callback will be called when you can write a PCM data.
791 * It might cause dead lock if change the state of audio handle in callback.
792 * (ex: audio_in_destroy, audio_in_prepare, audio_in_unprepare)
793 * Recommend to use as a VOIP only.
794 * Recommend not to hold callback too long.(it affects latency)
796 * @remarks @a output must be created using audio_out_create().
798 * @param[in] output An audio output handle
799 * @param[in] callback notify stream callback when user can write data (#audio_out_stream_cb)
800 * @param[in] userdata user data to be retrieved when callback is called
801 * @return 0 on success, otherwise a negative error value
802 * @retval #AUDIO_IO_ERROR_NONE Successful
803 * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
804 * @retval #AUDIO_IO_ERROR_OUT_OF_MEMORY Out of memory
805 * @retval #AUDIO_IO_ERROR_DEVICE_NOT_OPENED Device not opened
806 * @retval #AUDIO_IO_ERROR_SOUND_POLICY Sound policy error
808 * @see audio_in_set_stream_cb()
810 int audio_out_set_stream_cb(audio_out_h output, audio_out_stream_cb callback, void* userdata);
813 * @brief Unregisters the callback function.
817 * @param[in] output The handle to the audio output
818 * @return 0 on success, otherwise a negative error value
819 * @retval #AUDIO_IO_ERROR_NONE Successful
820 * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
821 * @retval #AUDIO_IO_ERROR_INVALID_OPERATION Invalid operation
823 * @see audio_out_set_stream_cb()
825 int audio_out_unset_stream_cb(audio_out_h output);
834 #endif /* __TIZEN_MEDIA_AUDIO_IO_H__ */