From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ v2 3/4] android/hal-audio: Fix not handling EINTR errors
Date: Mon, 27 Jan 2014 22:16:59 -0800 [thread overview]
Message-ID: <1390889820-24709-3-git-send-email-luiz.dentz@gmail.com> (raw)
In-Reply-To: <1390889820-24709-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
If the kernel interrupts us while writting just try again.
---
android/hal-audio.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/android/hal-audio.c b/android/hal-audio.c
index 8d737ad..2ca6289 100644
--- a/android/hal-audio.c
+++ b/android/hal-audio.c
@@ -399,7 +399,7 @@ static void sbc_resume(void *codec_data)
sbc_data->frames_sent = 0;
}
-static void write_media_packet(int fd, struct sbc_data *sbc_data,
+static int write_media_packet(int fd, struct sbc_data *sbc_data,
struct media_packet *mp, size_t data_len)
{
struct timespec cur;
@@ -407,10 +407,13 @@ static void write_media_packet(int fd, struct sbc_data *sbc_data,
unsigned expected_frames;
int ret;
- ret = write(fd, mp, sizeof(*mp) + data_len);
- if (ret < 0) {
- int err = errno;
- error("SBC: failed to write data: %d (%s)", err, strerror(err));
+ while (true) {
+ ret = write(fd, mp, sizeof(*mp) + data_len);
+ if (ret >= 0)
+ break;
+
+ if (errno != EINTR)
+ return -errno;
}
sbc_data->frames_sent += mp->payload.frame_count;
@@ -432,6 +435,8 @@ static void write_media_packet(int fd, struct sbc_data *sbc_data,
if (sbc_data->frames_sent >= expected_frames)
usleep(sbc_data->frame_duration *
mp->payload.frame_count);
+
+ return ret;
}
static ssize_t sbc_write_data(void *codec_data, const void *buffer,
@@ -474,7 +479,9 @@ static ssize_t sbc_write_data(void *codec_data, const void *buffer,
*/
if (mp->payload.frame_count == sbc_data->frames_per_packet ||
bytes == consumed) {
- write_media_packet(fd, sbc_data, mp, encoded);
+ ret = write_media_packet(fd, sbc_data, mp, encoded);
+ if (ret < 0)
+ return ret;
encoded = 0;
free_space = sbc_data->out_buf_size - sizeof(*mp);
--
1.8.4.2
next prev parent reply other threads:[~2014-01-28 6:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-28 6:16 [PATCH BlueZ v2 1/4] android/AVDTP: Make signalling channel priority 6 Luiz Augusto von Dentz
2014-01-28 6:16 ` [PATCH BlueZ v2 2/4] android/AVDTP: Make stream channel priority 5 Luiz Augusto von Dentz
2014-01-28 6:16 ` Luiz Augusto von Dentz [this message]
2014-01-28 6:17 ` [PATCH BlueZ v2 4/4] android/hal-audio: Set stream fd to blocking Luiz Augusto von Dentz
2014-01-28 12:05 ` [PATCH BlueZ v2 1/4] android/AVDTP: Make signalling channel priority 6 Marcel Holtmann
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=1390889820-24709-3-git-send-email-luiz.dentz@gmail.com \
--to=luiz.dentz@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox