From f474d172dd6796e85f5a8b0ae4e28b946e0415cd Mon Sep 17 00:00:00 2001 From: Patrik Lindgren Date: Mon, 22 Dec 2014 09:06:21 +0100 Subject: Handle error result from DrmManagerClient correctly readAtDRM() must handle the case when DrmManagerClient::pread() returns an error (-1) correctly. This is a degrade in Android L. Change-Id: Id7ff124d178e26931dddac5ac73697cfe6da501c --- include/media/stagefright/FileSource.h | 2 +- media/libstagefright/FileSource.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/media/stagefright/FileSource.h b/include/media/stagefright/FileSource.h index 7051b20..f4f874f 100644 --- a/include/media/stagefright/FileSource.h +++ b/include/media/stagefright/FileSource.h @@ -61,7 +61,7 @@ private: sp mDecryptHandle; DrmManagerClient *mDrmManagerClient; int64_t mDrmBufOffset; - size_t mDrmBufSize; + ssize_t mDrmBufSize; unsigned char *mDrmBuf; ssize_t readAtDRM(off64_t offset, void *data, size_t size); diff --git a/media/libstagefright/FileSource.cpp b/media/libstagefright/FileSource.cpp index f7b1a02..eaa41ff 100644 --- a/media/libstagefright/FileSource.cpp +++ b/media/libstagefright/FileSource.cpp @@ -168,7 +168,7 @@ ssize_t FileSource::readAtDRM(off64_t offset, void *data, size_t size) { } if (mDrmBuf != NULL && mDrmBufSize > 0 && (offset + mOffset) >= mDrmBufOffset - && (offset + mOffset + size) <= (mDrmBufOffset + mDrmBufSize)) { + && (offset + mOffset + size) <= static_cast(mDrmBufOffset + mDrmBufSize)) { /* Use buffered data */ memcpy(data, (void*)(mDrmBuf+(offset+mOffset-mDrmBufOffset)), size); return size; @@ -179,7 +179,7 @@ ssize_t FileSource::readAtDRM(off64_t offset, void *data, size_t size) { DRM_CACHE_SIZE, offset + mOffset); if (mDrmBufSize > 0) { int64_t dataRead = 0; - dataRead = size > mDrmBufSize ? mDrmBufSize : size; + dataRead = size > static_cast(mDrmBufSize) ? mDrmBufSize : size; memcpy(data, (void*)mDrmBuf, dataRead); return dataRead; } else { -- cgit v1.1