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

Commit 598331dd authored by android-build SharedAccount's avatar android-build SharedAccount
Browse files

Merge commit 'goog/eclair' into eclair-release

parents 77b7f1c2 3431c6cb
Loading
Loading
Loading
Loading
+39 −18
Original line number Diff line number Diff line
@@ -74,6 +74,8 @@ static const int8_t kMaxTrackStartupRetries = 50;
static const int kDumpLockRetries = 50;
static const int kDumpLockSleep = 20000;

static const nsecs_t kWarningThrottle = seconds(5);


#define AUDIOFLINGER_SECURITY_ENABLED 1

@@ -601,18 +603,19 @@ status_t AudioFlinger::setParameters(int ioHandle, const String8& keyValuePairs)
        return result;
    }

    // Check if parameters are for an output
    PlaybackThread *playbackThread = checkPlaybackThread_l(ioHandle);
    if (playbackThread != NULL) {
        return playbackThread->setParameters(keyValuePairs);
    // hold a strong ref on thread in case closeOutput() or closeInput() is called
    // and the thread is exited once the lock is released
    sp<ThreadBase> thread;
    {
        Mutex::Autolock _l(mLock);
        thread = checkPlaybackThread_l(ioHandle);
        if (thread == NULL) {
            thread = checkRecordThread_l(ioHandle);
        }

    // Check if parameters are for an input
    RecordThread *recordThread = checkRecordThread_l(ioHandle);
    if (recordThread != NULL) {
        return recordThread->setParameters(keyValuePairs);
    }

    if (thread != NULL) {
        return thread->setParameters(keyValuePairs);
    }
    return BAD_VALUE;
}

@@ -624,6 +627,9 @@ String8 AudioFlinger::getParameters(int ioHandle, const String8& keys)
    if (ioHandle == 0) {
        return mAudioHardware->getParameters(keys);
    }

    Mutex::Autolock _l(mLock);

    PlaybackThread *playbackThread = checkPlaybackThread_l(ioHandle);
    if (playbackThread != NULL) {
        return playbackThread->getParameters(keys);
@@ -734,7 +740,7 @@ AudioFlinger::ThreadBase::~ThreadBase()

void AudioFlinger::ThreadBase::exit()
{
    // keep a strong ref on ourself so that we want get
    // keep a strong ref on ourself so that we wont get
    // destroyed in the middle of requestExitAndWait()
    sp <ThreadBase> strongMe = this;

@@ -776,9 +782,14 @@ status_t AudioFlinger::ThreadBase::setParameters(const String8& keyValuePairs)

    mNewParameters.add(keyValuePairs);
    mWaitWorkCV.signal();
    mParamCond.wait(mLock);
    // wait condition with timeout in case the thread loop has exited
    // before the request could be processed
    if (mParamCond.waitRelative(mLock, seconds(2)) == NO_ERROR) {
        status = mParamStatus;
        mWaitWorkCV.signal();
    } else {
        status = TIMED_OUT;
    }
    return status;
}

@@ -1170,7 +1181,10 @@ bool AudioFlinger::MixerThread::threadLoop()
    size_t enabledTracks = 0;
    nsecs_t standbyTime = systemTime();
    size_t mixBufferSize = mFrameCount * mFrameSize;
    nsecs_t maxPeriod = seconds(mFrameCount) / mSampleRate * 2;
    // FIXME: Relaxed timing because of a certain device that can't meet latency
    // Should be reduced to 2x after the vendor fixes the driver issue
    nsecs_t maxPeriod = seconds(mFrameCount) / mSampleRate * 3;
    nsecs_t lastWarning = 0;

    while (!exitPending())
    {
@@ -1183,7 +1197,9 @@ bool AudioFlinger::MixerThread::threadLoop()

            if (checkForNewParameters_l()) {
                mixBufferSize = mFrameCount * mFrameSize;
                maxPeriod = seconds(mFrameCount) / mSampleRate * 2;
                // FIXME: Relaxed timing because of a certain device that can't meet latency
                // Should be reduced to 2x after the vendor fixes the driver issue
                maxPeriod = seconds(mFrameCount) / mSampleRate * 3;
            }

            const SortedVector< wp<Track> >& activeTracks = mActiveTracks;
@@ -1260,10 +1276,15 @@ bool AudioFlinger::MixerThread::threadLoop()
            mNumWrites++;
            mInWrite = false;
            mStandby = false;
            nsecs_t delta = systemTime() - mLastWriteTime;
            nsecs_t now = systemTime();
            nsecs_t delta = now - mLastWriteTime;
            if (delta > maxPeriod) {
                LOGW("write blocked for %llu msecs, thread %p", ns2ms(delta), this);
                mNumDelayedWrites++;
                if ((now - lastWarning) > kWarningThrottle) {
                    LOGW("write blocked for %llu msecs, %d delayed writes, thread %p",
                            ns2ms(delta), mNumDelayedWrites, this);
                    lastWarning = now;
                }
            }
        } else {
            usleep(sleepTime);
+45 −18
Original line number Diff line number Diff line
@@ -294,8 +294,8 @@ sp<SurfaceBuffer> Layer::requestBuffer(int index, int usage)
                this, index, w, h, strerror(-err));
    } else {
        LOGD_IF(DEBUG_RESIZE,
                "Layer::requestBuffer(this=%p), index=%d, w=%d, h=%d",
                this, index, w, h);
                "Layer::requestBuffer(this=%p), index=%d, w=%d, h=%d, handle=%p",
                this, index, w, h, buffer->handle);
    }

    if (err == NO_ERROR && buffer->handle != 0) {
@@ -318,22 +318,18 @@ uint32_t Layer::doTransaction(uint32_t flags)
    const Layer::State& front(drawingState());
    const Layer::State& temp(currentState());

    // Index of the back buffer
    const bool backbufferChanged = (front.w != temp.w) || (front.h != temp.h);
    if (backbufferChanged) {
    if ((front.requested_w != temp.requested_w) || 
        (front.requested_h != temp.requested_h)) {
        // the size changed, we need to ask our client to request a new buffer
        LOGD_IF(DEBUG_RESIZE,
                    "resize (layer=%p), requested (%dx%d), "
                    "drawing (%d,%d), (%dx%d), (%dx%d)",
                    this, int(temp.w), int(temp.h),
                    int(drawingState().w), int(drawingState().h),
                    this, 
                    int(temp.requested_w), int(temp.requested_h),
                    int(front.requested_w), int(front.requested_h),
                    int(mBuffers[0]->getWidth()), int(mBuffers[0]->getHeight()),
                    int(mBuffers[1]->getWidth()), int(mBuffers[1]->getHeight()));

        // record the new size, form this point on, when the client request a
        // buffer, it'll get the new size.
        setDrawingSize(temp.w, temp.h);

        // we're being resized and there is a freeze display request,
        // acquire a freeze lock, so that the screen stays put
        // until we've redrawn at the new size; this is to avoid
@@ -346,9 +342,16 @@ uint32_t Layer::doTransaction(uint32_t flags)
            }
        }

        // recompute the visible region
        flags |= Layer::eVisibleRegion;
        this->contentDirty = true;
        // this will make sure LayerBase::doTransaction doesn't update
        // the drawing state's size
        Layer::State& editDraw(mDrawingState);
        editDraw.requested_w = temp.requested_w;
        editDraw.requested_h = temp.requested_h;

        // record the new size, form this point on, when the client request a
        // buffer, it'll get the new size.
        setDrawingSize(temp.requested_w, temp.requested_h);

        // all buffers need reallocation
        lcblk->reallocate();
    }
