From: "Frédéric Dalleau" <frederic.dalleau@access-company.com>
To: BlueZ development <bluez-devel@lists.sourceforge.net>
Subject: Re: [Bluez-devel] [patch] alsa plugin disconnection
Date: Mon, 03 Mar 2008 19:09:47 +0100 [thread overview]
Message-ID: <47CC3EEB.6060105@access-company.com> (raw)
In-Reply-To: <47CC3DF5.8070303@access-company.com>
[-- Attachment #1: Type: text/plain, Size: 692 bytes --]
updated patch.
Frédéric Dalleau wrote:
> Hi,
>
> This patch will allow alsa plugin to detect disconnection of devices and
> return error to applications.
> Not all applications will handle this error, but at least it is available.
>
> Comments are welcome.
>
> Frederic
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Bluez-devel mailing list
> Bluez-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/bluez-devel
>
[-- Attachment #2: alsa_plugin_disconnection.patch --]
[-- Type: text/x-patch, Size: 2334 bytes --]
diff --git a/audio/pcm_bluetooth.c b/audio/pcm_bluetooth.c
index 2282b2e..1355066 100644
--- a/audio/pcm_bluetooth.c
+++ b/audio/pcm_bluetooth.c
@@ -750,6 +750,11 @@ static int bluetooth_poll_revents(snd_pcm_ioplug_t *io ATTRIBUTE_UNUSED,
return 0;
}
+static int bluetooth_playback_poll_descriptors_count(snd_pcm_ioplug_t *io)
+{
+ return 2;
+}
+
static int bluetooth_playback_poll_descriptors(snd_pcm_ioplug_t *io,
struct pollfd *pfd, unsigned int space)
{
@@ -759,14 +764,17 @@ static int bluetooth_playback_poll_descriptors(snd_pcm_ioplug_t *io,
assert(data->pipefd[0] >= 0);
- if (space < 1)
+ if (space < 2)
return 0;
pfd[0].fd = data->pipefd[0];
pfd[0].events = POLLIN;
pfd[0].revents = 0;
+ pfd[1].fd = data->stream.fd;
+ pfd[1].events = POLLERR | POLLHUP | POLLNVAL;
+ pfd[1].revents = 0;
- return 1;
+ return 2;
}
static int bluetooth_playback_poll_revents(snd_pcm_ioplug_t *io,
@@ -779,14 +787,19 @@ static int bluetooth_playback_poll_revents(snd_pcm_ioplug_t *io,
DBG("");
assert(pfds);
- assert(nfds == 1);
+ assert(nfds == 2);
assert(revents);
assert(pfds[0].fd >= 0);
+ assert(pfds[1].fd >= 0);
if (io->state != SND_PCM_STATE_PREPARED)
ret = read(pfds[0].fd, buf, 1);
- *revents = (pfds[0].revents & ~POLLIN) | POLLOUT;
+ if (pfds[1].revents & (POLLERR | POLLHUP | POLLNVAL))
+ io->state = SND_PCM_STATE_DISCONNECTED;
+
+ revents[0] = (pfds[0].revents & ~POLLIN) | POLLOUT;
+ revents[1] = (pfds[1].revents & ~POLLIN);
return 0;
}
@@ -1087,6 +1100,7 @@ static snd_pcm_ioplug_callback_t bluetooth_hsp_playback = {
.hw_params = bluetooth_hsp_hw_params,
.prepare = bluetooth_prepare,
.transfer = bluetooth_hsp_write,
+ .poll_descriptors_count = bluetooth_playback_poll_descriptors_count,
.poll_descriptors = bluetooth_playback_poll_descriptors,
.poll_revents = bluetooth_playback_poll_revents,
.delay = bluetooth_playback_delay,
@@ -1112,6 +1126,7 @@ static snd_pcm_ioplug_callback_t bluetooth_a2dp_playback = {
.hw_params = bluetooth_a2dp_hw_params,
.prepare = bluetooth_prepare,
.transfer = bluetooth_a2dp_write,
+ .poll_descriptors_count = bluetooth_playback_poll_descriptors_count,
.poll_descriptors = bluetooth_playback_poll_descriptors,
.poll_revents = bluetooth_playback_poll_revents,
.delay = bluetooth_playback_delay,
[-- Attachment #3: Type: text/plain, Size: 228 bytes --]
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
[-- Attachment #4: Type: text/plain, Size: 164 bytes --]
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
next prev parent reply other threads:[~2008-03-03 18:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-03 18:05 [Bluez-devel] [patch] alsa plugin disconnection Frédéric Dalleau
2008-03-03 18:09 ` Frédéric Dalleau [this message]
2008-03-04 21:59 ` Luiz Augusto von Dentz
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=47CC3EEB.6060105@access-company.com \
--to=frederic.dalleau@access-company.com \
--cc=bluez-devel@lists.sourceforge.net \
/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.