Add writable-size wait timeout log / Terminate write operation with accumulated timeouts
[platform/core/api/audio-io.git] / include / audio_io.h
index 85ea8cb..421b0d5 100644 (file)
@@ -74,6 +74,7 @@ typedef enum {
        AUDIO_SAMPLE_TYPE_S16_LE,       /**< Signed 16-bit audio samples */
        AUDIO_SAMPLE_TYPE_S24_LE,       /**< Signed 24-bit audio samples (Since 5.0) */
        AUDIO_SAMPLE_TYPE_S24_32_LE,    /**< Signed 24-bit (packed in 32-bit) audio samples (Since 5.0) */
+       AUDIO_SAMPLE_TYPE_S32_LE,       /**< Signed 32-bit audio samples (Since 5.5) */
 } audio_sample_type_e;
 
 /**
@@ -81,8 +82,14 @@ typedef enum {
  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
  */
 typedef enum {
-       AUDIO_CHANNEL_MONO = 0x80,                  /**< 1 channel, mono */
-       AUDIO_CHANNEL_STEREO,                       /**< 2 channel, stereo */
+       AUDIO_CHANNEL_MONO = 0x80,         /**< 1 channel, mono */
+       AUDIO_CHANNEL_STEREO,              /**< 2 channels, stereo */
+       AUDIO_CHANNEL_MULTI_3,             /**< 3 channels (Since 5.5) */
+       AUDIO_CHANNEL_MULTI_4,             /**< 4 channels (Since 5.5) */
+       AUDIO_CHANNEL_MULTI_5,             /**< 5 channels (Since 5.5) */
+       AUDIO_CHANNEL_MULTI_6,             /**< 6 channels (Since 5.5) */
+       AUDIO_CHANNEL_MULTI_7,             /**< 7 channels (Since 5.5) */
+       AUDIO_CHANNEL_MULTI_8,             /**< 8 channels (Since 5.5) */
 } audio_channel_e;
 
 /**
@@ -125,14 +132,14 @@ typedef enum {
  */
 
 /**
- * @brief Called when audio input data is available in asynchronous(event) mode.
+ * @brief Called when audio input data is available in asynchronous (event) mode.
  *
  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
  *
- * @remarks @a use audio_in_peek() to get audio in data inside callback, use audio_in_drop() after use of peeked data.
+ * @remarks Use audio_in_peek() to get 'audio in' data inside callback, use audio_in_drop() after use of peeked data.
  *
  * @param[in] handle The handle to the audio input
- * @param[in] nbytes The amount of available audio in data which can be peeked.
+ * @param[in] nbytes The amount of available 'audio in' data which can be peeked.
  * @param[in] user_data The user data passed from the callback registration function
  *
  * @see audio_in_set_stream_cb()
@@ -165,10 +172,18 @@ typedef void (*audio_in_state_changed_cb)(audio_in_h handle, audio_io_state_e pr
  * @privilege %http://tizen.org/privilege/recorder
  *
  * @remarks @a input must be released using audio_in_destroy().
- *
- * @param[in] sample_rate The audio sample rate in 8000[Hz] ~ 48000[Hz] (Before 5.0), 8000[Hz] ~ 192000[Hz] (Since 5.0)
- * @param[in] channel The audio channel type (mono or stereo)
- * @param[in] type The type of audio sample (8- or 16-bit)
+ *          If the channel count of the requested @a channel is different from the system's supported channel count, then channel remapping will be processed internally.
+ *
+ * @param[in] sample_rate The audio sample rate \n
+ *                        Before 5.0: 8000[Hz] ~ 48000[Hz] \n
+ *                         Since 5.0: 8000[Hz] ~ 192000[Hz]
+ * @param[in] channel The audio channel type \n
+ *                    Before 5.5: Mono or stereo \n
+ *                     Since 5.5: Mono, stereo or multi-channels
+ * @param[in] type The type of audio sample \n
+ *                 Before 5.0: 8 or 16-bit \n
+ *                  Since 5.0: 8, 16 or 24-bit \n
+ *                  Since 5.5: 8, 16, 24 or 32-bit
  * @param[out] input An audio input handle is created on success
  * @return @c 0 on success,
  *         otherwise a negative error value
@@ -208,7 +223,7 @@ int audio_in_destroy(audio_in_h input);
  *
  * @since_tizen 3.0
  *
- * @remarks @a the sound stream information includes audio routing and volume type.
+ * @remarks The sound stream information includes audio routing and volume type.
  *          For more details, you can refer to @ref CAPI_MEDIA_SOUND_MANAGER_MODULE
  *          System, Alarm, Notification, Emergency, Voice Information, Ringtone VOIP and Ringtone Call stream types are not supported in this API.
  *
@@ -364,7 +379,9 @@ int audio_in_get_buffer_size(audio_in_h input, int *size);
  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
  *
  * @param[in] input The handle to the audio input
- * @param[out] sample_rate The audio sample rate in Hertz (8000 ~ 48000) (Before 5.0), (8000 ~ 192000) (Since 5.0)
+ * @param[out] sample_rate The audio sample rate \n
+ *                         Before 5.0: 8000[Hz] ~ 48000[Hz] \n
+ *                          Since 5.0: 8000[Hz] ~ 192000[Hz]
  * @return @c 0 on success,
  *         otherwise a negative error value
  * @retval #AUDIO_IO_ERROR_NONE Successful
@@ -376,12 +393,12 @@ int audio_in_get_sample_rate(audio_in_h input, int *sample_rate);
 /**
  * @brief Gets the channel type of the audio input data stream.
  *
- * @details The audio channel type defines whether the audio is mono or stereo.
- *
  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
  *
  * @param[in] input The handle to the audio input
- * @param[out] channel The audio channel type
+ * @param[out] channel The audio channel type \n
+ *                     Before 5.5: Mono or stereo \n
+ *                      Since 5.5: Mono, stereo or multi-channels
  * @return @c 0 on success,
  *         otherwise a negative error value
  * @retval #AUDIO_IO_ERROR_NONE Successful
@@ -391,12 +408,15 @@ int audio_in_get_sample_rate(audio_in_h input, int *sample_rate);
 int audio_in_get_channel(audio_in_h input, audio_channel_e *channel);
 
 /**
- * @brief Gets the sample audio format (8-bit or 16-bit) of the audio input data stream.
+ * @brief Gets the sample audio format of the audio input data stream.
  *
  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
  *
  * @param[in] input The handle to the audio input
- * @param[out] type The audio sample type
+ * @param[out] type The type of audio sample \n
+ *                  Before 5.0: 8 or 16-bit \n
+ *                   Since 5.0: 8, 16 or 24-bit \n
+ *                   Since 5.5: 8, 16, 24 or 32-bit
  * @return @c 0 on success,
  *         otherwise a negative error value
  * @retval #AUDIO_IO_ERROR_NONE Successful
@@ -406,11 +426,11 @@ int audio_in_get_channel(audio_in_h input, audio_channel_e *channel);
 int audio_in_get_sample_type(audio_in_h input, audio_sample_type_e *type);
 
 /**
- * @brief Sets an asynchronous(event) callback function to handle recording PCM (pulse-code modulation) data.
+ * @brief Sets an asynchronous (event) callback function to handle recording PCM (pulse-code modulation) data.
  *
  * @details @a callback will be called when you can read a PCM data.
  * It might cause dead lock if change the state of audio handle in callback.
- * (ex: audio_in_destroy, audio_in_prepare, audio_in_unprepare)
+ * (ex: audio_in_destroy(), audio_in_prepare(), audio_in_unprepare())
  * Recommend to use as a VOIP only.
  * Recommend not to hold callback too long.(it affects latency)
  *
@@ -452,17 +472,19 @@ int audio_in_set_stream_cb(audio_in_h input, audio_in_stream_cb callback, void*
 int audio_in_unset_stream_cb(audio_in_h input);
 
 /**
- * @brief peek from audio in buffer
+ * @brief Peeks into the 'audio in' buffer.
  *
- * @details This function works correctly only with read, write callback. Otherwise it won't operate as intended.
+ * @details This function works correctly only with read callback. Otherwise it won't operate as intended.
  *
  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
  *
- * @remarks @a Works only in asynchronous(event) mode. This will just retrieve buffer pointer from audio in buffer. Drop after use.
+ * @remarks Works only in asynchronous (event) mode.
+ *          This function provides the pointer to the 'audio in' buffer. The pointed memory is owned by the platform, therefore the @a buffer should not be released by the application.
+ *          When the data in the @a buffer is not needed anymore, use audio_in_drop() with the @a input for which audio_in_peek() was called.
  *
  * @param[in] input The handle to the audio input
- * @param[out] buffer start buffer pointer of peeked audio in data
- * @param[out] length amount of audio in data to be peeked
+ * @param[out] buffer start buffer pointer of peeked 'audio in' data
+ * @param[out] length amount of 'audio in' data to be peeked
  * @return @c 0 on success,
  *         otherwise a negative error value
  * @retval #AUDIO_IO_ERROR_NONE Successful
@@ -477,13 +499,13 @@ int audio_in_unset_stream_cb(audio_in_h input);
 int audio_in_peek(audio_in_h input, const void **buffer, unsigned int *length);
 
 /**
- * @brief drop peeked audio buffer.
+ * @brief Drops the 'audio in' buffer that was peeked into.
  *
- * @details This function works correctly only with read, write callback. Otherwise it won't operate as intended.
+ * @details This function works correctly only with read callback. Otherwise it won't operate as intended.
  *
  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
  *
- * @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.
+ * @remarks Works only in asynchronous (event) mode. This will remove 'audio in' data from the actual stream buffer. Use this if peeked data is not needed anymore.
  *
  * @param[in] input The handle to the audio input
  * @return 0 on success, otherwise a negative error value
@@ -535,6 +557,48 @@ int audio_in_set_state_changed_cb(audio_in_h input, audio_in_state_changed_cb ca
 int audio_in_unset_state_changed_cb(audio_in_h input);
 
 /**
+ * @brief Gets the volume of the audio input data stream.
+ *
+ * @since_tizen 6.0
+ *
+ * @remarks The default @a volume of the audio input stream is 1.0.
+ *
+ * @param[in] input The handle to the audio input
+ * @param[out] volume The current volume value of the audio input stream
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #AUDIO_IO_ERROR_NONE Successful
+ * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #AUDIO_IO_ERROR_NOT_SUPPORTED Not supported
+ *
+ * @see audio_in_set_volume()
+ */
+int audio_in_get_volume(audio_in_h input, double *volume);
+
+/**
+ * @brief Sets the volume of the audio input data stream.
+ *
+ * @since_tizen 6.0
+ *
+ * @remarks The default @a volume of the audio input stream is 1.0.
+ *          If the @a volume is less than 1.0, the loudness of recorded data will be decreased.
+ *          If the @a volume is greater than 1.0, the loudness of recorded data will be increased,
+ *          which can be useful when the loudness of original recorded data is too low in certain environments.
+ *          Note that the volume can be clipped if the @a volume is greater than 1.0 and the loudness of original recorded data is high enough.
+ *
+ * @param[in] input The handle to the audio input
+ * @param[in] volume The volume value to be set (0.0 <= volume <= 2.0)
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #AUDIO_IO_ERROR_NONE Successful
+ * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #AUDIO_IO_ERROR_NOT_SUPPORTED Not supported
+ *
+ * @see audio_in_get_volume()
+ */
+int audio_in_set_volume(audio_in_h input, double volume);
+
+/**
  * @}
  */
 
