Merge "Antialiasing for rectangles"
diff --git a/CleanSpec.mk b/CleanSpec.mk
index 50292e4..b19bed0 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -97,7 +97,7 @@
 $(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/core/java/android/hardware/IUsbManager.java)
 $(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/core/java/android/nfc)
 $(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework_intermediates)
-
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libstagefright_intermediates)
 # ************************************************
 # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
 # ************************************************
diff --git a/core/java/android/net/RouteInfo.java b/core/java/android/net/RouteInfo.java
index 9c4e48b..39e708a 100644
--- a/core/java/android/net/RouteInfo.java
+++ b/core/java/android/net/RouteInfo.java
@@ -47,13 +47,25 @@
     public RouteInfo(LinkAddress destination, InetAddress gateway) {
         if (destination == null) {
             try {
-                if ((gateway != null) || (gateway instanceof Inet4Address)) {
-                    destination = new LinkAddress(Inet4Address.ANY, 0);
+                if (gateway != null) {
+                    if (gateway instanceof Inet4Address) {
+                        destination = new LinkAddress(Inet4Address.ANY, 0);
+                    } else {
+                        destination = new LinkAddress(Inet6Address.ANY, 0);
+                    }
                 } else {
-                    destination = new LinkAddress(Inet6Address.ANY, 0);
+                    // no destination, no gateway. invalid.
+                    throw new RuntimeException("Invalid arguments passed in.");
                 }
             } catch (Exception e) {}
         }
+        if (gateway == null) {
+            if (destination.getAddress() instanceof Inet4Address) {
+                gateway = Inet4Address.ANY;
+            } else {
+                gateway = Inet6Address.ANY;
+            }
+        }
         mDestination = new LinkAddress(NetworkUtils.getNetworkPart(destination.getAddress(),
                 destination.getNetworkPrefixLength()), destination.getNetworkPrefixLength());
         mGateway = gateway;
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index 0acd748..68c9904 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -4380,15 +4380,20 @@
     }
 
     WebViewCore.CursorData cursorData() {
-        WebViewCore.CursorData result = new WebViewCore.CursorData();
-        result.mMoveGeneration = nativeMoveGeneration();
-        result.mFrame = nativeCursorFramePointer();
+        WebViewCore.CursorData result = cursorDataNoPosition();
         Point position = nativeCursorPosition();
         result.mX = position.x;
         result.mY = position.y;
         return result;
     }
 
+    WebViewCore.CursorData cursorDataNoPosition() {
+        WebViewCore.CursorData result = new WebViewCore.CursorData();
+        result.mMoveGeneration = nativeMoveGeneration();
+        result.mFrame = nativeCursorFramePointer();
+        return result;
+    }
+
     /**
      *  Delete text from start to end in the focused textfield. If there is no
      *  focus, or if start == end, silently fail.  If start and end are out of
@@ -5588,6 +5593,18 @@
     private static final int DRAG_LAYER_FINGER_DISTANCE = 20000;
 
     @Override
+    public boolean onHoverEvent(MotionEvent event) {
+        if (mNativeClass == 0) {
+            return false;
+        }
+        WebViewCore.CursorData data = cursorDataNoPosition();
+        data.mX = viewToContentX((int) event.getX());
+        data.mY = viewToContentY((int) event.getY());
+        mWebViewCore.sendMessage(EventHub.SET_MOVE_MOUSE, data);
+        return true;
+    }
+
+    @Override
     public boolean onTouchEvent(MotionEvent ev) {
         if (mNativeClass == 0 || (!isClickable() && !isLongClickable())) {
             return false;
diff --git a/libs/rs/driver/rsdGL.cpp b/libs/rs/driver/rsdGL.cpp
index 48690d5..de9fb51 100644
--- a/libs/rs/driver/rsdGL.cpp
+++ b/libs/rs/driver/rsdGL.cpp
@@ -30,11 +30,8 @@
 #include <GLES2/gl2.h>
 #include <GLES2/gl2ext.h>
 
-//#include <cutils/sched_policy.h>
-//#include <sys/syscall.h>
 #include <string.h>
 
-
 #include "rsdCore.h"
 #include "rsdGL.h"
 
@@ -346,3 +343,27 @@
     eglSwapBuffers(dc->gl.egl.display, dc->gl.egl.surface);
 }
 
+void rsdGLCheckError(const android::renderscript::Context *rsc,
+                     const char *msg, bool isFatal) {
+    GLenum err = glGetError();
+    if (err != GL_NO_ERROR) {
+        char buf[1024];
+        snprintf(buf, sizeof(buf), "GL Error = 0x%08x, from: %s", err, msg);
+
+        if (isFatal) {
+            rsc->setError(RS_ERROR_FATAL_DRIVER, buf);
+        } else {
+            switch (err) {
+            case GL_OUT_OF_MEMORY:
+                rsc->setError(RS_ERROR_OUT_OF_MEMORY, buf);
+                break;
+            default:
+                rsc->setError(RS_ERROR_DRIVER, buf);
+                break;
+            }
+        }
+
+        LOGE("%p, %s", rsc, buf);
+    }
+
+}
diff --git a/libs/rs/driver/rsdGL.h b/libs/rs/driver/rsdGL.h
index 351b2d5..90cbe04 100644
--- a/libs/rs/driver/rsdGL.h
+++ b/libs/rs/driver/rsdGL.h
@@ -76,6 +76,8 @@
 bool rsdGLSetSurface(const android::renderscript::Context *rsc,
                      uint32_t w, uint32_t h, ANativeWindow *sur);
 void rsdGLSwap(const android::renderscript::Context *rsc);
+void rsdGLCheckError(const android::renderscript::Context *rsc,
+                     const char *msg, bool isFatal = false);
 
 #endif
 
diff --git a/libs/rs/driver/rsdMeshObj.cpp b/libs/rs/driver/rsdMeshObj.cpp
index 6bb33f7..2c07784 100644
--- a/libs/rs/driver/rsdMeshObj.cpp
+++ b/libs/rs/driver/rsdMeshObj.cpp
@@ -23,6 +23,7 @@
 #include <rsMesh.h>
 
 #include "rsdMeshObj.h"
+#include "rsdGL.h"
 
 using namespace android;
 using namespace android::renderscript;
@@ -134,7 +135,7 @@
         return;
     }
 
-    rsc->checkError("Mesh::renderPrimitiveRange 1");
+    rsdGLCheckError(rsc, "Mesh::renderPrimitiveRange 1");
     // update attributes with either buffer information or data ptr based on their current state
     for (uint32_t ct=0; ct < mAttribCount; ct++) {
         uint32_t allocIndex = mAttribAllocationIndex[ct];
@@ -149,9 +150,9 @@
     }
 
     RsdVertexArray va(mAttribs, mAttribCount);
-    va.setupGL2(rsc);
+    va.setup(rsc);
 
-    rsc->checkError("Mesh::renderPrimitiveRange 2");
+    rsdGLCheckError(rsc, "Mesh::renderPrimitiveRange 2");
     Mesh::Primitive_t *prim = mRSMesh->mHal.state.primitives[primIndex];
     if (prim->mIndexBuffer.get()) {
         glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, prim->mIndexBuffer->getBufferObjectID());
@@ -160,7 +161,7 @@
         glDrawArrays(mGLPrimitives[primIndex], start, len);
     }
 
-    rsc->checkError("Mesh::renderPrimitiveRange");
+    rsdGLCheckError(rsc, "Mesh::renderPrimitiveRange");
 }
 
 void RsdMeshObj::updateGLPrimitives() {
diff --git a/libs/rs/driver/rsdShader.cpp b/libs/rs/driver/rsdShader.cpp
index 1710a8b..371266b 100644
--- a/libs/rs/driver/rsdShader.cpp
+++ b/libs/rs/driver/rsdShader.cpp
@@ -377,7 +377,7 @@
         glTexParameterf(target, GL_TEXTURE_MAX_ANISOTROPY_EXT, anisoValue);
     }
 
-    rsc->checkError("Sampler::setupGL2 tex env");
+    rsdGLCheckError(rsc, "Sampler::setup tex env");
 }
 
 void RsdShader::setupTextures(const Context *rsc, RsdShaderCache *sc) {
@@ -385,8 +385,10 @@
         return;
     }
 
+    RsdHal *dc = (RsdHal *)rsc->mHal.drv;
+
     uint32_t numTexturesToBind = mRSProgram->mHal.state.texturesCount;
-    uint32_t numTexturesAvailable = rsc->getMaxFragmentTextures();
+    uint32_t numTexturesAvailable = dc->gl.gl.maxFragmentTextureImageUnits;
     if (numTexturesToBind >= numTexturesAvailable) {
         LOGE("Attempting to bind %u textures on shader id %u, but only %u are available",
              mRSProgram->mHal.state.texturesCount, (uint32_t)this, numTexturesAvailable);
@@ -408,7 +410,7 @@
             rsc->setError(RS_ERROR_BAD_SHADER, "Non-texture allocation bound to a shader");
         }
         glBindTexture(target, mRSProgram->mHal.state.textures[ct]->getTextureID());
-        rsc->checkError("ProgramFragment::setupGL2 tex bind");
+        rsdGLCheckError(rsc, "ProgramFragment::setup tex bind");
         if (mRSProgram->mHal.state.samplers[ct].get()) {
             setupSampler(rsc, mRSProgram->mHal.state.samplers[ct].get(), mRSProgram->mHal.state.textures[ct].get());
         } else {
@@ -416,16 +418,16 @@
             glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
             glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
             glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-            rsc->checkError("ProgramFragment::setupGL2 tex env");
+            rsdGLCheckError(rsc, "ProgramFragment::setup tex env");
         }
 
         glUniform1i(sc->fragUniformSlot(mTextureUniformIndexStart + ct), ct);
-        rsc->checkError("ProgramFragment::setupGL2 uniforms");
+        rsdGLCheckError(rsc, "ProgramFragment::setup uniforms");
     }
 
     glActiveTexture(GL_TEXTURE0);
     mDirty = false;
-    rsc->checkError("ProgramFragment::setupGL2");
+    rsdGLCheckError(rsc, "ProgramFragment::setup");
 }
 
 void RsdShader::setupUserConstants(const Context *rsc, RsdShaderCache *sc, bool isFragment) {
diff --git a/libs/rs/driver/rsdShaderCache.cpp b/libs/rs/driver/rsdShaderCache.cpp
index 18a8225..d11490c 100644
--- a/libs/rs/driver/rsdShaderCache.cpp
+++ b/libs/rs/driver/rsdShaderCache.cpp
@@ -19,6 +19,7 @@
 
 #include "rsdShader.h"
 #include "rsdShaderCache.h"
+#include "rsdGL.h"
 
 #include <GLES/gl.h>
 #include <GLES2/gl2.h>
@@ -128,7 +129,7 @@
             glUseProgram(mEntries[ct]->program);
             mCurrent = mEntries[ct];
             //LOGV("RsdShaderCache hit, using %i", ct);
-            rsc->checkError("RsdShaderCache::link (hit)");
+            rsdGLCheckError(rsc, "RsdShaderCache::link (hit)");
             return true;
         }
     }
@@ -230,7 +231,7 @@
 
     //LOGV("SC made program %i", e->program);
     glUseProgram(e->program);
-    rsc->checkError("RsdShaderCache::link (miss)");
+    rsdGLCheckError(rsc, "RsdShaderCache::link (miss)");
 
     return true;
 }
diff --git a/libs/rs/driver/rsdVertexArray.cpp b/libs/rs/driver/rsdVertexArray.cpp
index d0a5a54..62ec107 100644
--- a/libs/rs/driver/rsdVertexArray.cpp
+++ b/libs/rs/driver/rsdVertexArray.cpp
@@ -20,6 +20,7 @@
 #include <GLES/gl.h>
 #include <GLES2/gl2.h>
 
+#include "rsdGL.h"
 #include "rsdCore.h"
 #include "rsdVertexArray.h"
 #include "rsdShaderCache.h"
@@ -78,13 +79,13 @@
          mAttribs[idx].offset);
 }
 
-void RsdVertexArray::setupGL2(const Context *rsc) const {
+void RsdVertexArray::setup(const Context *rsc) const {
 
     RsdHal *dc = (RsdHal *)rsc->mHal.drv;
     RsdVertexArrayState *state = dc->gl.vertexArrayState;
     RsdShaderCache *sc = dc->gl.shaderCache;
 
-    rsc->checkError("RsdVertexArray::setupGL2 start");
+    rsdGLCheckError(rsc, "RsdVertexArray::setup start");
     uint32_t maxAttrs = state->mAttrsEnabledSize;
 
     for (uint32_t ct=1; ct < maxAttrs; ct++) {
@@ -94,7 +95,7 @@
         }
     }
 
-    rsc->checkError("RsdVertexArray::setupGL2 disabled");
+    rsdGLCheckError(rsc, "RsdVertexArray::setup disabled");
     for (uint32_t ct=0; ct < mCount; ct++) {
         int32_t slot = sc->vtxAttribSlot(mAttribs[ct].name);
         if (rsc->props.mLogShadersAttr) {
@@ -113,7 +114,7 @@
                               mAttribs[ct].stride,
                               mAttribs[ct].ptr + mAttribs[ct].offset);
     }
-    rsc->checkError("RsdVertexArray::setupGL2 done");
+    rsdGLCheckError(rsc, "RsdVertexArray::setup done");
 }
 ////////////////////////////////////////////
 RsdVertexArrayState::RsdVertexArrayState() {
diff --git a/libs/rs/driver/rsdVertexArray.h b/libs/rs/driver/rsdVertexArray.h
index 925a6ae..3e807a3 100644
--- a/libs/rs/driver/rsdVertexArray.h
+++ b/libs/rs/driver/rsdVertexArray.h
@@ -49,7 +49,7 @@
     RsdVertexArray(const Attrib *attribs, uint32_t numAttribs);
     virtual ~RsdVertexArray();
 
-    void setupGL2(const android::renderscript::Context *rsc) const;
+    void setup(const android::renderscript::Context *rsc) const;
     void logAttrib(uint32_t idx, uint32_t slot) const;
 
 protected:
diff --git a/libs/rs/rsAllocation.cpp b/libs/rs/rsAllocation.cpp
index b5f6f56..5b84ca6 100644
--- a/libs/rs/rsAllocation.cpp
+++ b/libs/rs/rsAllocation.cpp
@@ -209,7 +209,7 @@
         freeScriptMemory();
     }
 
-    rsc->checkError("Allocation::uploadToTexture");
+    //rsc->checkError("Allocation::uploadToTexture");
 #endif //ANDROID_RS_SERIALIZE
 }
 
@@ -334,7 +334,7 @@
     glBindBuffer(target, mBufferID);
     glBufferData(target, mHal.state.type->getSizeBytes(), getPtr(), GL_DYNAMIC_DRAW);
     glBindBuffer(target, 0);
-    rsc->checkError("Allocation::uploadToBufferObject");
+    //rsc->checkError("Allocation::uploadToBufferObject");
 #endif //ANDROID_RS_SERIALIZE
 }
 
diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp
index e2e14f2..98adabc 100644
--- a/libs/rs/rsContext.cpp
+++ b/libs/rs/rsContext.cpp
@@ -27,11 +27,6 @@
 
 #include <cutils/properties.h>
 
-#include <GLES/gl.h>
-#include <GLES/glext.h>
-#include <GLES2/gl2.h>
-#include <GLES2/gl2ext.h>
-
 #include <cutils/sched_policy.h>
 #include <sys/syscall.h>
 #include <string.h>
@@ -52,28 +47,6 @@
         return false;
     }
 
-    const char * ext = (const char *)glGetString(GL_EXTENSIONS);
-
-    glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &mGL.mMaxVertexAttribs);
-    glGetIntegerv(GL_MAX_VERTEX_UNIFORM_VECTORS, &mGL.mMaxVertexUniformVectors);
-    glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, &mGL.mMaxVertexTextureUnits);
-
-    glGetIntegerv(GL_MAX_VARYING_VECTORS, &mGL.mMaxVaryingVectors);
-    glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &mGL.mMaxTextureImageUnits);
-
-    glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &mGL.mMaxFragmentTextureImageUnits);
-    glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_VECTORS, &mGL.mMaxFragmentUniformVectors);
-
-    mGL.OES_texture_npot = NULL != strstr(ext, "GL_OES_texture_npot");
-    mGL.GL_IMG_texture_npot = NULL != strstr(ext, "GL_IMG_texture_npot");
-    mGL.GL_NV_texture_npot_2D_mipmap = NULL != strstr(ext, "GL_NV_texture_npot_2D_mipmap");
-    mGL.EXT_texture_max_aniso = 1.0f;
-    bool hasAniso = NULL != strstr(ext, "GL_EXT_texture_filter_anisotropic");
-    if (hasAniso) {
-        glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &mGL.EXT_texture_max_aniso);
-    }
-
-    LOGV("initGLThread end %p", this);
     pthread_mutex_unlock(&gInitMutex);
     return true;
 }
@@ -112,38 +85,11 @@
     return ret;
 }
 
-void Context::checkError(const char *msg, bool isFatal) const {
-
-    GLenum err = glGetError();
-    if (err != GL_NO_ERROR) {
-        char buf[1024];
-        snprintf(buf, sizeof(buf), "GL Error = 0x%08x, from: %s", err, msg);
-
-        if (isFatal) {
-            setError(RS_ERROR_FATAL_DRIVER, buf);
-        } else {
-            switch (err) {
-            case GL_OUT_OF_MEMORY:
-                setError(RS_ERROR_OUT_OF_MEMORY, buf);
-                break;
-            default:
-                setError(RS_ERROR_DRIVER, buf);
-                break;
-            }
-        }
-
-        LOGE("%p, %s", this, buf);
-    }
-}
-
 uint32_t Context::runRootScript() {
-    glViewport(0, 0, mWidth, mHeight);
-
     timerSet(RS_TIMER_SCRIPT);
     mStateFragmentStore.mLast.clear();
     uint32_t ret = runScript(mRootScript.get());
 
-    checkError("runRootScript");
     return ret;
 }
 
@@ -217,10 +163,10 @@
 bool Context::setupCheck() {
 
     mFragmentStore->setup(this, &mStateFragmentStore);
-    mFragment->setupGL2(this, &mStateFragment);
+    mFragment->setup(this, &mStateFragment);
     mRaster->setup(this, &mStateRaster);
-    mVertex->setupGL2(this, &mStateVertex);
-    mFBOCache.setupGL2(this);
+    mVertex->setup(this, &mStateVertex);
+    mFBOCache.setup(this);
     return true;
 }
 
@@ -406,7 +352,6 @@
         memset(&mUserSurfaceConfig, 0, sizeof(mUserSurfaceConfig));
     }
 
-    memset(&mGL, 0, sizeof(mGL));
     mIsGraphicsContext = sc != NULL;
 
     int status;
diff --git a/libs/rs/rsContext.h b/libs/rs/rsContext.h
index 107f639..1407b7e 100644
--- a/libs/rs/rsContext.h
+++ b/libs/rs/rsContext.h
@@ -42,9 +42,10 @@
 #include "rsgApiStructs.h"
 #include "rsLocklessFifo.h"
 
-#include <ui/egl/android_natives.h>
 #endif // ANDROID_RS_SERIALIZE
 
+class ANativeWindow;
+
 // ---------------------------------------------------------------------------
 namespace android {
 
@@ -197,43 +198,16 @@
     } props;
 
     void dumpDebug() const;
-    void checkError(const char *, bool isFatal = false) const;
     void setError(RsError e, const char *msg = NULL) const;
 
     mutable const ObjectBase * mObjHead;
 
-    bool ext_OES_texture_npot() const {return mGL.OES_texture_npot;}
-    bool ext_GL_IMG_texture_npot() const {return mGL.GL_IMG_texture_npot;}
-    bool ext_GL_NV_texture_npot_2D_mipmap() const {return mGL.GL_NV_texture_npot_2D_mipmap;}
-    float ext_texture_max_aniso() const {return mGL.EXT_texture_max_aniso; }
-    uint32_t getMaxFragmentTextures() const {return mGL.mMaxFragmentTextureImageUnits;}
-    uint32_t getMaxFragmentUniformVectors() const {return mGL.mMaxFragmentUniformVectors;}
-    uint32_t getMaxVertexUniformVectors() const {return mGL.mMaxVertexUniformVectors;}
-    uint32_t getMaxVertexAttributes() const {return mGL.mMaxVertexAttribs;}
-
     uint32_t getDPI() const {return mDPI;}
     void setDPI(uint32_t dpi) {mDPI = dpi;}
 
     Device *mDev;
 protected:
 
-    struct {
-        int32_t mMaxVaryingVectors;
-        int32_t mMaxTextureImageUnits;
-
-        int32_t mMaxFragmentTextureImageUnits;
-        int32_t mMaxFragmentUniformVectors;
-
-        int32_t mMaxVertexAttribs;
-        int32_t mMaxVertexUniformVectors;
-        int32_t mMaxVertexTextureUnits;
-
-        bool OES_texture_npot;
-        bool GL_IMG_texture_npot;
-        bool GL_NV_texture_npot_2D_mipmap;
-        float EXT_texture_max_aniso;
-    } mGL;
-
     uint32_t mDPI;
     uint32_t mWidth;
     uint32_t mHeight;
diff --git a/libs/rs/rsFBOCache.cpp b/libs/rs/rsFBOCache.cpp
index 78aa8ce..0f33f67 100644
--- a/libs/rs/rsFBOCache.cpp
+++ b/libs/rs/rsFBOCache.cpp
@@ -30,7 +30,7 @@
 
 FBOCache::FBOCache() {
     mFBOId = 0;
-    mDirty = false;
+    mDirty = true;
     mMaxTargets = 1;
     mColorTargets = new ObjectBaseRef<Allocation>[mMaxTargets];
 }
@@ -180,7 +180,7 @@
 #endif //ANDROID_RS_SERIALIZE
 }
 
-void FBOCache::setupGL2(Context *rsc) {
+void FBOCache::setup(Context *rsc) {
 #ifndef ANDROID_RS_SERIALIZE
     if (!mDirty) {
         return;
@@ -205,5 +205,6 @@
         glBindFramebuffer(GL_FRAMEBUFFER, 0);
         glViewport(0, 0, rsc->getWidth(), rsc->getHeight());
     }
+    mDirty = false;
 #endif //ANDROID_RS_SERIALIZE
 }
diff --git a/libs/rs/rsFBOCache.h b/libs/rs/rsFBOCache.h
index 9a0a3b6..c9ae1dc 100644
--- a/libs/rs/rsFBOCache.h
+++ b/libs/rs/rsFBOCache.h
@@ -34,7 +34,7 @@
     void bindDepthTarget(Context *, Allocation *a);
     void resetAll(Context *);
 
-    void setupGL2(Context *);
+    void setup(Context *);
 
 protected:
 
diff --git a/libs/rs/rsMesh.cpp b/libs/rs/rsMesh.cpp
index ed29063..35184c1 100644
--- a/libs/rs/rsMesh.cpp
+++ b/libs/rs/rsMesh.cpp
@@ -199,10 +199,8 @@
     if (prim->mIndexBuffer.get()) {
         prim->mIndexBuffer->uploadCheck(rsc);
     }
-    rsc->checkError("Mesh::renderPrimitiveRange upload check");
 
     mRSC->mHal.funcs.mesh.draw(mRSC, this, primIndex, start, len);
-    rsc->checkError("Mesh::renderPrimitiveRange draw");
 }
 
 void Mesh::uploadAll(Context *rsc) {
diff --git a/libs/rs/rsProgramFragment.cpp b/libs/rs/rsProgramFragment.cpp
index fcbfbc8..e40fc7b 100644
--- a/libs/rs/rsProgramFragment.cpp
+++ b/libs/rs/rsProgramFragment.cpp
@@ -55,14 +55,12 @@
     mDirty = true;
 }
 
-void ProgramFragment::setupGL2(Context *rsc, ProgramFragmentState *state) {
+void ProgramFragment::setup(Context *rsc, ProgramFragmentState *state) {
     if ((state->mLast.get() == this) && !mDirty) {
         return;
     }
     state->mLast.set(this);
 
-    rsc->checkError("ProgramFragment::setupGL2 start");
-
     for (uint32_t ct=0; ct < mHal.state.texturesCount; ct++) {
         if (!mHal.state.textures[ct].get()) {
             LOGE("No texture bound for shader id %u, texture unit %u", (uint)this, ct);
diff --git a/libs/rs/rsProgramFragment.h b/libs/rs/rsProgramFragment.h
index 7520af0..d6e20cd 100644
--- a/libs/rs/rsProgramFragment.h
+++ b/libs/rs/rsProgramFragment.h
@@ -32,7 +32,7 @@
                              uint32_t paramLength);
     virtual ~ProgramFragment();
 
-    virtual void setupGL2(Context *, ProgramFragmentState *);
+    virtual void setup(Context *, ProgramFragmentState *);
 
     virtual void serialize(OStream *stream) const;
     virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_PROGRAM_FRAGMENT; }
diff --git a/libs/rs/rsProgramVertex.cpp b/libs/rs/rsProgramVertex.cpp
index b8b3c0b..534e8a6 100644
--- a/libs/rs/rsProgramVertex.cpp
+++ b/libs/rs/rsProgramVertex.cpp
@@ -32,7 +32,7 @@
     mRSC->mHal.funcs.vertex.destroy(mRSC, this);
 }
 
-void ProgramVertex::setupGL2(Context *rsc, ProgramVertexState *state) {
+void ProgramVertex::setup(Context *rsc, ProgramVertexState *state) {
     if ((state->mLast.get() == this) && !mDirty) {
         return;
     }
diff --git a/libs/rs/rsProgramVertex.h b/libs/rs/rsProgramVertex.h
index 04224a7..5cfdd8b 100644
--- a/libs/rs/rsProgramVertex.h
+++ b/libs/rs/rsProgramVertex.h
@@ -31,7 +31,7 @@
                   const uint32_t * params, uint32_t paramLength);
     virtual ~ProgramVertex();
 
-    virtual void setupGL2(Context *rsc, ProgramVertexState *state);
+    virtual void setup(Context *rsc, ProgramVertexState *state);
 
     void setProjectionMatrix(Context *, const rsc_Matrix *) const;
     void getProjectionMatrix(Context *, rsc_Matrix *) const;
diff --git a/libs/rs/rsScriptC_LibGL.cpp b/libs/rs/rsScriptC_LibGL.cpp
index ecda485..3259cb4 100644
--- a/libs/rs/rsScriptC_LibGL.cpp
+++ b/libs/rs/rsScriptC_LibGL.cpp
@@ -156,7 +156,7 @@
     attribs[1].set(GL_FLOAT, 2, 8, false, (uint32_t)tex, "ATTRIB_texture0");
 
     RsdVertexArray va(attribs, 2);
-    va.setupGL2(rsc);
+    va.setup(rsc);
 
     glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
 }
@@ -250,7 +250,7 @@
 
 
 void rsrClearColor(Context *rsc, Script *sc, float r, float g, float b, float a) {
-    rsc->mFBOCache.setupGL2(rsc);
+    rsc->mFBOCache.setup(rsc);
     rsc->setupProgramStore();
 
     glClearColor(r, g, b, a);
@@ -258,7 +258,7 @@
 }
 
 void rsrClearDepth(Context *rsc, Script *sc, float v) {
-    rsc->mFBOCache.setupGL2(rsc);
+    rsc->mFBOCache.setup(rsc);
     rsc->setupProgramStore();
 
     glClearDepthf(v);
diff --git a/media/libmediaplayerservice/nuplayer/Android.mk b/media/libmediaplayerservice/nuplayer/Android.mk
index c20e279..e761509 100644
--- a/media/libmediaplayerservice/nuplayer/Android.mk
+++ b/media/libmediaplayerservice/nuplayer/Android.mk
@@ -8,7 +8,6 @@
         NuPlayerDriver.cpp              \
         NuPlayerRenderer.cpp            \
         NuPlayerStreamListener.cpp      \
-        DecoderWrapper.cpp              \
         StreamingSource.cpp             \
 
 LOCAL_C_INCLUDES := \
diff --git a/media/libmediaplayerservice/nuplayer/DecoderWrapper.cpp b/media/libmediaplayerservice/nuplayer/DecoderWrapper.cpp
deleted file mode 100644
index 802d1fb..0000000
--- a/media/libmediaplayerservice/nuplayer/DecoderWrapper.cpp
+++ /dev/null
@@ -1,576 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-//#define LOG_NDEBUG 0
-#define LOG_TAG "DecoderWrapper"
-#include <utils/Log.h>
-
-#include "DecoderWrapper.h"
-
-#include "AACDecoder.h"
-
-#include <media/stagefright/foundation/hexdump.h>
-#include <media/stagefright/foundation/ABuffer.h>
-#include <media/stagefright/foundation/ADebug.h>
-#include <media/stagefright/foundation/AMessage.h>
-#include <media/stagefright/ACodec.h>
-#include <media/stagefright/MediaBuffer.h>
-#include <media/stagefright/MediaDefs.h>
-#include <media/stagefright/MediaSource.h>
-#include <media/stagefright/MetaData.h>
-
-namespace android {
-
-struct DecoderWrapper::WrapperSource : public MediaSource {
-    WrapperSource(
-            const sp<MetaData> &meta,
-            const sp<AMessage> &notify);
-
-    virtual status_t start(MetaData *params);
-    virtual status_t stop();
-    virtual sp<MetaData> getFormat();
-
-    virtual status_t read(
-            MediaBuffer **buffer, const ReadOptions *options);
-
-    void queueBuffer(const sp<ABuffer> &buffer);
-    void queueEOS(status_t finalResult);
-    void clear();
-
-protected:
-    virtual ~WrapperSource();
-
-private:
-    Mutex mLock;
-    Condition mCondition;
-
-    sp<MetaData> mMeta;
-    sp<AMessage> mNotify;
-
-    List<sp<ABuffer> > mQueue;
-    status_t mFinalResult;
-
-    DISALLOW_EVIL_CONSTRUCTORS(WrapperSource);
-};
-
-DecoderWrapper::WrapperSource::WrapperSource(
-        const sp<MetaData> &meta, const sp<AMessage> &notify)
-    : mMeta(meta),
-      mNotify(notify),
-      mFinalResult(OK) {
-}
-
-DecoderWrapper::WrapperSource::~WrapperSource() {
-}
-
-status_t DecoderWrapper::WrapperSource::start(MetaData *params) {
-    return OK;
-}
-
-status_t DecoderWrapper::WrapperSource::stop() {
-    return OK;
-}
-
-sp<MetaData> DecoderWrapper::WrapperSource::getFormat() {
-    return mMeta;
-}
-
-status_t DecoderWrapper::WrapperSource::read(
-        MediaBuffer **out, const ReadOptions *options) {
-    Mutex::Autolock autoLock(mLock);
-
-    bool requestedBuffer = false;
-
-    while (mQueue.empty() && mFinalResult == OK) {
-        if (!requestedBuffer) {
-            mNotify->dup()->post();
-            requestedBuffer = true;
-        }
-
-        mCondition.wait(mLock);
-    }
-
-    if (mQueue.empty()) {
-        return mFinalResult;
-    }
-
-    sp<ABuffer> src = *mQueue.begin();
-    mQueue.erase(mQueue.begin());
-
-    MediaBuffer *dst = new MediaBuffer(src->size());
-    memcpy(dst->data(), src->data(), src->size());
-
-    int64_t timeUs;
-    CHECK(src->meta()->findInt64("timeUs", &timeUs));
-
-    dst->meta_data()->setInt64(kKeyTime, timeUs);
-
-    *out = dst;
-
-    return OK;
-}
-
-void DecoderWrapper::WrapperSource::queueBuffer(const sp<ABuffer> &buffer) {
-    Mutex::Autolock autoLock(mLock);
-    mQueue.push_back(buffer);
-    mCondition.broadcast();
-}
-
-void DecoderWrapper::WrapperSource::queueEOS(status_t finalResult) {
-    CHECK_NE(finalResult, (status_t)OK);
-
-    Mutex::Autolock autoLock(mLock);
-    mFinalResult = finalResult;
-    mCondition.broadcast();
-}
-
-void DecoderWrapper::WrapperSource::clear() {
-    Mutex::Autolock autoLock(mLock);
-    mQueue.clear();
-    mFinalResult = OK;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-
-struct DecoderWrapper::WrapperReader : public AHandler {
-    WrapperReader(
-            const sp<MediaSource> &decoder,
-            const sp<AMessage> &notify);
-
-    void start();
-    void stop();
-    void readMore(bool flush = false);
-
-protected:
-    virtual ~WrapperReader();
-
-    virtual void onMessageReceived(const sp<AMessage> &msg);
-
-private:
-    enum {
-        kWhatRead
-    };
-
-    sp<MediaSource> mDecoder;
-    sp<AMessage> mNotify;
-    bool mEOS;
-    bool mSentFormat;
-
-    void sendFormatChange();
-
-    DISALLOW_EVIL_CONSTRUCTORS(WrapperReader);
-};
-
-DecoderWrapper::WrapperReader::WrapperReader(
-        const sp<MediaSource> &decoder, const sp<AMessage> &notify)
-    : mDecoder(decoder),
-      mNotify(notify),
-      mEOS(false),
-      mSentFormat(false) {
-}
-
-DecoderWrapper::WrapperReader::~WrapperReader() {
-}
-
-void DecoderWrapper::WrapperReader::start() {
-    CHECK_EQ(mDecoder->start(), (status_t)OK);
-    readMore();
-}
-
-void DecoderWrapper::WrapperReader::stop() {
-    CHECK_EQ(mDecoder->stop(), (status_t)OK);
-}
-
-void DecoderWrapper::WrapperReader::readMore(bool flush) {
-    if (!flush && mEOS) {
-        return;
-    }
-
-    sp<AMessage> msg = new AMessage(kWhatRead, id());
-    msg->setInt32("flush", static_cast<int32_t>(flush));
-    msg->post();
-}
-
-void DecoderWrapper::WrapperReader::onMessageReceived(
-        const sp<AMessage> &msg) {
-    switch (msg->what()) {
-        case kWhatRead:
-        {
-            int32_t flush;
-            CHECK(msg->findInt32("flush", &flush));
-
-            MediaSource::ReadOptions options;
-            if (flush) {
-                // Dummy seek
-                options.setSeekTo(0);
-                mEOS = false;
-            }
-
-            CHECK(!mEOS);
-
-            MediaBuffer *src;
-            status_t err = mDecoder->read(&src, &options);
-
-            if (err == OK) {
-                if (!mSentFormat) {
-                    sendFormatChange();
-                    mSentFormat = true;
-                }
-
-                sp<AMessage> notify = mNotify->dup();
-
-                sp<AMessage> realNotify;
-                CHECK(notify->findMessage("real-notify", &realNotify));
-
-                realNotify->setInt32("what", ACodec::kWhatDrainThisBuffer);
-
-                sp<ABuffer> dst = new ABuffer(src->range_length());
-                memcpy(dst->data(),
-                       (const uint8_t *)src->data() + src->range_offset(),
-                       src->range_length());
-
-                int64_t timeUs;
-                CHECK(src->meta_data()->findInt64(kKeyTime, &timeUs));
-                src->release();
-                src = NULL;
-
-                dst->meta()->setInt64("timeUs", timeUs);
-
-                realNotify->setObject("buffer", dst);
-
-                notify->post();
-            } else if (err == INFO_FORMAT_CHANGED) {
-                sendFormatChange();
-
-                readMore(false /* flush */);
-            } else {
-                sp<AMessage> notify = mNotify->dup();
-
-                sp<AMessage> realNotify;
-                CHECK(notify->findMessage("real-notify", &realNotify));
-
-                realNotify->setInt32("what", ACodec::kWhatEOS);
-                mEOS = true;
-
-                notify->post();
-            }
-            break;
-        }
-
-        default:
-            TRESPASS();
-            break;
-    }
-}
-
-void DecoderWrapper::WrapperReader::sendFormatChange() {
-    sp<AMessage> notify = mNotify->dup();
-
-    sp<AMessage> realNotify;
-    CHECK(notify->findMessage("real-notify", &realNotify));
-
-    realNotify->setInt32("what", ACodec::kWhatOutputFormatChanged);
-
-    sp<MetaData> meta = mDecoder->getFormat();
-
-    const char *mime;
-    CHECK(meta->findCString(kKeyMIMEType, &mime));
-
-    realNotify->setString("mime", mime);
-
-    if (!strncasecmp("audio/", mime, 6)) {
-        int32_t numChannels;
-        CHECK(meta->findInt32(kKeyChannelCount, &numChannels));
-
-        int32_t sampleRate;
-        CHECK(meta->findInt32(kKeySampleRate, &sampleRate));
-
-        realNotify->setInt32("channel-count", numChannels);
-        realNotify->setInt32("sample-rate", sampleRate);
-    } else {
-        CHECK(!strncasecmp("video/", mime, 6));
-
-        int32_t width, height;
-        CHECK(meta->findInt32(kKeyWidth, &width));
-        CHECK(meta->findInt32(kKeyHeight, &height));
-
-        realNotify->setInt32("width", width);
-        realNotify->setInt32("height", height);
-
-        int32_t cropLeft, cropTop, cropRight, cropBottom;
-        if (!meta->findRect(
-                    kKeyCropRect,
-                    &cropLeft, &cropTop, &cropRight, &cropBottom)) {
-            cropLeft = 0;
-            cropTop = 0;
-            cropRight = width - 1;
-            cropBottom = height - 1;
-        }
-
-        realNotify->setRect("crop", cropLeft, cropTop, cropRight, cropBottom);
-    }
-
-    notify->post();
-
-    mSentFormat = true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-
-DecoderWrapper::DecoderWrapper()
-    : mNumOutstandingInputBuffers(0),
-      mNumOutstandingOutputBuffers(0),
-      mNumPendingDecodes(0),
-      mFlushing(false) {
-}
-
-DecoderWrapper::~DecoderWrapper() {
-}
-
-void DecoderWrapper::setNotificationMessage(const sp<AMessage> &msg) {
-    mNotify = msg;
-}
-
-void DecoderWrapper::initiateSetup(const sp<AMessage> &msg) {
-    msg->setWhat(kWhatSetup);
-    msg->setTarget(id());
-    msg->post();
-}
-
-void DecoderWrapper::initiateShutdown() {
-    (new AMessage(kWhatShutdown, id()))->post();
-}
-
-void DecoderWrapper::signalFlush() {
-    (new AMessage(kWhatFlush, id()))->post();
-}
-
-void DecoderWrapper::signalResume() {
-    (new AMessage(kWhatResume, id()))->post();
-}
-
-void DecoderWrapper::onMessageReceived(const sp<AMessage> &msg) {
-    switch (msg->what()) {
-        case kWhatSetup:
-            onSetup(msg);
-            break;
-
-        case kWhatShutdown:
-            onShutdown();
-            break;
-
-        case kWhatInputDataRequested:
-        {
-            postFillBuffer();
-            ++mNumOutstandingInputBuffers;
-            break;
-        }
-
-        case kWhatInputBufferFilled:
-        {
-            CHECK_GT(mNumOutstandingInputBuffers, 0);
-            --mNumOutstandingInputBuffers;
-
-            if (mFlushing) {
-                mSource->queueEOS(INFO_DISCONTINUITY);
-
-                completeFlushIfPossible();
-                break;
-            }
-
-            sp<RefBase> obj;
-            if (!msg->findObject("buffer", &obj)) {
-                int32_t err = OK;
-                CHECK(msg->findInt32("err", &err));
-
-                mSource->queueEOS(err);
-                break;
-            }
-
-            sp<ABuffer> buffer = static_cast<ABuffer *>(obj.get());
-
-            mSource->queueBuffer(buffer);
-            break;
-        }
-
-        case kWhatFillBufferDone:
-        {
-            sp<AMessage> notify;
-            CHECK(msg->findMessage("real-notify", &notify));
-
-            int32_t what;
-            CHECK(notify->findInt32("what", &what));
-
-            if (what == ACodec::kWhatDrainThisBuffer) {
-                CHECK_GT(mNumPendingDecodes, 0);
-                --mNumPendingDecodes;
-
-                sp<AMessage> reply =
-                    new AMessage(kWhatOutputBufferDrained, id());
-
-                notify->setMessage("reply", reply);
-
-                ++mNumOutstandingOutputBuffers;
-            } else if (what == ACodec::kWhatEOS) {
-                CHECK_GT(mNumPendingDecodes, 0);
-                --mNumPendingDecodes;
-
-                if (mFlushing) {
-                    completeFlushIfPossible();
-                    break;
-                }
-            }
-
-            notify->post();
-            break;
-        }
-
-        case kWhatOutputBufferDrained:
-        {
-            CHECK_GT(mNumOutstandingOutputBuffers, 0);
-            --mNumOutstandingOutputBuffers;
-
-            if (mFlushing) {
-                completeFlushIfPossible();
-                break;
-            }
-
-            ++mNumPendingDecodes;
-            mReader->readMore();
-            break;
-        }
-
-        case kWhatFlush:
-        {
-            onFlush();
-            break;
-        }
-
-        case kWhatResume:
-        {
-            onResume();
-            break;
-        }
-
-        default:
-            TRESPASS();
-            break;
-    }
-}
-
-void DecoderWrapper::onSetup(const sp<AMessage> &msg) {
-    AString mime;
-    CHECK(msg->findString("mime", &mime));
-
-    CHECK(!strcasecmp(mime.c_str(), MEDIA_MIMETYPE_AUDIO_AAC));
-
-    int32_t numChannels, sampleRate;
-    CHECK(msg->findInt32("channel-count", &numChannels));
-    CHECK(msg->findInt32("sample-rate", &sampleRate));
-
-    sp<RefBase> obj;
-    CHECK(msg->findObject("esds", &obj));
-    sp<ABuffer> esds = static_cast<ABuffer *>(obj.get());
-
-    sp<MetaData> meta = new MetaData;
-    meta->setCString(kKeyMIMEType, mime.c_str());
-    meta->setInt32(kKeySampleRate, sampleRate);
-    meta->setInt32(kKeyChannelCount, numChannels);
-    meta->setData(kKeyESDS, 0, esds->data(), esds->size());
-
-    mSource = new WrapperSource(
-            meta, new AMessage(kWhatInputDataRequested, id()));
-
-    sp<MediaSource> decoder = new AACDecoder(mSource);
-
-    mReaderLooper = new ALooper;
-    mReaderLooper->setName("DecoderWrapper looper");
-
-    mReaderLooper->start(
-            false, /* runOnCallingThread */
-            false, /* canCallJava */
-            PRIORITY_AUDIO);
-
-    sp<AMessage> notify = new AMessage(kWhatFillBufferDone, id());
-    notify->setMessage("real-notify", mNotify);
-
-    mReader = new WrapperReader(decoder, notify);
-    mReaderLooper->registerHandler(mReader);
-
-    mReader->start();
-    ++mNumPendingDecodes;
-}
-
-void DecoderWrapper::onShutdown() {
-    mReaderLooper->stop();
-    mReaderLooper.clear();
-
-    mReader->stop();
-    mReader.clear();
-
-    mSource.clear();
-
-    mNumOutstandingInputBuffers = 0;
-    mNumOutstandingOutputBuffers = 0;
-    mNumPendingDecodes = 0;
-    mFlushing = false;
-
-    sp<AMessage> notify = mNotify->dup();
-    notify->setInt32("what", ACodec::kWhatShutdownCompleted);
-    notify->post();
-}
-
-void DecoderWrapper::postFillBuffer() {
-    sp<AMessage> notify = mNotify->dup();
-    notify->setInt32("what", ACodec::kWhatFillThisBuffer);
-    sp<AMessage> reply = new AMessage(kWhatInputBufferFilled, id());
-    notify->setMessage("reply", reply);
-    notify->post();
-}
-
-void DecoderWrapper::onFlush() {
-    CHECK(!mFlushing);
-    mFlushing = true;
-
-    completeFlushIfPossible();
-}
-
-void DecoderWrapper::completeFlushIfPossible() {
-    CHECK(mFlushing);
-
-    if (mNumOutstandingInputBuffers > 0
-            || mNumOutstandingOutputBuffers > 0
-            || mNumPendingDecodes > 0) {
-        return;
-    }
-
-    mFlushing = false;
-
-    sp<AMessage> notify = mNotify->dup();
-    notify->setInt32("what", ACodec::kWhatFlushCompleted);
-    notify->post();
-}
-
-void DecoderWrapper::onResume() {
-    CHECK(!mFlushing);
-
-    ++mNumPendingDecodes;
-
-    mSource->clear();
-    mReader->readMore(true /* flush */);
-}
-
-}  // namespace android
diff --git a/media/libmediaplayerservice/nuplayer/DecoderWrapper.h b/media/libmediaplayerservice/nuplayer/DecoderWrapper.h
deleted file mode 100644
index b9be12c..0000000
--- a/media/libmediaplayerservice/nuplayer/DecoderWrapper.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef DECODER_WRAPPER_H_
-
-#define DECODER_WRAPPER_H_
-
-#include <media/stagefright/foundation/AHandler.h>
-
-namespace android {
-
-struct MediaSource;
-
-struct DecoderWrapper : public AHandler {
-    DecoderWrapper();
-
-    void setNotificationMessage(const sp<AMessage> &msg);
-    void initiateSetup(const sp<AMessage> &msg);
-    void initiateShutdown();
-    void signalFlush();
-    void signalResume();
-
-protected:
-    virtual ~DecoderWrapper();
-
-    virtual void onMessageReceived(const sp<AMessage> &msg);
-
-private:
-    struct WrapperSource;
-    struct WrapperReader;
-
-    enum {
-        kWhatSetup,
-        kWhatInputBufferFilled,
-        kWhatOutputBufferDrained,
-        kWhatShutdown,
-        kWhatFillBufferDone,
-        kWhatInputDataRequested,
-        kWhatFlush,
-        kWhatResume,
-    };
-
-    sp<AMessage> mNotify;
-
-    sp<WrapperSource> mSource;
-
-    sp<ALooper> mReaderLooper;
-    sp<WrapperReader> mReader;
-
-    int32_t mNumOutstandingInputBuffers;
-    int32_t mNumOutstandingOutputBuffers;
-    int32_t mNumPendingDecodes;
-    bool mFlushing;
-
-    void onSetup(const sp<AMessage> &msg);
-    void onShutdown();
-    void onFlush();
-    void onResume();
-
-    void postFillBuffer();
-    void completeFlushIfPossible();
-
-    DISALLOW_EVIL_CONSTRUCTORS(DecoderWrapper);
-};
-
-}  // namespace android
-
-#endif  // DECODER_WRAPPER_H_
-
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp b/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp
index 517acc9..81b41ef 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp
+++ b/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp
@@ -20,7 +20,6 @@
 
 #include "NuPlayerDecoder.h"
 
