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

Commit 4ee31e26 authored by Andreas Huber's avatar Andreas Huber
Browse files

Cache the file size in favour of extraneous seek requests.

Change-Id: Ia922b13179c69749d09cd3fccbd5c30109c28bd7
related-to-bug: 6321952
parent d2469c3f
Loading
Loading
Loading
Loading
+5 −7
Original line number Diff line number Diff line
@@ -35,6 +35,10 @@ FileSource::FileSource(const char *filename)
      mDrmBuf(NULL){

    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)
@@ -116,17 +120,11 @@ status_t FileSource::getSize(off64_t *size) {
        return NO_INIT;
    }

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

    return OK;
}

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

    return OK;
}

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