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

Commit e2018ca9 authored by Andreas Huber's avatar Andreas Huber
Browse files

Remove unnecessary lock from AMRWriter.

Change-Id: Ia02966d936dd8cbb31e92051578a3fa816885710
parent 71c27d99
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -42,14 +42,12 @@ protected:
    virtual ~AMRWriter();

private:
    Mutex mLock;

    FILE *mFile;
    status_t mInitCheck;
    sp<MediaSource> mSource;
    bool mStarted;
    volatile bool mDone;
    bool mReachedEOS;
    volatile bool mReachedEOS;
    pthread_t mThread;

    static void *ThreadWrapper(void *);
+5 −21
Original line number Diff line number Diff line
@@ -53,8 +53,6 @@ status_t AMRWriter::initCheck() const {
}

status_t AMRWriter::addSource(const sp<MediaSource> &source) {
    Mutex::Autolock autoLock(mLock);

    if (mInitCheck != OK) {
        return mInitCheck;
    }
@@ -95,8 +93,6 @@ status_t AMRWriter::addSource(const sp<MediaSource> &source) {
}

status_t AMRWriter::start() {
    Mutex::Autolock autoLock(mLock);

    if (mInitCheck != OK) {
        return mInitCheck;
    }
@@ -127,15 +123,11 @@ status_t AMRWriter::start() {
}

void AMRWriter::stop() {
    {
        Mutex::Autolock autoLock(mLock);

    if (!mStarted) {
        return;
    }

    mDone = true;
    }

    void *dummy;
    pthread_join(mThread, &dummy);
@@ -153,13 +145,7 @@ void *AMRWriter::ThreadWrapper(void *me) {
}

void AMRWriter::threadFunc() {
    for (;;) {
        Mutex::Autolock autoLock(mLock);

        if (mDone) {
            break;
        }

    while (!mDone) {
        MediaBuffer *buffer;
        status_t err = mSource->read(&buffer);

@@ -184,12 +170,10 @@ void AMRWriter::threadFunc() {
        buffer = NULL;
    }

    Mutex::Autolock autoLock(mLock);
    mReachedEOS = true;
}

bool AMRWriter::reachedEOS() {
    Mutex::Autolock autoLock(mLock);
    return mReachedEOS;
}