All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
To: vinod.koul@intel.com
Cc: alsa-devel@alsa-project.org
Subject: [PATCH TINYCOMPRESS 8/14] compress: Handle case of pause() during	compress_write()
Date: Sun, 10 Feb 2013 00:15:06 +0000	[thread overview]
Message-ID: <20130210001506.GH31139@opensource.wolfsonmicro.com> (raw)

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

             reply	other threads:[~2013-02-10  0:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-10  0:15 Richard Fitzgerald [this message]
2013-02-22 16:04 ` [PATCH TINYCOMPRESS 8/14 v2] compress: Handle case of pause() during compress_write() Richard Fitzgerald

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130210001506.GH31139@opensource.wolfsonmicro.com \
    --to=rf@opensource.wolfsonmicro.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=vinod.koul@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.