audio: audiohal rebase from android R [1/1]
PD#SWPL-53508
Problem:
audiohal rebase from android R
Solution:
audiohal rebase from android R
Verify:
yocto-ap222
Change-Id: I1870254e6da05e84789299789e8f46ea578c53eb
Signed-off-by: wei.du <wei.du@amlogic.com>
diff --git a/utils/SPDIFEncoderAD.cpp b/utils/SPDIFEncoderAD.cpp
old mode 100755
new mode 100644
index 84c7b24..3007ba2
--- a/utils/SPDIFEncoderAD.cpp
+++ b/utils/SPDIFEncoderAD.cpp
@@ -19,7 +19,7 @@
//#define LOG_NDEBUG 0
#define LOG_TAG "SPDIFEncoderAD"
#include <stdint.h>
-#include <cutils/log.h>
+#include <utils/Log.h>
#include <system/audio.h>
#include <audio_utils/spdif/SPDIFEncoder.h>
#include <tinyalsa/asoundlib.h>
@@ -62,14 +62,12 @@
memcpy((void *)iec61937_buffer, (const void*)buffer, actual_write_size);
else
return -1;
-#if 0
if (actual_write_size > 0) {
-#endif
outBufCurrentPos += actual_write_size;
mTotalBytes += actual_write_size;
ALOGV("%s() actual_write_size %zu outBufCurrentPos %zu\n", __FUNCTION__, actual_write_size, outBufCurrentPos);
#if 1
- if (aml_getprop_bool("media.audiohal.outdump")) {
+ if (aml_getprop_bool("vendor.media.audiohal.outdump")) {
FILE *fp1 = fopen("/data/audio_out/enc_output.spdif", "a+");
if (fp1) {
int flen = fwrite((char *)iec61937_buffer, 1, actual_write_size, fp1);
@@ -81,11 +79,9 @@
}
#endif
return actual_write_size;
-#if 0
}
else
return -1;
-#endif
}
/*
*@brief get current iec61937 data size
@@ -117,25 +113,40 @@
size_t outBufCurrentPos;
};
-static SPDIFEncoderAD *spdif_encoder_ad = NULL;
-extern "C" int spdif_encoder_ad_init(audio_format_t format, const void *output, int max_output_size)
+
+extern "C" int spdif_encoder_ad_init(void **pphandle, audio_format_t format, const void *output, int max_output_size)
{
- if (spdif_encoder_ad) {
- delete spdif_encoder_ad;
- spdif_encoder_ad = NULL;
- }
+ SPDIFEncoderAD *spdif_encoder_ad = NULL;
+
spdif_encoder_ad = new SPDIFEncoderAD(format, output, max_output_size);
if (spdif_encoder_ad == NULL) {
ALOGE("init SPDIFEncoderAD failed \n");
return -1;
}
+ *pphandle = (void *)spdif_encoder_ad;
ALOGI("init SPDIFEncoderAD done\n");
return 0;
}
-extern "C" int spdif_encoder_ad_write(const void *buffer, size_t numBytes)
+extern "C" int spdif_encoder_ad_deinit(void *phandle)
{
+ SPDIFEncoderAD *spdif_encoder_ad = (SPDIFEncoderAD *) phandle;
+ if (spdif_encoder_ad) {
+ delete spdif_encoder_ad;
+ }
+
+ return 0;
+}
+
+
+extern "C" int spdif_encoder_ad_write(void *phandle, const void *buffer, size_t numBytes)
+{
+ SPDIFEncoderAD *spdif_encoder_ad = (SPDIFEncoderAD *) phandle;
+ if (phandle == NULL) {
+ return -1;
+ }
+
#if 1
- if (aml_getprop_bool("media.audiohal.outdump")) {
+ if (aml_getprop_bool("vendor.media.audiohal.outdump")) {
FILE *fp1 = fopen("/data/audio_out/enc_input.spdif", "a+");
if (fp1) {
fwrite((char *)buffer, 1, numBytes, fp1);
@@ -145,27 +156,47 @@
#endif
return spdif_encoder_ad->write(buffer, numBytes);
}
-extern "C" uint64_t spdif_encoder_ad_get_total()
+extern "C" uint64_t spdif_encoder_ad_get_total(void *phandle)
{
+ SPDIFEncoderAD *spdif_encoder_ad = (SPDIFEncoderAD *) phandle;
+ if (phandle == NULL) {
+ return -1;
+ }
+
return spdif_encoder_ad->total_bytes();
}
/*
*@brief get current iec61937 data size
*/
-extern "C" size_t spdif_encoder_ad_get_current_position(void)
+extern "C" size_t spdif_encoder_ad_get_current_position(void *phandle)
{
+ SPDIFEncoderAD *spdif_encoder_ad = (SPDIFEncoderAD *) phandle;
+ if (phandle == NULL) {
+ return -1;
+ }
+
return spdif_encoder_ad->getCurrentIEC61937DataSize();
}
/*
*@brief flush output iec61937 data current position to zero!
*/
-extern "C" void spdif_encoder_ad_flush_output_current_position(void)
+extern "C" void spdif_encoder_ad_flush_output_current_position(void *phandle)
{
+ SPDIFEncoderAD *spdif_encoder_ad = (SPDIFEncoderAD *) phandle;
+ if (phandle == NULL) {
+ return;
+ }
+
return spdif_encoder_ad->flushOutputCurrentPosition();
}
-extern "C" void spdif_encoder_ad_reset(void)
+extern "C" void spdif_encoder_ad_reset(void *phandle)
{
+ SPDIFEncoderAD *spdif_encoder_ad = (SPDIFEncoderAD *) phandle;
+ if (phandle == NULL) {
+ return;
+ }
+
return spdif_encoder_ad->reset();
}