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

Commit 32661d0a authored by Surajit Podder's avatar Surajit Podder Committed by Steve Kondik
Browse files

libstagefright: Return EOS after buffers are released

Return EOS from SurfaceMediaSource after buffers
have been released, due to disconnect from producer..

CRs-Fixed: 550868
Change-Id: I4b2f3ef1c2895f155260baa0c58d90df4b4210d9
parent 08167e2a
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -227,6 +227,8 @@ private:

    Condition mMediaBuffersAvailableCondition;

    bool mBuffersReleased;

    // Avoid copying and equating and default constructor
    DISALLOW_IMPLICIT_CONSTRUCTORS(SurfaceMediaSource);
};
+6 −3
Original line number Diff line number Diff line
@@ -47,7 +47,8 @@ SurfaceMediaSource::SurfaceMediaSource(uint32_t bufferWidth, uint32_t bufferHeig
    mNumFramesEncoded(0),
    mFirstFrameTimestamp(0),
    mMaxAcquiredBufferCount(4),  // XXX double-check the default
    mUseAbsoluteTimestamps(false) {
    mUseAbsoluteTimestamps(false),
    mBuffersReleased(false) {
    ALOGV("SurfaceMediaSource");

    if (bufferWidth == 0 || bufferHeight == 0) {
@@ -138,6 +139,7 @@ status_t SurfaceMediaSource::start(MetaData *params)
    Mutex::Autolock lock(mMutex);

    CHECK(!mStarted);
    mBuffersReleased = false;

    mStartTimeNs = 0;
    int64_t startTimeUs;
@@ -288,7 +290,7 @@ status_t SurfaceMediaSource::read( MediaBuffer **buffer,
    BufferQueue::BufferItem item;
    // If the recording has started and the queue is empty, then just
    // wait here till the frames come in from the client side
    while (mStarted) {
    while (mStarted && !mBuffersReleased) {

        status_t err = mBufferQueue->acquireBuffer(&item, 0);
        if (err == BufferQueue::NO_BUFFER_AVAILABLE) {
@@ -335,7 +337,7 @@ status_t SurfaceMediaSource::read( MediaBuffer **buffer,

    // If the loop was exited as a result of stopping the recording,
    // it is OK
    if (!mStarted) {
    if (!mStarted || mBuffersReleased) {
        ALOGV("Read: SurfaceMediaSource is stopped. Returning ERROR_END_OF_STREAM.");
        return ERROR_END_OF_STREAM;
    }
@@ -467,6 +469,7 @@ void SurfaceMediaSource::onBuffersReleased() {

    Mutex::Autolock lock(mMutex);

    mBuffersReleased = true;
    mFrameAvailableCondition.signal();

    for (int i = 0; i < BufferQueue::NUM_BUFFER_SLOTS; i++) {