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

Commit 946ab0ff authored by James Dong's avatar James Dong
Browse files

Don't call virtual functions in the destructor for audio and camera source classes

Change-Id: Ia74ffc1c0cbd7971697f5e3c476e340ec5c7727a
parent 3a29869d
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ struct AudioSource : public MediaSource, public MediaBufferObserver {
    status_t initCheck() const;

    virtual status_t start(MetaData *params = NULL);
    virtual status_t stop();
    virtual status_t stop() { return reset(); }
    virtual sp<MetaData> getFormat();

    // Returns the maximum amplitude since last call.
@@ -97,6 +97,7 @@ private:

    void releaseQueuedFrames_l();
    void waitOutstandingEncodingFrames_l();
    status_t reset();

    AudioSource(const AudioSource &);
    AudioSource &operator=(const AudioSource &);
+3 −2
Original line number Diff line number Diff line
@@ -79,7 +79,7 @@ public:
    virtual ~CameraSource();

    virtual status_t start(MetaData *params = NULL);
    virtual status_t stop();
    virtual status_t stop() { return reset(); }
    virtual status_t read(
            MediaBuffer **buffer, const ReadOptions *options = NULL);

@@ -163,7 +163,6 @@ protected:
                 bool storeMetaDataInVideoBuffers);

    virtual void startCameraRecording();
    virtual void stopCameraRecording();
    virtual void releaseRecordingFrame(const sp<IMemory>& frame);

    // Returns true if need to skip the current frame.
@@ -220,7 +219,9 @@ private:
    status_t checkFrameRate(const CameraParameters& params,
                    int32_t frameRate);

    void stopCameraRecording();
    void releaseCamera();
    status_t reset();

    CameraSource(const CameraSource &);
    CameraSource &operator=(const CameraSource &);
+0 −3
Original line number Diff line number Diff line
@@ -121,9 +121,6 @@ private:
    // Wrapper over CameraSource::read() to implement quick stop.
    virtual status_t read(MediaBuffer **buffer, const ReadOptions *options = NULL);

    // For video camera case, just stops the camera's video recording.
    virtual void stopCameraRecording();

    // mSkipCurrentFrame is set to true in dataCallbackTimestamp() if the current
    // frame needs to be skipped and this function just returns the value of mSkipCurrentFrame.
    virtual bool skipCurrentFrame(int64_t timestampUs);
+2 −2
Original line number Diff line number Diff line
@@ -72,7 +72,7 @@ AudioSource::AudioSource(

AudioSource::~AudioSource() {
    if (mStarted) {
        stop();
        reset();
    }

    delete mRecord;
@@ -130,7 +130,7 @@ void AudioSource::waitOutstandingEncodingFrames_l() {
    }
}

status_t AudioSource::stop() {
status_t AudioSource::reset() {
    Mutex::Autolock autoLock(mLock);
    if (!mStarted) {
        return UNKNOWN_ERROR;
+4 −4
Original line number Diff line number Diff line
@@ -548,7 +548,7 @@ status_t CameraSource::initWithCameraAccess(

CameraSource::~CameraSource() {
    if (mStarted) {
        stop();
        reset();
    } else if (mInitCheck == OK) {
        // Camera is initialized but because start() is never called,
        // the lock on Camera is never released(). This makes sure
@@ -632,8 +632,8 @@ void CameraSource::releaseCamera() {
    mCameraFlags = 0;
}

status_t CameraSource::stop() {
    ALOGD("stop: E");
status_t CameraSource::reset() {
    ALOGD("reset: E");
    Mutex::Autolock autoLock(mLock);
    mStarted = false;
    mFrameAvailableCondition.signal();
@@ -670,7 +670,7 @@ status_t CameraSource::stop() {
    }

    CHECK_EQ(mNumFramesReceived, mNumFramesEncoded + mNumFramesDropped);
    ALOGD("stop: X");
    ALOGD("reset: X");
    return OK;
}

Loading