@@ -392,12 +395,36 @@ void Layer::lockPageFlip(bool& recomputeVisibleRegions)
    const Region dirty(lcblk->getDirtyRegion(buf));
    mPostedDirtyRegion = dirty.intersect( newFrontBuffer->getBounds() );


    const Layer::State& front(drawingState());
    if (newFrontBuffer->getWidth() == front.w &&
        newFrontBuffer->getHeight() ==front.h) {
    if (newFrontBuffer->getWidth()  == front.requested_w &&
        newFrontBuffer->getHeight() == front.requested_h)
    {
        if ((front.w != front.requested_w) ||
            (front.h != front.requested_h))
        {
            // Here we pretend the transaction happened by updating the
            // current and drawing states. Drawing state is only accessed
            // in this thread, no need to have it locked
            Layer::State& editDraw(mDrawingState);
            editDraw.w = editDraw.requested_w;
            editDraw.h = editDraw.requested_h;

            // We also need to update the current state so that we don't
            // end-up doing too much work during the next transaction.
            // NOTE: We actually don't need hold the transaction lock here
            // because State::w and State::h are only accessed from
            // this thread
            Layer::State& editTemp(currentState());
            editTemp.w = editDraw.w;
            editTemp.h = editDraw.h;

            // recompute visible region
            recomputeVisibleRegions = true;

            // we now have the correct size, unfreeze the screen
            mFreezeLock.clear();
        }
    }

    // FIXME: signal an event if we have more buffers waiting
    // mFlinger->signalEvent();
+27 −25
Original line number Diff line number Diff line
@@ -34,12 +34,6 @@
#include "DisplayHardware/DisplayHardware.h"


// We don't honor the premultiplied alpha flags, which means that
// premultiplied surface may be composed using a non-premultiplied
// equation. We do this because it may be a lot faster on some hardware
// The correct value is HONOR_PREMULTIPLIED_ALPHA = 1
#define HONOR_PREMULTIPLIED_ALPHA   0

namespace android {

// ---------------------------------------------------------------------------
@@ -92,6 +86,8 @@ void LayerBase::initStates(uint32_t w, uint32_t h, uint32_t flags)
    mCurrentState.z             = 0;
    mCurrentState.w             = w;
    mCurrentState.h             = h;
    mCurrentState.requested_w   = w;
    mCurrentState.requested_h   = h;
    mCurrentState.alpha         = 0xFF;
    mCurrentState.flags         = layerFlags;
    mCurrentState.sequence      = 0;
@@ -101,14 +97,8 @@ void LayerBase::initStates(uint32_t w, uint32_t h, uint32_t flags)
    mDrawingState = mCurrentState;
}

void LayerBase::commitTransaction(bool skipSize) {
    const uint32_t w = mDrawingState.w;
    const uint32_t h = mDrawingState.h;
void LayerBase::commitTransaction() {
    mDrawingState = mCurrentState;
    if (skipSize) {
        mDrawingState.w = w;
        mDrawingState.h = h;
    }
}
void LayerBase::forceVisibilityTransaction() {
    // this can be called without SurfaceFlinger.mStateLock, but if we
@@ -144,10 +134,10 @@ bool LayerBase::setLayer(uint32_t z) {
    return true;
}
bool LayerBase::setSize(uint32_t w, uint32_t h) {
    if (mCurrentState.w == w && mCurrentState.h == h)
    if (mCurrentState.requested_w == w && mCurrentState.requested_h == h)
        return false;
    mCurrentState.w = w;
    mCurrentState.h = h;
    mCurrentState.requested_w = w;
    mCurrentState.requested_h = h;
    requestTransaction();
    return true;
}
@@ -204,13 +194,25 @@ uint32_t LayerBase::doTransaction(uint32_t flags)
    const Layer::State& front(drawingState());
    const Layer::State& temp(currentState());

    if (temp.sequence != front.sequence) {
    if ((front.requested_w != temp.requested_w) ||
        (front.requested_h != temp.requested_h))  {
        // resize the layer, set the physical size to the requested size
        Layer::State& editTemp(currentState());
        editTemp.w = temp.requested_w;
        editTemp.h = temp.requested_h;
    }

    if ((front.w != temp.w) || (front.h != temp.h)) {
        // invalidate and recompute the visible regions if needed
        flags |= eVisibleRegion;
        flags |= Layer::eVisibleRegion;
        this->contentDirty = true;
    }

    if (temp.sequence != front.sequence) {
        // invalidate and recompute the visible regions if needed
        flags |= eVisibleRegion;
        this->contentDirty = true;

        const bool linearFiltering = mUseLinearFiltering;
        mUseLinearFiltering = false;
        if (!(mFlags & DisplayHardware::SLOW_CONFIG)) {
@@ -223,7 +225,7 @@ uint32_t LayerBase::doTransaction(uint32_t flags)
    }

    // Commit the transaction
    commitTransaction(flags & eRestartTransaction);
    commitTransaction();
    return flags;
}

+3 −2
Original line number Diff line number Diff line
@@ -88,6 +88,8 @@ public:
            struct State {
                uint32_t        w;
                uint32_t        h;
                uint32_t        requested_w;
                uint32_t        requested_h;
                uint32_t        z;
                uint8_t         alpha;
                uint8_t         flags;
@@ -107,7 +109,7 @@ public:
            bool setTransparentRegionHint(const Region& opaque);
            bool setFlags(uint8_t flags, uint8_t mask);
            
            void commitTransaction(bool skipSize);
            void commitTransaction();
            bool requestTransaction();
            void forceVisibilityTransaction();
            
@@ -211,7 +213,6 @@ public:
    
    enum { // flags for doTransaction()
        eVisibleRegion      = 0x00000002,
        eRestartTransaction = 0x00000008
    };


+8 −7
Original line number Diff line number Diff line
@@ -594,12 +594,6 @@ void SurfaceFlinger::handleTransactionLocked(
            const uint32_t flags = layer->doTransaction(0);
            if (flags & Layer::eVisibleRegion)
                mVisibleRegionsDirty = true;

            if (flags & Layer::eRestartTransaction) {
                // restart the transaction, but back-off a little
                layer->setTransactionFlags(eTransactionNeeded);
                setTransactionFlags(eTraversalNeeded, ms2ns(8));
            }
        }
    }

@@ -1131,7 +1125,14 @@ void SurfaceFlinger::closeGlobalTransaction()
        // take effect before returning.
        Mutex::Autolock _l(mStateLock);
        while (mResizeTransationPending) {
            mTransactionCV.wait(mStateLock);
            status_t err = mTransactionCV.waitRelative(mStateLock, s2ns(5));
            if (CC_UNLIKELY(err != NO_ERROR)) {
                // just in case something goes wrong in SF, return to the
                // called after a few seconds.
                LOGW_IF(err == TIMED_OUT, "closeGlobalTransaction timed out!");
                mResizeTransationPending = false;
                break;
            }
        }
    }
}
Loading