Ejemplo n.º 1
0
bool
ParamsManager::
splitInt(String8 const& s8Input, Vector<int>& rOutput)
{
    rOutput.clear();
    //
    if  ( s8Input.isEmpty() )
    {
        MY_LOGW("empty string");
        return  false;
    }
    //
    char const*start = s8Input.string();
    char *end = NULL;
    do {
        int value = ::strtol(start, &end, 10);
        if  ( start == end ) {
            MY_LOGW_IF(0, "no digits in str:%s", s8Input.string());
            return  false;
        }
        rOutput.push_back(value);
        MY_LOGD_IF(0, "%d", value);
        start = end + 1;
    } while ( end && *end );
    //
    return  (rOutput.size() > 0);
}
bool
ImgBufQueue::
dequeProcessor(Vector<ImgBufQueNode>& rvNode)
{
    bool ret = false;
    //
    Mutex::Autolock _lock(mDoneImgBufQueMtx);
    //
    while   ( mDoneImgBufQue.empty() && mbIsProcessorRunning )
    {
        status_t status = mDoneImgBufQueCond.wait(mDoneImgBufQueMtx);
        if  ( NO_ERROR != status )
        {
            MY_LOGW("wait status(%d), Que.size(%d), IsProcessorRunning(%d)", status, mDoneImgBufQue.size(), mbIsProcessorRunning);
        }
    }
    //
    if  ( ! mDoneImgBufQue.empty() )
    {
        //  If the queue is not empty, deque all buffers from the queue.
        ret = true;
        rvNode = mDoneImgBufQue;
        mDoneImgBufQue.clear();
    }
    else
    {
        MY_LOGD_IF(ENABLE_LOG_PER_FRAME, "Empty Que");
        rvNode.clear();
    }
    //
    return ret;
}
/******************************************************************************
*   It returns false if Processor is Running; call pauseProcessor() firstly
*   before flushProcessor().
*******************************************************************************/
bool
ImgBufQueue::
flushProcessor()
{
    Mutex::Autolock _lock_DONE(mDoneImgBufQueMtx);   //  + lock DONE QUE
    //
    if  ( mbIsProcessorRunning )
    {
        MY_LOGW("IsProcessorRunning=1; please pause it before calling this function.");
        return  false;
    }
    //
    //
    Mutex::Autolock _lock_TODO(mTodoImgBufQueMtx);   //  + lock TODO QUE
    //
    MY_LOGD("TODO Que.size(%d)", mTodoImgBufQue.size());
    for ( List<ImgBufQueNode>::iterator it = mTodoImgBufQue.begin(); it != mTodoImgBufQue.end(); it++ )
    {
        (*it).setStatus(ImgBufQueNode::eSTATUS_CANCEL);
        MY_LOGD_IF(
            ENABLE_LOG_PER_FRAME, 
            "%s: (CookieED/mi4CookieDE)=(%p/%p); Buffer[%s@0x%08X@%d@%s@(%d)%dx%d-%dBit@Timestamp(%lld)]", 
            ImgBufQueNodeStatus2Name((*it).getStatus()), (*it).getCookieED(), (*it).getCookieDE(),  
            (*it)->getBufName(), (*it)->getVirAddr(), (*it)->getBufSize(), (*it)->getImgFormat().string(), 
            (*it)->getImgWidthStride(), (*it)->getImgWidth(), (*it)->getImgHeight(), 
            (*it)->getBitsPerPixel(), (*it)->getTimestamp()
        );
        mDoneImgBufQue.push_back(*it);
    }
    //
    mTodoImgBufQue.clear();
    //
    //
    return  true;
}
Ejemplo n.º 4
0
bool
ParamsManager::
isEnabled(char const* key) const
{
    if  ( ! key )
    {
        MY_LOGW("Null key");
        return  false;
    }
    //
    RWLock::AutoRLock _lock(mRWLock);
    char const* p = mParameters.get(key);
    //
    if ( ! p ) {
        MY_LOGD_IF(1, "No %s", key);
        return false;
    }
    //
    return ( ::strcmp(p, CameraParameters::TRUE) != 0 ) ? false : true;
}
/******************************************************************************
 *  Arguments:
 *      rNode
 *          [I] If this function returns true, rNode is a copy of the first
 *          node in the queue. Unlike dequeProvider(), the first node is not
 *          removed from the queue.
 *  Return:
 *      false if the queue is empty.
 *      true if the queue is not empty.
*******************************************************************************/
bool
ImgBufQueue::
queryProvider(ImgBufQueNode& rNode)
{
    bool ret = false;
    //
    Mutex::Autolock _lock(mTodoImgBufQueMtx);
    //
    if  ( ! mTodoImgBufQue.empty() )
    {
        //  If the queue is not empty, return a copy of the first buffer.
        ret = true;
        rNode = *mTodoImgBufQue.begin();
    }
    else
    {
        MY_LOGD_IF(0, "Empty Que");
    }
    //
    return ret;
}
/******************************************************************************
*   REPEAT:[ dequeProvider() -> enqueProvider() ]
*   dequeProvider() returns false immediately if empty.
*******************************************************************************/
bool
ImgBufQueue::
dequeProvider(ImgBufQueNode& rNode)
{
    bool ret = false;
    //
    Mutex::Autolock _lock(mTodoImgBufQueMtx);
    //
    if  ( ! mTodoImgBufQue.empty() )
    {
        //  If the queue is not empty, take the first buffer from the queue.
        ret = true;
        rNode = *mTodoImgBufQue.begin();
        mTodoImgBufQue.erase(mTodoImgBufQue.begin());
    }
    else
    {
        MY_LOGD_IF(ENABLE_LOG_PER_FRAME, "Empty Que");
    }
    //
    return ret;
}