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

Commit cf207b63 authored by Android (Google) Code Review's avatar Android (Google) Code Review
Browse files

Merge change 22651 into eclair

* changes:
  Implement java interface for RS shutdown and fix shutdown deadlock with the command fifo.
parents f96d49a2 f5b4596a
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -206,6 +206,13 @@ public class RenderScript {
        }
    }

    public void destroy() {
        nContextDestroy(mContext);
        mContext = 0;

        nDeviceDestroy(mDev);
        mDev = 0;
    }

    //////////////////////////////////////////////////////////////////////////////////
    // Triangle Mesh
+4 −0
Original line number Diff line number Diff line
@@ -243,11 +243,13 @@ void * Context::threadProc(void *vrsc)
         }
     }

     LOGV("RS Thread exiting");
     glClearColor(0,0,0,0);
     glClear(GL_COLOR_BUFFER_BIT);
     eglSwapBuffers(rsc->mEGL.mDisplay, rsc->mEGL.mSurface);
     eglTerminate(rsc->mEGL.mDisplay);
     rsc->objDestroyOOBRun();
     LOGV("RS Thread exited");
     return NULL;
}

@@ -298,9 +300,11 @@ Context::Context(Device *dev, Surface *sur, bool useDepth)

Context::~Context()
{
    LOGV("Context::~Context");
    mExit = true;
    void *res;

    mIO.shutdown();
    int status = pthread_join(mThreadId, &res);
    objDestroyOOBRun();

+15 −4
Original line number Diff line number Diff line
@@ -25,6 +25,16 @@ LocklessCommandFifo::LocklessCommandFifo()

LocklessCommandFifo::~LocklessCommandFifo()
{
    if (!mInShutdown) {
        shutdown();
    }
    free(mBuffer);
}

void LocklessCommandFifo::shutdown()
{
    mInShutdown = true;
    mSignalToWorker.set();
}

bool LocklessCommandFifo::init(uint32_t sizeInBytes)
@@ -42,6 +52,7 @@ bool LocklessCommandFifo::init(uint32_t sizeInBytes)
        return false;
    }

    mInShutdown = false;
    mSize = sizeInBytes;
    mPut = mBuffer;
    mGet = mBuffer;
@@ -115,7 +126,7 @@ const void * LocklessCommandFifo::get(uint32_t *command, uint32_t *bytesData)
{
    while(1) {
        //dumpState("get");
        while(isEmpty()) {
        while(isEmpty() && !mInShutdown) {
            mSignalToControl.set();
            mSignalToWorker.wait();
        }
+4 −2
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ class LocklessCommandFifo
{
public:
    bool init(uint32_t size);
    void shutdown();

    LocklessCommandFifo();
    ~LocklessCommandFifo();
@@ -59,6 +60,7 @@ protected:
    uint8_t * mBuffer;
    uint8_t * mEnd;
    uint8_t mSize;
    bool mInShutdown;

    Signal mSignalToWorker;
    Signal mSignalToControl;
+5 −0
Original line number Diff line number Diff line
@@ -30,6 +30,11 @@ ThreadIO::~ThreadIO()
{
}

void ThreadIO::shutdown()
{
    mToCore.shutdown();
}

bool ThreadIO::playCoreCommands(Context *con, bool waitForCommand)
{
    bool ret = false;
Loading