-#include "DecoderWrapper.h"
 #include "ESDS.h"
 
 #include <media/stagefright/foundation/ABuffer.h>
@@ -47,7 +46,6 @@
 
 void NuPlayer::Decoder::configure(const sp<MetaData> &meta) {
     CHECK(mCodec == NULL);
-    CHECK(mWrapper == NULL);
 
     const char *mime;
     CHECK(meta->findCString(kKeyMIMEType, &mime));
@@ -61,19 +59,11 @@
         format->setObject("native-window", mNativeWindow);
     }
 
-    if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AAC)) {
-        mWrapper = new DecoderWrapper;
-        looper()->registerHandler(mWrapper);
+    mCodec = new ACodec;
+    looper()->registerHandler(mCodec);
 
-        mWrapper->setNotificationMessage(notifyMsg);
-        mWrapper->initiateSetup(format);
-    } else {
-        mCodec = new ACodec;
-        looper()->registerHandler(mCodec);
-
-        mCodec->setNotificationMessage(notifyMsg);
-        mCodec->initiateSetup(format);
-    }
+    mCodec->setNotificationMessage(notifyMsg);
+    mCodec->initiateSetup(format);
 }
 
 void NuPlayer::Decoder::onMessageReceived(const sp<AMessage> &msg) {
@@ -214,7 +204,6 @@
 
         msg->setObject("csd", buffer);
     } else if (meta->findData(kKeyESDS, &type, &data, &size)) {
-#if 0
         ESDS esds((const char *)data, size);
         CHECK_EQ(esds.InitCheck(), (status_t)OK);
 
@@ -230,12 +219,6 @@
 
         buffer->meta()->setInt32("csd", true);
         mCSD.push(buffer);
-#else
-        sp<ABuffer> buffer = new ABuffer(size);
-        memcpy(buffer->data(), data, size);
-
-        msg->setObject("esds", buffer);
-#endif
     }
 
     return msg;
