* [PATCH TINYCOMPRESS 8/14] compress: Handle case of pause() during compress_write()
@ 2013-02-10 0:15 Richard Fitzgerald
2013-02-22 16:04 ` [PATCH TINYCOMPRESS 8/14 v2] " Richard Fitzgerald
0 siblings, 1 reply; 2+ messages in thread
From: Richard Fitzgerald @ 2013-02-10 0:15 UTC (permalink / raw)
To: vinod.koul; +Cc: alsa-devel
If stream is paused() during a compress_write() the poll()
will return 0 or -EBADFD, or the write() will return -EBADFD.
This is not an error so compress_write() should not pass an
error code to the caller. It should abort the write and then
return the number of bytes it had written up to that point.
diff --git a/compress.c b/compress.c
index b706f8b..7457550 100644
--- a/compress.c
+++ b/compress.c
@@ -329,10 +329,13 @@ int compress_write(struct compress *compress, const void *buf, unsigned int size
if (avail.avail < compress->config.fragment_size) {
/* nothing to write so wait */
ret = poll(&fds, 1, compress->max_poll_wait_ms);
+ /* A pause will cause -EBADFD or zero return from driver
+ * This is not an error, just stop writing
+ */
+ if ((ret == 0) || (ret == -EBADFD))
+ break;
if (ret < 0)
return oops(compress, errno, "poll error");
- if (ret == 0)
- return oops(compress, -EPIPE, "Poll timeout, Broken Pipe");
if (fds.revents & POLLOUT) {
if (ioctl(compress->fd, SNDRV_COMPRESS_AVAIL, &avail))
return oops(compress, errno, "cannot get avail");
@@ -351,6 +354,9 @@ int compress_write(struct compress *compress, const void *buf, unsigned int size
else
to_write = size;
written = write(compress->fd, cbuf, to_write);
+ /* If play was paused the write returns -EBADFD */
+ if (written == -EBADFD)
+ break;
if (written < 0)
return oops(compress, errno, "write failed!\n");
--
1.7.2.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH TINYCOMPRESS 8/14 v2] compress: Handle case of pause() during compress_write()
2013-02-10 0:15 [PATCH TINYCOMPRESS 8/14] compress: Handle case of pause() during compress_write() Richard Fitzgerald
@ 2013-02-22 16:04 ` Richard Fitzgerald
0 siblings, 0 replies; 2+ messages in thread
From: Richard Fitzgerald @ 2013-02-22 16:04 UTC (permalink / raw)
To: vinod.koul; +Cc: alsa-devel
If stream is paused() during a compress_write() the poll()
will return 0 or -EBADFD, or the write() will return -EBADFD.
This is not an error so compress_write() should not pass an
error code to the caller. It should abort the write and then
return the number of bytes it had written up to that point.
---
compress.c | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/compress.c b/compress.c
index 478652a..92d1a80 100644
--- a/compress.c
+++ b/compress.c
@@ -340,10 +340,13 @@ int compress_write(struct compress *compress, const void *buf, unsigned int size
if (avail.avail < compress->config.fragment_size) {
/* nothing to write so wait */
ret = poll(&fds, 1, compress->max_poll_wait_ms);
+ /* A pause will cause -EBADFD or zero return from driver
+ * This is not an error, just stop writing
+ */
+ if ((ret == 0) || (ret == -EBADFD))
+ break;
if (ret < 0)
return oops(compress, errno, "poll error");
- if (ret == 0)
- return oops(compress, -EPIPE, "Poll timeout, Broken Pipe");
if (fds.revents & POLLOUT) {
if (ioctl(compress->fd, SNDRV_COMPRESS_AVAIL, &avail))
return oops(compress, errno, "cannot get avail");
@@ -362,6 +365,9 @@ int compress_write(struct compress *compress, const void *buf, unsigned int size
else
to_write = size;
written = write(compress->fd, cbuf, to_write);
+ /* If play was paused the write returns -EBADFD */
+ if (written == -EBADFD)
+ break;
if (written < 0)
return oops(compress, errno, "write failed!");
--
1.7.2.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-02-22 16:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-10 0:15 [PATCH TINYCOMPRESS 8/14] compress: Handle case of pause() during compress_write() Richard Fitzgerald
2013-02-22 16:04 ` [PATCH TINYCOMPRESS 8/14 v2] " Richard Fitzgerald
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).