@@ -544,13 +608,13 @@ int audio_in_unset_state_changed_cb(audio_in_h input);
  */
 
 /**
- * @brief Called when audio out data can be written in asynchronous(event) mode.
+ * @brief Called when 'audio out' data can be written in asynchronous (event) mode.
  *
  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
  *
- * @remarks @a use audio_out_write() to write pcm data inside this callback.
+ * @remarks Use audio_out_write() to write pcm data inside this callback.
  * @param[in] handle The handle to the audio output
- * @param[in] nbytes The amount of audio in data which can be written.
+ * @param[in] nbytes The amount of 'audio in' data which can be written.
  * @param[in] user_data The user data passed from the callback registration function
  *
  * @see audio_out_set_stream_cb()
@@ -582,10 +646,16 @@ typedef void (*audio_out_state_changed_cb)(audio_out_h handle, audio_io_state_e
  *
  * @remarks @a output must be released by audio_out_destroy().
  *          It is recommended to call audio_out_set_sound_stream_info() after this API.
+ *          Multi-channel playback is not supported.
  *
- * @param[in] sample_rate The audio sample rate in 8000[Hz] ~ 48000[Hz] (Before 5.0), 8000[Hz] ~ 192000[Hz] (Since 5.0)
+ * @param[in] sample_rate The audio sample rate \n
+ *                        Before 5.0: 8000[Hz] ~ 48000[Hz] \n
+ *                         Since 5.0: 8000[Hz] ~ 192000[Hz]
  * @param[in] channel The audio channel type (mono or stereo)
- * @param[in] type The type of audio sample (8-bit or 16-bit)
+ * @param[in] type The type of audio sample \n
+ *                 Before 5.0: 8 or 16-bit \n
+ *                  Since 5.0: 8, 16 or 24-bit \n
+ *                  Since 5.5: 8, 16, 24 or 32-bit
  * @param[out] output An audio output handle is created on success
  * @return @c 0 on success,
  *         otherwise a negative error value
@@ -623,7 +693,7 @@ int audio_out_destroy(audio_out_h output);
  *
  * @since_tizen 3.0
  *
- * @remarks @a the sound stream information includes audio routing and volume type.
+ * @remarks The sound stream information includes audio routing and volume type.
  *          For more details, you can refer to @ref CAPI_MEDIA_SOUND_MANAGER_MODULE
  *          Voice Recognition and Loopback stream types are not supported in this API.
  *
@@ -792,7 +862,9 @@ int audio_out_get_buffer_size(audio_out_h output, int *size);
  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
  *
  * @param[in] output The handle to the audio output
- * @param[out] sample_rate The audio sample rate in Hertz (8000 ~ 48000) (Before 5.0), (8000 ~ 192000) (Since 5.0)
+ * @param[out] sample_rate The audio sample rate \n
+ *                         Before 5.0: 8000[Hz] ~ 48000[Hz] \n
+ *                          Since 5.0: 8000[Hz] ~ 192000[Hz]
  * @return  @c 0 on success,
  *          otherwise a negative error value
  * @retval  #AUDIO_IO_ERROR_NONE Successful
@@ -803,12 +875,10 @@ int audio_out_get_sample_rate(audio_out_h output, int *sample_rate);
 /**
  * @brief Gets the channel type of the audio output data stream.
  *
- * @details The audio channel type defines whether the audio is mono or stereo.
- *
  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
  *
  * @param[in] output The handle to the audio output
- * @param[out] channel The audio channel type
+ * @param[out] channel The audio channel type (mono or stereo)
  * @return @c 0 on success,
  *         otherwise a negative error value
  * @retval #AUDIO_IO_ERROR_NONE Successful
@@ -817,12 +887,15 @@ int audio_out_get_sample_rate(audio_out_h output, int *sample_rate);
 int audio_out_get_channel(audio_out_h output, audio_channel_e *channel);
 
 /**
- * @brief Gets the sample audio format (8-bit or 16-bit) of the audio output data stream.
+ * @brief Gets the sample audio format of the audio output data stream.
  *
  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
  *
  * @param[in] output The handle to the audio output
- * @param[out] type The audio sample type
+ * @param[out] type The type of audio sample \n
+ *                  Before 5.0: 8 or 16-bit \n
+ *                   Since 5.0: 8, 16 or 24-bit \n
+ *                   Since 5.5: 8, 16, 24 or 32-bit
  * @return @c 0 on success,
  *         otherwise a negative error value
  * @retval #AUDIO_IO_ERROR_NONE Successful
@@ -845,11 +918,11 @@ int audio_out_get_sample_type(audio_out_h output, audio_sample_type_e *type);
 int audio_out_get_sound_type(audio_out_h output, sound_type_e *type);
 
 /**
- * @brief Sets an asynchronous(event) callback function to handle playing PCM (pulse-code modulation) data.
+ * @brief Sets an asynchronous (event) callback function to handle playing PCM (pulse-code modulation) data.
  *
  * @details @a callback will be called when you can write a PCM data.
  * It might cause dead lock if change the state of audio handle in callback.
- * (ex: audio_out_destroy, audio_out_prepare, audio_out_unprepare)
+ * (ex: audio_out_destroy(), audio_out_prepare(), audio_out_unprepare())
  * Recommend to use as a VOIP only.
  * Recommend not to hold callback too long.(it affects latency)
  *