status_t Condition::waitRelative(Mutex& mutex, nsecs_t reltime)
{
    WinCondition* condState = (WinCondition*) mState;
    HANDLE hMutex = (HANDLE) mutex.mState;
    nsecs_t absTime = systemTime()+reltime;

    return ((WinCondition*)mState)->wait(condState, hMutex, &absTime);
}
Ejemplo n.º 2
0
    static void waitForLiberationLocked() {
        if (sThread == NULL) {
            return;
        }

        const nsecs_t timeout = 500 * 1000 * 1000;
        nsecs_t now = systemTime(SYSTEM_TIME_MONOTONIC);
        nsecs_t timeToStop = now + timeout;
        while (!sThread->mQueue.isEmpty() && now < timeToStop) {
            sThread->mFreedCondition.waitRelative(sMutex, timeToStop - now);
            now = systemTime(SYSTEM_TIME_MONOTONIC);
        }

        if (!sThread->mQueue.isEmpty()) {
            ALOGW("waitForLiberationLocked timed out");
        }
    }
Ejemplo n.º 3
0
int SurfaceTextureClient::queueBuffer(android_native_buffer_t* buffer) {
    LOGV("SurfaceTextureClient::queueBuffer");
#ifdef GFX_TESTFRAMEWORK
    char eventID[TF_EVENT_ID_SIZE_MAX];
    int idx = getSlotFromBufferLocked(buffer);
    snprintf(eventID, TF_EVENT_ID_SIZE_MAX, "Q-%d", idx);
    TF_PRINT(TF_EVENT_START, "STClient", eventID, "BUFFER:STC queue start");
    sQueueStartTime[idx] = systemTime();
#endif
    Mutex::Autolock lock(mMutex);
    int64_t timestamp;
    if (mTimestamp == NATIVE_WINDOW_TIMESTAMP_AUTO) {
        timestamp = systemTime(SYSTEM_TIME_MONOTONIC);
        LOGV("SurfaceTextureClient::queueBuffer making up timestamp: %.2f ms",
             timestamp / 1000000.f);
    } else {
        timestamp = mTimestamp;
    }
    int i = getSlotFromBufferLocked(buffer);
    if (i < 0) {
        return i;
    }
    status_t err = mSurfaceTexture->queueBuffer(i, timestamp,
            &mDefaultWidth, &mDefaultHeight, &mTransformHint);
    if (err != OK)  {
        LOGE("queueBuffer: error queuing buffer to SurfaceTexture, %d", err);
    }
#ifdef GFX_TESTFRAMEWORK
    sQueueEndTime[i] = systemTime();
    TF_PRINT(TF_EVENT_STOP, "STClient", eventID, "BUFFER:STC queue end, buffer=%p",
             mSlots[i]->handle);
    {
        int dqTime = ns2ms(sDequeueEndTime[i] - sDequeueStartTime[i]);
        int dqToLock = ns2ms(sLockStartTime[i] - sDequeueEndTime[i]);
        int qTime = ns2ms(sQueueEndTime[i] - sQueueStartTime[i]);
        int renderingTime = ns2ms(sQueueStartTime[i] - sLockStartTime[i]);
        int totalTime = ns2ms(sQueueEndTime[i] - sDequeueStartTime[i]);
        TF_PRINT(TF_EVENT, "STClient", "GFX-Timelines", "DequeueTime %d LockTime Unk QueueTime %d "
                 "RenderingTime %d DequeueToLockTime %d TotalTime %d bufSlot %d PID %d TID %d",
                 dqTime, qTime, renderingTime, dqToLock, totalTime,
                 i, getpid(), gettid());
    }
#endif
    return err;
}
Ejemplo n.º 4
0
void camera_take_snapshot_step(enum CAMERA_TAKEPIC_STEP step)
{
	if (step > CMR_STEP_CALL_BACK) {
		CMR_LOGE("error %d", step);
		return;
	}
	cap_stp[step].timestamp = systemTime(CLOCK_MONOTONIC);
	cap_stp[step].valid = 1;
}
void SystemTimePerfTimer::init()
    {
    DBGT_PROLOG("");

    //store current time
    mInitTime = systemTime(SYSTEM_TIME_REALTIME);

    DBGT_EPILOG("");
    }
