summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeungbae Shin <seungbae.shin@samsung.com>2012-08-21 20:47:55 +0900
committerSeungbae Shin <seungbae.shin@samsung.com>2012-08-21 20:47:55 +0900
commitd35f10bcf7df8f242062beb7e6e2462ef81f9807 (patch)
treede2e0be402bbb4cbbb5e179670dcf7d6238f0f3a
parentf5eaed17888c6710641e6bd1f85ed70164907e5d (diff)
downloadaudio-io-d35f10bcf7df8f242062beb7e6e2462ef81f9807.tar.gz
audio-io-d35f10bcf7df8f242062beb7e6e2462ef81f9807.tar.bz2
audio-io-d35f10bcf7df8f242062beb7e6e2462ef81f9807.zip
2.0 init
-rwxr-xr-x[-rw-r--r--]CMakeLists.txt0
-rwxr-xr-xTC/_export_env.sh8
-rwxr-xr-xTC/_export_target_env.sh7
-rwxr-xr-xTC/build.sh16
-rwxr-xr-xTC/clean.sh11
-rw-r--r--TC/config2
-rwxr-xr-xTC/execute.sh15
-rw-r--r--TC/media_samsung.mp3bin0 -> 1941924 bytes
-rwxr-xr-xTC/testcase/Makefile25
-rw-r--r--TC/testcase/tslist2
-rw-r--r--TC/testcase/utc_media_audio_input.c307
-rw-r--r--TC/testcase/utc_media_audio_output.c377
-rwxr-xr-xTC/tet_scen7
-rw-r--r--TC/tetbuild.cfg5
-rw-r--r--TC/tetclean.cfg5
-rw-r--r--TC/tetexec.cfg5
-rw-r--r--debian/changelog80
-rw-r--r--[-rwxr-xr-x]include/audio_io.h61
-rw-r--r--packaging/capi-media-audio-io.spec5
-rw-r--r--src/audio_io.c94
20 files changed, 1007 insertions, 25 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b018af6..b018af6 100644..100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
diff --git a/TC/_export_env.sh b/TC/_export_env.sh
new file mode 100755
index 0000000..72a11ec
--- /dev/null
+++ b/TC/_export_env.sh
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+. ./config
+export TET_INSTALL_PATH=$TET_INSTALL_HOST_PATH # tetware root path
+export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target # tetware target path
+export PATH=$TET_TARGET_PATH/bin:$PATH
+export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH
+export TET_ROOT=$TET_TARGET_PATH
diff --git a/TC/_export_target_env.sh b/TC/_export_target_env.sh
new file mode 100755
index 0000000..5ddaa53
--- /dev/null
+++ b/TC/_export_target_env.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+. ./config
+export TET_INSTALL_PATH=$TET_INSTALL_TARGET_PATH # path to path
+export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target
+export PATH=$TET_TARGET_PATH/bin:$PATH
+export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH
+export TET_ROOT=$TET_TARGET_PATH
diff --git a/TC/build.sh b/TC/build.sh
new file mode 100755
index 0000000..72aad6c
--- /dev/null
+++ b/TC/build.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+. ./_export_env.sh # setting environment variables
+
+export TET_SUITE_ROOT=`pwd`
+FILE_NAME_EXTENSION=`date +%s`
+
+RESULT_DIR=results
+HTML_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.html
+JOURNAL_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.journal
+
+mkdir -p $RESULT_DIR
+
+tcc -c -p ./
+tcc -b -j $JOURNAL_RESULT -p ./
+grw -c 7 -f chtml -o $HTML_RESULT $JOURNAL_RESULT
diff --git a/TC/clean.sh b/TC/clean.sh
new file mode 100755
index 0000000..29743e0
--- /dev/null
+++ b/TC/clean.sh
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+. ./_export_env.sh # setting environment variables
+
+export TET_SUITE_ROOT=`pwd`
+RESULT_DIR=results
+
+tcc -c -p ./ # executing tcc, with clean option (-c)
+rm -r $RESULT_DIR
+rm -r tet_tmp_dir
+rm testcase/tet_captured
diff --git a/TC/config b/TC/config
new file mode 100644
index 0000000..04684f0
--- /dev/null
+++ b/TC/config
@@ -0,0 +1,2 @@
+TET_INSTALL_HOST_PATH=/home/rookiejava/dts_tool/TETware
+TET_INSTALL_TARGET_PATH=/mnt/nfs/dts_tool/TETware
diff --git a/TC/execute.sh b/TC/execute.sh
new file mode 100755
index 0000000..a4f6095
--- /dev/null
+++ b/TC/execute.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+. ./_export_target_env.sh # setting environment variables
+
+export TET_SUITE_ROOT=`pwd`
+FILE_NAME_EXTENSION=`date +%s`
+
+RESULT_DIR=results
+HTML_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.html
+JOURNAL_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.journal
+
+mkdir -p $RESULT_DIR
+
+tcc -e -j $JOURNAL_RESULT -p ./
+grw -c 3 -f chtml -o $HTML_RESULT $JOURNAL_RESULT
diff --git a/TC/media_samsung.mp3 b/TC/media_samsung.mp3
new file mode 100644
index 0000000..d871c5d
--- /dev/null
+++ b/TC/media_samsung.mp3
Binary files differ
diff --git a/TC/testcase/Makefile b/TC/testcase/Makefile
new file mode 100755
index 0000000..04ee11e
--- /dev/null
+++ b/TC/testcase/Makefile
@@ -0,0 +1,25 @@
+CC ?= gcc
+
+C_FILES = $(shell ls *.c)
+
+PKGS = capi-media-audio-io dlog glib-2.0
+
+LDFLAGS = `pkg-config --libs $(PKGS)`
+LDFLAGS += $(TET_ROOT)/lib/tet3/tcm_s.o
+LDFLAGS += -L$(TET_ROOT)/lib/tet3 -ltcm_s
+LDFLAGS += -L$(TET_ROOT)/lib/tet3 -lapi_s
+
+CFLAGS = -I. `pkg-config --cflags $(PKGS)`
+CFLAGS += -I$(TET_ROOT)/inc/tet3
+CFLAGS += -Wall
+
+#TARGETS = $(C_FILES:%.c=tc-%)
+TCS := $(shell ls -1 *.c | cut -d. -f1)
+
+all: $(TCS)
+
+%: %.c
+ $(CC) -o $@ $< $(CFLAGS) $(LDFLAGS)
+
+clean:
+ rm -f $(TCS)
diff --git a/TC/testcase/tslist b/TC/testcase/tslist
new file mode 100644
index 0000000..c4f5399
--- /dev/null
+++ b/TC/testcase/tslist
@@ -0,0 +1,2 @@
+/testcase/utc_media_audio_input
+/testcase/utc_media_audio_output
diff --git a/TC/testcase/utc_media_audio_input.c b/TC/testcase/utc_media_audio_input.c
new file mode 100644
index 0000000..4755dbc
--- /dev/null
+++ b/TC/testcase/utc_media_audio_input.c
@@ -0,0 +1,307 @@
+/*
+* 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 <tet_api.h>
+#include <media/audio_io.h>
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_media_audio_in_create_p(void);
+static void utc_media_audio_in_create_n(void);
+static void utc_media_audio_in_destroy_p(void);
+static void utc_media_audio_in_destroy_n(void);
+static void utc_media_audio_in_read_p(void);
+static void utc_media_audio_in_read_n(void);
+static void utc_media_audio_in_get_buffer_size_p(void);
+static void utc_media_audio_in_get_buffer_size_n(void);
+static void utc_media_audio_in_get_sample_rate_p(void);
+static void utc_media_audio_in_get_sample_rate_n(void);
+static void utc_media_audio_in_get_channel_p(void);
+static void utc_media_audio_in_get_channel_n(void);
+static void utc_media_audio_in_get_sample_type_p(void);
+static void utc_media_audio_in_get_sample_type_n(void);
+
+
+struct tet_testlist tet_testlist[] = {
+ { utc_media_audio_in_create_p , POSITIVE_TC_IDX },
+ { utc_media_audio_in_create_n , NEGATIVE_TC_IDX },
+ { utc_media_audio_in_destroy_p, POSITIVE_TC_IDX },
+ { utc_media_audio_in_destroy_n, NEGATIVE_TC_IDX },
+ { utc_media_audio_in_read_p, POSITIVE_TC_IDX },
+ { utc_media_audio_in_read_n, NEGATIVE_TC_IDX },
+ { utc_media_audio_in_get_buffer_size_p, POSITIVE_TC_IDX },
+ { utc_media_audio_in_get_buffer_size_n, NEGATIVE_TC_IDX },
+ { utc_media_audio_in_get_sample_rate_p, POSITIVE_TC_IDX },
+ { utc_media_audio_in_get_sample_rate_n, NEGATIVE_TC_IDX },
+ { utc_media_audio_in_get_channel_p , POSITIVE_TC_IDX },
+ { utc_media_audio_in_get_channel_n, NEGATIVE_TC_IDX },
+ { utc_media_audio_in_get_sample_type_p, POSITIVE_TC_IDX },
+ { utc_media_audio_in_get_sample_type_n, NEGATIVE_TC_IDX },
+ { NULL, 0 },
+};
+
+static void startup(void)
+{
+ /* start of TC */
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+static void utc_media_audio_in_create_p(void)
+{
+ char* api_name = "audio_in_create";
+ int ret;
+ audio_in_h input;
+ if ((ret = audio_in_create(44100, AUDIO_CHANNEL_MONO ,AUDIO_SAMPLE_TYPE_S16_LE , &input)) == AUDIO_IO_ERROR_NONE)
+ {
+ audio_in_destroy(input);
+ dts_pass(api_name);
+ }
+ dts_message(api_name, "Call log: %d", ret);
+ dts_fail(api_name);
+}
+
+static void utc_media_audio_in_create_n(void)
+{
+ char* api_name = "audio_in_create";
+ int ret;
+ audio_in_h input;
+ if ((ret = audio_in_create(45100, AUDIO_CHANNEL_MONO ,AUDIO_SAMPLE_TYPE_S16_LE, &input)) != AUDIO_IO_ERROR_NONE)
+ {
+ dts_pass(api_name);
+ }
+ dts_message(api_name, "Call log: %d", ret);
+ dts_fail(api_name);
+}
+
+static void utc_media_audio_in_destroy_p(void)
+{
+ char* api_name = "audio_in_destroy";
+ int ret;
+ audio_in_h input;
+ if ((ret = audio_in_create(44100, AUDIO_CHANNEL_MONO ,AUDIO_SAMPLE_TYPE_S16_LE, &input)) == AUDIO_IO_ERROR_NONE)
+ {
+ if ((ret = audio_in_destroy(input)) == AUDIO_IO_ERROR_NONE)
+ {
+ dts_pass(api_name);
+ }
+ }
+ dts_message(api_name, "Call log: %d", ret);
+ dts_fail(api_name);
+}
+
+static void utc_media_audio_in_destroy_n(void)
+{
+ char* api_name = "audio_in_destroy";
+ int ret;
+ if ((ret = audio_in_destroy(NULL)) != AUDIO_IO_ERROR_NONE)
+ {
+ dts_pass(api_name);
+ }
+ dts_message(api_name, "Call log: %d", ret);
+ dts_fail(api_name);
+}
+
+static void utc_media_audio_in_read_p(void)
+{
+ char* api_name = "audio_in_read";
+ int ret, size;
+ audio_in_h input;
+ if ((ret = audio_in_create(44100, AUDIO_CHANNEL_MONO ,AUDIO_SAMPLE_TYPE_S16_LE, &input)) == AUDIO_IO_ERROR_NONE)
+ {
+ audio_in_prepare(input);
+ if ((ret = audio_in_get_buffer_size(input, &size)) == AUDIO_IO_ERROR_NONE)
+ {
+ char *buffer = NULL;
+ buffer = alloca(size);
+ if ((ret = audio_in_read(input, (void*)buffer, size)) > AUDIO_IO_ERROR_NONE)
+ {
+ audio_in_destroy(input);
+ dts_pass(api_name);
+ }
+ }
+ audio_in_destroy(input);
+ }
+ dts_message(api_name, "Call log: %d", ret);
+ dts_fail(api_name);
+}
+
+static void utc_media_audio_in_read_n(void)
+{
+ char* api_name = "audio_in_read";
+ int ret, size;
+ audio_in_h input;
+ if ((ret = audio_in_create(44100, AUDIO_CHANNEL_MONO ,AUDIO_SAMPLE_TYPE_S16_LE, &input)) == AUDIO_IO_ERROR_NONE)
+ {
+ if ((ret = audio_in_get_buffer_size(input, &size)) == AUDIO_IO_ERROR_NONE)
+ {
+ char *buffer = NULL;
+ buffer = alloca(size);
+ if ((ret = audio_in_read(input, (void*)buffer, 0)) == AUDIO_IO_ERROR_NONE)
+ {
+ audio_in_destroy(input);
+ dts_pass(api_name);
+ }
+ }
+ audio_in_destroy(input);
+ }
+ dts_message(api_name, "Call log: %d", ret);
+ dts_fail(api_name);
+}
+
+static void utc_media_audio_in_get_buffer_size_p(void)
+{
+ char* api_name = "audio_in_get_buffer_size";
+ int ret, size;
+ audio_in_h input;
+ if ((ret = audio_in_create(44100, AUDIO_CHANNEL_MONO ,AUDIO_SAMPLE_TYPE_S16_LE , &input)) == AUDIO_IO_ERROR_NONE)
+ {
+ if ((ret = audio_in_get_buffer_size(input, &size)) == AUDIO_IO_ERROR_NONE)
+ {
+ audio_in_destroy(input);
+ dts_pass(api_name);
+ }
+ audio_in_destroy(input);
+ }
+ dts_message(api_name, "Call log: %d", ret);
+ dts_fail(api_name);
+}
+
+static void utc_media_audio_in_get_buffer_size_n(void)
+{
+ char* api_name = "audio_in_get_buffer_size";
+ int ret, size;
+ audio_in_h input;
+ if ((ret = audio_in_create(45100, AUDIO_CHANNEL_MONO ,AUDIO_SAMPLE_TYPE_S16_LE , &input)) != AUDIO_IO_ERROR_NONE)
+ {
+ if ((ret = audio_in_get_buffer_size(input, &size)) != AUDIO_IO_ERROR_NONE)
+ {
+ dts_pass(api_name);
+ }
+ }
+ dts_message(api_name, "Call log: %d", ret);
+ dts_fail(api_name);
+}
+
+static void utc_media_audio_in_get_sample_rate_p(void)
+{
+ char* api_name = "audio_in_get_sample_rate";
+ int ret;
+ audio_in_h input;
+ if ((ret = audio_in_create(44100, AUDIO_CHANNEL_MONO ,AUDIO_SAMPLE_TYPE_S16_LE , &input)) == AUDIO_IO_ERROR_NONE)
+ {
+ int sample_rate;
+ if ((ret = audio_in_get_sample_rate(input, &sample_rate)) == AUDIO_IO_ERROR_NONE)
+ {
+ audio_in_destroy(input);
+ dts_pass(api_name);
+ }
+ audio_in_destroy(input);
+ }
+ dts_message(api_name, "Call log: %d", ret);
+ dts_fail(api_name);
+}
+
+static void utc_media_audio_in_get_sample_rate_n(void)
+{
+ char* api_name = "audio_in_get_sample_rate";
+ int ret, sample_rate;
+ audio_in_h input = NULL;
+ if ((ret = audio_in_get_sample_rate(input, &sample_rate)) != AUDIO_IO_ERROR_NONE)
+ {
+ dts_pass(api_name);
+ }
+ dts_message(api_name, "Call log: %d", ret);
+ dts_fail(api_name);
+}
+
+static void utc_media_audio_in_get_channel_p(void)
+{
+ char* api_name = "audio_in_get_channel";
+ int ret;
+ audio_in_h input;
+ if ((ret = audio_in_create(44100, AUDIO_CHANNEL_MONO ,AUDIO_SAMPLE_TYPE_S16_LE , &input)) == AUDIO_IO_ERROR_NONE)
+ {
+ audio_channel_e channel;
+ if ((ret = audio_in_get_channel(input, &channel)) == AUDIO_IO_ERROR_NONE)
+ {
+ audio_in_destroy(input);
+ dts_pass(api_name);
+ }
+ audio_in_destroy(input);
+ }
+ dts_message(api_name, "Call log: %d", ret);
+ dts_fail(api_name);
+}
+
+static void utc_media_audio_in_get_channel_n(void)
+{
+ char* api_name = "audio_in_get_channel";
+ int ret;
+ audio_channel_e channel;
+ audio_in_h input = NULL;
+ if ((ret = audio_in_get_channel(input, &channel)) != AUDIO_IO_ERROR_NONE)
+ {
+ dts_pass(api_name);
+ }
+ dts_message(api_name, "Call log: %d", ret);
+ dts_fail(api_name);
+}
+
+static void utc_media_audio_in_get_sample_type_p(void)
+{
+ char* api_name = "audio_in_get_sample_type";
+ int ret;
+ audio_in_h input;
+ if ((ret = audio_in_create(44100, AUDIO_CHANNEL_MONO ,AUDIO_SAMPLE_TYPE_S16_LE , &input)) == AUDIO_IO_ERROR_NONE)
+ {
+ audio_sample_type_e type;
+ if ((ret = audio_in_get_sample_type(input, &type)) == AUDIO_IO_ERROR_NONE)
+ {
+ audio_in_destroy(input);
+ dts_pass(api_name);
+ }
+ audio_in_destroy(input);
+ }
+ dts_message(api_name, "Call log: %d", ret);
+ dts_fail(api_name);
+}
+
+static void utc_media_audio_in_get_sample_type_n(void)
+{
+ char* api_name = "audio_in_get_sample_type";
+ int ret;
+ audio_sample_type_e type;
+ audio_in_h input = NULL;
+ if ((ret = audio_in_get_sample_type(input, &type)) != AUDIO_IO_ERROR_NONE)
+ {
+ dts_pass(api_name);
+ }
+ dts_message(api_name, "Call log: %d", ret);
+ dts_fail(api_name);
+}
diff --git a/TC/testcase/utc_media_audio_output.c b/TC/testcase/utc_media_audio_output.c
new file mode 100644
index 0000000..7c924cf
--- /dev/null
+++ b/TC/testcase/utc_media_audio_output.c
@@ -0,0 +1,377 @@
+/*
+* 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 <tet_api.h>
+#include <media/audio_io.h>
+
+#define AUDIO_FILE "/mnt/nfs/workspace/capi/media/audio-io/TC/media_samsung.mp3"
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_media_audio_out_create_p(void);
+static void utc_media_audio_out_create_n(void);
+static void utc_media_audio_out_destroy_p(void);
+static void utc_media_audio_out_destroy_n(void);
+static void utc_media_audio_out_write_p(void);
+static void utc_media_audio_out_write_n(void);
+static void utc_media_audio_out_get_buffer_size_p(void);
+static void utc_media_audio_out_get_buffer_size_n(void);
+static void utc_media_audio_out_get_sample_rate_p(void);
+static void utc_media_audio_out_get_sample_rate_n(void);
+static void utc_media_audio_out_get_channel_p(void);
+static void utc_media_audio_out_get_channel_n(void);
+static void utc_media_audio_out_get_sample_type_p(void);
+static void utc_media_audio_out_get_sample_type_n(void);
+static void utc_media_audio_out_get_sound_type_p(void);
+static void utc_media_audio_out_get_sound_type_n(void);
+
+
+struct tet_testlist tet_testlist[] = {
+ { utc_media_audio_out_create_p , POSITIVE_TC_IDX },
+ { utc_media_audio_out_create_n , NEGATIVE_TC_IDX },
+ { utc_media_audio_out_destroy_p, POSITIVE_TC_IDX },
+ { utc_media_audio_out_destroy_n, NEGATIVE_TC_IDX },
+ { utc_media_audio_out_write_p, POSITIVE_TC_IDX },
+ { utc_media_audio_out_write_n, NEGATIVE_TC_IDX },
+ { utc_media_audio_out_get_buffer_size_p, POSITIVE_TC_IDX },
+ { utc_media_audio_out_get_buffer_size_n, NEGATIVE_TC_IDX },
+ { utc_media_audio_out_get_sample_rate_p, POSITIVE_TC_IDX },
+ { utc_media_audio_out_get_sample_rate_n, NEGATIVE_TC_IDX },
+ { utc_media_audio_out_get_channel_p , POSITIVE_TC_IDX },
+ { utc_media_audio_out_get_channel_n, NEGATIVE_TC_IDX },
+ { utc_media_audio_out_get_sample_type_p, POSITIVE_TC_IDX },
+ { utc_media_audio_out_get_sample_type_n, NEGATIVE_TC_IDX },
+ { utc_media_audio_out_get_sound_type_p, POSITIVE_TC_IDX },
+ { utc_media_audio_out_get_sound_type_n, NEGATIVE_TC_IDX },
+ { NULL, 0 },
+};
+
+static void startup(void)
+{
+ /* start of TC */
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+static void utc_media_audio_out_create_p(void)
+{
+ char* api_name = "audio_out_create";
+ int ret;
+ audio_out_h output;
+ if ((ret = audio_out_create(44100, AUDIO_CHANNEL_STEREO ,AUDIO_SAMPLE_TYPE_S16_LE , SOUND_TYPE_SYSTEM, &output)) == AUDIO_IO_ERROR_NONE)
+ {
+ audio_out_destroy(output);
+ dts_pass(api_name);
+ }
+ dts_message(api_name, "Call log: %d", ret);
+ dts_fail(api_name);
+}
+
+static void utc_media_audio_out_create_n(void)
+{
+ char* api_name = "audio_out_create";
+ int ret;
+ audio_out_h output;
+ if ((ret = audio_out_create(45100, AUDIO_CHANNEL_STEREO ,AUDIO_SAMPLE_TYPE_S16_LE, SOUND_TYPE_SYSTEM , &output)) != AUDIO_IO_ERROR_NONE)
+ {
+ dts_pass(api_name);
+ }
+ dts_message(api_name, "Call log: %d", ret);
+ dts_fail(api_name);
+}
+
+static void utc_media_audio_out_destroy_p(void)
+{
+ char* api_name = "audio_out_destroy";
+ int ret;
+ audio_out_h output;
+ if ((ret = audio_out_create(44100, AUDIO_CHANNEL_STEREO ,AUDIO_SAMPLE_TYPE_S16_LE, SOUND_TYPE_SYSTEM , &output)) == AUDIO_IO_ERROR_NONE)
+ {
+ if ((ret = audio_out_destroy(output)) == AUDIO_IO_ERROR_NONE)
+ {
+ dts_pass(api_name);
+ }
+ }
+ dts_message(api_name, "Call log: %d", ret);
+ dts_fail(api_name);
+}
+
+static void utc_media_audio_out_destroy_n(void)
+{
+ char* api_name = "audio_out_destroy";
+ int ret;
+ if ((ret = audio_out_destroy(NULL)) != AUDIO_IO_ERROR_NONE)
+ {
+ dts_pass(api_name);
+ }
+ dts_message(api_name, "Call log: %d", ret);
+ dts_fail(api_name);
+}
+
+static void utc_media_audio_out_write_p(void)
+{
+ char* api_name = "audio_out_write";
+ int ret, size;
+ audio_out_h output;
+ if ((ret = audio_out_create(44100, AUDIO_CHANNEL_STEREO ,AUDIO_SAMPLE_TYPE_S16_LE, SOUND_TYPE_SYSTEM , &output)) == AUDIO_IO_ERROR_NONE)
+ {
+ if ((ret = audio_out_get_buffer_size(output, &size)) == AUDIO_IO_ERROR_NONE)
+ {
+ FILE *fp = NULL;
+ fp = fopen(AUDIO_FILE,"r");
+ if(fp != NULL)
+ {
+ int read;
+ char *buffer = NULL;
+ buffer = alloca(size);
+ if((read = fread(buffer, size, sizeof(char), fp)) > 0 )
+ {
+ audio_out_prepare(output);
+ if ((ret = audio_out_write(output, (void*)buffer, read)) > AUDIO_IO_ERROR_NONE)
+ {
+ fclose(fp);
+ audio_out_destroy(output);
+ dts_pass(api_name);
+ }
+ }
+ else
+ {
+ ret = AUDIO_IO_ERROR_INVALID_BUFFER;
+ }
+ fclose(fp);
+ }
+ else
+ {
+ ret = AUDIO_IO_ERROR_INVALID_BUFFER ;
+ }
+ }
+ audio_out_destroy(output);
+ }
+ dts_message(api_name, "Call log: %d", ret);
+ dts_fail(api_name);
+}
+
+static void utc_media_audio_out_write_n(void)
+{
+ char* api_name = "audio_out_write";
+ int ret, size;
+ audio_out_h output;
+ if ((ret = audio_out_create(44100, AUDIO_CHANNEL_STEREO ,AUDIO_SAMPLE_TYPE_S16_LE, SOUND_TYPE_SYSTEM , &output)) == AUDIO_IO_ERROR_NONE)
+ {
+ if ((ret = audio_out_get_buffer_size(output, &size)) == AUDIO_IO_ERROR_NONE)
+ {
+ FILE *fp = NULL;
+ fp = fopen(AUDIO_FILE,"r");
+ if(fp != NULL)
+ {
+ char *buffer = NULL;
+ int read;
+ audio_out_prepare(output);
+ if ((ret = audio_out_write(output, (void*)buffer, read)) != AUDIO_IO_ERROR_NONE)
+ {
+ fclose(fp);
+ audio_out_destroy(output);
+ dts_pass(api_name);
+ }
+ fclose(fp);
+ }
+ else
+ {
+ ret = AUDIO_IO_ERROR_INVALID_BUFFER ;
+ }
+ }
+ audio_out_destroy(output);
+ }
+ dts_message(api_name, "Call log: %d", ret);
+ dts_fail(api_name);
+}
+
+static void utc_media_audio_out_get_buffer_size_p(void)
+{
+ char* api_name = "audio_out_get_buffer_size";
+ int ret, size;
+ audio_out_h output;
+ if ((ret = audio_out_create(44100, AUDIO_CHANNEL_STEREO ,AUDIO_SAMPLE_TYPE_S16_LE , SOUND_TYPE_SYSTEM, &output)) == AUDIO_IO_ERROR_NONE)
+ {
+ if ((ret = audio_out_get_buffer_size(output, &size)) == AUDIO_IO_ERROR_NONE)
+ {
+ audio_out_destroy(output);
+ dts_pass(api_name);
+ }
+ audio_out_destroy(output);
+ }
+ dts_message(api_name, "Call log: %d", ret);
+ dts_fail(api_name);
+}
+
+static void utc_media_audio_out_get_buffer_size_n(void)
+{
+ char* api_name = "audio_out_get_buffer_size";
+ int ret, size;
+ audio_out_h output;
+ if ((ret = audio_out_create(45100, AUDIO_CHANNEL_STEREO ,AUDIO_SAMPLE_TYPE_S16_LE , SOUND_TYPE_SYSTEM, &output)) != AUDIO_IO_ERROR_NONE)
+ {
+ if ((ret = audio_out_get_buffer_size(output, &size)) != AUDIO_IO_ERROR_NONE)
+ {
+ dts_pass(api_name);
+ }
+ }
+ dts_message(api_name, "Call log: %d", ret);
+ dts_fail(api_name);
+}
+
+static void utc_media_audio_out_get_sample_rate_p(void)
+{
+ char* api_name = "audio_out_get_sample_rate";
+ int ret;
+ audio_out_h output;
+ if ((ret = audio_out_create(44100, AUDIO_CHANNEL_STEREO ,AUDIO_SAMPLE_TYPE_S16_LE , SOUND_TYPE_SYSTEM , &output)) == AUDIO_IO_ERROR_NONE)
+ {
+ int sample_rate;
+ if ((ret = audio_out_get_sample_rate(output, &sample_rate)) == AUDIO_IO_ERROR_NONE)
+ {
+ audio_out_destroy(output);
+ dts_pass(api_name);
+ }
+ audio_out_destroy(output);
+ }
+ dts_message(api_name, "Call log: %d", ret);
+ dts_fail(api_name);
+}
+
+static void utc_media_audio_out_get_sample_rate_n(void)
+{
+ char* api_name = "audio_in_get_sample_rate";
+ int ret, sample_rate;
+ audio_in_h input = NULL;
+ if ((ret = audio_in_get_sample_rate(input, &sample_rate)) != AUDIO_IO_ERROR_NONE)
+ {
+ dts_pass(api_name);
+ }
+ dts_message(api_name, "Call log: %d", ret);
+ dts_fail(api_name);
+}
+
+static void utc_media_audio_out_get_channel_p(void)
+{
+ char* api_name = "audio_out_get_channel";
+ int ret;
+ audio_out_h output;
+ if ((ret = audio_out_create(44100, AUDIO_CHANNEL_STEREO ,AUDIO_SAMPLE_TYPE_S16_LE , SOUND_TYPE_SYSTEM , &output)) == AUDIO_IO_ERROR_NONE)
+ {
+ audio_channel_e channel;
+ if ((ret = audio_out_get_channel(output, &channel)) == AUDIO_IO_ERROR_NONE)
+ {
+ audio_out_destroy(output);
+ dts_pass(api_name);
+ }
+ audio_out_destroy(output);
+ }
+ dts_message(api_name, "Call log: %d", ret);
+ dts_fail(api_name);
+}
+
+static void utc_media_audio_out_get_channel_n(void)
+{
+ char* api_name = "audio_out_get_channel";
+ int ret;
+ audio_channel_e channel;
+ audio_out_h output = NULL;
+ if ((ret = audio_out_get_channel(output, &channel)) != AUDIO_IO_ERROR_NONE)
+ {
+ dts_pass(api_name);
+ }
+ dts_message(api_name, "Call log: %d", ret);
+ dts_fail(api_name);
+}
+
+static void utc_media_audio_out_get_sample_type_p(void)
+{
+ char* api_name = "audio_out_get_sample_type";
+ int ret;
+ audio_out_h output;
+ if ((ret = audio_out_create(44100, AUDIO_CHANNEL_STEREO ,AUDIO_SAMPLE_TYPE_S16_LE , SOUND_TYPE_SYSTEM , &output)) == AUDIO_IO_ERROR_NONE)
+ {
+ audio_sample_type_e type;
+ if ((ret = audio_out_get_sample_type(output, &type)) == AUDIO_IO_ERROR_NONE)
+ {
+ audio_out_destroy(output);
+ dts_pass(api_name);
+ }
+ audio_out_destroy(output);
+ }
+ dts_message(api_name, "Call log: %d", ret);
+ dts_fail(api_name);
+}
+
+static void utc_media_audio_out_get_sample_type_n(void)
+{
+ char* api_name = "audio_out_get_sample_type";
+ int ret;
+ audio_sample_type_e type;
+ audio_out_h output = NULL;
+ if ((ret = audio_out_get_sample_type(output, &type)) != AUDIO_IO_ERROR_NONE)
+ {
+ dts_pass(api_name);
+ }
+ dts_message(api_name, "Call log: %d", ret);
+ dts_fail(api_name);
+}
+
+static void utc_media_audio_out_get_sound_type_p(void)
+{
+ char* api_name = "audio_out_get_sound_type";
+ int ret;
+ audio_out_h output;
+ if ((ret = audio_out_create(44100, AUDIO_CHANNEL_STEREO ,AUDIO_SAMPLE_TYPE_S16_LE , SOUND_TYPE_SYSTEM , &output)) == AUDIO_IO_ERROR_NONE)
+ {
+ sound_type_e type;
+ if ((ret = audio_out_get_sound_type(output, &type)) == AUDIO_IO_ERROR_NONE)
+ {
+ audio_out_destroy(output);
+ dts_pass(api_name);
+ }
+ audio_out_destroy(output);
+ }
+ dts_message(api_name, "Call log: %d", ret);
+ dts_fail(api_name);
+}
+
+static void utc_media_audio_out_get_sound_type_n(void)
+{
+ char* api_name = "audio_out_get_sound_type";
+ int ret;
+ audio_sample_type_e type;
+ audio_out_h output = NULL;
+ if ((ret = audio_out_get_sample_type(output, &type)) != AUDIO_IO_ERROR_NONE)
+ {
+ dts_pass(api_name);
+ }
+ dts_message(api_name, "Call log: %d", ret);
+ dts_fail(api_name);
+}
diff --git a/TC/tet_scen b/TC/tet_scen
new file mode 100755
index 0000000..03f029a
--- /dev/null
+++ b/TC/tet_scen
@@ -0,0 +1,7 @@
+all
+ ^TEST
+##### Scenarios for TEST #####
+
+# Test scenario
+TEST
+ :include:/testcase/tslist
diff --git a/TC/tetbuild.cfg b/TC/tetbuild.cfg
new file mode 100644
index 0000000..f7eda55
--- /dev/null
+++ b/TC/tetbuild.cfg
@@ -0,0 +1,5 @@
+TET_OUTPUT_CAPTURE=True # capture option for build operation checking
+TET_BUILD_TOOL=make # build with using make command
+TET_BUILD_FILE=-f Makefile # execution file (Makefile) for build
+TET_API_COMPLIANT=True # use TET API in Test Case ?
+TET_PASS_TC_NAME=True # report passed TC name in Journal file?
diff --git a/TC/tetclean.cfg b/TC/tetclean.cfg
new file mode 100644
index 0000000..02d7030
--- /dev/null
+++ b/TC/tetclean.cfg
@@ -0,0 +1,5 @@
+TET_OUTPUT_CAPTURE=True # capture option
+TET_CLEAN_TOOL= make clean # clean tool
+TET_CLEAN_FILE= Makefile # file for clean
+TET_API_COMPLIANT=True # TET API useage
+TET_PASS_TC_NAME=True # showing name , passed TC
diff --git a/TC/tetexec.cfg b/TC/tetexec.cfg
new file mode 100644
index 0000000..ef3e452
--- /dev/null
+++ b/TC/tetexec.cfg
@@ -0,0 +1,5 @@
+TET_OUTPUT_CAPTURE=True # capturing execution or not
+TET_EXEC_TOOL= # ex) exec : execution tool set up/ Optional
+TET_EXEC_FILE= # ex) exectool : execution file/ Optional
+TET_API_COMPLIANT=True # Test case or Tool usesTET API?
+TET_PASS_TC_NAME=True # showing Passed TC name ?
diff --git a/debian/changelog b/debian/changelog
index d1f7c84..619eb9c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,17 +1,87 @@
+capi-media-audio-io (0.1.0-9) unstable; urgency=low
+
+ * Fix audio_in_read() bug.
+ * Git: slp-source.sec.samsung.net:slp/api/audio-io
+ * Tag: capi-media-audio-io_0.1.0-9
+
+ -- Kangho Hur <kangho.hur@samsung.com> Wed, 04 Jul 2012 13:30:46 +0900
+
+capi-media-audio-io (0.1.0-8) unstable; urgency=low
+
+ * Add the start/stop recording APIs
+ * Git: slp-source.sec.samsung.net:slp/api/audio-io
+ * Tag: capi-media-audio-io_0.1.0-8
+
+ -- Kangho Hur <kangho.hur@samsung.com> Thu, 28 Jun 2012 20:25:31 +0900
+
+capi-media-audio-io (0.1.0-7) unstable; urgency=low
+
+ * The valid sample rate range updated.
+ * Git: slp-source.sec.samsung.net:slp/api/audio-io
+ * Tag: capi-media-audio-io_0.1.0-7
+
+ -- Kangho Hur <kangho.hur@samsung.com> Thu, 10 May 2012 21:18:26 +0900
+
capi-media-audio-io (0.1.0-6) unstable; urgency=low
- * Use 'static' to local function which is limited to the current source file.
+ * Use 'static' to local function which is limited to the current source file.
+ * Git: slp-source.sec.samsung.net:slp/api/audio-io
+ * Tag: capi-media-audio-io_0.1.0-6
- -- Kangho Hur <kangho.hur@samsung.com> Tue, 21 Feb 2012 10:17:37 +0900
+ -- Kangho Hur <kangho.hur@samsung.com> Tue, 21 Feb 2012 10:07:56 +0900
capi-media-audio-io (0.1.0-5) unstable; urgency=low
* Apply the SOVERSION
+ * Git: slp-source.sec.samsung.net:slp/api/audio-io
+ * Tag: capi-media-audio-io_0.1.0-5
- -- Kangho Hur <kangho.hur@samsung.com> Tue, 14 Feb 2012 18:19:52 +0900
+ -- Kangho Hur <kangho.hur@samsung.com> Tue, 14 Feb 2012 17:11:01 +0900
capi-media-audio-io (0.1.0-4) unstable; urgency=low
- * Initial release.
+ * Changes the value of ERROR_NONE
+ * Git: slp-source.sec.samsung.net:slp/api/audio-io
+ * Tag: capi-media-audio-io_0.1.0-4
+
+ -- Kangho Hur <kangho.hur@samsung.com> Mon, 05 Dec 2011 11:26:36 +0900
+
+capi-media-audio-io (0.1.0-3) unstable; urgency=low
+
+ * Apply the Tizen
+ * Git: slp-source.sec.samsung.net:slp/api/audio-io
+ * Tag: capi-media-audio-io_0.1.0-3
+
+ -- Kangho Hur <kangho.hur@samsung.com> Wed, 23 Nov 2011 15:52:29 +0900
+
+capi-media-audio-io (0.1.0-2) unstable; urgency=low
+
+ * Apply the error messages
+ * Git: slp-source.sec.samsung.net:slp/api/audio-io
+ * Tag: capi-media-audio-io_0.1.0-2
+
+ -- Kangho Hur <kangho.hur@samsung.com> Fri, 07 Oct 2011 21:08:17 +0900
+
+capi-media-audio-io (0.1.0-1) unstable; urgency=low
+
+ * Alpha Release
+ * Git: slp-source.sec.samsung.net:slp/api/audio-io
+ * Tag: capi-media-audio-io_0.1.0-1
+
+ -- Kangho Hur <kangho.hur@samsung.com> Tue, 27 Sep 2011 19:44:18 +0900
+
+capi-media-audio-io (0.0.1-2) unstable; urgency=low
+
+ * Update API Description
+ * Git: slp-source.sec.samsung.net:slp/api/audio-io
+ * Tag: capi-media-audio-io_0.0.1-2
+
+ -- Kangho Hur <kangho.hur@samsung.com> Mon, 19 Sep 2011 17:46:51 +0900
+
+capi-media-audio-io (0.0.1-1) unstable; urgency=low
+
+ * Initial Upload
+ * Git: slp-source.sec.samsung.net:slp/api/audio-io
+ * Tag: capi-media-audio-io_0.0.1-1
- -- Kangho Hur <kangho.hur@samsung.com> Wed, 07 Dec 2011 12:50:57 +0900
+ -- Kangho Hur <kangho.hur@samsung.com> Thu, 04 Aug 2011 18:11:55 +0900
diff --git a/include/audio_io.h b/include/audio_io.h
index bd1511c..1aa7bab 100755..100644
--- a/include/audio_io.h
+++ b/include/audio_io.h
@@ -118,7 +118,7 @@ typedef enum{
*
* @remarks @a input must be release audio_in_destroy() by you.
*
- * @param[in] sample_rate The audio sample rate in 8000[Hz] ~ 44100[Hz]
+ * @param[in] sample_rate The audio sample rate in 8000[Hz] ~ 48000[Hz]
* @param[in] channel The audio channel type, mono, or stereo
* @param[in] type The type of audio sample (8- or 16-bit)
* @param[out] input An audio input handle will be created, if successful
@@ -151,7 +151,31 @@ int audio_in_destroy(audio_in_h input);
/**
- * @brief Starts reading and buffering the audio data from the device
+ * @brief Prepare reading audio in by starting buffering the audio data from the device
+ * @param[in] input The handle to the audio input
+ * @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_unprepare()
+ */
+int audio_in_prepare(audio_in_h input);
+
+
+
+/**
+ * @brief Unprepare reading audio in by stopping buffering the audio data from the device
+ * @param[in] input The handle to the audio input
+ * @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_prepare()
+ */
+int audio_in_unprepare(audio_in_h input);
+
+
+
+/**
+ * @brief Reads audio data from the audio input buffer
*
* @param[in] input The handle to the audio input
* @param[out] buffer The PCM buffer address
@@ -161,6 +185,8 @@ int audio_in_destroy(audio_in_h input);
* @retval #AUDIO_IO_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #AUDIO_IO_ERROR_INVALID_BUFFER Invalid buffer pointer
* @retval #AUDIO_IO_ERROR_SOUND_POLICY Sound policy error
+ * @retval #AUDIO_IO_ERROR_INVALID_OPERATION Invalid operation
+ * @pre audio_in_start_recording()
*/
int audio_in_read(audio_in_h input, void *buffer, unsigned int length);
@@ -174,7 +200,7 @@ int audio_in_read(audio_in_h input, void *buffer, unsigned int length);
* @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_read()
+ * @see audio_in_read()
*/
int audio_in_get_buffer_size(audio_in_h input, int *size);
@@ -184,7 +210,7 @@ int audio_in_get_buffer_size(audio_in_h input, int *size);
* @brief Gets the sample rate of the audio input data stream
*
* @param[in] input The handle to the audio input
- * @param[out] sample_rate The audio sample rate in Hertz (8000 ~ 44100)
+ * @param[out] sample_rate The audio sample rate in Hertz (8000 ~ 48000)
*
* @return 0 on success, otherwise a negative error value.
* @retval #AUDIO_IO_ERROR_NONE Successful
@@ -243,7 +269,7 @@ int audio_in_get_sample_type(audio_in_h input, audio_sample_type_e *type);
* @details This function is used for audio output initialization.
* @remarks @a output must be released audio_out_destroy() by you.
*
- * @param[in] sample_rate The audio sample rate in 8000[Hz] ~ 44100[Hz]
+ * @param[in] sample_rate The audio sample rate in 8000[Hz] ~ 48000[Hz]
* @param[in] channel The audio channel type, mono, or stereo
* @param[in] type The type of audio sample (8- or 16-bit)
* @param[in] sound_type The type of sound (#sound_type_e)
@@ -277,6 +303,29 @@ int audio_out_create(int sample_rate, audio_channel_e channel, audio_sample_type
*/
int audio_out_destroy(audio_out_h output);
+/**
+ * @brief Prepare playing audio out, this must be called before audio_out_write()
+ * @param[in] input The handle to the audio output
+ * @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_unprepare()
+ */
+int audio_out_prepare(audio_out_h output);
+
+
+
+/**
+ * @brief Unprepare playing audio out.
+ * @param[in] input The handle to the audio output
+ * @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_prepare()
+ */
+int audio_out_unprepare(audio_out_h output);
+
+
/**
@@ -314,7 +363,7 @@ int audio_out_get_buffer_size(audio_out_h output, int *size);
* @brief Gets the sample rate of audio output data stream
*
* @param[in] output The handle to the audio output
- * @param[out] sample_rate The audio sample rate in Hertz (8000 ~ 44100)
+ * @param[out] sample_rate The audio sample rate in Hertz (8000 ~ 48000)
*
* @return 0 on success, otherwise a negative error value.
* @retval #AUDIO_IO_ERROR_NONE Successful
diff --git a/packaging/capi-media-audio-io.spec b/packaging/capi-media-audio-io.spec
index 3a62bcb..973d1dd 100644
--- a/packaging/capi-media-audio-io.spec
+++ b/packaging/capi-media-audio-io.spec
@@ -1,9 +1,10 @@
+#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.1.0
-Release: 4
+Release: 10
Group: TO_BE/FILLED_IN
-License: Apache-2.0
+License: TO BE FILLED IN
Source0: %{name}-%{version}.tar.gz
BuildRequires: cmake
BuildRequires: pkgconfig(dlog)
diff --git a/src/audio_io.c b/src/audio_io.c
index 8b09340..97a54e1 100644
--- a/src/audio_io.c
+++ b/src/audio_io.c
@@ -83,9 +83,9 @@ static int __convert_error_code(int code, char *func_name)
static int __check_parameter(int sample_rate, audio_channel_e channel, audio_sample_type_e type)
{
- if(sample_rate<8000 || sample_rate > 44100)
+ if(sample_rate<8000 || sample_rate > 48000)
{
- LOGE("[%s] AUDIO_IO_ERROR_INVALID_PARAMETER(0x%08x) : Invalid sample rate (8000~44100Hz) : %d",__FUNCTION__, AUDIO_IO_ERROR_INVALID_PARAMETER,sample_rate);
+ LOGE("[%s] AUDIO_IO_ERROR_INVALID_PARAMETER(0x%08x) : Invalid sample rate (8000~48000Hz) : %d",__FUNCTION__, AUDIO_IO_ERROR_INVALID_PARAMETER,sample_rate);
return AUDIO_IO_ERROR_INVALID_PARAMETER;
}
if (channel < AUDIO_CHANNEL_MONO || channel > AUDIO_CHANNEL_STEREO)
@@ -151,22 +151,58 @@ int audio_in_destroy(audio_in_h input)
}
}
-int audio_in_read(audio_in_h input, void *buffer, unsigned int length )
+int audio_in_prepare(audio_in_h input)
{
AUDIO_IO_NULL_ARG_CHECK(input);
- AUDIO_IO_NULL_ARG_CHECK(buffer);
audio_in_s * handle = (audio_in_s *) input;
- int ret;
- ret = mm_sound_pcm_capture_read(handle->mm_handle, (void*) buffer, length);
- if(ret <0)
+ int ret = mm_sound_pcm_capture_start(handle->mm_handle);
+ if (ret != MM_ERROR_NONE)
+ {
+ return __convert_error_code(ret, (char*)__FUNCTION__);
+ }
+ else
+ return AUDIO_IO_ERROR_NONE;
+}
+
+int audio_in_unprepare(audio_in_h input)
+{
+ AUDIO_IO_NULL_ARG_CHECK(input);
+ audio_in_s * handle = (audio_in_s *) input;
+ int ret = mm_sound_pcm_capture_stop(handle->mm_handle);
+ if (ret != MM_ERROR_NONE)
{
return __convert_error_code(ret, (char*)__FUNCTION__);
}
else
+ return AUDIO_IO_ERROR_NONE;
+}
+
+int audio_in_read(audio_in_h input, void *buffer, unsigned int length )
+{
+ AUDIO_IO_NULL_ARG_CHECK(input);
+ AUDIO_IO_NULL_ARG_CHECK(buffer);
+ audio_in_s * handle = (audio_in_s *) input;
+ int ret;
+ int result;
+ ret = mm_sound_pcm_capture_read(handle->mm_handle, (void*) buffer, length);
+
+ if (ret >0)
{
LOGI("[%s] %d bytes read" ,__FUNCTION__, ret);
return ret;
}
+
+ switch(ret)
+ {
+ case MM_ERROR_SOUND_INVALID_STATE:
+ result = AUDIO_IO_ERROR_INVALID_OPERATION;
+ LOGE("[%s] (0x%08x) : Not recording started yet.",(char*)__FUNCTION__, AUDIO_IO_ERROR_INVALID_OPERATION);
+ break;
+ default:
+ result = __convert_error_code(ret, (char*)__FUNCTION__);
+ break;
+ }
+ return result;
}
int audio_in_get_buffer_size(audio_in_h input, int *size)
@@ -259,23 +295,57 @@ int audio_out_destroy(audio_out_h output)
}
}
+int audio_out_prepare(audio_out_h output)
+{
+ AUDIO_IO_NULL_ARG_CHECK(output);
+ audio_out_s * handle = (audio_out_s *) output;
+ int ret = mm_sound_pcm_play_start(handle->mm_handle);
+ if (ret != MM_ERROR_NONE)
+ {
+ return __convert_error_code(ret, (char*)__FUNCTION__);
+ }
+ else
+ return AUDIO_IO_ERROR_NONE;
+}
-int audio_out_write(audio_out_h output, void* buffer, unsigned int length)
+int audio_out_unprepare(audio_out_h output)
{
AUDIO_IO_NULL_ARG_CHECK(output);
- AUDIO_IO_NULL_ARG_CHECK(buffer);
audio_out_s * handle = (audio_out_s *) output;
- int ret;
- ret = mm_sound_pcm_play_write(handle->mm_handle, (void*) buffer, length);
- if(ret <0)
+ int ret = mm_sound_pcm_play_stop(handle->mm_handle);
+ if (ret != MM_ERROR_NONE)
{
return __convert_error_code(ret, (char*)__FUNCTION__);
}
else
+ return AUDIO_IO_ERROR_NONE;
+}
+
+
+
+int audio_out_write(audio_out_h output, void* buffer, unsigned int length)
+{
+ AUDIO_IO_NULL_ARG_CHECK(output);
+ AUDIO_IO_NULL_ARG_CHECK(buffer);
+ audio_out_s * handle = (audio_out_s *) output;
+ int ret;
+ ret = mm_sound_pcm_play_write(handle->mm_handle, (void*) buffer, length);
+ if (ret >0)
{
LOGI("[%s] %d bytes written" ,__FUNCTION__, ret);
return ret;
}
+ switch(ret)
+ {
+ case MM_ERROR_SOUND_INVALID_STATE:
+ ret = AUDIO_IO_ERROR_INVALID_OPERATION;
+ LOGE("[%s] (0x%08x) : Not playing started yet.",(char*)__FUNCTION__, AUDIO_IO_ERROR_INVALID_OPERATION);
+ break;
+ default:
+ ret = __convert_error_code(ret, (char*)__FUNCTION__);
+ break;
+ }
+ return ret;
}