Permalink
Browse files

AI 145972: am: CL 145785 Don't close the A2DP data socket on data err…

…or - prevents mediaserver from wedging on A2DP device poweroff.

  This prevents a race that occurs when an A2DP headset is powered down. If the data socket closes itself then mediaserver tries to recover the stream, while the control path in hcid tries to cleanup the disconnected stream. hcid cant handle this and wedges mediaserver.
  Instead let the control path code trigger all the cleanup (including eventually closing the data socket through bluetooth_close() or bluetooth_stop()).
  Original author: npelly
  Merged from: //branches/cupcake/...

Automated import of CL 145972
  • Loading branch information...
1 parent fc6d963 commit f837f3c108f27e37765f8916cf73560ddd87e2b0 Nick Pelly committed with The Android Open Source Project Apr 13, 2009
Showing with 6 additions and 10 deletions.
  1. +6 −10 utils/audio/liba2dp.c
View
@@ -613,17 +613,13 @@ static int avdtp_write(struct bluetooth_data *data)
print_time("send", begin2, end2);
#endif
if (ret < 0) {
- ERR("send returned %d errno %s.", ret, strerror(errno));
- ret = -errno;
+ /* can happen during normal remote disconnect */
+ VDBG("send() failed: %d (errno %s)", ret, strerror(errno));
}
} else {
- ret = -errno;
- ERR("poll failed: %d", ret);
- }
-
- if (ret < 0) {
- close(data->stream.fd);
- data->stream.fd = -1;
+ /* can happen during normal remote disconnect */
+ VDBG("poll() failed: %d (revents = %d, errno %s)",
+ ret, data->stream.revents, strerror(errno));
}
/* Reset buffer of data to send */
@@ -636,7 +632,7 @@ static int avdtp_write(struct bluetooth_data *data)
end = get_microseconds();
print_time("avdtp_write", begin, end);
#endif
- return ret;
+ return 0; /* always return success */
}
static int audioservice_send(struct bluetooth_data *data,

0 comments on commit f837f3c

Please sign in to comment.