Ejemplo n.º 6
0
status_t AudioPolicyManager::stopOutput(audio_io_handle_t output, AudioSystem::stream_type stream, int session)
{
    LOGV("stopOutput() output %d, stream %d", output, stream);
    ssize_t index = mOutputs.indexOfKey(output);
    if (index < 0) {
        LOGW("stopOutput() unknow output %d", output);
        return BAD_VALUE;
    }

    AudioOutputDescriptor *outputDesc = mOutputs.valueAt(index);
    routing_strategy strategy = AudioPolicyManagerBase::getStrategy((AudioSystem::stream_type)stream);

    // handle special case for sonification while in call
    if (isInCall()) {
        AudioPolicyManagerBase::handleIncallSonification(stream, false, false);
    }

    if (outputDesc->mRefCount[stream] > 0) {
        // decrement usage count of this stream on the output
        outputDesc->changeRefCount(stream, -1);
        // store time at which the last music track was stopped - see computeVolume()
        if (stream == AudioSystem::MUSIC) {
            outputDesc->mStopTime[stream] = systemTime();
           // mMusicStopTime = systemTime();
        }

#ifdef WITH_QCOM_LPA
        uint32_t newDevice = AudioPolicyManagerBase::getNewDevice(mHardwareOutput, false);

        if(newDevice == 0 && mLPADecodeOutput != -1) {
            newDevice = AudioPolicyManagerBase::getNewDevice(mLPADecodeOutput, false);
        }

        setOutputDevice(output, newDevice);
#else
        setOutputDevice(output, AudioPolicyManagerBase::getNewDevice(output));
#endif

#ifdef WITH_A2DP
        if (mA2dpOutput != 0 && !a2dpUsedForSonification() &&
                (strategy == STRATEGY_SONIFICATION || strategy == STRATEGY_ENFORCED_AUDIBLE)) {
            setStrategyMute(STRATEGY_MEDIA,
                            false,
                            mA2dpOutput,
                            mOutputs.valueFor(mHardwareOutput)->mLatency*2);
        }
#endif
        if (output != mHardwareOutput) {
            setOutputDevice(mHardwareOutput, AudioPolicyManagerBase::getNewDevice(mHardwareOutput), true);
        }
        return NO_ERROR;
    } else {
        LOGW("stopOutput() refcount is already 0 for output %d", output);
        return INVALID_OPERATION;
    }
}
void GraphicLog::logImpl(int32_t tag, int32_t buffer)
{
    uint8_t scratch[2 + 2 + sizeof(int32_t) + sizeof(int64_t)];
    size_t pos = 0;
    scratch[pos++] = EVENT_TYPE_LIST;
    scratch[pos++] = 2;
    writeInt32(scratch, pos, buffer);
    writeInt64(scratch, pos, ns2ms( systemTime( SYSTEM_TIME_MONOTONIC ) ));
    android_bWriteLog(tag, scratch, sizeof(scratch));
}
Ejemplo n.º 8
0
void Layer::onLayerDisplayed() {
    if (mFrameLatencyNeeded) {
        const DisplayHardware& hw(graphicPlane(0).displayHardware());
        mFrameStats[mFrameLatencyOffset].timestamp = mSurfaceTexture->getTimestamp();
        mFrameStats[mFrameLatencyOffset].set = systemTime();
        mFrameStats[mFrameLatencyOffset].vsync = hw.getRefreshTimestamp();
        mFrameLatencyOffset = (mFrameLatencyOffset + 1) % 128;
        mFrameLatencyNeeded = false;
    }
}
Ejemplo n.º 9
0
/**
 * override for IAtomIspObserver::atomIspNotify()
 *
 * signal start of 3A processing based on 3A statistics available event
 * store SOF event information for future use
 */
