summaryrefslogtreecommitdiff
path: root/compress.c
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-04-10 10:06:48 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-04-10 10:06:48 +0000
commitdd6039d4a998cac6eeef16d0d211a06031cea6f9 (patch)
tree8ff84f79bb871c15761516f097bf466700255858 /compress.c
parent4378d4e526cc7e3284478d28e6420661d145fc4a (diff)
parentf6700a93634f3c219a40b1298d12cbbf5ebf1160 (diff)
Snap for 8430879 from f6700a93634f3c219a40b1298d12cbbf5ebf1160 to t-keystone-qcom-release
Change-Id: Ie416305838cb4b389b63319b946512c0ce92b5a9
Diffstat (limited to 'compress.c')
-rw-r--r--compress.c76
1 files changed, 37 insertions, 39 deletions
diff --git a/compress.c b/compress.c
index f1947b0..187bbe9 100644
--- a/compress.c
+++ b/compress.c
@@ -397,51 +397,49 @@ int compress_read(struct compress *compress, void *buf, unsigned int size)
return oops(compress, ENODEV, "device not ready");
fds.events = POLLIN;
- while (size) {
- if (compress->ops->ioctl(compress->data, SNDRV_COMPRESS_AVAIL, &avail))
- return oops(compress, errno, "cannot get avail");
+ if (compress->ops->ioctl(compress->data, SNDRV_COMPRESS_AVAIL, &avail))
+ return oops(compress, errno, "cannot get avail");
- if ( (avail.avail < frag_size) && (avail.avail < size) ) {
- /* Less than one fragment available and not at the
- * end of the read, so poll
- */
- if (compress->nonblocking)
- return total;
+ if ( (avail.avail < frag_size) && (avail.avail < size) ) {
+ /* Less than one fragment available and not at the
+ * end of the read, so poll
+ */
+ if (compress->nonblocking)
+ return total;
- ret = compress->ops->poll(compress->data, &fds, 1,
- compress->max_poll_wait_ms);
- if (fds.revents & POLLERR) {
- return oops(compress, EIO, "poll returned error!");
- }
- /* A pause will cause -EBADFD or zero.
- * This is not an error, just stop reading */
- if ((ret == 0) || (ret < 0 && errno == EBADFD))
- break;
- if (ret < 0)
- return oops(compress, errno, "poll error");
- if (fds.revents & POLLIN) {
- continue;
- }
+ ret = compress->ops->poll(compress->data, &fds, 1,
+ compress->max_poll_wait_ms);
+ if (fds.revents & POLLERR) {
+ return oops(compress, EIO, "poll returned error!");
}
- /* read avail bytes */
- if (size > avail.avail)
- to_read = avail.avail;
- else
- to_read = size;
- num_read = compress->ops->read(compress->data, cbuf, to_read);
- if (num_read < 0) {
- /* If play was paused the read returns -EBADFD */
- if (errno == EBADFD)
- break;
- return oops(compress, errno, "read failed!");
+ /* A pause will cause -EBADFD or zero.
+ * This is not an error, just stop reading */
+ if ((ret == 0) || (ret < 0 && errno == EBADFD))
+ return 0;
+ if (ret < 0)
+ return oops(compress, errno, "poll error");
+ if (fds.revents & POLLIN) {
+ return 0;
}
-
- size -= num_read;
- cbuf += num_read;
- total += num_read;
+ }
+ /* read avail bytes */
+ if (size > avail.avail)
+ to_read = avail.avail;
+ else
+ to_read = size;
+ num_read = compress->ops->read(compress->data, cbuf, to_read);
+ if (num_read < 0) {
+ /* If play was paused the read returns -EBADFD */
+ if (errno == EBADFD)
+ return 0;
+ return oops(compress, errno, "read failed!");
}
- return total;
+ size -= num_read;
+ cbuf += num_read;
+ total += num_read;
+
+ return num_read;
}
int compress_start(struct compress *compress)