All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vic Lee <llyzs.vic@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH] audio: returns error if poll_revents failed.
Date: Sat, 30 Jun 2012 12:29:40 +0800	[thread overview]
Message-ID: <4FEE80B4.6060609@gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 0 bytes --]



[-- Attachment #2: 0001-audio-returns-error-if-poll_revents-failed.patch --]
[-- Type: text/x-patch, Size: 1343 bytes --]

>From a79537c26867fd92f32e77a6fe59bf0e1dd61c11 Mon Sep 17 00:00:00 2001
From: Vic Lee <llyzs@163.com>
Date: Sat, 30 Jun 2012 20:16:18 +0800
Subject: [PATCH] audio: returns error if poll_revents failed.

Error must be reported back to ALSA if poll_revents failed. Otherwise,
when the bluetooth audio device is disconnected during playback, ALSA
will enter in an infinite loop, bluez will keep printing "read error",
and application freezes.

Signed-off-by: Vic Lee <llyzs@163.com>
---
 audio/pcm_bluetooth.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/audio/pcm_bluetooth.c b/audio/pcm_bluetooth.c
index b9da805..ca5ff11 100644
--- a/audio/pcm_bluetooth.c
+++ b/audio/pcm_bluetooth.c
@@ -821,6 +821,7 @@ static int bluetooth_playback_poll_revents(snd_pcm_ioplug_t *io,
 					unsigned short *revents)
 {
 	static char buf[1];
+	int err = 0;
 
 	DBG("");
 
@@ -832,14 +833,17 @@ static int bluetooth_playback_poll_revents(snd_pcm_ioplug_t *io,
 
 	if (io->state != SND_PCM_STATE_PREPARED)
 		if (read(pfds[0].fd, buf, 1) < 0)
+		{
 			SYSERR("read error: %s (%d)", strerror(errno), errno);
+			err = -1;
+		}
 
 	if (pfds[1].revents & (POLLERR | POLLHUP | POLLNVAL))
 		io->state = SND_PCM_STATE_DISCONNECTED;
 
 	*revents = (pfds[0].revents & POLLIN) ? POLLOUT : 0;
 
-	return 0;
+	return err;
 }
 
 
-- 
1.7.10


             reply	other threads:[~2012-06-30  4:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-30  4:29 Vic Lee [this message]
2012-07-02 21:51 ` [PATCH] audio: returns error if poll_revents failed Lucas De Marchi

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=4FEE80B4.6060609@gmail.com \
    --to=llyzs.vic@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /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.