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 | 2747e0e07ff7ec2ba808298e8d96536d72d211cb (patch) | |
tree | fa83a99a342b7633027ac349a1d592c098545c08 /media/libstagefright/FileSource.cpp | |
parent | 9803d7f87054ad67b62011e5b84e8963c5930e51 (diff) | |
download | frameworks_base-2747e0e07ff7ec2ba808298e8d96536d72d211cb.zip frameworks_base-2747e0e07ff7ec2ba808298e8d96536d72d211cb.tar.gz frameworks_base-2747e0e07ff7ec2ba808298e8d96536d72d211cb.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; } |