summaryrefslogtreecommitdiff
authorZhenggang Luo <zhenggang.luo@amlogic.com>2015-03-16 07:07:58 (GMT)
committer Zhenggang Luo <zhenggang.luo@amlogic.com>2015-03-16 07:14:45 (GMT)
commita801bcf3a78e64eba87db8ca84bb8abca979280e (patch)
treee08b34c4b51ec32cf693ee024a12c601db2fb7ac
parent39a7c235ab6f04927119285322a305e07faaa620 (diff)
downloadaudio-a801bcf3a78e64eba87db8ca84bb8abca979280e.zip
audio-a801bcf3a78e64eba87db8ca84bb8abca979280e.tar.gz
audio-a801bcf3a78e64eba87db8ca84bb8abca979280e.tar.bz2
PD #102134: fix CTS_test testGetTimestamp failed issue;
Change-Id: Ic0f3ec5b6d31262d4efee42ff28f038d57121998
Diffstat
-rw-r--r--Android.mk11
-rwxr-xr-xaudio_hw.c25
2 files changed, 29 insertions, 7 deletions
diff --git a/Android.mk b/Android.mk
index 9b88943..7d05ad4 100644
--- a/Android.mk
+++ b/Android.mk
@@ -35,7 +35,7 @@ ifeq ($(strip $(BOARD_ALSA_AUDIO)),tiny)
system/media/audio_route/include
LOCAL_SHARED_LIBRARIES := \
liblog libcutils libtinyalsa \
- libaudioutils libdl libaudioroute
+ libaudioutils libdl libaudioroute libutils
LOCAL_MODULE_TAGS := optional
include $(BUILD_SHARED_LIBRARY)
@@ -51,7 +51,7 @@ ifeq ($(strip $(BOARD_ALSA_AUDIO)),tiny)
LOCAL_C_INCLUDES += \
external/tinyalsa/include \
system/media/audio_utils/include
- LOCAL_SHARED_LIBRARIES := liblog libcutils libtinyalsa libaudioutils
+ LOCAL_SHARED_LIBRARIES := liblog libcutils libtinyalsa libaudioutils libutils
LOCAL_MODULE_TAGS := optional
include $(BUILD_SHARED_LIBRARY)
@@ -68,7 +68,7 @@ ifeq ($(strip $(BOARD_ALSA_AUDIO)),tiny)
system/media/audio_effects/include \
system/media/audio_utils/include
- LOCAL_SHARED_LIBRARIES := liblog libcutils libtinyalsa libaudioutils
+ LOCAL_SHARED_LIBRARIES := liblog libcutils libtinyalsa libaudioutils libutils
LOCAL_MODULE_TAGS := optional
include $(BUILD_SHARED_LIBRARY)
@@ -86,7 +86,7 @@ include $(CLEAR_VARS)
external/tinyalsa/include \
system/media/audio_utils/include \
system/media/audio_effects/include
- LOCAL_SHARED_LIBRARIES := liblog libcutils libtinyalsa libaudioutils libdl
+ LOCAL_SHARED_LIBRARIES := liblog libcutils libtinyalsa libaudioutils libdl libutils
LOCAL_MODULE_TAGS := optional
endif
@@ -105,7 +105,8 @@ LOCAL_SHARED_LIBRARIES := \
libutils \
libmedia \
libbinder \
- libaudiopolicymanagerdefault
+ libaudiopolicymanagerdefault \
+ libutils
LOCAL_C_INCLUDES := \
external/tinyalsa/include \
diff --git a/audio_hw.c b/audio_hw.c
index 56fcc20..7e4bf40 100755
--- a/audio_hw.c
+++ b/audio_hw.c
@@ -45,6 +45,9 @@
#include <hardware/audio_effect.h>
#include <audio_effects/effect_aec.h>
#include <audio_route/audio_route.h>
+#include <time.h>
+#include <utils/Timers.h>
+
/* ALSA cards for AML */
#define CARD_AMLOGIC_BOARD 0
#define CARD_AMLOGIC_USB 1
@@ -133,6 +136,7 @@ struct aml_stream_out {
int write_threshold;
bool low_power;
uint32_t frame_count;
+ int fram_write_sum;
};
#define MAX_PREPROCESSORS 3 /* maximum one AGC + one NS + one AEC per input stream */
@@ -175,7 +179,6 @@ static int adev_set_voice_volume(struct audio_hw_device *dev, float volume);
static int do_input_standby(struct aml_stream_in *in);
static int do_output_standby(struct aml_stream_out *out);
static uint32_t out_get_sample_rate(const struct audio_stream *stream);
-
static int getprop_bool(const char * path)
{
char buf[PROPERTY_VALUE_MAX];
@@ -1088,6 +1091,7 @@ static ssize_t out_write(struct audio_stream_out *stream, const void* buffer,
#else
ret = pcm_write(out->pcm, in_buffer, out_frames * frame_size);
out->frame_count += out_frames;
+ out->fram_write_sum+=out_frames;
#endif
exit:
pthread_mutex_unlock(&out->lock);
@@ -1136,6 +1140,22 @@ static int out_get_next_write_timestamp(const struct audio_stream_out *stream,
return -EINVAL;
}
+//actually maybe it be not useful now except pass CTS_TEST:
+// run cts -c android.media.cts.AudioTrackTest -m testGetTimestamp
+static int out_get_presentation_position(const struct audio_stream_out *stream,uint64_t *frames, struct timespec *timestamp)
+{
+ struct aml_stream_out *out=(struct aml_stream_out *)stream;
+ if (frames != NULL)
+ *frames=out->fram_write_sum;
+ if (timestamp != NULL) {
+ //the timestame value got here does not match :
+ // System.nanoTime() located in android_5.0\cts\tests\tests\media\src\android\media\cts\AudioTrackTest.java\< public void testGetTimestamp() >
+ //why???!!
+ clock_gettime(CLOCK_REALTIME,timestamp);
+ }
+
+ return 0;
+}
static int get_next_buffer(struct resampler_buffer_provider *buffer_provider,
struct resampler_buffer* buffer);
static void release_buffer(struct resampler_buffer_provider *buffer_provider,
@@ -1873,13 +1893,14 @@ static int adev_open_output_stream(struct audio_hw_device *dev,
out->stream.write = out_write;
out->stream.get_render_position = out_get_render_position;
out->stream.get_next_write_timestamp = out_get_next_write_timestamp;
+ out->stream.get_presentation_position=out_get_presentation_position;
out->config = pcm_config_out;
out->dev = ladev;
out->standby = true;
output_standby = true;
out->frame_count = 0;
-
+ out->fram_write_sum=0;
/* FIXME: when we support multiple output devices, we will want to
* do the following:
* adev->devices &= ~AUDIO_DEVICE_OUT_ALL;