audio-io add drain/flush APIs 99/40299/4 accepted/tizen_3.0.2015.q2_common tizen_3.0.2015.q2_common accepted/tizen/3.0.2015.q2/common/20150615.160126 accepted/tizen/common/20150615.075842 accepted/tizen/mobile/20150616.010509 accepted/tizen/tv/20150616.010533 accepted/tizen/wearable/20150616.010551 submit/submit/tizen/20150603.045007/20150603.045120 submit/tizen/20150612.061826 submit/tizen_3.0.2015.q2_common/20150615.075539
authorKimJeongYeon <jeongyeon.kim@samsung.com>
Tue, 2 Jun 2015 05:58:33 +0000 (14:58 +0900)
committerKimJeongYeon <jeongyeon.kim@samsung.com>
Wed, 3 Jun 2015 01:46:27 +0000 (10:46 +0900)
[Version] 0.2.2
[Profile] Common
[Issue Type] Add features
[Dependency module] libmm-sound
[Dependency commit] e8195430f9822760bbb469b48bd5cab807202dec
[Comment]
+ audio_in_flush()
+ audio_out_drain()
+ audio_out_flush()

Signed-off-by: KimJeongYeon <jeongyeon.kim@samsung.com>
Change-Id: Ib9898c3a0420af9ba6480cea3d0299bacdc46160

include/audio_io.h
packaging/capi-media-audio-io.spec
src/audio_io.c [changed mode: 0755->0644]

index 0b237cffe7dc784c80aa65845edb4afd1587a1d5..b797d2d448bb2913fbb322b5623e395992a321fb 100644 (file)
@@ -263,6 +263,23 @@ int audio_in_prepare(audio_in_h input);
  */
 int audio_in_unprepare(audio_in_h input);
 
+/**
+ * @brief Flushes and discards buffered audio data from the input stream.
+ *
+ * @since_tizen 2.4
+ *
+ * @param[in] input The handle to the audio input
+ * @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
+ * @retval #AUDIO_IO_ERROR_INVALID_STATE Invalid state
+ *
+ * @pre The state should be #AUDIO_IO_STATE_RUNNING or #AUDIO_IO_STATE_PAUSED.
+ */
+int audio_in_flush(audio_in_h input);
+
 /**
  * @brief Reads audio data from the audio input buffer.
  *
@@ -271,7 +288,7 @@ int audio_in_unprepare(audio_in_h input);
  * @param[in] input The handle to the audio input
  * @param[out] buffer The PCM buffer address
  * @param[in] length The length of the PCM data buffer (in bytes)
- * @return The number of read bytes on success, 
+ * @return The number of read bytes on success,
  *         otherwise a negative error value
  * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
  * @retval #AUDIO_IO_ERROR_INVALID_BUFFER Invalid buffer pointer
@@ -589,6 +606,42 @@ int audio_out_prepare(audio_out_h output);
  */
 int audio_out_unprepare(audio_out_h output);
 
+/**
+ * @brief Drains buffered audio data from the output stream.
+ *
+ * @details This function waits until drains stream buffer completely. (e.g end of playback)
+ *
+ * @since_tizen 2.4
+ *
+ * @param[in] output The handle to the audio output
+ * @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_INVALID_STATE Invalid state
+ *
+ * @pre The state should be #AUDIO_IO_STATE_RUNNING or #AUDIO_IO_STATE_PAUSED.
+ * @see audio_out_flush()
+ */
+int audio_out_drain(audio_out_h output);
+
+/**
+ * @brief Flushes and discards buffered audio data from the output stream.
+ *
+ * @since_tizen 2.4
+ *
+ * @param[in] output The handle to the audio output
+ * @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_INVALID_STATE Invalid state
+ *
+ * @pre The state should be #AUDIO_IO_STATE_RUNNING or #AUDIO_IO_STATE_PAUSED.
+ * @see audio_out_drain()
+ */
+int audio_out_flush(audio_out_h output);
+
 /**
  * @brief Starts writing the audio data to the device.
  *
@@ -597,7 +650,7 @@ int audio_out_unprepare(audio_out_h output);
  * @param[in] output The handle to the audio output
  * @param[in,out] buffer The PCM buffer address
  * @param[in] length The length of the PCM buffer (in bytes)
- * @return The written data size on success, 
+ * @return The written data size on success,
  *         otherwise a negative error value
  * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
  * @retval #AUDIO_IO_ERROR_INVALID_BUFFER Invalid buffer pointer
index 92118a349e38576d9b12d766489fc6bd2af51342..fe26901a7f4beda04bf1872b20024d0cc60d2564 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-audio-io
 Summary:    An Audio Input & Audio Output library in Tizen Native API
-Version: 0.2.1
+Version: 0.2.2
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
old mode 100755 (executable)
new mode 100644 (file)
index 8ed0cee..6b29ada
@@ -94,6 +94,21 @@ int audio_in_unprepare(audio_in_h input)
        return AUDIO_IO_ERROR_NONE;
 }
 
+int audio_in_flush(audio_in_h input)
+{
+       AUDIO_IO_NULL_ARG_CHECK(input);
+       audio_in_s *handle = (audio_in_s *) input;
+       int ret = MM_ERROR_NONE;
+
+       ret = mm_sound_pcm_capture_flush(handle->mm_handle);
+       if (ret != MM_ERROR_NONE) {
+               return __convert_audio_io_error_code(ret, (char*)__FUNCTION__);
+       }
+
+       LOGI("[%s] mm_sound_pcm_capture_flush() success",__FUNCTION__);
+       return AUDIO_IO_ERROR_NONE;
+}
+
 int audio_in_read(audio_in_h input, void *buffer, unsigned int length )
 {
        AUDIO_IO_NULL_ARG_CHECK(input);
@@ -286,6 +301,36 @@ int audio_out_unprepare(audio_out_h output)
        return AUDIO_IO_ERROR_NONE;
 }
 
+int audio_out_drain(audio_out_h output)
+{
+       AUDIO_IO_NULL_ARG_CHECK(output);
+       audio_out_s *handle = (audio_out_s *) output;
+       int ret = MM_ERROR_NONE;
+
+       ret = mm_sound_pcm_play_drain(handle->mm_handle);
+       if (ret != MM_ERROR_NONE) {
+               return __convert_audio_io_error_code(ret, (char*)__FUNCTION__);
+       }
+
+       LOGI("[%s] mm_sound_pcm_play_drain() success",__FUNCTION__);
+       return AUDIO_IO_ERROR_NONE;
+}
+
+int audio_out_flush(audio_out_h output)
+{
+       AUDIO_IO_NULL_ARG_CHECK(output);
+       audio_out_s *handle = (audio_out_s *) output;
+       int ret = MM_ERROR_NONE;
+
+       ret = mm_sound_pcm_play_flush(handle->mm_handle);
+       if (ret != MM_ERROR_NONE) {
+               return __convert_audio_io_error_code(ret, (char*)__FUNCTION__);
+       }
+
+       LOGI("[%s] mm_sound_pcm_play_flush() success",__FUNCTION__);
+       return AUDIO_IO_ERROR_NONE;
+}
+
 int audio_out_write(audio_out_h output, void* buffer, unsigned int length)
 {
        AUDIO_IO_NULL_ARG_CHECK(output);