[PATCH] audio: returns error if poll_revents failed.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>From a79537c26867fd92f32e77a6fe59bf0e1dd61c11 Mon Sep 17 00:00:00 2001
From: Vic Lee <llyzs@xxxxxxx>
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@xxxxxxx>
---
 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


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux