Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b3eb2b7e authored by Andreas Huber's avatar Andreas Huber Committed by Android (Google) Code Review
Browse files

Merge "Cache the file size in favour of extraneous seek requests."

parents 2d531e1b 4ee31e26
Loading
Loading
Loading
Loading
+5 −7
Original line number Original line Diff line number Diff line
@@ -35,6 +35,10 @@ FileSource::FileSource(const char *filename)
      mDrmBuf(NULL){
      mDrmBuf(NULL){


    mFd = open(filename, O_LARGEFILE | O_RDONLY);
    mFd = open(filename, O_LARGEFILE | O_RDONLY);

    if (mFd >= 0) {
        mLength = lseek64(mFd, 0, SEEK_END);
    }
}
}


FileSource::FileSource(int fd, int64_t offset, int64_t length)
FileSource::FileSource(int fd, int64_t offset, int64_t length)
@@ -116,17 +120,11 @@ status_t FileSource::getSize(off64_t *size) {
        return NO_INIT;
        return NO_INIT;
    }
    }


    if (mLength >= 0) {
    *size = mLength;
    *size = mLength;


    return OK;
    return OK;
}
}


    *size = lseek64(mFd, 0, SEEK_END);

    return OK;
}

sp<DecryptHandle> FileSource::DrmInitialization(const char *mime) {
sp<DecryptHandle> FileSource::DrmInitialization(const char *mime) {
    if (mDrmManagerClient == NULL) {
    if (mDrmManagerClient == NULL) {
        mDrmManagerClient = new DrmManagerClient();
        mDrmManagerClient = new DrmManagerClient();