summaryrefslogtreecommitdiffstats
path: root/media/libmedia
diff options
context:
space:
mode:
authorLeena Winterrowd <lenhardw@codeaurora.org>2015-12-08 14:40:36 -0800
committerSteve Kondik <steve@cyngn.com>2015-12-23 14:29:27 -0800
commit54cdb1f0ce7d03a75499d5ae258fd278de27462d (patch)
tree980b593b8b776a36d8e396ea9b8d2457a036bf3a /media/libmedia
parent5a1e278683de3700dc119a99a6b57cc1fc1463b8 (diff)
downloadframeworks_av-54cdb1f0ce7d03a75499d5ae258fd278de27462d.zip
frameworks_av-54cdb1f0ce7d03a75499d5ae258fd278de27462d.tar.gz
frameworks_av-54cdb1f0ce7d03a75499d5ae258fd278de27462d.tar.bz2
libmedia: Preserve futex return status in client obtainBuffer
clock_gettime() can change errno if something goes wrong (most commonly setting EBADF). This failure should not cause a failure in ClientProxy::obtainBuffer() if the futex returned successfully or with a known status. Preserve errno before calling clock_gettime to prevent propagation of an invalid, unexpected error. Propagated from Ib69201031a81395ece47dd8ad7c4dcddd2b00153 Change-Id: I48320fc287b6a0ef2a1b9e71f9d0e979bd6343a5
Diffstat (limited to 'media/libmedia')
-rw-r--r--media/libmedia/AudioTrackShared.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/media/libmedia/AudioTrackShared.cpp b/media/libmedia/AudioTrackShared.cpp
index 7148743..a6eab12 100644
--- a/media/libmedia/AudioTrackShared.cpp
+++ b/media/libmedia/AudioTrackShared.cpp
@@ -240,6 +240,7 @@ status_t ClientProxy::obtainBuffer(Buffer* buffer, const struct timespec *reques
errno = 0;
(void) syscall(__NR_futex, &cblk->mFutex,
mClientInServer ? FUTEX_WAIT_PRIVATE : FUTEX_WAIT, old & ~CBLK_FUTEX_WAKE, ts);
+ status_t error = errno; // clock_gettime can affect errno
// update total elapsed time spent waiting
if (measure) {
struct timespec after;
@@ -257,7 +258,7 @@ status_t ClientProxy::obtainBuffer(Buffer* buffer, const struct timespec *reques
before = after;
beforeIsValid = true;
}
- switch (errno) {
+ switch (error) {
case 0: // normal wakeup by server, or by binderDied()
case EWOULDBLOCK: // benign race condition with server
case EINTR: // wait was interrupted by signal or other spurious wakeup
@@ -265,7 +266,7 @@ status_t ClientProxy::obtainBuffer(Buffer* buffer, const struct timespec *reques
// FIXME these error/non-0 status are being dropped
break;
default:
- status = errno;
+ status = error;
ALOGE("%s unexpected error %s", __func__, strerror(status));
goto end;
}