@@ -270,27 +253,18 @@
 void NuPlayer::Decoder::signalFlush() {
     if (mCodec != NULL) {
         mCodec->signalFlush();
-    } else {
-        CHECK(mWrapper != NULL);
-        mWrapper->signalFlush();
     }
 }
 
 void NuPlayer::Decoder::signalResume() {
     if (mCodec != NULL) {
         mCodec->signalResume();
-    } else {
-        CHECK(mWrapper != NULL);
-        mWrapper->signalResume();
     }
 }
 
 void NuPlayer::Decoder::initiateShutdown() {
     if (mCodec != NULL) {
         mCodec->initiateShutdown();
-    } else {
-        CHECK(mWrapper != NULL);
-        mWrapper->initiateShutdown();
     }
 }
 
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.h b/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.h
index 732f090..fabc606 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.h
+++ b/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.h
@@ -25,7 +25,6 @@
 namespace android {
 
 struct ABuffer;
-struct DecoderWrapper;
 
 struct NuPlayer::Decoder : public AHandler {
     Decoder(const sp<AMessage> &notify,
@@ -51,7 +50,6 @@
     sp<NativeWindowWrapper> mNativeWindow;
 
     sp<ACodec> mCodec;
-    sp<DecoderWrapper> mWrapper;
 
     Vector<sp<ABuffer> > mCSD;
     size_t mCSDIndex;
diff --git a/media/libstagefright/Android.mk b/media/libstagefright/Android.mk
index d8cf810..f731dfb 100644
--- a/media/libstagefright/Android.mk
+++ b/media/libstagefright/Android.mk
@@ -3,7 +3,7 @@
 
 include frameworks/base/media/libstagefright/codecs/common/Config.mk
 
-BUILD_WITH_SOFTWARE_DECODERS := true
+BUILD_WITH_SOFTWARE_DECODERS := false
 
 LOCAL_SRC_FILES:=                         \
         ACodec.cpp                        \
diff --git a/media/libstagefright/SampleTable.cpp b/media/libstagefright/SampleTable.cpp
index ef4d3d0..eb135ab 100644
--- a/media/libstagefright/SampleTable.cpp
+++ b/media/libstagefright/SampleTable.cpp
@@ -220,7 +220,7 @@
             return ERROR_MALFORMED;
         }
 
-        mSampleSizeFieldSize = mDefaultSampleSize & 0xf;
+        mSampleSizeFieldSize = mDefaultSampleSize & 0xff;
         mDefaultSampleSize = 0;
 
         if (mSampleSizeFieldSize != 4 && mSampleSizeFieldSize != 8