diff options
author | James Dong <jdong@google.com> | 2010-11-18 20:59:13 -0800 |
---|---|---|
committer | James Dong <jdong@google.com> | 2010-11-19 10:48:22 -0800 |
commit | 674ebd0b4e1143e38392a4e3bb38b4679a4577bc (patch) | |
tree | 413ce9a380d7c35b935e475ea21fecf5cc5466e7 /media/libstagefright/FileSource.cpp | |
parent | 317ca79a49746dbd1b6bb83712e93e2dc5f6e4f0 (diff) | |
download | frameworks_av-674ebd0b4e1143e38392a4e3bb38b4679a4577bc.zip frameworks_av-674ebd0b4e1143e38392a4e3bb38b4679a4577bc.tar.gz frameworks_av-674ebd0b4e1143e38392a4e3bb38b4679a4577bc.tar.bz2 |
Removed uncessary FILE structure pointer for I/O
o also move the fd owner from caller to callee in the Writers
Change-Id: I510ccfdd0fcc58f1777fea4ed1349fd251852c65
Diffstat (limited to 'media/libstagefright/FileSource.cpp')
-rw-r--r-- | media/libstagefright/FileSource.cpp | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/media/libstagefright/FileSource.cpp b/media/libstagefright/FileSource.cpp index c9f68e9..98d5b50 100644 --- a/media/libstagefright/FileSource.cpp +++ b/media/libstagefright/FileSource.cpp @@ -18,12 +18,14 @@ #include <media/stagefright/MediaDebug.h> #include <sys/types.h> #include <unistd.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> namespace android { FileSource::FileSource(const char *filename) - : mFile(fopen(filename, "rb")), - mFd(mFile == NULL ? -1 : fileno(mFile)), + : mFd(-1), mOffset(0), mLength(-1), mDecryptHandle(NULL), @@ -31,11 +33,12 @@ FileSource::FileSource(const char *filename) mDrmBufOffset(0), mDrmBufSize(0), mDrmBuf(NULL){ + + mFd = open(filename, O_LARGEFILE | O_RDONLY); } FileSource::FileSource(int fd, int64_t offset, int64_t length) - : mFile(fdopen(fd, "rb")), - mFd(fd), + : mFd(fd), mOffset(offset), mLength(length), mDecryptHandle(NULL), @@ -48,9 +51,9 @@ FileSource::FileSource(int fd, int64_t offset, int64_t length) } FileSource::~FileSource() { - if (mFile != NULL) { - fclose(mFile); - mFile = NULL; + if (mFd >= 0) { + close(mFd); + mFd = -1; } if (mDrmBuf != NULL) { @@ -60,11 +63,11 @@ FileSource::~FileSource() { } status_t FileSource::initCheck() const { - return mFile != NULL ? OK : NO_INIT; + return mFd >= 0 ? OK : NO_INIT; } ssize_t FileSource::readAt(off64_t offset, void *data, size_t size) { - if (mFile == NULL) { + if (mFd < 0) { return NO_INIT; } @@ -95,7 +98,7 @@ ssize_t FileSource::readAt(off64_t offset, void *data, size_t size) { } status_t FileSource::getSize(off64_t *size) { - if (mFile == NULL) { + if (mFd < 0) { return NO_INIT; } |