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

Commit 04d070f2 authored by James Dong's avatar James Dong Committed by Android (Google) Code Review
Browse files

Merge "Removed uncessary FILE structure pointer for I/O"

parents 8c62c1d6 2747e0e0
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -44,7 +44,6 @@ protected:
    virtual ~AMRWriter();

private:
    FILE *mFile;
    int   mFd;
    status_t mInitCheck;
    sp<MediaSource> mSource;
+0 −1
Original line number Diff line number Diff line
@@ -46,7 +46,6 @@ protected:
    virtual ~FileSource();

private:
    FILE *mFile;
    int mFd;
    int64_t mOffset;
    int64_t mLength;
+2 −2
Original line number Diff line number Diff line
@@ -61,8 +61,8 @@ protected:
private:
    class Track;

    FILE *mFile;
    int  mFd;
    status_t mInitCheck;
    bool mUse4ByteNalLength;
    bool mUse32BitOffset;
    bool mIsFileSizeLimitExplicitlyRequested;
@@ -149,7 +149,7 @@ private:
    off64_t addSample_l(MediaBuffer *buffer);
    off64_t addLengthPrefixedSample_l(MediaBuffer *buffer);

    inline size_t write(const void *ptr, size_t size, size_t nmemb, FILE* stream);
    inline size_t write(const void *ptr, size_t size, size_t nmemb);
    bool exceedsFileSizeLimit();
    bool use32BitFileOffset() const;
    bool exceedsFileDurationLimit();
+4 −4
Original line number Diff line number Diff line
@@ -864,7 +864,7 @@ status_t StagefrightRecorder::startAMRRecording() {
        return UNKNOWN_ERROR;
    }

    mWriter = new AMRWriter(dup(mOutputFd));
    mWriter = new AMRWriter(mOutputFd);
    mWriter->addSource(audioEncoder);

    if (mMaxFileDurationUs != 0) {
@@ -912,7 +912,7 @@ status_t StagefrightRecorder::startRTPRecording() {
        }
    }

    mWriter = new ARTPWriter(dup(mOutputFd));
    mWriter = new ARTPWriter(mOutputFd);
    mWriter->addSource(source);
    mWriter->setListener(mListener);

@@ -922,7 +922,7 @@ status_t StagefrightRecorder::startRTPRecording() {
status_t StagefrightRecorder::startMPEG2TSRecording() {
    CHECK_EQ(mOutputFormat, OUTPUT_FORMAT_MPEG2TS);

    sp<MediaWriter> writer = new MPEG2TSWriter(dup(mOutputFd));
    sp<MediaWriter> writer = new MPEG2TSWriter(mOutputFd);

    if (mAudioSource != AUDIO_SOURCE_LIST_END) {
        if (mAudioEncoder != AUDIO_ENCODER_AAC) {
@@ -1204,7 +1204,7 @@ status_t StagefrightRecorder::setupMPEG4Recording(
    mediaWriter->clear();
    *totalBitRate = 0;
    status_t err = OK;
    sp<MediaWriter> writer = new MPEG4Writer(dup(outputFd));
    sp<MediaWriter> writer = new MPEG4Writer(outputFd);

    // Add audio source first if it exists
    if (!mCaptureTimeLapse && (mAudioSource != AUDIO_SOURCE_LIST_END)) {
+18 −13
Original line number Diff line number Diff line
@@ -24,22 +24,28 @@
#include <media/mediarecorder.h>
#include <sys/prctl.h>
#include <sys/resource.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

namespace android {

AMRWriter::AMRWriter(const char *filename)
    : mFile(fopen(filename, "wb")),
      mFd(mFile == NULL? -1: fileno(mFile)),
      mInitCheck(mFile != NULL ? OK : NO_INIT),
    : mFd(-1),
      mInitCheck(NO_INIT),
      mStarted(false),
      mPaused(false),
      mResumed(false) {

    mFd = open(filename, O_CREAT | O_LARGEFILE | O_TRUNC);
    if (mFd >= 0) {
        mInitCheck = OK;
    }
}

AMRWriter::AMRWriter(int fd)
    : mFile(fdopen(fd, "wb")),
      mFd(mFile == NULL? -1: fileno(mFile)),
      mInitCheck(mFile != NULL ? OK : NO_INIT),
    : mFd(dup(fd)),
      mInitCheck(mFd < 0? NO_INIT: OK),
      mStarted(false),
      mPaused(false),
      mResumed(false) {
@@ -50,9 +56,9 @@ AMRWriter::~AMRWriter() {
        stop();
    }

    if (mFile != NULL) {
        fclose(mFile);
        mFile = NULL;
    if (mFd != -1) {
        close(mFd);
        mFd = -1;
    }
}

@@ -92,7 +98,7 @@ status_t AMRWriter::addSource(const sp<MediaSource> &source) {
    mSource = source;

    const char *kHeader = isWide ? "#!AMR-WB\n" : "#!AMR\n";
    size_t n = strlen(kHeader);
    ssize_t n = strlen(kHeader);
    if (write(mFd, kHeader, n) != n) {
        return ERROR_IO;
    }
@@ -266,9 +272,8 @@ status_t AMRWriter::threadFunc() {
        notify(MEDIA_RECORDER_EVENT_INFO, MEDIA_RECORDER_INFO_COMPLETION_STATUS, UNKNOWN_ERROR);
    }

    fflush(mFile);
    fclose(mFile);
    mFile = NULL;
    close(mFd);
    mFd = -1;
    mReachedEOS = true;
    if (err == ERROR_END_OF_STREAM) {
        return OK;
Loading