bool AAAThread::atomIspNotify(IAtomIspObserver::Message *msg, const ObserverState state)
{
    if(msg && msg->id == IAtomIspObserver::MESSAGE_ID_EVENT) {
        if (mSensorEmbeddedMetaDataEnabled || msg->data.event.type == EVENT_TYPE_METADATA_READY) {
            mSensorEmbeddedMetaDataEnabled = true;
            // When both sensor metadata event and statistics event are ready, then triggers 3A run
            if (msg->data.event.type == EVENT_TYPE_METADATA_READY) {
                mTrigger3A |= EVENT_TYPE_METADATA_READY;
                if (mTrigger3A & EVENT_TYPE_STATISTICS_READY) {
                    mTrigger3A = 0;
                    newStats(mCachedStatsEventMsg.data.event.timestamp, mCachedStatsEventMsg.data.event.sequence);
                    CLEAR(mCachedStatsEventMsg);
                }
                return NO_ERROR;
            }
            if (msg->data.event.type == EVENT_TYPE_STATISTICS_READY) {
                mTrigger3A |= EVENT_TYPE_STATISTICS_READY;
                if (mTrigger3A & EVENT_TYPE_METADATA_READY) {
                    mTrigger3A = 0;
                    newStats(msg->data.event.timestamp, msg->data.event.sequence);
                } else {
                    mCachedStatsEventMsg = *msg;
                }
                return NO_ERROR;
            }
        } else if (msg->data.event.type == EVENT_TYPE_STATISTICS_READY) {
            LOG2("-- STATS READY, seq %d, ts %lldus, systemTime %lldms ---",
                 msg->data.event.sequence,
                 nsecs_t(msg->data.event.timestamp.tv_sec)*1000000LL
                 + nsecs_t(msg->data.event.timestamp.tv_usec),
                 systemTime()/1000/1000);
            newStats(msg->data.event.timestamp, msg->data.event.sequence);
        }
    } else if (msg && msg->id == IAtomIspObserver::MESSAGE_ID_FRAME) {
        LOG2("--- FRAME, seq %d, ts %lldms, systemTime %lldms ---",
             msg->data.frameBuffer.buff.frameSequenceNbr,
             nsecs_t(msg->data.frameBuffer.buff.capture_timestamp.tv_sec)*1000000LL
             + nsecs_t(msg->data.frameBuffer.buff.capture_timestamp.tv_usec),
             systemTime()/1000/1000);
        newFrame(&msg->data.frameBuffer.buff);
    }
    return false;
}
Ejemplo n.º 10
0
int Surface::queueBuffer(android_native_buffer_t* buffer, int fenceFd) {
    ATRACE_CALL();
    ALOGV("Surface::queueBuffer");
    Mutex::Autolock lock(mMutex);
    int64_t timestamp;
    bool isAutoTimestamp = false;
    if (mTimestamp == NATIVE_WINDOW_TIMESTAMP_AUTO) {
        timestamp = systemTime(SYSTEM_TIME_MONOTONIC);
        isAutoTimestamp = true;
        ALOGV("Surface::queueBuffer making up timestamp: %.2f ms",
              timestamp / 1000000.f);
    } else {
        timestamp = mTimestamp;
    }
    int i = getSlotFromBufferLocked(buffer);
    if (i < 0) {
        return i;
    }


    // Make sure the crop rectangle is entirely inside the buffer.
    Rect crop;
    mCrop.intersect(Rect(buffer->width, buffer->height), &crop);

#ifdef QCOM_BSP
    Rect dirtyRect = mDirtyRect;
    if(dirtyRect.isEmpty()) {
        int drWidth = mUserWidth ? mUserWidth : mDefaultWidth;
        int drHeight = mUserHeight ? mUserHeight : mDefaultHeight;
        dirtyRect = Rect(drWidth, drHeight);
    }
#endif

    sp<Fence> fence(fenceFd >= 0 ? new Fence(fenceFd) : Fence::NO_FENCE);
    IGraphicBufferProducer::QueueBufferOutput output;
    IGraphicBufferProducer::QueueBufferInput input(timestamp, isAutoTimestamp,
            crop,
#ifdef QCOM_BSP
            dirtyRect,
#endif
            mScalingMode, mTransform, mSwapIntervalZero,fence);
    status_t err = mGraphicBufferProducer->queueBuffer(i, input, &output);
    if (err != OK)  {
        ALOGE("queueBuffer: error queuing buffer to SurfaceTexture, %d", err);
    }
    uint32_t numPendingBuffers = 0;
    output.deflate(&mDefaultWidth, &mDefaultHeight, &mTransformHint,
                   &numPendingBuffers);

    mConsumerRunningBehind = (numPendingBuffers >= 2);
#ifdef QCOM_BSP
    mDirtyRect.clear();
#endif
    return err;
}
int FramebufferNativeWindow::dequeueBuffer(ANativeWindow* window, 
        android_native_buffer_t** buffer)
{
    FramebufferNativeWindow* self = getSelf(window);
    framebuffer_device_t* fb = self->fbDev;

    int index = self->mBufferHead;
#ifdef GFX_TESTFRAMEWORK
    char eventID[TF_EVENT_ID_SIZE_MAX];
    snprintf(eventID, TF_EVENT_ID_SIZE_MAX, "Dequeue-%d", index);
    nsecs_t start = systemTime();
    TF_PRINT(TF_EVENT_START, "FBNW", eventID, "BUFFER:FBNW dequeue start");
#endif
    GraphicLog& logger(GraphicLog::getInstance());
    logger.log(GraphicLog::SF_FB_DEQUEUE_BEFORE, index);

    /* The buffer is available, return it */
    Mutex::Autolock _l(self->mutex);

    // wait if the number of free buffers <= 0
    while (self->mNumFreeBuffers <= 0) {
        self->mCondition.wait(self->mutex);
    }
    self->mBufferHead++;
    if (self->mBufferHead >= self->mNumBuffers)
        self->mBufferHead = 0;

    // get this buffer
    self->mNumFreeBuffers--;
    self->mCurrentBufferIndex = index;

    *buffer = self->buffers[index].get();
#ifdef GFX_TESTFRAMEWORK
    nsecs_t end = systemTime();
    int dqtime = ns2ms(end - start);
    TF_PRINT(TF_EVENT_STOP, "FBNW", eventID,
             "BUFFER:FBNW dequeue end, DequeueTime %d on buf %d",
             dqtime, index);
#endif
    logger.log(GraphicLog::SF_FB_DEQUEUE_AFTER, index);
    return 0;
}
Ejemplo n.º 12
0
bool SwAudioOutputCollection::isStreamActive(audio_stream_type_t stream, uint32_t inPastMs) const
{
    nsecs_t sysTime = systemTime();
    for (size_t i = 0; i < this->size(); i++) {
        const sp<SwAudioOutputDescriptor> outputDesc = this->valueAt(i);
        if (outputDesc->isStreamActive(stream, inPastMs, sysTime)) {
            return true;
        }
    }
    return false;
}
Ejemplo n.º 13
0
void Layer::onPostComposition() {
    if (mFrameLatencyNeeded) {
        const HWComposer& hwc = mFlinger->getHwComposer();
        const size_t offset = mFrameLatencyOffset;
        mFrameStats[offset].timestamp = mSurfaceTexture->getTimestamp();
        mFrameStats[offset].set = systemTime();
        mFrameStats[offset].vsync = hwc.getRefreshTimestamp(HWC_DISPLAY_PRIMARY);
        mFrameLatencyOffset = (mFrameLatencyOffset + 1) % 128;
        mFrameLatencyNeeded = false;
    }
}
bool AudioPolicyManagerBase::isStreamActive(int stream, uint32_t inPastMs) const
{
    nsecs_t sysTime = systemTime();
    for (size_t i = 0; i < mOutputs.size(); i++) {
        if (mOutputs.valueAt(i)->mRefCount[stream] != 0 ||
            ns2ms(sysTime - mOutputs.valueAt(i)->mStopTime[stream]) < inPastMs) {
            return true;
        }
    }
    return false;
}
Ejemplo n.º 15
0
DisplayList::DisplayList(const DisplayListRenderer& recorder) :
    mDestroyed(false), mTransformMatrix(NULL), mTransformCamera(NULL), mTransformMatrix3D(NULL),
    mStaticMatrix(NULL), mAnimationMatrix(NULL) {

    initFromDisplayListRenderer(recorder);

#if MTK_DEBUG_ERROR_CHECK
    mTid = gettid();
    mTimestamp = systemTime(SYSTEM_TIME_MONOTONIC);
    Caches::getInstance().addDisplayList(this);
#endif
}
Ejemplo n.º 16
0
void setBrightnessValueBg_notifyRenderTime(float time)
{
    static void *handle;
    void  *func;
    int    boost_level = LEVEL_BOOST_NOP, first_frame = 0;
    static nsecs_t mPreviousTime = 0;
    char buff[64];
    nsecs_t now = systemTime(CLOCK_MONOTONIC);
    //init();

    setBrightnessValueBg_notifyFrameUpdate(1);
    //ALOGI("setBrightnessValueBg_notifyRenderTime: time:%f", time);

#if 0
    if(handle == NULL) {
        handle = dlopen("libperfservice.so", RTLD_NOW);
        func = dlsym(handle, "perfCalcBoostLevel");
        perfCalcBoostLevel = reinterpret_cast<calc_boost_level>(func);
        if (perfCalcBoostLevel == NULL) {
            ALOGE("perfCalcBoostLevel init fail!");
        }
    }

    if(mPreviousTime == 0 || (now - mPreviousTime) > RENDER_THREAD_CHECK_DURATION) { // exceed RENDER_THREAD_CHECK_DURATION => first frame
        first_frame = 1;
    }
    mPreviousTime = now;

    if(first_frame) {
        //ALOGI("setBrightnessValueBg_notifyRenderTime: first_frame");
        if(perfCalcBoostLevel)
            perfCalcBoostLevel(0);
        return;
    }

    if(perfCalcBoostLevel) {
        boost_level = perfCalcBoostLevel(time);
    }

    // init value
    //sprintf(buff, "notifyRenderTime:%.2f", time);

    if(boost_level == LEVEL_BOOST_NOP)
        return;

    sprintf(buff, "levelBoost:%d", boost_level);
    ATRACE_BEGIN(buff);
#if defined(MTK_LEVEL_BOOST_SUPPORT)
    setBrightnessValueBg_levelBoost(boost_level);
#endif
    ATRACE_END();
#endif
}
int FramebufferNativeWindow::lockBuffer(ANativeWindow* window, 
        android_native_buffer_t* buffer)
{
    FramebufferNativeWindow* self = getSelf(window);
    framebuffer_device_t* fb = self->fbDev;
    int index = -1;

#ifdef GFX_TESTFRAMEWORK
    char eventID[TF_EVENT_ID_SIZE_MAX];
    index = self->mCurrentBufferIndex;
    snprintf(eventID, TF_EVENT_ID_SIZE_MAX, "lock-%d", index);
    nsecs_t start = systemTime();
    TF_PRINT(TF_EVENT_START, "FBNW", eventID, "BUFFER:FBNW lock start");
#endif
    {
        Mutex::Autolock _l(self->mutex);
        index = self->mCurrentBufferIndex;
    }
    GraphicLog& logger(GraphicLog::getInstance());
    logger.log(GraphicLog::SF_FB_LOCK_BEFORE, index);

    if (!fb->lockBuffer) {
        while (self->front == buffer) {
            self->mCondition.wait(self->mutex);
        }
    }
    else {
        fb->lockBuffer(fb, index);
    }

    logger.log(GraphicLog::SF_FB_LOCK_AFTER, index);
#ifdef GFX_TESTFRAMEWORK
    nsecs_t end = systemTime();
    int lktime = ns2ms(end - start);
    TF_PRINT(TF_EVENT_STOP, "FBNW", eventID,
             "BUFFER:FBNW lock end, LockTime %d on buf %d",
             lktime, index);
#endif
    return NO_ERROR;
}
Ejemplo n.º 18
0
int SurfaceTextureClient::dequeueBuffer(android_native_buffer_t** buffer) {
    LOGV("SurfaceTextureClient::dequeueBuffer");
#ifdef GFX_TESTFRAMEWORK
    nsecs_t startTime = systemTime();
    TF_PRINT(TF_EVENT_START, "STClient", "DQ", "BUFFER:STC dequeue start");
#endif
    Mutex::Autolock lock(mMutex);
    int buf = -1;
    status_t result = mSurfaceTexture->dequeueBuffer(&buf, mReqWidth, mReqHeight,
            mReqFormat, mReqUsage);
    if (result < 0) {
        LOGV("dequeueBuffer: ISurfaceTexture::dequeueBuffer(%d, %d, %d, %d)"
             "failed: %d", mReqWidth, mReqHeight, mReqFormat, mReqUsage,
             result);
        return result;
    }
    sp<GraphicBuffer>& gbuf(mSlots[buf]);
    if (result & ISurfaceTexture::RELEASE_ALL_BUFFERS) {
        freeAllBuffers();
    }

    if ((result & ISurfaceTexture::BUFFER_NEEDS_REALLOCATION) || gbuf == 0) {
        result = mSurfaceTexture->requestBuffer(buf, &gbuf);
        if (result != NO_ERROR) {
            LOGE("dequeueBuffer: ISurfaceTexture::requestBuffer failed: %d",
                    result);
            return result;
        }
    }
    *buffer = gbuf.get();
#ifdef GFX_TESTFRAMEWORK
    sDequeueEndTime[buf] = systemTime();
    sDequeueStartTime[buf] = startTime;
    TF_PRINT(TF_EVENT_STOP, "STClient", "DQ",
             "BUFFER:STC dequeue end bufSlot=%d buffer=%p",
             buf, mSlots[buf]->handle);
#endif

    return OK;
}
Ejemplo n.º 19
0
void SFWatchDog::markStartTransactionTime(uint32_t index) {
    Mutex::Autolock _l(mLock);

    if (index >= mNodeList.size()) {
        XLOGE("[unmarkStartTransactionTime] index=%d > Node list size=%d", index, mNodeList.size());
        return;
    }

    mNodeList[index]->mStartTransactionTime = systemTime();
    mUpdateCount ++;
    if (mShowLog)
        XLOGV("[%s] name=%s, index=%d, time = %" PRId64 "", __func__, mNodeList[index]->mName.string(), index, mNodeList[index]->mStartTransactionTime);
}
Ejemplo n.º 20
0
void TrimTask::run() {
    acquire_wake_lock(PARTIAL_WAKE_LOCK, kWakeLock);

    for (const auto& path : mPaths) {
        LOG(DEBUG) << "Starting trim of " << path;

        int fd = open(path.c_str(), O_RDONLY | O_DIRECTORY | O_CLOEXEC | O_NOFOLLOW);
        if (fd < 0) {
            PLOG(WARNING) << "Failed to open " << path;
            continue;
        }

        struct fstrim_range range;
        memset(&range, 0, sizeof(range));
        range.len = ULLONG_MAX;

        nsecs_t start = systemTime(SYSTEM_TIME_BOOTTIME);
        if (ioctl(fd, (mFlags & Flags::kDeepTrim) ? FIDTRIM : FITRIM, &range)) {
            PLOG(WARNING) << "Trim failed on " << path;
            notifyResult(path, -1, -1);
        } else {
            nsecs_t delta = systemTime(SYSTEM_TIME_BOOTTIME) - start;
            LOG(INFO) << "Trimmed " << range.len << " bytes on " << path
                    << " in " << nanoseconds_to_milliseconds(delta) << "ms";
            notifyResult(path, range.len, delta);
        }
        close(fd);

        if (mFlags & Flags::kBenchmarkAfter) {
#if BENCHMARK_ENABLED
            BenchmarkPrivate(path);
#else
            LOG(DEBUG) << "Benchmark disabled";
#endif
        }
    }

    release_wake_lock(kWakeLock);
}
Message* Message::createMessage(MessageHandlerInterface* target){
	Message* msg = new Message();
	if(NULL == msg){
		return NULL;
	}
	msg->flags = FLAG_FREE;
	msg->mTarget = target;
	int i = 5;
	msg->mData = reinterpret_cast<int*>(&i);
	msg->when = systemTime(SYSTEM_TIME_MONOTONIC);
	msg->type = TYPE_HAVE_CALLBACK;
	return msg;
}
Ejemplo n.º 22
0
bool Caches::dumpActiveDisplayLists(DisplayList *displayList) {
    Mutex::Autolock _l(mDisplayListLock);
    ALOGW("Active DisplayLists: %d (%lld)", activeDisplayLists.size(), systemTime(SYSTEM_TIME_MONOTONIC));
    bool isFound = false;
    DisplayList *item;
    for (size_t i = 0; i < activeDisplayLists.size(); i++) {
        item = activeDisplayLists.itemAt(i);
        ALOGW("\t[%d] %p, tid=%d, time=%lld", i, item, item->mTid, item->mTimestamp);
        if (item == displayList)
            isFound = true;
    }
    return isFound;
}
Ejemplo n.º 23
0
bool Caches::dumpActiveLayers(Layer *layer) {
    Mutex::Autolock _l(mLayerLock);
    ALOGW("Active Layers: %d (%lld)", activeLayers.size(), systemTime(SYSTEM_TIME_MONOTONIC));
    bool isFound = false;
    Layer *item;
    for (size_t i = 0; i < activeLayers.size(); i++) {
        item = activeLayers.itemAt(i);
        ALOGW("\t[%d] %p, tid=%d, time=%lld", i, item, item->mTid, item->mTimestamp);
        if (item == layer)
            isFound = true;
    }
    return isFound;
}
status_t MessageQueue::queueMessage(
        const sp<MessageBase>& message, nsecs_t relTime, uint32_t flags)
{
    Mutex::Autolock _l(mLock);
    message->when = systemTime() + relTime;
    mMessages.insert(message);
    
    //LOGD("MessageQueue::queueMessage time = %lld ms", message->when);
    //dumpLocked(message);

    mCondition.signal();
    return NO_ERROR;
}
Ejemplo n.º 25
0
int SurfaceTextureClient::lockBuffer(android_native_buffer_t* buffer) {
    LOGV("SurfaceTextureClient::lockBuffer");
#ifdef GFX_TESTFRAMEWORK
    int i = getSlotFromBufferLocked(buffer);
    char eventID[TF_EVENT_ID_SIZE_MAX];
    snprintf(eventID, TF_EVENT_ID_SIZE_MAX, "Lock-%d", i);
    TF_PRINT(TF_EVENT, "STClient", eventID, "BUFFER:STC lock, buffer=%p",
             mSlots[i]->handle);
    sLockStartTime[i] = systemTime();
#endif
    Mutex::Autolock lock(mMutex);
    return OK;
}
Ejemplo n.º 26
0
    void DisplayDispatcherThread::signalEvent(int reason)
    {
        if(reason != 0)
        {
            ALOGV("signalEvent!\n");

            mSemaphore->up();

            mStartReason     = reason;
            mStartTime        = systemTime()/1000;
            mLastTime        = mStartTime;
        }
    }
