diff options
author | jk7744.park <jk7744.park@samsung.com> | 2015-10-24 16:21:51 +0900 |
---|---|---|
committer | jk7744.park <jk7744.park@samsung.com> | 2015-10-24 16:21:51 +0900 |
commit | 24ae0a2ece2cd116eea6fc9b41403a38e95aedda (patch) | |
tree | b7339ea1abcbeeed314cde7f4bb27889b4210bc1 | |
parent | db7ddd104db9bdfb1364f6ee12f2daf30b039b60 (diff) | |
download | audio-io-24ae0a2ece2cd116eea6fc9b41403a38e95aedda.tar.gz audio-io-24ae0a2ece2cd116eea6fc9b41403a38e95aedda.tar.bz2 audio-io-24ae0a2ece2cd116eea6fc9b41403a38e95aedda.zip |
tizen 2.4 releasetizen_2.4_mobile_releasesubmit/tizen_2.4/20151028.063508accepted/tizen/2.4/mobile/20151029.034946
-rw-r--r-- | doc/audio_io_doc.h | 2 | ||||
-rw-r--r-- | include/audio_io.h | 46 | ||||
-rw-r--r-- | include/audio_io_internal.h | 73 | ||||
-rw-r--r-- | include/audio_io_private.h | 3 | ||||
-rw-r--r-- | packaging/capi-media-audio-io.spec | 3 | ||||
-rw-r--r-- | src/audio_io.c | 59 | ||||
-rw-r--r-- | src/audio_io_internal.c | 42 | ||||
-rw-r--r-- | src/audio_io_private.c | 8 | ||||
-rw-r--r-- | test/audio_io_test.c | 8 |
9 files changed, 231 insertions, 13 deletions
diff --git a/doc/audio_io_doc.h b/doc/audio_io_doc.h index a875a31..3f2adb4 100644 --- a/doc/audio_io_doc.h +++ b/doc/audio_io_doc.h @@ -72,7 +72,7 @@ * * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n * - * More details on featuring your application can be found from <a href="../org.tizen.mobile.native.appprogramming/html/ide_sdk_tools/feature_element.htm"><b>Feature Element</b>.</a> + * More details on featuring your application can be found from <a href="https://developer.tizen.org/development/tools/native-tools/manifest-text-editor#feature"><b>Feature Element</b>.</a> * */ diff --git a/include/audio_io.h b/include/audio_io.h index 484a9c1..170bf90 100644 --- a/include/audio_io.h +++ b/include/audio_io.h @@ -264,6 +264,20 @@ 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 + */ +int audio_in_flush(audio_in_h input); + +/** * @brief Reads audio data from the audio input buffer. * * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif @@ -590,6 +604,38 @@ 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 + * + * @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 + * + * @see audio_out_drain() + */ +int audio_out_flush(audio_out_h output); + +/** * @brief Starts writing the audio data to the device. * * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif diff --git a/include/audio_io_internal.h b/include/audio_io_internal.h new file mode 100644 index 0000000..1ae3b6c --- /dev/null +++ b/include/audio_io_internal.h @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __TIZEN_MEDIA_AUDIO_IO_INTERNAL_H__ +#define __TIZEN_MEDIA_AUDIO_IO_INTERNAL_H__ + +#include <tizen.h> +#include <sound_manager.h> +#include <sys/types.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + +/** + * @file audio_io_internal.h + * @brief This file contains the Audio Input and Audio Output API. + */ + +/** + * @brief Gets the latency value of audio input data stream + * @param[in] input The handle to the audio input + * @param[out] latency The stream latency value(millisecond). + * + * @return 0 on success, otherwise a negative error value. + * @retval #AUDIO_IO_ERROR_NONE Successful + * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter + * @see audio_out_get_latency() + */ +int audio_in_get_latency(audio_in_h input, int *latency); + +/** + * @brief Gets the latency value of audio output data stream + * @param[in] input The handle to the audio output + * @param[out] latency The stream latency value(millisecond). + * + * @return 0 on success, otherwise a negative error value. + * @retval #AUDIO_IO_ERROR_NONE Successful + * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter + * @see audio_in_get_latency() + */ +int audio_out_get_latency(audio_out_h output, int *latency); + +/** + * @brief Set device which USB Mic input you want to capture + * @remarks @a Can be used after audio_in_prepare + * @param[in] input The handle to the audio input + * @param[in] device Device unique information (udev id) to Capture + * @return 0 on success, otherwise a negative error value. + * @retval #AUDIO_IO_ERROR_NONE Successful + * @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter + */ +int audio_in_set_device(audio_in_h input, char* device); + +#ifdef __cplusplus +} +#endif + +#endif /* __TIZEN_MEDIA_AUDIO_IO_INTERNAL_H__ */ diff --git a/include/audio_io_private.h b/include/audio_io_private.h index 6fbe201..4f9d9c0 100644 --- a/include/audio_io_private.h +++ b/include/audio_io_private.h @@ -25,9 +25,6 @@ * Internal Macros */ -#define AUDIO_IO_INTERRUPTED_BY_RESUMABLE_MEDIA (AUDIO_IO_INTERRUPTED_BY_NOTIFICATION + 1) -#define AUDIO_IO_INTERRUPTED_BY_RESUMABLE_CANCELED (AUDIO_IO_INTERRUPTED_BY_NOTIFICATION + 2) - #define AUDIO_IO_CHECK_CONDITION(condition,error,msg) \ if(condition) {} else \ { LOGE("[%s] %s(0x%08x)",__FUNCTION__, msg,error); return error;}; \ diff --git a/packaging/capi-media-audio-io.spec b/packaging/capi-media-audio-io.spec index c742d92..5e3a5e8 100644 --- a/packaging/capi-media-audio-io.spec +++ b/packaging/capi-media-audio-io.spec @@ -1,7 +1,7 @@ #sbs-git:slp/api/audio-io capi-media-audio-io 0.1.0 da265a7364928d92084360809316e36f666f053f Name: capi-media-audio-io Summary: An Audio Input & Audio Output library in Tizen Native API -Version: 0.2.28 +Version: 0.2.34 Release: 0 Group: libdevel License: Apache-2.0 @@ -56,6 +56,7 @@ mkdir -p %{buildroot}/usr/share/privilege-control %files devel %{_includedir}/media/audio_io.h +%{_includedir}/media/audio_io_internal.h %{_libdir}/pkgconfig/*.pc %{_libdir}/libcapi-media-audio-io.so #%{_prefix}/bin/audio_io_test diff --git a/src/audio_io.c b/src/audio_io.c index 0b0fec8..f333e9e 100644 --- a/src/audio_io.c +++ b/src/audio_io.c @@ -107,6 +107,25 @@ 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; + + if (handle->is_async) { + ret = mm_sound_pcm_capture_flush_async(handle->mm_handle); + } else { + 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); @@ -376,6 +395,46 @@ 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; + + if (handle->is_async) { + ret = mm_sound_pcm_play_drain_async(handle->mm_handle); + } else { + 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; + + if (handle->is_async) { + ret = mm_sound_pcm_play_flush_async(handle->mm_handle); + } else { + 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); diff --git a/src/audio_io_internal.c b/src/audio_io_internal.c new file mode 100644 index 0000000..f339415 --- /dev/null +++ b/src/audio_io_internal.c @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <mm.h> +#include "audio_io_private.h" +#include <dlog.h> + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "TIZEN_N_AUDIO_IO" + +int audio_in_get_latency(audio_in_h input, int *latency) +{ + return AUDIO_IO_ERROR_NONE; +} + +int audio_out_get_latency(audio_out_h output, int *latency) +{ + return AUDIO_IO_ERROR_NONE; +} + +int audio_in_set_device(audio_in_h input, char* device) +{ + return AUDIO_IO_ERROR_NONE; +} diff --git a/src/audio_io_private.c b/src/audio_io_private.c index abacab6..789e286 100644 --- a/src/audio_io_private.c +++ b/src/audio_io_private.c @@ -139,14 +139,6 @@ audio_io_interrupted_code_e __translate_interrupted_code (int code) case MM_MSG_CODE_INTERRUPTED_BY_EMERGENCY_START: e = AUDIO_IO_INTERRUPTED_BY_EMERGENCY; break; - - case MM_MSG_CODE_INTERRUPTED_BY_RESUMABLE_MEDIA: - e = AUDIO_IO_INTERRUPTED_BY_RESUMABLE_MEDIA; - break; - - case MM_MSG_CODE_INTERRUPTED_BY_RESUMABLE_CANCELED: - e = AUDIO_IO_INTERRUPTED_BY_RESUMABLE_CANCELED; - break; } return e; diff --git a/test/audio_io_test.c b/test/audio_io_test.c index f28da0e..6a3f7e0 100644 --- a/test/audio_io_test.c +++ b/test/audio_io_test.c @@ -384,6 +384,14 @@ int _convert_cmd_and_run(char cmd, int mode) { if(mode & 0x01) ret = audio_out_unprepare(output); if(mode & 0x02) ret = audio_in_unprepare(input); break; + case 'd': + if(mode & 0x01) ret = audio_out_drain(output); + //if(mode & 0x02) ret = audio_in_drain(input); + break; + case 'f': + if(mode & 0x01) ret = audio_out_flush(output); + if(mode & 0x02) ret = audio_in_flush(input); + break; case 'i': #ifdef _SESSION_SOUND_MANAGER_API_ ret = sound_manager_set_session_type(SOUND_SESSION_TYPE_MEDIA); |