summaryrefslogtreecommitdiff
path: root/compress.c
diff options
context:
space:
mode:
authorJake Weinstein <jake@aospa.co>2023-10-31 07:03:04 +0900
committeralk3pInjection <webmaster@raspii.tech>2023-12-27 00:35:28 +0800
commit7b4840522f61eaec3162d3fc234c701cce553798 (patch)
treecec7731b2842e9bc137e5d0c1b81d671bc346c97 /compress.c
parentd1e4fdea6d1201756414f2ab9a97dfa7571bb8ce (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
Diffstat (limited to 'compress.c')
-rw-r--r--compress.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/compress.c b/compress.c
index 3019cb3..5525e43 100644
--- a/compress.c
+++ b/compress.c
@@ -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)