void VirtualDisplaySurface::onFrameCommitted() {
    if (mDisplayId < 0)
        return;

    VDS_LOGW_IF(mDbgState != DBG_STATE_HWC,
            "Unexpected onFrameCommitted() in %s state", dbgStateStr());
    mDbgState = DBG_STATE_IDLE;

    sp<Fence> fbFence = mHwc.getAndResetReleaseFence(mDisplayId);
    if (mFbProducerSlot >= 0) {
        // release the scratch buffer back to the pool
        Mutex::Autolock lock(mMutex);
        int sslot = mapProducer2SourceSlot(SOURCE_SCRATCH, mFbProducerSlot);
        VDS_LOGV("onFrameCommitted: release scratch sslot=%d", sslot);
        addReleaseFenceLocked(sslot, mProducerBuffers[mFbProducerSlot], fbFence);
        releaseBufferLocked(sslot, mProducerBuffers[mFbProducerSlot],
                EGL_NO_DISPLAY, EGL_NO_SYNC_KHR);
    }

    if (mOutputProducerSlot >= 0) {
        int sslot = mapProducer2SourceSlot(SOURCE_SINK, mOutputProducerSlot);
        QueueBufferOutput qbo;
        sp<Fence> outFence = mHwc.getLastRetireFence(mDisplayId);
        VDS_LOGV("onFrameCommitted: queue sink sslot=%d", sslot);
        // Allow queuing to sink buffer if mMustRecompose is true or
        // mForceHwcCopy is true. This is required to support Miracast WFD Sink
        // Initiatied Pause/Resume feature support
        if (mForceHwcCopy || mMustRecompose) {
            status_t result = mSource[SOURCE_SINK]->queueBuffer(sslot,
                    QueueBufferInput(
                        systemTime(), false /* isAutoTimestamp */,
                        Rect(mSinkBufferWidth, mSinkBufferHeight),
                        NATIVE_WINDOW_SCALING_MODE_FREEZE, 0 /* transform */,
                        true /* async*/,
                        outFence),
                    &qbo);
            if (result == NO_ERROR) {
                updateQueueBufferOutput(qbo);
            }
        } else {
            // If the surface hadn't actually been updated, then we only went
            // through the motions of updating the display to keep our state
            // machine happy. We cancel the buffer to avoid triggering another
            // re-composition and causing an infinite loop.
            mSource[SOURCE_SINK]->cancelBuffer(sslot, outFence);
        }
    }

    resetPerFrameState();
}
MPerfTimer::Time SystemTimePerfTimer::elapsedTime()
    {
    DBGT_PROLOG("");
    
    //get current time
    nsecs_t currentTick = systemTime(SYSTEM_TIME_REALTIME);

    DBGT_PTRACE("Current tick: %lld", currentTick);

    Time time = (currentTick-mInitTime)/1000;

    DBGT_EPILOG("");
    return time;
    }
