diff options
author | Jake Weinstein <jake@aospa.co> | 2023-10-31 07:03:04 +0900 |
---|---|---|
committer | alk3pInjection <webmaster@raspii.tech> | 2023-12-27 00:35:28 +0800 |
commit | 7b4840522f61eaec3162d3fc234c701cce553798 (patch) | |
tree | cec7731b2842e9bc137e5d0c1b81d671bc346c97 | |
parent | d1e4fdea6d1201756414f2ab9a97dfa7571bb8ce (diff) |
Conditionally Revert "tinycompress: do not loop in the compress read"umineko
This change isn't ready for audio HALs before 5.10 and
breaks compress audio record, such as in WhatsApp.
This reverts commit f6700a93634f3c219a40b1298d12cbbf5ebf1160.
Co-Authored-By: Adithya R <gh0strider.2k18.reborn@gmail.com>
Change-Id: Ia87f587db74cad31585cac5fb5e628f29d1ba109
-rw-r--r-- | Android.mk | 6 | ||||
-rw-r--r-- | compress.c | 21 | ||||
-rw-r--r-- | compress_plugin.c | 4 |
3 files changed, 31 insertions, 0 deletions
@@ -6,6 +6,9 @@ LOCAL_CFLAGS := -Wno-macro-redefined -Wno-unused-function ifeq ($(strip $(AUDIO_FEATURE_ENABLED_EXTENDED_COMPRESS_FORMAT)), true) LOCAL_CFLAGS += -DENABLE_EXTENDED_COMPRESS_FORMAT endif +ifeq ($(TARGET_LOOP_COMPRESS_READ), true) +LOCAL_CFLAGS += -DLOOP_COMPRESS_READ +endif LOCAL_C_INCLUDES := $(LOCAL_PATH)/include ifeq ($(TARGET_PREBUILT_KERNEL),) LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include @@ -41,6 +44,9 @@ LOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr LOCAL_SRC_FILES := compress.c utils.c LOCAL_CFLAGS += -DUSE_VENDOR_EXTN LOCAL_CFLAGS += -DENABLE_EXTENDED_COMPRESS_FORMAT +ifeq ($(TARGET_LOOP_COMPRESS_READ), true) +LOCAL_CFLAGS += -DLOOP_COMPRESS_READ +endif LOCAL_MODULE := libtinycompress_vendor LOCAL_SHARED_LIBRARIES := libcutils libutils LOCAL_MODULE_TAGS := optional @@ -397,6 +397,10 @@ int compress_read(struct compress *compress, void *buf, unsigned int size) return oops(compress, ENODEV, "device not ready"); fds.events = POLLIN; +#ifdef LOOP_COMPRESS_READ + while (size) { +#endif + if (compress->ops->ioctl(compress->data, SNDRV_COMPRESS_AVAIL, &avail)) return oops(compress, errno, "cannot get avail"); @@ -415,11 +419,19 @@ int compress_read(struct compress *compress, void *buf, unsigned int size) /* A pause will cause -EBADFD or zero. * This is not an error, just stop reading */ if ((ret == 0) || (ret < 0 && errno == EBADFD)) +#ifdef LOOP_COMPRESS_READ + break; +#else return 0; +#endif if (ret < 0) return oops(compress, errno, "poll error"); if (fds.revents & POLLIN) { +#ifdef LOOP_COMPRESS_READ + continue; +#else return 0; +#endif } } /* read avail bytes */ @@ -431,7 +443,11 @@ int compress_read(struct compress *compress, void *buf, unsigned int size) if (num_read < 0) { /* If play was paused the read returns -EBADFD */ if (errno == EBADFD) +#ifdef LOOP_COMPRESS_READ + break; +#else return 0; +#endif return oops(compress, errno, "read failed!"); } @@ -439,7 +455,12 @@ int compress_read(struct compress *compress, void *buf, unsigned int size) cbuf += num_read; total += num_read; +#ifdef LOOP_COMPRESS_READ + } + return total; +#else return num_read; +#endif } int compress_start(struct compress *compress) diff --git a/compress_plugin.c b/compress_plugin.c index ac54f6c..5cb97c0 100644 --- a/compress_plugin.c +++ b/compress_plugin.c @@ -43,7 +43,9 @@ #include <linux/ioctl.h> #include <sound/asound.h> #include "tinycompress/compress_plugin.h" +#ifndef LOOP_COMPRESS_READ #include "tinycompress/tinycompress.h" +#endif #include "sound/compress_offload.h" #include "compress_ops.h" #include "snd_utils.h" @@ -99,8 +101,10 @@ static int compress_plug_set_params(struct compress_plug_data *plug_data, rc = plugin->ops->set_params(plugin, params); if (!rc) { plugin->state = COMPRESS_PLUG_STATE_SETUP; +#ifndef LOOP_COMPRESS_READ if (plug_data->flags & COMPRESS_OUT) plugin->state = COMPRESS_PLUG_STATE_PREPARED; +#endif } return rc; |