Ejemplo n.º 29
0
bool Caches::checkInvalidDisplayLists() {
#if MTK_DEBUG_ERROR_CHECK
    Mutex::Autolock _l(mDisplayListLock);
    if (invalidDisplayLists.size() != 0) {
        ALOGW("Invalid DisplayLists: %d (%lld)", invalidDisplayLists.size(), systemTime(SYSTEM_TIME_MONOTONIC));
        for (size_t i = 0; i < invalidDisplayLists.size(); i++) {
            ALOGW("\t[%d] %p", i, invalidDisplayLists.itemAt(i));
        }
        invalidDisplayLists.clear();
        return false;
    }
#endif
    return true;
}
/* LGE_CHANGE_E [email protected] 2010.01.27 */ 
status_t AudioPolicyManagerALSA::stopOutput(audio_io_handle_t output, AudioSystem::stream_type stream)
{
        LOGV("stopOutput() output %d, stream %d", output, stream);
        ssize_t index = mOutputs.indexOfKey(output);
        if (index < 0) {
        LOGW("stopOutput() unknow output %d", output);
        return BAD_VALUE;
        }
        AudioOutputDescriptor *outputDesc = mOutputs.valueAt(index);
        routing_strategy strategy = getStrategy((AudioSystem::stream_type)stream);

        // handle special case for sonification while in call
        if (mPhoneState == AudioSystem::MODE_IN_CALL) {
        handleIncallSonification(stream, false, false);
        }
        if (outputDesc->isUsedByStrategy(strategy)) {
        // decrement usage count of this stream on the output
        outputDesc->changeRefCount(stream, -1);
        if (!outputDesc->isUsedByStrategy(strategy)) {
        // if the stream is the last of its strategy to use this output, change routing
        // in the following order or priority:
        // PHONE > SONIFICATION > MEDIA > DTMF
        uint32_t newDevice = 0;
        if (outputDesc->isUsedByStrategy(STRATEGY_PHONE)) {
            newDevice = getDeviceForStrategy(STRATEGY_PHONE);
        } else if (outputDesc->isUsedByStrategy(STRATEGY_SONIFICATION)) {
            newDevice = getDeviceForStrategy(STRATEGY_SONIFICATION);
        } else if (mPhoneState == AudioSystem::MODE_IN_CALL) {
            newDevice = getDeviceForStrategy(STRATEGY_PHONE);
        } else if (outputDesc->isUsedByStrategy(STRATEGY_MEDIA)) {
            newDevice = getDeviceForStrategy(STRATEGY_MEDIA);
        } else if (outputDesc->isUsedByStrategy(STRATEGY_DTMF)) {
            newDevice = getDeviceForStrategy(STRATEGY_DTMF);
        }
              // apply routing change if necessary.
              // insert a delay of 2 times the audio hardware latency to ensure PCM
              // buffers in audio flinger and audio hardware are emptied before the
              // routing change is executed.
              setOutputDevice(mHardwareOutput, newDevice, false, mOutputs.valueFor(mHardwareOutput)->mLatency*2);
        }
        // store time at which the last music track was stopped - see computeVolume()
	   if (stream == AudioSystem::MUSIC) {
               mMusicStopTime = systemTime();
           }
           return NO_ERROR;
           } else {
              LOGW("stopOutput() refcount is already 0 for output %d", output);
              return INVALID_OPERATION;
       }
}