am c0ef548c: am d75961ee: am b4cee0f8: Merge "stagefright aacenc/amrwbenc: Remove trailing whitespace"

* commit 'c0ef548c748f0c3bc917eff7b50941f9cbe1df86':
  stagefright aacenc/amrwbenc: Remove trailing whitespace
diff --git a/camera/Camera.cpp b/camera/Camera.cpp
index 7ac3cc1..ee458f1 100644
--- a/camera/Camera.cpp
+++ b/camera/Camera.cpp
@@ -47,7 +47,7 @@
             binder = sm->getService(String16("media.camera"));
             if (binder != 0)
                 break;
-            LOGW("CameraService not published, waiting...");
+            ALOGW("CameraService not published, waiting...");
             usleep(500000); // 0.5 s
         } while(true);
         if (mDeathNotifier == NULL) {
@@ -56,7 +56,7 @@
         binder->linkToDeath(mDeathNotifier);
         mCameraService = interface_cast<ICameraService>(binder);
     }
-    LOGE_IF(mCameraService==0, "no CameraService!?");
+    ALOGE_IF(mCameraService==0, "no CameraService!?");
     return mCameraService;
 }
 
@@ -70,9 +70,9 @@
 // construct a camera client from an existing camera remote
 sp<Camera> Camera::create(const sp<ICamera>& camera)
 {
-     LOGV("create");
+     ALOGV("create");
      if (camera == 0) {
-         LOGE("camera remote is a NULL pointer");
+         ALOGE("camera remote is a NULL pointer");
          return 0;
      }
 
@@ -117,7 +117,7 @@
 
 sp<Camera> Camera::connect(int cameraId)
 {
-    LOGV("connect");
+    ALOGV("connect");
     sp<Camera> c = new Camera();
     const sp<ICameraService>& cs = getCameraService();
     if (cs != 0) {
@@ -134,7 +134,7 @@
 
 void Camera::disconnect()
 {
-    LOGV("disconnect");
+    ALOGV("disconnect");
     if (mCamera != 0) {
         mCamera->disconnect();
         mCamera->asBinder()->unlinkToDeath(this);
@@ -144,7 +144,7 @@
 
 status_t Camera::reconnect()
 {
-    LOGV("reconnect");
+    ALOGV("reconnect");
     sp <ICamera> c = mCamera;
     if (c == 0) return NO_INIT;
     return c->connect(this);
@@ -172,13 +172,13 @@
 // pass the buffered Surface to the camera service
 status_t Camera::setPreviewDisplay(const sp<Surface>& surface)
 {
-    LOGV("setPreviewDisplay(%p)", surface.get());
+    ALOGV("setPreviewDisplay(%p)", surface.get());
     sp <ICamera> c = mCamera;
     if (c == 0) return NO_INIT;
     if (surface != 0) {
         return c->setPreviewDisplay(surface);
     } else {
-        LOGD("app passed NULL surface");
+        ALOGD("app passed NULL surface");
         return c->setPreviewDisplay(0);
     }
 }
@@ -186,13 +186,13 @@
 // pass the buffered ISurfaceTexture to the camera service
 status_t Camera::setPreviewTexture(const sp<ISurfaceTexture>& surfaceTexture)
 {
-    LOGV("setPreviewTexture(%p)", surfaceTexture.get());
+    ALOGV("setPreviewTexture(%p)", surfaceTexture.get());
     sp <ICamera> c = mCamera;
     if (c == 0) return NO_INIT;
     if (surfaceTexture != 0) {
         return c->setPreviewTexture(surfaceTexture);
     } else {
-        LOGD("app passed NULL surface");
+        ALOGD("app passed NULL surface");
         return c->setPreviewTexture(0);
     }
 }
@@ -200,7 +200,7 @@
 // start preview mode
 status_t Camera::startPreview()
 {
-    LOGV("startPreview");
+    ALOGV("startPreview");
     sp <ICamera> c = mCamera;
     if (c == 0) return NO_INIT;
     return c->startPreview();
@@ -208,7 +208,7 @@
 
 status_t Camera::storeMetaDataInBuffers(bool enabled)
 {
-    LOGV("storeMetaDataInBuffers: %s",
+    ALOGV("storeMetaDataInBuffers: %s",
             enabled? "true": "false");
     sp <ICamera> c = mCamera;
     if (c == 0) return NO_INIT;
@@ -218,7 +218,7 @@
 // start recording mode, must call setPreviewDisplay first
 status_t Camera::startRecording()
 {
-    LOGV("startRecording");
+    ALOGV("startRecording");
     sp <ICamera> c = mCamera;
     if (c == 0) return NO_INIT;
     return c->startRecording();
@@ -227,7 +227,7 @@
 // stop preview mode
 void Camera::stopPreview()
 {
-    LOGV("stopPreview");
+    ALOGV("stopPreview");
     sp <ICamera> c = mCamera;
     if (c == 0) return;
     c->stopPreview();
@@ -236,7 +236,7 @@
 // stop recording mode
 void Camera::stopRecording()
 {
-    LOGV("stopRecording");
+    ALOGV("stopRecording");
     {
         Mutex::Autolock _l(mLock);
         mRecordingProxyListener.clear();
@@ -249,7 +249,7 @@
 // release a recording frame
 void Camera::releaseRecordingFrame(const sp<IMemory>& mem)
 {
-    LOGV("releaseRecordingFrame");
+    ALOGV("releaseRecordingFrame");
     sp <ICamera> c = mCamera;
     if (c == 0) return;
     c->releaseRecordingFrame(mem);
@@ -258,7 +258,7 @@
 // get preview state
 bool Camera::previewEnabled()
 {
-    LOGV("previewEnabled");
+    ALOGV("previewEnabled");
     sp <ICamera> c = mCamera;
     if (c == 0) return false;
     return c->previewEnabled();
@@ -267,7 +267,7 @@
 // get recording state
 bool Camera::recordingEnabled()
 {
-    LOGV("recordingEnabled");
+    ALOGV("recordingEnabled");
     sp <ICamera> c = mCamera;
     if (c == 0) return false;
     return c->recordingEnabled();
@@ -275,7 +275,7 @@
 
 status_t Camera::autoFocus()
 {
-    LOGV("autoFocus");
+    ALOGV("autoFocus");
     sp <ICamera> c = mCamera;
     if (c == 0) return NO_INIT;
     return c->autoFocus();
@@ -283,7 +283,7 @@
 
 status_t Camera::cancelAutoFocus()
 {
-    LOGV("cancelAutoFocus");
+    ALOGV("cancelAutoFocus");
     sp <ICamera> c = mCamera;
     if (c == 0) return NO_INIT;
     return c->cancelAutoFocus();
@@ -292,7 +292,7 @@
 // take a picture
 status_t Camera::takePicture(int msgType)
 {
-    LOGV("takePicture: 0x%x", msgType);
+    ALOGV("takePicture: 0x%x", msgType);
     sp <ICamera> c = mCamera;
     if (c == 0) return NO_INIT;
     return c->takePicture(msgType);
@@ -301,7 +301,7 @@
 // set preview/capture parameters - key/value pairs
 status_t Camera::setParameters(const String8& params)
 {
-    LOGV("setParameters");
+    ALOGV("setParameters");
     sp <ICamera> c = mCamera;
     if (c == 0) return NO_INIT;
     return c->setParameters(params);
@@ -310,7 +310,7 @@
 // get preview/capture parameters - key/value pairs
 String8 Camera::getParameters() const
 {
-    LOGV("getParameters");
+    ALOGV("getParameters");
     String8 params;
     sp <ICamera> c = mCamera;
     if (c != 0) params = mCamera->getParameters();
@@ -320,7 +320,7 @@
 // send command to camera driver
 status_t Camera::sendCommand(int32_t cmd, int32_t arg1, int32_t arg2)
 {
-    LOGV("sendCommand");
+    ALOGV("sendCommand");
     sp <ICamera> c = mCamera;
     if (c == 0) return NO_INIT;
     return c->sendCommand(cmd, arg1, arg2);
@@ -340,7 +340,7 @@
 
 void Camera::setPreviewCallbackFlags(int flag)
 {
-    LOGV("setPreviewCallbackFlags");
+    ALOGV("setPreviewCallbackFlags");
     sp <ICamera> c = mCamera;
     if (c == 0) return;
     mCamera->setPreviewCallbackFlag(flag);
@@ -397,31 +397,31 @@
     if (listener != NULL) {
         listener->postDataTimestamp(timestamp, msgType, dataPtr);
     } else {
-        LOGW("No listener was set. Drop a recording frame.");
+        ALOGW("No listener was set. Drop a recording frame.");
         releaseRecordingFrame(dataPtr);
     }
 }
 
 void Camera::binderDied(const wp<IBinder>& who) {
-    LOGW("ICamera died");
+    ALOGW("ICamera died");
     notifyCallback(CAMERA_MSG_ERROR, CAMERA_ERROR_SERVER_DIED, 0);
 }
 
 void Camera::DeathNotifier::binderDied(const wp<IBinder>& who) {
-    LOGV("binderDied");
+    ALOGV("binderDied");
     Mutex::Autolock _l(Camera::mLock);
     Camera::mCameraService.clear();
-    LOGW("Camera server died!");
+    ALOGW("Camera server died!");
 }
 
 sp<ICameraRecordingProxy> Camera::getRecordingProxy() {
-    LOGV("getProxy");
+    ALOGV("getProxy");
     return new RecordingProxy(this);
 }
 
 status_t Camera::RecordingProxy::startRecording(const sp<ICameraRecordingProxyListener>& listener)
 {
-    LOGV("RecordingProxy::startRecording");
+    ALOGV("RecordingProxy::startRecording");
     mCamera->setRecordingProxyListener(listener);
     mCamera->reconnect();
     return mCamera->startRecording();
@@ -429,13 +429,13 @@
 
 void Camera::RecordingProxy::stopRecording()
 {
-    LOGV("RecordingProxy::stopRecording");
+    ALOGV("RecordingProxy::stopRecording");
     mCamera->stopRecording();
 }
 
 void Camera::RecordingProxy::releaseRecordingFrame(const sp<IMemory>& mem)
 {
-    LOGV("RecordingProxy::releaseRecordingFrame");
+    ALOGV("RecordingProxy::releaseRecordingFrame");
     mCamera->releaseRecordingFrame(mem);
 }
 
diff --git a/camera/CameraParameters.cpp b/camera/CameraParameters.cpp
index c6087b4..059a8a5 100644
--- a/camera/CameraParameters.cpp
+++ b/camera/CameraParameters.cpp
@@ -231,12 +231,12 @@
 {
     // XXX i think i can do this with strspn()
     if (strchr(key, '=') || strchr(key, ';')) {
-        //XXX LOGE("Key \"%s\"contains invalid character (= or ;)", key);
+        //XXX ALOGE("Key \"%s\"contains invalid character (= or ;)", key);
         return;
     }
 
     if (strchr(value, '=') || strchr(key, ';')) {
-        //XXX LOGE("Value \"%s\"contains invalid character (= or ;)", value);
+        //XXX ALOGE("Value \"%s\"contains invalid character (= or ;)", value);
         return;
     }
 
@@ -294,7 +294,7 @@
     int w = (int)strtol(str, &end, 10);
     // If a delimeter does not immediately follow, give up.
     if (*end != delim) {
-        LOGE("Cannot find delimeter (%c) in str=%s", delim, str);
+        ALOGE("Cannot find delimeter (%c) in str=%s", delim, str);
         return -1;
     }
 
@@ -324,7 +324,7 @@
         int success = parse_pair(sizeStartPtr, &width, &height, 'x',
                                  &sizeStartPtr);
         if (success == -1 || (*sizeStartPtr != ',' && *sizeStartPtr != '\0')) {
-            LOGE("Picture sizes string \"%s\" contains invalid character.", sizesStr);
+            ALOGE("Picture sizes string \"%s\" contains invalid character.", sizesStr);
             return;
         }
         sizes.push(Size(width, height));
@@ -449,12 +449,12 @@
 
 void CameraParameters::dump() const
 {
-    LOGD("dump: mMap.size = %d", mMap.size());
+    ALOGD("dump: mMap.size = %d", mMap.size());
     for (size_t i = 0; i < mMap.size(); i++) {
         String8 k, v;
         k = mMap.keyAt(i);
         v = mMap.valueAt(i);
-        LOGD("%s: %s\n", k.string(), v.string());
+        ALOGD("%s: %s\n", k.string(), v.string());
     }
 }
 
diff --git a/camera/ICamera.cpp b/camera/ICamera.cpp
index 5f6e5ef..70f5dbc 100644
--- a/camera/ICamera.cpp
+++ b/camera/ICamera.cpp
@@ -60,7 +60,7 @@
     // disconnect from camera service
     void disconnect()
     {
-        LOGV("disconnect");
+        ALOGV("disconnect");
         Parcel data, reply;
         data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
         remote()->transact(DISCONNECT, data, &reply);
@@ -69,7 +69,7 @@
     // pass the buffered Surface to the camera service
     status_t setPreviewDisplay(const sp<Surface>& surface)
     {
-        LOGV("setPreviewDisplay");
+        ALOGV("setPreviewDisplay");
         Parcel data, reply;
         data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
         Surface::writeToParcel(surface, &data);
@@ -80,7 +80,7 @@
     // pass the buffered SurfaceTexture to the camera service
     status_t setPreviewTexture(const sp<ISurfaceTexture>& surfaceTexture)
     {
-        LOGV("setPreviewTexture");
+        ALOGV("setPreviewTexture");
         Parcel data, reply;
         data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
         sp<IBinder> b(surfaceTexture->asBinder());
@@ -93,7 +93,7 @@
     // preview are handled. See Camera.h for details.
     void setPreviewCallbackFlag(int flag)
     {
-        LOGV("setPreviewCallbackFlag(%d)", flag);
+        ALOGV("setPreviewCallbackFlag(%d)", flag);
         Parcel data, reply;
         data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
         data.writeInt32(flag);
@@ -103,7 +103,7 @@
     // start preview mode, must call setPreviewDisplay first
     status_t startPreview()
     {
-        LOGV("startPreview");
+        ALOGV("startPreview");
         Parcel data, reply;
         data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
         remote()->transact(START_PREVIEW, data, &reply);
@@ -113,7 +113,7 @@
     // start recording mode, must call setPreviewDisplay first
     status_t startRecording()
     {
-        LOGV("startRecording");
+        ALOGV("startRecording");
         Parcel data, reply;
         data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
         remote()->transact(START_RECORDING, data, &reply);
@@ -123,7 +123,7 @@
     // stop preview mode
     void stopPreview()
     {
-        LOGV("stopPreview");
+        ALOGV("stopPreview");
         Parcel data, reply;
         data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
         remote()->transact(STOP_PREVIEW, data, &reply);
@@ -132,7 +132,7 @@
     // stop recording mode
     void stopRecording()
     {
-        LOGV("stopRecording");
+        ALOGV("stopRecording");
         Parcel data, reply;
         data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
         remote()->transact(STOP_RECORDING, data, &reply);
@@ -140,7 +140,7 @@
 
     void releaseRecordingFrame(const sp<IMemory>& mem)
     {
-        LOGV("releaseRecordingFrame");
+        ALOGV("releaseRecordingFrame");
         Parcel data, reply;
         data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
         data.writeStrongBinder(mem->asBinder());
@@ -149,7 +149,7 @@
 
     status_t storeMetaDataInBuffers(bool enabled)
     {
-        LOGV("storeMetaDataInBuffers: %s", enabled? "true": "false");
+        ALOGV("storeMetaDataInBuffers: %s", enabled? "true": "false");
         Parcel data, reply;
         data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
         data.writeInt32(enabled);
@@ -160,7 +160,7 @@
     // check preview state
     bool previewEnabled()
     {
-        LOGV("previewEnabled");
+        ALOGV("previewEnabled");
         Parcel data, reply;
         data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
         remote()->transact(PREVIEW_ENABLED, data, &reply);
@@ -170,7 +170,7 @@
     // check recording state
     bool recordingEnabled()
     {
-        LOGV("recordingEnabled");
+        ALOGV("recordingEnabled");
         Parcel data, reply;
         data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
         remote()->transact(RECORDING_ENABLED, data, &reply);
@@ -180,7 +180,7 @@
     // auto focus
     status_t autoFocus()
     {
-        LOGV("autoFocus");
+        ALOGV("autoFocus");
         Parcel data, reply;
         data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
         remote()->transact(AUTO_FOCUS, data, &reply);
@@ -191,7 +191,7 @@
     // cancel focus
     status_t cancelAutoFocus()
     {
-        LOGV("cancelAutoFocus");
+        ALOGV("cancelAutoFocus");
         Parcel data, reply;
         data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
         remote()->transact(CANCEL_AUTO_FOCUS, data, &reply);
@@ -202,7 +202,7 @@
     // take a picture - returns an IMemory (ref-counted mmap)
     status_t takePicture(int msgType)
     {
-        LOGV("takePicture: 0x%x", msgType);
+        ALOGV("takePicture: 0x%x", msgType);
         Parcel data, reply;
         data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
         data.writeInt32(msgType);
@@ -214,7 +214,7 @@
     // set preview/capture parameters - key/value pairs
     status_t setParameters(const String8& params)
     {
-        LOGV("setParameters");
+        ALOGV("setParameters");
         Parcel data, reply;
         data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
         data.writeString8(params);
@@ -225,7 +225,7 @@
     // get preview/capture parameters - key/value pairs
     String8 getParameters() const
     {
-        LOGV("getParameters");
+        ALOGV("getParameters");
         Parcel data, reply;
         data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
         remote()->transact(GET_PARAMETERS, data, &reply);
@@ -233,7 +233,7 @@
     }
     virtual status_t sendCommand(int32_t cmd, int32_t arg1, int32_t arg2)
     {
-        LOGV("sendCommand");
+        ALOGV("sendCommand");
         Parcel data, reply;
         data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
         data.writeInt32(cmd);
@@ -275,116 +275,116 @@
 {
     switch(code) {
         case DISCONNECT: {
-            LOGV("DISCONNECT");
+            ALOGV("DISCONNECT");
             CHECK_INTERFACE(ICamera, data, reply);
             disconnect();
             return NO_ERROR;
         } break;
         case SET_PREVIEW_DISPLAY: {
-            LOGV("SET_PREVIEW_DISPLAY");
+            ALOGV("SET_PREVIEW_DISPLAY");
             CHECK_INTERFACE(ICamera, data, reply);
             sp<Surface> surface = Surface::readFromParcel(data);
             reply->writeInt32(setPreviewDisplay(surface));
             return NO_ERROR;
         } break;
         case SET_PREVIEW_TEXTURE: {
-            LOGV("SET_PREVIEW_TEXTURE");
+            ALOGV("SET_PREVIEW_TEXTURE");
             CHECK_INTERFACE(ICamera, data, reply);
             sp<ISurfaceTexture> st = interface_cast<ISurfaceTexture>(data.readStrongBinder());
             reply->writeInt32(setPreviewTexture(st));
             return NO_ERROR;
         } break;
         case SET_PREVIEW_CALLBACK_FLAG: {
-            LOGV("SET_PREVIEW_CALLBACK_TYPE");
+            ALOGV("SET_PREVIEW_CALLBACK_TYPE");
             CHECK_INTERFACE(ICamera, data, reply);
             int callback_flag = data.readInt32();
             setPreviewCallbackFlag(callback_flag);
             return NO_ERROR;
         } break;
         case START_PREVIEW: {
-            LOGV("START_PREVIEW");
+            ALOGV("START_PREVIEW");
             CHECK_INTERFACE(ICamera, data, reply);
             reply->writeInt32(startPreview());
             return NO_ERROR;
         } break;
         case START_RECORDING: {
-            LOGV("START_RECORDING");
+            ALOGV("START_RECORDING");
             CHECK_INTERFACE(ICamera, data, reply);
             reply->writeInt32(startRecording());
             return NO_ERROR;
         } break;
         case STOP_PREVIEW: {
-            LOGV("STOP_PREVIEW");
+            ALOGV("STOP_PREVIEW");
             CHECK_INTERFACE(ICamera, data, reply);
             stopPreview();
             return NO_ERROR;
         } break;
         case STOP_RECORDING: {
-            LOGV("STOP_RECORDING");
+            ALOGV("STOP_RECORDING");
             CHECK_INTERFACE(ICamera, data, reply);
             stopRecording();
             return NO_ERROR;
         } break;
         case RELEASE_RECORDING_FRAME: {
-            LOGV("RELEASE_RECORDING_FRAME");
+            ALOGV("RELEASE_RECORDING_FRAME");
             CHECK_INTERFACE(ICamera, data, reply);
             sp<IMemory> mem = interface_cast<IMemory>(data.readStrongBinder());
             releaseRecordingFrame(mem);
             return NO_ERROR;
         } break;
         case STORE_META_DATA_IN_BUFFERS: {
-            LOGV("STORE_META_DATA_IN_BUFFERS");
+            ALOGV("STORE_META_DATA_IN_BUFFERS");
             CHECK_INTERFACE(ICamera, data, reply);
             bool enabled = data.readInt32();
             reply->writeInt32(storeMetaDataInBuffers(enabled));
             return NO_ERROR;
         } break;
         case PREVIEW_ENABLED: {
-            LOGV("PREVIEW_ENABLED");
+            ALOGV("PREVIEW_ENABLED");
             CHECK_INTERFACE(ICamera, data, reply);
             reply->writeInt32(previewEnabled());
             return NO_ERROR;
         } break;
         case RECORDING_ENABLED: {
-            LOGV("RECORDING_ENABLED");
+            ALOGV("RECORDING_ENABLED");
             CHECK_INTERFACE(ICamera, data, reply);
             reply->writeInt32(recordingEnabled());
             return NO_ERROR;
         } break;
         case AUTO_FOCUS: {
-            LOGV("AUTO_FOCUS");
+            ALOGV("AUTO_FOCUS");
             CHECK_INTERFACE(ICamera, data, reply);
             reply->writeInt32(autoFocus());
             return NO_ERROR;
         } break;
         case CANCEL_AUTO_FOCUS: {
-            LOGV("CANCEL_AUTO_FOCUS");
+            ALOGV("CANCEL_AUTO_FOCUS");
             CHECK_INTERFACE(ICamera, data, reply);
             reply->writeInt32(cancelAutoFocus());
             return NO_ERROR;
         } break;
         case TAKE_PICTURE: {
-            LOGV("TAKE_PICTURE");
+            ALOGV("TAKE_PICTURE");
             CHECK_INTERFACE(ICamera, data, reply);
             int msgType = data.readInt32();
             reply->writeInt32(takePicture(msgType));
             return NO_ERROR;
         } break;
         case SET_PARAMETERS: {
-            LOGV("SET_PARAMETERS");
+            ALOGV("SET_PARAMETERS");
             CHECK_INTERFACE(ICamera, data, reply);
             String8 params(data.readString8());
             reply->writeInt32(setParameters(params));
             return NO_ERROR;
          } break;
         case GET_PARAMETERS: {
-            LOGV("GET_PARAMETERS");
+            ALOGV("GET_PARAMETERS");
             CHECK_INTERFACE(ICamera, data, reply);
              reply->writeString8(getParameters());
             return NO_ERROR;
          } break;
         case SEND_COMMAND: {
-            LOGV("SEND_COMMAND");
+            ALOGV("SEND_COMMAND");
             CHECK_INTERFACE(ICamera, data, reply);
             int command = data.readInt32();
             int arg1 = data.readInt32();
diff --git a/camera/ICameraClient.cpp b/camera/ICameraClient.cpp
index 183429a..205c8ba 100644
--- a/camera/ICameraClient.cpp
+++ b/camera/ICameraClient.cpp
@@ -41,7 +41,7 @@
     // generic callback from camera service to app
     void notifyCallback(int32_t msgType, int32_t ext1, int32_t ext2)
     {
-        LOGV("notifyCallback");
+        ALOGV("notifyCallback");
         Parcel data, reply;
         data.writeInterfaceToken(ICameraClient::getInterfaceDescriptor());
         data.writeInt32(msgType);
@@ -54,7 +54,7 @@
     void dataCallback(int32_t msgType, const sp<IMemory>& imageData,
                       camera_frame_metadata_t *metadata)
     {
-        LOGV("dataCallback");
+        ALOGV("dataCallback");
         Parcel data, reply;
         data.writeInterfaceToken(ICameraClient::getInterfaceDescriptor());
         data.writeInt32(msgType);
@@ -69,7 +69,7 @@
     // generic data callback from camera service to app with image data
     void dataCallbackTimestamp(nsecs_t timestamp, int32_t msgType, const sp<IMemory>& imageData)
     {
-        LOGV("dataCallback");
+        ALOGV("dataCallback");
         Parcel data, reply;
         data.writeInterfaceToken(ICameraClient::getInterfaceDescriptor());
         data.writeInt64(timestamp);
@@ -88,7 +88,7 @@
 {
     switch(code) {
         case NOTIFY_CALLBACK: {
-            LOGV("NOTIFY_CALLBACK");
+            ALOGV("NOTIFY_CALLBACK");
             CHECK_INTERFACE(ICameraClient, data, reply);
             int32_t msgType = data.readInt32();
             int32_t ext1 = data.readInt32();
@@ -97,7 +97,7 @@
             return NO_ERROR;
         } break;
         case DATA_CALLBACK: {
-            LOGV("DATA_CALLBACK");
+            ALOGV("DATA_CALLBACK");
             CHECK_INTERFACE(ICameraClient, data, reply);
             int32_t msgType = data.readInt32();
             sp<IMemory> imageData = interface_cast<IMemory>(data.readStrongBinder());
@@ -113,7 +113,7 @@
             return NO_ERROR;
         } break;
         case DATA_CALLBACK_TIMESTAMP: {
-            LOGV("DATA_CALLBACK_TIMESTAMP");
+            ALOGV("DATA_CALLBACK_TIMESTAMP");
             CHECK_INTERFACE(ICameraClient, data, reply);
             nsecs_t timestamp = data.readInt64();
             int32_t msgType = data.readInt32();
diff --git a/camera/ICameraRecordingProxy.cpp b/camera/ICameraRecordingProxy.cpp
index 64b6a5c..7223b6d 100644
--- a/camera/ICameraRecordingProxy.cpp
+++ b/camera/ICameraRecordingProxy.cpp
@@ -42,7 +42,7 @@
 
     status_t startRecording(const sp<ICameraRecordingProxyListener>& listener)
     {
-        LOGV("startRecording");
+        ALOGV("startRecording");
         Parcel data, reply;
         data.writeInterfaceToken(ICameraRecordingProxy::getInterfaceDescriptor());
         data.writeStrongBinder(listener->asBinder());
@@ -52,7 +52,7 @@
 
     void stopRecording()
     {
-        LOGV("stopRecording");
+        ALOGV("stopRecording");
         Parcel data, reply;
         data.writeInterfaceToken(ICameraRecordingProxy::getInterfaceDescriptor());
         remote()->transact(STOP_RECORDING, data, &reply);
@@ -60,7 +60,7 @@
 
     void releaseRecordingFrame(const sp<IMemory>& mem)
     {
-        LOGV("releaseRecordingFrame");
+        ALOGV("releaseRecordingFrame");
         Parcel data, reply;
         data.writeInterfaceToken(ICameraRecordingProxy::getInterfaceDescriptor());
         data.writeStrongBinder(mem->asBinder());
@@ -77,7 +77,7 @@
 {
     switch(code) {
         case START_RECORDING: {
-            LOGV("START_RECORDING");
+            ALOGV("START_RECORDING");
             CHECK_INTERFACE(ICameraRecordingProxy, data, reply);
             sp<ICameraRecordingProxyListener> listener =
                 interface_cast<ICameraRecordingProxyListener>(data.readStrongBinder());
@@ -85,13 +85,13 @@
             return NO_ERROR;
         } break;
         case STOP_RECORDING: {
-            LOGV("STOP_RECORDING");
+            ALOGV("STOP_RECORDING");
             CHECK_INTERFACE(ICameraRecordingProxy, data, reply);
             stopRecording();
             return NO_ERROR;
         } break;
         case RELEASE_RECORDING_FRAME: {
-            LOGV("RELEASE_RECORDING_FRAME");
+            ALOGV("RELEASE_RECORDING_FRAME");
             CHECK_INTERFACE(ICameraRecordingProxy, data, reply);
             sp<IMemory> mem = interface_cast<IMemory>(data.readStrongBinder());
             releaseRecordingFrame(mem);
diff --git a/camera/ICameraRecordingProxyListener.cpp b/camera/ICameraRecordingProxyListener.cpp
index f8cece5..cb17f19 100644
--- a/camera/ICameraRecordingProxyListener.cpp
+++ b/camera/ICameraRecordingProxyListener.cpp
@@ -37,7 +37,7 @@
 
     void dataCallbackTimestamp(nsecs_t timestamp, int32_t msgType, const sp<IMemory>& imageData)
     {
-        LOGV("dataCallback");
+        ALOGV("dataCallback");
         Parcel data, reply;
         data.writeInterfaceToken(ICameraRecordingProxyListener::getInterfaceDescriptor());
         data.writeInt64(timestamp);
@@ -56,7 +56,7 @@
 {
     switch(code) {
         case DATA_CALLBACK_TIMESTAMP: {
-            LOGV("DATA_CALLBACK_TIMESTAMP");
+            ALOGV("DATA_CALLBACK_TIMESTAMP");
             CHECK_INTERFACE(ICameraRecordingProxyListener, data, reply);
             nsecs_t timestamp = data.readInt64();
             int32_t msgType = data.readInt32();
diff --git a/cmds/stagefright/record.cpp b/cmds/stagefright/record.cpp
index b718299..613435d 100644
--- a/cmds/stagefright/record.cpp
+++ b/cmds/stagefright/record.cpp
@@ -96,7 +96,7 @@
         ++mNumFramesOutput;
 
         // printf("DummySource::read - returning buffer\n");
-        // LOGI("DummySource::read - returning buffer");
+        // ALOGI("DummySource::read - returning buffer");
         return OK;
     }
 
diff --git a/cmds/stagefright/sf2.cpp b/cmds/stagefright/sf2.cpp
index f547e01..ae80f88 100644
--- a/cmds/stagefright/sf2.cpp
+++ b/cmds/stagefright/sf2.cpp
@@ -454,7 +454,7 @@
 
                 if (sizeNeeded > sizeLeft) {
                     if (outBuffer->size() == 0) {
-                        LOGE("Unable to fit even a single input buffer of size %d.",
+                        ALOGE("Unable to fit even a single input buffer of size %d.",
                              sizeNeeded);
                     }
                     CHECK_GT(outBuffer->size(), 0u);
@@ -500,7 +500,7 @@
                 break;  // Don't coalesce
             }
 
-            LOGV("coalesced %d input buffers", n);
+            ALOGV("coalesced %d input buffers", n);
 
             if (outBuffer->size() == 0) {
                 CHECK_NE(mFinalResult, (status_t)OK);
diff --git a/cmds/stagefright/stream.cpp b/cmds/stagefright/stream.cpp
index bd430d1..0d6c738 100644
--- a/cmds/stagefright/stream.cpp
+++ b/cmds/stagefright/stream.cpp
@@ -90,7 +90,7 @@
 
 #if 0
     if (mNumPacketsSent >= 20000) {
-        LOGI("signalling discontinuity now");
+        ALOGI("signalling discontinuity now");
 
         off64_t offset = 0;
         CHECK((offset % 188) == 0);
@@ -308,7 +308,7 @@
     ssize_t displayWidth = composerClient->getDisplayWidth(0);
     ssize_t displayHeight = composerClient->getDisplayHeight(0);
 
-    LOGV("display is %d x %d\n", displayWidth, displayHeight);
+    ALOGV("display is %d x %d\n", displayWidth, displayHeight);
 
     sp<SurfaceControl> control =
         composerClient->createSurface(
diff --git a/drm/common/DrmEngineBase.cpp b/drm/common/DrmEngineBase.cpp
index 9b16c36..1c345a2 100644
--- a/drm/common/DrmEngineBase.cpp
+++ b/drm/common/DrmEngineBase.cpp
@@ -120,13 +120,23 @@
 }
 
 status_t DrmEngineBase::openDecryptSession(
-    int uniqueId, DecryptHandle* decryptHandle, int fd, off64_t offset, off64_t length) {
-    return onOpenDecryptSession(uniqueId, decryptHandle, fd, offset, length);
+    int uniqueId, DecryptHandle* decryptHandle,
+    int fd, off64_t offset, off64_t length, const char* mime) {
+
+    if (!mime || mime[0] == '\0') {
+        return onOpenDecryptSession(uniqueId, decryptHandle, fd, offset, length);
+    }
+
+    return onOpenDecryptSession(uniqueId, decryptHandle, fd, offset, length, mime);
 }
 
 status_t DrmEngineBase::openDecryptSession(
-    int uniqueId, DecryptHandle* decryptHandle, const char* uri) {
-    return onOpenDecryptSession(uniqueId, decryptHandle, uri);
+    int uniqueId, DecryptHandle* decryptHandle,
+    const char* uri, const char* mime) {
+    if (!mime || mime[0] == '\0') {
+        return onOpenDecryptSession(uniqueId, decryptHandle, uri);
+    }
+    return onOpenDecryptSession(uniqueId, decryptHandle, uri, mime);
 }
 
 status_t DrmEngineBase::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {
diff --git a/drm/common/DrmMetadata.cpp b/drm/common/DrmMetadata.cpp
index 6cc5ec1..2a4b8c8 100644
--- a/drm/common/DrmMetadata.cpp
+++ b/drm/common/DrmMetadata.cpp
@@ -78,11 +78,11 @@
 DrmMetadata::KeyIterator::KeyIterator(const DrmMetadata::KeyIterator& keyIterator) :
     mDrmMetadata(keyIterator.mDrmMetadata),
     mIndex(keyIterator.mIndex) {
-    LOGV("DrmMetadata::KeyIterator::KeyIterator");
+    ALOGV("DrmMetadata::KeyIterator::KeyIterator");
 }
 
 DrmMetadata::KeyIterator& DrmMetadata::KeyIterator::operator=(const DrmMetadata::KeyIterator& keyIterator) {
-    LOGV("DrmMetadata::KeyIterator::operator=");
+    ALOGV("DrmMetadata::KeyIterator::operator=");
     mDrmMetadata = keyIterator.mDrmMetadata;
     mIndex = keyIterator.mIndex;
     return *this;
@@ -96,11 +96,11 @@
 DrmMetadata::Iterator::Iterator(const DrmMetadata::Iterator& iterator) :
     mDrmMetadata(iterator.mDrmMetadata),
     mIndex(iterator.mIndex) {
-    LOGV("DrmMetadata::Iterator::Iterator");
+    ALOGV("DrmMetadata::Iterator::Iterator");
 }
 
 DrmMetadata::Iterator& DrmMetadata::Iterator::operator=(const DrmMetadata::Iterator& iterator) {
-    LOGV("DrmMetadata::Iterator::operator=");
+    ALOGV("DrmMetadata::Iterator::operator=");
     mDrmMetadata = iterator.mDrmMetadata;
     mIndex = iterator.mIndex;
     return *this;
diff --git a/drm/common/IDrmManagerService.cpp b/drm/common/IDrmManagerService.cpp
index 0b76a36..43f64f2 100644
--- a/drm/common/IDrmManagerService.cpp
+++ b/drm/common/IDrmManagerService.cpp
@@ -111,7 +111,7 @@
 }
 
 int BpDrmManagerService::addUniqueId(bool isNative) {
-    LOGV("add uniqueid");
+    ALOGV("add uniqueid");
     Parcel data, reply;
     data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
     data.writeInt32(isNative);
@@ -120,7 +120,7 @@
 }
 
 void BpDrmManagerService::removeUniqueId(int uniqueId) {
-    LOGV("remove uniqueid");
+    ALOGV("remove uniqueid");
     Parcel data, reply;
     data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
     data.writeInt32(uniqueId);
@@ -143,7 +143,7 @@
 
 status_t BpDrmManagerService::setDrmServiceListener(
             int uniqueId, const sp<IDrmServiceListener>& drmServiceListener) {
-    LOGV("setDrmServiceListener");
+    ALOGV("setDrmServiceListener");
     Parcel data, reply;
 
     data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
@@ -154,7 +154,7 @@
 }
 
 status_t BpDrmManagerService::installDrmEngine(int uniqueId, const String8& drmEngineFile) {
-    LOGV("Install DRM Engine");
+    ALOGV("Install DRM Engine");
     Parcel data, reply;
 
     data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
@@ -167,7 +167,7 @@
 
 DrmConstraints* BpDrmManagerService::getConstraints(
             int uniqueId, const String8* path, const int action) {
-    LOGV("Get Constraints");
+    ALOGV("Get Constraints");
     Parcel data, reply;
 
     data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
@@ -198,7 +198,7 @@
 }
 
 DrmMetadata* BpDrmManagerService::getMetadata(int uniqueId, const String8* path) {
-    LOGV("Get Metadata");
+    ALOGV("Get Metadata");
     Parcel data, reply;
     data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
     data.writeInt32(uniqueId);
@@ -227,7 +227,7 @@
 }
 
 bool BpDrmManagerService::canHandle(int uniqueId, const String8& path, const String8& mimeType) {
-    LOGV("Can Handle");
+    ALOGV("Can Handle");
     Parcel data, reply;
 
     data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
@@ -242,7 +242,7 @@
 }
 
 DrmInfoStatus* BpDrmManagerService::processDrmInfo(int uniqueId, const DrmInfo* drmInfo) {
-    LOGV("Process DRM Info");
+    ALOGV("Process DRM Info");
     Parcel data, reply;
 
     data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
@@ -293,7 +293,7 @@
 }
 
 DrmInfo* BpDrmManagerService::acquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInforequest) {
-    LOGV("Acquire DRM Info");
+    ALOGV("Acquire DRM Info");
     Parcel data, reply;
 
     data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
@@ -341,7 +341,7 @@
 status_t BpDrmManagerService::saveRights(
             int uniqueId, const DrmRights& drmRights,
             const String8& rightsPath, const String8& contentPath) {
-    LOGV("Save Rights");
+    ALOGV("Save Rights");
     Parcel data, reply;
 
     data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
@@ -369,7 +369,7 @@
 }
 
 String8 BpDrmManagerService::getOriginalMimeType(int uniqueId, const String8& path) {
-    LOGV("Get Original MimeType");
+    ALOGV("Get Original MimeType");
     Parcel data, reply;
 
     data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
@@ -382,7 +382,7 @@
 
 int BpDrmManagerService::getDrmObjectType(
             int uniqueId, const String8& path, const String8& mimeType) {
-    LOGV("Get Drm object type");
+    ALOGV("Get Drm object type");
     Parcel data, reply;
 
     data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
@@ -396,7 +396,7 @@
 }
 
 int BpDrmManagerService::checkRightsStatus(int uniqueId, const String8& path, int action) {
-    LOGV("checkRightsStatus");
+    ALOGV("checkRightsStatus");
     Parcel data, reply;
 
     data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
@@ -411,7 +411,7 @@
 
 status_t BpDrmManagerService::consumeRights(
             int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve) {
-    LOGV("consumeRights");
+    ALOGV("consumeRights");
     Parcel data, reply;
 
     data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
@@ -428,7 +428,7 @@
 
 status_t BpDrmManagerService::setPlaybackStatus(
             int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int64_t position) {
-    LOGV("setPlaybackStatus");
+    ALOGV("setPlaybackStatus");
     Parcel data, reply;
 
     data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
@@ -446,7 +446,7 @@
 bool BpDrmManagerService::validateAction(
             int uniqueId, const String8& path,
             int action, const ActionDescription& description) {
-    LOGV("validateAction");
+    ALOGV("validateAction");
     Parcel data, reply;
 
     data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
@@ -462,7 +462,7 @@
 }
 
 status_t BpDrmManagerService::removeRights(int uniqueId, const String8& path) {
-    LOGV("removeRights");
+    ALOGV("removeRights");
     Parcel data, reply;
 
     data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
@@ -474,7 +474,7 @@
 }
 
 status_t BpDrmManagerService::removeAllRights(int uniqueId) {
-    LOGV("removeAllRights");
+    ALOGV("removeAllRights");
     Parcel data, reply;
 
     data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
@@ -485,7 +485,7 @@
 }
 
 int BpDrmManagerService::openConvertSession(int uniqueId, const String8& mimeType) {
-    LOGV("openConvertSession");
+    ALOGV("openConvertSession");
     Parcel data, reply;
 
     data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
@@ -498,7 +498,7 @@
 
 DrmConvertedStatus* BpDrmManagerService::convertData(
             int uniqueId, int convertId, const DrmBuffer* inputData) {
-    LOGV("convertData");
+    ALOGV("convertData");
     Parcel data, reply;
 
     data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
@@ -532,7 +532,7 @@
 }
 
 DrmConvertedStatus* BpDrmManagerService::closeConvertSession(int uniqueId, int convertId) {
-    LOGV("closeConvertSession");
+    ALOGV("closeConvertSession");
     Parcel data, reply;
 
     data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
@@ -565,7 +565,7 @@
 
 status_t BpDrmManagerService::getAllSupportInfo(
             int uniqueId, int* length, DrmSupportInfo** drmSupportInfoArray) {
-    LOGV("Get All Support Info");
+    ALOGV("Get All Support Info");
     Parcel data, reply;
 
     data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
@@ -600,8 +600,8 @@
 }
 
 DecryptHandle* BpDrmManagerService::openDecryptSession(
-            int uniqueId, int fd, off64_t offset, off64_t length) {
-    LOGV("Entering BpDrmManagerService::openDecryptSession");
+            int uniqueId, int fd, off64_t offset, off64_t length, const char* mime) {
+    ALOGV("Entering BpDrmManagerService::openDecryptSession");
     Parcel data, reply;
 
     data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
@@ -609,6 +609,11 @@
     data.writeFileDescriptor(fd);
     data.writeInt64(offset);
     data.writeInt64(length);
+    String8 mimeType;
+    if (mime) {
+        mimeType = mime;
+    }
+    data.writeString8(mimeType);
 
     remote()->transact(OPEN_DECRYPT_SESSION, data, &reply);
 
@@ -620,13 +625,20 @@
     return handle;
 }
 
-DecryptHandle* BpDrmManagerService::openDecryptSession(int uniqueId, const char* uri) {
-    LOGV("Entering BpDrmManagerService::openDecryptSession");
+DecryptHandle* BpDrmManagerService::openDecryptSession(
+        int uniqueId, const char* uri, const char* mime) {
+
+    ALOGV("Entering BpDrmManagerService::openDecryptSession: mime=%s", mime? mime: "NULL");
     Parcel data, reply;
 
     data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
     data.writeInt32(uniqueId);
     data.writeString8(String8(uri));
+    String8 mimeType;
+    if (mime) {
+        mimeType = mime;
+    }
+    data.writeString8(mimeType);
 
     remote()->transact(OPEN_DECRYPT_SESSION_FROM_URI, data, &reply);
 
@@ -635,13 +647,13 @@
         handle = new DecryptHandle();
         readDecryptHandleFromParcelData(handle, reply);
     } else {
-        LOGV("no decryptHandle is generated in service side");
+        ALOGV("no decryptHandle is generated in service side");
     }
     return handle;
 }
 
 status_t BpDrmManagerService::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {
-    LOGV("closeDecryptSession");
+    ALOGV("closeDecryptSession");
     Parcel data, reply;
 
     data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
@@ -657,7 +669,7 @@
 status_t BpDrmManagerService::initializeDecryptUnit(
             int uniqueId, DecryptHandle* decryptHandle,
             int decryptUnitId, const DrmBuffer* headerInfo) {
-    LOGV("initializeDecryptUnit");
+    ALOGV("initializeDecryptUnit");
     Parcel data, reply;
 
     data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
@@ -677,7 +689,7 @@
 status_t BpDrmManagerService::decrypt(
             int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,
             const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) {
-    LOGV("decrypt");
+    ALOGV("decrypt");
     Parcel data, reply;
 
     data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
@@ -699,7 +711,7 @@
     remote()->transact(DECRYPT, data, &reply);
 
     const status_t status = reply.readInt32();
-    LOGV("Return value of decrypt() is %d", status);
+    ALOGV("Return value of decrypt() is %d", status);
 
     const int size = reply.readInt32();
     (*decBuffer)->length = size;
@@ -710,7 +722,7 @@
 
 status_t BpDrmManagerService::finalizeDecryptUnit(
             int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) {
-    LOGV("finalizeDecryptUnit");
+    ALOGV("finalizeDecryptUnit");
     Parcel data, reply;
 
     data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
@@ -727,7 +739,7 @@
 ssize_t BpDrmManagerService::pread(
             int uniqueId, DecryptHandle* decryptHandle, void* buffer,
             ssize_t numBytes, off64_t offset) {
-    LOGV("read");
+    ALOGV("read");
     Parcel data, reply;
     int result;
 
@@ -752,12 +764,12 @@
 status_t BnDrmManagerService::onTransact(
             uint32_t code, const Parcel& data,
             Parcel* reply, uint32_t flags) {
-    LOGV("Entering BnDrmManagerService::onTransact with code %d", code);
+    ALOGV("Entering BnDrmManagerService::onTransact with code %d", code);
 
     switch (code) {
     case ADD_UNIQUEID:
     {
-        LOGV("BnDrmManagerService::onTransact :ADD_UNIQUEID");
+        ALOGV("BnDrmManagerService::onTransact :ADD_UNIQUEID");
         CHECK_INTERFACE(IDrmManagerService, data, reply);
         int uniqueId = addUniqueId(data.readInt32());
         reply->writeInt32(uniqueId);
@@ -766,7 +778,7 @@
 
     case REMOVE_UNIQUEID:
     {
-        LOGV("BnDrmManagerService::onTransact :REMOVE_UNIQUEID");
+        ALOGV("BnDrmManagerService::onTransact :REMOVE_UNIQUEID");
         CHECK_INTERFACE(IDrmManagerService, data, reply);
         removeUniqueId(data.readInt32());
         return DRM_NO_ERROR;
@@ -774,7 +786,7 @@
 
     case ADD_CLIENT:
     {
-        LOGV("BnDrmManagerService::onTransact :ADD_CLIENT");
+        ALOGV("BnDrmManagerService::onTransact :ADD_CLIENT");
         CHECK_INTERFACE(IDrmManagerService, data, reply);
         addClient(data.readInt32());
         return DRM_NO_ERROR;
@@ -782,7 +794,7 @@
 
     case REMOVE_CLIENT:
     {
-        LOGV("BnDrmManagerService::onTransact :REMOVE_CLIENT");
+        ALOGV("BnDrmManagerService::onTransact :REMOVE_CLIENT");
         CHECK_INTERFACE(IDrmManagerService, data, reply);
         removeClient(data.readInt32());
         return DRM_NO_ERROR;
@@ -790,7 +802,7 @@
 
     case SET_DRM_SERVICE_LISTENER:
     {
-        LOGV("BnDrmManagerService::onTransact :SET_DRM_SERVICE_LISTENER");
+        ALOGV("BnDrmManagerService::onTransact :SET_DRM_SERVICE_LISTENER");
         CHECK_INTERFACE(IDrmManagerService, data, reply);
 
         const int uniqueId = data.readInt32();
@@ -805,7 +817,7 @@
 
     case INSTALL_DRM_ENGINE:
     {
-        LOGV("BnDrmManagerService::onTransact :INSTALL_DRM_ENGINE");
+        ALOGV("BnDrmManagerService::onTransact :INSTALL_DRM_ENGINE");
         CHECK_INTERFACE(IDrmManagerService, data, reply);
 
         const int uniqueId = data.readInt32();
@@ -818,7 +830,7 @@
 
     case GET_CONSTRAINTS_FROM_CONTENT:
     {
-        LOGV("BnDrmManagerService::onTransact :GET_CONSTRAINTS_FROM_CONTENT");
+        ALOGV("BnDrmManagerService::onTransact :GET_CONSTRAINTS_FROM_CONTENT");
         CHECK_INTERFACE(IDrmManagerService, data, reply);
 
         const int uniqueId = data.readInt32();
@@ -850,7 +862,7 @@
 
     case GET_METADATA_FROM_CONTENT:
     {
-        LOGV("BnDrmManagerService::onTransact :GET_METADATA_FROM_CONTENT");
+        ALOGV("BnDrmManagerService::onTransact :GET_METADATA_FROM_CONTENT");
         CHECK_INTERFACE(IDrmManagerService, data, reply);
 
         const int uniqueId = data.readInt32();
@@ -882,7 +894,7 @@
 
     case CAN_HANDLE:
     {
-        LOGV("BnDrmManagerService::onTransact :CAN_HANDLE");
+        ALOGV("BnDrmManagerService::onTransact :CAN_HANDLE");
         CHECK_INTERFACE(IDrmManagerService, data, reply);
 
         const int uniqueId = data.readInt32();
@@ -897,7 +909,7 @@
 
     case PROCESS_DRM_INFO:
     {
-        LOGV("BnDrmManagerService::onTransact :PROCESS_DRM_INFO");
+        ALOGV("BnDrmManagerService::onTransact :PROCESS_DRM_INFO");
         CHECK_INTERFACE(IDrmManagerService, data, reply);
 
         const int uniqueId = data.readInt32();
@@ -945,7 +957,7 @@
 
     case ACQUIRE_DRM_INFO:
     {
-        LOGV("BnDrmManagerService::onTransact :ACQUIRE_DRM_INFO");
+        ALOGV("BnDrmManagerService::onTransact :ACQUIRE_DRM_INFO");
         CHECK_INTERFACE(IDrmManagerService, data, reply);
 
         const int uniqueId = data.readInt32();
@@ -993,7 +1005,7 @@
 
     case SAVE_RIGHTS:
     {
-        LOGV("BnDrmManagerService::onTransact :SAVE_RIGHTS");
+        ALOGV("BnDrmManagerService::onTransact :SAVE_RIGHTS");
         CHECK_INTERFACE(IDrmManagerService, data, reply);
 
         const int uniqueId = data.readInt32();
@@ -1023,7 +1035,7 @@
 
     case GET_ORIGINAL_MIMETYPE:
     {
-        LOGV("BnDrmManagerService::onTransact :GET_ORIGINAL_MIMETYPE");
+        ALOGV("BnDrmManagerService::onTransact :GET_ORIGINAL_MIMETYPE");
         CHECK_INTERFACE(IDrmManagerService, data, reply);
 
         const int uniqueId = data.readInt32();
@@ -1036,7 +1048,7 @@
 
     case GET_DRM_OBJECT_TYPE:
     {
-        LOGV("BnDrmManagerService::onTransact :GET_DRM_OBJECT_TYPE");
+        ALOGV("BnDrmManagerService::onTransact :GET_DRM_OBJECT_TYPE");
         CHECK_INTERFACE(IDrmManagerService, data, reply);
 
         const int uniqueId = data.readInt32();
@@ -1050,7 +1062,7 @@
 
     case CHECK_RIGHTS_STATUS:
     {
-        LOGV("BnDrmManagerService::onTransact :CHECK_RIGHTS_STATUS");
+        ALOGV("BnDrmManagerService::onTransact :CHECK_RIGHTS_STATUS");
         CHECK_INTERFACE(IDrmManagerService, data, reply);
 
         const int uniqueId = data.readInt32();
@@ -1064,7 +1076,7 @@
 
     case CONSUME_RIGHTS:
     {
-        LOGV("BnDrmManagerService::onTransact :CONSUME_RIGHTS");
+        ALOGV("BnDrmManagerService::onTransact :CONSUME_RIGHTS");
         CHECK_INTERFACE(IDrmManagerService, data, reply);
 
         const int uniqueId = data.readInt32();
@@ -1084,7 +1096,7 @@
 
     case SET_PLAYBACK_STATUS:
     {
-        LOGV("BnDrmManagerService::onTransact :SET_PLAYBACK_STATUS");
+        ALOGV("BnDrmManagerService::onTransact :SET_PLAYBACK_STATUS");
         CHECK_INTERFACE(IDrmManagerService, data, reply);
 
         const int uniqueId = data.readInt32();
@@ -1104,7 +1116,7 @@
 
     case VALIDATE_ACTION:
     {
-        LOGV("BnDrmManagerService::onTransact :VALIDATE_ACTION");
+        ALOGV("BnDrmManagerService::onTransact :VALIDATE_ACTION");
         CHECK_INTERFACE(IDrmManagerService, data, reply);
 
         const int uniqueId = data.readInt32();
@@ -1121,7 +1133,7 @@
 
     case REMOVE_RIGHTS:
     {
-        LOGV("BnDrmManagerService::onTransact :REMOVE_RIGHTS");
+        ALOGV("BnDrmManagerService::onTransact :REMOVE_RIGHTS");
         CHECK_INTERFACE(IDrmManagerService, data, reply);
 
         int uniqueId = data.readInt32();
@@ -1134,7 +1146,7 @@
 
     case REMOVE_ALL_RIGHTS:
     {
-        LOGV("BnDrmManagerService::onTransact :REMOVE_ALL_RIGHTS");
+        ALOGV("BnDrmManagerService::onTransact :REMOVE_ALL_RIGHTS");
         CHECK_INTERFACE(IDrmManagerService, data, reply);
 
         const status_t status = removeAllRights(data.readInt32());
@@ -1145,7 +1157,7 @@
 
     case OPEN_CONVERT_SESSION:
     {
-        LOGV("BnDrmManagerService::onTransact :OPEN_CONVERT_SESSION");
+        ALOGV("BnDrmManagerService::onTransact :OPEN_CONVERT_SESSION");
         CHECK_INTERFACE(IDrmManagerService, data, reply);
 
         const int uniqueId = data.readInt32();
@@ -1158,7 +1170,7 @@
 
     case CONVERT_DATA:
     {
-        LOGV("BnDrmManagerService::onTransact :CONVERT_DATA");
+        ALOGV("BnDrmManagerService::onTransact :CONVERT_DATA");
         CHECK_INTERFACE(IDrmManagerService, data, reply);
 
         const int uniqueId = data.readInt32();
@@ -1193,7 +1205,7 @@
 
     case CLOSE_CONVERT_SESSION:
     {
-        LOGV("BnDrmManagerService::onTransact :CLOSE_CONVERT_SESSION");
+        ALOGV("BnDrmManagerService::onTransact :CLOSE_CONVERT_SESSION");
         CHECK_INTERFACE(IDrmManagerService, data, reply);
 
         const int uniqueId = data.readInt32();
@@ -1223,7 +1235,7 @@
 
     case GET_ALL_SUPPORT_INFO:
     {
-        LOGV("BnDrmManagerService::onTransact :GET_ALL_SUPPORT_INFO");
+        ALOGV("BnDrmManagerService::onTransact :GET_ALL_SUPPORT_INFO");
         CHECK_INTERFACE(IDrmManagerService, data, reply);
 
         const int uniqueId = data.readInt32();
@@ -1257,7 +1269,7 @@
 
     case OPEN_DECRYPT_SESSION:
     {
-        LOGV("BnDrmManagerService::onTransact :OPEN_DECRYPT_SESSION");
+        ALOGV("BnDrmManagerService::onTransact :OPEN_DECRYPT_SESSION");
         CHECK_INTERFACE(IDrmManagerService, data, reply);
 
         const int uniqueId = data.readInt32();
@@ -1265,8 +1277,10 @@
 
         const off64_t offset = data.readInt64();
         const off64_t length = data.readInt64();
+        const String8 mime = data.readString8();
+
         DecryptHandle* handle
-            = openDecryptSession(uniqueId, fd, offset, length);
+            = openDecryptSession(uniqueId, fd, offset, length, mime.string());
 
         if (NULL != handle) {
             writeDecryptHandleToParcelData(handle, reply);
@@ -1278,13 +1292,14 @@
 
     case OPEN_DECRYPT_SESSION_FROM_URI:
     {
-        LOGV("BnDrmManagerService::onTransact :OPEN_DECRYPT_SESSION_FROM_URI");
+        ALOGV("BnDrmManagerService::onTransact :OPEN_DECRYPT_SESSION_FROM_URI");
         CHECK_INTERFACE(IDrmManagerService, data, reply);
 
         const int uniqueId = data.readInt32();
         const String8 uri = data.readString8();
+        const String8 mime = data.readString8();
 
-        DecryptHandle* handle = openDecryptSession(uniqueId, uri.string());
+        DecryptHandle* handle = openDecryptSession(uniqueId, uri.string(), mime.string());
 
         if (NULL != handle) {
             writeDecryptHandleToParcelData(handle, reply);
@@ -1292,14 +1307,14 @@
             clearDecryptHandle(handle);
             delete handle; handle = NULL;
         } else {
-            LOGV("NULL decryptHandle is returned");
+            ALOGV("NULL decryptHandle is returned");
         }
         return DRM_NO_ERROR;
     }
 
     case CLOSE_DECRYPT_SESSION:
     {
-        LOGV("BnDrmManagerService::onTransact :CLOSE_DECRYPT_SESSION");
+        ALOGV("BnDrmManagerService::onTransact :CLOSE_DECRYPT_SESSION");
         CHECK_INTERFACE(IDrmManagerService, data, reply);
 
         const int uniqueId = data.readInt32();
@@ -1314,7 +1329,7 @@
 
     case INITIALIZE_DECRYPT_UNIT:
     {
-        LOGV("BnDrmManagerService::onTransact :INITIALIZE_DECRYPT_UNIT");
+        ALOGV("BnDrmManagerService::onTransact :INITIALIZE_DECRYPT_UNIT");
         CHECK_INTERFACE(IDrmManagerService, data, reply);
 
         const int uniqueId = data.readInt32();
@@ -1340,7 +1355,7 @@
 
     case DECRYPT:
     {
-        LOGV("BnDrmManagerService::onTransact :DECRYPT");
+        ALOGV("BnDrmManagerService::onTransact :DECRYPT");
         CHECK_INTERFACE(IDrmManagerService, data, reply);
 
         const int uniqueId = data.readInt32();
@@ -1384,7 +1399,7 @@
 
     case FINALIZE_DECRYPT_UNIT:
     {
-        LOGV("BnDrmManagerService::onTransact :FINALIZE_DECRYPT_UNIT");
+        ALOGV("BnDrmManagerService::onTransact :FINALIZE_DECRYPT_UNIT");
         CHECK_INTERFACE(IDrmManagerService, data, reply);
 
         const int uniqueId = data.readInt32();
@@ -1401,7 +1416,7 @@
 
     case PREAD:
     {
-        LOGV("BnDrmManagerService::onTransact :READ");
+        ALOGV("BnDrmManagerService::onTransact :READ");
         CHECK_INTERFACE(IDrmManagerService, data, reply);
 
         const int uniqueId = data.readInt32();
diff --git a/drm/common/ReadWriteUtils.cpp b/drm/common/ReadWriteUtils.cpp
index c16214e..fd17e98 100644
--- a/drm/common/ReadWriteUtils.cpp
+++ b/drm/common/ReadWriteUtils.cpp
@@ -85,7 +85,7 @@
         int size = data.size();
         if (FAILURE != ftruncate(fd, size)) {
             if (size != write(fd, data.string(), size)) {
-                LOGE("Failed to write the data to: %s", filePath.string());
+                ALOGE("Failed to write the data to: %s", filePath.string());
             }
         }
         fclose(file);
@@ -101,7 +101,7 @@
 
         int size = data.size();
         if (size != write(fd, data.string(), size)) {
-            LOGE("Failed to write the data to: %s", filePath.string());
+            ALOGE("Failed to write the data to: %s", filePath.string());
         }
         fclose(file);
     }
diff --git a/drm/drmserver/DrmManager.cpp b/drm/drmserver/DrmManager.cpp
index b2fa053..999295a 100644
--- a/drm/drmserver/DrmManager.cpp
+++ b/drm/drmserver/DrmManager.cpp
@@ -426,7 +426,9 @@
     return DRM_NO_ERROR;
 }
 
-DecryptHandle* DrmManager::openDecryptSession(int uniqueId, int fd, off64_t offset, off64_t length) {
+DecryptHandle* DrmManager::openDecryptSession(
+        int uniqueId, int fd, off64_t offset, off64_t length, const char* mime) {
+
     Mutex::Autolock _l(mDecryptLock);
     status_t result = DRM_ERROR_CANNOT_HANDLE;
     Vector<String8> plugInIdList = mPlugInManager.getPlugInIdList();
@@ -438,7 +440,7 @@
         for (unsigned int index = 0; index < plugInIdList.size(); index++) {
             String8 plugInId = plugInIdList.itemAt(index);
             IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId);
-            result = rDrmEngine.openDecryptSession(uniqueId, handle, fd, offset, length);
+            result = rDrmEngine.openDecryptSession(uniqueId, handle, fd, offset, length, mime);
 
             if (DRM_NO_ERROR == result) {
                 ++mDecryptSessionId;
@@ -453,7 +455,8 @@
     return handle;
 }
 
-DecryptHandle* DrmManager::openDecryptSession(int uniqueId, const char* uri) {
+DecryptHandle* DrmManager::openDecryptSession(
+        int uniqueId, const char* uri, const char* mime) {
     Mutex::Autolock _l(mDecryptLock);
     status_t result = DRM_ERROR_CANNOT_HANDLE;
     Vector<String8> plugInIdList = mPlugInManager.getPlugInIdList();
@@ -465,7 +468,7 @@
         for (unsigned int index = 0; index < plugInIdList.size(); index++) {
             String8 plugInId = plugInIdList.itemAt(index);
             IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId);
-            result = rDrmEngine.openDecryptSession(uniqueId, handle, uri);
+            result = rDrmEngine.openDecryptSession(uniqueId, handle, uri, mime);
 
             if (DRM_NO_ERROR == result) {
                 ++mDecryptSessionId;
@@ -476,7 +479,7 @@
     }
     if (DRM_NO_ERROR != result) {
         delete handle; handle = NULL;
-        LOGV("DrmManager::openDecryptSession: no capable plug-in found");
+        ALOGV("DrmManager::openDecryptSession: no capable plug-in found");
     }
     return handle;
 }
diff --git a/drm/drmserver/DrmManagerService.cpp b/drm/drmserver/DrmManagerService.cpp
index 7ebcac3..caeb026 100644
--- a/drm/drmserver/DrmManagerService.cpp
+++ b/drm/drmserver/DrmManagerService.cpp
@@ -52,7 +52,7 @@
 }
 
 void DrmManagerService::instantiate() {
-    LOGV("instantiate");
+    ALOGV("instantiate");
     defaultServiceManager()->addService(String16("drm.drmManager"), new DrmManagerService());
 
     if (0 >= trustedUids.size()) {
@@ -67,13 +67,13 @@
 
 DrmManagerService::DrmManagerService() :
         mDrmManager(NULL) {
-    LOGV("created");
+    ALOGV("created");
     mDrmManager = new DrmManager();
     mDrmManager->loadPlugIns();
 }
 
 DrmManagerService::~DrmManagerService() {
-    LOGV("Destroyed");
+    ALOGV("Destroyed");
     mDrmManager->unloadPlugIns();
     delete mDrmManager; mDrmManager = NULL;
 }
@@ -96,164 +96,164 @@
 
 status_t DrmManagerService::setDrmServiceListener(
             int uniqueId, const sp<IDrmServiceListener>& drmServiceListener) {
-    LOGV("Entering setDrmServiceListener");
+    ALOGV("Entering setDrmServiceListener");
     mDrmManager->setDrmServiceListener(uniqueId, drmServiceListener);
     return DRM_NO_ERROR;
 }
 
 status_t DrmManagerService::installDrmEngine(int uniqueId, const String8& drmEngineFile) {
-    LOGV("Entering installDrmEngine");
+    ALOGV("Entering installDrmEngine");
     return mDrmManager->installDrmEngine(uniqueId, drmEngineFile);
 }
 
 DrmConstraints* DrmManagerService::getConstraints(
             int uniqueId, const String8* path, const int action) {
-    LOGV("Entering getConstraints from content");
+    ALOGV("Entering getConstraints from content");
     return mDrmManager->getConstraints(uniqueId, path, action);
 }
 
 DrmMetadata* DrmManagerService::getMetadata(int uniqueId, const String8* path) {
-    LOGV("Entering getMetadata from content");
+    ALOGV("Entering getMetadata from content");
     return mDrmManager->getMetadata(uniqueId, path);
 }
 
 bool DrmManagerService::canHandle(int uniqueId, const String8& path, const String8& mimeType) {
-    LOGV("Entering canHandle");
+    ALOGV("Entering canHandle");
     return mDrmManager->canHandle(uniqueId, path, mimeType);
 }
 
 DrmInfoStatus* DrmManagerService::processDrmInfo(int uniqueId, const DrmInfo* drmInfo) {
-    LOGV("Entering processDrmInfo");
+    ALOGV("Entering processDrmInfo");
     return mDrmManager->processDrmInfo(uniqueId, drmInfo);
 }
 
 DrmInfo* DrmManagerService::acquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInfoRequest) {
-    LOGV("Entering acquireDrmInfo");
+    ALOGV("Entering acquireDrmInfo");
     return mDrmManager->acquireDrmInfo(uniqueId, drmInfoRequest);
 }
 
 status_t DrmManagerService::saveRights(
             int uniqueId, const DrmRights& drmRights,
             const String8& rightsPath, const String8& contentPath) {
-    LOGV("Entering saveRights");
+    ALOGV("Entering saveRights");
     return mDrmManager->saveRights(uniqueId, drmRights, rightsPath, contentPath);
 }
 
 String8 DrmManagerService::getOriginalMimeType(int uniqueId, const String8& path) {
-    LOGV("Entering getOriginalMimeType");
+    ALOGV("Entering getOriginalMimeType");
     return mDrmManager->getOriginalMimeType(uniqueId, path);
 }
 
 int DrmManagerService::getDrmObjectType(
            int uniqueId, const String8& path, const String8& mimeType) {
-    LOGV("Entering getDrmObjectType");
+    ALOGV("Entering getDrmObjectType");
     return mDrmManager->getDrmObjectType(uniqueId, path, mimeType);
 }
 
 int DrmManagerService::checkRightsStatus(
             int uniqueId, const String8& path, int action) {
-    LOGV("Entering checkRightsStatus");
+    ALOGV("Entering checkRightsStatus");
     return mDrmManager->checkRightsStatus(uniqueId, path, action);
 }
 
 status_t DrmManagerService::consumeRights(
             int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve) {
-    LOGV("Entering consumeRights");
+    ALOGV("Entering consumeRights");
     return mDrmManager->consumeRights(uniqueId, decryptHandle, action, reserve);
 }
 
 status_t DrmManagerService::setPlaybackStatus(
             int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int64_t position) {
-    LOGV("Entering setPlaybackStatus");
+    ALOGV("Entering setPlaybackStatus");
     return mDrmManager->setPlaybackStatus(uniqueId, decryptHandle, playbackStatus, position);
 }
 
 bool DrmManagerService::validateAction(
             int uniqueId, const String8& path,
             int action, const ActionDescription& description) {
-    LOGV("Entering validateAction");
+    ALOGV("Entering validateAction");
     return mDrmManager->validateAction(uniqueId, path, action, description);
 }
 
 status_t DrmManagerService::removeRights(int uniqueId, const String8& path) {
-    LOGV("Entering removeRights");
+    ALOGV("Entering removeRights");
     return mDrmManager->removeRights(uniqueId, path);
 }
 
 status_t DrmManagerService::removeAllRights(int uniqueId) {
-    LOGV("Entering removeAllRights");
+    ALOGV("Entering removeAllRights");
     return mDrmManager->removeAllRights(uniqueId);
 }
 
 int DrmManagerService::openConvertSession(int uniqueId, const String8& mimeType) {
-    LOGV("Entering openConvertSession");
+    ALOGV("Entering openConvertSession");
     return mDrmManager->openConvertSession(uniqueId, mimeType);
 }
 
 DrmConvertedStatus* DrmManagerService::convertData(
             int uniqueId, int convertId, const DrmBuffer* inputData) {
-    LOGV("Entering convertData");
+    ALOGV("Entering convertData");
     return mDrmManager->convertData(uniqueId, convertId, inputData);
 }
 
 DrmConvertedStatus* DrmManagerService::closeConvertSession(int uniqueId, int convertId) {
-    LOGV("Entering closeConvertSession");
+    ALOGV("Entering closeConvertSession");
     return mDrmManager->closeConvertSession(uniqueId, convertId);
 }
 
 status_t DrmManagerService::getAllSupportInfo(
             int uniqueId, int* length, DrmSupportInfo** drmSupportInfoArray) {
-    LOGV("Entering getAllSupportInfo");
+    ALOGV("Entering getAllSupportInfo");
     return mDrmManager->getAllSupportInfo(uniqueId, length, drmSupportInfoArray);
 }
 
 DecryptHandle* DrmManagerService::openDecryptSession(
-            int uniqueId, int fd, off64_t offset, off64_t length) {
-    LOGV("Entering DrmManagerService::openDecryptSession");
+            int uniqueId, int fd, off64_t offset, off64_t length, const char* mime) {
+    ALOGV("Entering DrmManagerService::openDecryptSession");
     if (isProtectedCallAllowed()) {
-        return mDrmManager->openDecryptSession(uniqueId, fd, offset, length);
+        return mDrmManager->openDecryptSession(uniqueId, fd, offset, length, mime);
     }
 
     return NULL;
 }
 
 DecryptHandle* DrmManagerService::openDecryptSession(
-            int uniqueId, const char* uri) {
-    LOGV("Entering DrmManagerService::openDecryptSession with uri");
+            int uniqueId, const char* uri, const char* mime) {
+    ALOGV("Entering DrmManagerService::openDecryptSession with uri");
     if (isProtectedCallAllowed()) {
-        return mDrmManager->openDecryptSession(uniqueId, uri);
+        return mDrmManager->openDecryptSession(uniqueId, uri, mime);
     }
 
     return NULL;
 }
 
 status_t DrmManagerService::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {
-    LOGV("Entering closeDecryptSession");
+    ALOGV("Entering closeDecryptSession");
     return mDrmManager->closeDecryptSession(uniqueId, decryptHandle);
 }
 
 status_t DrmManagerService::initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
             int decryptUnitId, const DrmBuffer* headerInfo) {
-    LOGV("Entering initializeDecryptUnit");
+    ALOGV("Entering initializeDecryptUnit");
     return mDrmManager->initializeDecryptUnit(uniqueId,decryptHandle, decryptUnitId, headerInfo);
 }
 
 status_t DrmManagerService::decrypt(
             int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,
             const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) {
-    LOGV("Entering decrypt");
+    ALOGV("Entering decrypt");
     return mDrmManager->decrypt(uniqueId, decryptHandle, decryptUnitId, encBuffer, decBuffer, IV);
 }
 
 status_t DrmManagerService::finalizeDecryptUnit(
             int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) {
-    LOGV("Entering finalizeDecryptUnit");
+    ALOGV("Entering finalizeDecryptUnit");
     return mDrmManager->finalizeDecryptUnit(uniqueId, decryptHandle, decryptUnitId);
 }
 
 ssize_t DrmManagerService::pread(int uniqueId, DecryptHandle* decryptHandle,
             void* buffer, ssize_t numBytes, off64_t offset) {
-    LOGV("Entering pread");
+    ALOGV("Entering pread");
     return mDrmManager->pread(uniqueId, decryptHandle, buffer, numBytes, offset);
 }
 
diff --git a/drm/drmserver/main_drmserver.cpp b/drm/drmserver/main_drmserver.cpp
index 6d10646..e61b269 100644
--- a/drm/drmserver/main_drmserver.cpp
+++ b/drm/drmserver/main_drmserver.cpp
@@ -14,6 +14,9 @@
  * limitations under the License.
  */
 
+#define LOG_TAG "drmserver"
+//#define LOG_NDEBUG 0
+
 #include <sys/types.h>
 #include <unistd.h>
 #include <grp.h>
@@ -32,7 +35,7 @@
 {
     sp<ProcessState> proc(ProcessState::self());
     sp<IServiceManager> sm = defaultServiceManager();
-    LOGI("ServiceManager: %p", sm.get());
+    ALOGV("ServiceManager: %p", sm.get());
     DrmManagerService::instantiate();
     ProcessState::self()->startThreadPool();
     IPCThreadState::self()->joinThreadPool();
diff --git a/drm/libdrmframework/DrmManagerClient.cpp b/drm/libdrmframework/DrmManagerClient.cpp
index c9c0d57..8768c08 100644
--- a/drm/libdrmframework/DrmManagerClient.cpp
+++ b/drm/libdrmframework/DrmManagerClient.cpp
@@ -116,12 +116,18 @@
     return mDrmManagerClientImpl->getAllSupportInfo(mUniqueId, length, drmSupportInfoArray);
 }
 
-sp<DecryptHandle> DrmManagerClient::openDecryptSession(int fd, off64_t offset, off64_t length) {
-    return mDrmManagerClientImpl->openDecryptSession(mUniqueId, fd, offset, length);
+sp<DecryptHandle> DrmManagerClient::openDecryptSession(
+        int fd, off64_t offset, off64_t length, const char* mime) {
+
+    return mDrmManagerClientImpl->openDecryptSession(
+                    mUniqueId, fd, offset, length, mime);
 }
 
-sp<DecryptHandle> DrmManagerClient::openDecryptSession(const char* uri) {
-    return mDrmManagerClientImpl->openDecryptSession(mUniqueId, uri);
+sp<DecryptHandle> DrmManagerClient::openDecryptSession(
+        const char* uri, const char* mime) {
+
+    return mDrmManagerClientImpl->openDecryptSession(
+                    mUniqueId, uri, mime);
 }
 
 status_t DrmManagerClient::closeDecryptSession(sp<DecryptHandle> &decryptHandle) {
diff --git a/drm/libdrmframework/DrmManagerClientImpl.cpp b/drm/libdrmframework/DrmManagerClientImpl.cpp
index 67f58ca..fb0439e 100644
--- a/drm/libdrmframework/DrmManagerClientImpl.cpp
+++ b/drm/libdrmframework/DrmManagerClientImpl.cpp
@@ -54,7 +54,7 @@
             if (binder != 0) {
                 break;
             }
-            LOGW("DrmManagerService not published, waiting...");
+            ALOGW("DrmManagerService not published, waiting...");
             struct timespec reqt;
             reqt.tv_sec  = 0;
             reqt.tv_nsec = 500000000; //0.5 sec
@@ -255,15 +255,19 @@
 }
 
 sp<DecryptHandle> DrmManagerClientImpl::openDecryptSession(
-            int uniqueId, int fd, off64_t offset, off64_t length) {
-    return getDrmManagerService()->openDecryptSession(uniqueId, fd, offset, length);
+            int uniqueId, int fd, off64_t offset,
+            off64_t length, const char* mime) {
+
+    return getDrmManagerService()->openDecryptSession(
+                uniqueId, fd, offset, length, mime);
 }
 
 sp<DecryptHandle> DrmManagerClientImpl::openDecryptSession(
-        int uniqueId, const char* uri) {
+        int uniqueId, const char* uri, const char* mime) {
+
     DecryptHandle* handle = NULL;
     if (NULL != uri) {
-        handle = getDrmManagerService()->openDecryptSession(uniqueId, uri);
+        handle = getDrmManagerService()->openDecryptSession(uniqueId, uri, mime);
     }
     return handle;
 }
@@ -342,6 +346,6 @@
 void DrmManagerClientImpl::DeathNotifier::binderDied(const wp<IBinder>& who) {
     Mutex::Autolock lock(sMutex);
     DrmManagerClientImpl::sDrmManagerService.clear();
-    LOGW("DrmManager server died!");
+    ALOGW("DrmManager server died!");
 }
 
diff --git a/drm/libdrmframework/include/DrmManager.h b/drm/libdrmframework/include/DrmManager.h
index ac2b946..c9167d4 100644
--- a/drm/libdrmframework/include/DrmManager.h
+++ b/drm/libdrmframework/include/DrmManager.h
@@ -111,9 +111,10 @@
 
     status_t getAllSupportInfo(int uniqueId, int* length, DrmSupportInfo** drmSupportInfoArray);
 
-    DecryptHandle* openDecryptSession(int uniqueId, int fd, off64_t offset, off64_t length);
+    DecryptHandle* openDecryptSession(
+            int uniqueId, int fd, off64_t offset, off64_t length, const char* mime);
 
-    DecryptHandle* openDecryptSession(int uniqueId, const char* uri);
+    DecryptHandle* openDecryptSession(int uniqueId, const char* uri, const char* mime);
 
     status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle);
 
diff --git a/drm/libdrmframework/include/DrmManagerClientImpl.h b/drm/libdrmframework/include/DrmManagerClientImpl.h
index e3338d9..2aa493f 100644
--- a/drm/libdrmframework/include/DrmManagerClientImpl.h
+++ b/drm/libdrmframework/include/DrmManagerClientImpl.h
@@ -300,20 +300,24 @@
      * @param[in] fd File descriptor of the protected content to be decrypted
      * @param[in] offset Start position of the content
      * @param[in] length The length of the protected content
+     * @param[in] mime The mime type of the protected content if it is not NULL or empty
      * @return
      *     Handle for the decryption session
      */
-    sp<DecryptHandle> openDecryptSession(int uniqueId, int fd, off64_t offset, off64_t length);
+    sp<DecryptHandle> openDecryptSession(
+            int uniqueId, int fd, off64_t offset, off64_t length, const char* mime);
 
     /**
      * Open the decrypt session to decrypt the given protected content
      *
      * @param[in] uniqueId Unique identifier for a session
      * @param[in] uri Path of the protected content to be decrypted
+     * @param[in] mime The mime type of the protected content if it is not NULL or empty
      * @return
      *     Handle for the decryption session
      */
-    sp<DecryptHandle> openDecryptSession(int uniqueId, const char* uri);
+    sp<DecryptHandle> openDecryptSession(
+            int uniqueId, const char* uri, const char* mime);
 
     /**
      * Close the decrypt session for the given handle
diff --git a/drm/libdrmframework/include/DrmManagerService.h b/drm/libdrmframework/include/DrmManagerService.h
index 9cb5804..1a8c2ae 100644
--- a/drm/libdrmframework/include/DrmManagerService.h
+++ b/drm/libdrmframework/include/DrmManagerService.h
@@ -98,9 +98,11 @@
 
     status_t getAllSupportInfo(int uniqueId, int* length, DrmSupportInfo** drmSupportInfoArray);
 
-    DecryptHandle* openDecryptSession(int uniqueId, int fd, off64_t offset, off64_t length);
+    DecryptHandle* openDecryptSession(
+        int uniqueId, int fd, off64_t offset, off64_t length, const char *mime);
 
-    DecryptHandle* openDecryptSession(int uniqueId, const char* uri);
+    DecryptHandle* openDecryptSession(
+        int uniqueId, const char* uri, const char* mime);
 
     status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle);
 
diff --git a/drm/libdrmframework/include/IDrmManagerService.h b/drm/libdrmframework/include/IDrmManagerService.h
index b9618bb..a7d21c5 100644
--- a/drm/libdrmframework/include/IDrmManagerService.h
+++ b/drm/libdrmframework/include/IDrmManagerService.h
@@ -139,9 +139,12 @@
     virtual status_t getAllSupportInfo(
             int uniqueId, int* length, DrmSupportInfo** drmSupportInfoArray) = 0;
 
-    virtual DecryptHandle* openDecryptSession(int uniqueId, int fd, off64_t offset, off64_t length) = 0;
+    virtual DecryptHandle* openDecryptSession(
+                int uniqueId, int fd, off64_t offset,
+                off64_t length, const char* mime) = 0;
 
-    virtual DecryptHandle* openDecryptSession(int uniqueId, const char* uri) = 0;
+    virtual DecryptHandle* openDecryptSession(
+                int uniqueId, const char* uri, const char* mime) = 0;
 
     virtual status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) = 0;
 
@@ -222,9 +225,12 @@
     virtual status_t getAllSupportInfo(
             int uniqueId, int* length, DrmSupportInfo** drmSupportInfoArray);
 
-    virtual DecryptHandle* openDecryptSession(int uniqueId, int fd, off64_t offset, off64_t length);
+    virtual DecryptHandle* openDecryptSession(
+                int uniqueId, int fd, off64_t offset, off64_t length,
+                const char* mime);
 
-    virtual DecryptHandle* openDecryptSession(int uniqueId, const char* uri);
+    virtual DecryptHandle* openDecryptSession(
+                int uniqueId, const char* uri, const char* mime);
 
     virtual status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle);
 
diff --git a/drm/libdrmframework/plugins/common/include/DrmEngineBase.h b/drm/libdrmframework/plugins/common/include/DrmEngineBase.h
index 4a5afcf..08f6e6d 100644
--- a/drm/libdrmframework/plugins/common/include/DrmEngineBase.h
+++ b/drm/libdrmframework/plugins/common/include/DrmEngineBase.h
@@ -80,10 +80,12 @@
     DrmSupportInfo* getSupportInfo(int uniqueId);
 
     status_t openDecryptSession(
-            int uniqueId, DecryptHandle* decryptHandle, int fd, off64_t offset, off64_t length);
+            int uniqueId, DecryptHandle* decryptHandle,
+            int fd, off64_t offset, off64_t length, const char* mime);
 
     status_t openDecryptSession(
-            int uniqueId, DecryptHandle* decryptHandle, const char* uri);
+            int uniqueId, DecryptHandle* decryptHandle,
+            const char* uri, const char* mime);
 
     status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle);
 
@@ -375,7 +377,29 @@
      *     DRM_ERROR_CANNOT_HANDLE for failure and DRM_NO_ERROR for success
      */
     virtual status_t onOpenDecryptSession(
-            int uniqueId, DecryptHandle* decryptHandle, int fd, off64_t offset, off64_t length) = 0;
+            int uniqueId, DecryptHandle* decryptHandle,
+            int fd, off64_t offset, off64_t length) = 0;
+
+    /**
+     * Open the decrypt session to decrypt the given protected content
+     *
+     * @param[in] uniqueId Unique identifier for a session
+     * @param[in] decryptHandle Handle for the current decryption session
+     * @param[in] fd File descriptor of the protected content to be decrypted
+     * @param[in] offset Start position of the content
+     * @param[in] length The length of the protected content
+     * @param[in] mime Mime type of the protected content
+     *     drm plugin may do some optimization since the mime type is known.
+     * @return
+     *     DRM_ERROR_CANNOT_HANDLE for failure and DRM_NO_ERROR for success
+     */
+    virtual status_t onOpenDecryptSession(
+            int uniqueId, DecryptHandle* decryptHandle,
+            int fd, off64_t offset, off64_t length,
+            const char* mime) {
+
+        return DRM_ERROR_CANNOT_HANDLE;
+    }
 
     /**
      * Open the decrypt session to decrypt the given protected content
@@ -387,7 +411,26 @@
      *     DRM_ERROR_CANNOT_HANDLE for failure and DRM_NO_ERROR for success
      */
     virtual status_t onOpenDecryptSession(
-            int uniqueId, DecryptHandle* decryptHandle, const char* uri) = 0;
+            int uniqueId, DecryptHandle* decryptHandle,
+            const char* uri) = 0;
+
+    /**
+     * Open the decrypt session to decrypt the given protected content
+     *
+     * @param[in] uniqueId Unique identifier for a session
+     * @param[in] decryptHandle Handle for the current decryption session
+     * @param[in] uri Path of the protected content to be decrypted
+     * @param[in] mime Mime type of the protected content. The corresponding
+     *     drm plugin may do some optimization since the mime type is known.
+     * @return
+     *     DRM_ERROR_CANNOT_HANDLE for failure and DRM_NO_ERROR for success
+     */
+    virtual status_t onOpenDecryptSession(
+            int uniqueId, DecryptHandle* decryptHandle,
+            const char* uri, const char* mime) {
+
+        return DRM_ERROR_CANNOT_HANDLE;
+    }
 
     /**
      * Close the decrypt session for the given handle
diff --git a/drm/libdrmframework/plugins/common/include/IDrmEngine.h b/drm/libdrmframework/plugins/common/include/IDrmEngine.h
index 77460f6..dcf5977 100644
--- a/drm/libdrmframework/plugins/common/include/IDrmEngine.h
+++ b/drm/libdrmframework/plugins/common/include/IDrmEngine.h
@@ -320,11 +320,14 @@
      * @param[in] fd File descriptor of the protected content to be decrypted
      * @param[in] offset Start position of the content
      * @param[in] length The length of the protected content
+     * @param[in] mime Mime type of the protected content if it is
+     *     not NULL or empty
      * @return
      *     DRM_ERROR_CANNOT_HANDLE for failure and DRM_NO_ERROR for success
      */
     virtual status_t openDecryptSession(
-        int uniqueId, DecryptHandle* decryptHandle, int fd, off64_t offset, off64_t length) = 0;
+        int uniqueId, DecryptHandle* decryptHandle,
+        int fd, off64_t offset, off64_t length, const char* mime) = 0;
 
     /**
      * Open the decrypt session to decrypt the given protected content
@@ -332,11 +335,14 @@
      * @param[in] uniqueId Unique identifier for a session
      * @param[in] decryptHandle Handle for the current decryption session
      * @param[in] uri Path of the protected content to be decrypted
+     * @param[in] mime Mime type of the protected content if it is
+     *     not NULL or empty
      * @return
      *     DRM_ERROR_CANNOT_HANDLE for failure and DRM_NO_ERROR for success
      */
     virtual status_t openDecryptSession(
-        int uniqueId, DecryptHandle* decryptHandle, const char* uri) = 0;
+        int uniqueId, DecryptHandle* decryptHandle,
+        const char* uri, const char* mime) = 0;
 
     /**
      * Close the decrypt session for the given handle
diff --git a/drm/libdrmframework/plugins/common/util/src/MimeTypeUtil.cpp b/drm/libdrmframework/plugins/common/util/src/MimeTypeUtil.cpp
index 57ef799..576ed15 100644
--- a/drm/libdrmframework/plugins/common/util/src/MimeTypeUtil.cpp
+++ b/drm/libdrmframework/plugins/common/util/src/MimeTypeUtil.cpp
@@ -24,7 +24,7 @@
 
 #ifdef DRM_OMA_FL_ENGINE_DEBUG
 #define LOG_NDEBUG 0
-#define LOG_DEBUG(...) LOGD(__VA_ARGS__)
+#define LOG_DEBUG(...) ALOGD(__VA_ARGS__)
 #else
 #define LOG_DEBUG(...)
 #endif
diff --git a/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/src/FwdLockEngine.cpp b/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/src/FwdLockEngine.cpp
index e184545..0273a4b 100644
--- a/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/src/FwdLockEngine.cpp
+++ b/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/src/FwdLockEngine.cpp
@@ -43,7 +43,7 @@
 
 #ifdef DRM_OMA_FL_ENGINE_DEBUG
 #define LOG_NDEBUG 0
-#define LOG_VERBOSE(...) LOGV(__VA_ARGS__)
+#define LOG_VERBOSE(...) ALOGV(__VA_ARGS__)
 #else
 #define LOG_VERBOSE(...)
 #endif
@@ -92,12 +92,12 @@
         case FwdLockConv_Status_InvalidArgument:
         case FwdLockConv_Status_UnsupportedFileFormat:
         case FwdLockConv_Status_UnsupportedContentTransferEncoding:
-            LOGE("FwdLockEngine getConvertedStatus: file conversion Error %d. "
+            ALOGE("FwdLockEngine getConvertedStatus: file conversion Error %d. "
                   "Returning STATUS_INPUTDATA_ERROR", status);
             retStatus = DrmConvertedStatus::STATUS_INPUTDATA_ERROR;
             break;
         default:
-            LOGE("FwdLockEngine getConvertedStatus: file conversion Error %d. "
+            ALOGE("FwdLockEngine getConvertedStatus: file conversion Error %d. "
                   "Returning STATUS_ERROR", status);
             retStatus = DrmConvertedStatus::STATUS_ERROR;
             break;
@@ -139,7 +139,7 @@
     if (FwdLockGlue_InitializeKeyEncryption()) {
         LOG_VERBOSE("FwdLockEngine::onInitialize -- FwdLockGlue_InitializeKeyEncryption succeeded");
     } else {
-        LOGE("FwdLockEngine::onInitialize -- FwdLockGlue_InitializeKeyEncryption failed:"
+        ALOGE("FwdLockEngine::onInitialize -- FwdLockGlue_InitializeKeyEncryption failed:"
              "errno = %d", errno);
     }
 
@@ -351,7 +351,7 @@
             convertSessionMap.addValue(convertId, newSession);
             result = DRM_NO_ERROR;
         } else {
-            LOGE("FwdLockEngine::onOpenConvertSession -- FwdLockConv_OpenSession failed.");
+            ALOGE("FwdLockEngine::onOpenConvertSession -- FwdLockConv_OpenSession failed.");
             delete newSession;
         }
     }
@@ -448,7 +448,7 @@
         (!decodeSessionMap.isCreated(decryptHandle->decryptId))) {
         fileDesc = dup(fd);
     } else {
-        LOGE("FwdLockEngine::onOpenDecryptSession parameter error");
+        ALOGE("FwdLockEngine::onOpenDecryptSession parameter error");
         return result;
     }
 
@@ -550,13 +550,13 @@
                                                 DecryptHandle* decryptHandle,
                                                 int decryptUnitId,
                                                 const DrmBuffer* headerInfo) {
-    LOGE("FwdLockEngine::onInitializeDecryptUnit is not supported for this DRM scheme");
+    ALOGE("FwdLockEngine::onInitializeDecryptUnit is not supported for this DRM scheme");
     return DRM_ERROR_UNKNOWN;
 }
 
 status_t FwdLockEngine::onDecrypt(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,
             const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) {
-    LOGE("FwdLockEngine::onDecrypt is not supported for this DRM scheme");
+    ALOGE("FwdLockEngine::onDecrypt is not supported for this DRM scheme");
     return DRM_ERROR_UNKNOWN;
 }
 
@@ -565,14 +565,14 @@
                                   int decryptUnitId,
                                   const DrmBuffer* encBuffer,
                                   DrmBuffer** decBuffer) {
-    LOGE("FwdLockEngine::onDecrypt is not supported for this DRM scheme");
+    ALOGE("FwdLockEngine::onDecrypt is not supported for this DRM scheme");
     return DRM_ERROR_UNKNOWN;
 }
 
 status_t FwdLockEngine::onFinalizeDecryptUnit(int uniqueId,
                                               DecryptHandle* decryptHandle,
                                               int decryptUnitId) {
-    LOGE("FwdLockEngine::onFinalizeDecryptUnit is not supported for this DRM scheme");
+    ALOGE("FwdLockEngine::onFinalizeDecryptUnit is not supported for this DRM scheme");
     return DRM_ERROR_UNKNOWN;
 }
 
@@ -650,11 +650,11 @@
         if (((off_t)-1) != decoderSession->offset) {
             bytesRead = onRead(uniqueId, decryptHandle, buffer, numBytes);
             if (bytesRead < 0) {
-                LOGE("FwdLockEngine::onPread error reading");
+                ALOGE("FwdLockEngine::onPread error reading");
             }
         }
     } else {
-        LOGE("FwdLockEngine::onPread decryptId not found");
+        ALOGE("FwdLockEngine::onPread decryptId not found");
     }
 
     return bytesRead;
diff --git a/drm/libdrmframework/plugins/passthru/src/DrmPassthruPlugIn.cpp b/drm/libdrmframework/plugins/passthru/src/DrmPassthruPlugIn.cpp
index 976978f..0ffc0a7 100644
--- a/drm/libdrmframework/plugins/passthru/src/DrmPassthruPlugIn.cpp
+++ b/drm/libdrmframework/plugins/passthru/src/DrmPassthruPlugIn.cpp
@@ -58,7 +58,7 @@
 
 DrmConstraints* DrmPassthruPlugIn::onGetConstraints(
         int uniqueId, const String8* path, int action) {
-    LOGD("DrmPassthruPlugIn::onGetConstraints From Path: %d", uniqueId);
+    ALOGD("DrmPassthruPlugIn::onGetConstraints From Path: %d", uniqueId);
     DrmConstraints* drmConstraints = new DrmConstraints();
 
     String8 value("dummy_available_time");
@@ -73,7 +73,7 @@
 }
 
 DrmInfoStatus* DrmPassthruPlugIn::onProcessDrmInfo(int uniqueId, const DrmInfo* drmInfo) {
-    LOGD("DrmPassthruPlugIn::onProcessDrmInfo - Enter : %d", uniqueId);
+    ALOGD("DrmPassthruPlugIn::onProcessDrmInfo - Enter : %d", uniqueId);
     DrmInfoStatus* drmInfoStatus = NULL;
     if (NULL != drmInfo) {
         switch (drmInfo->getInfoType()) {
@@ -102,28 +102,28 @@
         }
         }
     }
-    LOGD("DrmPassthruPlugIn::onProcessDrmInfo - Exit");
+    ALOGD("DrmPassthruPlugIn::onProcessDrmInfo - Exit");
     return drmInfoStatus;
 }
 
 status_t DrmPassthruPlugIn::onSetOnInfoListener(
             int uniqueId, const IDrmEngine::OnInfoListener* infoListener) {
-    LOGD("DrmPassthruPlugIn::onSetOnInfoListener : %d", uniqueId);
+    ALOGD("DrmPassthruPlugIn::onSetOnInfoListener : %d", uniqueId);
     return DRM_NO_ERROR;
 }
 
 status_t DrmPassthruPlugIn::onInitialize(int uniqueId) {
-    LOGD("DrmPassthruPlugIn::onInitialize : %d", uniqueId);
+    ALOGD("DrmPassthruPlugIn::onInitialize : %d", uniqueId);
     return DRM_NO_ERROR;
 }
 
 status_t DrmPassthruPlugIn::onTerminate(int uniqueId) {
-    LOGD("DrmPassthruPlugIn::onTerminate : %d", uniqueId);
+    ALOGD("DrmPassthruPlugIn::onTerminate : %d", uniqueId);
     return DRM_NO_ERROR;
 }
 
 DrmSupportInfo* DrmPassthruPlugIn::onGetSupportInfo(int uniqueId) {
-    LOGD("DrmPassthruPlugIn::onGetSupportInfo : %d", uniqueId);
+    ALOGD("DrmPassthruPlugIn::onGetSupportInfo : %d", uniqueId);
     DrmSupportInfo* drmSupportInfo = new DrmSupportInfo();
     // Add mimetype's
     drmSupportInfo->addMimeType(String8("application/vnd.passthru.drm"));
@@ -136,12 +136,12 @@
 
 status_t DrmPassthruPlugIn::onSaveRights(int uniqueId, const DrmRights& drmRights,
             const String8& rightsPath, const String8& contentPath) {
-    LOGD("DrmPassthruPlugIn::onSaveRights : %d", uniqueId);
+    ALOGD("DrmPassthruPlugIn::onSaveRights : %d", uniqueId);
     return DRM_NO_ERROR;
 }
 
 DrmInfo* DrmPassthruPlugIn::onAcquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInfoRequest) {
-    LOGD("DrmPassthruPlugIn::onAcquireDrmInfo : %d", uniqueId);
+    ALOGD("DrmPassthruPlugIn::onAcquireDrmInfo : %d", uniqueId);
     DrmInfo* drmInfo = NULL;
 
     if (NULL != drmInfoRequest) {
@@ -157,65 +157,65 @@
 }
 
 bool DrmPassthruPlugIn::onCanHandle(int uniqueId, const String8& path) {
-    LOGD("DrmPassthruPlugIn::canHandle: %s ", path.string());
+    ALOGD("DrmPassthruPlugIn::canHandle: %s ", path.string());
     String8 extension = path.getPathExtension();
     extension.toLower();
     return (String8(".passthru") == extension);
 }
 
 String8 DrmPassthruPlugIn::onGetOriginalMimeType(int uniqueId, const String8& path) {
-    LOGD("DrmPassthruPlugIn::onGetOriginalMimeType() : %d", uniqueId);
+    ALOGD("DrmPassthruPlugIn::onGetOriginalMimeType() : %d", uniqueId);
     return String8("video/passthru");
 }
 
 int DrmPassthruPlugIn::onGetDrmObjectType(
             int uniqueId, const String8& path, const String8& mimeType) {
-    LOGD("DrmPassthruPlugIn::onGetDrmObjectType() : %d", uniqueId);
+    ALOGD("DrmPassthruPlugIn::onGetDrmObjectType() : %d", uniqueId);
     return DrmObjectType::UNKNOWN;
 }
 
 int DrmPassthruPlugIn::onCheckRightsStatus(int uniqueId, const String8& path, int action) {
-    LOGD("DrmPassthruPlugIn::onCheckRightsStatus() : %d", uniqueId);
+    ALOGD("DrmPassthruPlugIn::onCheckRightsStatus() : %d", uniqueId);
     int rightsStatus = RightsStatus::RIGHTS_VALID;
     return rightsStatus;
 }
 
 status_t DrmPassthruPlugIn::onConsumeRights(int uniqueId, DecryptHandle* decryptHandle,
             int action, bool reserve) {
-    LOGD("DrmPassthruPlugIn::onConsumeRights() : %d", uniqueId);
+    ALOGD("DrmPassthruPlugIn::onConsumeRights() : %d", uniqueId);
     return DRM_NO_ERROR;
 }
 
 status_t DrmPassthruPlugIn::onSetPlaybackStatus(int uniqueId, DecryptHandle* decryptHandle,
             int playbackStatus, int64_t position) {
-    LOGD("DrmPassthruPlugIn::onSetPlaybackStatus() : %d", uniqueId);
+    ALOGD("DrmPassthruPlugIn::onSetPlaybackStatus() : %d", uniqueId);
     return DRM_NO_ERROR;
 }
 
 bool DrmPassthruPlugIn::onValidateAction(int uniqueId, const String8& path,
             int action, const ActionDescription& description) {
-    LOGD("DrmPassthruPlugIn::onValidateAction() : %d", uniqueId);
+    ALOGD("DrmPassthruPlugIn::onValidateAction() : %d", uniqueId);
     return true;
 }
 
 status_t DrmPassthruPlugIn::onRemoveRights(int uniqueId, const String8& path) {
-    LOGD("DrmPassthruPlugIn::onRemoveRights() : %d", uniqueId);
+    ALOGD("DrmPassthruPlugIn::onRemoveRights() : %d", uniqueId);
     return DRM_NO_ERROR;
 }
 
 status_t DrmPassthruPlugIn::onRemoveAllRights(int uniqueId) {
-    LOGD("DrmPassthruPlugIn::onRemoveAllRights() : %d", uniqueId);
+    ALOGD("DrmPassthruPlugIn::onRemoveAllRights() : %d", uniqueId);
     return DRM_NO_ERROR;
 }
 
 status_t DrmPassthruPlugIn::onOpenConvertSession(int uniqueId, int convertId) {
-    LOGD("DrmPassthruPlugIn::onOpenConvertSession() : %d", uniqueId);
+    ALOGD("DrmPassthruPlugIn::onOpenConvertSession() : %d", uniqueId);
     return DRM_NO_ERROR;
 }
 
 DrmConvertedStatus* DrmPassthruPlugIn::onConvertData(
             int uniqueId, int convertId, const DrmBuffer* inputData) {
-    LOGD("DrmPassthruPlugIn::onConvertData() : %d", uniqueId);
+    ALOGD("DrmPassthruPlugIn::onConvertData() : %d", uniqueId);
     DrmBuffer* convertedData = NULL;
 
     if (NULL != inputData && 0 < inputData->length) {
@@ -229,13 +229,13 @@
 }
 
 DrmConvertedStatus* DrmPassthruPlugIn::onCloseConvertSession(int uniqueId, int convertId) {
-    LOGD("DrmPassthruPlugIn::onCloseConvertSession() : %d", uniqueId);
+    ALOGD("DrmPassthruPlugIn::onCloseConvertSession() : %d", uniqueId);
     return new DrmConvertedStatus(DrmConvertedStatus::STATUS_OK, NULL, 0 /*offset*/);
 }
 
 status_t DrmPassthruPlugIn::onOpenDecryptSession(
             int uniqueId, DecryptHandle* decryptHandle, int fd, off64_t offset, off64_t length) {
-    LOGD("DrmPassthruPlugIn::onOpenDecryptSession() : %d", uniqueId);
+    ALOGD("DrmPassthruPlugIn::onOpenDecryptSession() : %d", uniqueId);
 
 #ifdef ENABLE_PASSTHRU_DECRYPTION
     decryptHandle->mimeType = String8("video/passthru");
@@ -254,7 +254,7 @@
 }
 
 status_t DrmPassthruPlugIn::onCloseDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {
-    LOGD("DrmPassthruPlugIn::onCloseDecryptSession() : %d", uniqueId);
+    ALOGD("DrmPassthruPlugIn::onCloseDecryptSession() : %d", uniqueId);
     if (NULL != decryptHandle) {
         if (NULL != decryptHandle->decryptInfo) {
             delete decryptHandle->decryptInfo; decryptHandle->decryptInfo = NULL;
@@ -266,13 +266,13 @@
 
 status_t DrmPassthruPlugIn::onInitializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
             int decryptUnitId, const DrmBuffer* headerInfo) {
-    LOGD("DrmPassthruPlugIn::onInitializeDecryptUnit() : %d", uniqueId);
+    ALOGD("DrmPassthruPlugIn::onInitializeDecryptUnit() : %d", uniqueId);
     return DRM_NO_ERROR;
 }
 
 status_t DrmPassthruPlugIn::onDecrypt(int uniqueId, DecryptHandle* decryptHandle,
             int decryptUnitId, const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) {
-    LOGD("DrmPassthruPlugIn::onDecrypt() : %d", uniqueId);
+    ALOGD("DrmPassthruPlugIn::onDecrypt() : %d", uniqueId);
     /**
      * As a workaround implementation passthru would copy the given
      * encrypted buffer as it is to decrypted buffer. Note, decBuffer
@@ -287,13 +287,13 @@
 
 status_t DrmPassthruPlugIn::onFinalizeDecryptUnit(
             int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) {
-    LOGD("DrmPassthruPlugIn::onFinalizeDecryptUnit() : %d", uniqueId);
+    ALOGD("DrmPassthruPlugIn::onFinalizeDecryptUnit() : %d", uniqueId);
     return DRM_NO_ERROR;
 }
 
 ssize_t DrmPassthruPlugIn::onPread(int uniqueId, DecryptHandle* decryptHandle,
             void* buffer, ssize_t numBytes, off64_t offset) {
-    LOGD("DrmPassthruPlugIn::onPread() : %d", uniqueId);
+    ALOGD("DrmPassthruPlugIn::onPread() : %d", uniqueId);
     return 0;
 }
 
diff --git a/include/drm/DrmManagerClient.h b/include/drm/DrmManagerClient.h
index b8fe46d..c47bbfb 100644
--- a/include/drm/DrmManagerClient.h
+++ b/include/drm/DrmManagerClient.h
@@ -66,19 +66,21 @@
      * @param[in] fd File descriptor of the protected content to be decrypted
      * @param[in] offset Start position of the content
      * @param[in] length The length of the protected content
+     * @param[in] mime Mime type of the protected content if it is not NULL or empty
      * @return
      *     Handle for the decryption session
      */
-    sp<DecryptHandle> openDecryptSession(int fd, off64_t offset, off64_t length);
+    sp<DecryptHandle> openDecryptSession(int fd, off64_t offset, off64_t length, const char* mime);
 
     /**
      * Open the decrypt session to decrypt the given protected content
      *
      * @param[in] uri Path of the protected content to be decrypted
+     * @param[in] mime Mime type of the protected content if it is not NULL or empty
      * @return
      *     Handle for the decryption session
      */
-    sp<DecryptHandle> openDecryptSession(const char* uri);
+    sp<DecryptHandle> openDecryptSession(const char* uri, const char* mime);
 
     /**
      * Close the decrypt session for the given handle
diff --git a/include/media/AudioRecord.h b/include/media/AudioRecord.h
index 605680a..2fb69b6 100644
--- a/include/media/AudioRecord.h
+++ b/include/media/AudioRecord.h
@@ -385,6 +385,8 @@
     uint32_t                mChannelMask;
     audio_io_handle_t       mInput;
     int                     mSessionId;
+    int                     mPreviousPriority;          // before start()
+    int                     mPreviousSchedulingGroup;
 };
 
 }; // namespace android
diff --git a/include/media/AudioTrack.h b/include/media/AudioTrack.h
index d1a8105..60b052b 100644
--- a/include/media/AudioTrack.h
+++ b/include/media/AudioTrack.h
@@ -38,7 +38,7 @@
 
 // ----------------------------------------------------------------------------
 
-class AudioTrack
+class AudioTrack : virtual public RefBase
 {
 public:
     enum channel_index {
@@ -69,21 +69,22 @@
             MUTE    = 0x00000001
         };
         uint32_t    flags;
-        int         format;
+        audio_format_t format; // but AUDIO_FORMAT_PCM_8_BIT -> AUDIO_FORMAT_PCM_16_BIT
+        // accessed directly by WebKit ANP callback
         int         channelCount; // will be removed in the future, do not use
         size_t      frameCount;
         size_t      size;
         union {
             void*       raw;
-            short*      i16;
-            int8_t*     i8;
+            short*      i16;    // signed 16-bit
+            int8_t*     i8;     // unsigned 8-bit, offset by 0x80
         };
     };
 
 
     /* As a convenience, if a callback is supplied, a handler thread
      * is automatically created with the appropriate priority. This thread
-     * invokes the callback when a new buffer becomes availlable or an underrun condition occurs.
+     * invokes the callback when a new buffer becomes available or an underrun condition occurs.
      * Parameters:
      *
      * event:   type of event notified (see enum AudioTrack::event_type).
@@ -94,8 +95,8 @@
      *          written.
      *          - EVENT_UNDERRUN: unused.
      *          - EVENT_LOOP_END: pointer to an int indicating the number of loops remaining.
-     *          - EVENT_MARKER: pointer to an uin32_t containing the marker position in frames.
-     *          - EVENT_NEW_POS: pointer to an uin32_t containing the new position in frames.
+     *          - EVENT_MARKER: pointer to an uint32_t containing the marker position in frames.
+     *          - EVENT_NEW_POS: pointer to an uint32_t containing the new position in frames.
      *          - EVENT_BUFFER_END: unused.
      */
 
@@ -135,14 +136,15 @@
      * flags:              Reserved for future use.
      * cbf:                Callback function. If not null, this function is called periodically
      *                     to request new PCM data.
+     * user:               Context for use by the callback receiver.
      * notificationFrames: The callback function is called each time notificationFrames PCM
-     *                     frames have been comsumed from track input buffer.
-     * user                Context for use by the callback receiver.
+     *                     frames have been consumed from track input buffer.
+     * sessionId:          Specific session ID, or zero to use default.
      */
 
                         AudioTrack( int streamType,
                                     uint32_t sampleRate  = 0,
-                                    int format           = 0,
+                                    audio_format_t format = AUDIO_FORMAT_DEFAULT,
                                     int channelMask      = 0,
                                     int frameCount       = 0,
                                     uint32_t flags       = 0,
@@ -152,17 +154,17 @@
                                     int sessionId = 0);
 
     /* Creates an audio track and registers it with AudioFlinger. With this constructor,
-     * The PCM data to be rendered by AudioTrack is passed in a shared memory buffer
+     * the PCM data to be rendered by AudioTrack is passed in a shared memory buffer
      * identified by the argument sharedBuffer. This prototype is for static buffer playback.
-     * PCM data must be present into memory before the AudioTrack is started.
-     * The Write() and Flush() methods are not supported in this case.
-     * It is recommented to pass a callback function to be notified of playback end by an
+     * PCM data must be present in memory before the AudioTrack is started.
+     * The write() and flush() methods are not supported in this case.
+     * It is recommended to pass a callback function to be notified of playback end by an
      * EVENT_UNDERRUN event.
      */
 
                         AudioTrack( int streamType,
                                     uint32_t sampleRate = 0,
-                                    int format          = 0,
+                                    audio_format_t format = AUDIO_FORMAT_DEFAULT,
                                     int channelMask     = 0,
                                     const sp<IMemory>& sharedBuffer = 0,
                                     uint32_t flags      = 0,
@@ -172,21 +174,21 @@
                                     int sessionId = 0);
 
     /* Terminates the AudioTrack and unregisters it from AudioFlinger.
-     * Also destroys all resources assotiated with the AudioTrack.
+     * Also destroys all resources associated with the AudioTrack.
      */
                         ~AudioTrack();
 
 
     /* Initialize an uninitialized AudioTrack.
      * Returned status (from utils/Errors.h) can be:
-     *  - NO_ERROR: successful intialization
-     *  - INVALID_OPERATION: AudioTrack is already intitialized
+     *  - NO_ERROR: successful initialization
+     *  - INVALID_OPERATION: AudioTrack is already initialized
      *  - BAD_VALUE: invalid parameter (channels, format, sampleRate...)
      *  - NO_INIT: audio server or audio hardware not initialized
      * */
             status_t    set(int streamType      =-1,
                             uint32_t sampleRate = 0,
-                            int format          = 0,
+                            audio_format_t format = AUDIO_FORMAT_DEFAULT,
                             int channelMask     = 0,
                             int frameCount      = 0,
                             uint32_t flags      = 0,
@@ -199,13 +201,13 @@
 
 
     /* Result of constructing the AudioTrack. This must be checked
-     * before using any AudioTrack API (except for set()), using
+     * before using any AudioTrack API (except for set()), because using
      * an uninitialized AudioTrack produces undefined results.
      * See set() method above for possible return codes.
      */
             status_t    initCheck() const;
 
-    /* Returns this track's latency in milliseconds.
+    /* Returns this track's estimated latency in milliseconds.
      * This includes the latency due to AudioTrack buffer size, AudioMixer (if any)
      * and audio hardware driver.
      */
@@ -214,7 +216,7 @@
     /* getters, see constructor */
 
             int         streamType() const;
-            int         format() const;
+            audio_format_t format() const;
             int         channelCount() const;
             uint32_t    frameCount() const;
             int         frameSize() const;
@@ -233,8 +235,8 @@
             void        stop();
             bool        stopped() const;
 
-    /* flush a stopped track. All pending buffers are discarded.
-     * This function has no effect if the track is not stoped.
+    /* Flush a stopped track. All pending buffers are discarded.
+     * This function has no effect if the track is not stopped.
      */
             void        flush();
 
@@ -244,26 +246,25 @@
      */
             void        pause();
 
-    /* mute or unmutes this track.
-     * While mutted, the callback, if set, is still called.
+    /* Mute or unmute this track.
+     * While muted, the callback, if set, is still called.
      */
             void        mute(bool);
             bool        muted() const;
 
-
-    /* set volume for this track, mostly used for games' sound effects
-     * left and right volumes. Levels must be <= 1.0.
+    /* Set volume for this track, mostly used for games' sound effects
+     * left and right volumes. Levels must be >= 0.0 and <= 1.0.
      */
             status_t    setVolume(float left, float right);
             void        getVolume(float* left, float* right);
 
-    /* set the send level for this track. An auxiliary effect should be attached
-     * to the track with attachEffect(). Level must be <= 1.0.
+    /* Set the send level for this track. An auxiliary effect should be attached
+     * to the track with attachEffect(). Level must be >= 0.0 and <= 1.0.
      */
             status_t    setAuxEffectSendLevel(float level);
             void        getAuxEffectSendLevel(float* level);
 
-    /* set sample rate for this track, mostly used for games' sound effects
+    /* Set sample rate for this track, mostly used for games' sound effects
      */
             status_t    setSampleRate(int sampleRate);
             uint32_t    getSampleRate();
@@ -274,8 +275,8 @@
      *
      * loopStart:   loop start expressed as the number of PCM frames played since AudioTrack start.
      * loopEnd:     loop end expressed as the number of PCM frames played since AudioTrack start.
-     * loopCount:   number of loops to execute. Calling setLoop() with loopCount == 0 cancels any pending or
-     *          active loop. loopCount = -1 means infinite looping.
+     * loopCount:   number of loops to execute. Calling setLoop() with loopCount == 0 cancels any
+     *              pending or active loop. loopCount = -1 means infinite looping.
      *
      * For proper operation the following condition must be respected:
      *          (loopEnd-loopStart) <= framecount()
@@ -283,10 +284,9 @@
             status_t    setLoop(uint32_t loopStart, uint32_t loopEnd, int loopCount);
             status_t    getLoop(uint32_t *loopStart, uint32_t *loopEnd, int *loopCount);
 
-
-    /* Sets marker position. When playback reaches the number of frames specified, a callback with event 
-     * type EVENT_MARKER is called. Calling setMarkerPosition with marker == 0 cancels marker notification 
-     * callback. 
+    /* Sets marker position. When playback reaches the number of frames specified, a callback with
+     * event type EVENT_MARKER is called. Calling setMarkerPosition with marker == 0 cancels marker
+     * notification callback.
      * If the AudioTrack has been opened with no callback function associated, the operation will fail.
      *
      * Parameters:
@@ -301,10 +301,10 @@
             status_t    getMarkerPosition(uint32_t *marker);
 
 
-    /* Sets position update period. Every time the number of frames specified has been played, 
-     * a callback with event type EVENT_NEW_POS is called. 
-     * Calling setPositionUpdatePeriod with updatePeriod == 0 cancels new position notification 
-     * callback. 
+    /* Sets position update period. Every time the number of frames specified has been played,
+     * a callback with event type EVENT_NEW_POS is called.
+     * Calling setPositionUpdatePeriod with updatePeriod == 0 cancels new position notification
+     * callback.
      * If the AudioTrack has been opened with no callback function associated, the operation will fail.
      *
      * Parameters:
@@ -318,12 +318,11 @@
             status_t    setPositionUpdatePeriod(uint32_t updatePeriod);
             status_t    getPositionUpdatePeriod(uint32_t *updatePeriod);
 
-
     /* Sets playback head position within AudioTrack buffer. The new position is specified
-     * in number of frames. 
+     * in number of frames.
      * This method must be called with the AudioTrack in paused or stopped state.
-     * Note that the actual position set is <position> modulo the AudioTrack buffer size in frames. 
-     * Therefore using this method makes sense only when playing a "static" audio buffer 
+     * Note that the actual position set is <position> modulo the AudioTrack buffer size in frames.
+     * Therefore using this method makes sense only when playing a "static" audio buffer
      * as opposed to streaming.
      * The getPosition() method on the other hand returns the total number of frames played since
      * playback start.
@@ -335,12 +334,12 @@
      * Returned status (from utils/Errors.h) can be:
      *  - NO_ERROR: successful operation
      *  - INVALID_OPERATION: the AudioTrack is not stopped.
-     *  - BAD_VALUE: The specified position is beyond the number of frames present in AudioTrack buffer 
+     *  - BAD_VALUE: The specified position is beyond the number of frames present in AudioTrack buffer
      */
             status_t    setPosition(uint32_t position);
             status_t    getPosition(uint32_t *position);
 
-    /* Forces AudioTrack buffer full condition. When playing a static buffer, this method avoids 
+    /* Forces AudioTrack buffer full condition. When playing a static buffer, this method avoids
      * rewriting the buffer before restarting playback after a stop.
      * This method must be called with the AudioTrack in paused or stopped state.
      *
@@ -350,7 +349,7 @@
      */
             status_t    reload();
 
-    /* returns a handle on the audio output used by this AudioTrack.
+    /* Returns a handle on the audio output used by this AudioTrack.
      *
      * Parameters:
      *  none.
@@ -360,18 +359,17 @@
      */
             audio_io_handle_t    getOutput();
 
-    /* returns the unique ID associated to this track.
+    /* Returns the unique session ID associated with this track.
      *
      * Parameters:
      *  none.
      *
      * Returned value:
-     *  AudioTrack ID.
+     *  AudioTrack session ID.
      */
             int    getSessionId();
 
-
-    /* Attach track auxiliary output to specified effect. Used effectId = 0
+    /* Attach track auxiliary output to specified effect. Use effectId = 0
      * to detach track from effect.
      *
      * Parameters:
@@ -385,9 +383,9 @@
      */
             status_t    attachAuxEffect(int effectId);
 
-    /* obtains a buffer of "frameCount" frames. The buffer must be
+    /* Obtains a buffer of "frameCount" frames. The buffer must be
      * filled entirely. If the track is stopped, obtainBuffer() returns
-     * STOPPED instead of NO_ERROR as long as there are buffers availlable,
+     * STOPPED instead of NO_ERROR as long as there are buffers available,
      * at which point NO_MORE_BUFFERS is returned.
      * Buffers will be returned until the pool (buffercount())
      * is exhausted, at which point obtainBuffer() will either block
@@ -403,10 +401,9 @@
             status_t    obtainBuffer(Buffer* audioBuffer, int32_t waitCount);
             void        releaseBuffer(Buffer* audioBuffer);
 
-
     /* As a convenience we provide a write() interface to the audio buffer.
      * This is implemented on top of lockBuffer/unlockBuffer. For best
-     * performance
+     * performance use callbacks. Return actual number of bytes written.
      *
      */
             ssize_t     write(const void* buffer, size_t size);
@@ -438,7 +435,7 @@
             bool processAudioBuffer(const sp<AudioTrackThread>& thread);
             status_t createTrack_l(int streamType,
                                  uint32_t sampleRate,
-                                 uint32_t format,
+                                 audio_format_t format,
                                  uint32_t channelMask,
                                  int frameCount,
                                  uint32_t flags,
@@ -449,6 +446,7 @@
             status_t setLoop_l(uint32_t loopStart, uint32_t loopEnd, int loopCount);
             audio_io_handle_t getOutput_l();
             status_t restoreTrack_l(audio_track_cblk_t*& cblk, bool fromStart);
+            bool stopped_l() const { return !mActive; }
 
     sp<IAudioTrack>         mAudioTrack;
     sp<IMemory>             mCblkMemory;
@@ -459,7 +457,7 @@
     uint32_t                mFrameCount;
 
     audio_track_cblk_t*     mCblk;
-    uint32_t                mFormat;
+    audio_format_t          mFormat;
     uint8_t                 mStreamType;
     uint8_t                 mChannelCount;
     uint8_t                 mMuted;
@@ -468,7 +466,7 @@
     status_t                mStatus;
     uint32_t                mLatency;
 
-    volatile int32_t        mActive;
+    bool                    mActive;                // protected by mLock
 
     callback_t              mCbf;
     void*                   mUserData;
@@ -485,8 +483,10 @@
     uint32_t                mFlags;
     int                     mSessionId;
     int                     mAuxEffectId;
-    Mutex                   mLock;
+    mutable Mutex           mLock;
     status_t                mRestoreStatus;
+    int                     mPreviousPriority;          // before start()
+    int                     mPreviousSchedulingGroup;
 };
 
 
diff --git a/include/media/IAudioTrack.h b/include/media/IAudioTrack.h
index 47d530b..b83e552 100644
--- a/include/media/IAudioTrack.h
+++ b/include/media/IAudioTrack.h
@@ -35,6 +35,9 @@
 public: 
     DECLARE_META_INTERFACE(AudioTrack);
 
+    /* Get this track's control block */
+    virtual sp<IMemory> getCblk() const = 0;
+
     /* After it's created the track is not active. Call start() to
      * make it active. If set, the callback will start being called.
      */
@@ -46,13 +49,13 @@
      */
     virtual void        stop() = 0;
 
-    /* flush a stopped track. All pending buffers are discarded.
-     * This function has no effect if the track is not stoped.
+    /* Flush a stopped track. All pending buffers are discarded.
+     * This function has no effect if the track is not stopped.
      */
     virtual void        flush() = 0;
 
-    /* mute or unmutes this track.
-     * While mutted, the callback, if set, is still called.
+    /* Mute or unmute this track.
+     * While muted, the callback, if set, is still called.
      */
     virtual void        mute(bool) = 0;
     
@@ -67,8 +70,6 @@
      */
     virtual status_t    attachAuxEffect(int effectId) = 0;
 
-    /* get this tracks control block */
-    virtual sp<IMemory> getCblk() const = 0;    
 };
 
 // ----------------------------------------------------------------------------
diff --git a/include/media/IMediaPlayerService.h b/include/media/IMediaPlayerService.h
index 93bbe13..4f46fcd 100644
--- a/include/media/IMediaPlayerService.h
+++ b/include/media/IMediaPlayerService.h
@@ -23,6 +23,7 @@
 #include <utils/String8.h>
 #include <binder/IInterface.h>
 #include <binder/Parcel.h>
+#include <system/audio.h>
 
 #include <media/IMediaPlayerClient.h>
 #include <media/IMediaPlayer.h>
@@ -43,8 +44,8 @@
     virtual sp<IMediaMetadataRetriever> createMetadataRetriever(pid_t pid) = 0;
     virtual sp<IMediaPlayer> create(pid_t pid, const sp<IMediaPlayerClient>& client, int audioSessionId = 0) = 0;
 
-    virtual sp<IMemory>         decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, int* pFormat) = 0;
-    virtual sp<IMemory>         decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, int* pFormat) = 0;
+    virtual sp<IMemory>         decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, audio_format_t* pFormat) = 0;
+    virtual sp<IMemory>         decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, audio_format_t* pFormat) = 0;
     virtual sp<IOMX>            getOMX() = 0;
 
     // codecs and audio devices usage tracking for the battery app
diff --git a/include/media/JetPlayer.h b/include/media/JetPlayer.h
index 16764a9..491a950 100644
--- a/include/media/JetPlayer.h
+++ b/include/media/JetPlayer.h
@@ -65,7 +65,6 @@
 
 
 private:
-    static  int         renderThread(void*);
     int                 render();
     void                fireUpdateOnStatusChange();
     void                fireEventsFromJetQueue();
@@ -95,8 +94,30 @@
     S_JET_STATUS        mJetStatus;
     S_JET_STATUS        mPreviousJetStatus;
 
-    char                mJetFilePath[256];
+    char                mJetFilePath[PATH_MAX];
 
+    class JetPlayerThread : public Thread {
+    public:
+        JetPlayerThread(JetPlayer *player) : mPlayer(player) {
+        }
+
+    protected:
+        virtual ~JetPlayerThread() {}
+
+    private:
+        JetPlayer *mPlayer;
+
+        bool threadLoop() {
+            int result;
+            result = mPlayer->render();
+            return false;
+        }
+
+        JetPlayerThread(const JetPlayerThread &);
+        JetPlayerThread &operator=(const JetPlayerThread &);
+    };
+
+    sp<JetPlayerThread> mThread;
 
 }; // end class JetPlayer
 
diff --git a/include/media/MediaPlayerInterface.h b/include/media/MediaPlayerInterface.h
index 80f43a3..1f6bdda 100644
--- a/include/media/MediaPlayerInterface.h
+++ b/include/media/MediaPlayerInterface.h
@@ -85,7 +85,7 @@
         // audio data.
         virtual status_t    open(
                 uint32_t sampleRate, int channelCount,
-                int format=AUDIO_FORMAT_PCM_16_BIT,
+                audio_format_t format=AUDIO_FORMAT_PCM_16_BIT,
                 int bufferCount=DEFAULT_AUDIOSINK_BUFFERCOUNT,
                 AudioCallback cb = NULL,
                 void *cookie = NULL) = 0;
diff --git a/include/media/mediaplayer.h b/include/media/mediaplayer.h
index e6a0cc5..2dc055e 100644
--- a/include/media/mediaplayer.h
+++ b/include/media/mediaplayer.h
@@ -190,8 +190,8 @@
             bool            isLooping();
             status_t        setVolume(float leftVolume, float rightVolume);
             void            notify(int msg, int ext1, int ext2, const Parcel *obj = NULL);
-    static  sp<IMemory>     decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, int* pFormat);
-    static  sp<IMemory>     decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, int* pFormat);
+    static  sp<IMemory>     decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, audio_format_t* pFormat);
+    static  sp<IMemory>     decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, audio_format_t* pFormat);
             status_t        invoke(const Parcel& request, Parcel *reply);
             status_t        setMetadataFilter(const Parcel& filter);
             status_t        getMetadata(bool update_only, bool apply_filter, Parcel *metadata);
diff --git a/include/media/stagefright/DataSource.h b/include/media/stagefright/DataSource.h
index 713af92..00d583e 100644
--- a/include/media/stagefright/DataSource.h
+++ b/include/media/stagefright/DataSource.h
@@ -81,7 +81,7 @@
     static void RegisterDefaultSniffers();
 
     // for DRM
-    virtual sp<DecryptHandle> DrmInitialization() {
+    virtual sp<DecryptHandle> DrmInitialization(const char *mime = NULL) {
         return NULL;
     }
     virtual void getDrmInfo(sp<DecryptHandle> &handle, DrmManagerClient **client) {};
diff --git a/include/media/stagefright/FileSource.h b/include/media/stagefright/FileSource.h
index 6cf86dc..d994cb3 100644
--- a/include/media/stagefright/FileSource.h
+++ b/include/media/stagefright/FileSource.h
@@ -38,7 +38,7 @@
 
     virtual status_t getSize(off64_t *size);
 
-    virtual sp<DecryptHandle> DrmInitialization();
+    virtual sp<DecryptHandle> DrmInitialization(const char *mime);
 
     virtual void getDrmInfo(sp<DecryptHandle> &handle, DrmManagerClient **client);
 
diff --git a/include/media/stagefright/MediaExtractor.h b/include/media/stagefright/MediaExtractor.h
index eb45237..94090ee 100644
--- a/include/media/stagefright/MediaExtractor.h
+++ b/include/media/stagefright/MediaExtractor.h
@@ -56,10 +56,10 @@
     virtual uint32_t flags() const;
 
     // for DRM
-    virtual void setDrmFlag(bool flag) {
+    void setDrmFlag(bool flag) {
         mIsDrm = flag;
     };
-    virtual bool getDrmFlag() {
+    bool getDrmFlag() {
         return mIsDrm;
     }
     virtual char* getDrmTrackInfo(size_t trackID, int *len) {
diff --git a/include/private/gui/ComposerService.h b/include/private/gui/ComposerService.h
new file mode 100644
index 0000000..d04491a
--- /dev/null
+++ b/include/private/gui/ComposerService.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2011 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 ANDROID_PRIVATE_GUI_COMPOSER_SERVICE_H
+#define ANDROID_PRIVATE_GUI_COMPOSER_SERVICE_H
+
+#include <stdint.h>
+#include <sys/types.h>
+
+#include <utils/Singleton.h>
+#include <utils/StrongPointer.h>
+
+
+namespace android {
+
+// ---------------------------------------------------------------------------
+
+class IMemoryHeap;
+class ISurfaceComposer;
+class surface_flinger_cblk_t;
+
+// ---------------------------------------------------------------------------
+
+class ComposerService : public Singleton<ComposerService>
+{
+    // these are constants
+    sp<ISurfaceComposer> mComposerService;
+    sp<IMemoryHeap> mServerCblkMemory;
+    surface_flinger_cblk_t volatile* mServerCblk;
+    ComposerService();
+    friend class Singleton<ComposerService>;
+public:
+    static sp<ISurfaceComposer> getComposerService();
+    static surface_flinger_cblk_t const volatile * getControlBlock();
+};
+
+// ---------------------------------------------------------------------------
+}; // namespace android
+
+#endif // ANDROID_PRIVATE_GUI_COMPOSER_SERVICE_H
diff --git a/include/private/media/AudioTrackShared.h b/include/private/media/AudioTrackShared.h
index 20abd51..046d5e9 100644
--- a/include/private/media/AudioTrackShared.h
+++ b/include/private/media/AudioTrackShared.h
@@ -59,8 +59,8 @@
 
     // The data members are grouped so that members accessed frequently and in the same context
     // are in the same line of data cache.
-                Mutex       lock;
-                Condition   cv;
+                Mutex       lock;           // sizeof(int)
+                Condition   cv;             // sizeof(int)
     volatile    uint32_t    user;
     volatile    uint32_t    server;
                 uint32_t    userBase;
diff --git a/media/libeffects/factory/EffectsFactory.c b/media/libeffects/factory/EffectsFactory.c
index d333510..9f6599f 100644
--- a/media/libeffects/factory/EffectsFactory.c
+++ b/media/libeffects/factory/EffectsFactory.c
@@ -188,7 +188,7 @@
     *pNumEffects = gNumEffects;
     gCanQueryEffect = 1;
     pthread_mutex_unlock(&gLibLock);
-    LOGV("EffectQueryNumberEffects(): %d", *pNumEffects);
+    ALOGV("EffectQueryNumberEffects(): %d", *pNumEffects);
     return ret;
 }
 
@@ -230,7 +230,7 @@
 #if (LOG_NDEBUG == 0)
     char str[256];
     dumpEffectDescriptor(pDescriptor, str, 256);
-    LOGV("EffectQueryEffect() desc:%s", str);
+    ALOGV("EffectQueryEffect() desc:%s", str);
 #endif
     pthread_mutex_unlock(&gLibLock);
     return ret;
@@ -271,7 +271,7 @@
         return -EINVAL;
     }
 
-    LOGV("EffectCreate() UUID: %08X-%04X-%04X-%04X-%02X%02X%02X%02X%02X%02X\n",
+    ALOGV("EffectCreate() UUID: %08X-%04X-%04X-%04X-%02X%02X%02X%02X%02X%02X\n",
             uuid->timeLow, uuid->timeMid, uuid->timeHiAndVersion,
             uuid->clockSeq, uuid->node[0], uuid->node[1],uuid->node[2],
             uuid->node[3],uuid->node[4],uuid->node[5]);
@@ -279,7 +279,7 @@
     ret = init();
 
     if (ret < 0) {
-        LOGW("EffectCreate() init error: %d", ret);
+        ALOGW("EffectCreate() init error: %d", ret);
         return ret;
     }
 
@@ -293,7 +293,7 @@
     // create effect in library
     ret = l->desc->create_effect(uuid, sessionId, ioId, &itfe);
     if (ret != 0) {
-        LOGW("EffectCreate() library %s: could not create fx %s, error %d", l->name, d->name, ret);
+        ALOGW("EffectCreate() library %s: could not create fx %s, error %d", l->name, d->name, ret);
         goto exit;
     }
 
@@ -302,10 +302,10 @@
     fx->subItfe = itfe;
     if ((*itfe)->process_reverse != NULL) {
         fx->itfe = (struct effect_interface_s *)&gInterfaceWithReverse;
-        LOGV("EffectCreate() gInterfaceWithReverse");
+        ALOGV("EffectCreate() gInterfaceWithReverse");
     }   else {
         fx->itfe = (struct effect_interface_s *)&gInterface;
-        LOGV("EffectCreate() gInterface");
+        ALOGV("EffectCreate() gInterface");
     }
     fx->lib = l;
 
@@ -316,7 +316,7 @@
 
     *pHandle = (effect_handle_t)fx;
 
-    LOGV("EffectCreate() created entry %p with sub itfe %p in library %s", *pHandle, itfe, l->name);
+    ALOGV("EffectCreate() created entry %p with sub itfe %p in library %s", *pHandle, itfe, l->name);
 
 exit:
     pthread_mutex_unlock(&gLibLock);
@@ -359,7 +359,7 @@
 
     // release effect in library
     if (fx->lib == NULL) {
-        LOGW("EffectRelease() fx %p library already unloaded", handle);
+        ALOGW("EffectRelease() fx %p library already unloaded", handle);
     } else {
         pthread_mutex_lock(&fx->lib->lock);
         fx->lib->desc->release_effect(fx->subItfe);
@@ -401,7 +401,7 @@
 
     updateNumEffects();
     gInitDone = 1;
-    LOGV("init() done");
+    ALOGV("init() done");
     return 0;
 }
 
@@ -456,24 +456,24 @@
 
     hdl = dlopen(node->value, RTLD_NOW);
     if (hdl == NULL) {
-        LOGW("loadLibrary() failed to open %s", node->value);
+        ALOGW("loadLibrary() failed to open %s", node->value);
         goto error;
     }
 
     desc = (audio_effect_library_t *)dlsym(hdl, AUDIO_EFFECT_LIBRARY_INFO_SYM_AS_STR);
     if (desc == NULL) {
-        LOGW("loadLibrary() could not find symbol %s", AUDIO_EFFECT_LIBRARY_INFO_SYM_AS_STR);
+        ALOGW("loadLibrary() could not find symbol %s", AUDIO_EFFECT_LIBRARY_INFO_SYM_AS_STR);
         goto error;
     }
 
     if (AUDIO_EFFECT_LIBRARY_TAG != desc->tag) {
-        LOGW("getLibrary() bad tag %08x in lib info struct", desc->tag);
+        ALOGW("getLibrary() bad tag %08x in lib info struct", desc->tag);
         goto error;
     }
 
     if (EFFECT_API_VERSION_MAJOR(desc->version) !=
             EFFECT_API_VERSION_MAJOR(EFFECT_LIBRARY_API_VERSION)) {
-        LOGW("loadLibrary() bad lib version %08x", desc->version);
+        ALOGW("loadLibrary() bad lib version %08x", desc->version);
         goto error;
     }
 
@@ -492,7 +492,7 @@
     e->next = gLibraryList;
     gLibraryList = e;
     pthread_mutex_unlock(&gLibLock);
-    LOGV("getLibrary() linked library %p for path %s", l, node->value);
+    ALOGV("getLibrary() linked library %p for path %s", l, node->value);
 
     return 0;
 
@@ -534,7 +534,7 @@
 
     l = getLibrary(node->value);
     if (l == NULL) {
-        LOGW("loadEffect() could not get library %s", node->value);
+        ALOGW("loadEffect() could not get library %s", node->value);
         return -EINVAL;
     }
 
@@ -543,7 +543,7 @@
         return -EINVAL;
     }
     if (stringToUuid(node->value, &uuid) != 0) {
-        LOGW("loadEffect() invalid uuid %s", node->value);
+        ALOGW("loadEffect() invalid uuid %s", node->value);
         return -EINVAL;
     }
 
@@ -551,18 +551,18 @@
     if (l->desc->get_descriptor(&uuid, d) != 0) {
         char s[40];
         uuidToString(&uuid, s, 40);
-        LOGW("Error querying effect %s on lib %s", s, l->name);
+        ALOGW("Error querying effect %s on lib %s", s, l->name);
         free(d);
         return -EINVAL;
     }
 #if (LOG_NDEBUG==0)
     char s[256];
     dumpEffectDescriptor(d, s, 256);
-    LOGV("loadEffect() read descriptor %p:%s",d, s);
+    ALOGV("loadEffect() read descriptor %p:%s",d, s);
 #endif
     if (EFFECT_API_VERSION_MAJOR(d->apiVersion) !=
             EFFECT_API_VERSION_MAJOR(EFFECT_CONTROL_API_VERSION)) {
-        LOGW("Bad API version %08x on lib %s", d->apiVersion, l->name);
+        ALOGW("Bad API version %08x on lib %s", d->apiVersion, l->name);
         free(d);
         return -EINVAL;
     }
@@ -657,10 +657,10 @@
         e = e->next;
     }
     if (!found) {
-        LOGV("findEffect() effect not found");
+        ALOGV("findEffect() effect not found");
         ret = -ENOENT;
     } else {
-        LOGV("findEffect() found effect: %s in lib %s", d->name, l->name);
+        ALOGV("findEffect() found effect: %s in lib %s", d->name, l->name);
         *lib = l;
         if (desc) {
             *desc = d;
diff --git a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
index 5a1e93a..108d36a 100644
--- a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
+++ b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
@@ -32,19 +32,19 @@
 
 #define LVM_ERROR_CHECK(LvmStatus, callingFunc, calledFunc){\
         if (LvmStatus == LVM_NULLADDRESS){\
-            LOGV("\tLVM_ERROR : Parameter error - "\
+            ALOGV("\tLVM_ERROR : Parameter error - "\
                     "null pointer returned by %s in %s\n\n\n\n", callingFunc, calledFunc);\
         }\
         if (LvmStatus == LVM_ALIGNMENTERROR){\
-            LOGV("\tLVM_ERROR : Parameter error - "\
+            ALOGV("\tLVM_ERROR : Parameter error - "\
                     "bad alignment returned by %s in %s\n\n\n\n", callingFunc, calledFunc);\
         }\
         if (LvmStatus == LVM_INVALIDNUMSAMPLES){\
-            LOGV("\tLVM_ERROR : Parameter error - "\
+            ALOGV("\tLVM_ERROR : Parameter error - "\
                     "bad number of samples returned by %s in %s\n\n\n\n", callingFunc, calledFunc);\
         }\
         if (LvmStatus == LVM_OUTOFRANGE){\
-            LOGV("\tLVM_ERROR : Parameter error - "\
+            ALOGV("\tLVM_ERROR : Parameter error - "\
                     "out of range returned by %s in %s\n", callingFunc, calledFunc);\
         }\
     }
@@ -71,7 +71,7 @@
 /* local functions */
 #define CHECK_ARG(cond) {                     \
     if (!(cond)) {                            \
-        LOGV("\tLVM_ERROR : Invalid argument: "#cond);      \
+        ALOGV("\tLVM_ERROR : Invalid argument: "#cond);      \
         return -EINVAL;                       \
     }                                         \
 }
@@ -133,7 +133,8 @@
 int  LvmEffect_enable          (EffectContext *pContext);
 int  LvmEffect_disable         (EffectContext *pContext);
 void LvmEffect_free            (EffectContext *pContext);
-int  Effect_configure          (EffectContext *pContext, effect_config_t *pConfig);
+int  Effect_setConfig          (EffectContext *pContext, effect_config_t *pConfig);
+void Effect_getConfig          (EffectContext *pContext, effect_config_t *pConfig);
 int  BassBoost_setParameter    (EffectContext *pContext, void *pParam, void *pValue);
 int  BassBoost_getParameter    (EffectContext *pContext,
                                void           *pParam,
@@ -158,39 +159,39 @@
 
 /* Effect Library Interface Implementation */
 extern "C" int EffectQueryNumberEffects(uint32_t *pNumEffects){
-    LOGV("\n\tEffectQueryNumberEffects start");
+    ALOGV("\n\tEffectQueryNumberEffects start");
     *pNumEffects = 4;
-    LOGV("\tEffectQueryNumberEffects creating %d effects", *pNumEffects);
-    LOGV("\tEffectQueryNumberEffects end\n");
+    ALOGV("\tEffectQueryNumberEffects creating %d effects", *pNumEffects);
+    ALOGV("\tEffectQueryNumberEffects end\n");
     return 0;
 }     /* end EffectQueryNumberEffects */
 
 extern "C" int EffectQueryEffect(uint32_t index, effect_descriptor_t *pDescriptor){
-    LOGV("\n\tEffectQueryEffect start");
-    LOGV("\tEffectQueryEffect processing index %d", index);
+    ALOGV("\n\tEffectQueryEffect start");
+    ALOGV("\tEffectQueryEffect processing index %d", index);
 
     if (pDescriptor == NULL){
-        LOGV("\tLVM_ERROR : EffectQueryEffect was passed NULL pointer");
+        ALOGV("\tLVM_ERROR : EffectQueryEffect was passed NULL pointer");
         return -EINVAL;
     }
     if (index > 3){
-        LOGV("\tLVM_ERROR : EffectQueryEffect index out of range %d", index);
+        ALOGV("\tLVM_ERROR : EffectQueryEffect index out of range %d", index);
         return -ENOENT;
     }
     if(index == LVM_BASS_BOOST){
-        LOGV("\tEffectQueryEffect processing LVM_BASS_BOOST");
+        ALOGV("\tEffectQueryEffect processing LVM_BASS_BOOST");
         memcpy(pDescriptor, &gBassBoostDescriptor,   sizeof(effect_descriptor_t));
     }else if(index == LVM_VIRTUALIZER){
-        LOGV("\tEffectQueryEffect processing LVM_VIRTUALIZER");
+        ALOGV("\tEffectQueryEffect processing LVM_VIRTUALIZER");
         memcpy(pDescriptor, &gVirtualizerDescriptor, sizeof(effect_descriptor_t));
     } else if(index == LVM_EQUALIZER){
-        LOGV("\tEffectQueryEffect processing LVM_EQUALIZER");
+        ALOGV("\tEffectQueryEffect processing LVM_EQUALIZER");
         memcpy(pDescriptor, &gEqualizerDescriptor,   sizeof(effect_descriptor_t));
     } else if(index == LVM_VOLUME){
-        LOGV("\tEffectQueryEffect processing LVM_VOLUME");
+        ALOGV("\tEffectQueryEffect processing LVM_VOLUME");
         memcpy(pDescriptor, &gVolumeDescriptor, sizeof(effect_descriptor_t));
     }
-    LOGV("\tEffectQueryEffect end\n");
+    ALOGV("\tEffectQueryEffect end\n");
     return 0;
 }     /* end EffectQueryEffect */
 
@@ -205,17 +206,17 @@
     bool newBundle = false;
     SessionContext *pSessionContext;
 
-    LOGV("\n\tEffectCreate start session %d", sessionId);
+    ALOGV("\n\tEffectCreate start session %d", sessionId);
 
     if (pHandle == NULL || uuid == NULL){
-        LOGV("\tLVM_ERROR : EffectCreate() called with NULL pointer");
+        ALOGV("\tLVM_ERROR : EffectCreate() called with NULL pointer");
         ret = -EINVAL;
         goto exit;
     }
 
     if(LvmInitFlag == LVM_FALSE){
         LvmInitFlag = LVM_TRUE;
-        LOGV("\tEffectCreate - Initializing all global memory");
+        ALOGV("\tEffectCreate - Initializing all global memory");
         LvmGlobalBundle_init();
     }
 
@@ -224,13 +225,13 @@
         if((SessionIndex[i] == LVM_UNUSED_SESSION)||(SessionIndex[i] == sessionId)){
             sessionNo       = i;
             SessionIndex[i] = sessionId;
-            LOGV("\tEffectCreate: Allocating SessionNo %d for SessionId %d\n", sessionNo,sessionId);
+            ALOGV("\tEffectCreate: Allocating SessionNo %d for SessionId %d\n", sessionNo,sessionId);
             break;
         }
     }
 
     if(i==LVM_MAX_SESSIONS){
-        LOGV("\tLVM_ERROR : Cannot find memory to allocate for current session");
+        ALOGV("\tLVM_ERROR : Cannot find memory to allocate for current session");
         ret = -EINVAL;
         goto exit;
     }
@@ -239,7 +240,7 @@
 
     // If this is the first create in this session
     if(GlobalSessionMemory[sessionNo].bBundledEffectsEnabled == LVM_FALSE){
-        LOGV("\tEffectCreate - This is the first effect in current sessionId %d sessionNo %d",
+        ALOGV("\tEffectCreate - This is the first effect in current sessionId %d sessionNo %d",
                 sessionId, sessionNo);
 
         GlobalSessionMemory[sessionNo].bBundledEffectsEnabled = LVM_TRUE;
@@ -265,7 +266,7 @@
         snprintf(fileName, 256, "/data/tmp/bundle_%p_pcm_in.pcm", pContext->pBundledContext);
         pContext->pBundledContext->PcmInPtr = fopen(fileName, "w");
         if (pContext->pBundledContext->PcmInPtr == NULL) {
-            LOGV("cannot open %s", fileName);
+            ALOGV("cannot open %s", fileName);
             ret = -EINVAL;
             goto exit;
         }
@@ -273,7 +274,7 @@
         snprintf(fileName, 256, "/data/tmp/bundle_%p_pcm_out.pcm", pContext->pBundledContext);
         pContext->pBundledContext->PcmOutPtr = fopen(fileName, "w");
         if (pContext->pBundledContext->PcmOutPtr == NULL) {
-            LOGV("cannot open %s", fileName);
+            ALOGV("cannot open %s", fileName);
             fclose(pContext->pBundledContext->PcmInPtr);
            pContext->pBundledContext->PcmInPtr = NULL;
            ret = -EINVAL;
@@ -298,28 +299,28 @@
         pContext->pBundledContext->SamplesToExitCountBb     = 0;
         pContext->pBundledContext->SamplesToExitCountEq     = 0;
 
-        LOGV("\tEffectCreate - Calling LvmBundle_init");
+        ALOGV("\tEffectCreate - Calling LvmBundle_init");
         ret = LvmBundle_init(pContext);
 
         if (ret < 0){
-            LOGV("\tLVM_ERROR : EffectCreate() Bundle init failed");
+            ALOGV("\tLVM_ERROR : EffectCreate() Bundle init failed");
             goto exit;
         }
     }
     else{
-        LOGV("\tEffectCreate - Assigning memory for previously created effect on sessionNo %d",
+        ALOGV("\tEffectCreate - Assigning memory for previously created effect on sessionNo %d",
                 sessionNo);
         pContext->pBundledContext =
                 GlobalSessionMemory[sessionNo].pBundledContext;
     }
-    LOGV("\tEffectCreate - pBundledContext is %p", pContext->pBundledContext);
+    ALOGV("\tEffectCreate - pBundledContext is %p", pContext->pBundledContext);
 
     pSessionContext = &GlobalSessionMemory[pContext->pBundledContext->SessionNo];
 
     // Create each Effect
     if (memcmp(uuid, &gBassBoostDescriptor.uuid, sizeof(effect_uuid_t)) == 0){
         // Create Bass Boost
-        LOGV("\tEffectCreate - Effect to be created is LVM_BASS_BOOST");
+        ALOGV("\tEffectCreate - Effect to be created is LVM_BASS_BOOST");
         pSessionContext->bBassInstantiated = LVM_TRUE;
         pContext->pBundledContext->SamplesToExitCountBb = 0;
 
@@ -327,7 +328,7 @@
         pContext->EffectType = LVM_BASS_BOOST;
     } else if (memcmp(uuid, &gVirtualizerDescriptor.uuid, sizeof(effect_uuid_t)) == 0){
         // Create Virtualizer
-        LOGV("\tEffectCreate - Effect to be created is LVM_VIRTUALIZER");
+        ALOGV("\tEffectCreate - Effect to be created is LVM_VIRTUALIZER");
         pSessionContext->bVirtualizerInstantiated=LVM_TRUE;
         pContext->pBundledContext->SamplesToExitCountVirt = 0;
 
@@ -335,7 +336,7 @@
         pContext->EffectType = LVM_VIRTUALIZER;
     } else if (memcmp(uuid, &gEqualizerDescriptor.uuid, sizeof(effect_uuid_t)) == 0){
         // Create Equalizer
-        LOGV("\tEffectCreate - Effect to be created is LVM_EQUALIZER");
+        ALOGV("\tEffectCreate - Effect to be created is LVM_EQUALIZER");
         pSessionContext->bEqualizerInstantiated = LVM_TRUE;
         pContext->pBundledContext->SamplesToExitCountEq = 0;
 
@@ -343,14 +344,14 @@
         pContext->EffectType = LVM_EQUALIZER;
     } else if (memcmp(uuid, &gVolumeDescriptor.uuid, sizeof(effect_uuid_t)) == 0){
         // Create Volume
-        LOGV("\tEffectCreate - Effect to be created is LVM_VOLUME");
+        ALOGV("\tEffectCreate - Effect to be created is LVM_VOLUME");
         pSessionContext->bVolumeInstantiated = LVM_TRUE;
 
         pContext->itfe       = &gLvmEffectInterface;
         pContext->EffectType = LVM_VOLUME;
     }
     else{
-        LOGV("\tLVM_ERROR : EffectCreate() invalid UUID");
+        ALOGV("\tLVM_ERROR : EffectCreate() invalid UUID");
         ret = -EINVAL;
         goto exit;
     }
@@ -369,17 +370,17 @@
     } else {
         *pHandle = (effect_handle_t)pContext;
     }
-    LOGV("\tEffectCreate end..\n\n");
+    ALOGV("\tEffectCreate end..\n\n");
     return ret;
 } /* end EffectCreate */
 
 extern "C" int EffectRelease(effect_handle_t handle){
-    LOGV("\n\tEffectRelease start %p", handle);
+    ALOGV("\n\tEffectRelease start %p", handle);
     EffectContext * pContext = (EffectContext *)handle;
 
-    LOGV("\tEffectRelease start handle: %p, context %p", handle, pContext->pBundledContext);
+    ALOGV("\tEffectRelease start handle: %p, context %p", handle, pContext->pBundledContext);
     if (pContext == NULL){
-        LOGV("\tLVM_ERROR : EffectRelease called with NULL pointer");
+        ALOGV("\tLVM_ERROR : EffectRelease called with NULL pointer");
         return -EINVAL;
     }
 
@@ -388,34 +389,34 @@
     // Clear the instantiated flag for the effect
     // protect agains the case where an effect is un-instantiated without being disabled
     if(pContext->EffectType == LVM_BASS_BOOST) {
-        LOGV("\tEffectRelease LVM_BASS_BOOST Clearing global intstantiated flag");
+        ALOGV("\tEffectRelease LVM_BASS_BOOST Clearing global intstantiated flag");
         pSessionContext->bBassInstantiated = LVM_FALSE;
         if(pContext->pBundledContext->SamplesToExitCountBb > 0){
             pContext->pBundledContext->NumberEffectsEnabled--;
         }
         pContext->pBundledContext->SamplesToExitCountBb = 0;
     } else if(pContext->EffectType == LVM_VIRTUALIZER) {
-        LOGV("\tEffectRelease LVM_VIRTUALIZER Clearing global intstantiated flag");
+        ALOGV("\tEffectRelease LVM_VIRTUALIZER Clearing global intstantiated flag");
         pSessionContext->bVirtualizerInstantiated = LVM_FALSE;
         if(pContext->pBundledContext->SamplesToExitCountVirt > 0){
             pContext->pBundledContext->NumberEffectsEnabled--;
         }
         pContext->pBundledContext->SamplesToExitCountVirt = 0;
     } else if(pContext->EffectType == LVM_EQUALIZER) {
-        LOGV("\tEffectRelease LVM_EQUALIZER Clearing global intstantiated flag");
+        ALOGV("\tEffectRelease LVM_EQUALIZER Clearing global intstantiated flag");
         pSessionContext->bEqualizerInstantiated =LVM_FALSE;
         if(pContext->pBundledContext->SamplesToExitCountEq > 0){
             pContext->pBundledContext->NumberEffectsEnabled--;
         }
         pContext->pBundledContext->SamplesToExitCountEq = 0;
     } else if(pContext->EffectType == LVM_VOLUME) {
-        LOGV("\tEffectRelease LVM_VOLUME Clearing global intstantiated flag");
+        ALOGV("\tEffectRelease LVM_VOLUME Clearing global intstantiated flag");
         pSessionContext->bVolumeInstantiated = LVM_FALSE;
         if (pContext->pBundledContext->bVolumeEnabled == LVM_TRUE){
             pContext->pBundledContext->NumberEffectsEnabled--;
         }
     } else {
-        LOGV("\tLVM_ERROR : EffectRelease : Unsupported effect\n\n\n\n\n\n\n");
+        ALOGV("\tLVM_ERROR : EffectRelease : Unsupported effect\n\n\n\n\n\n\n");
     }
 
     // Disable effect, in this case ignore errors (return codes)
@@ -444,18 +445,18 @@
         for(int i=0; i<LVM_MAX_SESSIONS; i++){
             if(SessionIndex[i] == pContext->pBundledContext->SessionId){
                 SessionIndex[i] = LVM_UNUSED_SESSION;
-                LOGV("\tEffectRelease: Clearing SessionIndex SessionNo %d for SessionId %d\n",
+                ALOGV("\tEffectRelease: Clearing SessionIndex SessionNo %d for SessionId %d\n",
                         i, pContext->pBundledContext->SessionId);
                 break;
             }
         }
 
-        LOGV("\tEffectRelease: All effects are no longer instantiated\n");
+        ALOGV("\tEffectRelease: All effects are no longer instantiated\n");
         pSessionContext->bBundledEffectsEnabled = LVM_FALSE;
         pSessionContext->pBundledContext = LVM_NULL;
-        LOGV("\tEffectRelease: Freeing LVM Bundle memory\n");
+        ALOGV("\tEffectRelease: Freeing LVM Bundle memory\n");
         LvmEffect_free(pContext);
-        LOGV("\tEffectRelease: Deleting LVM Bundle context %p\n", pContext->pBundledContext);
+        ALOGV("\tEffectRelease: Deleting LVM Bundle context %p\n", pContext->pBundledContext);
         if (pContext->pBundledContext->workBuffer != NULL) {
             free(pContext->pBundledContext->workBuffer);
         }
@@ -465,7 +466,7 @@
     // free the effect context for current effect
     delete pContext;
 
-    LOGV("\tEffectRelease end\n");
+    ALOGV("\tEffectRelease end\n");
     return 0;
 
 } /* end EffectRelease */
@@ -475,7 +476,7 @@
     const effect_descriptor_t *desc = NULL;
 
     if (pDescriptor == NULL || uuid == NULL){
-        LOGV("EffectGetDescriptor() called with NULL pointer");
+        ALOGV("EffectGetDescriptor() called with NULL pointer");
         return -EINVAL;
     }
 
@@ -499,7 +500,7 @@
 } /* end EffectGetDescriptor */
 
 void LvmGlobalBundle_init(){
-    LOGV("\tLvmGlobalBundle_init start");
+    ALOGV("\tLvmGlobalBundle_init start");
     for(int i=0; i<LVM_MAX_SESSIONS; i++){
         GlobalSessionMemory[i].bBundledEffectsEnabled   = LVM_FALSE;
         GlobalSessionMemory[i].bVolumeInstantiated      = LVM_FALSE;
@@ -528,7 +529,7 @@
 int LvmBundle_init(EffectContext *pContext){
     int status;
 
-    LOGV("\tLvmBundle_init start");
+    ALOGV("\tLvmBundle_init start");
 
     pContext->config.inputCfg.accessMode                    = EFFECT_BUFFER_ACCESS_READ;
     pContext->config.inputCfg.channels                      = AUDIO_CHANNEL_OUT_STEREO;
@@ -550,12 +551,12 @@
     CHECK_ARG(pContext != NULL);
 
     if (pContext->pBundledContext->hInstance != NULL){
-        LOGV("\tLvmBundle_init pContext->pBassBoost != NULL "
+        ALOGV("\tLvmBundle_init pContext->pBassBoost != NULL "
                 "-> Calling pContext->pBassBoost->free()");
 
         LvmEffect_free(pContext);
 
-        LOGV("\tLvmBundle_init pContext->pBassBoost != NULL "
+        ALOGV("\tLvmBundle_init pContext->pBassBoost != NULL "
                 "-> Called pContext->pBassBoost->free()");
     }
 
@@ -582,7 +583,7 @@
     LVM_ERROR_CHECK(LvmStatus, "LVM_GetMemoryTable", "LvmBundle_init")
     if(LvmStatus != LVM_SUCCESS) return -EINVAL;
 
-    LOGV("\tCreateInstance Succesfully called LVM_GetMemoryTable\n");
+    ALOGV("\tCreateInstance Succesfully called LVM_GetMemoryTable\n");
 
     /* Allocate memory */
     for (int i=0; i<LVM_NR_MEMORY_REGIONS; i++){
@@ -590,11 +591,11 @@
             MemTab.Region[i].pBaseAddress = malloc(MemTab.Region[i].Size);
 
             if (MemTab.Region[i].pBaseAddress == LVM_NULL){
-                LOGV("\tLVM_ERROR :LvmBundle_init CreateInstance Failed to allocate %ld bytes "
+                ALOGV("\tLVM_ERROR :LvmBundle_init CreateInstance Failed to allocate %ld bytes "
                         "for region %u\n", MemTab.Region[i].Size, i );
                 bMallocFailure = LVM_TRUE;
             }else{
-                LOGV("\tLvmBundle_init CreateInstance allocated %ld bytes for region %u at %p\n",
+                ALOGV("\tLvmBundle_init CreateInstance allocated %ld bytes for region %u at %p\n",
                         MemTab.Region[i].Size, i, MemTab.Region[i].pBaseAddress);
             }
         }
@@ -606,10 +607,10 @@
     if(bMallocFailure == LVM_TRUE){
         for (int i=0; i<LVM_NR_MEMORY_REGIONS; i++){
             if (MemTab.Region[i].pBaseAddress == LVM_NULL){
-                LOGV("\tLVM_ERROR :LvmBundle_init CreateInstance Failed to allocate %ld bytes "
+                ALOGV("\tLVM_ERROR :LvmBundle_init CreateInstance Failed to allocate %ld bytes "
                         "for region %u Not freeing\n", MemTab.Region[i].Size, i );
             }else{
-                LOGV("\tLVM_ERROR :LvmBundle_init CreateInstance Failed: but allocated %ld bytes "
+                ALOGV("\tLVM_ERROR :LvmBundle_init CreateInstance Failed: but allocated %ld bytes "
                      "for region %u at %p- free\n",
                      MemTab.Region[i].Size, i, MemTab.Region[i].pBaseAddress);
                 free(MemTab.Region[i].pBaseAddress);
@@ -617,7 +618,7 @@
         }
         return -EINVAL;
     }
-    LOGV("\tLvmBundle_init CreateInstance Succesfully malloc'd memory\n");
+    ALOGV("\tLvmBundle_init CreateInstance Succesfully malloc'd memory\n");
 
     /* Initialise */
     pContext->pBundledContext->hInstance = LVM_NULL;
@@ -630,7 +631,7 @@
     LVM_ERROR_CHECK(LvmStatus, "LVM_GetInstanceHandle", "LvmBundle_init")
     if(LvmStatus != LVM_SUCCESS) return -EINVAL;
 
-    LOGV("\tLvmBundle_init CreateInstance Succesfully called LVM_GetInstanceHandle\n");
+    ALOGV("\tLvmBundle_init CreateInstance Succesfully called LVM_GetInstanceHandle\n");
 
     /* Set the initial process parameters */
     /* General parameters */
@@ -692,7 +693,7 @@
     LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "LvmBundle_init")
     if(LvmStatus != LVM_SUCCESS) return -EINVAL;
 
-    LOGV("\tLvmBundle_init CreateInstance Succesfully called LVM_SetControlParameters\n");
+    ALOGV("\tLvmBundle_init CreateInstance Succesfully called LVM_SetControlParameters\n");
 
     /* Set the headroom parameters */
     HeadroomBandDef[0].Limit_Low          = 20;
@@ -711,8 +712,8 @@
     LVM_ERROR_CHECK(LvmStatus, "LVM_SetHeadroomParams", "LvmBundle_init")
     if(LvmStatus != LVM_SUCCESS) return -EINVAL;
 
-    LOGV("\tLvmBundle_init CreateInstance Succesfully called LVM_SetHeadroomParams\n");
-    LOGV("\tLvmBundle_init End");
+    ALOGV("\tLvmBundle_init CreateInstance Succesfully called LVM_SetHeadroomParams\n");
+    ALOGV("\tLvmBundle_init End");
     return 0;
 }   /* end LvmBundle_init */
 
@@ -757,7 +758,7 @@
         }
         pOutTmp = pContext->pBundledContext->workBuffer;
     }else{
-        LOGV("LVM_ERROR : LvmBundle_process invalid access mode");
+        ALOGV("LVM_ERROR : LvmBundle_process invalid access mode");
         return -EINVAL;
     }
 
@@ -766,7 +767,7 @@
     fflush(pContext->pBundledContext->PcmInPtr);
     #endif
 
-    //LOGV("Calling LVM_Process");
+    //ALOGV("Calling LVM_Process");
 
     /* Process the samples */
     LvmStatus = LVM_Process(pContext->pBundledContext->hInstance, /* Instance handle */
@@ -804,7 +805,7 @@
 //----------------------------------------------------------------------------
 
 int LvmEffect_enable(EffectContext *pContext){
-    //LOGV("\tLvmEffect_enable start");
+    //ALOGV("\tLvmEffect_enable start");
 
     LVM_ControlParams_t     ActiveParams;                           /* Current control Parameters */
     LVM_ReturnStatus_en     LvmStatus = LVM_SUCCESS;                /* Function call status */
@@ -815,30 +816,30 @@
 
     LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "LvmEffect_enable")
     if(LvmStatus != LVM_SUCCESS) return -EINVAL;
-    //LOGV("\tLvmEffect_enable Succesfully called LVM_GetControlParameters\n");
+    //ALOGV("\tLvmEffect_enable Succesfully called LVM_GetControlParameters\n");
 
     if(pContext->EffectType == LVM_BASS_BOOST) {
-        LOGV("\tLvmEffect_enable : Enabling LVM_BASS_BOOST");
+        ALOGV("\tLvmEffect_enable : Enabling LVM_BASS_BOOST");
         ActiveParams.BE_OperatingMode       = LVM_BE_ON;
     }
     if(pContext->EffectType == LVM_VIRTUALIZER) {
-        LOGV("\tLvmEffect_enable : Enabling LVM_VIRTUALIZER");
+        ALOGV("\tLvmEffect_enable : Enabling LVM_VIRTUALIZER");
         ActiveParams.VirtualizerOperatingMode   = LVM_MODE_ON;
     }
     if(pContext->EffectType == LVM_EQUALIZER) {
-        LOGV("\tLvmEffect_enable : Enabling LVM_EQUALIZER");
+        ALOGV("\tLvmEffect_enable : Enabling LVM_EQUALIZER");
         ActiveParams.EQNB_OperatingMode     = LVM_EQNB_ON;
     }
     if(pContext->EffectType == LVM_VOLUME) {
-        LOGV("\tLvmEffect_enable : Enabling LVM_VOLUME");
+        ALOGV("\tLvmEffect_enable : Enabling LVM_VOLUME");
     }
 
     LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
     LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "LvmEffect_enable")
     if(LvmStatus != LVM_SUCCESS) return -EINVAL;
 
-    //LOGV("\tLvmEffect_enable Succesfully called LVM_SetControlParameters\n");
-    //LOGV("\tLvmEffect_enable end");
+    //ALOGV("\tLvmEffect_enable Succesfully called LVM_SetControlParameters\n");
+    //ALOGV("\tLvmEffect_enable end");
     return 0;
 }
 
@@ -855,7 +856,7 @@
 //----------------------------------------------------------------------------
 
 int LvmEffect_disable(EffectContext *pContext){
-    //LOGV("\tLvmEffect_disable start");
+    //ALOGV("\tLvmEffect_disable start");
 
     LVM_ControlParams_t     ActiveParams;                           /* Current control Parameters */
     LVM_ReturnStatus_en     LvmStatus = LVM_SUCCESS;                /* Function call status */
@@ -865,30 +866,30 @@
 
     LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "LvmEffect_disable")
     if(LvmStatus != LVM_SUCCESS) return -EINVAL;
-    //LOGV("\tLvmEffect_disable Succesfully called LVM_GetControlParameters\n");
+    //ALOGV("\tLvmEffect_disable Succesfully called LVM_GetControlParameters\n");
 
     if(pContext->EffectType == LVM_BASS_BOOST) {
-        LOGV("\tLvmEffect_disable : Disabling LVM_BASS_BOOST");
+        ALOGV("\tLvmEffect_disable : Disabling LVM_BASS_BOOST");
         ActiveParams.BE_OperatingMode       = LVM_BE_OFF;
     }
     if(pContext->EffectType == LVM_VIRTUALIZER) {
-        LOGV("\tLvmEffect_disable : Disabling LVM_VIRTUALIZER");
+        ALOGV("\tLvmEffect_disable : Disabling LVM_VIRTUALIZER");
         ActiveParams.VirtualizerOperatingMode   = LVM_MODE_OFF;
     }
     if(pContext->EffectType == LVM_EQUALIZER) {
-        LOGV("\tLvmEffect_disable : Disabling LVM_EQUALIZER");
+        ALOGV("\tLvmEffect_disable : Disabling LVM_EQUALIZER");
         ActiveParams.EQNB_OperatingMode     = LVM_EQNB_OFF;
     }
     if(pContext->EffectType == LVM_VOLUME) {
-        LOGV("\tLvmEffect_disable : Disabling LVM_VOLUME");
+        ALOGV("\tLvmEffect_disable : Disabling LVM_VOLUME");
     }
 
     LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
     LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "LvmEffect_disable")
     if(LvmStatus != LVM_SUCCESS) return -EINVAL;
 
-    //LOGV("\tLvmEffect_disable Succesfully called LVM_SetControlParameters\n");
-    //LOGV("\tLvmEffect_disable end");
+    //ALOGV("\tLvmEffect_disable Succesfully called LVM_SetControlParameters\n");
+    //ALOGV("\tLvmEffect_disable end");
     return 0;
 }
 
@@ -919,15 +920,15 @@
     for (int i=0; i<LVM_NR_MEMORY_REGIONS; i++){
         if (MemTab.Region[i].Size != 0){
             if (MemTab.Region[i].pBaseAddress != NULL){
-                LOGV("\tLvmEffect_free - START freeing %ld bytes for region %u at %p\n",
+                ALOGV("\tLvmEffect_free - START freeing %ld bytes for region %u at %p\n",
                         MemTab.Region[i].Size, i, MemTab.Region[i].pBaseAddress);
 
                 free(MemTab.Region[i].pBaseAddress);
 
-                LOGV("\tLvmEffect_free - END   freeing %ld bytes for region %u at %p\n",
+                ALOGV("\tLvmEffect_free - END   freeing %ld bytes for region %u at %p\n",
                         MemTab.Region[i].Size, i, MemTab.Region[i].pBaseAddress);
             }else{
-                LOGV("\tLVM_ERROR : LvmEffect_free - trying to free with NULL pointer %ld bytes "
+                ALOGV("\tLVM_ERROR : LvmEffect_free - trying to free with NULL pointer %ld bytes "
                         "for region %u at %p ERROR\n",
                         MemTab.Region[i].Size, i, MemTab.Region[i].pBaseAddress);
             }
@@ -936,7 +937,7 @@
 }    /* end LvmEffect_free */
 
 //----------------------------------------------------------------------------
-// Effect_configure()
+// Effect_setConfig()
 //----------------------------------------------------------------------------
 // Purpose: Set input and output audio configuration.
 //
@@ -949,9 +950,9 @@
 //
 //----------------------------------------------------------------------------
 
-int Effect_configure(EffectContext *pContext, effect_config_t *pConfig){
+int Effect_setConfig(EffectContext *pContext, effect_config_t *pConfig){
     LVM_Fs_en   SampleRate;
-    //LOGV("\tEffect_configure start");
+    //ALOGV("\tEffect_setConfig start");
 
     CHECK_ARG(pContext != NULL);
     CHECK_ARG(pConfig != NULL);
@@ -992,7 +993,7 @@
         pContext->pBundledContext->SamplesPerSecond = 48000*2; // 2 secs Stereo
         break;
     default:
-        LOGV("\tEffect_Configure invalid sampling rate %d", pConfig->inputCfg.samplingRate);
+        ALOGV("\tEffect_setConfig invalid sampling rate %d", pConfig->inputCfg.samplingRate);
         return -EINVAL;
     }
 
@@ -1001,28 +1002,47 @@
         LVM_ControlParams_t     ActiveParams;
         LVM_ReturnStatus_en     LvmStatus = LVM_SUCCESS;
 
-        LOGV("\tEffect_configure change sampling rate to %d", SampleRate);
+        ALOGV("\tEffect_setConfig change sampling rate to %d", SampleRate);
 
         /* Get the current settings */
         LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance,
                                          &ActiveParams);
 
-        LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "Effect_configure")
+        LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "Effect_setConfig")
         if(LvmStatus != LVM_SUCCESS) return -EINVAL;
 
         LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
 
-        LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "Effect_configure")
-        LOGV("\tEffect_configure Succesfully called LVM_SetControlParameters\n");
+        LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "Effect_setConfig")
+        ALOGV("\tEffect_setConfig Succesfully called LVM_SetControlParameters\n");
         pContext->pBundledContext->SampleRate = SampleRate;
 
     }else{
-        //LOGV("\tEffect_configure keep sampling rate at %d", SampleRate);
+        //ALOGV("\tEffect_setConfig keep sampling rate at %d", SampleRate);
     }
 
-    //LOGV("\tEffect_configure End....");
+    //ALOGV("\tEffect_setConfig End....");
     return 0;
-}   /* end Effect_configure */
+}   /* end Effect_setConfig */
+
+//----------------------------------------------------------------------------
+// Effect_getConfig()
+//----------------------------------------------------------------------------
+// Purpose: Get input and output audio configuration.
+//
+// Inputs:
+//  pContext:   effect engine context
+//  pConfig:    pointer to effect_config_t structure holding input and output
+//      configuration parameters
+//
+// Outputs:
+//
+//----------------------------------------------------------------------------
+
+void Effect_getConfig(EffectContext *pContext, effect_config_t *pConfig)
+{
+    memcpy(pConfig, &pContext->config, sizeof(effect_config_t));
+}   /* end Effect_getConfig */
 
 //----------------------------------------------------------------------------
 // BassGetStrength()
@@ -1039,7 +1059,7 @@
 //----------------------------------------------------------------------------
 
 uint32_t BassGetStrength(EffectContext *pContext){
-    //LOGV("\tBassGetStrength() (0-1000) -> %d\n", pContext->pBundledContext->BassStrengthSaved);
+    //ALOGV("\tBassGetStrength() (0-1000) -> %d\n", pContext->pBundledContext->BassStrengthSaved);
 
     LVM_ControlParams_t     ActiveParams;                           /* Current control Parameters */
     LVM_ReturnStatus_en     LvmStatus = LVM_SUCCESS;                /* Function call status */
@@ -1050,18 +1070,18 @@
     LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "BassGetStrength")
     if(LvmStatus != LVM_SUCCESS) return -EINVAL;
 
-    //LOGV("\tBassGetStrength Succesfully returned from LVM_GetControlParameters\n");
+    //ALOGV("\tBassGetStrength Succesfully returned from LVM_GetControlParameters\n");
 
     /* Check that the strength returned matches the strength that was set earlier */
     if(ActiveParams.BE_EffectLevel !=
        (LVM_INT16)((15*pContext->pBundledContext->BassStrengthSaved)/1000)){
-        LOGV("\tLVM_ERROR : BassGetStrength module strength does not match savedStrength %d %d\n",
+        ALOGV("\tLVM_ERROR : BassGetStrength module strength does not match savedStrength %d %d\n",
                 ActiveParams.BE_EffectLevel, pContext->pBundledContext->BassStrengthSaved);
         return -EINVAL;
     }
 
-    //LOGV("\tBassGetStrength() (0-15)   -> %d\n", ActiveParams.BE_EffectLevel );
-    //LOGV("\tBassGetStrength() (saved)  -> %d\n", pContext->pBundledContext->BassStrengthSaved );
+    //ALOGV("\tBassGetStrength() (0-15)   -> %d\n", ActiveParams.BE_EffectLevel );
+    //ALOGV("\tBassGetStrength() (saved)  -> %d\n", pContext->pBundledContext->BassStrengthSaved );
     return pContext->pBundledContext->BassStrengthSaved;
 }    /* end BassGetStrength */
 
@@ -1078,7 +1098,7 @@
 //----------------------------------------------------------------------------
 
 void BassSetStrength(EffectContext *pContext, uint32_t strength){
-    //LOGV("\tBassSetStrength(%d)", strength);
+    //ALOGV("\tBassSetStrength(%d)", strength);
 
     pContext->pBundledContext->BassStrengthSaved = (int)strength;
 
@@ -1090,19 +1110,19 @@
                                          &ActiveParams);
 
     LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "BassSetStrength")
-    //LOGV("\tBassSetStrength Succesfully returned from LVM_GetControlParameters\n");
+    //ALOGV("\tBassSetStrength Succesfully returned from LVM_GetControlParameters\n");
 
     /* Bass Enhancement parameters */
     ActiveParams.BE_EffectLevel    = (LVM_INT16)((15*strength)/1000);
     ActiveParams.BE_CentreFreq     = LVM_BE_CENTRE_90Hz;
 
-    //LOGV("\tBassSetStrength() (0-15)   -> %d\n", ActiveParams.BE_EffectLevel );
+    //ALOGV("\tBassSetStrength() (0-15)   -> %d\n", ActiveParams.BE_EffectLevel );
 
     /* Activate the initial settings */
     LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
 
     LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "BassSetStrength")
-    //LOGV("\tBassSetStrength Succesfully called LVM_SetControlParameters\n");
+    //ALOGV("\tBassSetStrength Succesfully called LVM_SetControlParameters\n");
 }    /* end BassSetStrength */
 
 //----------------------------------------------------------------------------
@@ -1120,7 +1140,7 @@
 //----------------------------------------------------------------------------
 
 uint32_t VirtualizerGetStrength(EffectContext *pContext){
-    //LOGV("\tVirtualizerGetStrength (0-1000) -> %d\n",pContext->pBundledContext->VirtStrengthSaved);
+    //ALOGV("\tVirtualizerGetStrength (0-1000) -> %d\n",pContext->pBundledContext->VirtStrengthSaved);
 
     LVM_ControlParams_t     ActiveParams;                           /* Current control Parameters */
     LVM_ReturnStatus_en     LvmStatus = LVM_SUCCESS;                /* Function call status */
@@ -1130,8 +1150,8 @@
     LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VirtualizerGetStrength")
     if(LvmStatus != LVM_SUCCESS) return -EINVAL;
 
-    //LOGV("\tVirtualizerGetStrength Succesfully returned from LVM_GetControlParameters\n");
-    //LOGV("\tVirtualizerGetStrength() (0-100)   -> %d\n", ActiveParams.VirtualizerReverbLevel*10);
+    //ALOGV("\tVirtualizerGetStrength Succesfully returned from LVM_GetControlParameters\n");
+    //ALOGV("\tVirtualizerGetStrength() (0-100)   -> %d\n", ActiveParams.VirtualizerReverbLevel*10);
     return pContext->pBundledContext->VirtStrengthSaved;
 }    /* end getStrength */
 
@@ -1148,7 +1168,7 @@
 //----------------------------------------------------------------------------
 
 void VirtualizerSetStrength(EffectContext *pContext, uint32_t strength){
-    //LOGV("\tVirtualizerSetStrength(%d)", strength);
+    //ALOGV("\tVirtualizerSetStrength(%d)", strength);
     LVM_ControlParams_t     ActiveParams;              /* Current control Parameters */
     LVM_ReturnStatus_en     LvmStatus=LVM_SUCCESS;     /* Function call status */
 
@@ -1158,18 +1178,18 @@
     LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance,&ActiveParams);
 
     LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VirtualizerSetStrength")
-    //LOGV("\tVirtualizerSetStrength Succesfully returned from LVM_GetControlParameters\n");
+    //ALOGV("\tVirtualizerSetStrength Succesfully returned from LVM_GetControlParameters\n");
 
     /* Virtualizer parameters */
     ActiveParams.CS_EffectLevel             = (int)((strength*32767)/1000);
 
-    //LOGV("\tVirtualizerSetStrength() (0-1000)   -> %d\n", strength );
-    //LOGV("\tVirtualizerSetStrength() (0- 100)   -> %d\n", ActiveParams.CS_EffectLevel );
+    //ALOGV("\tVirtualizerSetStrength() (0-1000)   -> %d\n", strength );
+    //ALOGV("\tVirtualizerSetStrength() (0- 100)   -> %d\n", ActiveParams.CS_EffectLevel );
 
     /* Activate the initial settings */
     LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
     LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "VirtualizerSetStrength")
-    //LOGV("\tVirtualizerSetStrength Succesfully called LVM_SetControlParameters\n\n");
+    //ALOGV("\tVirtualizerSetStrength Succesfully called LVM_SetControlParameters\n\n");
 }    /* end setStrength */
 
 //----------------------------------------------------------------------------
@@ -1199,8 +1219,8 @@
     BandDef = ActiveParams.pEQNB_BandDefinition;
     Gain    = (int32_t)BandDef[band].Gain*100;    // Convert to millibels
 
-    //LOGV("\tEqualizerGetBandLevel -> %d\n", Gain );
-    //LOGV("\tEqualizerGetBandLevel Succesfully returned from LVM_GetControlParameters\n");
+    //ALOGV("\tEqualizerGetBandLevel -> %d\n", Gain );
+    //ALOGV("\tEqualizerGetBandLevel Succesfully returned from LVM_GetControlParameters\n");
     return Gain;
 }
 
@@ -1225,7 +1245,7 @@
     }else{
         gainRounded = (int)((Gain-50)/100);
     }
-    //LOGV("\tEqualizerSetBandLevel(%d)->(%d)", Gain, gainRounded);
+    //ALOGV("\tEqualizerSetBandLevel(%d)->(%d)", Gain, gainRounded);
 
 
     LVM_ControlParams_t     ActiveParams;              /* Current control Parameters */
@@ -1235,8 +1255,8 @@
     /* Get the current settings */
     LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
     LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "EqualizerSetBandLevel")
-    //LOGV("\tEqualizerSetBandLevel Succesfully returned from LVM_GetControlParameters\n");
-    //LOGV("\tEqualizerSetBandLevel just Got -> %d\n",ActiveParams.pEQNB_BandDefinition[band].Gain);
+    //ALOGV("\tEqualizerSetBandLevel Succesfully returned from LVM_GetControlParameters\n");
+    //ALOGV("\tEqualizerSetBandLevel just Got -> %d\n",ActiveParams.pEQNB_BandDefinition[band].Gain);
 
     /* Set local EQ parameters */
     BandDef = ActiveParams.pEQNB_BandDefinition;
@@ -1245,7 +1265,7 @@
     /* Activate the initial settings */
     LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
     LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "EqualizerSetBandLevel")
-    //LOGV("\tEqualizerSetBandLevel just Set -> %d\n",ActiveParams.pEQNB_BandDefinition[band].Gain);
+    //ALOGV("\tEqualizerSetBandLevel just Set -> %d\n",ActiveParams.pEQNB_BandDefinition[band].Gain);
 
     pContext->pBundledContext->CurPreset = PRESET_CUSTOM;
     return;
@@ -1277,8 +1297,8 @@
     BandDef   = ActiveParams.pEQNB_BandDefinition;
     Frequency = (int32_t)BandDef[band].Frequency*1000;     // Convert to millibels
 
-    //LOGV("\tEqualizerGetCentreFrequency -> %d\n", Frequency );
-    //LOGV("\tEqualizerGetCentreFrequency Succesfully returned from LVM_GetControlParameters\n");
+    //ALOGV("\tEqualizerGetCentreFrequency -> %d\n", Frequency );
+    //ALOGV("\tEqualizerGetCentreFrequency Succesfully returned from LVM_GetControlParameters\n");
     return Frequency;
 }
 
@@ -1372,7 +1392,7 @@
 //----------------------------------------------------------------------------
 void EqualizerSetPreset(EffectContext *pContext, int preset){
 
-    //LOGV("\tEqualizerSetPreset(%d)", preset);
+    //ALOGV("\tEqualizerSetPreset(%d)", preset);
     pContext->pBundledContext->CurPreset = preset;
 
     LVM_ControlParams_t     ActiveParams;              /* Current control Parameters */
@@ -1381,7 +1401,7 @@
     /* Get the current settings */
     LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
     LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "EqualizerSetPreset")
-    //LOGV("\tEqualizerSetPreset Succesfully returned from LVM_GetControlParameters\n");
+    //ALOGV("\tEqualizerSetPreset Succesfully returned from LVM_GetControlParameters\n");
 
     //ActiveParams.pEQNB_BandDefinition = &BandDefs[0];
     for (int i=0; i<FIVEBAND_NUMBANDS; i++)
@@ -1395,7 +1415,7 @@
     LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
     LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "EqualizerSetPreset")
 
-    //LOGV("\tEqualizerSetPreset Succesfully called LVM_SetControlParameters\n");
+    //ALOGV("\tEqualizerSetPreset Succesfully called LVM_SetControlParameters\n");
     return;
 }
 
@@ -1415,13 +1435,13 @@
 //
 //-------------------------------------------------------------------------
 const char * EqualizerGetPresetName(int32_t preset){
-    //LOGV("\tEqualizerGetPresetName start(%d)", preset);
+    //ALOGV("\tEqualizerGetPresetName start(%d)", preset);
     if (preset == PRESET_CUSTOM) {
         return "Custom";
     } else {
         return gEqualizerPresets[preset].name;
     }
-    //LOGV("\tEqualizerGetPresetName end(%d)", preset);
+    //ALOGV("\tEqualizerGetPresetName end(%d)", preset);
     return 0;
 }
 
@@ -1441,35 +1461,35 @@
     LVM_ControlParams_t     ActiveParams;              /* Current control Parameters */
     LVM_ReturnStatus_en     LvmStatus=LVM_SUCCESS;     /* Function call status */
 
-    //LOGV("\tVolumeSetVolumeLevel Level to be set is %d %d\n", level, (LVM_INT16)(level/100));
+    //ALOGV("\tVolumeSetVolumeLevel Level to be set is %d %d\n", level, (LVM_INT16)(level/100));
     /* Get the current settings */
     LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
     LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeSetVolumeLevel")
     if(LvmStatus != LVM_SUCCESS) return -EINVAL;
-    //LOGV("\tVolumeSetVolumeLevel Succesfully returned from LVM_GetControlParameters got: %d\n",
+    //ALOGV("\tVolumeSetVolumeLevel Succesfully returned from LVM_GetControlParameters got: %d\n",
     //ActiveParams.VC_EffectLevel);
 
     /* Volume parameters */
     ActiveParams.VC_EffectLevel  = (LVM_INT16)(level/100);
-    //LOGV("\tVolumeSetVolumeLevel() (-96dB -> 0dB)   -> %d\n", ActiveParams.VC_EffectLevel );
+    //ALOGV("\tVolumeSetVolumeLevel() (-96dB -> 0dB)   -> %d\n", ActiveParams.VC_EffectLevel );
 
     /* Activate the initial settings */
     LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
     LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "VolumeSetVolumeLevel")
     if(LvmStatus != LVM_SUCCESS) return -EINVAL;
 
-    //LOGV("\tVolumeSetVolumeLevel Succesfully called LVM_SetControlParameters\n");
+    //ALOGV("\tVolumeSetVolumeLevel Succesfully called LVM_SetControlParameters\n");
 
     /* Get the current settings */
     LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
     LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeSetVolumeLevel")
     if(LvmStatus != LVM_SUCCESS) return -EINVAL;
 
-    //LOGV("\tVolumeSetVolumeLevel just set (-96dB -> 0dB)   -> %d\n",ActiveParams.VC_EffectLevel );
+    //ALOGV("\tVolumeSetVolumeLevel just set (-96dB -> 0dB)   -> %d\n",ActiveParams.VC_EffectLevel );
     if(pContext->pBundledContext->firstVolume == LVM_TRUE){
         LvmStatus = LVM_SetVolumeNoSmoothing(pContext->pBundledContext->hInstance, &ActiveParams);
         LVM_ERROR_CHECK(LvmStatus, "LVM_SetVolumeNoSmoothing", "LvmBundle_process")
-        LOGV("\tLVM_VOLUME: Disabling Smoothing for first volume change to remove spikes/clicks");
+        ALOGV("\tLVM_VOLUME: Disabling Smoothing for first volume change to remove spikes/clicks");
         pContext->pBundledContext->firstVolume = LVM_FALSE;
     }
     return 0;
@@ -1487,7 +1507,7 @@
 
 int VolumeGetVolumeLevel(EffectContext *pContext, int16_t *level){
 
-    //LOGV("\tVolumeGetVolumeLevel start");
+    //ALOGV("\tVolumeGetVolumeLevel start");
 
     LVM_ControlParams_t     ActiveParams;                           /* Current control Parameters */
     LVM_ReturnStatus_en     LvmStatus = LVM_SUCCESS;                /* Function call status */
@@ -1496,11 +1516,11 @@
     LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeGetVolumeLevel")
     if(LvmStatus != LVM_SUCCESS) return -EINVAL;
 
-    //LOGV("\tVolumeGetVolumeLevel() (-96dB -> 0dB) -> %d\n", ActiveParams.VC_EffectLevel );
-    //LOGV("\tVolumeGetVolumeLevel Succesfully returned from LVM_GetControlParameters\n");
+    //ALOGV("\tVolumeGetVolumeLevel() (-96dB -> 0dB) -> %d\n", ActiveParams.VC_EffectLevel );
+    //ALOGV("\tVolumeGetVolumeLevel Succesfully returned from LVM_GetControlParameters\n");
 
     *level = ActiveParams.VC_EffectLevel*100;     // Convert dB to millibels
-    //LOGV("\tVolumeGetVolumeLevel end");
+    //ALOGV("\tVolumeGetVolumeLevel end");
     return 0;
 }    /* end VolumeGetVolumeLevel */
 
@@ -1516,7 +1536,7 @@
 //----------------------------------------------------------------------------
 
 int32_t VolumeSetMute(EffectContext *pContext, uint32_t mute){
-    //LOGV("\tVolumeSetMute start(%d)", mute);
+    //ALOGV("\tVolumeSetMute start(%d)", mute);
 
     pContext->pBundledContext->bMuteEnabled = mute;
 
@@ -1528,8 +1548,8 @@
     LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeSetMute")
     if(LvmStatus != LVM_SUCCESS) return -EINVAL;
 
-    //LOGV("\tVolumeSetMute Succesfully returned from LVM_GetControlParameters\n");
-    //LOGV("\tVolumeSetMute to %d, level was %d\n", mute, ActiveParams.VC_EffectLevel );
+    //ALOGV("\tVolumeSetMute Succesfully returned from LVM_GetControlParameters\n");
+    //ALOGV("\tVolumeSetMute to %d, level was %d\n", mute, ActiveParams.VC_EffectLevel );
 
     /* Set appropriate volume level */
     if(pContext->pBundledContext->bMuteEnabled == LVM_TRUE){
@@ -1544,8 +1564,8 @@
     LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "VolumeSetMute")
     if(LvmStatus != LVM_SUCCESS) return -EINVAL;
 
-    //LOGV("\tVolumeSetMute Succesfully called LVM_SetControlParameters\n");
-    //LOGV("\tVolumeSetMute end");
+    //ALOGV("\tVolumeSetMute Succesfully called LVM_SetControlParameters\n");
+    //ALOGV("\tVolumeSetMute end");
     return 0;
 }    /* end setMute */
 
@@ -1562,17 +1582,17 @@
 //----------------------------------------------------------------------------
 
 int32_t VolumeGetMute(EffectContext *pContext, uint32_t *mute){
-    //LOGV("\tVolumeGetMute start");
+    //ALOGV("\tVolumeGetMute start");
     if((pContext->pBundledContext->bMuteEnabled == LVM_FALSE)||
        (pContext->pBundledContext->bMuteEnabled == LVM_TRUE)){
         *mute = pContext->pBundledContext->bMuteEnabled;
         return 0;
     }else{
-        LOGV("\tLVM_ERROR : VolumeGetMute read an invalid value from context %d",
+        ALOGV("\tLVM_ERROR : VolumeGetMute read an invalid value from context %d",
               pContext->pBundledContext->bMuteEnabled);
         return -EINVAL;
     }
-    //LOGV("\tVolumeGetMute end");
+    //ALOGV("\tVolumeGetMute end");
 }    /* end getMute */
 
 int16_t VolumeConvertStereoPosition(int16_t position){
@@ -1606,43 +1626,43 @@
     pContext->pBundledContext->positionSaved = position;
     Balance = VolumeConvertStereoPosition(pContext->pBundledContext->positionSaved);
 
-    //LOGV("\tVolumeSetStereoPosition start pContext->pBundledContext->positionSaved = %d",
+    //ALOGV("\tVolumeSetStereoPosition start pContext->pBundledContext->positionSaved = %d",
     //pContext->pBundledContext->positionSaved);
 
     if(pContext->pBundledContext->bStereoPositionEnabled == LVM_TRUE){
 
-        //LOGV("\tVolumeSetStereoPosition Position to be set is %d %d\n", position, Balance);
+        //ALOGV("\tVolumeSetStereoPosition Position to be set is %d %d\n", position, Balance);
         pContext->pBundledContext->positionSaved = position;
         /* Get the current settings */
         LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
         LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeSetStereoPosition")
         if(LvmStatus != LVM_SUCCESS) return -EINVAL;
-        //LOGV("\tVolumeSetStereoPosition Succesfully returned from LVM_GetControlParameters got:"
+        //ALOGV("\tVolumeSetStereoPosition Succesfully returned from LVM_GetControlParameters got:"
         //     " %d\n", ActiveParams.VC_Balance);
 
         /* Volume parameters */
         ActiveParams.VC_Balance  = Balance;
-        //LOGV("\tVolumeSetStereoPosition() (-96dB -> +96dB)   -> %d\n", ActiveParams.VC_Balance );
+        //ALOGV("\tVolumeSetStereoPosition() (-96dB -> +96dB)   -> %d\n", ActiveParams.VC_Balance );
 
         /* Activate the initial settings */
         LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
         LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "VolumeSetStereoPosition")
         if(LvmStatus != LVM_SUCCESS) return -EINVAL;
 
-        //LOGV("\tVolumeSetStereoPosition Succesfully called LVM_SetControlParameters\n");
+        //ALOGV("\tVolumeSetStereoPosition Succesfully called LVM_SetControlParameters\n");
 
         /* Get the current settings */
         LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
         LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeSetStereoPosition")
         if(LvmStatus != LVM_SUCCESS) return -EINVAL;
-        //LOGV("\tVolumeSetStereoPosition Succesfully returned from LVM_GetControlParameters got: "
+        //ALOGV("\tVolumeSetStereoPosition Succesfully returned from LVM_GetControlParameters got: "
         //     "%d\n", ActiveParams.VC_Balance);
     }
     else{
-        //LOGV("\tVolumeSetStereoPosition Position attempting to set, but not enabled %d %d\n",
+        //ALOGV("\tVolumeSetStereoPosition Position attempting to set, but not enabled %d %d\n",
         //position, Balance);
     }
-    //LOGV("\tVolumeSetStereoPosition end pContext->pBundledContext->positionSaved = %d\n",
+    //ALOGV("\tVolumeSetStereoPosition end pContext->pBundledContext->positionSaved = %d\n",
     //pContext->pBundledContext->positionSaved);
     return 0;
 }    /* end VolumeSetStereoPosition */
@@ -1661,21 +1681,21 @@
 //----------------------------------------------------------------------------
 
 int32_t VolumeGetStereoPosition(EffectContext *pContext, int16_t *position){
-    //LOGV("\tVolumeGetStereoPosition start");
+    //ALOGV("\tVolumeGetStereoPosition start");
 
     LVM_ControlParams_t     ActiveParams;                           /* Current control Parameters */
     LVM_ReturnStatus_en     LvmStatus = LVM_SUCCESS;                /* Function call status */
     LVM_INT16               balance;
 
-    //LOGV("\tVolumeGetStereoPosition start pContext->pBundledContext->positionSaved = %d",
+    //ALOGV("\tVolumeGetStereoPosition start pContext->pBundledContext->positionSaved = %d",
     //pContext->pBundledContext->positionSaved);
 
     LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
     LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeGetStereoPosition")
     if(LvmStatus != LVM_SUCCESS) return -EINVAL;
 
-    //LOGV("\tVolumeGetStereoPosition -> %d\n", ActiveParams.VC_Balance);
-    //LOGV("\tVolumeGetStereoPosition Succesfully returned from LVM_GetControlParameters\n");
+    //ALOGV("\tVolumeGetStereoPosition -> %d\n", ActiveParams.VC_Balance);
+    //ALOGV("\tVolumeGetStereoPosition Succesfully returned from LVM_GetControlParameters\n");
 
     balance = VolumeConvertStereoPosition(pContext->pBundledContext->positionSaved);
 
@@ -1685,7 +1705,7 @@
         }
     }
     *position = (LVM_INT16)pContext->pBundledContext->positionSaved;     // Convert dB to millibels
-    //LOGV("\tVolumeGetStereoPosition end returning pContext->pBundledContext->positionSaved =%d\n",
+    //ALOGV("\tVolumeGetStereoPosition end returning pContext->pBundledContext->positionSaved =%d\n",
     //pContext->pBundledContext->positionSaved);
     return 0;
 }    /* end VolumeGetStereoPosition */
@@ -1702,7 +1722,7 @@
 //----------------------------------------------------------------------------
 
 int32_t VolumeEnableStereoPosition(EffectContext *pContext, uint32_t enabled){
-    //LOGV("\tVolumeEnableStereoPosition start()");
+    //ALOGV("\tVolumeEnableStereoPosition start()");
 
     pContext->pBundledContext->bStereoPositionEnabled = enabled;
 
@@ -1714,8 +1734,8 @@
     LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeEnableStereoPosition")
     if(LvmStatus != LVM_SUCCESS) return -EINVAL;
 
-    //LOGV("\tVolumeEnableStereoPosition Succesfully returned from LVM_GetControlParameters\n");
-    //LOGV("\tVolumeEnableStereoPosition to %d, position was %d\n",
+    //ALOGV("\tVolumeEnableStereoPosition Succesfully returned from LVM_GetControlParameters\n");
+    //ALOGV("\tVolumeEnableStereoPosition to %d, position was %d\n",
     //     enabled, ActiveParams.VC_Balance );
 
     /* Set appropriate stereo position */
@@ -1731,8 +1751,8 @@
     LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "VolumeEnableStereoPosition")
     if(LvmStatus != LVM_SUCCESS) return -EINVAL;
 
-    //LOGV("\tVolumeEnableStereoPosition Succesfully called LVM_SetControlParameters\n");
-    //LOGV("\tVolumeEnableStereoPosition end()\n");
+    //ALOGV("\tVolumeEnableStereoPosition Succesfully called LVM_SetControlParameters\n");
+    //ALOGV("\tVolumeEnableStereoPosition end()\n");
     return 0;
 }    /* end VolumeEnableStereoPosition */
 
@@ -1767,26 +1787,26 @@
     int32_t param2;
     char *name;
 
-    //LOGV("\tBassBoost_getParameter start");
+    //ALOGV("\tBassBoost_getParameter start");
 
     switch (param){
         case BASSBOOST_PARAM_STRENGTH_SUPPORTED:
             if (*pValueSize != sizeof(uint32_t)){
-                LOGV("\tLVM_ERROR : BassBoost_getParameter() invalid pValueSize1 %d", *pValueSize);
+                ALOGV("\tLVM_ERROR : BassBoost_getParameter() invalid pValueSize1 %d", *pValueSize);
                 return -EINVAL;
             }
             *pValueSize = sizeof(uint32_t);
             break;
         case BASSBOOST_PARAM_STRENGTH:
             if (*pValueSize != sizeof(int16_t)){
-                LOGV("\tLVM_ERROR : BassBoost_getParameter() invalid pValueSize2 %d", *pValueSize);
+                ALOGV("\tLVM_ERROR : BassBoost_getParameter() invalid pValueSize2 %d", *pValueSize);
                 return -EINVAL;
             }
             *pValueSize = sizeof(int16_t);
             break;
 
         default:
-            LOGV("\tLVM_ERROR : BassBoost_getParameter() invalid param %d", param);
+            ALOGV("\tLVM_ERROR : BassBoost_getParameter() invalid param %d", param);
             return -EINVAL;
     }
 
@@ -1794,24 +1814,24 @@
         case BASSBOOST_PARAM_STRENGTH_SUPPORTED:
             *(uint32_t *)pValue = 1;
 
-            //LOGV("\tBassBoost_getParameter() BASSBOOST_PARAM_STRENGTH_SUPPORTED Value is %d",
+            //ALOGV("\tBassBoost_getParameter() BASSBOOST_PARAM_STRENGTH_SUPPORTED Value is %d",
             //        *(uint32_t *)pValue);
             break;
 
         case BASSBOOST_PARAM_STRENGTH:
             *(int16_t *)pValue = BassGetStrength(pContext);
 
-            //LOGV("\tBassBoost_getParameter() BASSBOOST_PARAM_STRENGTH Value is %d",
+            //ALOGV("\tBassBoost_getParameter() BASSBOOST_PARAM_STRENGTH Value is %d",
             //        *(int16_t *)pValue);
             break;
 
         default:
-            LOGV("\tLVM_ERROR : BassBoost_getParameter() invalid param %d", param);
+            ALOGV("\tLVM_ERROR : BassBoost_getParameter() invalid param %d", param);
             status = -EINVAL;
             break;
     }
 
-    //LOGV("\tBassBoost_getParameter end");
+    //ALOGV("\tBassBoost_getParameter end");
     return status;
 } /* end BassBoost_getParameter */
 
@@ -1835,22 +1855,22 @@
     int16_t strength;
     int32_t *pParamTemp = (int32_t *)pParam;
 
-    //LOGV("\tBassBoost_setParameter start");
+    //ALOGV("\tBassBoost_setParameter start");
 
     switch (*pParamTemp){
         case BASSBOOST_PARAM_STRENGTH:
             strength = *(int16_t *)pValue;
-            //LOGV("\tBassBoost_setParameter() BASSBOOST_PARAM_STRENGTH value is %d", strength);
-            //LOGV("\tBassBoost_setParameter() Calling pBassBoost->BassSetStrength");
+            //ALOGV("\tBassBoost_setParameter() BASSBOOST_PARAM_STRENGTH value is %d", strength);
+            //ALOGV("\tBassBoost_setParameter() Calling pBassBoost->BassSetStrength");
             BassSetStrength(pContext, (int32_t)strength);
-            //LOGV("\tBassBoost_setParameter() Called pBassBoost->BassSetStrength");
+            //ALOGV("\tBassBoost_setParameter() Called pBassBoost->BassSetStrength");
            break;
         default:
-            LOGV("\tLVM_ERROR : BassBoost_setParameter() invalid param %d", *pParamTemp);
+            ALOGV("\tLVM_ERROR : BassBoost_setParameter() invalid param %d", *pParamTemp);
             break;
     }
 
-    //LOGV("\tBassBoost_setParameter end");
+    //ALOGV("\tBassBoost_setParameter end");
     return status;
 } /* end BassBoost_setParameter */
 
@@ -1885,26 +1905,26 @@
     int32_t param2;
     char *name;
 
-    //LOGV("\tVirtualizer_getParameter start");
+    //ALOGV("\tVirtualizer_getParameter start");
 
     switch (param){
         case VIRTUALIZER_PARAM_STRENGTH_SUPPORTED:
             if (*pValueSize != sizeof(uint32_t)){
-                LOGV("\tLVM_ERROR : Virtualizer_getParameter() invalid pValueSize %d",*pValueSize);
+                ALOGV("\tLVM_ERROR : Virtualizer_getParameter() invalid pValueSize %d",*pValueSize);
                 return -EINVAL;
             }
             *pValueSize = sizeof(uint32_t);
             break;
         case VIRTUALIZER_PARAM_STRENGTH:
             if (*pValueSize != sizeof(int16_t)){
-                LOGV("\tLVM_ERROR : Virtualizer_getParameter() invalid pValueSize2 %d",*pValueSize);
+                ALOGV("\tLVM_ERROR : Virtualizer_getParameter() invalid pValueSize2 %d",*pValueSize);
                 return -EINVAL;
             }
             *pValueSize = sizeof(int16_t);
             break;
 
         default:
-            LOGV("\tLVM_ERROR : Virtualizer_getParameter() invalid param %d", param);
+            ALOGV("\tLVM_ERROR : Virtualizer_getParameter() invalid param %d", param);
             return -EINVAL;
     }
 
@@ -1912,24 +1932,24 @@
         case VIRTUALIZER_PARAM_STRENGTH_SUPPORTED:
             *(uint32_t *)pValue = 1;
 
-            //LOGV("\tVirtualizer_getParameter() VIRTUALIZER_PARAM_STRENGTH_SUPPORTED Value is %d",
+            //ALOGV("\tVirtualizer_getParameter() VIRTUALIZER_PARAM_STRENGTH_SUPPORTED Value is %d",
             //        *(uint32_t *)pValue);
             break;
 
         case VIRTUALIZER_PARAM_STRENGTH:
             *(int16_t *)pValue = VirtualizerGetStrength(pContext);
 
-            //LOGV("\tVirtualizer_getParameter() VIRTUALIZER_PARAM_STRENGTH Value is %d",
+            //ALOGV("\tVirtualizer_getParameter() VIRTUALIZER_PARAM_STRENGTH Value is %d",
             //        *(int16_t *)pValue);
             break;
 
         default:
-            LOGV("\tLVM_ERROR : Virtualizer_getParameter() invalid param %d", param);
+            ALOGV("\tLVM_ERROR : Virtualizer_getParameter() invalid param %d", param);
             status = -EINVAL;
             break;
     }
 
-    //LOGV("\tVirtualizer_getParameter end");
+    //ALOGV("\tVirtualizer_getParameter end");
     return status;
 } /* end Virtualizer_getParameter */
 
@@ -1954,22 +1974,22 @@
     int32_t *pParamTemp = (int32_t *)pParam;
     int32_t param = *pParamTemp++;
 
-    //LOGV("\tVirtualizer_setParameter start");
+    //ALOGV("\tVirtualizer_setParameter start");
 
     switch (param){
         case VIRTUALIZER_PARAM_STRENGTH:
             strength = *(int16_t *)pValue;
-            //LOGV("\tVirtualizer_setParameter() VIRTUALIZER_PARAM_STRENGTH value is %d", strength);
-            //LOGV("\tVirtualizer_setParameter() Calling pVirtualizer->setStrength");
+            //ALOGV("\tVirtualizer_setParameter() VIRTUALIZER_PARAM_STRENGTH value is %d", strength);
+            //ALOGV("\tVirtualizer_setParameter() Calling pVirtualizer->setStrength");
             VirtualizerSetStrength(pContext, (int32_t)strength);
-            //LOGV("\tVirtualizer_setParameter() Called pVirtualizer->setStrength");
+            //ALOGV("\tVirtualizer_setParameter() Called pVirtualizer->setStrength");
            break;
         default:
-            LOGV("\tLVM_ERROR : Virtualizer_setParameter() invalid param %d", param);
+            ALOGV("\tLVM_ERROR : Virtualizer_setParameter() invalid param %d", param);
             break;
     }
 
-    //LOGV("\tVirtualizer_setParameter end");
+    //ALOGV("\tVirtualizer_setParameter end");
     return status;
 } /* end Virtualizer_setParameter */
 
@@ -2004,7 +2024,7 @@
     int32_t param2;
     char *name;
 
-    //LOGV("\tEqualizer_getParameter start");
+    //ALOGV("\tEqualizer_getParameter start");
 
     switch (param) {
     case EQ_PARAM_NUM_BANDS:
@@ -2013,7 +2033,7 @@
     case EQ_PARAM_BAND_LEVEL:
     case EQ_PARAM_GET_BAND:
         if (*pValueSize < sizeof(int16_t)) {
-            LOGV("\tLVM_ERROR : Equalizer_getParameter() invalid pValueSize 1  %d", *pValueSize);
+            ALOGV("\tLVM_ERROR : Equalizer_getParameter() invalid pValueSize 1  %d", *pValueSize);
             return -EINVAL;
         }
         *pValueSize = sizeof(int16_t);
@@ -2021,14 +2041,14 @@
 
     case EQ_PARAM_LEVEL_RANGE:
         if (*pValueSize < 2 * sizeof(int16_t)) {
-            LOGV("\tLVM_ERROR : Equalizer_getParameter() invalid pValueSize 2  %d", *pValueSize);
+            ALOGV("\tLVM_ERROR : Equalizer_getParameter() invalid pValueSize 2  %d", *pValueSize);
             return -EINVAL;
         }
         *pValueSize = 2 * sizeof(int16_t);
         break;
     case EQ_PARAM_BAND_FREQ_RANGE:
         if (*pValueSize < 2 * sizeof(int32_t)) {
-            LOGV("\tLVM_ERROR : Equalizer_getParameter() invalid pValueSize 3  %d", *pValueSize);
+            ALOGV("\tLVM_ERROR : Equalizer_getParameter() invalid pValueSize 3  %d", *pValueSize);
             return -EINVAL;
         }
         *pValueSize = 2 * sizeof(int32_t);
@@ -2036,7 +2056,7 @@
 
     case EQ_PARAM_CENTER_FREQ:
         if (*pValueSize < sizeof(int32_t)) {
-            LOGV("\tLVM_ERROR : Equalizer_getParameter() invalid pValueSize 5  %d", *pValueSize);
+            ALOGV("\tLVM_ERROR : Equalizer_getParameter() invalid pValueSize 5  %d", *pValueSize);
             return -EINVAL;
         }
         *pValueSize = sizeof(int32_t);
@@ -2047,27 +2067,27 @@
 
     case EQ_PARAM_PROPERTIES:
         if (*pValueSize < (2 + FIVEBAND_NUMBANDS) * sizeof(uint16_t)) {
-            LOGV("\tLVM_ERROR : Equalizer_getParameter() invalid pValueSize 1  %d", *pValueSize);
+            ALOGV("\tLVM_ERROR : Equalizer_getParameter() invalid pValueSize 1  %d", *pValueSize);
             return -EINVAL;
         }
         *pValueSize = (2 + FIVEBAND_NUMBANDS) * sizeof(uint16_t);
         break;
 
     default:
-        LOGV("\tLVM_ERROR : Equalizer_getParameter unknown param %d", param);
+        ALOGV("\tLVM_ERROR : Equalizer_getParameter unknown param %d", param);
         return -EINVAL;
     }
 
     switch (param) {
     case EQ_PARAM_NUM_BANDS:
         *(uint16_t *)pValue = (uint16_t)FIVEBAND_NUMBANDS;
-        //LOGV("\tEqualizer_getParameter() EQ_PARAM_NUM_BANDS %d", *(int16_t *)pValue);
+        //ALOGV("\tEqualizer_getParameter() EQ_PARAM_NUM_BANDS %d", *(int16_t *)pValue);
         break;
 
     case EQ_PARAM_LEVEL_RANGE:
         *(int16_t *)pValue = -1500;
         *((int16_t *)pValue + 1) = 1500;
-        //LOGV("\tEqualizer_getParameter() EQ_PARAM_LEVEL_RANGE min %d, max %d",
+        //ALOGV("\tEqualizer_getParameter() EQ_PARAM_LEVEL_RANGE min %d, max %d",
         //      *(int16_t *)pValue, *((int16_t *)pValue + 1));
         break;
 
@@ -2078,7 +2098,7 @@
             break;
         }
         *(int16_t *)pValue = (int16_t)EqualizerGetBandLevel(pContext, param2);
-        //LOGV("\tEqualizer_getParameter() EQ_PARAM_BAND_LEVEL band %d, level %d",
+        //ALOGV("\tEqualizer_getParameter() EQ_PARAM_BAND_LEVEL band %d, level %d",
         //      param2, *(int32_t *)pValue);
         break;
 
@@ -2089,7 +2109,7 @@
             break;
         }
         *(int32_t *)pValue = EqualizerGetCentreFrequency(pContext, param2);
-        //LOGV("\tEqualizer_getParameter() EQ_PARAM_CENTER_FREQ band %d, frequency %d",
+        //ALOGV("\tEqualizer_getParameter() EQ_PARAM_CENTER_FREQ band %d, frequency %d",
         //      param2, *(int32_t *)pValue);
         break;
 
@@ -2100,25 +2120,25 @@
             break;
         }
         EqualizerGetBandFreqRange(pContext, param2, (uint32_t *)pValue, ((uint32_t *)pValue + 1));
-        //LOGV("\tEqualizer_getParameter() EQ_PARAM_BAND_FREQ_RANGE band %d, min %d, max %d",
+        //ALOGV("\tEqualizer_getParameter() EQ_PARAM_BAND_FREQ_RANGE band %d, min %d, max %d",
         //      param2, *(int32_t *)pValue, *((int32_t *)pValue + 1));
         break;
 
     case EQ_PARAM_GET_BAND:
         param2 = *pParamTemp;
         *(uint16_t *)pValue = (uint16_t)EqualizerGetBand(pContext, param2);
-        //LOGV("\tEqualizer_getParameter() EQ_PARAM_GET_BAND frequency %d, band %d",
+        //ALOGV("\tEqualizer_getParameter() EQ_PARAM_GET_BAND frequency %d, band %d",
         //      param2, *(uint16_t *)pValue);
         break;
 
     case EQ_PARAM_CUR_PRESET:
         *(uint16_t *)pValue = (uint16_t)EqualizerGetPreset(pContext);
-        //LOGV("\tEqualizer_getParameter() EQ_PARAM_CUR_PRESET %d", *(int32_t *)pValue);
+        //ALOGV("\tEqualizer_getParameter() EQ_PARAM_CUR_PRESET %d", *(int32_t *)pValue);
         break;
 
     case EQ_PARAM_GET_NUM_OF_PRESETS:
         *(uint16_t *)pValue = (uint16_t)EqualizerGetNumPresets();
-        //LOGV("\tEqualizer_getParameter() EQ_PARAM_GET_NUM_OF_PRESETS %d", *(int16_t *)pValue);
+        //ALOGV("\tEqualizer_getParameter() EQ_PARAM_GET_NUM_OF_PRESETS %d", *(int16_t *)pValue);
         break;
 
     case EQ_PARAM_GET_PRESET_NAME:
@@ -2132,13 +2152,13 @@
         strncpy(name, EqualizerGetPresetName(param2), *pValueSize - 1);
         name[*pValueSize - 1] = 0;
         *pValueSize = strlen(name) + 1;
-        //LOGV("\tEqualizer_getParameter() EQ_PARAM_GET_PRESET_NAME preset %d, name %s len %d",
+        //ALOGV("\tEqualizer_getParameter() EQ_PARAM_GET_PRESET_NAME preset %d, name %s len %d",
         //      param2, gEqualizerPresets[param2].name, *pValueSize);
         break;
 
     case EQ_PARAM_PROPERTIES: {
         int16_t *p = (int16_t *)pValue;
-        LOGV("\tEqualizer_getParameter() EQ_PARAM_PROPERTIES");
+        ALOGV("\tEqualizer_getParameter() EQ_PARAM_PROPERTIES");
         p[0] = (int16_t)EqualizerGetPreset(pContext);
         p[1] = (int16_t)FIVEBAND_NUMBANDS;
         for (int i = 0; i < FIVEBAND_NUMBANDS; i++) {
@@ -2147,7 +2167,7 @@
     } break;
 
     default:
-        LOGV("\tLVM_ERROR : Equalizer_getParameter() invalid param %d", param);
+        ALOGV("\tLVM_ERROR : Equalizer_getParameter() invalid param %d", param);
         status = -EINVAL;
         break;
     }
@@ -2179,12 +2199,12 @@
     int32_t param = *pParamTemp++;
 
 
-    //LOGV("\tEqualizer_setParameter start");
+    //ALOGV("\tEqualizer_setParameter start");
     switch (param) {
     case EQ_PARAM_CUR_PRESET:
         preset = (int32_t)(*(uint16_t *)pValue);
 
-        //LOGV("\tEqualizer_setParameter() EQ_PARAM_CUR_PRESET %d", preset);
+        //ALOGV("\tEqualizer_setParameter() EQ_PARAM_CUR_PRESET %d", preset);
         if ((preset >= EqualizerGetNumPresets())||(preset < 0)) {
             status = -EINVAL;
             break;
@@ -2194,7 +2214,7 @@
     case EQ_PARAM_BAND_LEVEL:
         band =  *pParamTemp;
         level = (int32_t)(*(int16_t *)pValue);
-        //LOGV("\tEqualizer_setParameter() EQ_PARAM_BAND_LEVEL band %d, level %d", band, level);
+        //ALOGV("\tEqualizer_setParameter() EQ_PARAM_BAND_LEVEL band %d, level %d", band, level);
         if (band >= FIVEBAND_NUMBANDS) {
             status = -EINVAL;
             break;
@@ -2202,7 +2222,7 @@
         EqualizerSetBandLevel(pContext, band, level);
         break;
     case EQ_PARAM_PROPERTIES: {
-        //LOGV("\tEqualizer_setParameter() EQ_PARAM_PROPERTIES");
+        //ALOGV("\tEqualizer_setParameter() EQ_PARAM_PROPERTIES");
         int16_t *p = (int16_t *)pValue;
         if ((int)p[0] >= EqualizerGetNumPresets()) {
             status = -EINVAL;
@@ -2221,12 +2241,12 @@
         }
     } break;
     default:
-        LOGV("\tLVM_ERROR : Equalizer_setParameter() invalid param %d", param);
+        ALOGV("\tLVM_ERROR : Equalizer_setParameter() invalid param %d", param);
         status = -EINVAL;
         break;
     }
 
-    //LOGV("\tEqualizer_setParameter end");
+    //ALOGV("\tEqualizer_setParameter end");
     return status;
 } /* end Equalizer_setParameter */
 
@@ -2261,14 +2281,14 @@
     int32_t param = *pParamTemp++;;
     char *name;
 
-    //LOGV("\tVolume_getParameter start");
+    //ALOGV("\tVolume_getParameter start");
 
     switch (param){
         case VOLUME_PARAM_LEVEL:
         case VOLUME_PARAM_MAXLEVEL:
         case VOLUME_PARAM_STEREOPOSITION:
             if (*pValueSize != sizeof(int16_t)){
-                LOGV("\tLVM_ERROR : Volume_getParameter() invalid pValueSize 1  %d", *pValueSize);
+                ALOGV("\tLVM_ERROR : Volume_getParameter() invalid pValueSize 1  %d", *pValueSize);
                 return -EINVAL;
             }
             *pValueSize = sizeof(int16_t);
@@ -2277,55 +2297,55 @@
         case VOLUME_PARAM_MUTE:
         case VOLUME_PARAM_ENABLESTEREOPOSITION:
             if (*pValueSize < sizeof(int32_t)){
-                LOGV("\tLVM_ERROR : Volume_getParameter() invalid pValueSize 2  %d", *pValueSize);
+                ALOGV("\tLVM_ERROR : Volume_getParameter() invalid pValueSize 2  %d", *pValueSize);
                 return -EINVAL;
             }
             *pValueSize = sizeof(int32_t);
             break;
 
         default:
-            LOGV("\tLVM_ERROR : Volume_getParameter unknown param %d", param);
+            ALOGV("\tLVM_ERROR : Volume_getParameter unknown param %d", param);
             return -EINVAL;
     }
 
     switch (param){
         case VOLUME_PARAM_LEVEL:
             status = VolumeGetVolumeLevel(pContext, (int16_t *)(pValue));
-            //LOGV("\tVolume_getParameter() VOLUME_PARAM_LEVEL Value is %d",
+            //ALOGV("\tVolume_getParameter() VOLUME_PARAM_LEVEL Value is %d",
             //        *(int16_t *)pValue);
             break;
 
         case VOLUME_PARAM_MAXLEVEL:
             *(int16_t *)pValue = 0;
-            //LOGV("\tVolume_getParameter() VOLUME_PARAM_MAXLEVEL Value is %d",
+            //ALOGV("\tVolume_getParameter() VOLUME_PARAM_MAXLEVEL Value is %d",
             //        *(int16_t *)pValue);
             break;
 
         case VOLUME_PARAM_STEREOPOSITION:
             VolumeGetStereoPosition(pContext, (int16_t *)pValue);
-            //LOGV("\tVolume_getParameter() VOLUME_PARAM_STEREOPOSITION Value is %d",
+            //ALOGV("\tVolume_getParameter() VOLUME_PARAM_STEREOPOSITION Value is %d",
             //        *(int16_t *)pValue);
             break;
 
         case VOLUME_PARAM_MUTE:
             status = VolumeGetMute(pContext, (uint32_t *)pValue);
-            LOGV("\tVolume_getParameter() VOLUME_PARAM_MUTE Value is %d",
+            ALOGV("\tVolume_getParameter() VOLUME_PARAM_MUTE Value is %d",
                     *(uint32_t *)pValue);
             break;
 
         case VOLUME_PARAM_ENABLESTEREOPOSITION:
             *(int32_t *)pValue = pContext->pBundledContext->bStereoPositionEnabled;
-            //LOGV("\tVolume_getParameter() VOLUME_PARAM_ENABLESTEREOPOSITION Value is %d",
+            //ALOGV("\tVolume_getParameter() VOLUME_PARAM_ENABLESTEREOPOSITION Value is %d",
             //        *(uint32_t *)pValue);
             break;
 
         default:
-            LOGV("\tLVM_ERROR : Volume_getParameter() invalid param %d", param);
+            ALOGV("\tLVM_ERROR : Volume_getParameter() invalid param %d", param);
             status = -EINVAL;
             break;
     }
 
-    //LOGV("\tVolume_getParameter end");
+    //ALOGV("\tVolume_getParameter end");
     return status;
 } /* end Volume_getParameter */
 
@@ -2354,46 +2374,46 @@
     int32_t *pParamTemp = (int32_t *)pParam;
     int32_t param = *pParamTemp++;
 
-    //LOGV("\tVolume_setParameter start");
+    //ALOGV("\tVolume_setParameter start");
 
     switch (param){
         case VOLUME_PARAM_LEVEL:
             level = *(int16_t *)pValue;
-            //LOGV("\tVolume_setParameter() VOLUME_PARAM_LEVEL value is %d", level);
-            //LOGV("\tVolume_setParameter() Calling pVolume->setVolumeLevel");
+            //ALOGV("\tVolume_setParameter() VOLUME_PARAM_LEVEL value is %d", level);
+            //ALOGV("\tVolume_setParameter() Calling pVolume->setVolumeLevel");
             status = VolumeSetVolumeLevel(pContext, (int16_t)level);
-            //LOGV("\tVolume_setParameter() Called pVolume->setVolumeLevel");
+            //ALOGV("\tVolume_setParameter() Called pVolume->setVolumeLevel");
             break;
 
         case VOLUME_PARAM_MUTE:
             mute = *(uint32_t *)pValue;
-            //LOGV("\tVolume_setParameter() Calling pVolume->setMute, mute is %d", mute);
-            //LOGV("\tVolume_setParameter() Calling pVolume->setMute");
+            //ALOGV("\tVolume_setParameter() Calling pVolume->setMute, mute is %d", mute);
+            //ALOGV("\tVolume_setParameter() Calling pVolume->setMute");
             status = VolumeSetMute(pContext, mute);
-            //LOGV("\tVolume_setParameter() Called pVolume->setMute");
+            //ALOGV("\tVolume_setParameter() Called pVolume->setMute");
             break;
 
         case VOLUME_PARAM_ENABLESTEREOPOSITION:
             positionEnabled = *(uint32_t *)pValue;
             status = VolumeEnableStereoPosition(pContext, positionEnabled);
             status = VolumeSetStereoPosition(pContext, pContext->pBundledContext->positionSaved);
-            //LOGV("\tVolume_setParameter() VOLUME_PARAM_ENABLESTEREOPOSITION called");
+            //ALOGV("\tVolume_setParameter() VOLUME_PARAM_ENABLESTEREOPOSITION called");
             break;
 
         case VOLUME_PARAM_STEREOPOSITION:
             position = *(int16_t *)pValue;
-            //LOGV("\tVolume_setParameter() VOLUME_PARAM_STEREOPOSITION value is %d", position);
-            //LOGV("\tVolume_setParameter() Calling pVolume->VolumeSetStereoPosition");
+            //ALOGV("\tVolume_setParameter() VOLUME_PARAM_STEREOPOSITION value is %d", position);
+            //ALOGV("\tVolume_setParameter() Calling pVolume->VolumeSetStereoPosition");
             status = VolumeSetStereoPosition(pContext, (int16_t)position);
-            //LOGV("\tVolume_setParameter() Called pVolume->VolumeSetStereoPosition");
+            //ALOGV("\tVolume_setParameter() Called pVolume->VolumeSetStereoPosition");
             break;
 
         default:
-            LOGV("\tLVM_ERROR : Volume_setParameter() invalid param %d", param);
+            ALOGV("\tLVM_ERROR : Volume_setParameter() invalid param %d", param);
             break;
     }
 
-    //LOGV("\tVolume_setParameter end");
+    //ALOGV("\tVolume_setParameter end");
     return status;
 } /* end Volume_setParameter */
 
@@ -2459,7 +2479,7 @@
 
 int Effect_setEnabled(EffectContext *pContext, bool enabled)
 {
-    LOGV("\tEffect_setEnabled() type %d, enabled %d", pContext->EffectType, enabled);
+    ALOGV("\tEffect_setEnabled() type %d, enabled %d", pContext->EffectType, enabled);
 
     if (enabled) {
         // Bass boost or Virtualizer can be temporarily disabled if playing over device speaker due
@@ -2468,7 +2488,7 @@
         switch (pContext->EffectType) {
             case LVM_BASS_BOOST:
                 if (pContext->pBundledContext->bBassEnabled == LVM_TRUE) {
-                     LOGV("\tEffect_setEnabled() LVM_BASS_BOOST is already enabled");
+                     ALOGV("\tEffect_setEnabled() LVM_BASS_BOOST is already enabled");
                      return -EINVAL;
                 }
                 if(pContext->pBundledContext->SamplesToExitCountBb <= 0){
@@ -2481,7 +2501,7 @@
                 break;
             case LVM_EQUALIZER:
                 if (pContext->pBundledContext->bEqualizerEnabled == LVM_TRUE) {
-                    LOGV("\tEffect_setEnabled() LVM_EQUALIZER is already enabled");
+                    ALOGV("\tEffect_setEnabled() LVM_EQUALIZER is already enabled");
                     return -EINVAL;
                 }
                 if(pContext->pBundledContext->SamplesToExitCountEq <= 0){
@@ -2493,7 +2513,7 @@
                 break;
             case LVM_VIRTUALIZER:
                 if (pContext->pBundledContext->bVirtualizerEnabled == LVM_TRUE) {
-                    LOGV("\tEffect_setEnabled() LVM_VIRTUALIZER is already enabled");
+                    ALOGV("\tEffect_setEnabled() LVM_VIRTUALIZER is already enabled");
                     return -EINVAL;
                 }
                 if(pContext->pBundledContext->SamplesToExitCountVirt <= 0){
@@ -2506,14 +2526,14 @@
                 break;
             case LVM_VOLUME:
                 if (pContext->pBundledContext->bVolumeEnabled == LVM_TRUE) {
-                    LOGV("\tEffect_setEnabled() LVM_VOLUME is already enabled");
+                    ALOGV("\tEffect_setEnabled() LVM_VOLUME is already enabled");
                     return -EINVAL;
                 }
                 pContext->pBundledContext->NumberEffectsEnabled++;
                 pContext->pBundledContext->bVolumeEnabled = LVM_TRUE;
                 break;
             default:
-                LOGV("\tEffect_setEnabled() invalid effect type");
+                ALOGV("\tEffect_setEnabled() invalid effect type");
                 return -EINVAL;
         }
         if (!tempDisabled) {
@@ -2523,34 +2543,34 @@
         switch (pContext->EffectType) {
             case LVM_BASS_BOOST:
                 if (pContext->pBundledContext->bBassEnabled == LVM_FALSE) {
-                    LOGV("\tEffect_setEnabled() LVM_BASS_BOOST is already disabled");
+                    ALOGV("\tEffect_setEnabled() LVM_BASS_BOOST is already disabled");
                     return -EINVAL;
                 }
                 pContext->pBundledContext->bBassEnabled = LVM_FALSE;
                 break;
             case LVM_EQUALIZER:
                 if (pContext->pBundledContext->bEqualizerEnabled == LVM_FALSE) {
-                    LOGV("\tEffect_setEnabled() LVM_EQUALIZER is already disabled");
+                    ALOGV("\tEffect_setEnabled() LVM_EQUALIZER is already disabled");
                     return -EINVAL;
                 }
                 pContext->pBundledContext->bEqualizerEnabled = LVM_FALSE;
                 break;
             case LVM_VIRTUALIZER:
                 if (pContext->pBundledContext->bVirtualizerEnabled == LVM_FALSE) {
-                    LOGV("\tEffect_setEnabled() LVM_VIRTUALIZER is already disabled");
+                    ALOGV("\tEffect_setEnabled() LVM_VIRTUALIZER is already disabled");
                     return -EINVAL;
                 }
                 pContext->pBundledContext->bVirtualizerEnabled = LVM_FALSE;
                 break;
             case LVM_VOLUME:
                 if (pContext->pBundledContext->bVolumeEnabled == LVM_FALSE) {
-                    LOGV("\tEffect_setEnabled() LVM_VOLUME is already disabled");
+                    ALOGV("\tEffect_setEnabled() LVM_VOLUME is already disabled");
                     return -EINVAL;
                 }
                 pContext->pBundledContext->bVolumeEnabled = LVM_FALSE;
                 break;
             default:
-                LOGV("\tEffect_setEnabled() invalid effect type");
+                ALOGV("\tEffect_setEnabled() invalid effect type");
                 return -EINVAL;
         }
         LvmEffect_disable(pContext);
@@ -2595,77 +2615,77 @@
     LVM_INT16   *in  = (LVM_INT16 *)inBuffer->raw;
     LVM_INT16   *out = (LVM_INT16 *)outBuffer->raw;
 
-//LOGV("\tEffect_process Start : Enabled = %d     Called = %d (%8d %8d %8d)",
+//ALOGV("\tEffect_process Start : Enabled = %d     Called = %d (%8d %8d %8d)",
 //pContext->pBundledContext->NumberEffectsEnabled,pContext->pBundledContext->NumberEffectsCalled,
 //    pContext->pBundledContext->SamplesToExitCountBb,
 //    pContext->pBundledContext->SamplesToExitCountVirt,
 //    pContext->pBundledContext->SamplesToExitCountEq);
 
     if (pContext == NULL){
-        LOGV("\tLVM_ERROR : Effect_process() ERROR pContext == NULL");
+        ALOGV("\tLVM_ERROR : Effect_process() ERROR pContext == NULL");
         return -EINVAL;
     }
 
     //if(pContext->EffectType == LVM_BASS_BOOST){
-    //  LOGV("\tEffect_process: Effect type is BASS_BOOST");
+    //  ALOGV("\tEffect_process: Effect type is BASS_BOOST");
     //}else if(pContext->EffectType == LVM_EQUALIZER){
-    //  LOGV("\tEffect_process: Effect type is LVM_EQUALIZER");
+    //  ALOGV("\tEffect_process: Effect type is LVM_EQUALIZER");
     //}else if(pContext->EffectType == LVM_VIRTUALIZER){
-    //  LOGV("\tEffect_process: Effect type is LVM_VIRTUALIZER");
+    //  ALOGV("\tEffect_process: Effect type is LVM_VIRTUALIZER");
     //}
 
     if (inBuffer == NULL  || inBuffer->raw == NULL  ||
             outBuffer == NULL || outBuffer->raw == NULL ||
             inBuffer->frameCount != outBuffer->frameCount){
-        LOGV("\tLVM_ERROR : Effect_process() ERROR NULL INPUT POINTER OR FRAME COUNT IS WRONG");
+        ALOGV("\tLVM_ERROR : Effect_process() ERROR NULL INPUT POINTER OR FRAME COUNT IS WRONG");
         return -EINVAL;
     }
     if ((pContext->pBundledContext->bBassEnabled == LVM_FALSE)&&
         (pContext->EffectType == LVM_BASS_BOOST)){
-        //LOGV("\tEffect_process() LVM_BASS_BOOST Effect is not enabled");
+        //ALOGV("\tEffect_process() LVM_BASS_BOOST Effect is not enabled");
         if(pContext->pBundledContext->SamplesToExitCountBb > 0){
             pContext->pBundledContext->SamplesToExitCountBb -= outBuffer->frameCount * 2; // STEREO
-            //LOGV("\tEffect_process: Waiting to turn off BASS_BOOST, %d samples left",
+            //ALOGV("\tEffect_process: Waiting to turn off BASS_BOOST, %d samples left",
             //    pContext->pBundledContext->SamplesToExitCountBb);
         }
         if(pContext->pBundledContext->SamplesToExitCountBb <= 0) {
             status = -ENODATA;
             pContext->pBundledContext->NumberEffectsEnabled--;
-            LOGV("\tEffect_process() this is the last frame for LVM_BASS_BOOST");
+            ALOGV("\tEffect_process() this is the last frame for LVM_BASS_BOOST");
         }
     }
     if ((pContext->pBundledContext->bVolumeEnabled == LVM_FALSE)&&
         (pContext->EffectType == LVM_VOLUME)){
-        //LOGV("\tEffect_process() LVM_VOLUME Effect is not enabled");
+        //ALOGV("\tEffect_process() LVM_VOLUME Effect is not enabled");
         status = -ENODATA;
         pContext->pBundledContext->NumberEffectsEnabled--;
     }
     if ((pContext->pBundledContext->bEqualizerEnabled == LVM_FALSE)&&
         (pContext->EffectType == LVM_EQUALIZER)){
-        //LOGV("\tEffect_process() LVM_EQUALIZER Effect is not enabled");
+        //ALOGV("\tEffect_process() LVM_EQUALIZER Effect is not enabled");
         if(pContext->pBundledContext->SamplesToExitCountEq > 0){
             pContext->pBundledContext->SamplesToExitCountEq -= outBuffer->frameCount * 2; // STEREO
-            //LOGV("\tEffect_process: Waiting to turn off EQUALIZER, %d samples left",
+            //ALOGV("\tEffect_process: Waiting to turn off EQUALIZER, %d samples left",
             //    pContext->pBundledContext->SamplesToExitCountEq);
         }
         if(pContext->pBundledContext->SamplesToExitCountEq <= 0) {
             status = -ENODATA;
             pContext->pBundledContext->NumberEffectsEnabled--;
-            LOGV("\tEffect_process() this is the last frame for LVM_EQUALIZER");
+            ALOGV("\tEffect_process() this is the last frame for LVM_EQUALIZER");
         }
     }
     if ((pContext->pBundledContext->bVirtualizerEnabled == LVM_FALSE)&&
         (pContext->EffectType == LVM_VIRTUALIZER)){
-        //LOGV("\tEffect_process() LVM_VIRTUALIZER Effect is not enabled");
+        //ALOGV("\tEffect_process() LVM_VIRTUALIZER Effect is not enabled");
         if(pContext->pBundledContext->SamplesToExitCountVirt > 0){
             pContext->pBundledContext->SamplesToExitCountVirt -= outBuffer->frameCount * 2;// STEREO
-            //LOGV("\tEffect_process: Waiting for to turn off VIRTUALIZER, %d samples left",
+            //ALOGV("\tEffect_process: Waiting for to turn off VIRTUALIZER, %d samples left",
             //    pContext->pBundledContext->SamplesToExitCountVirt);
         }
         if(pContext->pBundledContext->SamplesToExitCountVirt <= 0) {
             status = -ENODATA;
             pContext->pBundledContext->NumberEffectsEnabled--;
-            LOGV("\tEffect_process() this is the last frame for LVM_VIRTUALIZER");
+            ALOGV("\tEffect_process() this is the last frame for LVM_VIRTUALIZER");
         }
     }
 
@@ -2675,12 +2695,12 @@
 
     if(pContext->pBundledContext->NumberEffectsCalled ==
        pContext->pBundledContext->NumberEffectsEnabled){
-        //LOGV("\tEffect_process     Calling process with %d effects enabled, %d called: Effect %d",
+        //ALOGV("\tEffect_process     Calling process with %d effects enabled, %d called: Effect %d",
         //pContext->pBundledContext->NumberEffectsEnabled,
         //pContext->pBundledContext->NumberEffectsCalled, pContext->EffectType);
 
         if(status == -ENODATA){
-            LOGV("\tEffect_process() processing last frame");
+            ALOGV("\tEffect_process() processing last frame");
         }
         pContext->pBundledContext->NumberEffectsCalled = 0;
         /* Process all the available frames, block processing is
@@ -2690,11 +2710,11 @@
                                                 outBuffer->frameCount,
                                                 pContext);
         if(lvmStatus != LVM_SUCCESS){
-            LOGV("\tLVM_ERROR : LvmBundle_process returned error %d", lvmStatus);
+            ALOGV("\tLVM_ERROR : LvmBundle_process returned error %d", lvmStatus);
             return lvmStatus;
         }
     } else {
-        //LOGV("\tEffect_process Not Calling process with %d effects enabled, %d called: Effect %d",
+        //ALOGV("\tEffect_process Not Calling process with %d effects enabled, %d called: Effect %d",
         //pContext->pBundledContext->NumberEffectsEnabled,
         //pContext->pBundledContext->NumberEffectsCalled, pContext->EffectType);
         // 2 is for stereo input
@@ -2721,92 +2741,103 @@
     EffectContext * pContext = (EffectContext *) self;
     int retsize;
 
-    //LOGV("\t\nEffect_command start");
+    //ALOGV("\t\nEffect_command start");
 
     if(pContext->EffectType == LVM_BASS_BOOST){
-        //LOGV("\tEffect_command setting command for LVM_BASS_BOOST");
+        //ALOGV("\tEffect_command setting command for LVM_BASS_BOOST");
     }
     if(pContext->EffectType == LVM_VIRTUALIZER){
-        //LOGV("\tEffect_command setting command for LVM_VIRTUALIZER");
+        //ALOGV("\tEffect_command setting command for LVM_VIRTUALIZER");
     }
     if(pContext->EffectType == LVM_EQUALIZER){
-        //LOGV("\tEffect_command setting command for LVM_EQUALIZER");
+        //ALOGV("\tEffect_command setting command for LVM_EQUALIZER");
     }
     if(pContext->EffectType == LVM_VOLUME){
-        //LOGV("\tEffect_command setting command for LVM_VOLUME");
+        //ALOGV("\tEffect_command setting command for LVM_VOLUME");
     }
 
     if (pContext == NULL){
-        LOGV("\tLVM_ERROR : Effect_command ERROR pContext == NULL");
+        ALOGV("\tLVM_ERROR : Effect_command ERROR pContext == NULL");
         return -EINVAL;
     }
 
-    //LOGV("\tEffect_command INPUTS are: command %d cmdSize %d",cmdCode, cmdSize);
+    //ALOGV("\tEffect_command INPUTS are: command %d cmdSize %d",cmdCode, cmdSize);
 
     // Incase we disable an effect, next time process is
     // called the number of effect called could be greater
     // pContext->pBundledContext->NumberEffectsCalled = 0;
 
-    //LOGV("\tEffect_command NumberEffectsCalled = %d, NumberEffectsEnabled = %d",
+    //ALOGV("\tEffect_command NumberEffectsCalled = %d, NumberEffectsEnabled = %d",
     //        pContext->pBundledContext->NumberEffectsCalled,
     //        pContext->pBundledContext->NumberEffectsEnabled);
 
     switch (cmdCode){
         case EFFECT_CMD_INIT:
             if (pReplyData == NULL || *replySize != sizeof(int)){
-                LOGV("\tLVM_ERROR, EFFECT_CMD_INIT: ERROR for effect type %d",
+                ALOGV("\tLVM_ERROR, EFFECT_CMD_INIT: ERROR for effect type %d",
                         pContext->EffectType);
                 return -EINVAL;
             }
             *(int *) pReplyData = 0;
-            //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_INIT start");
+            //ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_INIT start");
             if(pContext->EffectType == LVM_BASS_BOOST){
-                //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_INIT for LVM_BASS_BOOST");
+                //ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_INIT for LVM_BASS_BOOST");
                 android::BassSetStrength(pContext, 0);
             }
             if(pContext->EffectType == LVM_VIRTUALIZER){
-                //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_INIT for LVM_VIRTUALIZER");
+                //ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_INIT for LVM_VIRTUALIZER");
                 android::VirtualizerSetStrength(pContext, 0);
             }
             if(pContext->EffectType == LVM_EQUALIZER){
-                //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_INIT for LVM_EQUALIZER");
+                //ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_INIT for LVM_EQUALIZER");
                 android::EqualizerSetPreset(pContext, 0);
             }
             if(pContext->EffectType == LVM_VOLUME){
-                //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_INIT for LVM_VOLUME");
+                //ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_INIT for LVM_VOLUME");
                 *(int *) pReplyData = android::VolumeSetVolumeLevel(pContext, 0);
             }
             break;
 
-        case EFFECT_CMD_CONFIGURE:
-            //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_CONFIGURE start");
+        case EFFECT_CMD_SET_CONFIG:
+            //ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_SET_CONFIG start");
             if (pCmdData    == NULL||
                 cmdSize     != sizeof(effect_config_t)||
                 pReplyData  == NULL||
                 *replySize  != sizeof(int)){
-                LOGV("\tLVM_ERROR : Effect_command cmdCode Case: "
-                        "EFFECT_CMD_CONFIGURE: ERROR");
+                ALOGV("\tLVM_ERROR : Effect_command cmdCode Case: "
+                        "EFFECT_CMD_SET_CONFIG: ERROR");
                 return -EINVAL;
             }
-            *(int *) pReplyData = android::Effect_configure(pContext, (effect_config_t *) pCmdData);
-            //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_CONFIGURE end");
+            *(int *) pReplyData = android::Effect_setConfig(pContext, (effect_config_t *) pCmdData);
+            //ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_SET_CONFIG end");
+            break;
+
+        case EFFECT_CMD_GET_CONFIG:
+            if (pReplyData == NULL ||
+                *replySize != sizeof(effect_config_t)) {
+                ALOGV("\tLVM_ERROR : Effect_command cmdCode Case: "
+                        "EFFECT_CMD_GET_CONFIG: ERROR");
+                return -EINVAL;
+            }
+
+            android::Effect_getConfig(pContext, (effect_config_t *)pReplyData);
             break;
 
         case EFFECT_CMD_RESET:
-            //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_RESET start");
-            android::Effect_configure(pContext, &pContext->config);
-            //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_RESET end");
+            //ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_RESET start");
+            android::Effect_setConfig(pContext, &pContext->config);
+            //ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_RESET end");
             break;
 
         case EFFECT_CMD_GET_PARAM:{
-            //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_GET_PARAM start");
+            //ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_GET_PARAM start");
 
             if(pContext->EffectType == LVM_BASS_BOOST){
                 if (pCmdData == NULL ||
                         cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) ||
                         pReplyData == NULL ||
                         *replySize < (int) (sizeof(effect_param_t) + sizeof(int32_t))){
-                    LOGV("\tLVM_ERROR : BassBoost_command cmdCode Case: "
+                    ALOGV("\tLVM_ERROR : BassBoost_command cmdCode Case: "
                             "EFFECT_CMD_GET_PARAM: ERROR");
                     return -EINVAL;
                 }
@@ -2825,7 +2856,7 @@
 
                 *replySize = sizeof(effect_param_t) + voffset + p->vsize;
 
-                //LOGV("\tBassBoost_command EFFECT_CMD_GET_PARAM "
+                //ALOGV("\tBassBoost_command EFFECT_CMD_GET_PARAM "
                 //        "*pCmdData %d, *replySize %d, *pReplyData %d ",
                 //        *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)),
                 //        *replySize,
@@ -2837,7 +2868,7 @@
                         cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) ||
                         pReplyData == NULL ||
                         *replySize < (int) (sizeof(effect_param_t) + sizeof(int32_t))){
-                    LOGV("\tLVM_ERROR : Virtualizer_command cmdCode Case: "
+                    ALOGV("\tLVM_ERROR : Virtualizer_command cmdCode Case: "
                             "EFFECT_CMD_GET_PARAM: ERROR");
                     return -EINVAL;
                 }
@@ -2856,20 +2887,20 @@
 
                 *replySize = sizeof(effect_param_t) + voffset + p->vsize;
 
-                //LOGV("\tVirtualizer_command EFFECT_CMD_GET_PARAM "
+                //ALOGV("\tVirtualizer_command EFFECT_CMD_GET_PARAM "
                 //        "*pCmdData %d, *replySize %d, *pReplyData %d ",
                 //        *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)),
                 //        *replySize,
                 //        *(int16_t *)((char *)pReplyData + sizeof(effect_param_t) + voffset));
             }
             if(pContext->EffectType == LVM_EQUALIZER){
-                //LOGV("\tEqualizer_command cmdCode Case: "
+                //ALOGV("\tEqualizer_command cmdCode Case: "
                 //        "EFFECT_CMD_GET_PARAM start");
                 if (pCmdData == NULL ||
                     cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) ||
                     pReplyData == NULL ||
                     *replySize < (int) (sizeof(effect_param_t) + sizeof(int32_t))) {
-                    LOGV("\tLVM_ERROR : Equalizer_command cmdCode Case: "
+                    ALOGV("\tLVM_ERROR : Equalizer_command cmdCode Case: "
                             "EFFECT_CMD_GET_PARAM");
                     return -EINVAL;
                 }
@@ -2888,7 +2919,7 @@
 
                 *replySize = sizeof(effect_param_t) + voffset + p->vsize;
 
-                //LOGV("\tEqualizer_command EFFECT_CMD_GET_PARAM *pCmdData %d, *replySize %d, "
+                //ALOGV("\tEqualizer_command EFFECT_CMD_GET_PARAM *pCmdData %d, *replySize %d, "
                 //       "*pReplyData %08x %08x",
                 //        *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)), *replySize,
                 //        *(int32_t *)((char *)pReplyData + sizeof(effect_param_t) + voffset),
@@ -2896,12 +2927,12 @@
                 //        sizeof(int32_t)));
             }
             if(pContext->EffectType == LVM_VOLUME){
-                //LOGV("\tVolume_command cmdCode Case: EFFECT_CMD_GET_PARAM start");
+                //ALOGV("\tVolume_command cmdCode Case: EFFECT_CMD_GET_PARAM start");
                 if (pCmdData == NULL ||
                         cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) ||
                         pReplyData == NULL ||
                         *replySize < (int) (sizeof(effect_param_t) + sizeof(int32_t))){
-                    LOGV("\tLVM_ERROR : Volume_command cmdCode Case: "
+                    ALOGV("\tLVM_ERROR : Volume_command cmdCode Case: "
                             "EFFECT_CMD_GET_PARAM: ERROR");
                     return -EINVAL;
                 }
@@ -2920,18 +2951,18 @@
 
                 *replySize = sizeof(effect_param_t) + voffset + p->vsize;
 
-                //LOGV("\tVolume_command EFFECT_CMD_GET_PARAM "
+                //ALOGV("\tVolume_command EFFECT_CMD_GET_PARAM "
                 //        "*pCmdData %d, *replySize %d, *pReplyData %d ",
                 //        *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)),
                 //        *replySize,
                 //        *(int16_t *)((char *)pReplyData + sizeof(effect_param_t) + voffset));
             }
-            //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_GET_PARAM end");
+            //ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_GET_PARAM end");
         } break;
         case EFFECT_CMD_SET_PARAM:{
-            //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_SET_PARAM start");
+            //ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_SET_PARAM start");
             if(pContext->EffectType == LVM_BASS_BOOST){
-                //LOGV("\tBassBoost_command EFFECT_CMD_SET_PARAM param %d, *replySize %d, value %d",
+                //ALOGV("\tBassBoost_command EFFECT_CMD_SET_PARAM param %d, *replySize %d, value %d",
                 //       *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)),
                 //       *replySize,
                 //       *(int16_t *)((char *)pCmdData + sizeof(effect_param_t) + sizeof(int32_t)));
@@ -2940,19 +2971,19 @@
                     cmdSize    != (int)(sizeof(effect_param_t) + sizeof(int32_t) +sizeof(int16_t))||
                     pReplyData == NULL||
                     *replySize != sizeof(int32_t)){
-                    LOGV("\tLVM_ERROR : BassBoost_command cmdCode Case: "
+                    ALOGV("\tLVM_ERROR : BassBoost_command cmdCode Case: "
                             "EFFECT_CMD_SET_PARAM: ERROR");
                     return -EINVAL;
                 }
                 effect_param_t *p = (effect_param_t *) pCmdData;
 
                 if (p->psize != sizeof(int32_t)){
-                    LOGV("\tLVM_ERROR : BassBoost_command cmdCode Case: "
+                    ALOGV("\tLVM_ERROR : BassBoost_command cmdCode Case: "
                             "EFFECT_CMD_SET_PARAM: ERROR, psize is not sizeof(int32_t)");
                     return -EINVAL;
                 }
 
-                //LOGV("\tnBassBoost_command cmdSize is %d\n"
+                //ALOGV("\tnBassBoost_command cmdSize is %d\n"
                 //        "\tsizeof(effect_param_t) is  %d\n"
                 //        "\tp->psize is %d\n"
                 //        "\tp->vsize is %d"
@@ -2964,7 +2995,7 @@
                                                                     p->data + p->psize);
             }
             if(pContext->EffectType == LVM_VIRTUALIZER){
-              //LOGV("\tVirtualizer_command EFFECT_CMD_SET_PARAM param %d, *replySize %d, value %d",
+              //ALOGV("\tVirtualizer_command EFFECT_CMD_SET_PARAM param %d, *replySize %d, value %d",
               //        *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)),
               //        *replySize,
               //        *(int16_t *)((char *)pCmdData + sizeof(effect_param_t) + sizeof(int32_t)));
@@ -2973,19 +3004,19 @@
                     cmdSize    != (int)(sizeof(effect_param_t) + sizeof(int32_t) +sizeof(int16_t))||
                     pReplyData == NULL||
                     *replySize != sizeof(int32_t)){
-                    LOGV("\tLVM_ERROR : Virtualizer_command cmdCode Case: "
+                    ALOGV("\tLVM_ERROR : Virtualizer_command cmdCode Case: "
                             "EFFECT_CMD_SET_PARAM: ERROR");
                     return -EINVAL;
                 }
                 effect_param_t *p = (effect_param_t *) pCmdData;
 
                 if (p->psize != sizeof(int32_t)){
-                    LOGV("\tLVM_ERROR : Virtualizer_command cmdCode Case: "
+                    ALOGV("\tLVM_ERROR : Virtualizer_command cmdCode Case: "
                             "EFFECT_CMD_SET_PARAM: ERROR, psize is not sizeof(int32_t)");
                     return -EINVAL;
                 }
 
-                //LOGV("\tnVirtualizer_command cmdSize is %d\n"
+                //ALOGV("\tnVirtualizer_command cmdSize is %d\n"
                 //        "\tsizeof(effect_param_t) is  %d\n"
                 //        "\tp->psize is %d\n"
                 //        "\tp->vsize is %d"
@@ -2997,16 +3028,16 @@
                                                                        p->data + p->psize);
             }
             if(pContext->EffectType == LVM_EQUALIZER){
-               //LOGV("\tEqualizer_command cmdCode Case: "
+               //ALOGV("\tEqualizer_command cmdCode Case: "
                //        "EFFECT_CMD_SET_PARAM start");
-               //LOGV("\tEqualizer_command EFFECT_CMD_SET_PARAM param %d, *replySize %d, value %d ",
+               //ALOGV("\tEqualizer_command EFFECT_CMD_SET_PARAM param %d, *replySize %d, value %d ",
                //        *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)),
                //        *replySize,
                //        *(int16_t *)((char *)pCmdData + sizeof(effect_param_t) + sizeof(int32_t)));
 
                 if (pCmdData == NULL || cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) ||
                     pReplyData == NULL || *replySize != sizeof(int32_t)) {
-                    LOGV("\tLVM_ERROR : Equalizer_command cmdCode Case: "
+                    ALOGV("\tLVM_ERROR : Equalizer_command cmdCode Case: "
                             "EFFECT_CMD_SET_PARAM: ERROR");
                     return -EINVAL;
                 }
@@ -3017,8 +3048,8 @@
                                                                      p->data + p->psize);
             }
             if(pContext->EffectType == LVM_VOLUME){
-                //LOGV("\tVolume_command cmdCode Case: EFFECT_CMD_SET_PARAM start");
-                //LOGV("\tVolume_command EFFECT_CMD_SET_PARAM param %d, *replySize %d, value %d ",
+                //ALOGV("\tVolume_command cmdCode Case: EFFECT_CMD_SET_PARAM start");
+                //ALOGV("\tVolume_command EFFECT_CMD_SET_PARAM param %d, *replySize %d, value %d ",
                 //        *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)),
                 //        *replySize,
                 //        *(int16_t *)((char *)pCmdData + sizeof(effect_param_t) +sizeof(int32_t)));
@@ -3027,7 +3058,7 @@
                         cmdSize    < (int)(sizeof(effect_param_t) + sizeof(int32_t))||
                         pReplyData == NULL||
                         *replySize != sizeof(int32_t)){
-                    LOGV("\tLVM_ERROR : Volume_command cmdCode Case: "
+                    ALOGV("\tLVM_ERROR : Volume_command cmdCode Case: "
                             "EFFECT_CMD_SET_PARAM: ERROR");
                     return -EINVAL;
                 }
@@ -3037,13 +3068,13 @@
                                                                  (void *)p->data,
                                                                  p->data + p->psize);
             }
-            //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_SET_PARAM end");
+            //ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_SET_PARAM end");
         } break;
 
         case EFFECT_CMD_ENABLE:
-            LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_ENABLE start");
+            ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_ENABLE start");
             if (pReplyData == NULL || *replySize != sizeof(int)){
-                LOGV("\tLVM_ERROR : Effect_command cmdCode Case: EFFECT_CMD_ENABLE: ERROR");
+                ALOGV("\tLVM_ERROR : Effect_command cmdCode Case: EFFECT_CMD_ENABLE: ERROR");
                 return -EINVAL;
             }
 
@@ -3051,9 +3082,9 @@
             break;
 
         case EFFECT_CMD_DISABLE:
-            //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_DISABLE start");
+            //ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_DISABLE start");
             if (pReplyData == NULL || *replySize != sizeof(int)){
-                LOGV("\tLVM_ERROR : Effect_command cmdCode Case: EFFECT_CMD_DISABLE: ERROR");
+                ALOGV("\tLVM_ERROR : Effect_command cmdCode Case: EFFECT_CMD_DISABLE: ERROR");
                 return -EINVAL;
             }
             *(int *)pReplyData = android::Effect_setEnabled(pContext, LVM_FALSE);
@@ -3061,36 +3092,36 @@
 
         case EFFECT_CMD_SET_DEVICE:
         {
-            LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_SET_DEVICE start");
+            ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_SET_DEVICE start");
             uint32_t device = *(uint32_t *)pCmdData;
 
             if (pContext->EffectType == LVM_BASS_BOOST) {
                 if((device == AUDIO_DEVICE_OUT_SPEAKER) ||
                         (device == AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT) ||
                         (device == AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER)){
-                    LOGV("\tEFFECT_CMD_SET_DEVICE device is invalid for LVM_BASS_BOOST %d",
+                    ALOGV("\tEFFECT_CMD_SET_DEVICE device is invalid for LVM_BASS_BOOST %d",
                           *(int32_t *)pCmdData);
-                    LOGV("\tEFFECT_CMD_SET_DEVICE temporary disable LVM_BAS_BOOST");
+                    ALOGV("\tEFFECT_CMD_SET_DEVICE temporary disable LVM_BAS_BOOST");
 
                     // If a device doesnt support bassboost the effect must be temporarily disabled
                     // the effect must still report its original state as this can only be changed
                     // by the ENABLE/DISABLE command
 
                     if (pContext->pBundledContext->bBassEnabled == LVM_TRUE) {
-                        LOGV("\tEFFECT_CMD_SET_DEVICE disable LVM_BASS_BOOST %d",
+                        ALOGV("\tEFFECT_CMD_SET_DEVICE disable LVM_BASS_BOOST %d",
                              *(int32_t *)pCmdData);
                         android::LvmEffect_disable(pContext);
                     }
                     pContext->pBundledContext->bBassTempDisabled = LVM_TRUE;
                 } else {
-                    LOGV("\tEFFECT_CMD_SET_DEVICE device is valid for LVM_BASS_BOOST %d",
+                    ALOGV("\tEFFECT_CMD_SET_DEVICE device is valid for LVM_BASS_BOOST %d",
                          *(int32_t *)pCmdData);
 
                     // If a device supports bassboost and the effect has been temporarily disabled
                     // previously then re-enable it
 
                     if (pContext->pBundledContext->bBassEnabled == LVM_TRUE) {
-                        LOGV("\tEFFECT_CMD_SET_DEVICE re-enable LVM_BASS_BOOST %d",
+                        ALOGV("\tEFFECT_CMD_SET_DEVICE re-enable LVM_BASS_BOOST %d",
                              *(int32_t *)pCmdData);
                         android::LvmEffect_enable(pContext);
                     }
@@ -3101,36 +3132,36 @@
                 if((device == AUDIO_DEVICE_OUT_SPEAKER)||
                         (device == AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT)||
                         (device == AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER)){
-                    LOGV("\tEFFECT_CMD_SET_DEVICE device is invalid for LVM_VIRTUALIZER %d",
+                    ALOGV("\tEFFECT_CMD_SET_DEVICE device is invalid for LVM_VIRTUALIZER %d",
                           *(int32_t *)pCmdData);
-                    LOGV("\tEFFECT_CMD_SET_DEVICE temporary disable LVM_VIRTUALIZER");
+                    ALOGV("\tEFFECT_CMD_SET_DEVICE temporary disable LVM_VIRTUALIZER");
 
                     //If a device doesnt support virtualizer the effect must be temporarily disabled
                     // the effect must still report its original state as this can only be changed
                     // by the ENABLE/DISABLE command
 
                     if (pContext->pBundledContext->bVirtualizerEnabled == LVM_TRUE) {
-                        LOGV("\tEFFECT_CMD_SET_DEVICE disable LVM_VIRTUALIZER %d",
+                        ALOGV("\tEFFECT_CMD_SET_DEVICE disable LVM_VIRTUALIZER %d",
                               *(int32_t *)pCmdData);
                         android::LvmEffect_disable(pContext);
                     }
                     pContext->pBundledContext->bVirtualizerTempDisabled = LVM_TRUE;
                 } else {
-                    LOGV("\tEFFECT_CMD_SET_DEVICE device is valid for LVM_VIRTUALIZER %d",
+                    ALOGV("\tEFFECT_CMD_SET_DEVICE device is valid for LVM_VIRTUALIZER %d",
                           *(int32_t *)pCmdData);
 
                     // If a device supports virtualizer and the effect has been temporarily disabled
                     // previously then re-enable it
 
                     if(pContext->pBundledContext->bVirtualizerEnabled == LVM_TRUE){
-                        LOGV("\tEFFECT_CMD_SET_DEVICE re-enable LVM_VIRTUALIZER %d",
+                        ALOGV("\tEFFECT_CMD_SET_DEVICE re-enable LVM_VIRTUALIZER %d",
                               *(int32_t *)pCmdData);
                         android::LvmEffect_enable(pContext);
                     }
                     pContext->pBundledContext->bVirtualizerTempDisabled = LVM_FALSE;
                 }
             }
-            LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_SET_DEVICE end");
+            ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_SET_DEVICE end");
             break;
         }
         case EFFECT_CMD_SET_VOLUME:
@@ -3150,7 +3181,7 @@
 
             if (pCmdData == NULL ||
                 cmdSize != 2 * sizeof(uint32_t)) {
-                LOGV("\tLVM_ERROR : Effect_command cmdCode Case: "
+                ALOGV("\tLVM_ERROR : Effect_command cmdCode Case: "
                         "EFFECT_CMD_SET_VOLUME: ERROR");
                 return -EINVAL;
             }
@@ -3176,12 +3207,12 @@
             if(rightdB > maxdB){
                 maxdB = rightdB;
             }
-            //LOGV("\tEFFECT_CMD_SET_VOLUME Session: %d, SessionID: %d VOLUME is %d dB (%d), "
+            //ALOGV("\tEFFECT_CMD_SET_VOLUME Session: %d, SessionID: %d VOLUME is %d dB (%d), "
             //      "effect is %d",
             //pContext->pBundledContext->SessionNo, pContext->pBundledContext->SessionId,
             //(int32_t)maxdB, maxVol<<7, pContext->EffectType);
-            //LOGV("\tEFFECT_CMD_SET_VOLUME: Left is %d, Right is %d", leftVolume, rightVolume);
-            //LOGV("\tEFFECT_CMD_SET_VOLUME: Left %ddB, Right %ddB, Position %ddB",
+            //ALOGV("\tEFFECT_CMD_SET_VOLUME: Left is %d, Right is %d", leftVolume, rightVolume);
+            //ALOGV("\tEFFECT_CMD_SET_VOLUME: Left %ddB, Right %ddB, Position %ddB",
             //        leftdB, rightdB, pandB);
 
             memcpy(pReplyData, vol_ret, sizeof(int32_t)*2);
@@ -3194,7 +3225,7 @@
 
             /* Volume parameters */
             ActiveParams.VC_Balance  = pandB;
-            LOGV("\t\tVolumeSetStereoPosition() (-96dB -> +96dB)-> %d\n", ActiveParams.VC_Balance );
+            ALOGV("\t\tVolumeSetStereoPosition() (-96dB -> +96dB)-> %d\n", ActiveParams.VC_Balance );
 
             /* Activate the initial settings */
             LvmStatus =LVM_SetControlParameters(pContext->pBundledContext->hInstance,&ActiveParams);
@@ -3208,7 +3239,7 @@
             return -EINVAL;
     }
 
-    //LOGV("\tEffect_command end...\n\n");
+    //ALOGV("\tEffect_command end...\n\n");
     return 0;
 }    /* end Effect_command */
 
@@ -3220,7 +3251,7 @@
     const effect_descriptor_t *desc;
 
     if (pContext == NULL || pDescriptor == NULL) {
-        LOGV("Effect_getDescriptor() invalid param");
+        ALOGV("Effect_getDescriptor() invalid param");
         return -EINVAL;
     }
 
diff --git a/media/libeffects/lvm/wrapper/Reverb/EffectReverb.cpp b/media/libeffects/lvm/wrapper/Reverb/EffectReverb.cpp
index 663f8ff..09cd5cc 100755
--- a/media/libeffects/lvm/wrapper/Reverb/EffectReverb.cpp
+++ b/media/libeffects/lvm/wrapper/Reverb/EffectReverb.cpp
@@ -32,15 +32,15 @@
 
 #define LVM_ERROR_CHECK(LvmStatus, callingFunc, calledFunc){\
         if (LvmStatus == LVREV_NULLADDRESS){\
-            LOGV("\tLVREV_ERROR : Parameter error - "\
+            ALOGV("\tLVREV_ERROR : Parameter error - "\
                     "null pointer returned by %s in %s\n\n\n\n", callingFunc, calledFunc);\
         }\
         if (LvmStatus == LVREV_INVALIDNUMSAMPLES){\
-            LOGV("\tLVREV_ERROR : Parameter error - "\
+            ALOGV("\tLVREV_ERROR : Parameter error - "\
                     "bad number of samples returned by %s in %s\n\n\n\n", callingFunc, calledFunc);\
         }\
         if (LvmStatus == LVREV_OUTOFRANGE){\
-            LOGV("\tLVREV_ERROR : Parameter error - "\
+            ALOGV("\tLVREV_ERROR : Parameter error - "\
                     "out of range returned by %s in %s\n", callingFunc, calledFunc);\
         }\
     }
@@ -175,7 +175,8 @@
 //--- local function prototypes
 int  Reverb_init            (ReverbContext *pContext);
 void Reverb_free            (ReverbContext *pContext);
-int  Reverb_configure       (ReverbContext *pContext, effect_config_t *pConfig);
+int  Reverb_setConfig       (ReverbContext *pContext, effect_config_t *pConfig);
+void Reverb_getConfig       (ReverbContext *pContext, effect_config_t *pConfig);
 int  Reverb_setParameter    (ReverbContext *pContext, void *pParam, void *pValue);
 int  Reverb_getParameter    (ReverbContext *pContext,
                              void          *pParam,
@@ -185,27 +186,27 @@
 
 /* Effect Library Interface Implementation */
 extern "C" int EffectQueryNumberEffects(uint32_t *pNumEffects){
-    LOGV("\n\tEffectQueryNumberEffects start");
+    ALOGV("\n\tEffectQueryNumberEffects start");
     *pNumEffects = sizeof(gDescriptors) / sizeof(const effect_descriptor_t *);
-    LOGV("\tEffectQueryNumberEffects creating %d effects", *pNumEffects);
-    LOGV("\tEffectQueryNumberEffects end\n");
+    ALOGV("\tEffectQueryNumberEffects creating %d effects", *pNumEffects);
+    ALOGV("\tEffectQueryNumberEffects end\n");
     return 0;
 }     /* end EffectQueryNumberEffects */
 
 extern "C" int EffectQueryEffect(uint32_t index,
                                  effect_descriptor_t *pDescriptor){
-    LOGV("\n\tEffectQueryEffect start");
-    LOGV("\tEffectQueryEffect processing index %d", index);
+    ALOGV("\n\tEffectQueryEffect start");
+    ALOGV("\tEffectQueryEffect processing index %d", index);
     if (pDescriptor == NULL){
-        LOGV("\tLVM_ERROR : EffectQueryEffect was passed NULL pointer");
+        ALOGV("\tLVM_ERROR : EffectQueryEffect was passed NULL pointer");
         return -EINVAL;
     }
     if (index >= sizeof(gDescriptors) / sizeof(const effect_descriptor_t *)) {
-        LOGV("\tLVM_ERROR : EffectQueryEffect index out of range %d", index);
+        ALOGV("\tLVM_ERROR : EffectQueryEffect index out of range %d", index);
         return -ENOENT;
     }
     memcpy(pDescriptor, gDescriptors[index], sizeof(effect_descriptor_t));
-    LOGV("\tEffectQueryEffect end\n");
+    ALOGV("\tEffectQueryEffect end\n");
     return 0;
 }     /* end EffectQueryEffect */
 
@@ -218,10 +219,10 @@
     int length = sizeof(gDescriptors) / sizeof(const effect_descriptor_t *);
     const effect_descriptor_t *desc;
 
-    LOGV("\t\nEffectCreate start");
+    ALOGV("\t\nEffectCreate start");
 
     if (pHandle == NULL || uuid == NULL){
-        LOGV("\tLVM_ERROR : EffectCreate() called with NULL pointer");
+        ALOGV("\tLVM_ERROR : EffectCreate() called with NULL pointer");
         return -EINVAL;
     }
 
@@ -229,7 +230,7 @@
         desc = gDescriptors[i];
         if (memcmp(uuid, &desc->uuid, sizeof(effect_uuid_t))
                 == 0) {
-            LOGV("\tEffectCreate - UUID matched Reverb type %d, UUID = %x", i, desc->uuid.timeLow);
+            ALOGV("\tEffectCreate - UUID matched Reverb type %d, UUID = %x", i, desc->uuid.timeLow);
             break;
         }
     }
@@ -246,9 +247,9 @@
     pContext->auxiliary = false;
     if ((desc->flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_AUXILIARY){
         pContext->auxiliary = true;
-        LOGV("\tEffectCreate - AUX");
+        ALOGV("\tEffectCreate - AUX");
     }else{
-        LOGV("\tEffectCreate - INS");
+        ALOGV("\tEffectCreate - INS");
     }
 
     pContext->preset = false;
@@ -257,16 +258,16 @@
         // force reloading preset at first call to process()
         pContext->curPreset = REVERB_PRESET_LAST + 1;
         pContext->nextPreset = REVERB_DEFAULT_PRESET;
-        LOGV("\tEffectCreate - PRESET");
+        ALOGV("\tEffectCreate - PRESET");
     }else{
-        LOGV("\tEffectCreate - ENVIRONMENTAL");
+        ALOGV("\tEffectCreate - ENVIRONMENTAL");
     }
 
-    LOGV("\tEffectCreate - Calling Reverb_init");
+    ALOGV("\tEffectCreate - Calling Reverb_init");
     ret = Reverb_init(pContext);
 
     if (ret < 0){
-        LOGV("\tLVM_ERROR : EffectCreate() init failed");
+        ALOGV("\tLVM_ERROR : EffectCreate() init failed");
         delete pContext;
         return ret;
     }
@@ -291,17 +292,17 @@
     pContext->InFrames32  = (LVM_INT32 *)malloc(LVREV_MAX_FRAME_SIZE * sizeof(LVM_INT32) * 2);
     pContext->OutFrames32 = (LVM_INT32 *)malloc(LVREV_MAX_FRAME_SIZE * sizeof(LVM_INT32) * 2);
 
-    LOGV("\tEffectCreate %p, size %d", pContext, sizeof(ReverbContext));
-    LOGV("\tEffectCreate end\n");
+    ALOGV("\tEffectCreate %p, size %d", pContext, sizeof(ReverbContext));
+    ALOGV("\tEffectCreate end\n");
     return 0;
 } /* end EffectCreate */
 
 extern "C" int EffectRelease(effect_handle_t handle){
     ReverbContext * pContext = (ReverbContext *)handle;
 
-    LOGV("\tEffectRelease %p", handle);
+    ALOGV("\tEffectRelease %p", handle);
     if (pContext == NULL){
-        LOGV("\tLVM_ERROR : EffectRelease called with NULL pointer");
+        ALOGV("\tLVM_ERROR : EffectRelease called with NULL pointer");
         return -EINVAL;
     }
 
@@ -322,14 +323,14 @@
     int length = sizeof(gDescriptors) / sizeof(const effect_descriptor_t *);
 
     if (pDescriptor == NULL || uuid == NULL){
-        LOGV("EffectGetDescriptor() called with NULL pointer");
+        ALOGV("EffectGetDescriptor() called with NULL pointer");
         return -EINVAL;
     }
 
     for (i = 0; i < length; i++) {
         if (memcmp(uuid, &gDescriptors[i]->uuid, sizeof(effect_uuid_t)) == 0) {
             memcpy(pDescriptor, gDescriptors[i], sizeof(effect_descriptor_t));
-            LOGV("EffectGetDescriptor - UUID matched Reverb type %d, UUID = %x",
+            ALOGV("EffectGetDescriptor - UUID matched Reverb type %d, UUID = %x",
                  i, gDescriptors[i]->uuid.timeLow);
             return 0;
         }
@@ -341,7 +342,7 @@
 /* local functions */
 #define CHECK_ARG(cond) {                     \
     if (!(cond)) {                            \
-        LOGV("\tLVM_ERROR : Invalid argument: "#cond);      \
+        ALOGV("\tLVM_ERROR : Invalid argument: "#cond);      \
         return -EINVAL;                       \
     }                                         \
 }
@@ -444,7 +445,7 @@
     if (pContext->config.inputCfg.channels == AUDIO_CHANNEL_OUT_STEREO) {
         samplesPerFrame = 2;
     } else if (pContext->config.inputCfg.channels != AUDIO_CHANNEL_OUT_MONO) {
-        LOGV("\tLVREV_ERROR : process invalid PCM format");
+        ALOGV("\tLVREV_ERROR : process invalid PCM format");
         return -EINVAL;
     }
 
@@ -452,7 +453,7 @@
 
     // Check for NULL pointers
     if((pContext->InFrames32 == NULL)||(pContext->OutFrames32 == NULL)){
-        LOGV("\tLVREV_ERROR : process failed to allocate memory for temporary buffers ");
+        ALOGV("\tLVREV_ERROR : process failed to allocate memory for temporary buffers ");
         return -EINVAL;
     }
 
@@ -485,7 +486,7 @@
     } else {
         if(pContext->bEnabled == LVM_FALSE && pContext->SamplesToExitCount > 0) {
             memset(pContext->InFrames32,0,frameCount * sizeof(LVM_INT32) * samplesPerFrame);
-            LOGV("\tZeroing %d samples per frame at the end of call", samplesPerFrame);
+            ALOGV("\tZeroing %d samples per frame at the end of call", samplesPerFrame);
         }
 
         /* Process the samples, producing a stereo output */
@@ -552,12 +553,12 @@
 
     // Accumulate if required
     if (pContext->config.outputCfg.accessMode == EFFECT_BUFFER_ACCESS_ACCUMULATE){
-        //LOGV("\tBuffer access is ACCUMULATE");
+        //ALOGV("\tBuffer access is ACCUMULATE");
         for (int i=0; i<frameCount*2; i++){ //always stereo here
             pOut[i] = clamp16((int32_t)pOut[i] + (int32_t)OutFrames16[i]);
         }
     }else{
-        //LOGV("\tBuffer access is WRITE");
+        //ALOGV("\tBuffer access is WRITE");
         memcpy(pOut, OutFrames16, frameCount*sizeof(LVM_INT16)*2);
     }
 
@@ -592,15 +593,15 @@
     for (int i=0; i<LVM_NR_MEMORY_REGIONS; i++){
         if (MemTab.Region[i].Size != 0){
             if (MemTab.Region[i].pBaseAddress != NULL){
-                LOGV("\tfree() - START freeing %ld bytes for region %u at %p\n",
+                ALOGV("\tfree() - START freeing %ld bytes for region %u at %p\n",
                         MemTab.Region[i].Size, i, MemTab.Region[i].pBaseAddress);
 
                 free(MemTab.Region[i].pBaseAddress);
 
-                LOGV("\tfree() - END   freeing %ld bytes for region %u at %p\n",
+                ALOGV("\tfree() - END   freeing %ld bytes for region %u at %p\n",
                         MemTab.Region[i].Size, i, MemTab.Region[i].pBaseAddress);
             }else{
-                LOGV("\tLVM_ERROR : free() - trying to free with NULL pointer %ld bytes "
+                ALOGV("\tLVM_ERROR : free() - trying to free with NULL pointer %ld bytes "
                         "for region %u at %p ERROR\n",
                         MemTab.Region[i].Size, i, MemTab.Region[i].pBaseAddress);
             }
@@ -609,7 +610,7 @@
 }    /* end Reverb_free */
 
 //----------------------------------------------------------------------------
-// Reverb_configure()
+// Reverb_setConfig()
 //----------------------------------------------------------------------------
 // Purpose: Set input and output audio configuration.
 //
@@ -622,9 +623,9 @@
 //
 //----------------------------------------------------------------------------
 
-int Reverb_configure(ReverbContext *pContext, effect_config_t *pConfig){
+int Reverb_setConfig(ReverbContext *pContext, effect_config_t *pConfig){
     LVM_Fs_en   SampleRate;
-    //LOGV("\tReverb_configure start");
+    //ALOGV("\tReverb_setConfig start");
 
     CHECK_ARG(pContext != NULL);
     CHECK_ARG(pConfig != NULL);
@@ -642,7 +643,7 @@
         return -EINVAL;
     }
 
-    //LOGV("\tReverb_configure calling memcpy");
+    //ALOGV("\tReverb_setConfig calling memcpy");
     memcpy(&pContext->config, pConfig, sizeof(effect_config_t));
 
 
@@ -666,7 +667,7 @@
         SampleRate = LVM_FS_48000;
         break;
     default:
-        LOGV("\rReverb_Configure invalid sampling rate %d", pConfig->inputCfg.samplingRate);
+        ALOGV("\rReverb_setConfig invalid sampling rate %d", pConfig->inputCfg.samplingRate);
         return -EINVAL;
     }
 
@@ -675,28 +676,46 @@
         LVREV_ControlParams_st    ActiveParams;
         LVREV_ReturnStatus_en     LvmStatus = LVREV_SUCCESS;
 
-        //LOGV("\tReverb_configure change sampling rate to %d", SampleRate);
+        //ALOGV("\tReverb_setConfig change sampling rate to %d", SampleRate);
 
         /* Get the current settings */
         LvmStatus = LVREV_GetControlParameters(pContext->hInstance,
                                          &ActiveParams);
 
-        LVM_ERROR_CHECK(LvmStatus, "LVREV_GetControlParameters", "Reverb_configure")
+        LVM_ERROR_CHECK(LvmStatus, "LVREV_GetControlParameters", "Reverb_setConfig")
         if(LvmStatus != LVREV_SUCCESS) return -EINVAL;
 
         LvmStatus = LVREV_SetControlParameters(pContext->hInstance, &ActiveParams);
 
-        LVM_ERROR_CHECK(LvmStatus, "LVREV_SetControlParameters", "Reverb_configure")
-        //LOGV("\tReverb_configure Succesfully called LVREV_SetControlParameters\n");
+        LVM_ERROR_CHECK(LvmStatus, "LVREV_SetControlParameters", "Reverb_setConfig")
+        //ALOGV("\tReverb_setConfig Succesfully called LVREV_SetControlParameters\n");
 
     }else{
-        //LOGV("\tReverb_configure keep sampling rate at %d", SampleRate);
+        //ALOGV("\tReverb_setConfig keep sampling rate at %d", SampleRate);
     }
 
-    //LOGV("\tReverb_configure End");
+    //ALOGV("\tReverb_setConfig End");
     return 0;
-}   /* end Reverb_configure */
+}   /* end Reverb_setConfig */
 
+//----------------------------------------------------------------------------
+// Reverb_getConfig()
+//----------------------------------------------------------------------------
+// Purpose: Get input and output audio configuration.
+//
+// Inputs:
+//  pContext:   effect engine context
+//  pConfig:    pointer to effect_config_t structure holding input and output
+//      configuration parameters
+//
+// Outputs:
+//
+//----------------------------------------------------------------------------
+
+void Reverb_getConfig(ReverbContext *pContext, effect_config_t *pConfig)
+{
+    memcpy(pConfig, &pContext->config, sizeof(effect_config_t));
+}   /* end Reverb_getConfig */
 
 //----------------------------------------------------------------------------
 // Reverb_init()
@@ -713,7 +732,7 @@
 int Reverb_init(ReverbContext *pContext){
     int status;
 
-    LOGV("\tReverb_init start");
+    ALOGV("\tReverb_init start");
 
     CHECK_ARG(pContext != NULL);
 
@@ -768,7 +787,7 @@
     LVM_ERROR_CHECK(LvmStatus, "LVREV_GetMemoryTable", "Reverb_init")
     if(LvmStatus != LVREV_SUCCESS) return -EINVAL;
 
-    LOGV("\tCreateInstance Succesfully called LVM_GetMemoryTable\n");
+    ALOGV("\tCreateInstance Succesfully called LVM_GetMemoryTable\n");
 
     /* Allocate memory */
     for (int i=0; i<LVM_NR_MEMORY_REGIONS; i++){
@@ -776,11 +795,11 @@
             MemTab.Region[i].pBaseAddress = malloc(MemTab.Region[i].Size);
 
             if (MemTab.Region[i].pBaseAddress == LVM_NULL){
-                LOGV("\tLVREV_ERROR :Reverb_init CreateInstance Failed to allocate %ld "
+                ALOGV("\tLVREV_ERROR :Reverb_init CreateInstance Failed to allocate %ld "
                         "bytes for region %u\n", MemTab.Region[i].Size, i );
                 bMallocFailure = LVM_TRUE;
             }else{
-                LOGV("\tReverb_init CreateInstance allocate %ld bytes for region %u at %p\n",
+                ALOGV("\tReverb_init CreateInstance allocate %ld bytes for region %u at %p\n",
                         MemTab.Region[i].Size, i, MemTab.Region[i].pBaseAddress);
             }
         }
@@ -792,10 +811,10 @@
     if(bMallocFailure == LVM_TRUE){
         for (int i=0; i<LVM_NR_MEMORY_REGIONS; i++){
             if (MemTab.Region[i].pBaseAddress == LVM_NULL){
-                LOGV("\tLVM_ERROR :Reverb_init CreateInstance Failed to allocate %ld bytes "
+                ALOGV("\tLVM_ERROR :Reverb_init CreateInstance Failed to allocate %ld bytes "
                         "for region %u - Not freeing\n", MemTab.Region[i].Size, i );
             }else{
-                LOGV("\tLVM_ERROR :Reverb_init CreateInstance Failed: but allocated %ld bytes "
+                ALOGV("\tLVM_ERROR :Reverb_init CreateInstance Failed: but allocated %ld bytes "
                         "for region %u at %p- free\n",
                         MemTab.Region[i].Size, i, MemTab.Region[i].pBaseAddress);
                 free(MemTab.Region[i].pBaseAddress);
@@ -803,7 +822,7 @@
         }
         return -EINVAL;
     }
-    LOGV("\tReverb_init CreateInstance Succesfully malloc'd memory\n");
+    ALOGV("\tReverb_init CreateInstance Succesfully malloc'd memory\n");
 
     /* Initialise */
     pContext->hInstance = LVM_NULL;
@@ -816,7 +835,7 @@
     LVM_ERROR_CHECK(LvmStatus, "LVM_GetInstanceHandle", "Reverb_init")
     if(LvmStatus != LVREV_SUCCESS) return -EINVAL;
 
-    LOGV("\tReverb_init CreateInstance Succesfully called LVM_GetInstanceHandle\n");
+    ALOGV("\tReverb_init CreateInstance Succesfully called LVM_GetInstanceHandle\n");
 
     /* Set the initial process parameters */
     /* General parameters */
@@ -860,8 +879,8 @@
     LVM_ERROR_CHECK(LvmStatus, "LVREV_SetControlParameters", "Reverb_init")
     if(LvmStatus != LVREV_SUCCESS) return -EINVAL;
 
-    LOGV("\tReverb_init CreateInstance Succesfully called LVREV_SetControlParameters\n");
-    LOGV("\tReverb_init End");
+    ALOGV("\tReverb_init CreateInstance Succesfully called LVREV_SetControlParameters\n");
+    ALOGV("\tReverb_init End");
     return 0;
 }   /* end Reverb_init */
 
@@ -960,7 +979,7 @@
 //----------------------------------------------------------------------------
 
 void ReverbSetRoomHfLevel(ReverbContext *pContext, int16_t level){
-    //LOGV("\tReverbSetRoomHfLevel start (%d)", level);
+    //ALOGV("\tReverbSetRoomHfLevel start (%d)", level);
 
     LVREV_ControlParams_st    ActiveParams;              /* Current control Parameters */
     LVREV_ReturnStatus_en     LvmStatus=LVREV_SUCCESS;     /* Function call status */
@@ -968,17 +987,17 @@
     /* Get the current settings */
     LvmStatus = LVREV_GetControlParameters(pContext->hInstance, &ActiveParams);
     LVM_ERROR_CHECK(LvmStatus, "LVREV_GetControlParameters", "ReverbSetRoomHfLevel")
-    //LOGV("\tReverbSetRoomHfLevel Succesfully returned from LVM_GetControlParameters\n");
-    //LOGV("\tReverbSetRoomHfLevel() just Got -> %d\n", ActiveParams.LPF);
+    //ALOGV("\tReverbSetRoomHfLevel Succesfully returned from LVM_GetControlParameters\n");
+    //ALOGV("\tReverbSetRoomHfLevel() just Got -> %d\n", ActiveParams.LPF);
 
     ActiveParams.LPF = ReverbConvertHfLevel(level);
 
     /* Activate the initial settings */
     LvmStatus = LVREV_SetControlParameters(pContext->hInstance, &ActiveParams);
     LVM_ERROR_CHECK(LvmStatus, "LVREV_SetControlParameters", "ReverbSetRoomHfLevel")
-    //LOGV("\tReverbSetRoomhfLevel() just Set -> %d\n", ActiveParams.LPF);
+    //ALOGV("\tReverbSetRoomhfLevel() just Set -> %d\n", ActiveParams.LPF);
     pContext->SavedHfLevel = level;
-    //LOGV("\tReverbSetHfRoomLevel end.. saving %d", pContext->SavedHfLevel);
+    //ALOGV("\tReverbSetHfRoomLevel end.. saving %d", pContext->SavedHfLevel);
     return;
 }
 
@@ -995,7 +1014,7 @@
 
 int16_t ReverbGetRoomHfLevel(ReverbContext *pContext){
     int16_t level;
-    //LOGV("\tReverbGetRoomHfLevel start, saved level is %d", pContext->SavedHfLevel);
+    //ALOGV("\tReverbGetRoomHfLevel start, saved level is %d", pContext->SavedHfLevel);
 
     LVREV_ControlParams_st    ActiveParams;              /* Current control Parameters */
     LVREV_ReturnStatus_en     LvmStatus=LVREV_SUCCESS;     /* Function call status */
@@ -1003,20 +1022,20 @@
     /* Get the current settings */
     LvmStatus = LVREV_GetControlParameters(pContext->hInstance, &ActiveParams);
     LVM_ERROR_CHECK(LvmStatus, "LVREV_GetControlParameters", "ReverbGetRoomHfLevel")
-    //LOGV("\tReverbGetRoomHfLevel Succesfully returned from LVM_GetControlParameters\n");
-    //LOGV("\tReverbGetRoomHfLevel() just Got -> %d\n", ActiveParams.LPF);
+    //ALOGV("\tReverbGetRoomHfLevel Succesfully returned from LVM_GetControlParameters\n");
+    //ALOGV("\tReverbGetRoomHfLevel() just Got -> %d\n", ActiveParams.LPF);
 
     level = ReverbConvertHfLevel(pContext->SavedHfLevel);
 
-    //LOGV("\tReverbGetRoomHfLevel() ActiveParams.LPFL %d, pContext->SavedHfLevel: %d, "
+    //ALOGV("\tReverbGetRoomHfLevel() ActiveParams.LPFL %d, pContext->SavedHfLevel: %d, "
     //     "converted level: %d\n", ActiveParams.LPF, pContext->SavedHfLevel, level);
 
     if(ActiveParams.LPF != level){
-        LOGV("\tLVM_ERROR : (ignore at start up) ReverbGetRoomHfLevel() has wrong level -> %d %d\n",
+        ALOGV("\tLVM_ERROR : (ignore at start up) ReverbGetRoomHfLevel() has wrong level -> %d %d\n",
                ActiveParams.Level, level);
     }
 
-    //LOGV("\tReverbGetRoomHfLevel end");
+    //ALOGV("\tReverbGetRoomHfLevel end");
     return pContext->SavedHfLevel;
 }
 
@@ -1033,7 +1052,7 @@
 //----------------------------------------------------------------------------
 
 void ReverbSetReverbLevel(ReverbContext *pContext, int16_t level){
-    //LOGV("\n\tReverbSetReverbLevel start (%d)", level);
+    //ALOGV("\n\tReverbSetReverbLevel start (%d)", level);
 
     LVREV_ControlParams_st    ActiveParams;              /* Current control Parameters */
     LVREV_ReturnStatus_en     LvmStatus=LVREV_SUCCESS;     /* Function call status */
@@ -1042,25 +1061,25 @@
     /* Get the current settings */
     LvmStatus = LVREV_GetControlParameters(pContext->hInstance, &ActiveParams);
     LVM_ERROR_CHECK(LvmStatus, "LVREV_GetControlParameters", "ReverbSetReverbLevel")
-    //LOGV("\tReverbSetReverbLevel Succesfully returned from LVM_GetControlParameters\n");
-    //LOGV("\tReverbSetReverbLevel just Got -> %d\n", ActiveParams.Level);
+    //ALOGV("\tReverbSetReverbLevel Succesfully returned from LVM_GetControlParameters\n");
+    //ALOGV("\tReverbSetReverbLevel just Got -> %d\n", ActiveParams.Level);
 
     // needs to subtract max levels for both RoomLevel and ReverbLevel
     CombinedLevel = (level + pContext->SavedRoomLevel)-LVREV_MAX_REVERB_LEVEL;
-    //LOGV("\tReverbSetReverbLevel() CombinedLevel is %d = %d + %d\n",
+    //ALOGV("\tReverbSetReverbLevel() CombinedLevel is %d = %d + %d\n",
     //      CombinedLevel, level, pContext->SavedRoomLevel);
 
     ActiveParams.Level = ReverbConvertLevel(CombinedLevel);
 
-    //LOGV("\tReverbSetReverbLevel() Trying to set -> %d\n", ActiveParams.Level);
+    //ALOGV("\tReverbSetReverbLevel() Trying to set -> %d\n", ActiveParams.Level);
 
     /* Activate the initial settings */
     LvmStatus = LVREV_SetControlParameters(pContext->hInstance, &ActiveParams);
     LVM_ERROR_CHECK(LvmStatus, "LVREV_SetControlParameters", "ReverbSetReverbLevel")
-    //LOGV("\tReverbSetReverbLevel() just Set -> %d\n", ActiveParams.Level);
+    //ALOGV("\tReverbSetReverbLevel() just Set -> %d\n", ActiveParams.Level);
 
     pContext->SavedReverbLevel = level;
-    //LOGV("\tReverbSetReverbLevel end pContext->SavedReverbLevel is %d\n\n",
+    //ALOGV("\tReverbSetReverbLevel end pContext->SavedReverbLevel is %d\n\n",
     //     pContext->SavedReverbLevel);
     return;
 }
@@ -1078,7 +1097,7 @@
 
 int16_t ReverbGetReverbLevel(ReverbContext *pContext){
     int16_t level;
-    //LOGV("\tReverbGetReverbLevel start");
+    //ALOGV("\tReverbGetReverbLevel start");
 
     LVREV_ControlParams_st    ActiveParams;              /* Current control Parameters */
     LVREV_ReturnStatus_en     LvmStatus=LVREV_SUCCESS;     /* Function call status */
@@ -1087,26 +1106,26 @@
     /* Get the current settings */
     LvmStatus = LVREV_GetControlParameters(pContext->hInstance, &ActiveParams);
     LVM_ERROR_CHECK(LvmStatus, "LVREV_GetControlParameters", "ReverbGetReverbLevel")
-    //LOGV("\tReverbGetReverbLevel Succesfully returned from LVM_GetControlParameters\n");
-    //LOGV("\tReverbGetReverbLevel() just Got -> %d\n", ActiveParams.Level);
+    //ALOGV("\tReverbGetReverbLevel Succesfully returned from LVM_GetControlParameters\n");
+    //ALOGV("\tReverbGetReverbLevel() just Got -> %d\n", ActiveParams.Level);
 
     // needs to subtract max levels for both RoomLevel and ReverbLevel
     CombinedLevel = (pContext->SavedReverbLevel + pContext->SavedRoomLevel)-LVREV_MAX_REVERB_LEVEL;
 
-    //LOGV("\tReverbGetReverbLevel() CombinedLevel is %d = %d + %d\n",
+    //ALOGV("\tReverbGetReverbLevel() CombinedLevel is %d = %d + %d\n",
     //CombinedLevel, pContext->SavedReverbLevel, pContext->SavedRoomLevel);
     level = ReverbConvertLevel(CombinedLevel);
 
-    //LOGV("\tReverbGetReverbLevel(): ActiveParams.Level: %d, pContext->SavedReverbLevel: %d, "
+    //ALOGV("\tReverbGetReverbLevel(): ActiveParams.Level: %d, pContext->SavedReverbLevel: %d, "
     //"pContext->SavedRoomLevel: %d, CombinedLevel: %d, converted level: %d\n",
     //ActiveParams.Level, pContext->SavedReverbLevel,pContext->SavedRoomLevel, CombinedLevel,level);
 
     if(ActiveParams.Level != level){
-        LOGV("\tLVM_ERROR : (ignore at start up) ReverbGetReverbLevel() has wrong level -> %d %d\n",
+        ALOGV("\tLVM_ERROR : (ignore at start up) ReverbGetReverbLevel() has wrong level -> %d %d\n",
                 ActiveParams.Level, level);
     }
 
-    //LOGV("\tReverbGetReverbLevel end\n");
+    //ALOGV("\tReverbGetReverbLevel end\n");
 
     return pContext->SavedReverbLevel;
 }
@@ -1124,7 +1143,7 @@
 //----------------------------------------------------------------------------
 
 void ReverbSetRoomLevel(ReverbContext *pContext, int16_t level){
-    //LOGV("\tReverbSetRoomLevel start (%d)", level);
+    //ALOGV("\tReverbSetRoomLevel start (%d)", level);
 
     LVREV_ControlParams_st    ActiveParams;              /* Current control Parameters */
     LVREV_ReturnStatus_en     LvmStatus=LVREV_SUCCESS;     /* Function call status */
@@ -1133,8 +1152,8 @@
     /* Get the current settings */
     LvmStatus = LVREV_GetControlParameters(pContext->hInstance, &ActiveParams);
     LVM_ERROR_CHECK(LvmStatus, "LVREV_GetControlParameters", "ReverbSetRoomLevel")
-    //LOGV("\tReverbSetRoomLevel Succesfully returned from LVM_GetControlParameters\n");
-    //LOGV("\tReverbSetRoomLevel() just Got -> %d\n", ActiveParams.Level);
+    //ALOGV("\tReverbSetRoomLevel Succesfully returned from LVM_GetControlParameters\n");
+    //ALOGV("\tReverbSetRoomLevel() just Got -> %d\n", ActiveParams.Level);
 
     // needs to subtract max levels for both RoomLevel and ReverbLevel
     CombinedLevel = (level + pContext->SavedReverbLevel)-LVREV_MAX_REVERB_LEVEL;
@@ -1143,10 +1162,10 @@
     /* Activate the initial settings */
     LvmStatus = LVREV_SetControlParameters(pContext->hInstance, &ActiveParams);
     LVM_ERROR_CHECK(LvmStatus, "LVREV_SetControlParameters", "ReverbSetRoomLevel")
-    //LOGV("\tReverbSetRoomLevel() just Set -> %d\n", ActiveParams.Level);
+    //ALOGV("\tReverbSetRoomLevel() just Set -> %d\n", ActiveParams.Level);
 
     pContext->SavedRoomLevel = level;
-    //LOGV("\tReverbSetRoomLevel end");
+    //ALOGV("\tReverbSetRoomLevel end");
     return;
 }
 
@@ -1163,7 +1182,7 @@
 
 int16_t ReverbGetRoomLevel(ReverbContext *pContext){
     int16_t level;
-    //LOGV("\tReverbGetRoomLevel start");
+    //ALOGV("\tReverbGetRoomLevel start");
 
     LVREV_ControlParams_st    ActiveParams;              /* Current control Parameters */
     LVREV_ReturnStatus_en     LvmStatus=LVREV_SUCCESS;     /* Function call status */
@@ -1172,24 +1191,24 @@
     /* Get the current settings */
     LvmStatus = LVREV_GetControlParameters(pContext->hInstance, &ActiveParams);
     LVM_ERROR_CHECK(LvmStatus, "LVREV_GetControlParameters", "ReverbGetRoomLevel")
-    //LOGV("\tReverbGetRoomLevel Succesfully returned from LVM_GetControlParameters\n");
-    //LOGV("\tReverbGetRoomLevel() just Got -> %d\n", ActiveParams.Level);
+    //ALOGV("\tReverbGetRoomLevel Succesfully returned from LVM_GetControlParameters\n");
+    //ALOGV("\tReverbGetRoomLevel() just Got -> %d\n", ActiveParams.Level);
 
     // needs to subtract max levels for both RoomLevel and ReverbLevel
     CombinedLevel = (pContext->SavedRoomLevel + pContext->SavedReverbLevel-LVREV_MAX_REVERB_LEVEL);
     level = ReverbConvertLevel(CombinedLevel);
 
-    //LOGV("\tReverbGetRoomLevel, Level = %d, pContext->SavedRoomLevel = %d, "
+    //ALOGV("\tReverbGetRoomLevel, Level = %d, pContext->SavedRoomLevel = %d, "
     //     "pContext->SavedReverbLevel = %d, CombinedLevel = %d, level = %d",
     //     ActiveParams.Level, pContext->SavedRoomLevel,
     //     pContext->SavedReverbLevel, CombinedLevel, level);
 
     if(ActiveParams.Level != level){
-        LOGV("\tLVM_ERROR : (ignore at start up) ReverbGetRoomLevel() has wrong level -> %d %d\n",
+        ALOGV("\tLVM_ERROR : (ignore at start up) ReverbGetRoomLevel() has wrong level -> %d %d\n",
               ActiveParams.Level, level);
     }
 
-    //LOGV("\tReverbGetRoomLevel end");
+    //ALOGV("\tReverbGetRoomLevel end");
     return pContext->SavedRoomLevel;
 }
 
@@ -1206,7 +1225,7 @@
 //----------------------------------------------------------------------------
 
 void ReverbSetDecayTime(ReverbContext *pContext, uint32_t time){
-    //LOGV("\tReverbSetDecayTime start (%d)", time);
+    //ALOGV("\tReverbSetDecayTime start (%d)", time);
 
     LVREV_ControlParams_st    ActiveParams;              /* Current control Parameters */
     LVREV_ReturnStatus_en     LvmStatus=LVREV_SUCCESS;     /* Function call status */
@@ -1214,8 +1233,8 @@
     /* Get the current settings */
     LvmStatus = LVREV_GetControlParameters(pContext->hInstance, &ActiveParams);
     LVM_ERROR_CHECK(LvmStatus, "LVREV_GetControlParameters", "ReverbSetDecayTime")
-    //LOGV("\tReverbSetDecayTime Succesfully returned from LVM_GetControlParameters\n");
-    //LOGV("\tReverbSetDecayTime() just Got -> %d\n", ActiveParams.T60);
+    //ALOGV("\tReverbSetDecayTime Succesfully returned from LVM_GetControlParameters\n");
+    //ALOGV("\tReverbSetDecayTime() just Got -> %d\n", ActiveParams.T60);
 
     if (time <= LVREV_MAX_T60) {
         ActiveParams.T60 = (LVM_UINT16)time;
@@ -1227,12 +1246,12 @@
     /* Activate the initial settings */
     LvmStatus = LVREV_SetControlParameters(pContext->hInstance, &ActiveParams);
     LVM_ERROR_CHECK(LvmStatus, "LVREV_SetControlParameters", "ReverbSetDecayTime")
-    //LOGV("\tReverbSetDecayTime() just Set -> %d\n", ActiveParams.T60);
+    //ALOGV("\tReverbSetDecayTime() just Set -> %d\n", ActiveParams.T60);
 
     pContext->SamplesToExitCount = (ActiveParams.T60 * pContext->config.inputCfg.samplingRate)/1000;
-    //LOGV("\tReverbSetDecayTime() just Set SamplesToExitCount-> %d\n",pContext->SamplesToExitCount);
+    //ALOGV("\tReverbSetDecayTime() just Set SamplesToExitCount-> %d\n",pContext->SamplesToExitCount);
     pContext->SavedDecayTime = (int16_t)time;
-    //LOGV("\tReverbSetDecayTime end");
+    //ALOGV("\tReverbSetDecayTime end");
     return;
 }
 
@@ -1248,7 +1267,7 @@
 //----------------------------------------------------------------------------
 
 uint32_t ReverbGetDecayTime(ReverbContext *pContext){
-    //LOGV("\tReverbGetDecayTime start");
+    //ALOGV("\tReverbGetDecayTime start");
 
     LVREV_ControlParams_st    ActiveParams;              /* Current control Parameters */
     LVREV_ReturnStatus_en     LvmStatus=LVREV_SUCCESS;     /* Function call status */
@@ -1256,16 +1275,16 @@
     /* Get the current settings */
     LvmStatus = LVREV_GetControlParameters(pContext->hInstance, &ActiveParams);
     LVM_ERROR_CHECK(LvmStatus, "LVREV_GetControlParameters", "ReverbGetDecayTime")
-    //LOGV("\tReverbGetDecayTime Succesfully returned from LVM_GetControlParameters\n");
-    //LOGV("\tReverbGetDecayTime() just Got -> %d\n", ActiveParams.T60);
+    //ALOGV("\tReverbGetDecayTime Succesfully returned from LVM_GetControlParameters\n");
+    //ALOGV("\tReverbGetDecayTime() just Got -> %d\n", ActiveParams.T60);
 
     if(ActiveParams.T60 != pContext->SavedDecayTime){
         // This will fail if the decay time is set to more than 7000
-        LOGV("\tLVM_ERROR : ReverbGetDecayTime() has wrong level -> %d %d\n",
+        ALOGV("\tLVM_ERROR : ReverbGetDecayTime() has wrong level -> %d %d\n",
          ActiveParams.T60, pContext->SavedDecayTime);
     }
 
-    //LOGV("\tReverbGetDecayTime end");
+    //ALOGV("\tReverbGetDecayTime end");
     return (uint32_t)ActiveParams.T60;
 }
 
@@ -1282,7 +1301,7 @@
 //----------------------------------------------------------------------------
 
 void ReverbSetDecayHfRatio(ReverbContext *pContext, int16_t ratio){
-    //LOGV("\tReverbSetDecayHfRatioe start (%d)", ratio);
+    //ALOGV("\tReverbSetDecayHfRatioe start (%d)", ratio);
 
     LVREV_ControlParams_st    ActiveParams;              /* Current control Parameters */
     LVREV_ReturnStatus_en     LvmStatus=LVREV_SUCCESS;   /* Function call status */
@@ -1290,18 +1309,18 @@
     /* Get the current settings */
     LvmStatus = LVREV_GetControlParameters(pContext->hInstance, &ActiveParams);
     LVM_ERROR_CHECK(LvmStatus, "LVREV_GetControlParameters", "ReverbSetDecayHfRatio")
-    //LOGV("\tReverbSetDecayHfRatio Succesfully returned from LVM_GetControlParameters\n");
-    //LOGV("\tReverbSetDecayHfRatio() just Got -> %d\n", ActiveParams.Damping);
+    //ALOGV("\tReverbSetDecayHfRatio Succesfully returned from LVM_GetControlParameters\n");
+    //ALOGV("\tReverbSetDecayHfRatio() just Got -> %d\n", ActiveParams.Damping);
 
     ActiveParams.Damping = (LVM_INT16)(ratio/20);
 
     /* Activate the initial settings */
     LvmStatus = LVREV_SetControlParameters(pContext->hInstance, &ActiveParams);
     LVM_ERROR_CHECK(LvmStatus, "LVREV_SetControlParameters", "ReverbSetDecayHfRatio")
-    //LOGV("\tReverbSetDecayHfRatio() just Set -> %d\n", ActiveParams.Damping);
+    //ALOGV("\tReverbSetDecayHfRatio() just Set -> %d\n", ActiveParams.Damping);
 
     pContext->SavedDecayHfRatio = ratio;
-    //LOGV("\tReverbSetDecayHfRatio end");
+    //ALOGV("\tReverbSetDecayHfRatio end");
     return;
 }
 
@@ -1317,7 +1336,7 @@
 //----------------------------------------------------------------------------
 
 int32_t ReverbGetDecayHfRatio(ReverbContext *pContext){
-    //LOGV("\tReverbGetDecayHfRatio start");
+    //ALOGV("\tReverbGetDecayHfRatio start");
 
     LVREV_ControlParams_st    ActiveParams;              /* Current control Parameters */
     LVREV_ReturnStatus_en     LvmStatus=LVREV_SUCCESS;   /* Function call status */
@@ -1325,15 +1344,15 @@
     /* Get the current settings */
     LvmStatus = LVREV_GetControlParameters(pContext->hInstance, &ActiveParams);
     LVM_ERROR_CHECK(LvmStatus, "LVREV_GetControlParameters", "ReverbGetDecayHfRatio")
-    //LOGV("\tReverbGetDecayHfRatio Succesfully returned from LVM_GetControlParameters\n");
-    //LOGV("\tReverbGetDecayHfRatio() just Got -> %d\n", ActiveParams.Damping);
+    //ALOGV("\tReverbGetDecayHfRatio Succesfully returned from LVM_GetControlParameters\n");
+    //ALOGV("\tReverbGetDecayHfRatio() just Got -> %d\n", ActiveParams.Damping);
 
     if(ActiveParams.Damping != (LVM_INT16)(pContext->SavedDecayHfRatio / 20)){
-        LOGV("\tLVM_ERROR : ReverbGetDecayHfRatio() has wrong level -> %d %d\n",
+        ALOGV("\tLVM_ERROR : ReverbGetDecayHfRatio() has wrong level -> %d %d\n",
          ActiveParams.Damping, pContext->SavedDecayHfRatio);
     }
 
-    //LOGV("\tReverbGetDecayHfRatio end");
+    //ALOGV("\tReverbGetDecayHfRatio end");
     return pContext->SavedDecayHfRatio;
 }
 
@@ -1350,7 +1369,7 @@
 //----------------------------------------------------------------------------
 
 void ReverbSetDiffusion(ReverbContext *pContext, int16_t level){
-    //LOGV("\tReverbSetDiffusion start (%d)", level);
+    //ALOGV("\tReverbSetDiffusion start (%d)", level);
 
     LVREV_ControlParams_st    ActiveParams;              /* Current control Parameters */
     LVREV_ReturnStatus_en     LvmStatus=LVREV_SUCCESS;     /* Function call status */
@@ -1358,18 +1377,18 @@
     /* Get the current settings */
     LvmStatus = LVREV_GetControlParameters(pContext->hInstance, &ActiveParams);
     LVM_ERROR_CHECK(LvmStatus, "LVREV_GetControlParameters", "ReverbSetDiffusion")
-    //LOGV("\tReverbSetDiffusion Succesfully returned from LVM_GetControlParameters\n");
-    //LOGV("\tReverbSetDiffusion() just Got -> %d\n", ActiveParams.Density);
+    //ALOGV("\tReverbSetDiffusion Succesfully returned from LVM_GetControlParameters\n");
+    //ALOGV("\tReverbSetDiffusion() just Got -> %d\n", ActiveParams.Density);
 
     ActiveParams.Density = (LVM_INT16)(level/10);
 
     /* Activate the initial settings */
     LvmStatus = LVREV_SetControlParameters(pContext->hInstance, &ActiveParams);
     LVM_ERROR_CHECK(LvmStatus, "LVREV_SetControlParameters", "ReverbSetDiffusion")
-    //LOGV("\tReverbSetDiffusion() just Set -> %d\n", ActiveParams.Density);
+    //ALOGV("\tReverbSetDiffusion() just Set -> %d\n", ActiveParams.Density);
 
     pContext->SavedDiffusion = level;
-    //LOGV("\tReverbSetDiffusion end");
+    //ALOGV("\tReverbSetDiffusion end");
     return;
 }
 
@@ -1385,7 +1404,7 @@
 //----------------------------------------------------------------------------
 
 int32_t ReverbGetDiffusion(ReverbContext *pContext){
-    //LOGV("\tReverbGetDiffusion start");
+    //ALOGV("\tReverbGetDiffusion start");
 
     LVREV_ControlParams_st    ActiveParams;              /* Current control Parameters */
     LVREV_ReturnStatus_en     LvmStatus=LVREV_SUCCESS;     /* Function call status */
@@ -1394,16 +1413,16 @@
     /* Get the current settings */
     LvmStatus = LVREV_GetControlParameters(pContext->hInstance, &ActiveParams);
     LVM_ERROR_CHECK(LvmStatus, "LVREV_GetControlParameters", "ReverbGetDiffusion")
-    //LOGV("\tReverbGetDiffusion Succesfully returned from LVM_GetControlParameters\n");
-    //LOGV("\tReverbGetDiffusion just Got -> %d\n", ActiveParams.Density);
+    //ALOGV("\tReverbGetDiffusion Succesfully returned from LVM_GetControlParameters\n");
+    //ALOGV("\tReverbGetDiffusion just Got -> %d\n", ActiveParams.Density);
 
     Temp = (LVM_INT16)(pContext->SavedDiffusion/10);
 
     if(ActiveParams.Density != Temp){
-        LOGV("\tLVM_ERROR : ReverbGetDiffusion invalid value %d %d", Temp, ActiveParams.Density);
+        ALOGV("\tLVM_ERROR : ReverbGetDiffusion invalid value %d %d", Temp, ActiveParams.Density);
     }
 
-    //LOGV("\tReverbGetDiffusion end");
+    //ALOGV("\tReverbGetDiffusion end");
     return pContext->SavedDiffusion;
 }
 
@@ -1420,7 +1439,7 @@
 //----------------------------------------------------------------------------
 
 void ReverbSetDensity(ReverbContext *pContext, int16_t level){
-    //LOGV("\tReverbSetDensity start (%d)", level);
+    //ALOGV("\tReverbSetDensity start (%d)", level);
 
     LVREV_ControlParams_st    ActiveParams;              /* Current control Parameters */
     LVREV_ReturnStatus_en     LvmStatus=LVREV_SUCCESS;     /* Function call status */
@@ -1428,18 +1447,18 @@
     /* Get the current settings */
     LvmStatus = LVREV_GetControlParameters(pContext->hInstance, &ActiveParams);
     LVM_ERROR_CHECK(LvmStatus, "LVREV_GetControlParameters", "ReverbSetDensity")
-    //LOGV("\tReverbSetDensity Succesfully returned from LVM_GetControlParameters\n");
-    //LOGV("\tReverbSetDensity just Got -> %d\n", ActiveParams.RoomSize);
+    //ALOGV("\tReverbSetDensity Succesfully returned from LVM_GetControlParameters\n");
+    //ALOGV("\tReverbSetDensity just Got -> %d\n", ActiveParams.RoomSize);
 
     ActiveParams.RoomSize = (LVM_INT16)(((level * 99) / 1000) + 1);
 
     /* Activate the initial settings */
     LvmStatus = LVREV_SetControlParameters(pContext->hInstance, &ActiveParams);
     LVM_ERROR_CHECK(LvmStatus, "LVREV_SetControlParameters", "ReverbSetDensity")
-    //LOGV("\tReverbSetDensity just Set -> %d\n", ActiveParams.RoomSize);
+    //ALOGV("\tReverbSetDensity just Set -> %d\n", ActiveParams.RoomSize);
 
     pContext->SavedDensity = level;
-    //LOGV("\tReverbSetDensity end");
+    //ALOGV("\tReverbSetDensity end");
     return;
 }
 
@@ -1455,7 +1474,7 @@
 //----------------------------------------------------------------------------
 
 int32_t ReverbGetDensity(ReverbContext *pContext){
-    //LOGV("\tReverbGetDensity start");
+    //ALOGV("\tReverbGetDensity start");
 
     LVREV_ControlParams_st    ActiveParams;              /* Current control Parameters */
     LVREV_ReturnStatus_en     LvmStatus=LVREV_SUCCESS;     /* Function call status */
@@ -1463,17 +1482,17 @@
     /* Get the current settings */
     LvmStatus = LVREV_GetControlParameters(pContext->hInstance, &ActiveParams);
     LVM_ERROR_CHECK(LvmStatus, "LVREV_GetControlParameters", "ReverbGetDensity")
-    //LOGV("\tReverbGetDensity Succesfully returned from LVM_GetControlParameters\n");
-    //LOGV("\tReverbGetDensity() just Got -> %d\n", ActiveParams.RoomSize);
+    //ALOGV("\tReverbGetDensity Succesfully returned from LVM_GetControlParameters\n");
+    //ALOGV("\tReverbGetDensity() just Got -> %d\n", ActiveParams.RoomSize);
 
 
     Temp = (LVM_INT16)(((pContext->SavedDensity * 99) / 1000) + 1);
 
     if(Temp != ActiveParams.RoomSize){
-        LOGV("\tLVM_ERROR : ReverbGetDensity invalid value %d %d", Temp, ActiveParams.RoomSize);
+        ALOGV("\tLVM_ERROR : ReverbGetDensity invalid value %d %d", Temp, ActiveParams.RoomSize);
     }
 
-    //LOGV("\tReverbGetDensity end");
+    //ALOGV("\tReverbGetDensity end");
     return pContext->SavedDensity;
 }
 
@@ -1546,98 +1565,98 @@
     char *name;
     t_reverb_settings *pProperties;
 
-    //LOGV("\tReverb_getParameter start");
+    //ALOGV("\tReverb_getParameter start");
     if (pContext->preset) {
         if (param != REVERB_PARAM_PRESET || *pValueSize < sizeof(uint16_t)) {
             return -EINVAL;
         }
 
         *(uint16_t *)pValue = pContext->nextPreset;
-        LOGV("get REVERB_PARAM_PRESET, preset %d", pContext->nextPreset);
+        ALOGV("get REVERB_PARAM_PRESET, preset %d", pContext->nextPreset);
         return 0;
     }
 
     switch (param){
         case REVERB_PARAM_ROOM_LEVEL:
             if (*pValueSize != sizeof(int16_t)){
-                LOGV("\tLVM_ERROR : Reverb_getParameter() invalid pValueSize1 %d", *pValueSize);
+                ALOGV("\tLVM_ERROR : Reverb_getParameter() invalid pValueSize1 %d", *pValueSize);
                 return -EINVAL;
             }
             *pValueSize = sizeof(int16_t);
             break;
         case REVERB_PARAM_ROOM_HF_LEVEL:
             if (*pValueSize != sizeof(int16_t)){
-                LOGV("\tLVM_ERROR : Reverb_getParameter() invalid pValueSize12 %d", *pValueSize);
+                ALOGV("\tLVM_ERROR : Reverb_getParameter() invalid pValueSize12 %d", *pValueSize);
                 return -EINVAL;
             }
             *pValueSize = sizeof(int16_t);
             break;
         case REVERB_PARAM_DECAY_TIME:
             if (*pValueSize != sizeof(uint32_t)){
-                LOGV("\tLVM_ERROR : Reverb_getParameter() invalid pValueSize3 %d", *pValueSize);
+                ALOGV("\tLVM_ERROR : Reverb_getParameter() invalid pValueSize3 %d", *pValueSize);
                 return -EINVAL;
             }
             *pValueSize = sizeof(uint32_t);
             break;
         case REVERB_PARAM_DECAY_HF_RATIO:
             if (*pValueSize != sizeof(int16_t)){
-                LOGV("\tLVM_ERROR : Reverb_getParameter() invalid pValueSize4 %d", *pValueSize);
+                ALOGV("\tLVM_ERROR : Reverb_getParameter() invalid pValueSize4 %d", *pValueSize);
                 return -EINVAL;
             }
             *pValueSize = sizeof(int16_t);
             break;
         case REVERB_PARAM_REFLECTIONS_LEVEL:
             if (*pValueSize != sizeof(int16_t)){
-                LOGV("\tLVM_ERROR : Reverb_getParameter() invalid pValueSize5 %d", *pValueSize);
+                ALOGV("\tLVM_ERROR : Reverb_getParameter() invalid pValueSize5 %d", *pValueSize);
                 return -EINVAL;
             }
             *pValueSize = sizeof(int16_t);
             break;
         case REVERB_PARAM_REFLECTIONS_DELAY:
             if (*pValueSize != sizeof(uint32_t)){
-                LOGV("\tLVM_ERROR : Reverb_getParameter() invalid pValueSize6 %d", *pValueSize);
+                ALOGV("\tLVM_ERROR : Reverb_getParameter() invalid pValueSize6 %d", *pValueSize);
                 return -EINVAL;
             }
             *pValueSize = sizeof(uint32_t);
             break;
         case REVERB_PARAM_REVERB_LEVEL:
             if (*pValueSize != sizeof(int16_t)){
-                LOGV("\tLVM_ERROR : Reverb_getParameter() invalid pValueSize7 %d", *pValueSize);
+                ALOGV("\tLVM_ERROR : Reverb_getParameter() invalid pValueSize7 %d", *pValueSize);
                 return -EINVAL;
             }
             *pValueSize = sizeof(int16_t);
             break;
         case REVERB_PARAM_REVERB_DELAY:
             if (*pValueSize != sizeof(uint32_t)){
-                LOGV("\tLVM_ERROR : Reverb_getParameter() invalid pValueSize8 %d", *pValueSize);
+                ALOGV("\tLVM_ERROR : Reverb_getParameter() invalid pValueSize8 %d", *pValueSize);
                 return -EINVAL;
             }
             *pValueSize = sizeof(uint32_t);
             break;
         case REVERB_PARAM_DIFFUSION:
             if (*pValueSize != sizeof(int16_t)){
-                LOGV("\tLVM_ERROR : Reverb_getParameter() invalid pValueSize9 %d", *pValueSize);
+                ALOGV("\tLVM_ERROR : Reverb_getParameter() invalid pValueSize9 %d", *pValueSize);
                 return -EINVAL;
             }
             *pValueSize = sizeof(int16_t);
             break;
         case REVERB_PARAM_DENSITY:
             if (*pValueSize != sizeof(int16_t)){
-                LOGV("\tLVM_ERROR : Reverb_getParameter() invalid pValueSize10 %d", *pValueSize);
+                ALOGV("\tLVM_ERROR : Reverb_getParameter() invalid pValueSize10 %d", *pValueSize);
                 return -EINVAL;
             }
             *pValueSize = sizeof(int16_t);
             break;
         case REVERB_PARAM_PROPERTIES:
             if (*pValueSize != sizeof(t_reverb_settings)){
-                LOGV("\tLVM_ERROR : Reverb_getParameter() invalid pValueSize11 %d", *pValueSize);
+                ALOGV("\tLVM_ERROR : Reverb_getParameter() invalid pValueSize11 %d", *pValueSize);
                 return -EINVAL;
             }
             *pValueSize = sizeof(t_reverb_settings);
             break;
 
         default:
-            LOGV("\tLVM_ERROR : Reverb_getParameter() invalid param %d", param);
+            ALOGV("\tLVM_ERROR : Reverb_getParameter() invalid param %d", param);
             return -EINVAL;
     }
 
@@ -1656,68 +1675,68 @@
             pProperties->diffusion = ReverbGetDiffusion(pContext);
             pProperties->density = ReverbGetDensity(pContext);
 
-            LOGV("\tReverb_getParameter() REVERB_PARAM_PROPERTIES Value is roomLevel        %d",
+            ALOGV("\tReverb_getParameter() REVERB_PARAM_PROPERTIES Value is roomLevel        %d",
                 pProperties->roomLevel);
-            LOGV("\tReverb_getParameter() REVERB_PARAM_PROPERTIES Value is roomHFLevel      %d",
+            ALOGV("\tReverb_getParameter() REVERB_PARAM_PROPERTIES Value is roomHFLevel      %d",
                 pProperties->roomHFLevel);
-            LOGV("\tReverb_getParameter() REVERB_PARAM_PROPERTIES Value is decayTime        %d",
+            ALOGV("\tReverb_getParameter() REVERB_PARAM_PROPERTIES Value is decayTime        %d",
                 pProperties->decayTime);
-            LOGV("\tReverb_getParameter() REVERB_PARAM_PROPERTIES Value is decayHFRatio     %d",
+            ALOGV("\tReverb_getParameter() REVERB_PARAM_PROPERTIES Value is decayHFRatio     %d",
                 pProperties->decayHFRatio);
-            LOGV("\tReverb_getParameter() REVERB_PARAM_PROPERTIES Value is reflectionsLevel %d",
+            ALOGV("\tReverb_getParameter() REVERB_PARAM_PROPERTIES Value is reflectionsLevel %d",
                 pProperties->reflectionsLevel);
-            LOGV("\tReverb_getParameter() REVERB_PARAM_PROPERTIES Value is reflectionsDelay %d",
+            ALOGV("\tReverb_getParameter() REVERB_PARAM_PROPERTIES Value is reflectionsDelay %d",
                 pProperties->reflectionsDelay);
-            LOGV("\tReverb_getParameter() REVERB_PARAM_PROPERTIES Value is reverbDelay      %d",
+            ALOGV("\tReverb_getParameter() REVERB_PARAM_PROPERTIES Value is reverbDelay      %d",
                 pProperties->reverbDelay);
-            LOGV("\tReverb_getParameter() REVERB_PARAM_PROPERTIES Value is reverbLevel      %d",
+            ALOGV("\tReverb_getParameter() REVERB_PARAM_PROPERTIES Value is reverbLevel      %d",
                 pProperties->reverbLevel);
-            LOGV("\tReverb_getParameter() REVERB_PARAM_PROPERTIES Value is diffusion        %d",
+            ALOGV("\tReverb_getParameter() REVERB_PARAM_PROPERTIES Value is diffusion        %d",
                 pProperties->diffusion);
-            LOGV("\tReverb_getParameter() REVERB_PARAM_PROPERTIES Value is density          %d",
+            ALOGV("\tReverb_getParameter() REVERB_PARAM_PROPERTIES Value is density          %d",
                 pProperties->density);
             break;
 
         case REVERB_PARAM_ROOM_LEVEL:
             *(int16_t *)pValue = ReverbGetRoomLevel(pContext);
 
-            //LOGV("\tReverb_getParameter() REVERB_PARAM_ROOM_LEVEL Value is %d",
+            //ALOGV("\tReverb_getParameter() REVERB_PARAM_ROOM_LEVEL Value is %d",
             //        *(int16_t *)pValue);
             break;
         case REVERB_PARAM_ROOM_HF_LEVEL:
             *(int16_t *)pValue = ReverbGetRoomHfLevel(pContext);
 
-            //LOGV("\tReverb_getParameter() REVERB_PARAM_ROOM_HF_LEVEL Value is %d",
+            //ALOGV("\tReverb_getParameter() REVERB_PARAM_ROOM_HF_LEVEL Value is %d",
             //        *(int16_t *)pValue);
             break;
         case REVERB_PARAM_DECAY_TIME:
             *(uint32_t *)pValue = ReverbGetDecayTime(pContext);
 
-            //LOGV("\tReverb_getParameter() REVERB_PARAM_DECAY_TIME Value is %d",
+            //ALOGV("\tReverb_getParameter() REVERB_PARAM_DECAY_TIME Value is %d",
             //        *(int32_t *)pValue);
             break;
         case REVERB_PARAM_DECAY_HF_RATIO:
             *(int16_t *)pValue = ReverbGetDecayHfRatio(pContext);
 
-            //LOGV("\tReverb_getParameter() REVERB_PARAM_DECAY_HF_RATION Value is %d",
+            //ALOGV("\tReverb_getParameter() REVERB_PARAM_DECAY_HF_RATION Value is %d",
             //        *(int16_t *)pValue);
             break;
         case REVERB_PARAM_REVERB_LEVEL:
              *(int16_t *)pValue = ReverbGetReverbLevel(pContext);
 
-            //LOGV("\tReverb_getParameter() REVERB_PARAM_REVERB_LEVEL Value is %d",
+            //ALOGV("\tReverb_getParameter() REVERB_PARAM_REVERB_LEVEL Value is %d",
             //        *(int16_t *)pValue);
             break;
         case REVERB_PARAM_DIFFUSION:
             *(int16_t *)pValue = ReverbGetDiffusion(pContext);
 
-            //LOGV("\tReverb_getParameter() REVERB_PARAM_DECAY_DIFFUSION Value is %d",
+            //ALOGV("\tReverb_getParameter() REVERB_PARAM_DECAY_DIFFUSION Value is %d",
             //        *(int16_t *)pValue);
             break;
         case REVERB_PARAM_DENSITY:
             *(uint16_t *)pValue = 0;
             *(int16_t *)pValue = ReverbGetDensity(pContext);
-            //LOGV("\tReverb_getParameter() REVERB_PARAM_DENSITY Value is %d",
+            //ALOGV("\tReverb_getParameter() REVERB_PARAM_DENSITY Value is %d",
             //        *(uint32_t *)pValue);
             break;
         case REVERB_PARAM_REFLECTIONS_LEVEL:
@@ -1729,12 +1748,12 @@
             break;
 
         default:
-            LOGV("\tLVM_ERROR : Reverb_getParameter() invalid param %d", param);
+            ALOGV("\tLVM_ERROR : Reverb_getParameter() invalid param %d", param);
             status = -EINVAL;
             break;
     }
 
-    //LOGV("\tReverb_getParameter end");
+    //ALOGV("\tReverb_getParameter end");
     return status;
 } /* end Reverb_getParameter */
 
@@ -1762,14 +1781,14 @@
     int32_t *pParamTemp = (int32_t *)pParam;
     int32_t param = *pParamTemp++;
 
-    //LOGV("\tReverb_setParameter start");
+    //ALOGV("\tReverb_setParameter start");
     if (pContext->preset) {
         if (param != REVERB_PARAM_PRESET) {
             return -EINVAL;
         }
 
         uint16_t preset = *(uint16_t *)pValue;
-        LOGV("set REVERB_PARAM_PRESET, preset %d", preset);
+        ALOGV("set REVERB_PARAM_PRESET, preset %d", preset);
         if (preset > REVERB_PRESET_LAST) {
             return -EINVAL;
         }
@@ -1779,7 +1798,7 @@
 
     switch (param){
         case REVERB_PARAM_PROPERTIES:
-            LOGV("\tReverb_setParameter() REVERB_PARAM_PROPERTIES");
+            ALOGV("\tReverb_setParameter() REVERB_PARAM_PROPERTIES");
             pProperties = (t_reverb_settings *) pValue;
             ReverbSetRoomLevel(pContext, pProperties->roomLevel);
             ReverbSetRoomHfLevel(pContext, pProperties->roomHFLevel);
@@ -1791,52 +1810,52 @@
             break;
         case REVERB_PARAM_ROOM_LEVEL:
             level = *(int16_t *)pValue;
-            //LOGV("\tReverb_setParameter() REVERB_PARAM_ROOM_LEVEL value is %d", level);
-            //LOGV("\tReverb_setParameter() Calling ReverbSetRoomLevel");
+            //ALOGV("\tReverb_setParameter() REVERB_PARAM_ROOM_LEVEL value is %d", level);
+            //ALOGV("\tReverb_setParameter() Calling ReverbSetRoomLevel");
             ReverbSetRoomLevel(pContext, level);
-            //LOGV("\tReverb_setParameter() Called ReverbSetRoomLevel");
+            //ALOGV("\tReverb_setParameter() Called ReverbSetRoomLevel");
            break;
         case REVERB_PARAM_ROOM_HF_LEVEL:
             level = *(int16_t *)pValue;
-            //LOGV("\tReverb_setParameter() REVERB_PARAM_ROOM_HF_LEVEL value is %d", level);
-            //LOGV("\tReverb_setParameter() Calling ReverbSetRoomHfLevel");
+            //ALOGV("\tReverb_setParameter() REVERB_PARAM_ROOM_HF_LEVEL value is %d", level);
+            //ALOGV("\tReverb_setParameter() Calling ReverbSetRoomHfLevel");
             ReverbSetRoomHfLevel(pContext, level);
-            //LOGV("\tReverb_setParameter() Called ReverbSetRoomHfLevel");
+            //ALOGV("\tReverb_setParameter() Called ReverbSetRoomHfLevel");
            break;
         case REVERB_PARAM_DECAY_TIME:
             time = *(uint32_t *)pValue;
-            //LOGV("\tReverb_setParameter() REVERB_PARAM_DECAY_TIME value is %d", time);
-            //LOGV("\tReverb_setParameter() Calling ReverbSetDecayTime");
+            //ALOGV("\tReverb_setParameter() REVERB_PARAM_DECAY_TIME value is %d", time);
+            //ALOGV("\tReverb_setParameter() Calling ReverbSetDecayTime");
             ReverbSetDecayTime(pContext, time);
-            //LOGV("\tReverb_setParameter() Called ReverbSetDecayTime");
+            //ALOGV("\tReverb_setParameter() Called ReverbSetDecayTime");
            break;
         case REVERB_PARAM_DECAY_HF_RATIO:
             ratio = *(int16_t *)pValue;
-            //LOGV("\tReverb_setParameter() REVERB_PARAM_DECAY_HF_RATIO value is %d", ratio);
-            //LOGV("\tReverb_setParameter() Calling ReverbSetDecayHfRatio");
+            //ALOGV("\tReverb_setParameter() REVERB_PARAM_DECAY_HF_RATIO value is %d", ratio);
+            //ALOGV("\tReverb_setParameter() Calling ReverbSetDecayHfRatio");
             ReverbSetDecayHfRatio(pContext, ratio);
-            //LOGV("\tReverb_setParameter() Called ReverbSetDecayHfRatio");
+            //ALOGV("\tReverb_setParameter() Called ReverbSetDecayHfRatio");
             break;
          case REVERB_PARAM_REVERB_LEVEL:
             level = *(int16_t *)pValue;
-            //LOGV("\tReverb_setParameter() REVERB_PARAM_REVERB_LEVEL value is %d", level);
-            //LOGV("\tReverb_setParameter() Calling ReverbSetReverbLevel");
+            //ALOGV("\tReverb_setParameter() REVERB_PARAM_REVERB_LEVEL value is %d", level);
+            //ALOGV("\tReverb_setParameter() Calling ReverbSetReverbLevel");
             ReverbSetReverbLevel(pContext, level);
-            //LOGV("\tReverb_setParameter() Called ReverbSetReverbLevel");
+            //ALOGV("\tReverb_setParameter() Called ReverbSetReverbLevel");
            break;
         case REVERB_PARAM_DIFFUSION:
             ratio = *(int16_t *)pValue;
-            //LOGV("\tReverb_setParameter() REVERB_PARAM_DECAY_DIFFUSION value is %d", ratio);
-            //LOGV("\tReverb_setParameter() Calling ReverbSetDiffusion");
+            //ALOGV("\tReverb_setParameter() REVERB_PARAM_DECAY_DIFFUSION value is %d", ratio);
+            //ALOGV("\tReverb_setParameter() Calling ReverbSetDiffusion");
             ReverbSetDiffusion(pContext, ratio);
-            //LOGV("\tReverb_setParameter() Called ReverbSetDiffusion");
+            //ALOGV("\tReverb_setParameter() Called ReverbSetDiffusion");
             break;
         case REVERB_PARAM_DENSITY:
             ratio = *(int16_t *)pValue;
-            //LOGV("\tReverb_setParameter() REVERB_PARAM_DECAY_DENSITY value is %d", ratio);
-            //LOGV("\tReverb_setParameter() Calling ReverbSetDensity");
+            //ALOGV("\tReverb_setParameter() REVERB_PARAM_DECAY_DENSITY value is %d", ratio);
+            //ALOGV("\tReverb_setParameter() Calling ReverbSetDensity");
             ReverbSetDensity(pContext, ratio);
-            //LOGV("\tReverb_setParameter() Called ReverbSetDensity");
+            //ALOGV("\tReverb_setParameter() Called ReverbSetDensity");
             break;
            break;
         case REVERB_PARAM_REFLECTIONS_LEVEL:
@@ -1844,11 +1863,11 @@
         case REVERB_PARAM_REVERB_DELAY:
             break;
         default:
-            LOGV("\tLVM_ERROR : Reverb_setParameter() invalid param %d", param);
+            ALOGV("\tLVM_ERROR : Reverb_setParameter() invalid param %d", param);
             break;
     }
 
-    //LOGV("\tReverb_setParameter end");
+    //ALOGV("\tReverb_setParameter end");
     return status;
 } /* end Reverb_setParameter */
 
@@ -1864,16 +1883,16 @@
     int    status = 0;
 
     if (pContext == NULL){
-        LOGV("\tLVM_ERROR : Reverb_process() ERROR pContext == NULL");
+        ALOGV("\tLVM_ERROR : Reverb_process() ERROR pContext == NULL");
         return -EINVAL;
     }
     if (inBuffer == NULL  || inBuffer->raw == NULL  ||
             outBuffer == NULL || outBuffer->raw == NULL ||
             inBuffer->frameCount != outBuffer->frameCount){
-        LOGV("\tLVM_ERROR : Reverb_process() ERROR NULL INPUT POINTER OR FRAME COUNT IS WRONG");
+        ALOGV("\tLVM_ERROR : Reverb_process() ERROR NULL INPUT POINTER OR FRAME COUNT IS WRONG");
         return -EINVAL;
     }
-    //LOGV("\tReverb_process() Calling process with %d frames", outBuffer->frameCount);
+    //ALOGV("\tReverb_process() Calling process with %d frames", outBuffer->frameCount);
     /* Process all the available frames, block processing is handled internalLY by the LVM bundle */
     status = process(    (LVM_INT16 *)inBuffer->raw,
                          (LVM_INT16 *)outBuffer->raw,
@@ -1905,53 +1924,65 @@
 
 
     if (pContext == NULL){
-        LOGV("\tLVM_ERROR : Reverb_command ERROR pContext == NULL");
+        ALOGV("\tLVM_ERROR : Reverb_command ERROR pContext == NULL");
         return -EINVAL;
     }
 
-    //LOGV("\tReverb_command INPUTS are: command %d cmdSize %d",cmdCode, cmdSize);
+    //ALOGV("\tReverb_command INPUTS are: command %d cmdSize %d",cmdCode, cmdSize);
 
     switch (cmdCode){
         case EFFECT_CMD_INIT:
-            //LOGV("\tReverb_command cmdCode Case: "
+            //ALOGV("\tReverb_command cmdCode Case: "
             //        "EFFECT_CMD_INIT start");
 
             if (pReplyData == NULL || *replySize != sizeof(int)){
-                LOGV("\tLVM_ERROR : Reverb_command cmdCode Case: "
+                ALOGV("\tLVM_ERROR : Reverb_command cmdCode Case: "
                         "EFFECT_CMD_INIT: ERROR");
                 return -EINVAL;
             }
             *(int *) pReplyData = 0;
             break;
 
-        case EFFECT_CMD_CONFIGURE:
-            //LOGV("\tReverb_command cmdCode Case: "
-            //        "EFFECT_CMD_CONFIGURE start");
-            if (pCmdData    == NULL||
-                cmdSize     != sizeof(effect_config_t)||
-                pReplyData  == NULL||
-                *replySize  != sizeof(int)){
-                LOGV("\tLVM_ERROR : Reverb_command cmdCode Case: "
-                        "EFFECT_CMD_CONFIGURE: ERROR");
+        case EFFECT_CMD_SET_CONFIG:
+            //ALOGV("\tReverb_command cmdCode Case: "
+            //        "EFFECT_CMD_SET_CONFIG start");
+            if (pCmdData == NULL ||
+                cmdSize != sizeof(effect_config_t) ||
+                pReplyData == NULL ||
+                *replySize != sizeof(int)) {
+                ALOGV("\tLVM_ERROR : Reverb_command cmdCode Case: "
+                        "EFFECT_CMD_SET_CONFIG: ERROR");
                 return -EINVAL;
             }
-            *(int *) pReplyData = Reverb_configure(pContext, (effect_config_t *) pCmdData);
+            *(int *) pReplyData = android::Reverb_setConfig(pContext,
+                                                            (effect_config_t *) pCmdData);
+            break;
+
+        case EFFECT_CMD_GET_CONFIG:
+            if (pReplyData == NULL ||
+                *replySize != sizeof(effect_config_t)) {
+                ALOGV("\tLVM_ERROR : Reverb_command cmdCode Case: "
+                        "EFFECT_CMD_GET_CONFIG: ERROR");
+                return -EINVAL;
+            }
+
+            android::Reverb_getConfig(pContext, (effect_config_t *)pReplyData);
             break;
 
         case EFFECT_CMD_RESET:
-            //LOGV("\tReverb_command cmdCode Case: "
+            //ALOGV("\tReverb_command cmdCode Case: "
             //        "EFFECT_CMD_RESET start");
-            Reverb_configure(pContext, &pContext->config);
+            Reverb_setConfig(pContext, &pContext->config);
             break;
 
         case EFFECT_CMD_GET_PARAM:{
-            //LOGV("\tReverb_command cmdCode Case: "
+            //ALOGV("\tReverb_command cmdCode Case: "
             //        "EFFECT_CMD_GET_PARAM start");
             if (pCmdData == NULL ||
                     cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) ||
                     pReplyData == NULL ||
                     *replySize < (int) (sizeof(effect_param_t) + sizeof(int32_t))){
-                LOGV("\tLVM_ERROR : Reverb_command cmdCode Case: "
+                ALOGV("\tLVM_ERROR : Reverb_command cmdCode Case: "
                         "EFFECT_CMD_GET_PARAM: ERROR");
                 return -EINVAL;
             }
@@ -1970,7 +2001,7 @@
 
             *replySize = sizeof(effect_param_t) + voffset + p->vsize;
 
-            //LOGV("\tReverb_command EFFECT_CMD_GET_PARAM "
+            //ALOGV("\tReverb_command EFFECT_CMD_GET_PARAM "
             //        "*pCmdData %d, *replySize %d, *pReplyData %d ",
             //        *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)),
             //        *replySize,
@@ -1979,16 +2010,16 @@
         } break;
         case EFFECT_CMD_SET_PARAM:{
 
-            //LOGV("\tReverb_command cmdCode Case: "
+            //ALOGV("\tReverb_command cmdCode Case: "
             //        "EFFECT_CMD_SET_PARAM start");
-            //LOGV("\tReverb_command EFFECT_CMD_SET_PARAM param %d, *replySize %d, value %d ",
+            //ALOGV("\tReverb_command EFFECT_CMD_SET_PARAM param %d, *replySize %d, value %d ",
             //        *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)),
             //        *replySize,
             //        *(int16_t *)((char *)pCmdData + sizeof(effect_param_t) + sizeof(int32_t)));
 
             if (pCmdData == NULL || (cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)))
                     || pReplyData == NULL || *replySize != (int)sizeof(int32_t)) {
-                LOGV("\tLVM_ERROR : Reverb_command cmdCode Case: "
+                ALOGV("\tLVM_ERROR : Reverb_command cmdCode Case: "
                         "EFFECT_CMD_SET_PARAM: ERROR");
                 return -EINVAL;
             }
@@ -1996,12 +2027,12 @@
             effect_param_t *p = (effect_param_t *) pCmdData;
 
             if (p->psize != sizeof(int32_t)){
-                LOGV("\t4LVM_ERROR : Reverb_command cmdCode Case: "
+                ALOGV("\t4LVM_ERROR : Reverb_command cmdCode Case: "
                         "EFFECT_CMD_SET_PARAM: ERROR, psize is not sizeof(int32_t)");
                 return -EINVAL;
             }
 
-            //LOGV("\tn5Reverb_command cmdSize is %d\n"
+            //ALOGV("\tn5Reverb_command cmdSize is %d\n"
             //        "\tsizeof(effect_param_t) is  %d\n"
             //        "\tp->psize is %d\n"
             //        "\tp->vsize is %d"
@@ -2014,16 +2045,16 @@
         } break;
 
         case EFFECT_CMD_ENABLE:
-            //LOGV("\tReverb_command cmdCode Case: "
+            //ALOGV("\tReverb_command cmdCode Case: "
             //        "EFFECT_CMD_ENABLE start");
 
             if (pReplyData == NULL || *replySize != sizeof(int)){
-                LOGV("\tLVM_ERROR : Reverb_command cmdCode Case: "
+                ALOGV("\tLVM_ERROR : Reverb_command cmdCode Case: "
                         "EFFECT_CMD_ENABLE: ERROR");
                 return -EINVAL;
             }
             if(pContext->bEnabled == LVM_TRUE){
-                 LOGV("\tLVM_ERROR : Reverb_command cmdCode Case: "
+                 ALOGV("\tLVM_ERROR : Reverb_command cmdCode Case: "
                          "EFFECT_CMD_ENABLE: ERROR-Effect is already enabled");
                  return -EINVAL;
              }
@@ -2036,19 +2067,19 @@
                     (ActiveParams.T60 * pContext->config.inputCfg.samplingRate)/1000;
             // force no volume ramp for first buffer processed after enabling the effect
             pContext->volumeMode = android::REVERB_VOLUME_FLAT;
-            //LOGV("\tEFFECT_CMD_ENABLE SamplesToExitCount = %d", pContext->SamplesToExitCount);
+            //ALOGV("\tEFFECT_CMD_ENABLE SamplesToExitCount = %d", pContext->SamplesToExitCount);
             break;
         case EFFECT_CMD_DISABLE:
-            //LOGV("\tReverb_command cmdCode Case: "
+            //ALOGV("\tReverb_command cmdCode Case: "
             //        "EFFECT_CMD_DISABLE start");
 
             if (pReplyData == NULL || *replySize != sizeof(int)){
-                LOGV("\tLVM_ERROR : Reverb_command cmdCode Case: "
+                ALOGV("\tLVM_ERROR : Reverb_command cmdCode Case: "
                         "EFFECT_CMD_DISABLE: ERROR");
                 return -EINVAL;
             }
             if(pContext->bEnabled == LVM_FALSE){
-                 LOGV("\tLVM_ERROR : Reverb_command cmdCode Case: "
+                 ALOGV("\tLVM_ERROR : Reverb_command cmdCode Case: "
                          "EFFECT_CMD_DISABLE: ERROR-Effect is not yet enabled");
                  return -EINVAL;
              }
@@ -2059,7 +2090,7 @@
         case EFFECT_CMD_SET_VOLUME:
             if (pCmdData == NULL ||
                 cmdSize != 2 * sizeof(uint32_t)) {
-                LOGV("\tLVM_ERROR : Reverb_command cmdCode Case: "
+                ALOGV("\tLVM_ERROR : Reverb_command cmdCode Case: "
                         "EFFECT_CMD_SET_VOLUME: ERROR");
                 return -EINVAL;
             }
@@ -2079,23 +2110,23 @@
                 pContext->rightVolume = REVERB_UNIT_VOLUME;
                 pContext->volumeMode = android::REVERB_VOLUME_OFF;
             }
-            LOGV("EFFECT_CMD_SET_VOLUME left %d, right %d mode %d",
+            ALOGV("EFFECT_CMD_SET_VOLUME left %d, right %d mode %d",
                     pContext->leftVolume, pContext->rightVolume,  pContext->volumeMode);
             break;
 
         case EFFECT_CMD_SET_DEVICE:
         case EFFECT_CMD_SET_AUDIO_MODE:
-        //LOGV("\tReverb_command cmdCode Case: "
+        //ALOGV("\tReverb_command cmdCode Case: "
         //        "EFFECT_CMD_SET_DEVICE/EFFECT_CMD_SET_VOLUME/EFFECT_CMD_SET_AUDIO_MODE start");
             break;
 
         default:
-            LOGV("\tLVM_ERROR : Reverb_command cmdCode Case: "
+            ALOGV("\tLVM_ERROR : Reverb_command cmdCode Case: "
                     "DEFAULT start %d ERROR",cmdCode);
             return -EINVAL;
     }
 
-    //LOGV("\tReverb_command end\n\n");
+    //ALOGV("\tReverb_command end\n\n");
     return 0;
 }    /* end Reverb_command */
 
@@ -2107,7 +2138,7 @@
     const effect_descriptor_t *desc;
 
     if (pContext == NULL || pDescriptor == NULL) {
-        LOGV("Reverb_getDescriptor() invalid param");
+        ALOGV("Reverb_getDescriptor() invalid param");
         return -EINVAL;
     }
 
diff --git a/media/libeffects/preprocessing/PreProcessing.cpp b/media/libeffects/preprocessing/PreProcessing.cpp
index ba286a1..e988e06 100755
--- a/media/libeffects/preprocessing/PreProcessing.cpp
+++ b/media/libeffects/preprocessing/PreProcessing.cpp
@@ -226,7 +226,7 @@
 
 int  AgcInit (preproc_effect_t *effect)
 {
-    LOGV("AgcInit");
+    ALOGV("AgcInit");
     webrtc::GainControl *agc = static_cast<webrtc::GainControl *>(effect->engine);
     agc->set_mode(webrtc::GainControl::kFixedDigital);
     agc->set_target_level_dbfs(kAgcDefaultTargetLevel);
@@ -238,9 +238,9 @@
 int  AgcCreate(preproc_effect_t *effect)
 {
     webrtc::GainControl *agc = effect->session->apm->gain_control();
-    LOGV("AgcCreate got agc %p", agc);
+    ALOGV("AgcCreate got agc %p", agc);
     if (agc == NULL) {
-        LOGW("AgcCreate Error");
+        ALOGW("AgcCreate Error");
         return -ENOMEM;
     }
     effect->engine = static_cast<preproc_fx_handle_t>(agc);
@@ -280,7 +280,7 @@
         break;
 
     default:
-        LOGW("AgcGetParameter() unknown param %08x", param);
+        ALOGW("AgcGetParameter() unknown param %08x", param);
         status = -EINVAL;
         break;
     }
@@ -288,15 +288,15 @@
     switch (param) {
     case AGC_PARAM_TARGET_LEVEL:
         *(int16_t *) pValue = (int16_t)(agc->target_level_dbfs() * -100);
-        LOGV("AgcGetParameter() target level %d milliBels", *(int16_t *) pValue);
+        ALOGV("AgcGetParameter() target level %d milliBels", *(int16_t *) pValue);
         break;
     case AGC_PARAM_COMP_GAIN:
         *(int16_t *) pValue = (int16_t)(agc->compression_gain_db() * 100);
-        LOGV("AgcGetParameter() comp gain %d milliBels", *(int16_t *) pValue);
+        ALOGV("AgcGetParameter() comp gain %d milliBels", *(int16_t *) pValue);
         break;
     case AGC_PARAM_LIMITER_ENA:
         *(bool *) pValue = (bool)agc->is_limiter_enabled();
-        LOGV("AgcGetParameter() limiter enabled %s",
+        ALOGV("AgcGetParameter() limiter enabled %s",
              (*(int16_t *) pValue != 0) ? "true" : "false");
         break;
     case AGC_PARAM_PROPERTIES:
@@ -305,7 +305,7 @@
         pProperties->limiterEnabled = (bool)agc->is_limiter_enabled();
         break;
     default:
-        LOGW("AgcGetParameter() unknown param %d", param);
+        ALOGW("AgcGetParameter() unknown param %d", param);
         status = -EINVAL;
         break;
     }
@@ -321,19 +321,19 @@
 
     switch (param) {
     case AGC_PARAM_TARGET_LEVEL:
-        LOGV("AgcSetParameter() target level %d milliBels", *(int16_t *)pValue);
+        ALOGV("AgcSetParameter() target level %d milliBels", *(int16_t *)pValue);
         status = agc->set_target_level_dbfs(-(*(int16_t *)pValue / 100));
         break;
     case AGC_PARAM_COMP_GAIN:
-        LOGV("AgcSetParameter() comp gain %d milliBels", *(int16_t *)pValue);
+        ALOGV("AgcSetParameter() comp gain %d milliBels", *(int16_t *)pValue);
         status = agc->set_compression_gain_db(*(int16_t *)pValue / 100);
         break;
     case AGC_PARAM_LIMITER_ENA:
-        LOGV("AgcSetParameter() limiter enabled %s", *(bool *)pValue ? "true" : "false");
+        ALOGV("AgcSetParameter() limiter enabled %s", *(bool *)pValue ? "true" : "false");
         status = agc->enable_limiter(*(bool *)pValue);
         break;
     case AGC_PARAM_PROPERTIES:
-        LOGV("AgcSetParameter() properties level %d, gain %d limiter %d",
+        ALOGV("AgcSetParameter() properties level %d, gain %d limiter %d",
              pProperties->targetLevel,
              pProperties->compGain,
              pProperties->limiterEnabled);
@@ -344,12 +344,12 @@
         status = agc->enable_limiter(pProperties->limiterEnabled);
         break;
     default:
-        LOGW("AgcSetParameter() unknown param %08x value %08x", param, *(uint32_t *)pValue);
+        ALOGW("AgcSetParameter() unknown param %08x value %08x", param, *(uint32_t *)pValue);
         status = -EINVAL;
         break;
     }
 
-    LOGV("AgcSetParameter() done status %d", status);
+    ALOGV("AgcSetParameter() done status %d", status);
 
     return status;
 }
@@ -357,13 +357,13 @@
 void AgcEnable(preproc_effect_t *effect)
 {
     webrtc::GainControl *agc = static_cast<webrtc::GainControl *>(effect->engine);
-    LOGV("AgcEnable agc %p", agc);
+    ALOGV("AgcEnable agc %p", agc);
     agc->Enable(true);
 }
 
 void AgcDisable(preproc_effect_t *effect)
 {
-    LOGV("AgcDisable");
+    ALOGV("AgcDisable");
     webrtc::GainControl *agc = static_cast<webrtc::GainControl *>(effect->engine);
     agc->Enable(false);
 }
@@ -391,7 +391,7 @@
 
 int  AecInit (preproc_effect_t *effect)
 {
-    LOGV("AecInit");
+    ALOGV("AecInit");
     webrtc::EchoControlMobile *aec = static_cast<webrtc::EchoControlMobile *>(effect->engine);
     aec->set_routing_mode(kAecDefaultMode);
     aec->enable_comfort_noise(kAecDefaultComfortNoise);
@@ -401,9 +401,9 @@
 int  AecCreate(preproc_effect_t *effect)
 {
     webrtc::EchoControlMobile *aec = effect->session->apm->echo_control_mobile();
-    LOGV("AecCreate got aec %p", aec);
+    ALOGV("AecCreate got aec %p", aec);
     if (aec == NULL) {
-        LOGW("AgcCreate Error");
+        ALOGW("AgcCreate Error");
         return -ENOMEM;
     }
     effect->engine = static_cast<preproc_fx_handle_t>(aec);
@@ -426,10 +426,10 @@
     case AEC_PARAM_ECHO_DELAY:
     case AEC_PARAM_PROPERTIES:
         *(uint32_t *)pValue = 1000 * effect->session->apm->stream_delay_ms();
-        LOGV("AecGetParameter() echo delay %d us", *(uint32_t *)pValue);
+        ALOGV("AecGetParameter() echo delay %d us", *(uint32_t *)pValue);
         break;
     default:
-        LOGW("AecGetParameter() unknown param %08x value %08x", param, *(uint32_t *)pValue);
+        ALOGW("AecGetParameter() unknown param %08x value %08x", param, *(uint32_t *)pValue);
         status = -EINVAL;
         break;
     }
@@ -446,10 +446,10 @@
     case AEC_PARAM_ECHO_DELAY:
     case AEC_PARAM_PROPERTIES:
         status = effect->session->apm->set_stream_delay_ms(value/1000);
-        LOGV("AecSetParameter() echo delay %d us, status %d", value, status);
+        ALOGV("AecSetParameter() echo delay %d us, status %d", value, status);
         break;
     default:
-        LOGW("AecSetParameter() unknown param %08x value %08x", param, *(uint32_t *)pValue);
+        ALOGW("AecSetParameter() unknown param %08x value %08x", param, *(uint32_t *)pValue);
         status = -EINVAL;
         break;
     }
@@ -459,20 +459,20 @@
 void AecEnable(preproc_effect_t *effect)
 {
     webrtc::EchoControlMobile *aec = static_cast<webrtc::EchoControlMobile *>(effect->engine);
-    LOGV("AecEnable aec %p", aec);
+    ALOGV("AecEnable aec %p", aec);
     aec->Enable(true);
 }
 
 void AecDisable(preproc_effect_t *effect)
 {
-    LOGV("AecDisable");
+    ALOGV("AecDisable");
     webrtc::EchoControlMobile *aec = static_cast<webrtc::EchoControlMobile *>(effect->engine);
     aec->Enable(false);
 }
 
 int AecSetDevice(preproc_effect_t *effect, uint32_t device)
 {
-    LOGV("AecSetDevice %08x", device);
+    ALOGV("AecSetDevice %08x", device);
     webrtc::EchoControlMobile *aec = static_cast<webrtc::EchoControlMobile *>(effect->engine);
     webrtc::EchoControlMobile::RoutingMode mode = webrtc::EchoControlMobile::kQuietEarpieceOrHeadset;
 
@@ -511,7 +511,7 @@
 
 int  NsInit (preproc_effect_t *effect)
 {
-    LOGV("NsInit");
+    ALOGV("NsInit");
     webrtc::NoiseSuppression *ns = static_cast<webrtc::NoiseSuppression *>(effect->engine);
     ns->set_level(kNsDefaultLevel);
     return 0;
@@ -520,9 +520,9 @@
 int  NsCreate(preproc_effect_t *effect)
 {
     webrtc::NoiseSuppression *ns = effect->session->apm->noise_suppression();
-    LOGV("NsCreate got ns %p", ns);
+    ALOGV("NsCreate got ns %p", ns);
     if (ns == NULL) {
-        LOGW("AgcCreate Error");
+        ALOGW("AgcCreate Error");
         return -ENOMEM;
     }
     effect->engine = static_cast<preproc_fx_handle_t>(ns);
@@ -548,13 +548,13 @@
 void NsEnable(preproc_effect_t *effect)
 {
     webrtc::NoiseSuppression *ns = static_cast<webrtc::NoiseSuppression *>(effect->engine);
-    LOGV("NsEnable ns %p", ns);
+    ALOGV("NsEnable ns %p", ns);
     ns->Enable(true);
 }
 
 void NsDisable(preproc_effect_t *effect)
 {
-    LOGV("NsDisable");
+    ALOGV("NsDisable");
     webrtc::NoiseSuppression *ns = static_cast<webrtc::NoiseSuppression *>(effect->engine);
     ns->Enable(false);
 }
@@ -593,7 +593,7 @@
 int Effect_SetState(preproc_effect_t *effect, uint32_t state)
 {
     int status = 0;
-    LOGV("Effect_SetState proc %d, new %d old %d", effect->procId, state, effect->state);
+    ALOGV("Effect_SetState proc %d, new %d old %d", effect->procId, state, effect->state);
     switch(state) {
     case PREPROC_EFFECT_STATE_INIT:
         switch(effect->state) {
@@ -616,7 +616,7 @@
         case PREPROC_EFFECT_STATE_CREATED:
         case PREPROC_EFFECT_STATE_ACTIVE:
         case PREPROC_EFFECT_STATE_CONFIG:
-            LOGE("Effect_SetState invalid transition");
+            ALOGE("Effect_SetState invalid transition");
             status = -ENOSYS;
             break;
         default:
@@ -626,7 +626,7 @@
     case PREPROC_EFFECT_STATE_CONFIG:
         switch(effect->state) {
         case PREPROC_EFFECT_STATE_INIT:
-            LOGE("Effect_SetState invalid transition");
+            ALOGE("Effect_SetState invalid transition");
             status = -ENOSYS;
             break;
         case PREPROC_EFFECT_STATE_ACTIVE:
@@ -645,7 +645,7 @@
         case PREPROC_EFFECT_STATE_INIT:
         case PREPROC_EFFECT_STATE_CREATED:
         case PREPROC_EFFECT_STATE_ACTIVE:
-            LOGE("Effect_SetState invalid transition");
+            ALOGE("Effect_SetState invalid transition");
             status = -ENOSYS;
             break;
         case PREPROC_EFFECT_STATE_CONFIG:
@@ -725,12 +725,12 @@
 {
     int status = -ENOMEM;
 
-    LOGV("Session_CreateEffect procId %d, createdMsk %08x", procId, session->createdMsk);
+    ALOGV("Session_CreateEffect procId %d, createdMsk %08x", procId, session->createdMsk);
 
     if (session->createdMsk == 0) {
         session->apm = webrtc::AudioProcessing::Create(session->io);
         if (session->apm == NULL) {
-            LOGW("Session_CreateEffect could not get apm engine");
+            ALOGW("Session_CreateEffect could not get apm engine");
             goto error;
         }
         session->apm->set_sample_rate_hz(kPreprocDefaultSr);
@@ -738,12 +738,12 @@
         session->apm->set_num_reverse_channels(kPreProcDefaultCnl);
         session->procFrame = new webrtc::AudioFrame();
         if (session->procFrame == NULL) {
-            LOGW("Session_CreateEffect could not allocate audio frame");
+            ALOGW("Session_CreateEffect could not allocate audio frame");
             goto error;
         }
         session->revFrame = new webrtc::AudioFrame();
         if (session->revFrame == NULL) {
-            LOGW("Session_CreateEffect could not allocate reverse audio frame");
+            ALOGW("Session_CreateEffect could not allocate reverse audio frame");
             goto error;
         }
         session->apmSamplingRate = kPreprocDefaultSr;
@@ -775,7 +775,7 @@
     if (status < 0) {
         goto error;
     }
-    LOGV("Session_CreateEffect OK");
+    ALOGV("Session_CreateEffect OK");
     session->createdMsk |= (1<<procId);
     return status;
 
@@ -794,7 +794,7 @@
 int Session_ReleaseEffect(preproc_session_t *session,
                           preproc_effect_t *fx)
 {
-    LOGW_IF(Effect_Release(fx) != 0, " Effect_Release() failed for proc ID %d", fx->procId);
+    ALOGW_IF(Effect_Release(fx) != 0, " Effect_Release() failed for proc ID %d", fx->procId);
     session->createdMsk &= ~(1<<fx->procId);
     if (session->createdMsk == 0) {
         webrtc::AudioProcessing::Destroy(session->apm);
@@ -841,7 +841,7 @@
         return -EINVAL;
     }
 
-    LOGV("Session_SetConfig sr %d cnl %08x",
+    ALOGV("Session_SetConfig sr %d cnl %08x",
          config->inputCfg.samplingRate, config->inputCfg.channels);
     int status;
 
@@ -904,7 +904,7 @@
                                                     RESAMPLER_QUALITY,
                                                     &error);
         if (session->inResampler == NULL) {
-            LOGW("Session_SetConfig Cannot create speex resampler: %s",
+            ALOGW("Session_SetConfig Cannot create speex resampler: %s",
                  speex_resampler_strerror(error));
             return -EINVAL;
         }
@@ -914,7 +914,7 @@
                                                     RESAMPLER_QUALITY,
                                                     &error);
         if (session->outResampler == NULL) {
-            LOGW("Session_SetConfig Cannot create speex resampler: %s",
+            ALOGW("Session_SetConfig Cannot create speex resampler: %s",
                  speex_resampler_strerror(error));
             speex_resampler_destroy(session->inResampler);
             session->inResampler = NULL;
@@ -926,7 +926,7 @@
                                                     RESAMPLER_QUALITY,
                                                     &error);
         if (session->revResampler == NULL) {
-            LOGW("Session_SetConfig Cannot create speex resampler: %s",
+            ALOGW("Session_SetConfig Cannot create speex resampler: %s",
                  speex_resampler_strerror(error));
             speex_resampler_destroy(session->inResampler);
             session->inResampler = NULL;
@@ -940,6 +940,19 @@
     return 0;
 }
 
+void Session_GetConfig(preproc_session_t *session, effect_config_t *config)
+{
+    memset(config, 0, sizeof(effect_config_t));
+    config->inputCfg.samplingRate = config->outputCfg.samplingRate = session->samplingRate;
+    config->inputCfg.format = config->outputCfg.format = AUDIO_FORMAT_PCM_16_BIT;
+    config->inputCfg.channels = session->inChannelCount == 1 ?
+                                    AUDIO_CHANNEL_IN_MONO : AUDIO_CHANNEL_IN_STEREO;
+    config->outputCfg.channels = session->outChannelCount == 1 ?
+                                    AUDIO_CHANNEL_IN_MONO : AUDIO_CHANNEL_IN_STEREO;
+    config->inputCfg.mask = config->outputCfg.mask =
+            (EFFECT_CONFIG_SMP_RATE | EFFECT_CONFIG_CHANNELS | EFFECT_CONFIG_FORMAT);
+}
+
 int Session_SetReverseConfig(preproc_session_t *session, effect_config_t *config)
 {
     if (config->inputCfg.samplingRate != config->outputCfg.samplingRate ||
@@ -948,7 +961,7 @@
         return -EINVAL;
     }
 
-    LOGV("Session_SetReverseConfig sr %d cnl %08x",
+    ALOGV("Session_SetReverseConfig sr %d cnl %08x",
          config->inputCfg.samplingRate, config->inputCfg.channels);
 
     if (session->state < PREPROC_SESSION_STATE_CONFIG) {
@@ -969,6 +982,17 @@
     return 0;
 }
 
+void Session_GetReverseConfig(preproc_session_t *session, effect_config_t *config)
+{
+    memset(config, 0, sizeof(effect_config_t));
+    config->inputCfg.samplingRate = config->outputCfg.samplingRate = session->samplingRate;
+    config->inputCfg.format = config->outputCfg.format = AUDIO_FORMAT_PCM_16_BIT;
+    config->inputCfg.channels = config->outputCfg.channels =
+            session->revChannelCount == 1 ? AUDIO_CHANNEL_IN_MONO : AUDIO_CHANNEL_IN_STEREO;
+    config->inputCfg.mask = config->outputCfg.mask =
+            (EFFECT_CONFIG_SMP_RATE | EFFECT_CONFIG_CHANNELS | EFFECT_CONFIG_FORMAT);
+}
+
 void Session_SetProcEnabled(preproc_session_t *session, uint32_t procId, bool enabled)
 {
     if (enabled) {
@@ -996,7 +1020,7 @@
             session->revEnabledMsk &= ~(1 << procId);
         }
     }
-    LOGV("Session_SetProcEnabled proc %d, enabled %d enabledMsk %08x revEnabledMsk %08x",
+    ALOGV("Session_SetProcEnabled proc %d, enabled %d enabledMsk %08x revEnabledMsk %08x",
          procId, enabled, session->enabledMsk, session->revEnabledMsk);
     session->processedMsk = 0;
     if (HasReverseStream(procId)) {
@@ -1074,20 +1098,20 @@
     int    status = 0;
 
     if (effect == NULL){
-        LOGV("PreProcessingFx_Process() ERROR effect == NULL");
+        ALOGV("PreProcessingFx_Process() ERROR effect == NULL");
         return -EINVAL;
     }
     preproc_session_t * session = (preproc_session_t *)effect->session;
 
     if (inBuffer == NULL  || inBuffer->raw == NULL  ||
             outBuffer == NULL || outBuffer->raw == NULL){
-        LOGW("PreProcessingFx_Process() ERROR bad pointer");
+        ALOGW("PreProcessingFx_Process() ERROR bad pointer");
         return -EINVAL;
     }
 
     session->processedMsk |= (1<<effect->procId);
 
-//    LOGV("PreProcessingFx_Process In %d frames enabledMsk %08x processedMsk %08x",
+//    ALOGV("PreProcessingFx_Process In %d frames enabledMsk %08x processedMsk %08x",
 //         inBuffer->frameCount, session->enabledMsk, session->processedMsk);
 
     if ((session->processedMsk & session->enabledMsk) == session->enabledMsk) {
@@ -1237,7 +1261,7 @@
         return -EINVAL;
     }
 
-    //LOGV("PreProcessingFx_Command: command %d cmdSize %d",cmdCode, cmdSize);
+    //ALOGV("PreProcessingFx_Command: command %d cmdSize %d",cmdCode, cmdSize);
 
     switch (cmdCode){
         case EFFECT_CMD_INIT:
@@ -1250,13 +1274,13 @@
             *(int *)pReplyData = 0;
             break;
 
-        case EFFECT_CMD_CONFIGURE:
+        case EFFECT_CMD_SET_CONFIG:
             if (pCmdData    == NULL||
                 cmdSize     != sizeof(effect_config_t)||
                 pReplyData  == NULL||
                 *replySize  != sizeof(int)){
-                LOGV("PreProcessingFx_Command cmdCode Case: "
-                        "EFFECT_CMD_CONFIGURE: ERROR");
+                ALOGV("PreProcessingFx_Command cmdCode Case: "
+                        "EFFECT_CMD_SET_CONFIG: ERROR");
                 return -EINVAL;
             }
             *(int *)pReplyData = Session_SetConfig(effect->session, (effect_config_t *)pCmdData);
@@ -1266,13 +1290,24 @@
             *(int *)pReplyData = Effect_SetState(effect, PREPROC_EFFECT_STATE_CONFIG);
             break;
 
-        case EFFECT_CMD_CONFIGURE_REVERSE:
-            if (pCmdData    == NULL||
-                cmdSize     != sizeof(effect_config_t)||
-                pReplyData  == NULL||
-                *replySize  != sizeof(int)){
-                LOGV("PreProcessingFx_Command cmdCode Case: "
-                        "EFFECT_CMD_CONFIGURE_REVERSE: ERROR");
+        case EFFECT_CMD_GET_CONFIG:
+            if (pReplyData == NULL ||
+                *replySize != sizeof(effect_config_t)) {
+                ALOGV("\tLVM_ERROR : PreProcessingFx_Command cmdCode Case: "
+                        "EFFECT_CMD_GET_CONFIG: ERROR");
+                return -EINVAL;
+            }
+
+            Session_GetConfig(effect->session, (effect_config_t *)pCmdData);
+            break;
+
+        case EFFECT_CMD_SET_CONFIG_REVERSE:
+            if (pCmdData == NULL ||
+                cmdSize != sizeof(effect_config_t) ||
+                pReplyData == NULL ||
+                *replySize != sizeof(int)) {
+                ALOGV("PreProcessingFx_Command cmdCode Case: "
+                        "EFFECT_CMD_SET_CONFIG_REVERSE: ERROR");
                 return -EINVAL;
             }
             *(int *)pReplyData = Session_SetReverseConfig(effect->session,
@@ -1282,6 +1317,16 @@
             }
             break;
 
+        case EFFECT_CMD_GET_CONFIG_REVERSE:
+            if (pReplyData == NULL ||
+                *replySize != sizeof(effect_config_t)){
+                ALOGV("PreProcessingFx_Command cmdCode Case: "
+                        "EFFECT_CMD_GET_CONFIG_REVERSE: ERROR");
+                return -EINVAL;
+            }
+            Session_GetReverseConfig(effect->session, (effect_config_t *)pCmdData);
+            break;
+
         case EFFECT_CMD_RESET:
             if (effect->ops->reset) {
                 effect->ops->reset(effect);
@@ -1293,7 +1338,7 @@
                     cmdSize < (int)sizeof(effect_param_t) ||
                     pReplyData == NULL ||
                     *replySize < (int)sizeof(effect_param_t)){
-                LOGV("PreProcessingFx_Command cmdCode Case: "
+                ALOGV("PreProcessingFx_Command cmdCode Case: "
                         "EFFECT_CMD_GET_PARAM: ERROR");
                 return -EINVAL;
             }
@@ -1318,14 +1363,14 @@
                     cmdSize < (int)sizeof(effect_param_t) ||
                     pReplyData == NULL ||
                     *replySize != sizeof(int32_t)){
-                LOGV("PreProcessingFx_Command cmdCode Case: "
+                ALOGV("PreProcessingFx_Command cmdCode Case: "
                         "EFFECT_CMD_SET_PARAM: ERROR");
                 return -EINVAL;
             }
             effect_param_t *p = (effect_param_t *) pCmdData;
 
             if (p->psize != sizeof(int32_t)){
-                LOGV("PreProcessingFx_Command cmdCode Case: "
+                ALOGV("PreProcessingFx_Command cmdCode Case: "
                         "EFFECT_CMD_SET_PARAM: ERROR, psize is not sizeof(int32_t)");
                 return -EINVAL;
             }
@@ -1338,7 +1383,7 @@
 
         case EFFECT_CMD_ENABLE:
             if (pReplyData == NULL || *replySize != sizeof(int)){
-                LOGV("PreProcessingFx_Command cmdCode Case: EFFECT_CMD_ENABLE: ERROR");
+                ALOGV("PreProcessingFx_Command cmdCode Case: EFFECT_CMD_ENABLE: ERROR");
                 return -EINVAL;
             }
             *(int *)pReplyData = Effect_SetState(effect, PREPROC_EFFECT_STATE_ACTIVE);
@@ -1346,7 +1391,7 @@
 
         case EFFECT_CMD_DISABLE:
             if (pReplyData == NULL || *replySize != sizeof(int)){
-                LOGV("PreProcessingFx_Command cmdCode Case: EFFECT_CMD_DISABLE: ERROR");
+                ALOGV("PreProcessingFx_Command cmdCode Case: EFFECT_CMD_DISABLE: ERROR");
                 return -EINVAL;
             }
             *(int *)pReplyData  = Effect_SetState(effect, PREPROC_EFFECT_STATE_CONFIG);
@@ -1356,7 +1401,7 @@
         case EFFECT_CMD_SET_INPUT_DEVICE:
             if (pCmdData == NULL ||
                 cmdSize != sizeof(uint32_t)) {
-                LOGV("PreProcessingFx_Command cmdCode Case: EFFECT_CMD_SET_DEVICE: ERROR");
+                ALOGV("PreProcessingFx_Command cmdCode Case: EFFECT_CMD_SET_DEVICE: ERROR");
                 return -EINVAL;
             }
 
@@ -1398,19 +1443,19 @@
     int    status = 0;
 
     if (effect == NULL){
-        LOGW("PreProcessingFx_ProcessReverse() ERROR effect == NULL");
+        ALOGW("PreProcessingFx_ProcessReverse() ERROR effect == NULL");
         return -EINVAL;
     }
     preproc_session_t * session = (preproc_session_t *)effect->session;
 
     if (inBuffer == NULL  || inBuffer->raw == NULL){
-        LOGW("PreProcessingFx_ProcessReverse() ERROR bad pointer");
+        ALOGW("PreProcessingFx_ProcessReverse() ERROR bad pointer");
         return -EINVAL;
     }
 
     session->revProcessedMsk |= (1<<effect->procId);
 
-//    LOGV("PreProcessingFx_ProcessReverse In %d frames revEnabledMsk %08x revProcessedMsk %08x",
+//    ALOGV("PreProcessingFx_ProcessReverse In %d frames revEnabledMsk %08x revProcessedMsk %08x",
 //         inBuffer->frameCount, session->revEnabledMsk, session->revProcessedMsk);
 
 
@@ -1528,7 +1573,7 @@
                             int32_t             ioId,
                             effect_handle_t  *pInterface)
 {
-    LOGV("EffectCreate: uuid: %08x session %d IO: %d", uuid->timeLow, sessionId, ioId);
+    ALOGV("EffectCreate: uuid: %08x session %d IO: %d", uuid->timeLow, sessionId, ioId);
 
     int status;
     const effect_descriptor_t *desc;
@@ -1540,14 +1585,14 @@
     }
     desc =  PreProc_GetDescriptor(uuid);
     if (desc == NULL) {
-        LOGW("EffectCreate: fx not found uuid: %08x", uuid->timeLow);
+        ALOGW("EffectCreate: fx not found uuid: %08x", uuid->timeLow);
         return -EINVAL;
     }
     procId = UuidToProcId(&desc->type);
 
     session = PreProc_GetSession(procId, sessionId, ioId);
     if (session == NULL) {
-        LOGW("EffectCreate: no more session available");
+        ALOGW("EffectCreate: no more session available");
         return -EINVAL;
     }
 
@@ -1562,7 +1607,7 @@
 int PreProcessingLib_Release(effect_handle_t interface)
 {
     int status;
-    LOGV("EffectRelease start %p", interface);
+    ALOGV("EffectRelease start %p", interface);
     if (PreProc_Init() != 0) {
         return sInitStatus;
     }
@@ -1584,11 +1629,11 @@
 
     const effect_descriptor_t *desc = PreProc_GetDescriptor(uuid);
     if (desc == NULL) {
-        LOGV("PreProcessingLib_GetDescriptor() not found");
+        ALOGV("PreProcessingLib_GetDescriptor() not found");
         return  -EINVAL;
     }
 
-    LOGV("PreProcessingLib_GetDescriptor() got fx %s", desc->name);
+    ALOGV("PreProcessingLib_GetDescriptor() got fx %s", desc->name);
 
     memcpy(pDescriptor, desc, sizeof(effect_descriptor_t));
     return 0;
diff --git a/media/libeffects/testlibs/AudioBiquadFilter.cpp b/media/libeffects/testlibs/AudioBiquadFilter.cpp
index 72917a3..16dd1c5 100644
--- a/media/libeffects/testlibs/AudioBiquadFilter.cpp
+++ b/media/libeffects/testlibs/AudioBiquadFilter.cpp
@@ -17,12 +17,10 @@
 
 #include <string.h>
 #include <assert.h>
+#include <cutils/compiler.h>
 
 #include "AudioBiquadFilter.h"
 
-#define LIKELY( exp )       (__builtin_expect( (exp) != 0, true  ))
-#define UNLIKELY( exp )     (__builtin_expect( (exp) != 0, false ))
-
 namespace android {
 
 const audio_coef_t AudioBiquadFilter::IDENTITY_COEFS[AudioBiquadFilter::NUM_COEFS] = { AUDIO_COEF_ONE, 0, 0, 0, 0 };
@@ -55,7 +53,7 @@
 void AudioBiquadFilter::setCoefs(const audio_coef_t coefs[NUM_COEFS], bool immediate) {
     memcpy(mTargetCoefs, coefs, sizeof(mTargetCoefs));
     if (mState & STATE_ENABLED_MASK) {
-        if (UNLIKELY(immediate)) {
+        if (CC_UNLIKELY(immediate)) {
             memcpy(mCoefs, coefs, sizeof(mCoefs));
             setState(STATE_NORMAL);
         } else {
@@ -70,7 +68,7 @@
 }
 
 void AudioBiquadFilter::enable(bool immediate) {
-    if (UNLIKELY(immediate)) {
+    if (CC_UNLIKELY(immediate)) {
         memcpy(mCoefs, mTargetCoefs, sizeof(mCoefs));
         setState(STATE_NORMAL);
     } else {
@@ -79,7 +77,7 @@
 }
 
 void AudioBiquadFilter::disable(bool immediate) {
-    if (UNLIKELY(immediate)) {
+    if (CC_UNLIKELY(immediate)) {
         memcpy(mCoefs, IDENTITY_COEFS, sizeof(mCoefs));
         setState(STATE_BYPASS);
     } else {
@@ -142,7 +140,7 @@
                                        audio_sample_t * out,
                                        int frameCount) {
     // The common case is in-place processing, because this is what the EQ does.
-    if (UNLIKELY(in != out)) {
+    if (CC_UNLIKELY(in != out)) {
         memcpy(out, in, frameCount * mNumChannels * sizeof(audio_sample_t));
     }
 }
diff --git a/media/libeffects/testlibs/AudioCoefInterpolator.cpp b/media/libeffects/testlibs/AudioCoefInterpolator.cpp
index 039ab9f..6b56922 100644
--- a/media/libeffects/testlibs/AudioCoefInterpolator.cpp
+++ b/media/libeffects/testlibs/AudioCoefInterpolator.cpp
@@ -16,10 +16,10 @@
  */
 
 #include <string.h>
-#include "AudioCoefInterpolator.h"
 
-#define LIKELY( exp )       (__builtin_expect( (exp) != 0, true  ))
-#define UNLIKELY( exp )     (__builtin_expect( (exp) != 0, false ))
+#include <cutils/compiler.h>
+
+#include "AudioCoefInterpolator.h"
 
 namespace android {
 
@@ -44,9 +44,9 @@
     size_t index = 0;
     size_t dim = mNumInDims;
     while (dim-- > 0) {
-        if (UNLIKELY(intCoord[dim] < 0)) {
+        if (CC_UNLIKELY(intCoord[dim] < 0)) {
             fracCoord[dim] = 0;
-        } else if (UNLIKELY(intCoord[dim] >= (int)mInDims[dim] - 1)) {
+        } else if (CC_UNLIKELY(intCoord[dim] >= (int)mInDims[dim] - 1)) {
             fracCoord[dim] = 0;
             index += mInDimOffsets[dim] * (mInDims[dim] - 1);
         } else {
@@ -63,7 +63,7 @@
         memcpy(out, mTable + index, mNumOutDims * sizeof(audio_coef_t));
     } else {
         getCoefRecurse(index, fracCoord, out, dim + 1);
-        if (LIKELY(fracCoord != 0)) {
+        if (CC_LIKELY(fracCoord != 0)) {
            audio_coef_t tempCoef[MAX_OUT_DIMS];
            getCoefRecurse(index + mInDimOffsets[dim], fracCoord, tempCoef,
                            dim + 1);
diff --git a/media/libeffects/testlibs/AudioCommon.h b/media/libeffects/testlibs/AudioCommon.h
index 444f93a..e8080dc 100644
--- a/media/libeffects/testlibs/AudioCommon.h
+++ b/media/libeffects/testlibs/AudioCommon.h
@@ -20,6 +20,7 @@
 
 #include <stdint.h>
 #include <stddef.h>
+#include <cutils/compiler.h>
 
 namespace android {
 
@@ -76,9 +77,9 @@
 // Convert a audio_sample_t sample to S15 (with clipping)
 inline int16_t audio_sample_t_to_s15_clip(audio_sample_t sample) {
     // TODO: optimize for targets supporting this as an atomic operation.
-    if (__builtin_expect(sample >= (0x7FFF << 9), 0)) {
+    if (CC_UNLIKELY(sample >= (0x7FFF << 9))) {
         return 0x7FFF;
-    } else if (__builtin_expect(sample <= -(0x8000 << 9), 0)) {
+    } else if (CC_UNLIKELY(sample <= -(0x8000 << 9))) {
         return 0x8000;
     } else {
         return audio_sample_t_to_s15(sample);
diff --git a/media/libeffects/testlibs/AudioEqualizer.cpp b/media/libeffects/testlibs/AudioEqualizer.cpp
index 44c9476..4f3a308 100644
--- a/media/libeffects/testlibs/AudioEqualizer.cpp
+++ b/media/libeffects/testlibs/AudioEqualizer.cpp
@@ -39,7 +39,7 @@
                                                 int nChannels, int sampleRate,
                                                 const PresetConfig * presets,
                                                 int nPresets) {
-    LOGV("AudioEqualizer::CreateInstance(pMem=%p, nBands=%d, nChannels=%d, "
+    ALOGV("AudioEqualizer::CreateInstance(pMem=%p, nBands=%d, nChannels=%d, "
          "sampleRate=%d, nPresets=%d)",
          pMem, nBands, nChannels, sampleRate, nPresets);
     assert(nBands >= 2);
@@ -56,7 +56,7 @@
 }
 
 void AudioEqualizer::configure(int nChannels, int sampleRate) {
-    LOGV("AudioEqualizer::configure(nChannels=%d, sampleRate=%d)", nChannels,
+    ALOGV("AudioEqualizer::configure(nChannels=%d, sampleRate=%d)", nChannels,
          sampleRate);
     mpLowShelf->configure(nChannels, sampleRate);
     for (int i = 0; i < mNumPeaking; ++i) {
@@ -66,7 +66,7 @@
 }
 
 void AudioEqualizer::clear() {
-    LOGV("AudioEqualizer::clear()");
+    ALOGV("AudioEqualizer::clear()");
     mpLowShelf->clear();
     for (int i = 0; i < mNumPeaking; ++i) {
         mpPeakingFilters[i].clear();
@@ -75,14 +75,14 @@
 }
 
 void AudioEqualizer::free() {
-    LOGV("AudioEqualizer::free()");
+    ALOGV("AudioEqualizer::free()");
     if (mpMem != NULL) {
         ::free(mpMem);
     }
 }
 
 void AudioEqualizer::reset() {
-    LOGV("AudioEqualizer::reset()");
+    ALOGV("AudioEqualizer::reset()");
     const int32_t bottom = Effects_log2(kMinFreq);
     const int32_t top = Effects_log2(mSampleRate * 500);
     const int32_t jump = (top - bottom) / (mNumPeaking + 2);
@@ -103,7 +103,7 @@
 }
 
 void AudioEqualizer::setGain(int band, int32_t millibel) {
-    LOGV("AudioEqualizer::setGain(band=%d, millibel=%d)", band, millibel);
+    ALOGV("AudioEqualizer::setGain(band=%d, millibel=%d)", band, millibel);
     assert(band >= 0 && band < mNumPeaking + 2);
     if (band == 0) {
         mpLowShelf->setGain(millibel);
@@ -116,7 +116,7 @@
 }
 
 void AudioEqualizer::setFrequency(int band, uint32_t millihertz) {
-    LOGV("AudioEqualizer::setFrequency(band=%d, millihertz=%d)", band,
+    ALOGV("AudioEqualizer::setFrequency(band=%d, millihertz=%d)", band,
          millihertz);
     assert(band >= 0 && band < mNumPeaking + 2);
     if (band == 0) {
@@ -130,7 +130,7 @@
 }
 
 void AudioEqualizer::setBandwidth(int band, uint32_t cents) {
-    LOGV("AudioEqualizer::setBandwidth(band=%d, cents=%d)", band, cents);
+    ALOGV("AudioEqualizer::setBandwidth(band=%d, cents=%d)", band, cents);
     assert(band >= 0 && band < mNumPeaking + 2);
     if (band > 0 && band < mNumPeaking + 1) {
         mpPeakingFilters[band - 1].setBandwidth(cents);
@@ -201,7 +201,7 @@
 }
 
 void AudioEqualizer::setPreset(int preset) {
-    LOGV("AudioEqualizer::setPreset(preset=%d)", preset);
+    ALOGV("AudioEqualizer::setPreset(preset=%d)", preset);
     assert(preset < mNumPresets && preset >= 0);
     const PresetConfig &presetCfg = mpPresets[preset];
     for (int band = 0; band < (mNumPeaking + 2); ++band) {
@@ -214,7 +214,7 @@
 }
 
 void AudioEqualizer::commit(bool immediate) {
-    LOGV("AudioEqualizer::commit(immediate=%d)", immediate);
+    ALOGV("AudioEqualizer::commit(immediate=%d)", immediate);
     mpLowShelf->commit(immediate);
     for (int i = 0; i < mNumPeaking; ++i) {
         mpPeakingFilters[i].commit(immediate);
@@ -225,7 +225,7 @@
 void AudioEqualizer::process(const audio_sample_t * pIn,
                              audio_sample_t * pOut,
                              int frameCount) {
-//    LOGV("AudioEqualizer::process(frameCount=%d)", frameCount);
+//    ALOGV("AudioEqualizer::process(frameCount=%d)", frameCount);
     mpLowShelf->process(pIn, pOut, frameCount);
     for (int i = 0; i < mNumPeaking; ++i) {
         mpPeakingFilters[i].process(pIn, pOut, frameCount);
@@ -234,7 +234,7 @@
 }
 
 void AudioEqualizer::enable(bool immediate) {
-    LOGV("AudioEqualizer::enable(immediate=%d)", immediate);
+    ALOGV("AudioEqualizer::enable(immediate=%d)", immediate);
     mpLowShelf->enable(immediate);
     for (int i = 0; i < mNumPeaking; ++i) {
         mpPeakingFilters[i].enable(immediate);
@@ -243,7 +243,7 @@
 }
 
 void AudioEqualizer::disable(bool immediate) {
-    LOGV("AudioEqualizer::disable(immediate=%d)", immediate);
+    ALOGV("AudioEqualizer::disable(immediate=%d)", immediate);
     mpLowShelf->disable(immediate);
     for (int i = 0; i < mNumPeaking; ++i) {
         mpPeakingFilters[i].disable(immediate);
diff --git a/media/libeffects/testlibs/AudioPeakingFilter.cpp b/media/libeffects/testlibs/AudioPeakingFilter.cpp
index 60fefe6..99323ac 100644
--- a/media/libeffects/testlibs/AudioPeakingFilter.cpp
+++ b/media/libeffects/testlibs/AudioPeakingFilter.cpp
@@ -21,9 +21,7 @@
 
 #include <new>
 #include <assert.h>
-
-#define LIKELY( exp )       (__builtin_expect( (exp) != 0, true  ))
-#define UNLIKELY( exp )     (__builtin_expect( (exp) != 0, false ))
+#include <cutils/compiler.h>
 
 namespace android {
 // Format of the coefficient table:
@@ -66,12 +64,12 @@
 
 void AudioPeakingFilter::setFrequency(uint32_t millihertz) {
     mNominalFrequency = millihertz;
-    if (UNLIKELY(millihertz > mNiquistFreq / 2)) {
+    if (CC_UNLIKELY(millihertz > mNiquistFreq / 2)) {
         millihertz = mNiquistFreq / 2;
     }
     uint32_t normFreq = static_cast<uint32_t>(
             (static_cast<uint64_t>(millihertz) * mFrequencyFactor) >> 10);
-    if (LIKELY(normFreq > (1 << 23))) {
+    if (CC_LIKELY(normFreq > (1 << 23))) {
         mFrequency = (Effects_log2(normFreq) - ((32-9) << 15)) << (FREQ_PRECISION_BITS - 15);
     } else {
         mFrequency = 0;
@@ -107,11 +105,11 @@
     int32_t halfBW = (((mBandwidth + 1) / 2) << 15) / 1200;
 
     low = static_cast<uint32_t>((static_cast<uint64_t>(mNominalFrequency) * Effects_exp2(-halfBW + (16 << 15))) >> 16);
-    if (UNLIKELY(halfBW >= (16 << 15))) {
+    if (CC_UNLIKELY(halfBW >= (16 << 15))) {
         high = mNiquistFreq;
     } else {
         high = static_cast<uint32_t>((static_cast<uint64_t>(mNominalFrequency) * Effects_exp2(halfBW + (16 << 15))) >> 16);
-        if (UNLIKELY(high > mNiquistFreq)) {
+        if (CC_UNLIKELY(high > mNiquistFreq)) {
             high = mNiquistFreq;
         }
     }
diff --git a/media/libeffects/testlibs/AudioShelvingFilter.cpp b/media/libeffects/testlibs/AudioShelvingFilter.cpp
index b8650ba..e031287 100644
--- a/media/libeffects/testlibs/AudioShelvingFilter.cpp
+++ b/media/libeffects/testlibs/AudioShelvingFilter.cpp
@@ -21,9 +21,7 @@
 
 #include <new>
 #include <assert.h>
-
-#define LIKELY( exp )       (__builtin_expect( (exp) != 0, true  ))
-#define UNLIKELY( exp )     (__builtin_expect( (exp) != 0, false ))
+#include <cutils/compiler.h>
 
 namespace android {
 // Format of the coefficient tables:
@@ -71,13 +69,13 @@
 
 void AudioShelvingFilter::setFrequency(uint32_t millihertz) {
     mNominalFrequency = millihertz;
-    if (UNLIKELY(millihertz > mNiquistFreq / 2)) {
+    if (CC_UNLIKELY(millihertz > mNiquistFreq / 2)) {
         millihertz = mNiquistFreq / 2;
     }
     uint32_t normFreq = static_cast<uint32_t>(
             (static_cast<uint64_t>(millihertz) * mFrequencyFactor) >> 10);
     uint32_t log2minFreq = (mType == kLowShelf ? (32-10) : (32-2));
-    if (LIKELY(normFreq > (1U << log2minFreq))) {
+    if (CC_LIKELY(normFreq > (1U << log2minFreq))) {
         mFrequency = (Effects_log2(normFreq) - (log2minFreq << 15)) << (FREQ_PRECISION_BITS - 15);
     } else {
         mFrequency = 0;
diff --git a/media/libeffects/testlibs/EffectEqualizer.cpp b/media/libeffects/testlibs/EffectEqualizer.cpp
index b22ebec..5241660 100644
--- a/media/libeffects/testlibs/EffectEqualizer.cpp
+++ b/media/libeffects/testlibs/EffectEqualizer.cpp
@@ -114,7 +114,7 @@
 //--- local function prototypes
 
 int Equalizer_init(EqualizerContext *pContext);
-int Equalizer_configure(EqualizerContext *pContext, effect_config_t *pConfig);
+int Equalizer_setConfig(EqualizerContext *pContext, effect_config_t *pConfig);
 int Equalizer_getParameter(AudioEqualizer * pEqualizer, int32_t *pParam, size_t *pValueSize, void *pValue);
 int Equalizer_setParameter(AudioEqualizer * pEqualizer, int32_t *pParam, void *pValue);
 
@@ -147,7 +147,7 @@
     int ret;
     int i;
 
-    LOGV("EffectLibCreateEffect start");
+    ALOGV("EffectLibCreateEffect start");
 
     if (pHandle == NULL || uuid == NULL) {
         return -EINVAL;
@@ -165,7 +165,7 @@
 
     ret = Equalizer_init(pContext);
     if (ret < 0) {
-        LOGW("EffectLibCreateEffect() init failed");
+        ALOGW("EffectLibCreateEffect() init failed");
         delete pContext;
         return ret;
     }
@@ -173,7 +173,7 @@
     *pHandle = (effect_handle_t)pContext;
     pContext->state = EQUALIZER_STATE_INITIALIZED;
 
-    LOGV("EffectLibCreateEffect %p, size %d",
+    ALOGV("EffectLibCreateEffect %p, size %d",
          pContext, AudioEqualizer::GetInstanceSize(kNumBands)+sizeof(EqualizerContext));
 
     return 0;
@@ -183,7 +183,7 @@
 extern "C" int EffectRelease(effect_handle_t handle) {
     EqualizerContext * pContext = (EqualizerContext *)handle;
 
-    LOGV("EffectLibReleaseEffect %p", handle);
+    ALOGV("EffectLibReleaseEffect %p", handle);
     if (pContext == NULL) {
         return -EINVAL;
     }
@@ -199,7 +199,7 @@
                                    effect_descriptor_t *pDescriptor) {
 
     if (pDescriptor == NULL || uuid == NULL){
-        LOGV("EffectGetDescriptor() called with NULL pointer");
+        ALOGV("EffectGetDescriptor() called with NULL pointer");
         return -EINVAL;
     }
 
@@ -218,13 +218,13 @@
 
 #define CHECK_ARG(cond) {                     \
     if (!(cond)) {                            \
-        LOGV("Invalid argument: "#cond);      \
+        ALOGV("Invalid argument: "#cond);      \
         return -EINVAL;                       \
     }                                         \
 }
 
 //----------------------------------------------------------------------------
-// Equalizer_configure()
+// Equalizer_setConfig()
 //----------------------------------------------------------------------------
 // Purpose: Set input and output audio configuration.
 //
@@ -237,9 +237,9 @@
 //
 //----------------------------------------------------------------------------
 
-int Equalizer_configure(EqualizerContext *pContext, effect_config_t *pConfig)
+int Equalizer_setConfig(EqualizerContext *pContext, effect_config_t *pConfig)
 {
-    LOGV("Equalizer_configure start");
+    ALOGV("Equalizer_setConfig start");
 
     CHECK_ARG(pContext != NULL);
     CHECK_ARG(pConfig != NULL);
@@ -272,7 +272,26 @@
                         pConfig->outputCfg.accessMode);
 
     return 0;
-}   // end Equalizer_configure
+}   // end Equalizer_setConfig
+
+//----------------------------------------------------------------------------
+// Equalizer_getConfig()
+//----------------------------------------------------------------------------
+// Purpose: Get input and output audio configuration.
+//
+// Inputs:
+//  pContext:   effect engine context
+//  pConfig:    pointer to effect_config_t structure holding input and output
+//      configuration parameters
+//
+// Outputs:
+//
+//----------------------------------------------------------------------------
+
+void Equalizer_getConfig(EqualizerContext *pContext, effect_config_t *pConfig)
+{
+    memcpy(pConfig, &pContext->config, sizeof(effect_config_t));
+}   // end Equalizer_getConfig
 
 
 //----------------------------------------------------------------------------
@@ -292,7 +311,7 @@
 {
     int status;
 
-    LOGV("Equalizer_init start");
+    ALOGV("Equalizer_init start");
 
     CHECK_ARG(pContext != NULL);
 
@@ -332,7 +351,7 @@
 
     pContext->pEqualizer->enable(true);
 
-    Equalizer_configure(pContext, &pContext->config);
+    Equalizer_setConfig(pContext, &pContext->config);
 
     return 0;
 }   // end Equalizer_init
@@ -416,13 +435,13 @@
     switch (param) {
     case EQ_PARAM_NUM_BANDS:
         *(uint16_t *)pValue = (uint16_t)kNumBands;
-        LOGV("Equalizer_getParameter() EQ_PARAM_NUM_BANDS %d", *(int16_t *)pValue);
+        ALOGV("Equalizer_getParameter() EQ_PARAM_NUM_BANDS %d", *(int16_t *)pValue);
         break;
 
     case EQ_PARAM_LEVEL_RANGE:
         *(int16_t *)pValue = -9600;
         *((int16_t *)pValue + 1) = 4800;
-        LOGV("Equalizer_getParameter() EQ_PARAM_LEVEL_RANGE min %d, max %d",
+        ALOGV("Equalizer_getParameter() EQ_PARAM_LEVEL_RANGE min %d, max %d",
              *(int32_t *)pValue, *((int32_t *)pValue + 1));
         break;
 
@@ -433,7 +452,7 @@
             break;
         }
         *(int16_t *)pValue = (int16_t)pEqualizer->getGain(param2);
-        LOGV("Equalizer_getParameter() EQ_PARAM_BAND_LEVEL band %d, level %d",
+        ALOGV("Equalizer_getParameter() EQ_PARAM_BAND_LEVEL band %d, level %d",
              param2, *(int32_t *)pValue);
         break;
 
@@ -444,7 +463,7 @@
             break;
         }
         *(int32_t *)pValue = pEqualizer->getFrequency(param2);
-        LOGV("Equalizer_getParameter() EQ_PARAM_CENTER_FREQ band %d, frequency %d",
+        ALOGV("Equalizer_getParameter() EQ_PARAM_CENTER_FREQ band %d, frequency %d",
              param2, *(int32_t *)pValue);
         break;
 
@@ -455,25 +474,25 @@
             break;
         }
         pEqualizer->getBandRange(param2, *(uint32_t *)pValue, *((uint32_t *)pValue + 1));
-        LOGV("Equalizer_getParameter() EQ_PARAM_BAND_FREQ_RANGE band %d, min %d, max %d",
+        ALOGV("Equalizer_getParameter() EQ_PARAM_BAND_FREQ_RANGE band %d, min %d, max %d",
              param2, *(int32_t *)pValue, *((int32_t *)pValue + 1));
         break;
 
     case EQ_PARAM_GET_BAND:
         param2 = *pParam;
         *(uint16_t *)pValue = (uint16_t)pEqualizer->getMostRelevantBand(param2);
-        LOGV("Equalizer_getParameter() EQ_PARAM_GET_BAND frequency %d, band %d",
+        ALOGV("Equalizer_getParameter() EQ_PARAM_GET_BAND frequency %d, band %d",
              param2, *(int32_t *)pValue);
         break;
 
     case EQ_PARAM_CUR_PRESET:
         *(uint16_t *)pValue = (uint16_t)pEqualizer->getPreset();
-        LOGV("Equalizer_getParameter() EQ_PARAM_CUR_PRESET %d", *(int32_t *)pValue);
+        ALOGV("Equalizer_getParameter() EQ_PARAM_CUR_PRESET %d", *(int32_t *)pValue);
         break;
 
     case EQ_PARAM_GET_NUM_OF_PRESETS:
         *(uint16_t *)pValue = (uint16_t)pEqualizer->getNumPresets();
-        LOGV("Equalizer_getParameter() EQ_PARAM_GET_NUM_OF_PRESETS %d", *(int16_t *)pValue);
+        ALOGV("Equalizer_getParameter() EQ_PARAM_GET_NUM_OF_PRESETS %d", *(int16_t *)pValue);
         break;
 
     case EQ_PARAM_GET_PRESET_NAME:
@@ -486,13 +505,13 @@
         strncpy(name, pEqualizer->getPresetName(param2), *pValueSize - 1);
         name[*pValueSize - 1] = 0;
         *pValueSize = strlen(name) + 1;
-        LOGV("Equalizer_getParameter() EQ_PARAM_GET_PRESET_NAME preset %d, name %s len %d",
+        ALOGV("Equalizer_getParameter() EQ_PARAM_GET_PRESET_NAME preset %d, name %s len %d",
              param2, gEqualizerPresets[param2].name, *pValueSize);
         break;
 
     case EQ_PARAM_PROPERTIES: {
         int16_t *p = (int16_t *)pValue;
-        LOGV("Equalizer_getParameter() EQ_PARAM_PROPERTIES");
+        ALOGV("Equalizer_getParameter() EQ_PARAM_PROPERTIES");
         p[0] = (int16_t)pEqualizer->getPreset();
         p[1] = (int16_t)kNumBands;
         for (int i = 0; i < kNumBands; i++) {
@@ -501,7 +520,7 @@
     } break;
 
     default:
-        LOGV("Equalizer_getParameter() invalid param %d", param);
+        ALOGV("Equalizer_getParameter() invalid param %d", param);
         status = -EINVAL;
         break;
     }
@@ -541,7 +560,7 @@
     case EQ_PARAM_CUR_PRESET:
         preset = (int32_t)(*(uint16_t *)pValue);
 
-        LOGV("setParameter() EQ_PARAM_CUR_PRESET %d", preset);
+        ALOGV("setParameter() EQ_PARAM_CUR_PRESET %d", preset);
         if (preset < 0 || preset >= pEqualizer->getNumPresets()) {
             status = -EINVAL;
             break;
@@ -552,7 +571,7 @@
     case EQ_PARAM_BAND_LEVEL:
         band =  *pParam;
         level = (int32_t)(*(int16_t *)pValue);
-        LOGV("setParameter() EQ_PARAM_BAND_LEVEL band %d, level %d", band, level);
+        ALOGV("setParameter() EQ_PARAM_BAND_LEVEL band %d, level %d", band, level);
         if (band >= kNumBands) {
             status = -EINVAL;
             break;
@@ -561,7 +580,7 @@
         pEqualizer->commit(true);
        break;
     case EQ_PARAM_PROPERTIES: {
-        LOGV("setParameter() EQ_PARAM_PROPERTIES");
+        ALOGV("setParameter() EQ_PARAM_PROPERTIES");
         int16_t *p = (int16_t *)pValue;
         if ((int)p[0] >= pEqualizer->getNumPresets()) {
             status = -EINVAL;
@@ -581,7 +600,7 @@
         pEqualizer->commit(true);
     } break;
     default:
-        LOGV("setParameter() invalid param %d", param);
+        ALOGV("setParameter() invalid param %d", param);
         status = -EINVAL;
         break;
     }
@@ -634,7 +653,7 @@
 
     android::AudioEqualizer * pEqualizer = pContext->pEqualizer;
 
-    LOGV("Equalizer_command command %d cmdSize %d",cmdCode, cmdSize);
+    ALOGV("Equalizer_command command %d cmdSize %d",cmdCode, cmdSize);
 
     switch (cmdCode) {
     case EFFECT_CMD_INIT:
@@ -643,16 +662,22 @@
         }
         *(int *) pReplyData = Equalizer_init(pContext);
         break;
-    case EFFECT_CMD_CONFIGURE:
+    case EFFECT_CMD_SET_CONFIG:
         if (pCmdData == NULL || cmdSize != sizeof(effect_config_t)
                 || pReplyData == NULL || *replySize != sizeof(int)) {
             return -EINVAL;
         }
-        *(int *) pReplyData = Equalizer_configure(pContext,
+        *(int *) pReplyData = Equalizer_setConfig(pContext,
                 (effect_config_t *) pCmdData);
         break;
+    case EFFECT_CMD_GET_CONFIG:
+        if (pReplyData == NULL || *replySize != sizeof(effect_config_t)) {
+            return -EINVAL;
+        }
+        Equalizer_getConfig(pContext, (effect_config_t *) pCmdData);
+        break;
     case EFFECT_CMD_RESET:
-        Equalizer_configure(pContext, &pContext->config);
+        Equalizer_setConfig(pContext, &pContext->config);
         break;
     case EFFECT_CMD_GET_PARAM: {
         if (pCmdData == NULL || cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) ||
@@ -666,14 +691,14 @@
         p->status = android::Equalizer_getParameter(pEqualizer, (int32_t *)p->data, &p->vsize,
                 p->data + voffset);
         *replySize = sizeof(effect_param_t) + voffset + p->vsize;
-        LOGV("Equalizer_command EFFECT_CMD_GET_PARAM *pCmdData %d, *replySize %d, *pReplyData %08x %08x",
+        ALOGV("Equalizer_command EFFECT_CMD_GET_PARAM *pCmdData %d, *replySize %d, *pReplyData %08x %08x",
                 *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)), *replySize,
                 *(int32_t *)((char *)pReplyData + sizeof(effect_param_t) + voffset),
                 *(int32_t *)((char *)pReplyData + sizeof(effect_param_t) + voffset + sizeof(int32_t)));
 
         } break;
     case EFFECT_CMD_SET_PARAM: {
-        LOGV("Equalizer_command EFFECT_CMD_SET_PARAM cmdSize %d pCmdData %p, *replySize %d, pReplyData %p",
+        ALOGV("Equalizer_command EFFECT_CMD_SET_PARAM cmdSize %d pCmdData %p, *replySize %d, pReplyData %p",
              cmdSize, pCmdData, *replySize, pReplyData);
         if (pCmdData == NULL || cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) ||
             pReplyData == NULL || *replySize != sizeof(int32_t)) {
@@ -691,7 +716,7 @@
             return -ENOSYS;
         }
         pContext->state = EQUALIZER_STATE_ACTIVE;
-        LOGV("EFFECT_CMD_ENABLE() OK");
+        ALOGV("EFFECT_CMD_ENABLE() OK");
         *(int *)pReplyData = 0;
         break;
     case EFFECT_CMD_DISABLE:
@@ -702,7 +727,7 @@
             return -ENOSYS;
         }
         pContext->state = EQUALIZER_STATE_INITIALIZED;
-        LOGV("EFFECT_CMD_DISABLE() OK");
+        ALOGV("EFFECT_CMD_DISABLE() OK");
         *(int *)pReplyData = 0;
         break;
     case EFFECT_CMD_SET_DEVICE:
@@ -710,7 +735,7 @@
     case EFFECT_CMD_SET_AUDIO_MODE:
         break;
     default:
-        LOGW("Equalizer_command invalid command %d",cmdCode);
+        ALOGW("Equalizer_command invalid command %d",cmdCode);
         return -EINVAL;
     }
 
@@ -723,7 +748,7 @@
     android::EqualizerContext * pContext = (android::EqualizerContext *) self;
 
     if (pContext == NULL || pDescriptor == NULL) {
-        LOGV("Equalizer_getDescriptor() invalid param");
+        ALOGV("Equalizer_getDescriptor() invalid param");
         return -EINVAL;
     }
 
diff --git a/media/libeffects/testlibs/EffectReverb.c b/media/libeffects/testlibs/EffectReverb.c
index 405f908..ebb72c1 100644
--- a/media/libeffects/testlibs/EffectReverb.c
+++ b/media/libeffects/testlibs/EffectReverb.c
@@ -122,7 +122,7 @@
     int aux = 0;
     int preset = 0;
 
-    LOGV("EffectLibCreateEffect start");
+    ALOGV("EffectLibCreateEffect start");
 
     if (pHandle == NULL || uuid == NULL) {
         return -EINVAL;
@@ -154,7 +154,7 @@
     }
     ret = Reverb_Init(module, aux, preset);
     if (ret < 0) {
-        LOGW("EffectLibCreateEffect() init failed");
+        ALOGW("EffectLibCreateEffect() init failed");
         free(module);
         return ret;
     }
@@ -163,7 +163,7 @@
 
     module->context.mState = REVERB_STATE_INITIALIZED;
 
-    LOGV("EffectLibCreateEffect %p ,size %d", module, sizeof(reverb_module_t));
+    ALOGV("EffectLibCreateEffect %p ,size %d", module, sizeof(reverb_module_t));
 
     return 0;
 }
@@ -171,7 +171,7 @@
 int EffectRelease(effect_handle_t handle) {
     reverb_module_t *pRvbModule = (reverb_module_t *)handle;
 
-    LOGV("EffectLibReleaseEffect %p", handle);
+    ALOGV("EffectLibReleaseEffect %p", handle);
     if (handle == NULL) {
         return -EINVAL;
     }
@@ -188,14 +188,14 @@
     int length = sizeof(gDescriptors) / sizeof(const effect_descriptor_t *);
 
     if (pDescriptor == NULL || uuid == NULL){
-        LOGV("EffectGetDescriptor() called with NULL pointer");
+        ALOGV("EffectGetDescriptor() called with NULL pointer");
         return -EINVAL;
     }
 
     for (i = 0; i < length; i++) {
         if (memcmp(uuid, &gDescriptors[i]->uuid, sizeof(effect_uuid_t)) == 0) {
             memcpy(pDescriptor, gDescriptors[i], sizeof(effect_descriptor_t));
-            LOGV("EffectGetDescriptor - UUID matched Reverb type %d, UUID = %x",
+            ALOGV("EffectGetDescriptor - UUID matched Reverb type %d, UUID = %x",
                  i, gDescriptors[i]->uuid.timeLow);
             return 0;
         }
@@ -306,7 +306,7 @@
 
     pReverb = (reverb_object_t*) &pRvbModule->context;
 
-    LOGV("Reverb_Command command %d cmdSize %d",cmdCode, cmdSize);
+    ALOGV("Reverb_Command command %d cmdSize %d",cmdCode, cmdSize);
 
     switch (cmdCode) {
     case EFFECT_CMD_INIT:
@@ -318,19 +318,25 @@
             pRvbModule->context.mState = REVERB_STATE_INITIALIZED;
         }
         break;
-    case EFFECT_CMD_CONFIGURE:
+    case EFFECT_CMD_SET_CONFIG:
         if (pCmdData == NULL || cmdSize != sizeof(effect_config_t)
                 || pReplyData == NULL || *replySize != sizeof(int)) {
             return -EINVAL;
         }
-        *(int *) pReplyData = Reverb_Configure(pRvbModule,
+        *(int *) pReplyData = Reverb_setConfig(pRvbModule,
                 (effect_config_t *)pCmdData, false);
         break;
+    case EFFECT_CMD_GET_CONFIG:
+        if (pReplyData == NULL || *replySize != sizeof(effect_config_t)) {
+            return -EINVAL;
+        }
+        Reverb_getConfig(pRvbModule, (effect_config_t *) pCmdData);
+        break;
     case EFFECT_CMD_RESET:
         Reverb_Reset(pReverb, false);
         break;
     case EFFECT_CMD_GET_PARAM:
-        LOGV("Reverb_Command EFFECT_CMD_GET_PARAM pCmdData %p, *replySize %d, pReplyData: %p",pCmdData, *replySize, pReplyData);
+        ALOGV("Reverb_Command EFFECT_CMD_GET_PARAM pCmdData %p, *replySize %d, pReplyData: %p",pCmdData, *replySize, pReplyData);
 
         if (pCmdData == NULL || cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) ||
             pReplyData == NULL || *replySize < (int) sizeof(effect_param_t)) {
@@ -338,13 +344,13 @@
         }
         effect_param_t *rep = (effect_param_t *) pReplyData;
         memcpy(pReplyData, pCmdData, sizeof(effect_param_t) + sizeof(int32_t));
-        LOGV("Reverb_Command EFFECT_CMD_GET_PARAM param %d, replySize %d",*(int32_t *)rep->data, rep->vsize);
+        ALOGV("Reverb_Command EFFECT_CMD_GET_PARAM param %d, replySize %d",*(int32_t *)rep->data, rep->vsize);
         rep->status = Reverb_getParameter(pReverb, *(int32_t *)rep->data, &rep->vsize,
                 rep->data + sizeof(int32_t));
         *replySize = sizeof(effect_param_t) + sizeof(int32_t) + rep->vsize;
         break;
     case EFFECT_CMD_SET_PARAM:
-        LOGV("Reverb_Command EFFECT_CMD_SET_PARAM cmdSize %d pCmdData %p, *replySize %d, pReplyData %p",
+        ALOGV("Reverb_Command EFFECT_CMD_SET_PARAM cmdSize %d pCmdData %p, *replySize %d, pReplyData %p",
                 cmdSize, pCmdData, *replySize, pReplyData);
         if (pCmdData == NULL || (cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)))
                 || pReplyData == NULL || *replySize != (int)sizeof(int32_t)) {
@@ -362,7 +368,7 @@
             return -ENOSYS;
         }
         pReverb->mState = REVERB_STATE_ACTIVE;
-        LOGV("EFFECT_CMD_ENABLE() OK");
+        ALOGV("EFFECT_CMD_ENABLE() OK");
         *(int *)pReplyData = 0;
         break;
     case EFFECT_CMD_DISABLE:
@@ -373,14 +379,14 @@
             return -ENOSYS;
         }
         pReverb->mState = REVERB_STATE_INITIALIZED;
-        LOGV("EFFECT_CMD_DISABLE() OK");
+        ALOGV("EFFECT_CMD_DISABLE() OK");
         *(int *)pReplyData = 0;
         break;
     case EFFECT_CMD_SET_DEVICE:
         if (pCmdData == NULL || cmdSize != (int)sizeof(uint32_t)) {
             return -EINVAL;
         }
-        LOGV("Reverb_Command EFFECT_CMD_SET_DEVICE: 0x%08x", *(uint32_t *)pCmdData);
+        ALOGV("Reverb_Command EFFECT_CMD_SET_DEVICE: 0x%08x", *(uint32_t *)pCmdData);
         break;
     case EFFECT_CMD_SET_VOLUME: {
         // audio output is always stereo => 2 channel volumes
@@ -389,17 +395,17 @@
         }
         float left = (float)(*(uint32_t *)pCmdData) / (1 << 24);
         float right = (float)(*((uint32_t *)pCmdData + 1)) / (1 << 24);
-        LOGV("Reverb_Command EFFECT_CMD_SET_VOLUME: left %f, right %f ", left, right);
+        ALOGV("Reverb_Command EFFECT_CMD_SET_VOLUME: left %f, right %f ", left, right);
         break;
         }
     case EFFECT_CMD_SET_AUDIO_MODE:
         if (pCmdData == NULL || cmdSize != (int)sizeof(uint32_t)) {
             return -EINVAL;
         }
-        LOGV("Reverb_Command EFFECT_CMD_SET_AUDIO_MODE: %d", *(uint32_t *)pCmdData);
+        ALOGV("Reverb_Command EFFECT_CMD_SET_AUDIO_MODE: %d", *(uint32_t *)pCmdData);
         break;
     default:
-        LOGW("Reverb_Command invalid command %d",cmdCode);
+        ALOGW("Reverb_Command invalid command %d",cmdCode);
         return -EINVAL;
     }
 
@@ -464,7 +470,7 @@
 int Reverb_Init(reverb_module_t *pRvbModule, int aux, int preset) {
     int ret;
 
-    LOGV("Reverb_Init module %p, aux: %d, preset: %d", pRvbModule,aux, preset);
+    ALOGV("Reverb_Init module %p, aux: %d, preset: %d", pRvbModule,aux, preset);
 
     memset(&pRvbModule->context, 0, sizeof(reverb_object_t));
 
@@ -492,16 +498,16 @@
     pRvbModule->config.outputCfg.accessMode = EFFECT_BUFFER_ACCESS_ACCUMULATE;
     pRvbModule->config.outputCfg.mask = EFFECT_CONFIG_ALL;
 
-    ret = Reverb_Configure(pRvbModule, &pRvbModule->config, true);
+    ret = Reverb_setConfig(pRvbModule, &pRvbModule->config, true);
     if (ret < 0) {
-        LOGV("Reverb_Init error %d on module %p", ret, pRvbModule);
+        ALOGV("Reverb_Init error %d on module %p", ret, pRvbModule);
     }
 
     return ret;
 }
 
 /*----------------------------------------------------------------------------
- * Reverb_Init()
+ * Reverb_setConfig()
  *----------------------------------------------------------------------------
  * Purpose:
  *  Set input and output audio configuration.
@@ -518,7 +524,7 @@
  *----------------------------------------------------------------------------
  */
 
-int Reverb_Configure(reverb_module_t *pRvbModule, effect_config_t *pConfig,
+int Reverb_setConfig(reverb_module_t *pRvbModule, effect_config_t *pConfig,
         bool init) {
     reverb_object_t *pReverb = &pRvbModule->context;
     int bufferSizeInSamples;
@@ -531,12 +537,12 @@
         || pConfig->outputCfg.channels != OUTPUT_CHANNELS
         || pConfig->inputCfg.format != AUDIO_FORMAT_PCM_16_BIT
         || pConfig->outputCfg.format != AUDIO_FORMAT_PCM_16_BIT) {
-        LOGV("Reverb_Configure invalid config");
+        ALOGV("Reverb_setConfig invalid config");
         return -EINVAL;
     }
     if ((pReverb->m_Aux && (pConfig->inputCfg.channels != AUDIO_CHANNEL_OUT_MONO)) ||
         (!pReverb->m_Aux && (pConfig->inputCfg.channels != AUDIO_CHANNEL_OUT_STEREO))) {
-        LOGV("Reverb_Configure invalid config");
+        ALOGV("Reverb_setConfig invalid config");
         return -EINVAL;
     }
 
@@ -576,7 +582,7 @@
         pReverb->m_nCosWT_5KHz = 25997;
         break;
     default:
-        LOGV("Reverb_Configure invalid sampling rate %d", pReverb->m_nSamplingRate);
+        ALOGV("Reverb_setConfig invalid sampling rate %d", pReverb->m_nSamplingRate);
         return -EINVAL;
     }
 
@@ -620,6 +626,28 @@
 }
 
 /*----------------------------------------------------------------------------
+ * Reverb_getConfig()
+ *----------------------------------------------------------------------------
+ * Purpose:
+ *  Get input and output audio configuration.
+ *
+ * Inputs:
+ *  pRvbModule    - pointer to reverb effect module
+ *  pConfig       - pointer to effect_config_t structure containing input
+ *              and output audio parameters configuration
+ * Outputs:
+ *
+ * Side Effects:
+ *
+ *----------------------------------------------------------------------------
+ */
+
+void Reverb_getConfig(reverb_module_t *pRvbModule, effect_config_t *pConfig)
+{
+    memcpy(pConfig, &pRvbModule->config, sizeof(effect_config_t));
+}
+
+/*----------------------------------------------------------------------------
  * Reverb_Reset()
  *----------------------------------------------------------------------------
  * Purpose:
@@ -761,7 +789,7 @@
         } else {
             *pValue16 = (int16_t)(pReverb->m_nNextRoom + 1);
         }
-        LOGV("get REVERB_PARAM_PRESET, preset %d", *pValue16);
+        ALOGV("get REVERB_PARAM_PRESET, preset %d", *pValue16);
     } else {
         switch (param) {
         case REVERB_PARAM_ROOM_LEVEL:
@@ -812,7 +840,7 @@
                     / (32767 - pReverb->m_nRoomLpfFbk);
             *pValue16 = Effects_Linear16ToMillibels(temp);
 
-            LOGV("get REVERB_PARAM_ROOM_LEVEL %d, gain %d, m_nRoomLpfFwd %d, m_nRoomLpfFbk %d", *pValue16, temp, pReverb->m_nRoomLpfFwd, pReverb->m_nRoomLpfFbk);
+            ALOGV("get REVERB_PARAM_ROOM_LEVEL %d, gain %d, m_nRoomLpfFwd %d, m_nRoomLpfFbk %d", *pValue16, temp, pReverb->m_nRoomLpfFwd, pReverb->m_nRoomLpfFbk);
 
             if (param == REVERB_PARAM_ROOM_LEVEL) {
                 break;
@@ -827,24 +855,24 @@
             // - C is cos(2piWT) @ 5000Hz: pReverb->m_nCosWT_5KHz
 
             temp = MULT_EG1_EG1(pReverb->m_nRoomLpfFbk, pReverb->m_nRoomLpfFbk);
-            LOGV("get REVERB_PARAM_ROOM_HF_LEVEL, a1^2 %d", temp);
+            ALOGV("get REVERB_PARAM_ROOM_HF_LEVEL, a1^2 %d", temp);
             temp2 = MULT_EG1_EG1(pReverb->m_nRoomLpfFbk, pReverb->m_nCosWT_5KHz)
                     << 1;
-            LOGV("get REVERB_PARAM_ROOM_HF_LEVEL, 2 Cos a1 %d", temp2);
+            ALOGV("get REVERB_PARAM_ROOM_HF_LEVEL, 2 Cos a1 %d", temp2);
             temp = 32767 + temp - temp2;
-            LOGV("get REVERB_PARAM_ROOM_HF_LEVEL, a1^2 + 2 Cos a1 + 1 %d", temp);
+            ALOGV("get REVERB_PARAM_ROOM_HF_LEVEL, a1^2 + 2 Cos a1 + 1 %d", temp);
             temp = Effects_Sqrt(temp) * 181;
-            LOGV("get REVERB_PARAM_ROOM_HF_LEVEL, SQRT(a1^2 + 2 Cos a1 + 1) %d", temp);
+            ALOGV("get REVERB_PARAM_ROOM_HF_LEVEL, SQRT(a1^2 + 2 Cos a1 + 1) %d", temp);
             temp = ((32767 - pReverb->m_nRoomLpfFbk) << 15) / temp;
 
-            LOGV("get REVERB_PARAM_ROOM_HF_LEVEL, gain %d, m_nRoomLpfFwd %d, m_nRoomLpfFbk %d", temp, pReverb->m_nRoomLpfFwd, pReverb->m_nRoomLpfFbk);
+            ALOGV("get REVERB_PARAM_ROOM_HF_LEVEL, gain %d, m_nRoomLpfFwd %d, m_nRoomLpfFbk %d", temp, pReverb->m_nRoomLpfFwd, pReverb->m_nRoomLpfFbk);
 
             *pValue16 = Effects_Linear16ToMillibels(temp);
 
             if (param == REVERB_PARAM_ROOM_HF_LEVEL) {
                 break;
             }
-            pValue32 = &pProperties->decayTime;
+            pValue32 = (int32_t *)&pProperties->decayTime;
             /* FALL THROUGH */
 
         case REVERB_PARAM_DECAY_TIME:
@@ -858,7 +886,7 @@
             // Convert samples to ms
             *pValue32 = (temp * 1000) / pReverb->m_nSamplingRate;
 
-            LOGV("get REVERB_PARAM_DECAY_TIME, samples %d, ms %d", temp, *pValue32);
+            ALOGV("get REVERB_PARAM_DECAY_TIME, samples %d, ms %d", temp, *pValue32);
 
             if (param == REVERB_PARAM_DECAY_TIME) {
                 break;
@@ -877,7 +905,7 @@
             // - C is cos(2piWT) @ 5000Hz: pReverb->m_nCosWT_5KHz
             if (pReverb->m_nRvbLpfFbk == 0) {
                 *pValue16 = 1000;
-                LOGV("get REVERB_PARAM_DECAY_HF_RATIO, pReverb->m_nRvbLpfFbk == 0, ratio %d", *pValue16);
+                ALOGV("get REVERB_PARAM_DECAY_HF_RATIO, pReverb->m_nRvbLpfFbk == 0, ratio %d", *pValue16);
             } else {
                 temp = MULT_EG1_EG1(pReverb->m_nRvbLpfFbk, pReverb->m_nRvbLpfFbk);
                 temp2 = MULT_EG1_EG1(pReverb->m_nRvbLpfFbk, pReverb->m_nCosWT_5KHz)
@@ -891,7 +919,7 @@
 
                 temp = Effects_Linear16ToMillibels(temp);
                 temp2 = Effects_Linear16ToMillibels(temp2);
-                LOGV("get REVERB_PARAM_DECAY_HF_RATIO, gain 5KHz %d mB, gain DC %d mB", temp, temp2);
+                ALOGV("get REVERB_PARAM_DECAY_HF_RATIO, gain 5KHz %d mB, gain DC %d mB", temp, temp2);
 
                 if (temp == 0)
                     temp = 1;
@@ -900,7 +928,7 @@
                     temp = 1000;
 
                 *pValue16 = temp;
-                LOGV("get REVERB_PARAM_DECAY_HF_RATIO, ratio %d", *pValue16);
+                ALOGV("get REVERB_PARAM_DECAY_HF_RATIO, ratio %d", *pValue16);
             }
 
             if (param == REVERB_PARAM_DECAY_HF_RATIO) {
@@ -912,18 +940,18 @@
         case REVERB_PARAM_REFLECTIONS_LEVEL:
             *pValue16 = Effects_Linear16ToMillibels(pReverb->m_nEarlyGain);
 
-            LOGV("get REVERB_PARAM_REFLECTIONS_LEVEL, %d", *pValue16);
+            ALOGV("get REVERB_PARAM_REFLECTIONS_LEVEL, %d", *pValue16);
             if (param == REVERB_PARAM_REFLECTIONS_LEVEL) {
                 break;
             }
-            pValue32 = &pProperties->reflectionsDelay;
+            pValue32 = (int32_t *)&pProperties->reflectionsDelay;
             /* FALL THROUGH */
 
         case REVERB_PARAM_REFLECTIONS_DELAY:
             // convert samples to ms
             *pValue32 = (pReverb->m_nEarlyDelay * 1000) / pReverb->m_nSamplingRate;
 
-            LOGV("get REVERB_PARAM_REFLECTIONS_DELAY, samples %d, ms %d", pReverb->m_nEarlyDelay, *pValue32);
+            ALOGV("get REVERB_PARAM_REFLECTIONS_DELAY, samples %d, ms %d", pReverb->m_nEarlyDelay, *pValue32);
 
             if (param == REVERB_PARAM_REFLECTIONS_DELAY) {
                 break;
@@ -935,19 +963,19 @@
             // Convert linear gain to millibels
             *pValue16 = Effects_Linear16ToMillibels(pReverb->m_nLateGain << 2);
 
-            LOGV("get REVERB_PARAM_REVERB_LEVEL %d", *pValue16);
+            ALOGV("get REVERB_PARAM_REVERB_LEVEL %d", *pValue16);
 
             if (param == REVERB_PARAM_REVERB_LEVEL) {
                 break;
             }
-            pValue32 = &pProperties->reverbDelay;
+            pValue32 = (int32_t *)&pProperties->reverbDelay;
             /* FALL THROUGH */
 
         case REVERB_PARAM_REVERB_DELAY:
             // convert samples to ms
             *pValue32 = (pReverb->m_nLateDelay * 1000) / pReverb->m_nSamplingRate;
 
-            LOGV("get REVERB_PARAM_REVERB_DELAY, samples %d, ms %d", pReverb->m_nLateDelay, *pValue32);
+            ALOGV("get REVERB_PARAM_REVERB_DELAY, samples %d, ms %d", pReverb->m_nLateDelay, *pValue32);
 
             if (param == REVERB_PARAM_REVERB_DELAY) {
                 break;
@@ -965,7 +993,7 @@
                 temp = 1000;
 
             *pValue16 = temp;
-            LOGV("get REVERB_PARAM_DIFFUSION, %d, AP0 gain %d", *pValue16, pReverb->m_sAp0.m_nApGain);
+            ALOGV("get REVERB_PARAM_DIFFUSION, %d, AP0 gain %d", *pValue16, pReverb->m_sAp0.m_nApGain);
 
             if (param == REVERB_PARAM_DIFFUSION) {
                 break;
@@ -987,7 +1015,7 @@
 
             *pValue16 = temp;
 
-            LOGV("get REVERB_PARAM_DENSITY, %d, AP0 delay smps %d", *pValue16, pReverb->m_sAp0.m_zApOut - pReverb->m_sAp0.m_zApIn);
+            ALOGV("get REVERB_PARAM_DENSITY, %d, AP0 delay smps %d", *pValue16, pReverb->m_sAp0.m_zApOut - pReverb->m_sAp0.m_zApIn);
             break;
 
         default:
@@ -997,7 +1025,7 @@
 
     *pSize = size;
 
-    LOGV("Reverb_getParameter, context %p, param %d, value %d",
+    ALOGV("Reverb_getParameter, context %p, param %d, value %d",
             pReverb, param, *(int *)pValue);
 
     return 0;
@@ -1035,7 +1063,7 @@
     int32_t averageDelay;
     size_t paramSize;
 
-    LOGV("Reverb_setParameter, context %p, param %d, value16 %d, value32 %d",
+    ALOGV("Reverb_setParameter, context %p, param %d, value16 %d, value32 %d",
             pReverb, param, *(int16_t *)pValue, *(int32_t *)pValue);
 
     if (pReverb->m_Preset) {
@@ -1043,7 +1071,7 @@
             return -EINVAL;
         }
         value16 = *(int16_t *)pValue;
-        LOGV("set REVERB_PARAM_PRESET, preset %d", value16);
+        ALOGV("set REVERB_PARAM_PRESET, preset %d", value16);
         if (value16 < REVERB_PRESET_NONE || value16 > REVERB_PRESET_PLATE) {
             return -EINVAL;
         }
@@ -1114,7 +1142,7 @@
             pReverb->m_nRoomLpfFwd
                     = MULT_EG1_EG1(temp, (32767 - pReverb->m_nRoomLpfFbk));
 
-            LOGV("REVERB_PARAM_ROOM_LEVEL, gain %d, new m_nRoomLpfFwd %d, m_nRoomLpfFbk %d", temp, pReverb->m_nRoomLpfFwd, pReverb->m_nRoomLpfFbk);
+            ALOGV("REVERB_PARAM_ROOM_LEVEL, gain %d, new m_nRoomLpfFwd %d, m_nRoomLpfFbk %d", temp, pReverb->m_nRoomLpfFwd, pReverb->m_nRoomLpfFbk);
             if (param == REVERB_PARAM_ROOM_LEVEL)
                 break;
             value16 = pProperties->roomHFLevel;
@@ -1142,11 +1170,11 @@
 
                 // dG^2
                 temp = Effects_MillibelsToLinear16(value16);
-                LOGV("REVERB_PARAM_ROOM_HF_LEVEL, HF gain %d", temp);
+                ALOGV("REVERB_PARAM_ROOM_HF_LEVEL, HF gain %d", temp);
                 temp = (1 << 30) / temp;
-                LOGV("REVERB_PARAM_ROOM_HF_LEVEL, 1/ HF gain %d", temp);
+                ALOGV("REVERB_PARAM_ROOM_HF_LEVEL, 1/ HF gain %d", temp);
                 dG2 = (int32_t) (((int64_t) temp * (int64_t) temp) >> 15);
-                LOGV("REVERB_PARAM_ROOM_HF_LEVEL, 1/ HF gain ^ 2 %d", dG2);
+                ALOGV("REVERB_PARAM_ROOM_HF_LEVEL, 1/ HF gain ^ 2 %d", dG2);
                 // b = 2*(C-dG^2)/(1-dG^2)
                 b = (int32_t) ((((int64_t) 1 << (15 + 1))
                         * ((int64_t) pReverb->m_nCosWT_5KHz - (int64_t) dG2))
@@ -1156,18 +1184,18 @@
                 delta = (int32_t) ((((int64_t) b * (int64_t) b) >> 15) - (1 << (15
                         + 2)));
 
-                LOGV_IF(delta > (1<<30), " delta overflow %d", delta);
+                ALOGV_IF(delta > (1<<30), " delta overflow %d", delta);
 
-                LOGV("REVERB_PARAM_ROOM_HF_LEVEL, dG2 %d, b %d, delta %d, m_nCosWT_5KHz %d", dG2, b, delta, pReverb->m_nCosWT_5KHz);
+                ALOGV("REVERB_PARAM_ROOM_HF_LEVEL, dG2 %d, b %d, delta %d, m_nCosWT_5KHz %d", dG2, b, delta, pReverb->m_nCosWT_5KHz);
                 // m_nRoomLpfFbk = -a1 = - (- b + sqrt(delta)) / 2
                 pReverb->m_nRoomLpfFbk = (b - Effects_Sqrt(delta) * 181) >> 1;
             }
-            LOGV("REVERB_PARAM_ROOM_HF_LEVEL, olg DC gain %d new m_nRoomLpfFbk %d, old m_nRoomLpfFwd %d",
+            ALOGV("REVERB_PARAM_ROOM_HF_LEVEL, olg DC gain %d new m_nRoomLpfFbk %d, old m_nRoomLpfFwd %d",
                     temp2, pReverb->m_nRoomLpfFbk, pReverb->m_nRoomLpfFwd);
 
             pReverb->m_nRoomLpfFwd
                     = MULT_EG1_EG1(temp2, (32767 - pReverb->m_nRoomLpfFbk));
-            LOGV("REVERB_PARAM_ROOM_HF_LEVEL, new m_nRoomLpfFwd %d", pReverb->m_nRoomLpfFwd);
+            ALOGV("REVERB_PARAM_ROOM_HF_LEVEL, new m_nRoomLpfFwd %d", pReverb->m_nRoomLpfFwd);
 
             if (param == REVERB_PARAM_ROOM_HF_LEVEL)
                 break;
@@ -1189,7 +1217,7 @@
                     + (pReverb->m_sAp1.m_zApOut - pReverb->m_sAp1.m_zApIn)) >> 1;
 
             temp = (-6000 * averageDelay) / value32;
-            LOGV("REVERB_PARAM_DECAY_TIME, delay smps %d, DT smps %d, gain mB %d",averageDelay, value32, temp);
+            ALOGV("REVERB_PARAM_DECAY_TIME, delay smps %d, DT smps %d, gain mB %d",averageDelay, value32, temp);
             if (temp < -4000 || temp > -100)
                 return -EINVAL;
 
@@ -1202,7 +1230,7 @@
             pReverb->m_nRvbLpfFwd
                     = MULT_EG1_EG1(temp, (32767 - pReverb->m_nRvbLpfFbk));
 
-            LOGV("REVERB_PARAM_DECAY_TIME, gain %d, new m_nRvbLpfFwd %d, old m_nRvbLpfFbk %d, reverb gain %d", temp, pReverb->m_nRvbLpfFwd, pReverb->m_nRvbLpfFbk, Effects_Linear16ToMillibels(pReverb->m_nLateGain));
+            ALOGV("REVERB_PARAM_DECAY_TIME, gain %d, new m_nRvbLpfFwd %d, old m_nRvbLpfFbk %d, reverb gain %d", temp, pReverb->m_nRvbLpfFwd, pReverb->m_nRvbLpfFbk, Effects_Linear16ToMillibels(pReverb->m_nLateGain));
 
             if (param == REVERB_PARAM_DECAY_TIME)
                 break;
@@ -1229,17 +1257,17 @@
                 // G_5000Hz = G_DC * (1000/REVERB_PARAM_DECAY_HF_RATIO) in millibels
 
                 value32 = ((int32_t) 1000 << 15) / (int32_t) value16;
-                LOGV("REVERB_PARAM_DECAY_HF_RATIO, DC gain %d, DC gain mB %d, 1000/R %d", temp2, temp, value32);
+                ALOGV("REVERB_PARAM_DECAY_HF_RATIO, DC gain %d, DC gain mB %d, 1000/R %d", temp2, temp, value32);
 
                 temp = (int32_t) (((int64_t) temp * (int64_t) value32) >> 15);
 
                 if (temp < -4000) {
-                    LOGV("REVERB_PARAM_DECAY_HF_RATIO HF gain overflow %d mB", temp);
+                    ALOGV("REVERB_PARAM_DECAY_HF_RATIO HF gain overflow %d mB", temp);
                     temp = -4000;
                 }
 
                 temp = Effects_MillibelsToLinear16(temp);
-                LOGV("REVERB_PARAM_DECAY_HF_RATIO, HF gain %d", temp);
+                ALOGV("REVERB_PARAM_DECAY_HF_RATIO, HF gain %d", temp);
                 // dG^2
                 temp = (temp2 << 15) / temp;
                 dG2 = (int32_t) (((int64_t) temp * (int64_t) temp) >> 15);
@@ -1256,11 +1284,11 @@
                 // m_nRoomLpfFbk = -a1 = - (- b + sqrt(delta)) / 2
                 pReverb->m_nRvbLpfFbk = (b - Effects_Sqrt(delta) * 181) >> 1;
 
-                LOGV("REVERB_PARAM_DECAY_HF_RATIO, dG2 %d, b %d, delta %d", dG2, b, delta);
+                ALOGV("REVERB_PARAM_DECAY_HF_RATIO, dG2 %d, b %d, delta %d", dG2, b, delta);
 
             }
 
-            LOGV("REVERB_PARAM_DECAY_HF_RATIO, gain %d, m_nRvbLpfFbk %d, m_nRvbLpfFwd %d", temp2, pReverb->m_nRvbLpfFbk, pReverb->m_nRvbLpfFwd);
+            ALOGV("REVERB_PARAM_DECAY_HF_RATIO, gain %d, m_nRvbLpfFbk %d, m_nRvbLpfFwd %d", temp2, pReverb->m_nRvbLpfFbk, pReverb->m_nRvbLpfFwd);
 
             pReverb->m_nRvbLpfFwd
                     = MULT_EG1_EG1(temp2, (32767 - pReverb->m_nRvbLpfFbk));
@@ -1284,7 +1312,7 @@
                         = MULT_EG1_EG1(pPreset->m_sEarlyR.m_nGain[i],value16);
             }
             pReverb->m_nEarlyGain = value16;
-            LOGV("REVERB_PARAM_REFLECTIONS_LEVEL, m_nEarlyGain %d", pReverb->m_nEarlyGain);
+            ALOGV("REVERB_PARAM_REFLECTIONS_LEVEL, m_nEarlyGain %d", pReverb->m_nEarlyGain);
 
             if (param == REVERB_PARAM_REFLECTIONS_LEVEL)
                 break;
@@ -1315,7 +1343,7 @@
             }
             pReverb->m_nEarlyDelay = temp;
 
-            LOGV("REVERB_PARAM_REFLECTIONS_DELAY, m_nEarlyDelay smps %d max smp delay %d", pReverb->m_nEarlyDelay, maxSamples);
+            ALOGV("REVERB_PARAM_REFLECTIONS_DELAY, m_nEarlyDelay smps %d max smp delay %d", pReverb->m_nEarlyDelay, maxSamples);
 
             // Convert milliseconds to sample count => m_nEarlyDelay
             if (param == REVERB_PARAM_REFLECTIONS_DELAY)
@@ -1330,7 +1358,7 @@
             // Convert millibels to linear 16 bits (gange 0 - 8191) => m_nLateGain.
             pReverb->m_nLateGain = Effects_MillibelsToLinear16(value16) >> 2;
 
-            LOGV("REVERB_PARAM_REVERB_LEVEL, m_nLateGain %d", pReverb->m_nLateGain);
+            ALOGV("REVERB_PARAM_REVERB_LEVEL, m_nLateGain %d", pReverb->m_nLateGain);
 
             if (param == REVERB_PARAM_REVERB_LEVEL)
                 break;
@@ -1359,7 +1387,7 @@
             pReverb->m_nDelay1Out += temp;
             pReverb->m_nLateDelay += temp;
 
-            LOGV("REVERB_PARAM_REVERB_DELAY, m_nLateDelay smps %d max smp delay %d", pReverb->m_nLateDelay, maxSamples);
+            ALOGV("REVERB_PARAM_REVERB_DELAY, m_nLateDelay smps %d max smp delay %d", pReverb->m_nLateDelay, maxSamples);
 
             // Convert milliseconds to sample count => m_nDelay1Out + m_nMaxExcursion
             if (param == REVERB_PARAM_REVERB_DELAY)
@@ -1378,7 +1406,7 @@
             pReverb->m_sAp1.m_nApGain = AP1_GAIN_BASE + ((int32_t) value16
                     * AP1_GAIN_RANGE) / 1000;
 
-            LOGV("REVERB_PARAM_DIFFUSION, m_sAp0.m_nApGain %d m_sAp1.m_nApGain %d", pReverb->m_sAp0.m_nApGain, pReverb->m_sAp1.m_nApGain);
+            ALOGV("REVERB_PARAM_DIFFUSION, m_sAp0.m_nApGain %d m_sAp1.m_nApGain %d", pReverb->m_sAp0.m_nApGain, pReverb->m_sAp1.m_nApGain);
 
             if (param == REVERB_PARAM_DIFFUSION)
                 break;
@@ -1400,7 +1428,7 @@
                 temp = maxSamples;
             pReverb->m_sAp0.m_zApOut = (uint16_t) (pReverb->m_sAp0.m_zApIn + temp);
 
-            LOGV("REVERB_PARAM_DENSITY, Ap0 delay smps %d", temp);
+            ALOGV("REVERB_PARAM_DENSITY, Ap0 delay smps %d", temp);
 
             temp = AP1_TIME_BASE + ((int32_t) value16 * AP1_TIME_RANGE) / 1000;
             /*lint -e{702} shift for performance */
@@ -1409,7 +1437,7 @@
                 temp = maxSamples;
             pReverb->m_sAp1.m_zApOut = (uint16_t) (pReverb->m_sAp1.m_zApIn + temp);
 
-            LOGV("Ap1 delay smps %d", temp);
+            ALOGV("Ap1 delay smps %d", temp);
 
             break;
 
diff --git a/media/libeffects/testlibs/EffectReverb.h b/media/libeffects/testlibs/EffectReverb.h
index 8e2cc31..5137074 100644
--- a/media/libeffects/testlibs/EffectReverb.h
+++ b/media/libeffects/testlibs/EffectReverb.h
@@ -329,7 +329,8 @@
 */
 
 int Reverb_Init(reverb_module_t *pRvbModule, int aux, int preset);
-int Reverb_Configure(reverb_module_t *pRvbModule, effect_config_t *pConfig, bool init);
+int Reverb_setConfig(reverb_module_t *pRvbModule, effect_config_t *pConfig, bool init);
+void Reverb_getConfig(reverb_module_t *pRvbModule, effect_config_t *pConfig);
 void Reverb_Reset(reverb_object_t *pReverb, bool init);
 
 int Reverb_setParameter (reverb_object_t *pReverb, int32_t param, size_t size, void *pValue);
diff --git a/media/libeffects/visualizer/EffectVisualizer.cpp b/media/libeffects/visualizer/EffectVisualizer.cpp
index 1a06cc6..5d70a9b 100644
--- a/media/libeffects/visualizer/EffectVisualizer.cpp
+++ b/media/libeffects/visualizer/EffectVisualizer.cpp
@@ -78,7 +78,7 @@
 }
 
 //----------------------------------------------------------------------------
-// Visualizer_configure()
+// Visualizer_setConfig()
 //----------------------------------------------------------------------------
 // Purpose: Set input and output audio configuration.
 //
@@ -91,9 +91,9 @@
 //
 //----------------------------------------------------------------------------
 
-int Visualizer_configure(VisualizerContext *pContext, effect_config_t *pConfig)
+int Visualizer_setConfig(VisualizerContext *pContext, effect_config_t *pConfig)
 {
-    LOGV("Visualizer_configure start");
+    ALOGV("Visualizer_setConfig start");
 
     if (pConfig->inputCfg.samplingRate != pConfig->outputCfg.samplingRate) return -EINVAL;
     if (pConfig->inputCfg.channels != pConfig->outputCfg.channels) return -EINVAL;
@@ -112,6 +112,26 @@
 
 
 //----------------------------------------------------------------------------
+// Visualizer_getConfig()
+//----------------------------------------------------------------------------
+// Purpose: Get input and output audio configuration.
+//
+// Inputs:
+//  pContext:   effect engine context
+//  pConfig:    pointer to effect_config_t structure holding input and output
+//      configuration parameters
+//
+// Outputs:
+//
+//----------------------------------------------------------------------------
+
+void Visualizer_getConfig(VisualizerContext *pContext, effect_config_t *pConfig)
+{
+    memcpy(pConfig, &pContext->mConfig, sizeof(effect_config_t));
+}
+
+
+//----------------------------------------------------------------------------
 // Visualizer_init()
 //----------------------------------------------------------------------------
 // Purpose: Initialize engine with default configuration.
@@ -144,7 +164,7 @@
 
     pContext->mCaptureSize = VISUALIZER_CAPTURE_SIZE_MAX;
 
-    Visualizer_configure(pContext, &pContext->mConfig);
+    Visualizer_setConfig(pContext, &pContext->mConfig);
 
     return 0;
 }
@@ -192,7 +212,7 @@
 
     ret = Visualizer_init(pContext);
     if (ret < 0) {
-        LOGW("VisualizerLib_Create() init failed");
+        ALOGW("VisualizerLib_Create() init failed");
         delete pContext;
         return ret;
     }
@@ -201,7 +221,7 @@
 
     pContext->mState = VISUALIZER_STATE_INITIALIZED;
 
-    LOGV("VisualizerLib_Create %p", pContext);
+    ALOGV("VisualizerLib_Create %p", pContext);
 
     return 0;
 
@@ -210,7 +230,7 @@
 int VisualizerLib_Release(effect_handle_t handle) {
     VisualizerContext * pContext = (VisualizerContext *)handle;
 
-    LOGV("VisualizerLib_Release %p", handle);
+    ALOGV("VisualizerLib_Release %p", handle);
     if (pContext == NULL) {
         return -EINVAL;
     }
@@ -224,7 +244,7 @@
                                 effect_descriptor_t *pDescriptor) {
 
     if (pDescriptor == NULL || uuid == NULL){
-        LOGV("VisualizerLib_GetDescriptor() called with NULL pointer");
+        ALOGV("VisualizerLib_GetDescriptor() called with NULL pointer");
         return -EINVAL;
     }
 
@@ -328,7 +348,7 @@
         return -EINVAL;
     }
 
-//    LOGV("Visualizer_command command %d cmdSize %d",cmdCode, cmdSize);
+//    ALOGV("Visualizer_command command %d cmdSize %d",cmdCode, cmdSize);
 
     switch (cmdCode) {
     case EFFECT_CMD_INIT:
@@ -337,14 +357,21 @@
         }
         *(int *) pReplyData = Visualizer_init(pContext);
         break;
-    case EFFECT_CMD_CONFIGURE:
+    case EFFECT_CMD_SET_CONFIG:
         if (pCmdData == NULL || cmdSize != sizeof(effect_config_t)
                 || pReplyData == NULL || *replySize != sizeof(int)) {
             return -EINVAL;
         }
-        *(int *) pReplyData = Visualizer_configure(pContext,
+        *(int *) pReplyData = Visualizer_setConfig(pContext,
                 (effect_config_t *) pCmdData);
         break;
+    case EFFECT_CMD_GET_CONFIG:
+        if (pReplyData == NULL ||
+            *replySize != sizeof(effect_config_t)) {
+            return -EINVAL;
+        }
+        Visualizer_getConfig(pContext, (effect_config_t *)pReplyData);
+        break;
     case EFFECT_CMD_RESET:
         Visualizer_reset(pContext);
         break;
@@ -356,7 +383,7 @@
             return -ENOSYS;
         }
         pContext->mState = VISUALIZER_STATE_ACTIVE;
-        LOGV("EFFECT_CMD_ENABLE() OK");
+        ALOGV("EFFECT_CMD_ENABLE() OK");
         *(int *)pReplyData = 0;
         break;
     case EFFECT_CMD_DISABLE:
@@ -367,7 +394,7 @@
             return -ENOSYS;
         }
         pContext->mState = VISUALIZER_STATE_INITIALIZED;
-        LOGV("EFFECT_CMD_DISABLE() OK");
+        ALOGV("EFFECT_CMD_DISABLE() OK");
         *(int *)pReplyData = 0;
         break;
     case EFFECT_CMD_GET_PARAM: {
@@ -386,7 +413,7 @@
             p->status = -EINVAL;
             break;
         }
-        LOGV("get mCaptureSize = %d", pContext->mCaptureSize);
+        ALOGV("get mCaptureSize = %d", pContext->mCaptureSize);
         *((uint32_t *)p->data + 1) = pContext->mCaptureSize;
         p->vsize = sizeof(uint32_t);
         *replySize += sizeof(uint32_t);
@@ -406,7 +433,7 @@
             break;;
         }
         pContext->mCaptureSize = *((uint32_t *)p->data + 1);
-        LOGV("set mCaptureSize = %d", pContext->mCaptureSize);
+        ALOGV("set mCaptureSize = %d", pContext->mCaptureSize);
         } break;
     case EFFECT_CMD_SET_DEVICE:
     case EFFECT_CMD_SET_VOLUME:
@@ -416,7 +443,7 @@
 
     case VISUALIZER_CMD_CAPTURE:
         if (pReplyData == NULL || *replySize != pContext->mCaptureSize) {
-            LOGV("VISUALIZER_CMD_CAPTURE() error *replySize %d pContext->mCaptureSize %d",
+            ALOGV("VISUALIZER_CMD_CAPTURE() error *replySize %d pContext->mCaptureSize %d",
                     *replySize, pContext->mCaptureSize);
             return -EINVAL;
         }
@@ -445,7 +472,7 @@
         break;
 
     default:
-        LOGW("Visualizer_command invalid command %d",cmdCode);
+        ALOGW("Visualizer_command invalid command %d",cmdCode);
         return -EINVAL;
     }
 
@@ -459,7 +486,7 @@
     VisualizerContext * pContext = (VisualizerContext *) self;
 
     if (pContext == NULL || pDescriptor == NULL) {
-        LOGV("Visualizer_getDescriptor() invalid param");
+        ALOGV("Visualizer_getDescriptor() invalid param");
         return -EINVAL;
     }
 
diff --git a/media/libmedia/AudioEffect.cpp b/media/libmedia/AudioEffect.cpp
index 0633744..6639d06 100644
--- a/media/libmedia/AudioEffect.cpp
+++ b/media/libmedia/AudioEffect.cpp
@@ -69,7 +69,7 @@
     effect_uuid_t uuid;
     effect_uuid_t *pUuid = NULL;
 
-    LOGV("Constructor string\n - type: %s\n - uuid: %s", typeStr, uuidStr);
+    ALOGV("Constructor string\n - type: %s\n - uuid: %s", typeStr, uuidStr);
 
     if (typeStr != NULL) {
         if (stringToGuid(typeStr, &type) == NO_ERROR) {
@@ -98,21 +98,21 @@
     sp<IMemory> cblk;
     int enabled;
 
-    LOGV("set %p mUserData: %p uuid: %p timeLow %08x", this, user, type, type ? type->timeLow : 0);
+    ALOGV("set %p mUserData: %p uuid: %p timeLow %08x", this, user, type, type ? type->timeLow : 0);
 
     if (mIEffect != 0) {
-        LOGW("Effect already in use");
+        ALOGW("Effect already in use");
         return INVALID_OPERATION;
     }
 
     const sp<IAudioFlinger>& audioFlinger = AudioSystem::get_audio_flinger();
     if (audioFlinger == 0) {
-        LOGE("set(): Could not get audioflinger");
+        ALOGE("set(): Could not get audioflinger");
         return NO_INIT;
     }
 
     if (type == NULL && uuid == NULL) {
-        LOGW("Must specify at least type or uuid");
+        ALOGW("Must specify at least type or uuid");
         return BAD_VALUE;
     }
 
@@ -138,7 +138,7 @@
             mIEffectClient, priority, io, mSessionId, &mStatus, &mId, &enabled);
 
     if (iEffect == 0 || (mStatus != NO_ERROR && mStatus != ALREADY_EXISTS)) {
-        LOGE("set(): AudioFlinger could not create effect, status: %d", mStatus);
+        ALOGE("set(): AudioFlinger could not create effect, status: %d", mStatus);
         return mStatus;
     }
 
@@ -148,7 +148,7 @@
     cblk = iEffect->getCblk();
     if (cblk == 0) {
         mStatus = NO_INIT;
-        LOGE("Could not get control block");
+        ALOGE("Could not get control block");
         return mStatus;
     }
 
@@ -159,7 +159,7 @@
     mCblk->buffer = (uint8_t *)mCblk + bufOffset;
 
     iEffect->asBinder()->linkToDeath(mIEffectClient);
-    LOGV("set() %p OK effect: %s id: %d status %d enabled %d, ", this, mDescriptor.name, mId, mStatus, mEnabled);
+    ALOGV("set() %p OK effect: %s id: %d status %d enabled %d, ", this, mDescriptor.name, mId, mStatus, mEnabled);
 
     return mStatus;
 }
@@ -167,7 +167,7 @@
 
 AudioEffect::~AudioEffect()
 {
-    LOGV("Destructor %p", this);
+    ALOGV("Destructor %p", this);
 
     if (mStatus == NO_ERROR || mStatus == ALREADY_EXISTS) {
         if (mIEffect != NULL) {
@@ -210,10 +210,10 @@
     AutoMutex lock(mLock);
     if (enabled != mEnabled) {
         if (enabled) {
-            LOGV("enable %p", this);
+            ALOGV("enable %p", this);
             status = mIEffect->enable();
         } else {
-            LOGV("disable %p", this);
+            ALOGV("disable %p", this);
             status = mIEffect->disable();
         }
         if (status == NO_ERROR) {
@@ -230,7 +230,7 @@
                               void *replyData)
 {
     if (mStatus != NO_ERROR && mStatus != ALREADY_EXISTS) {
-        LOGV("command() bad status %d", mStatus);
+        ALOGV("command() bad status %d", mStatus);
         return INVALID_OPERATION;
     }
 
@@ -273,7 +273,7 @@
     uint32_t size = sizeof(int);
     uint32_t psize = ((param->psize - 1) / sizeof(int) + 1) * sizeof(int) + param->vsize;
 
-    LOGV("setParameter: param: %d, param2: %d", *(int *)param->data, (param->psize == 8) ? *((int *)param->data + 1): -1);
+    ALOGV("setParameter: param: %d, param2: %d", *(int *)param->data, (param->psize == 8) ? *((int *)param->data + 1): -1);
 
     return mIEffect->command(EFFECT_CMD_SET_PARAM, sizeof (effect_param_t) + psize, param, &size, &param->status);
 }
@@ -328,7 +328,7 @@
         return BAD_VALUE;
     }
 
-    LOGV("getParameter: param: %d, param2: %d", *(int *)param->data, (param->psize == 8) ? *((int *)param->data + 1): -1);
+    ALOGV("getParameter: param: %d, param2: %d", *(int *)param->data, (param->psize == 8) ? *((int *)param->data + 1): -1);
 
     uint32_t psize = sizeof(effect_param_t) + ((param->psize - 1) / sizeof(int) + 1) * sizeof(int) + param->vsize;
 
@@ -340,7 +340,7 @@
 
 void AudioEffect::binderDied()
 {
-    LOGW("IEffect died");
+    ALOGW("IEffect died");
     mStatus = NO_INIT;
     if (mCbf) {
         status_t status = DEAD_OBJECT;
@@ -353,7 +353,7 @@
 
 void AudioEffect::controlStatusChanged(bool controlGranted)
 {
-    LOGV("controlStatusChanged %p control %d callback %p mUserData %p", this, controlGranted, mCbf, mUserData);
+    ALOGV("controlStatusChanged %p control %d callback %p mUserData %p", this, controlGranted, mCbf, mUserData);
     if (controlGranted) {
         if (mStatus == ALREADY_EXISTS) {
             mStatus = NO_ERROR;
@@ -370,7 +370,7 @@
 
 void AudioEffect::enableStatusChanged(bool enabled)
 {
-    LOGV("enableStatusChanged %p enabled %d mCbf %p", this, enabled, mCbf);
+    ALOGV("enableStatusChanged %p enabled %d mCbf %p", this, enabled, mCbf);
     if (mStatus == ALREADY_EXISTS) {
         mEnabled = enabled;
         if (mCbf) {
diff --git a/media/libmedia/AudioParameter.cpp b/media/libmedia/AudioParameter.cpp
index 59ccfd0..abc7b3f 100644
--- a/media/libmedia/AudioParameter.cpp
+++ b/media/libmedia/AudioParameter.cpp
@@ -53,7 +53,7 @@
                 mParameters.replaceValueFor(key, value);
             }
         } else {
-            LOGV("AudioParameter() cstor empty key value pair");
+            ALOGV("AudioParameter() cstor empty key value pair");
         }
         pair = strtok(NULL, ";");
     }
diff --git a/media/libmedia/AudioRecord.cpp b/media/libmedia/AudioRecord.cpp
index e5062ab..8e4a9d6 100644
--- a/media/libmedia/AudioRecord.cpp
+++ b/media/libmedia/AudioRecord.cpp
@@ -39,9 +39,7 @@
 
 #include <system/audio.h>
 #include <cutils/bitops.h>
-
-#define LIKELY( exp )       (__builtin_expect( (exp) != 0, true  ))
-#define UNLIKELY( exp )     (__builtin_expect( (exp) != 0, false ))
+#include <cutils/compiler.h>
 
 namespace android {
 // ---------------------------------------------------------------------------
@@ -56,12 +54,12 @@
     size_t size = 0;
     if (AudioSystem::getInputBufferSize(sampleRate, format, channelCount, &size)
             != NO_ERROR) {
-        LOGE("AudioSystem could not query the input buffer size.");
+        ALOGE("AudioSystem could not query the input buffer size.");
         return NO_INIT;
     }
 
     if (size == 0) {
-        LOGE("Unsupported configuration: sampleRate %d, format %d, channelCount %d",
+        ALOGE("Unsupported configuration: sampleRate %d, format %d, channelCount %d",
             sampleRate, format, channelCount);
         return BAD_VALUE;
     }
@@ -80,7 +78,8 @@
 // ---------------------------------------------------------------------------
 
 AudioRecord::AudioRecord()
-    : mStatus(NO_INIT), mSessionId(0)
+    : mStatus(NO_INIT), mSessionId(0),
+      mPreviousPriority(ANDROID_PRIORITY_NORMAL), mPreviousSchedulingGroup(ANDROID_TGROUP_DEFAULT)
 {
 }
 
@@ -95,7 +94,8 @@
         void* user,
         int notificationFrames,
         int sessionId)
-    : mStatus(NO_INIT), mSessionId(0)
+    : mStatus(NO_INIT), mSessionId(0),
+      mPreviousPriority(ANDROID_PRIORITY_NORMAL), mPreviousSchedulingGroup(ANDROID_TGROUP_DEFAULT)
 {
     mStatus = set(inputSource, sampleRate, format, channelMask,
             frameCount, flags, cbf, user, notificationFrames, sessionId);
@@ -132,7 +132,7 @@
         int sessionId)
 {
 
-    LOGV("set(): sampleRate %d, channelMask %d, frameCount %d",sampleRate, channelMask, frameCount);
+    ALOGV("set(): sampleRate %d, channelMask %d, frameCount %d",sampleRate, channelMask, frameCount);
 
     AutoMutex lock(mLock);
 
@@ -153,7 +153,7 @@
     }
     // validate parameters
     if (!audio_is_valid_format(format)) {
-        LOGE("Invalid format");
+        ALOGE("Invalid format");
         return BAD_VALUE;
     }
 
@@ -168,7 +168,7 @@
     } else {
         mSessionId = sessionId;
     }
-    LOGV("set(): mSessionId %d", mSessionId);
+    ALOGV("set(): mSessionId %d", mSessionId);
 
     audio_io_handle_t input = AudioSystem::getInput(inputSource,
                                                     sampleRate,
@@ -177,7 +177,7 @@
                                                     (audio_in_acoustics_t)flags,
                                                     mSessionId);
     if (input == 0) {
-        LOGE("Could not get audio input for record source %d", inputSource);
+        ALOGE("Could not get audio input for record source %d", inputSource);
         return BAD_VALUE;
     }
 
@@ -187,7 +187,7 @@
     if (status != NO_ERROR) {
         return status;
     }
-    LOGV("AudioRecord::set() minFrameCount = %d", minFrameCount);
+    ALOGV("AudioRecord::set() minFrameCount = %d", minFrameCount);
 
     if (frameCount == 0) {
         frameCount = minFrameCount;
@@ -208,9 +208,6 @@
 
     if (cbf != 0) {
         mClientRecordThread = new ClientRecordThread(*this, threadCanCallJava);
-        if (mClientRecordThread == 0) {
-            return NO_INIT;
-        }
     }
 
     mStatus = NO_ERROR;
@@ -287,12 +284,12 @@
     status_t ret = NO_ERROR;
     sp<ClientRecordThread> t = mClientRecordThread;
 
-    LOGV("start");
+    ALOGV("start");
 
     if (t != 0) {
         if (t->exitPending()) {
             if (t->requestExitAndWait() == WOULD_BLOCK) {
-                LOGE("AudioRecord::start called from thread");
+                ALOGE("AudioRecord::start called from thread");
                 return WOULD_BLOCK;
             }
         }
@@ -326,9 +323,11 @@
             cblk->bufferTimeoutMs = MAX_RUN_TIMEOUT_MS;
             cblk->waitTimeMs = 0;
             if (t != 0) {
-               t->run("ClientRecordThread", ANDROID_PRIORITY_AUDIO);
+                t->run("ClientRecordThread", ANDROID_PRIORITY_AUDIO);
             } else {
-                setpriority(PRIO_PROCESS, 0, ANDROID_PRIORITY_AUDIO);
+                mPreviousPriority = getpriority(PRIO_PROCESS, 0);
+                mPreviousSchedulingGroup = androidGetThreadSchedulingGroup(0);
+                androidSetThreadPriority(0, ANDROID_PRIORITY_AUDIO);
             }
         } else {
             mActive = 0;
@@ -346,7 +345,7 @@
 {
     sp<ClientRecordThread> t = mClientRecordThread;
 
-    LOGV("stop");
+    ALOGV("stop");
 
     if (t != 0) {
         t->mLock.lock();
@@ -363,7 +362,8 @@
         if (t != 0) {
             t->requestExit();
         } else {
-            setpriority(PRIO_PROCESS, 0, ANDROID_PRIORITY_NORMAL);
+            setpriority(PRIO_PROCESS, 0, mPreviousPriority);
+            androidSetThreadSchedulingGroup(0, mPreviousSchedulingGroup);
         }
     }
 
@@ -469,12 +469,12 @@
                                                        &status);
 
     if (record == 0) {
-        LOGE("AudioFlinger could not create record track, status: %d", status);
+        ALOGE("AudioFlinger could not create record track, status: %d", status);
         return status;
     }
     sp<IMemory> cblk = record->getCblk();
     if (cblk == 0) {
-        LOGE("Could not get control block");
+        ALOGE("Could not get control block");
         return NO_INIT;
     }
     mAudioRecord.clear();
@@ -508,11 +508,11 @@
         goto start_loop_here;
         while (framesReady == 0) {
             active = mActive;
-            if (UNLIKELY(!active)) {
+            if (CC_UNLIKELY(!active)) {
                 cblk->lock.unlock();
                 return NO_MORE_BUFFERS;
             }
-            if (UNLIKELY(!waitCount)) {
+            if (CC_UNLIKELY(!waitCount)) {
                 cblk->lock.unlock();
                 return WOULD_BLOCK;
             }
@@ -529,10 +529,10 @@
             if (cblk->flags & CBLK_INVALID_MSK) {
                 goto create_new_record;
             }
-            if (__builtin_expect(result!=NO_ERROR, false)) {
+            if (CC_UNLIKELY(result != NO_ERROR)) {
                 cblk->waitTimeMs += waitTimeMs;
                 if (cblk->waitTimeMs >= cblk->bufferTimeoutMs) {
-                    LOGW(   "obtainBuffer timed out (is the CPU pegged?) "
+                    ALOGW(   "obtainBuffer timed out (is the CPU pegged?) "
                             "user=%08x, server=%08x", cblk->user, cblk->server);
                     cblk->lock.unlock();
                     result = mAudioRecord->start();
@@ -543,7 +543,7 @@
                         result = AudioRecord::restoreRecord_l(cblk);
                     }
                     if (result != NO_ERROR) {
-                        LOGW("obtainBuffer create Track error %d", result);
+                        ALOGW("obtainBuffer create Track error %d", result);
                         cblk->lock.unlock();
                         return result;
                     }
@@ -623,7 +623,7 @@
 
     if (ssize_t(userSize) < 0) {
         // sanity-check. user is most-likely passing an error code.
-        LOGE("AudioRecord::read(buffer=%p, size=%u (%d)",
+        ALOGE("AudioRecord::read(buffer=%p, size=%u (%d)",
                 buffer, userSize, userSize);
         return BAD_VALUE;
     }
@@ -706,7 +706,7 @@
         status_t err = obtainBuffer(&audioBuffer, 1);
         if (err < NO_ERROR) {
             if (err != TIMED_OUT) {
-                LOGE_IF(err != status_t(NO_MORE_BUFFERS), "Error obtaining an audio buffer, giving up.");
+                ALOGE_IF(err != status_t(NO_MORE_BUFFERS), "Error obtaining an audio buffer, giving up.");
                 return false;
             }
             break;
@@ -739,7 +739,7 @@
 
     // Manage overrun callback
     if (mActive && (cblk->framesAvailable() == 0)) {
-        LOGV("Overrun user: %x, server: %x, flags %04x", cblk->user, cblk->server, cblk->flags);
+        ALOGV("Overrun user: %x, server: %x, flags %04x", cblk->user, cblk->server, cblk->flags);
         if (!(android_atomic_or(CBLK_UNDERRUN_ON, &cblk->flags) & CBLK_UNDERRUN_MSK)) {
             mCbf(EVENT_OVERRUN, mUserData, 0);
         }
@@ -761,7 +761,7 @@
     status_t result;
 
     if (!(android_atomic_or(CBLK_RESTORING_ON, &cblk->flags) & CBLK_RESTORING_MSK)) {
-        LOGW("dead IAudioRecord, creating a new one");
+        ALOGW("dead IAudioRecord, creating a new one");
         // signal old cblk condition so that other threads waiting for available buffers stop
         // waiting now
         cblk->cv.broadcast();
@@ -784,13 +784,13 @@
         cblk->cv.broadcast();
     } else {
         if (!(cblk->flags & CBLK_RESTORED_MSK)) {
-            LOGW("dead IAudioRecord, waiting for a new one to be created");
+            ALOGW("dead IAudioRecord, waiting for a new one to be created");
             mLock.unlock();
             result = cblk->cv.waitRelative(cblk->lock, milliseconds(RESTORE_TIMEOUT_MS));
             cblk->lock.unlock();
             mLock.lock();
         } else {
-            LOGW("dead IAudioRecord, already restored");
+            ALOGW("dead IAudioRecord, already restored");
             result = NO_ERROR;
             cblk->lock.unlock();
         }
@@ -798,7 +798,7 @@
             result = status_t(STOPPED);
         }
     }
-    LOGV("restoreRecord_l() status %d mActive %d cblk %p, old cblk %p flags %08x old flags %08x",
+    ALOGV("restoreRecord_l() status %d mActive %d cblk %p, old cblk %p flags %08x old flags %08x",
          result, mActive, mCblk, cblk, mCblk->flags, cblk->flags);
 
     if (result == NO_ERROR) {
@@ -807,7 +807,7 @@
     }
     cblk->lock.lock();
 
-    LOGW_IF(result != NO_ERROR, "restoreRecord_l() error %d", result);
+    ALOGW_IF(result != NO_ERROR, "restoreRecord_l() error %d", result);
 
     return result;
 }
diff --git a/media/libmedia/AudioSystem.cpp b/media/libmedia/AudioSystem.cpp
index 7b14c18..9d4137e 100644
--- a/media/libmedia/AudioSystem.cpp
+++ b/media/libmedia/AudioSystem.cpp
@@ -38,7 +38,7 @@
 DefaultKeyedVector<int, audio_io_handle_t> AudioSystem::gStreamOutputMap(0);
 DefaultKeyedVector<audio_io_handle_t, AudioSystem::OutputDescriptor *> AudioSystem::gOutputs(0);
 
-// Cached values for recording queries
+// Cached values for recording queries, all protected by gLock
 uint32_t AudioSystem::gPrevInSamplingRate = 16000;
 int AudioSystem::gPrevInFormat = AUDIO_FORMAT_PCM_16_BIT;
 int AudioSystem::gPrevInChannelCount = 1;
@@ -56,7 +56,7 @@
             binder = sm->getService(String16("media.audio_flinger"));
             if (binder != 0)
                 break;
-            LOGW("AudioFlinger not published, waiting...");
+            ALOGW("AudioFlinger not published, waiting...");
             usleep(500000); // 0.5 s
         } while(true);
         if (gAudioFlingerClient == NULL) {
@@ -70,7 +70,7 @@
         gAudioFlinger = interface_cast<IAudioFlinger>(binder);
         gAudioFlinger->registerClient(gAudioFlingerClient);
     }
-    LOGE_IF(gAudioFlinger==0, "no AudioFlinger!?");
+    ALOGE_IF(gAudioFlinger==0, "no AudioFlinger!?");
 
     return gAudioFlinger;
 }
@@ -158,7 +158,7 @@
 
 status_t AudioSystem::setMode(int mode)
 {
-    if (mode >= AUDIO_MODE_CNT) return BAD_VALUE;
+    if (uint32_t(mode) >= AUDIO_MODE_CNT) return BAD_VALUE;
     const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
     if (af == 0) return PERMISSION_DENIED;
     return af->setMode(mode);
@@ -190,7 +190,7 @@
 float AudioSystem::linearToLog(int volume)
 {
     // float v = volume ? exp(float(100 - volume) * dBConvert) : 0;
-    // LOGD("linearToLog(%d)=%f", volume, v);
+    // ALOGD("linearToLog(%d)=%f", volume, v);
     // return v;
     return volume ? exp(float(100 - volume) * dBConvert) : 0;
 }
@@ -198,7 +198,7 @@
 int AudioSystem::logToLinear(float volume)
 {
     // int v = volume ? 100 - int(dBConvertInverse * log(volume) + 0.5) : 0;
-    // LOGD("logTolinear(%d)=%f", v, volume);
+    // ALOGD("logTolinear(%d)=%f", v, volume);
     // return v;
     return volume ? 100 - int(dBConvertInverse * log(volume) + 0.5) : 0;
 }
@@ -220,18 +220,18 @@
     gLock.lock();
     outputDesc = AudioSystem::gOutputs.valueFor(output);
     if (outputDesc == 0) {
-        LOGV("getOutputSamplingRate() no output descriptor for output %d in gOutputs", output);
+        ALOGV("getOutputSamplingRate() no output descriptor for output %d in gOutputs", output);
         gLock.unlock();
         const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
         if (af == 0) return PERMISSION_DENIED;
         *samplingRate = af->sampleRate(output);
     } else {
-        LOGV("getOutputSamplingRate() reading from output desc");
+        ALOGV("getOutputSamplingRate() reading from output desc");
         *samplingRate = outputDesc->samplingRate;
         gLock.unlock();
     }
 
-    LOGV("getOutputSamplingRate() streamType %d, output %d, sampling rate %d", streamType, output, *samplingRate);
+    ALOGV("getOutputSamplingRate() streamType %d, output %d, sampling rate %d", streamType, output, *samplingRate);
 
     return NO_ERROR;
 }
@@ -262,7 +262,7 @@
         gLock.unlock();
     }
 
-    LOGV("getOutputFrameCount() streamType %d, output %d, frameCount %d", streamType, output, *frameCount);
+    ALOGV("getOutputFrameCount() streamType %d, output %d, frameCount %d", streamType, output, *frameCount);
 
     return NO_ERROR;
 }
@@ -293,7 +293,7 @@
         gLock.unlock();
     }
 
-    LOGV("getOutputLatency() streamType %d, output %d, latency %d", streamType, output, *latency);
+    ALOGV("getOutputLatency() streamType %d, output %d, latency %d", streamType, output, *latency);
 
     return NO_ERROR;
 }
@@ -301,22 +301,27 @@
 status_t AudioSystem::getInputBufferSize(uint32_t sampleRate, int format, int channelCount,
     size_t* buffSize)
 {
+    gLock.lock();
     // Do we have a stale gInBufferSize or are we requesting the input buffer size for new values
-    if ((gInBuffSize == 0) || (sampleRate != gPrevInSamplingRate) || (format != gPrevInFormat)
+    size_t inBuffSize = gInBuffSize;
+    if ((inBuffSize == 0) || (sampleRate != gPrevInSamplingRate) || (format != gPrevInFormat)
         || (channelCount != gPrevInChannelCount)) {
+        gLock.unlock();
+        const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
+        if (af == 0) {
+            return PERMISSION_DENIED;
+        }
+        inBuffSize = af->getInputBufferSize(sampleRate, format, channelCount);
+        gLock.lock();
         // save the request params
         gPrevInSamplingRate = sampleRate;
         gPrevInFormat = format;
         gPrevInChannelCount = channelCount;
 
-        gInBuffSize = 0;
-        const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
-        if (af == 0) {
-            return PERMISSION_DENIED;
-        }
-        gInBuffSize = af->getInputBufferSize(sampleRate, format, channelCount);
+        gInBuffSize = inBuffSize;
     }
-    *buffSize = gInBuffSize;
+    gLock.unlock();
+    *buffSize = inBuffSize;
 
     return NO_ERROR;
 }
@@ -383,11 +388,11 @@
     if (gAudioErrorCallback) {
         gAudioErrorCallback(DEAD_OBJECT);
     }
-    LOGW("AudioFlinger server died!");
+    ALOGW("AudioFlinger server died!");
 }
 
 void AudioSystem::AudioFlingerClient::ioConfigChanged(int event, int ioHandle, void *param2) {
-    LOGV("ioConfigChanged() event %d", event);
+    ALOGV("ioConfigChanged() event %d", event);
     OutputDescriptor *desc;
     uint32_t stream;
 
@@ -399,14 +404,14 @@
     case STREAM_CONFIG_CHANGED:
         if (param2 == 0) break;
         stream = *(uint32_t *)param2;
-        LOGV("ioConfigChanged() STREAM_CONFIG_CHANGED stream %d, output %d", stream, ioHandle);
+        ALOGV("ioConfigChanged() STREAM_CONFIG_CHANGED stream %d, output %d", stream, ioHandle);
         if (gStreamOutputMap.indexOfKey(stream) >= 0) {
             gStreamOutputMap.replaceValueFor(stream, ioHandle);
         }
         break;
     case OUTPUT_OPENED: {
         if (gOutputs.indexOfKey(ioHandle) >= 0) {
-            LOGV("ioConfigChanged() opening already existing output! %d", ioHandle);
+            ALOGV("ioConfigChanged() opening already existing output! %d", ioHandle);
             break;
         }
         if (param2 == 0) break;
@@ -414,15 +419,15 @@
 
         OutputDescriptor *outputDesc =  new OutputDescriptor(*desc);
         gOutputs.add(ioHandle, outputDesc);
-        LOGV("ioConfigChanged() new output samplingRate %d, format %d channels %d frameCount %d latency %d",
+        ALOGV("ioConfigChanged() new output samplingRate %d, format %d channels %d frameCount %d latency %d",
                 outputDesc->samplingRate, outputDesc->format, outputDesc->channels, outputDesc->frameCount, outputDesc->latency);
         } break;
     case OUTPUT_CLOSED: {
         if (gOutputs.indexOfKey(ioHandle) < 0) {
-            LOGW("ioConfigChanged() closing unknow output! %d", ioHandle);
+            ALOGW("ioConfigChanged() closing unknow output! %d", ioHandle);
             break;
         }
-        LOGV("ioConfigChanged() output %d closed", ioHandle);
+        ALOGV("ioConfigChanged() output %d closed", ioHandle);
 
         gOutputs.removeItem(ioHandle);
         for (int i = gStreamOutputMap.size() - 1; i >= 0 ; i--) {
@@ -435,13 +440,13 @@
     case OUTPUT_CONFIG_CHANGED: {
         int index = gOutputs.indexOfKey(ioHandle);
         if (index < 0) {
-            LOGW("ioConfigChanged() modifying unknow output! %d", ioHandle);
+            ALOGW("ioConfigChanged() modifying unknow output! %d", ioHandle);
             break;
         }
         if (param2 == 0) break;
         desc = (OutputDescriptor *)param2;
 
-        LOGV("ioConfigChanged() new config for output %d samplingRate %d, format %d channels %d frameCount %d latency %d",
+        ALOGV("ioConfigChanged() new config for output %d samplingRate %d, format %d channels %d frameCount %d latency %d",
                 ioHandle, desc->samplingRate, desc->format,
                 desc->channels, desc->frameCount, desc->latency);
         OutputDescriptor *outputDesc = gOutputs.valueAt(index);
@@ -491,7 +496,7 @@
             binder = sm->getService(String16("media.audio_policy"));
             if (binder != 0)
                 break;
-            LOGW("AudioPolicyService not published, waiting...");
+            ALOGW("AudioPolicyService not published, waiting...");
             usleep(500000); // 0.5 s
         } while(true);
         if (gAudioPolicyServiceClient == NULL) {
@@ -582,7 +587,7 @@
          (samplingRate != 8000 && samplingRate != 16000))) {
         Mutex::Autolock _l(gLock);
         output = AudioSystem::gStreamOutputMap.valueFor(stream);
-        LOGV_IF((output != 0), "getOutput() read %d from cache for stream %d", output, stream);
+        ALOGV_IF((output != 0), "getOutput() read %d from cache for stream %d", output, stream);
     }
     if (output == 0) {
         const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
@@ -736,7 +741,7 @@
 void AudioSystem::clearAudioConfigCache()
 {
     Mutex::Autolock _l(gLock);
-    LOGV("clearAudioConfigCache()");
+    ALOGV("clearAudioConfigCache()");
     gStreamOutputMap.clear();
     gOutputs.clear();
 }
@@ -747,7 +752,7 @@
     Mutex::Autolock _l(AudioSystem::gLock);
     AudioSystem::gAudioPolicyService.clear();
 
-    LOGW("AudioPolicyService server died!");
+    ALOGW("AudioPolicyService server died!");
 }
 
 }; // namespace android
diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp
index 8ebb652..9c650ad 100644
--- a/media/libmedia/AudioTrack.cpp
+++ b/media/libmedia/AudioTrack.cpp
@@ -1,4 +1,4 @@
-/* //device/extlibs/pv/android/AudioTrack.cpp
+/* frameworks/base/media/libmedia/AudioTrack.cpp
 **
 ** Copyright 2007, The Android Open Source Project
 **
@@ -38,13 +38,11 @@
 #include <utils/Atomic.h>
 
 #include <cutils/bitops.h>
+#include <cutils/compiler.h>
 
 #include <system/audio.h>
 #include <system/audio_policy.h>
 
-#define LIKELY( exp )       (__builtin_expect( (exp) != 0, true  ))
-#define UNLIKELY( exp )     (__builtin_expect( (exp) != 0, false ))
-
 namespace android {
 // ---------------------------------------------------------------------------
 
@@ -79,14 +77,15 @@
 // ---------------------------------------------------------------------------
 
 AudioTrack::AudioTrack()
-    : mStatus(NO_INIT)
+    : mStatus(NO_INIT),
+      mPreviousPriority(ANDROID_PRIORITY_NORMAL), mPreviousSchedulingGroup(ANDROID_TGROUP_DEFAULT)
 {
 }
 
 AudioTrack::AudioTrack(
         int streamType,
         uint32_t sampleRate,
-        int format,
+        audio_format_t format,
         int channelMask,
         int frameCount,
         uint32_t flags,
@@ -94,7 +93,8 @@
         void* user,
         int notificationFrames,
         int sessionId)
-    : mStatus(NO_INIT)
+    : mStatus(NO_INIT),
+      mPreviousPriority(ANDROID_PRIORITY_NORMAL), mPreviousSchedulingGroup(ANDROID_TGROUP_DEFAULT)
 {
     mStatus = set(streamType, sampleRate, format, channelMask,
             frameCount, flags, cbf, user, notificationFrames,
@@ -104,7 +104,7 @@
 AudioTrack::AudioTrack(
         int streamType,
         uint32_t sampleRate,
-        int format,
+        audio_format_t format,
         int channelMask,
         const sp<IMemory>& sharedBuffer,
         uint32_t flags,
@@ -112,7 +112,8 @@
         void* user,
         int notificationFrames,
         int sessionId)
-    : mStatus(NO_INIT)
+    : mStatus(NO_INIT),
+      mPreviousPriority(ANDROID_PRIORITY_NORMAL), mPreviousSchedulingGroup(ANDROID_TGROUP_DEFAULT)
 {
     mStatus = set(streamType, sampleRate, format, channelMask,
             0, flags, cbf, user, notificationFrames,
@@ -121,7 +122,7 @@
 
 AudioTrack::~AudioTrack()
 {
-    LOGV_IF(mSharedBuffer != 0, "Destructor sharedBuffer: %p", mSharedBuffer->pointer());
+    ALOGV_IF(mSharedBuffer != 0, "Destructor sharedBuffer: %p", mSharedBuffer->pointer());
 
     if (mStatus == NO_ERROR) {
         // Make sure that callback function exits in the case where
@@ -141,7 +142,7 @@
 status_t AudioTrack::set(
         int streamType,
         uint32_t sampleRate,
-        int format,
+        audio_format_t format,
         int channelMask,
         int frameCount,
         uint32_t flags,
@@ -153,11 +154,11 @@
         int sessionId)
 {
 
-    LOGV_IF(sharedBuffer != 0, "sharedBuffer: %p, size: %d", sharedBuffer->pointer(), sharedBuffer->size());
+    ALOGV_IF(sharedBuffer != 0, "sharedBuffer: %p, size: %d", sharedBuffer->pointer(), sharedBuffer->size());
 
     AutoMutex lock(mLock);
     if (mAudioTrack != 0) {
-        LOGE("Track already in use");
+        ALOGE("Track already in use");
         return INVALID_OPERATION;
     }
 
@@ -178,7 +179,7 @@
         sampleRate = afSampleRate;
     }
     // these below should probably come from the audioFlinger too...
-    if (format == 0) {
+    if (format == AUDIO_FORMAT_DEFAULT) {
         format = AUDIO_FORMAT_PCM_16_BIT;
     }
     if (channelMask == 0) {
@@ -187,7 +188,7 @@
 
     // validate parameters
     if (!audio_is_valid_format(format)) {
-        LOGE("Invalid format");
+        ALOGE("Invalid format");
         return BAD_VALUE;
     }
 
@@ -197,18 +198,18 @@
     }
 
     if (!audio_is_output_channel(channelMask)) {
-        LOGE("Invalid channel mask");
+        ALOGE("Invalid channel mask");
         return BAD_VALUE;
     }
     uint32_t channelCount = popcount(channelMask);
 
     audio_io_handle_t output = AudioSystem::getOutput(
                                     (audio_stream_type_t)streamType,
-                                    sampleRate,format, channelMask,
+                                    sampleRate, format, channelMask,
                                     (audio_policy_output_flags_t)flags);
 
     if (output == 0) {
-        LOGE("Could not get audio output for stream type %d", streamType);
+        ALOGE("Could not get audio output for stream type %d", streamType);
         return BAD_VALUE;
     }
 
@@ -223,7 +224,7 @@
     // create the IAudioTrack
     status_t status = createTrack_l(streamType,
                                   sampleRate,
-                                  (uint32_t)format,
+                                  format,
                                   (uint32_t)channelMask,
                                   frameCount,
                                   flags,
@@ -237,21 +238,17 @@
 
     if (cbf != 0) {
         mAudioTrackThread = new AudioTrackThread(*this, threadCanCallJava);
-        if (mAudioTrackThread == 0) {
-          LOGE("Could not create callback thread");
-          return NO_INIT;
-        }
     }
 
     mStatus = NO_ERROR;
 
     mStreamType = streamType;
-    mFormat = (uint32_t)format;
+    mFormat = format;
     mChannelMask = (uint32_t)channelMask;
     mChannelCount = channelCount;
     mSharedBuffer = sharedBuffer;
     mMuted = false;
-    mActive = 0;
+    mActive = false;
     mCbf = cbf;
     mUserData = user;
     mLoopCount = 0;
@@ -283,7 +280,7 @@
     return mStreamType;
 }
 
-int AudioTrack::format() const
+audio_format_t AudioTrack::format() const
 {
     return mFormat;
 }
@@ -319,11 +316,11 @@
     sp<AudioTrackThread> t = mAudioTrackThread;
     status_t status = NO_ERROR;
 
-    LOGV("start %p", this);
+    ALOGV("start %p", this);
     if (t != 0) {
         if (t->exitPending()) {
             if (t->requestExitAndWait() == WOULD_BLOCK) {
-                LOGE("AudioTrack::start called from thread");
+                ALOGE("AudioTrack::start called from thread");
                 return;
             }
         }
@@ -337,21 +334,23 @@
     sp <IMemory> iMem = mCblkMemory;
     audio_track_cblk_t* cblk = mCblk;
 
-    if (mActive == 0) {
+    if (!mActive) {
         mFlushed = false;
-        mActive = 1;
+        mActive = true;
         mNewPosition = cblk->server + mUpdatePeriod;
         cblk->lock.lock();
         cblk->bufferTimeoutMs = MAX_STARTUP_TIMEOUT_MS;
         cblk->waitTimeMs = 0;
         android_atomic_and(~CBLK_DISABLED_ON, &cblk->flags);
         if (t != 0) {
-           t->run("AudioTrackThread", ANDROID_PRIORITY_AUDIO);
+            t->run("AudioTrackThread", ANDROID_PRIORITY_AUDIO);
         } else {
-            setpriority(PRIO_PROCESS, 0, ANDROID_PRIORITY_AUDIO);
+            mPreviousPriority = getpriority(PRIO_PROCESS, 0);
+            mPreviousSchedulingGroup = androidGetThreadSchedulingGroup(0);
+            androidSetThreadPriority(0, ANDROID_PRIORITY_AUDIO);
         }
 
-        LOGV("start %p before lock cblk %p", this, mCblk);
+        ALOGV("start %p before lock cblk %p", this, mCblk);
         if (!(cblk->flags & CBLK_INVALID_MSK)) {
             cblk->lock.unlock();
             status = mAudioTrack->start();
@@ -365,12 +364,13 @@
         }
         cblk->lock.unlock();
         if (status != NO_ERROR) {
-            LOGV("start() failed");
-            mActive = 0;
+            ALOGV("start() failed");
+            mActive = false;
             if (t != 0) {
                 t->requestExit();
             } else {
-                setpriority(PRIO_PROCESS, 0, ANDROID_PRIORITY_NORMAL);
+                setpriority(PRIO_PROCESS, 0, mPreviousPriority);
+                androidSetThreadSchedulingGroup(0, mPreviousSchedulingGroup);
             }
         }
     }
@@ -384,14 +384,14 @@
 {
     sp<AudioTrackThread> t = mAudioTrackThread;
 
-    LOGV("stop %p", this);
+    ALOGV("stop %p", this);
     if (t != 0) {
         t->mLock.lock();
     }
 
     AutoMutex lock(mLock);
-    if (mActive == 1) {
-        mActive = 0;
+    if (mActive) {
+        mActive = false;
         mCblk->cv.signal();
         mAudioTrack->stop();
         // Cancel loops (If we are in the middle of a loop, playback
@@ -408,7 +408,8 @@
         if (t != 0) {
             t->requestExit();
         } else {
-            setpriority(PRIO_PROCESS, 0, ANDROID_PRIORITY_NORMAL);
+            setpriority(PRIO_PROCESS, 0, mPreviousPriority);
+            androidSetThreadSchedulingGroup(0, mPreviousSchedulingGroup);
         }
     }
 
@@ -419,7 +420,8 @@
 
 bool AudioTrack::stopped() const
 {
-    return !mActive;
+    AutoMutex lock(mLock);
+    return stopped_l();
 }
 
 void AudioTrack::flush()
@@ -431,7 +433,7 @@
 // must be called with mLock held
 void AudioTrack::flush_l()
 {
-    LOGV("flush");
+    ALOGV("flush");
 
     // clear playback marker and periodic update counter
     mMarkerPosition = 0;
@@ -449,10 +451,10 @@
 
 void AudioTrack::pause()
 {
-    LOGV("pause");
+    ALOGV("pause");
     AutoMutex lock(mLock);
-    if (mActive == 1) {
-        mActive = 0;
+    if (mActive) {
+        mActive = false;
         mAudioTrack->pause();
     }
 }
@@ -470,7 +472,7 @@
 
 status_t AudioTrack::setVolume(float left, float right)
 {
-    if (left > 1.0f || right > 1.0f) {
+    if (left < 0.0f || left > 1.0f || right < 0.0f || right > 1.0f) {
         return BAD_VALUE;
     }
 
@@ -496,7 +498,7 @@
 
 status_t AudioTrack::setAuxEffectSendLevel(float level)
 {
-    LOGV("setAuxEffectSendLevel(%f)", level);
+    ALOGV("setAuxEffectSendLevel(%f)", level);
     if (level > 1.0f) {
         return BAD_VALUE;
     }
@@ -561,12 +563,12 @@
     if (loopStart >= loopEnd ||
         loopEnd - loopStart > cblk->frameCount ||
         cblk->server > loopStart) {
-        LOGE("setLoop invalid value: loopStart %d, loopEnd %d, loopCount %d, framecount %d, user %d", loopStart, loopEnd, loopCount, cblk->frameCount, cblk->user);
+        ALOGE("setLoop invalid value: loopStart %d, loopEnd %d, loopCount %d, framecount %d, user %d", loopStart, loopEnd, loopCount, cblk->frameCount, cblk->user);
         return BAD_VALUE;
     }
 
     if ((mSharedBuffer != 0) && (loopEnd > cblk->frameCount)) {
-        LOGE("setLoop invalid value: loop markers beyond data: loopStart %d, loopEnd %d, framecount %d",
+        ALOGE("setLoop invalid value: loop markers beyond data: loopStart %d, loopEnd %d, framecount %d",
             loopStart, loopEnd, cblk->frameCount);
         return BAD_VALUE;
     }
@@ -642,9 +644,10 @@
 status_t AudioTrack::setPosition(uint32_t position)
 {
     AutoMutex lock(mLock);
-    Mutex::Autolock _l(mCblk->lock);
 
-    if (!stopped()) return INVALID_OPERATION;
+    if (!stopped_l()) return INVALID_OPERATION;
+
+    Mutex::Autolock _l(mCblk->lock);
 
     if (position > mCblk->user) return BAD_VALUE;
 
@@ -667,7 +670,7 @@
 {
     AutoMutex lock(mLock);
 
-    if (!stopped()) return INVALID_OPERATION;
+    if (!stopped_l()) return INVALID_OPERATION;
 
     flush_l();
 
@@ -696,7 +699,7 @@
 
 status_t AudioTrack::attachAuxEffect(int effectId)
 {
-    LOGV("attachAuxEffect(%d)", effectId);
+    ALOGV("attachAuxEffect(%d)", effectId);
     status_t status = mAudioTrack->attachAuxEffect(effectId);
     if (status == NO_ERROR) {
         mAuxEffectId = effectId;
@@ -710,7 +713,7 @@
 status_t AudioTrack::createTrack_l(
         int streamType,
         uint32_t sampleRate,
-        uint32_t format,
+        audio_format_t format,
         uint32_t channelMask,
         int frameCount,
         uint32_t flags,
@@ -721,7 +724,7 @@
     status_t status;
     const sp<IAudioFlinger>& audioFlinger = AudioSystem::get_audio_flinger();
     if (audioFlinger == 0) {
-       LOGE("Could not get audioflinger");
+       ALOGE("Could not get audioflinger");
        return NO_INIT;
     }
 
@@ -764,7 +767,7 @@
             }
             if (frameCount < minFrameCount) {
                 if (enforceFrameCount) {
-                    LOGE("Invalid buffer size: minFrameCount %d, frameCount %d", minFrameCount, frameCount);
+                    ALOGE("Invalid buffer size: minFrameCount %d, frameCount %d", minFrameCount, frameCount);
                     return BAD_VALUE;
                 } else {
                     frameCount = minFrameCount;
@@ -774,7 +777,7 @@
             // Ensure that buffer alignment matches channelcount
             int channelCount = popcount(channelMask);
             if (((uint32_t)sharedBuffer->pointer() & (channelCount | 1)) != 0) {
-                LOGE("Invalid buffer alignement: address %p, channelCount %d", sharedBuffer->pointer(), channelCount);
+                ALOGE("Invalid buffer alignement: address %p, channelCount %d", sharedBuffer->pointer(), channelCount);
                 return BAD_VALUE;
             }
             frameCount = sharedBuffer->size()/channelCount/sizeof(int16_t);
@@ -794,17 +797,15 @@
                                                       &status);
 
     if (track == 0) {
-        LOGE("AudioFlinger could not create track, status: %d", status);
+        ALOGE("AudioFlinger could not create track, status: %d", status);
         return status;
     }
     sp<IMemory> cblk = track->getCblk();
     if (cblk == 0) {
-        LOGE("Could not get control block");
+        ALOGE("Could not get control block");
         return NO_INIT;
     }
-    mAudioTrack.clear();
     mAudioTrack = track;
-    mCblkMemory.clear();
     mCblkMemory = cblk;
     mCblk = static_cast<audio_track_cblk_t*>(cblk->pointer());
     android_atomic_or(CBLK_DIRECTION_OUT, &mCblk->flags);
@@ -829,7 +830,7 @@
 status_t AudioTrack::obtainBuffer(Buffer* audioBuffer, int32_t waitCount)
 {
     AutoMutex lock(mLock);
-    int active;
+    bool active;
     status_t result = NO_ERROR;
     audio_track_cblk_t* cblk = mCblk;
     uint32_t framesReq = audioBuffer->frameCount;
@@ -851,12 +852,12 @@
         goto start_loop_here;
         while (framesAvail == 0) {
             active = mActive;
-            if (UNLIKELY(!active)) {
-                LOGV("Not active and NO_MORE_BUFFERS");
+            if (CC_UNLIKELY(!active)) {
+                ALOGV("Not active and NO_MORE_BUFFERS");
                 cblk->lock.unlock();
                 return NO_MORE_BUFFERS;
             }
-            if (UNLIKELY(!waitCount)) {
+            if (CC_UNLIKELY(!waitCount)) {
                 cblk->lock.unlock();
                 return WOULD_BLOCK;
             }
@@ -865,7 +866,7 @@
                 result = cblk->cv.waitRelative(cblk->lock, milliseconds(waitTimeMs));
                 cblk->lock.unlock();
                 mLock.lock();
-                if (mActive == 0) {
+                if (!mActive) {
                     return status_t(STOPPED);
                 }
                 cblk->lock.lock();
@@ -874,13 +875,13 @@
             if (cblk->flags & CBLK_INVALID_MSK) {
                 goto create_new_track;
             }
-            if (__builtin_expect(result!=NO_ERROR, false)) {
+            if (CC_UNLIKELY(result != NO_ERROR)) {
                 cblk->waitTimeMs += waitTimeMs;
                 if (cblk->waitTimeMs >= cblk->bufferTimeoutMs) {
                     // timing out when a loop has been set and we have already written upto loop end
                     // is a normal condition: no need to wake AudioFlinger up.
                     if (cblk->user < cblk->loopEnd) {
-                        LOGW(   "obtainBuffer timed out (is the CPU pegged?) %p "
+                        ALOGW(   "obtainBuffer timed out (is the CPU pegged?) %p "
                                 "user=%08x, server=%08x", this, cblk->user, cblk->server);
                         //unlock cblk mutex before calling mAudioTrack->start() (see issue #1617140)
                         cblk->lock.unlock();
@@ -892,7 +893,7 @@
                             result = restoreTrack_l(cblk, false);
                         }
                         if (result != NO_ERROR) {
-                            LOGW("obtainBuffer create Track error %d", result);
+                            ALOGW("obtainBuffer create Track error %d", result);
                             cblk->lock.unlock();
                             return result;
                         }
@@ -915,7 +916,7 @@
     // restart track if it was disabled by audioflinger due to previous underrun
     if (mActive && (cblk->flags & CBLK_DISABLED_MSK)) {
         android_atomic_and(~CBLK_DISABLED_ON, &cblk->flags);
-        LOGW("obtainBuffer() track %p disabled, restarting", this);
+        ALOGW("obtainBuffer() track %p disabled, restarting", this);
         mAudioTrack->start();
     }
 
@@ -961,12 +962,12 @@
 
     if (ssize_t(userSize) < 0) {
         // sanity-check. user is most-likely passing an error code.
-        LOGE("AudioTrack::write(buffer=%p, size=%u (%d)",
+        ALOGE("AudioTrack::write(buffer=%p, size=%u (%d)",
                 buffer, userSize, userSize);
         return BAD_VALUE;
     }
 
-    LOGV("write %p: %d bytes, mActive=%d", this, userSize, mActive);
+    ALOGV("write %p: %d bytes, mActive=%d", this, userSize, mActive);
 
     // acquire a strong reference on the IMemory and IAudioTrack so that they cannot be destroyed
     // while we are accessing the cblk
@@ -1032,11 +1033,12 @@
     sp <IAudioTrack> audioTrack = mAudioTrack;
     sp <IMemory> iMem = mCblkMemory;
     audio_track_cblk_t* cblk = mCblk;
+    bool active = mActive;
     mLock.unlock();
 
     // Manage underrun callback
-    if (mActive && (cblk->framesAvailable() == cblk->frameCount)) {
-        LOGV("Underrun user: %x, server: %x, flags %04x", cblk->user, cblk->server, cblk->flags);
+    if (active && (cblk->framesAvailable() == cblk->frameCount)) {
+        ALOGV("Underrun user: %x, server: %x, flags %04x", cblk->user, cblk->server, cblk->flags);
         if (!(android_atomic_or(CBLK_UNDERRUN_ON, &cblk->flags) & CBLK_UNDERRUN_MSK)) {
             mCbf(EVENT_UNDERRUN, mUserData, 0);
             if (cblk->server == cblk->frameCount) {
@@ -1093,7 +1095,7 @@
         status_t err = obtainBuffer(&audioBuffer, waitCount);
         if (err < NO_ERROR) {
             if (err != TIMED_OUT) {
-                LOGE_IF(err != status_t(NO_MORE_BUFFERS), "Error obtaining an audio buffer, giving up.");
+                ALOGE_IF(err != status_t(NO_MORE_BUFFERS), "Error obtaining an audio buffer, giving up.");
                 return false;
             }
             break;
@@ -1161,7 +1163,7 @@
     status_t result;
 
     if (!(android_atomic_or(CBLK_RESTORING_ON, &cblk->flags) & CBLK_RESTORING_MSK)) {
-        LOGW("dead IAudioTrack, creating a new one from %s TID %d",
+        ALOGW("dead IAudioTrack, creating a new one from %s TID %d",
              fromStart ? "start()" : "obtainBuffer()", gettid());
 
         // signal old cblk condition so that other threads waiting for available buffers stop
@@ -1217,7 +1219,7 @@
             }
             if (mActive) {
                 result = mAudioTrack->start();
-                LOGW_IF(result != NO_ERROR, "restoreTrack_l() start() failed status %d", result);
+                ALOGW_IF(result != NO_ERROR, "restoreTrack_l() start() failed status %d", result);
             }
             if (fromStart && result == NO_ERROR) {
                 mNewPosition = mCblk->server + mUpdatePeriod;
@@ -1225,7 +1227,7 @@
         }
         if (result != NO_ERROR) {
             android_atomic_and(~CBLK_RESTORING_ON, &cblk->flags);
-            LOGW_IF(result != NO_ERROR, "restoreTrack_l() failed status %d", result);
+            ALOGW_IF(result != NO_ERROR, "restoreTrack_l() failed status %d", result);
         }
         mRestoreStatus = result;
         // signal old cblk condition for other threads waiting for restore completion
@@ -1233,7 +1235,7 @@
         cblk->cv.broadcast();
     } else {
         if (!(cblk->flags & CBLK_RESTORED_MSK)) {
-            LOGW("dead IAudioTrack, waiting for a new one TID %d", gettid());
+            ALOGW("dead IAudioTrack, waiting for a new one TID %d", gettid());
             mLock.unlock();
             result = cblk->cv.waitRelative(cblk->lock, milliseconds(RESTORE_TIMEOUT_MS));
             if (result == NO_ERROR) {
@@ -1242,12 +1244,12 @@
             cblk->lock.unlock();
             mLock.lock();
         } else {
-            LOGW("dead IAudioTrack, already restored TID %d", gettid());
+            ALOGW("dead IAudioTrack, already restored TID %d", gettid());
             result = mRestoreStatus;
             cblk->lock.unlock();
         }
     }
-    LOGV("restoreTrack_l() status %d mActive %d cblk %p, old cblk %p flags %08x old flags %08x",
+    ALOGV("restoreTrack_l() status %d mActive %d cblk %p, old cblk %p flags %08x old flags %08x",
          result, mActive, mCblk, cblk, mCblk->flags, cblk->flags);
 
     if (result == NO_ERROR) {
@@ -1256,7 +1258,7 @@
     }
     cblk->lock.lock();
 
-    LOGW_IF(result != NO_ERROR, "restoreTrack_l() error %d TID %d", result, gettid());
+    ALOGW_IF(result != NO_ERROR, "restoreTrack_l() error %d TID %d", result, gettid());
 
     return result;
 }
@@ -1315,7 +1317,7 @@
 
 uint32_t audio_track_cblk_t::stepUser(uint32_t frameCount)
 {
-    uint32_t u = this->user;
+    uint32_t u = user;
 
     u += frameCount;
     // Ensure that user is never ahead of server for AudioRecord
@@ -1324,16 +1326,16 @@
         if (bufferTimeoutMs == MAX_STARTUP_TIMEOUT_MS-1) {
             bufferTimeoutMs = MAX_RUN_TIMEOUT_MS;
         }
-    } else if (u > this->server) {
-        LOGW("stepServer occured after track reset");
-        u = this->server;
+    } else if (u > server) {
+        ALOGW("stepServer occurred after track reset");
+        u = server;
     }
 
     if (u >= userBase + this->frameCount) {
         userBase += this->frameCount;
     }
 
-    this->user = u;
+    user = u;
 
     // Clear flow control error condition as new data has been written/read to/from buffer.
     if (flags & CBLK_UNDERRUN_MSK) {
@@ -1346,11 +1348,11 @@
 bool audio_track_cblk_t::stepServer(uint32_t frameCount)
 {
     if (!tryLock()) {
-        LOGW("stepServer() could not lock cblk");
+        ALOGW("stepServer() could not lock cblk");
         return false;
     }
 
-    uint32_t s = this->server;
+    uint32_t s = server;
 
     s += frameCount;
     if (flags & CBLK_DIRECTION_MSK) {
@@ -1363,14 +1365,14 @@
         // while the mixer is processing a block: in this case,
         // stepServer() is called After the flush() has reset u & s and
         // we have s > u
-        if (s > this->user) {
-            LOGW("stepServer occured after track reset");
-            s = this->user;
+        if (s > user) {
+            ALOGW("stepServer occurred after track reset");
+            s = user;
         }
     }
 
     if (s >= loopEnd) {
-        LOGW_IF(s > loopEnd, "stepServer: s %u > loopEnd %u", s, loopEnd);
+        ALOGW_IF(s > loopEnd, "stepServer: s %u > loopEnd %u", s, loopEnd);
         s = loopStart;
         if (--loopCount == 0) {
             loopEnd = UINT_MAX;
@@ -1381,7 +1383,7 @@
         serverBase += this->frameCount;
     }
 
-    this->server = s;
+    server = s;
 
     if (!(flags & CBLK_INVALID_MSK)) {
         cv.signal();
@@ -1392,7 +1394,7 @@
 
 void* audio_track_cblk_t::buffer(uint32_t offset) const
 {
-    return (int8_t *)this->buffers + (offset - userBase) * this->frameSize;
+    return (int8_t *)buffers + (offset - userBase) * frameSize;
 }
 
 uint32_t audio_track_cblk_t::framesAvailable()
@@ -1403,8 +1405,8 @@
 
 uint32_t audio_track_cblk_t::framesAvailable_l()
 {
-    uint32_t u = this->user;
-    uint32_t s = this->server;
+    uint32_t u = user;
+    uint32_t s = server;
 
     if (flags & CBLK_DIRECTION_MSK) {
         uint32_t limit = (s < loopStart) ? s : loopStart;
@@ -1416,8 +1418,8 @@
 
 uint32_t audio_track_cblk_t::framesReady()
 {
-    uint32_t u = this->user;
-    uint32_t s = this->server;
+    uint32_t u = user;
+    uint32_t s = server;
 
     if (flags & CBLK_DIRECTION_MSK) {
         if (u < loopEnd) {
@@ -1425,7 +1427,7 @@
         } else {
             // do not block on mutex shared with client on AudioFlinger side
             if (!tryLock()) {
-                LOGW("framesReady() could not lock cblk");
+                ALOGW("framesReady() could not lock cblk");
                 return 0;
             }
             uint32_t frames = UINT_MAX;
@@ -1462,4 +1464,3 @@
 // -------------------------------------------------------------------------
 
 }; // namespace android
-
diff --git a/media/libmedia/IAudioFlinger.cpp b/media/libmedia/IAudioFlinger.cpp
index d58834b..abd491f 100644
--- a/media/libmedia/IAudioFlinger.cpp
+++ b/media/libmedia/IAudioFlinger.cpp
@@ -112,7 +112,7 @@
         data.writeInt32(lSessionId);
         status_t lStatus = remote()->transact(CREATE_TRACK, data, &reply);
         if (lStatus != NO_ERROR) {
-            LOGE("createTrack error: %s", strerror(-lStatus));
+            ALOGE("createTrack error: %s", strerror(-lStatus));
         } else {
             lSessionId = reply.readInt32();
             if (sessionId != NULL) {
@@ -155,7 +155,7 @@
         data.writeInt32(lSessionId);
         status_t lStatus = remote()->transact(OPEN_RECORD, data, &reply);
         if (lStatus != NO_ERROR) {
-            LOGE("openRecord error: %s", strerror(-lStatus));
+            ALOGE("openRecord error: %s", strerror(-lStatus));
         } else {
             lSessionId = reply.readInt32();
             if (sessionId != NULL) {
@@ -377,7 +377,7 @@
         data.writeInt32(flags);
         remote()->transact(OPEN_OUTPUT, data, &reply);
         int  output = reply.readInt32();
-        LOGV("openOutput() returned output, %p", output);
+        ALOGV("openOutput() returned output, %p", output);
         devices = reply.readInt32();
         if (pDevices) *pDevices = devices;
         samplingRate = reply.readInt32();
@@ -632,7 +632,7 @@
 
         status_t lStatus = remote()->transact(CREATE_EFFECT, data, &reply);
         if (lStatus != NO_ERROR) {
-            LOGE("createEffect error: %s", strerror(-lStatus));
+            ALOGE("createEffect error: %s", strerror(-lStatus));
         } else {
             lStatus = reply.readInt32();
             int tmp = reply.readInt32();
@@ -844,7 +844,7 @@
                                      &channels,
                                      &latency,
                                      flags);
-            LOGV("OPEN_OUTPUT output, %p", output);
+            ALOGV("OPEN_OUTPUT output, %p", output);
             reply->writeInt32(output);
             reply->writeInt32(devices);
             reply->writeInt32(samplingRate);
diff --git a/media/libmedia/IAudioFlingerClient.cpp b/media/libmedia/IAudioFlingerClient.cpp
index 3900de4..5a3f250 100644
--- a/media/libmedia/IAudioFlingerClient.cpp
+++ b/media/libmedia/IAudioFlingerClient.cpp
@@ -47,7 +47,7 @@
         data.writeInt32(ioHandle);
         if (event == AudioSystem::STREAM_CONFIG_CHANGED) {
             uint32_t stream = *(uint32_t *)param2;
-            LOGV("ioConfigChanged stream %d", stream);
+            ALOGV("ioConfigChanged stream %d", stream);
             data.writeInt32(stream);
         } else if (event != AudioSystem::OUTPUT_CLOSED && event != AudioSystem::INPUT_CLOSED) {
             AudioSystem::OutputDescriptor *desc = (AudioSystem::OutputDescriptor *)param2;
@@ -79,7 +79,7 @@
             if (event == AudioSystem::STREAM_CONFIG_CHANGED) {
                 stream = data.readInt32();
                 param2 = &stream;
-                LOGV("STREAM_CONFIG_CHANGED stream %d", stream);
+                ALOGV("STREAM_CONFIG_CHANGED stream %d", stream);
             } else if (event != AudioSystem::OUTPUT_CLOSED && event != AudioSystem::INPUT_CLOSED) {
                 desc.samplingRate = data.readInt32();
                 desc.format = data.readInt32();
diff --git a/media/libmedia/IAudioRecord.cpp b/media/libmedia/IAudioRecord.cpp
index ba0d55b..8c7a960 100644
--- a/media/libmedia/IAudioRecord.cpp
+++ b/media/libmedia/IAudioRecord.cpp
@@ -50,7 +50,7 @@
         if (status == NO_ERROR) {
             status = reply.readInt32();
         } else {
-            LOGW("start() error: %s", strerror(-status));
+            ALOGW("start() error: %s", strerror(-status));
         }
         return status;
     }
diff --git a/media/libmedia/IAudioTrack.cpp b/media/libmedia/IAudioTrack.cpp
index bc8ff34..e618619 100644
--- a/media/libmedia/IAudioTrack.cpp
+++ b/media/libmedia/IAudioTrack.cpp
@@ -46,6 +46,18 @@
     {
     }
     
+    virtual sp<IMemory> getCblk() const
+    {
+        Parcel data, reply;
+        sp<IMemory> cblk;
+        data.writeInterfaceToken(IAudioTrack::getInterfaceDescriptor());
+        status_t status = remote()->transact(GET_CBLK, data, &reply);
+        if (status == NO_ERROR) {
+            cblk = interface_cast<IMemory>(reply.readStrongBinder());
+        }
+        return cblk;
+    }
+
     virtual status_t start()
     {
         Parcel data, reply;
@@ -54,7 +66,7 @@
         if (status == NO_ERROR) {
             status = reply.readInt32();
         } else {
-            LOGW("start() error: %s", strerror(-status));
+            ALOGW("start() error: %s", strerror(-status));
         }
         return status;
     }
@@ -88,18 +100,6 @@
         remote()->transact(PAUSE, data, &reply);
     }
     
-    virtual sp<IMemory> getCblk() const
-    {
-        Parcel data, reply;
-        sp<IMemory> cblk;
-        data.writeInterfaceToken(IAudioTrack::getInterfaceDescriptor());
-        status_t status = remote()->transact(GET_CBLK, data, &reply);
-        if (status == NO_ERROR) {
-            cblk = interface_cast<IMemory>(reply.readStrongBinder());
-        }
-        return cblk;
-    }
-
     virtual status_t attachAuxEffect(int effectId)
     {
         Parcel data, reply;
@@ -109,7 +109,7 @@
         if (status == NO_ERROR) {
             status = reply.readInt32();
         } else {
-            LOGW("attachAuxEffect() error: %s", strerror(-status));
+            ALOGW("attachAuxEffect() error: %s", strerror(-status));
         }
         return status;
     }
diff --git a/media/libmedia/IEffect.cpp b/media/libmedia/IEffect.cpp
index a945b97..d469e28 100644
--- a/media/libmedia/IEffect.cpp
+++ b/media/libmedia/IEffect.cpp
@@ -43,7 +43,7 @@
 
     status_t enable()
     {
-        LOGV("enable");
+        ALOGV("enable");
         Parcel data, reply;
         data.writeInterfaceToken(IEffect::getInterfaceDescriptor());
         remote()->transact(ENABLE, data, &reply);
@@ -52,7 +52,7 @@
 
     status_t disable()
     {
-        LOGV("disable");
+        ALOGV("disable");
         Parcel data, reply;
         data.writeInterfaceToken(IEffect::getInterfaceDescriptor());
         remote()->transact(DISABLE, data, &reply);
@@ -65,7 +65,7 @@
                      uint32_t *pReplySize,
                      void *pReplyData)
     {
-        LOGV("command");
+        ALOGV("command");
         Parcel data, reply;
         data.writeInterfaceToken(IEffect::getInterfaceDescriptor());
         data.writeInt32(cmdCode);
@@ -95,7 +95,7 @@
 
     void disconnect()
     {
-        LOGV("disconnect");
+        ALOGV("disconnect");
         Parcel data, reply;
         data.writeInterfaceToken(IEffect::getInterfaceDescriptor());
         remote()->transact(DISCONNECT, data, &reply);
@@ -124,21 +124,21 @@
 {
     switch(code) {
         case ENABLE: {
-            LOGV("ENABLE");
+            ALOGV("ENABLE");
             CHECK_INTERFACE(IEffect, data, reply);
             reply->writeInt32(enable());
             return NO_ERROR;
         } break;
 
         case DISABLE: {
-            LOGV("DISABLE");
+            ALOGV("DISABLE");
             CHECK_INTERFACE(IEffect, data, reply);
             reply->writeInt32(disable());
             return NO_ERROR;
         } break;
 
         case COMMAND: {
-            LOGV("COMMAND");
+            ALOGV("COMMAND");
             CHECK_INTERFACE(IEffect, data, reply);
             uint32_t cmdCode = data.readInt32();
             uint32_t cmdSize = data.readInt32();
@@ -172,7 +172,7 @@
         } break;
 
         case DISCONNECT: {
-            LOGV("DISCONNECT");
+            ALOGV("DISCONNECT");
             CHECK_INTERFACE(IEffect, data, reply);
             disconnect();
             return NO_ERROR;
diff --git a/media/libmedia/IEffectClient.cpp b/media/libmedia/IEffectClient.cpp
index 1fa9cbe..4693b45 100644
--- a/media/libmedia/IEffectClient.cpp
+++ b/media/libmedia/IEffectClient.cpp
@@ -40,7 +40,7 @@
 
     void controlStatusChanged(bool controlGranted)
     {
-        LOGV("controlStatusChanged");
+        ALOGV("controlStatusChanged");
         Parcel data, reply;
         data.writeInterfaceToken(IEffectClient::getInterfaceDescriptor());
         data.writeInt32((uint32_t)controlGranted);
@@ -49,7 +49,7 @@
 
     void enableStatusChanged(bool enabled)
     {
-        LOGV("enableStatusChanged");
+        ALOGV("enableStatusChanged");
         Parcel data, reply;
         data.writeInterfaceToken(IEffectClient::getInterfaceDescriptor());
         data.writeInt32((uint32_t)enabled);
@@ -62,7 +62,7 @@
                          uint32_t replySize,
                          void *pReplyData)
     {
-        LOGV("commandExecuted");
+        ALOGV("commandExecuted");
         Parcel data, reply;
         data.writeInterfaceToken(IEffectClient::getInterfaceDescriptor());
         data.writeInt32(cmdCode);
@@ -96,21 +96,21 @@
 {
     switch(code) {
         case CONTROL_STATUS_CHANGED: {
-            LOGV("CONTROL_STATUS_CHANGED");
+            ALOGV("CONTROL_STATUS_CHANGED");
             CHECK_INTERFACE(IEffectClient, data, reply);
             bool hasControl = (bool)data.readInt32();
             controlStatusChanged(hasControl);
             return NO_ERROR;
         } break;
         case ENABLE_STATUS_CHANGED: {
-            LOGV("ENABLE_STATUS_CHANGED");
+            ALOGV("ENABLE_STATUS_CHANGED");
             CHECK_INTERFACE(IEffectClient, data, reply);
             bool enabled = (bool)data.readInt32();
             enableStatusChanged(enabled);
             return NO_ERROR;
         } break;
         case COMMAND_EXECUTED: {
-            LOGV("COMMAND_EXECUTED");
+            ALOGV("COMMAND_EXECUTED");
             CHECK_INTERFACE(IEffectClient, data, reply);
             uint32_t cmdCode = data.readInt32();
             uint32_t cmdSize = data.readInt32();
diff --git a/media/libmedia/IMediaDeathNotifier.cpp b/media/libmedia/IMediaDeathNotifier.cpp
index 39ac076..8525482 100644
--- a/media/libmedia/IMediaDeathNotifier.cpp
+++ b/media/libmedia/IMediaDeathNotifier.cpp
@@ -34,7 +34,7 @@
 /*static*/const sp<IMediaPlayerService>&
 IMediaDeathNotifier::getMediaPlayerService()
 {
-    LOGV("getMediaPlayerService");
+    ALOGV("getMediaPlayerService");
     Mutex::Autolock _l(sServiceLock);
     if (sMediaPlayerService.get() == 0) {
         sp<IServiceManager> sm = defaultServiceManager();
@@ -44,7 +44,7 @@
             if (binder != 0) {
                 break;
              }
-             LOGW("Media player service not published, waiting...");
+             ALOGW("Media player service not published, waiting...");
              usleep(500000); // 0.5 s
         } while(true);
 
@@ -54,14 +54,14 @@
     binder->linkToDeath(sDeathNotifier);
     sMediaPlayerService = interface_cast<IMediaPlayerService>(binder);
     }
-    LOGE_IF(sMediaPlayerService == 0, "no media player service!?");
+    ALOGE_IF(sMediaPlayerService == 0, "no media player service!?");
     return sMediaPlayerService;
 }
 
 /*static*/ void
 IMediaDeathNotifier::addObitRecipient(const wp<IMediaDeathNotifier>& recipient)
 {
-    LOGV("addObitRecipient");
+    ALOGV("addObitRecipient");
     Mutex::Autolock _l(sServiceLock);
     sObitRecipients.add(recipient);
 }
@@ -69,14 +69,14 @@
 /*static*/ void
 IMediaDeathNotifier::removeObitRecipient(const wp<IMediaDeathNotifier>& recipient)
 {
-    LOGV("removeObitRecipient");
+    ALOGV("removeObitRecipient");
     Mutex::Autolock _l(sServiceLock);
     sObitRecipients.remove(recipient);
 }
 
 void
 IMediaDeathNotifier::DeathNotifier::binderDied(const wp<IBinder>& who) {
-    LOGW("media server died");
+    ALOGW("media server died");
 
     // Need to do this with the lock held
     SortedVector< wp<IMediaDeathNotifier> > list;
@@ -100,7 +100,7 @@
 
 IMediaDeathNotifier::DeathNotifier::~DeathNotifier()
 {
-    LOGV("DeathNotifier::~DeathNotifier");
+    ALOGV("DeathNotifier::~DeathNotifier");
     Mutex::Autolock _l(sServiceLock);
     sObitRecipients.clear();
     if (sMediaPlayerService != 0) {
diff --git a/media/libmedia/IMediaMetadataRetriever.cpp b/media/libmedia/IMediaMetadataRetriever.cpp
index 07152d8..9b8d7c3 100644
--- a/media/libmedia/IMediaMetadataRetriever.cpp
+++ b/media/libmedia/IMediaMetadataRetriever.cpp
@@ -118,7 +118,7 @@
 
     sp<IMemory> getFrameAtTime(int64_t timeUs, int option)
     {
-        LOGV("getTimeAtTime: time(%lld us) and option(%d)", timeUs, option);
+        ALOGV("getTimeAtTime: time(%lld us) and option(%d)", timeUs, option);
         Parcel data, reply;
         data.writeInterfaceToken(IMediaMetadataRetriever::getInterfaceDescriptor());
         data.writeInt64(timeUs);
@@ -208,7 +208,7 @@
             CHECK_INTERFACE(IMediaMetadataRetriever, data, reply);
             int64_t timeUs = data.readInt64();
             int option = data.readInt32();
-            LOGV("getTimeAtTime: time(%lld us) and option(%d)", timeUs, option);
+            ALOGV("getTimeAtTime: time(%lld us) and option(%d)", timeUs, option);
 #ifndef DISABLE_GROUP_SCHEDULE_HACK
             setSchedPolicy(data);
 #endif
diff --git a/media/libmedia/IMediaPlayerService.cpp b/media/libmedia/IMediaPlayerService.cpp
index 8e4dd04..f5b5cbd 100644
--- a/media/libmedia/IMediaPlayerService.cpp
+++ b/media/libmedia/IMediaPlayerService.cpp
@@ -78,7 +78,7 @@
         return interface_cast<IMediaRecorder>(reply.readStrongBinder());
     }
 
-    virtual sp<IMemory> decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, int* pFormat)
+    virtual sp<IMemory> decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, audio_format_t* pFormat)
     {
         Parcel data, reply;
         data.writeInterfaceToken(IMediaPlayerService::getInterfaceDescriptor());
@@ -86,11 +86,11 @@
         remote()->transact(DECODE_URL, data, &reply);
         *pSampleRate = uint32_t(reply.readInt32());
         *pNumChannels = reply.readInt32();
-        *pFormat = reply.readInt32();
+        *pFormat = (audio_format_t) reply.readInt32();
         return interface_cast<IMemory>(reply.readStrongBinder());
     }
 
-    virtual sp<IMemory> decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, int* pFormat)
+    virtual sp<IMemory> decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, audio_format_t* pFormat)
     {
         Parcel data, reply;
         data.writeInterfaceToken(IMediaPlayerService::getInterfaceDescriptor());
@@ -100,7 +100,7 @@
         remote()->transact(DECODE_FD, data, &reply);
         *pSampleRate = uint32_t(reply.readInt32());
         *pNumChannels = reply.readInt32();
-        *pFormat = reply.readInt32();
+        *pFormat = (audio_format_t) reply.readInt32();
         return interface_cast<IMemory>(reply.readStrongBinder());
     }
 
@@ -148,11 +148,11 @@
             const char* url = data.readCString();
             uint32_t sampleRate;
             int numChannels;
-            int format;
+            audio_format_t format;
             sp<IMemory> player = decode(url, &sampleRate, &numChannels, &format);
             reply->writeInt32(sampleRate);
             reply->writeInt32(numChannels);
-            reply->writeInt32(format);
+            reply->writeInt32((int32_t) format);
             reply->writeStrongBinder(player->asBinder());
             return NO_ERROR;
         } break;
@@ -163,11 +163,11 @@
             int64_t length = data.readInt64();
             uint32_t sampleRate;
             int numChannels;
-            int format;
+            audio_format_t format;
             sp<IMemory> player = decode(fd, offset, length, &sampleRate, &numChannels, &format);
             reply->writeInt32(sampleRate);
             reply->writeInt32(numChannels);
-            reply->writeInt32(format);
+            reply->writeInt32((int32_t) format);
             reply->writeStrongBinder(player->asBinder());
             return NO_ERROR;
         } break;
diff --git a/media/libmedia/IMediaRecorder.cpp b/media/libmedia/IMediaRecorder.cpp
index 38e111e..42f55c2 100644
--- a/media/libmedia/IMediaRecorder.cpp
+++ b/media/libmedia/IMediaRecorder.cpp
@@ -64,7 +64,7 @@
 
     status_t setCamera(const sp<ICamera>& camera, const sp<ICameraRecordingProxy>& proxy)
     {
-        LOGV("setCamera(%p,%p)", camera.get(), proxy.get());
+        ALOGV("setCamera(%p,%p)", camera.get(), proxy.get());
         Parcel data, reply;
         data.writeInterfaceToken(IMediaRecorder::getInterfaceDescriptor());
         data.writeStrongBinder(camera->asBinder());
@@ -75,7 +75,7 @@
 
     sp<ISurfaceTexture> querySurfaceMediaSource()
     {
-        LOGV("Query SurfaceMediaSource");
+        ALOGV("Query SurfaceMediaSource");
         Parcel data, reply;
         data.writeInterfaceToken(IMediaRecorder::getInterfaceDescriptor());
         remote()->transact(QUERY_SURFACE_MEDIASOURCE, data, &reply);
@@ -88,7 +88,7 @@
 
     status_t setPreviewSurface(const sp<Surface>& surface)
     {
-        LOGV("setPreviewSurface(%p)", surface.get());
+        ALOGV("setPreviewSurface(%p)", surface.get());
         Parcel data, reply;
         data.writeInterfaceToken(IMediaRecorder::getInterfaceDescriptor());
         Surface::writeToParcel(surface, &data);
@@ -98,7 +98,7 @@
 
     status_t init()
     {
-        LOGV("init");
+        ALOGV("init");
         Parcel data, reply;
         data.writeInterfaceToken(IMediaRecorder::getInterfaceDescriptor());
         remote()->transact(INIT, data, &reply);
@@ -107,7 +107,7 @@
 
     status_t setVideoSource(int vs)
     {
-        LOGV("setVideoSource(%d)", vs);
+        ALOGV("setVideoSource(%d)", vs);
         Parcel data, reply;
         data.writeInterfaceToken(IMediaRecorder::getInterfaceDescriptor());
         data.writeInt32(vs);
@@ -117,7 +117,7 @@
 
     status_t setAudioSource(int as)
     {
-        LOGV("setAudioSource(%d)", as);
+        ALOGV("setAudioSource(%d)", as);
         Parcel data, reply;
         data.writeInterfaceToken(IMediaRecorder::getInterfaceDescriptor());
         data.writeInt32(as);
@@ -127,7 +127,7 @@
 
     status_t setOutputFormat(int of)
     {
-        LOGV("setOutputFormat(%d)", of);
+        ALOGV("setOutputFormat(%d)", of);
         Parcel data, reply;
         data.writeInterfaceToken(IMediaRecorder::getInterfaceDescriptor());
         data.writeInt32(of);
@@ -137,7 +137,7 @@
 
     status_t setVideoEncoder(int ve)
     {
-        LOGV("setVideoEncoder(%d)", ve);
+        ALOGV("setVideoEncoder(%d)", ve);
         Parcel data, reply;
         data.writeInterfaceToken(IMediaRecorder::getInterfaceDescriptor());
         data.writeInt32(ve);
@@ -147,7 +147,7 @@
 
     status_t setAudioEncoder(int ae)
     {
-        LOGV("setAudioEncoder(%d)", ae);
+        ALOGV("setAudioEncoder(%d)", ae);
         Parcel data, reply;
         data.writeInterfaceToken(IMediaRecorder::getInterfaceDescriptor());
         data.writeInt32(ae);
@@ -157,7 +157,7 @@
 
     status_t setOutputFile(const char* path)
     {
-        LOGV("setOutputFile(%s)", path);
+        ALOGV("setOutputFile(%s)", path);
         Parcel data, reply;
         data.writeInterfaceToken(IMediaRecorder::getInterfaceDescriptor());
         data.writeCString(path);
@@ -166,7 +166,7 @@
     }
 
     status_t setOutputFile(int fd, int64_t offset, int64_t length) {
-        LOGV("setOutputFile(%d, %lld, %lld)", fd, offset, length);
+        ALOGV("setOutputFile(%d, %lld, %lld)", fd, offset, length);
         Parcel data, reply;
         data.writeInterfaceToken(IMediaRecorder::getInterfaceDescriptor());
         data.writeFileDescriptor(fd);
@@ -178,7 +178,7 @@
 
     status_t setVideoSize(int width, int height)
     {
-        LOGV("setVideoSize(%dx%d)", width, height);
+        ALOGV("setVideoSize(%dx%d)", width, height);
         Parcel data, reply;
         data.writeInterfaceToken(IMediaRecorder::getInterfaceDescriptor());
         data.writeInt32(width);
@@ -189,7 +189,7 @@
 
     status_t setVideoFrameRate(int frames_per_second)
     {
-        LOGV("setVideoFrameRate(%d)", frames_per_second);
+        ALOGV("setVideoFrameRate(%d)", frames_per_second);
         Parcel data, reply;
         data.writeInterfaceToken(IMediaRecorder::getInterfaceDescriptor());
         data.writeInt32(frames_per_second);
@@ -199,7 +199,7 @@
 
     status_t setParameters(const String8& params)
     {
-        LOGV("setParameter(%s)", params.string());
+        ALOGV("setParameter(%s)", params.string());
         Parcel data, reply;
         data.writeInterfaceToken(IMediaRecorder::getInterfaceDescriptor());
         data.writeString8(params);
@@ -209,7 +209,7 @@
 
     status_t setListener(const sp<IMediaRecorderClient>& listener)
     {
-        LOGV("setListener(%p)", listener.get());
+        ALOGV("setListener(%p)", listener.get());
         Parcel data, reply;
         data.writeInterfaceToken(IMediaRecorder::getInterfaceDescriptor());
         data.writeStrongBinder(listener->asBinder());
@@ -219,7 +219,7 @@
 
     status_t prepare()
     {
-        LOGV("prepare");
+        ALOGV("prepare");
         Parcel data, reply;
         data.writeInterfaceToken(IMediaRecorder::getInterfaceDescriptor());
         remote()->transact(PREPARE, data, &reply);
@@ -228,7 +228,7 @@
 
     status_t getMaxAmplitude(int* max)
     {
-        LOGV("getMaxAmplitude");
+        ALOGV("getMaxAmplitude");
         Parcel data, reply;
         data.writeInterfaceToken(IMediaRecorder::getInterfaceDescriptor());
         remote()->transact(GET_MAX_AMPLITUDE, data, &reply);
@@ -238,7 +238,7 @@
 
     status_t start()
     {
-        LOGV("start");
+        ALOGV("start");
         Parcel data, reply;
         data.writeInterfaceToken(IMediaRecorder::getInterfaceDescriptor());
         remote()->transact(START, data, &reply);
@@ -247,7 +247,7 @@
 
     status_t stop()
     {
-        LOGV("stop");
+        ALOGV("stop");
         Parcel data, reply;
         data.writeInterfaceToken(IMediaRecorder::getInterfaceDescriptor());
         remote()->transact(STOP, data, &reply);
@@ -256,7 +256,7 @@
 
     status_t reset()
     {
-        LOGV("reset");
+        ALOGV("reset");
         Parcel data, reply;
         data.writeInterfaceToken(IMediaRecorder::getInterfaceDescriptor());
         remote()->transact(RESET, data, &reply);
@@ -265,7 +265,7 @@
 
     status_t close()
     {
-        LOGV("close");
+        ALOGV("close");
         Parcel data, reply;
         data.writeInterfaceToken(IMediaRecorder::getInterfaceDescriptor());
         remote()->transact(CLOSE, data, &reply);
@@ -274,7 +274,7 @@
 
     status_t release()
     {
-        LOGV("release");
+        ALOGV("release");
         Parcel data, reply;
         data.writeInterfaceToken(IMediaRecorder::getInterfaceDescriptor());
         remote()->transact(RELEASE, data, &reply);
@@ -291,49 +291,49 @@
 {
     switch(code) {
         case RELEASE: {
-            LOGV("RELEASE");
+            ALOGV("RELEASE");
             CHECK_INTERFACE(IMediaRecorder, data, reply);
             reply->writeInt32(release());
             return NO_ERROR;
         } break;
         case INIT: {
-            LOGV("INIT");
+            ALOGV("INIT");
             CHECK_INTERFACE(IMediaRecorder, data, reply);
             reply->writeInt32(init());
             return NO_ERROR;
         } break;
         case CLOSE: {
-            LOGV("CLOSE");
+            ALOGV("CLOSE");
             CHECK_INTERFACE(IMediaRecorder, data, reply);
             reply->writeInt32(close());
             return NO_ERROR;
         } break;
         case RESET: {
-            LOGV("RESET");
+            ALOGV("RESET");
             CHECK_INTERFACE(IMediaRecorder, data, reply);
             reply->writeInt32(reset());
             return NO_ERROR;
         } break;
         case STOP: {
-            LOGV("STOP");
+            ALOGV("STOP");
             CHECK_INTERFACE(IMediaRecorder, data, reply);
             reply->writeInt32(stop());
             return NO_ERROR;
         } break;
         case START: {
-            LOGV("START");
+            ALOGV("START");
             CHECK_INTERFACE(IMediaRecorder, data, reply);
             reply->writeInt32(start());
             return NO_ERROR;
         } break;
         case PREPARE: {
-            LOGV("PREPARE");
+            ALOGV("PREPARE");
             CHECK_INTERFACE(IMediaRecorder, data, reply);
             reply->writeInt32(prepare());
             return NO_ERROR;
         } break;
         case GET_MAX_AMPLITUDE: {
-            LOGV("GET_MAX_AMPLITUDE");
+            ALOGV("GET_MAX_AMPLITUDE");
             CHECK_INTERFACE(IMediaRecorder, data, reply);
             int max = 0;
             status_t ret = getMaxAmplitude(&max);
@@ -342,35 +342,35 @@
             return NO_ERROR;
         } break;
         case SET_VIDEO_SOURCE: {
-            LOGV("SET_VIDEO_SOURCE");
+            ALOGV("SET_VIDEO_SOURCE");
             CHECK_INTERFACE(IMediaRecorder, data, reply);
             int vs = data.readInt32();
             reply->writeInt32(setVideoSource(vs));
             return NO_ERROR;
         } break;
         case SET_AUDIO_SOURCE: {
-            LOGV("SET_AUDIO_SOURCE");
+            ALOGV("SET_AUDIO_SOURCE");
             CHECK_INTERFACE(IMediaRecorder, data, reply);
             int as = data.readInt32();
             reply->writeInt32(setAudioSource(as));
             return NO_ERROR;
         } break;
         case SET_OUTPUT_FORMAT: {
-            LOGV("SET_OUTPUT_FORMAT");
+            ALOGV("SET_OUTPUT_FORMAT");
             CHECK_INTERFACE(IMediaRecorder, data, reply);
             int of = data.readInt32();
             reply->writeInt32(setOutputFormat(of));
             return NO_ERROR;
         } break;
         case SET_VIDEO_ENCODER: {
-            LOGV("SET_VIDEO_ENCODER");
+            ALOGV("SET_VIDEO_ENCODER");
             CHECK_INTERFACE(IMediaRecorder, data, reply);
             int ve = data.readInt32();
             reply->writeInt32(setVideoEncoder(ve));
             return NO_ERROR;
         } break;
         case SET_AUDIO_ENCODER: {
-            LOGV("SET_AUDIO_ENCODER");
+            ALOGV("SET_AUDIO_ENCODER");
             CHECK_INTERFACE(IMediaRecorder, data, reply);
             int ae = data.readInt32();
             reply->writeInt32(setAudioEncoder(ae));
@@ -378,14 +378,14 @@
 
         } break;
         case SET_OUTPUT_FILE_PATH: {
-            LOGV("SET_OUTPUT_FILE_PATH");
+            ALOGV("SET_OUTPUT_FILE_PATH");
             CHECK_INTERFACE(IMediaRecorder, data, reply);
             const char* path = data.readCString();
             reply->writeInt32(setOutputFile(path));
             return NO_ERROR;
         } break;
         case SET_OUTPUT_FILE_FD: {
-            LOGV("SET_OUTPUT_FILE_FD");
+            ALOGV("SET_OUTPUT_FILE_FD");
             CHECK_INTERFACE(IMediaRecorder, data, reply);
             int fd = dup(data.readFileDescriptor());
             int64_t offset = data.readInt64();
@@ -395,7 +395,7 @@
             return NO_ERROR;
         } break;
         case SET_VIDEO_SIZE: {
-            LOGV("SET_VIDEO_SIZE");
+            ALOGV("SET_VIDEO_SIZE");
             CHECK_INTERFACE(IMediaRecorder, data, reply);
             int width = data.readInt32();
             int height = data.readInt32();
@@ -403,20 +403,20 @@
             return NO_ERROR;
         } break;
         case SET_VIDEO_FRAMERATE: {
-            LOGV("SET_VIDEO_FRAMERATE");
+            ALOGV("SET_VIDEO_FRAMERATE");
             CHECK_INTERFACE(IMediaRecorder, data, reply);
             int frames_per_second = data.readInt32();
             reply->writeInt32(setVideoFrameRate(frames_per_second));
             return NO_ERROR;
         } break;
         case SET_PARAMETERS: {
-            LOGV("SET_PARAMETER");
+            ALOGV("SET_PARAMETER");
             CHECK_INTERFACE(IMediaRecorder, data, reply);
             reply->writeInt32(setParameters(data.readString8()));
             return NO_ERROR;
         } break;
         case SET_LISTENER: {
-            LOGV("SET_LISTENER");
+            ALOGV("SET_LISTENER");
             CHECK_INTERFACE(IMediaRecorder, data, reply);
             sp<IMediaRecorderClient> listener =
                 interface_cast<IMediaRecorderClient>(data.readStrongBinder());
@@ -424,14 +424,14 @@
             return NO_ERROR;
         } break;
         case SET_PREVIEW_SURFACE: {
-            LOGV("SET_PREVIEW_SURFACE");
+            ALOGV("SET_PREVIEW_SURFACE");
             CHECK_INTERFACE(IMediaRecorder, data, reply);
             sp<Surface> surface = Surface::readFromParcel(data);
             reply->writeInt32(setPreviewSurface(surface));
             return NO_ERROR;
         } break;
         case SET_CAMERA: {
-            LOGV("SET_CAMERA");
+            ALOGV("SET_CAMERA");
             CHECK_INTERFACE(IMediaRecorder, data, reply);
             sp<ICamera> camera = interface_cast<ICamera>(data.readStrongBinder());
             sp<ICameraRecordingProxy> proxy =
@@ -440,7 +440,7 @@
             return NO_ERROR;
         } break;
         case QUERY_SURFACE_MEDIASOURCE: {
-            LOGV("QUERY_SURFACE_MEDIASOURCE");
+            ALOGV("QUERY_SURFACE_MEDIASOURCE");
             CHECK_INTERFACE(IMediaRecorder, data, reply);
             // call the mediaserver side to create
             // a surfacemediasource
diff --git a/media/libmedia/IOMX.cpp b/media/libmedia/IOMX.cpp
index 7d2fbce..d2f5f71 100644
--- a/media/libmedia/IOMX.cpp
+++ b/media/libmedia/IOMX.cpp
@@ -407,7 +407,7 @@
 
 #define CHECK_INTERFACE(interface, data, reply) \
         do { if (!data.enforceInterface(interface::getInterfaceDescriptor())) { \
-            LOGW("Call incorrectly routed to " #interface); \
+            ALOGW("Call incorrectly routed to " #interface); \
             return PERMISSION_DENIED; \
         } } while (0)
 
diff --git a/media/libmedia/JetPlayer.cpp b/media/libmedia/JetPlayer.cpp
index 8b953e0..8456db5 100644
--- a/media/libmedia/JetPlayer.cpp
+++ b/media/libmedia/JetPlayer.cpp
@@ -42,7 +42,7 @@
         mAudioTrack(NULL),
         mTrackBufferSize(trackBufferSize)
 {
-    LOGV("JetPlayer constructor");
+    ALOGV("JetPlayer constructor");
     mPreviousJetStatus.currentUserID = -1;
     mPreviousJetStatus.segmentRepeatCount = -1;
     mPreviousJetStatus.numQueuedSegments = -1;
@@ -52,7 +52,7 @@
 //-------------------------------------------------------------------------------------------------
 JetPlayer::~JetPlayer()
 {
-    LOGV("~JetPlayer");
+    ALOGV("~JetPlayer");
     release();
 
 }
@@ -68,21 +68,21 @@
     if (pLibConfig == NULL)
         pLibConfig = EAS_Config();
     if (pLibConfig == NULL) {
-        LOGE("JetPlayer::init(): EAS library configuration could not be retrieved, aborting.");
+        ALOGE("JetPlayer::init(): EAS library configuration could not be retrieved, aborting.");
         return EAS_FAILURE;
     }
 
     // init the EAS library
     result = EAS_Init(&mEasData);
     if( result != EAS_SUCCESS) {
-        LOGE("JetPlayer::init(): Error initializing Sonivox EAS library, aborting.");
+        ALOGE("JetPlayer::init(): Error initializing Sonivox EAS library, aborting.");
         mState = EAS_STATE_ERROR;
         return result;
     }
     // init the JET library with the default app event controller range
     result = JET_Init(mEasData, NULL, sizeof(S_JET_CONFIG));
     if( result != EAS_SUCCESS) {
-        LOGE("JetPlayer::init(): Error initializing JET library, aborting.");
+        ALOGE("JetPlayer::init(): Error initializing JET library, aborting.");
         mState = EAS_STATE_ERROR;
         return result;
     }
@@ -91,7 +91,7 @@
     mAudioTrack = new AudioTrack();
     mAudioTrack->set(AUDIO_STREAM_MUSIC,  //TODO parametrize this
             pLibConfig->sampleRate,
-            1, // format = PCM 16bits per sample,
+            AUDIO_FORMAT_PCM_16_BIT,
             (pLibConfig->numChannels == 2) ? AUDIO_CHANNEL_OUT_STEREO : AUDIO_CHANNEL_OUT_MONO,
             mTrackBufferSize,
             0);
@@ -99,16 +99,17 @@
     // create render and playback thread
     {
         Mutex::Autolock l(mMutex);
-        LOGV("JetPlayer::init(): trying to start render thread");
-        createThreadEtc(renderThread, this, "jetRenderThread", ANDROID_PRIORITY_AUDIO);
+        ALOGV("JetPlayer::init(): trying to start render thread");
+        mThread = new JetPlayerThread(this);
+        mThread->run("jetRenderThread", ANDROID_PRIORITY_AUDIO);
         mCondition.wait(mMutex);
     }
     if (mTid > 0) {
         // render thread started, we're ready
-        LOGV("JetPlayer::init(): render thread(%d) successfully started.", mTid);
+        ALOGV("JetPlayer::init(): render thread(%d) successfully started.", mTid);
         mState = EAS_STATE_READY;
     } else {
-        LOGE("JetPlayer::init(): failed to start render thread.");
+        ALOGE("JetPlayer::init(): failed to start render thread.");
         mState = EAS_STATE_ERROR;
         return EAS_FAILURE;
     }
@@ -125,7 +126,7 @@
 //-------------------------------------------------------------------------------------------------
 int JetPlayer::release()
 {
-    LOGV("JetPlayer::release()");
+    ALOGV("JetPlayer::release()");
     Mutex::Autolock lock(mMutex);
     mPaused = true;
     mRender = false;
@@ -156,33 +157,23 @@
 
 
 //-------------------------------------------------------------------------------------------------
-int JetPlayer::renderThread(void* p) {
-
-    return ((JetPlayer*)p)->render();
-}
-
-//-------------------------------------------------------------------------------------------------
 int JetPlayer::render() {
     EAS_RESULT result = EAS_FAILURE;
     EAS_I32 count;
     int temp;
     bool audioStarted = false;
 
-    LOGV("JetPlayer::render(): entering");
+    ALOGV("JetPlayer::render(): entering");
 
     // allocate render buffer
     mAudioBuffer = 
         new EAS_PCM[pLibConfig->mixBufferSize * pLibConfig->numChannels * MIX_NUM_BUFFERS];
-    if (!mAudioBuffer) {
-        LOGE("JetPlayer::render(): mAudioBuffer allocate failed");
-        goto threadExit;
-    }
 
     // signal main thread that we started
     {
         Mutex::Autolock l(mMutex);
         mTid = gettid();
-        LOGV("JetPlayer::render(): render thread(%d) signal", mTid);
+        ALOGV("JetPlayer::render(): render thread(%d) signal", mTid);
         mCondition.signal();
     }
 
@@ -192,21 +183,21 @@
 
         if (mEasData == NULL) {
             mMutex.unlock();
-            LOGV("JetPlayer::render(): NULL EAS data, exiting render.");
+            ALOGV("JetPlayer::render(): NULL EAS data, exiting render.");
             goto threadExit;
         }
             
         // nothing to render, wait for client thread to wake us up
         while (!mRender)
         {
-            LOGV("JetPlayer::render(): signal wait");
+            ALOGV("JetPlayer::render(): signal wait");
             if (audioStarted) { 
                 mAudioTrack->pause(); 
                 // we have to restart the playback once we start rendering again
                 audioStarted = false;
             }
             mCondition.wait(mMutex);
-            LOGV("JetPlayer::render(): signal rx'd");
+            ALOGV("JetPlayer::render(): signal rx'd");
         }
         
         // render midi data into the input buffer
@@ -215,7 +206,7 @@
         for (int i = 0; i < MIX_NUM_BUFFERS; i++) {
             result = EAS_Render(mEasData, p, pLibConfig->mixBufferSize, &count);
             if (result != EAS_SUCCESS) {
-                LOGE("JetPlayer::render(): EAS_Render returned error %ld", result);
+                ALOGE("JetPlayer::render(): EAS_Render returned error %ld", result);
             }
             p += count * pLibConfig->numChannels;
             num_output += count * pLibConfig->numChannels * sizeof(EAS_PCM);
@@ -225,7 +216,7 @@
         }
 
         // update playback state
-        //LOGV("JetPlayer::render(): updating state");
+        //ALOGV("JetPlayer::render(): updating state");
         JET_Status(mEasData, &mJetStatus);
         fireUpdateOnStatusChange();
         mPaused = mJetStatus.paused;
@@ -234,20 +225,20 @@
 
         // check audio output track
         if (mAudioTrack == NULL) {
-            LOGE("JetPlayer::render(): output AudioTrack was not created");
+            ALOGE("JetPlayer::render(): output AudioTrack was not created");
             goto threadExit;
         }
 
         // Write data to the audio hardware
-        //LOGV("JetPlayer::render(): writing to audio output");
+        //ALOGV("JetPlayer::render(): writing to audio output");
         if ((temp = mAudioTrack->write(mAudioBuffer, num_output)) < 0) {
-            LOGE("JetPlayer::render(): Error in writing:%d",temp);
+            ALOGE("JetPlayer::render(): Error in writing:%d",temp);
             return temp;
         }
 
         // start audio output if necessary
         if (!audioStarted) {
-            LOGV("JetPlayer::render(): starting audio playback");
+            ALOGV("JetPlayer::render(): starting audio playback");
             mAudioTrack->start();
             audioStarted = true;
         }
@@ -338,13 +329,13 @@
 //-------------------------------------------------------------------------------------------------
 int JetPlayer::loadFromFile(const char* path)
 {
-    LOGV("JetPlayer::loadFromFile(): path=%s", path);
+    ALOGV("JetPlayer::loadFromFile(): path=%s", path);
 
     Mutex::Autolock lock(mMutex);
 
     mEasJetFileLoc = (EAS_FILE_LOCATOR) malloc(sizeof(EAS_FILE));
-    memset(mJetFilePath, 0, 256);
-    strncpy(mJetFilePath, path, strlen(path));
+    strncpy(mJetFilePath, path, sizeof(mJetFilePath));
+    mJetFilePath[sizeof(mJetFilePath) - 1] = '\0';
     mEasJetFileLoc->path = mJetFilePath;
 
     mEasJetFileLoc->fd = 0;
@@ -363,7 +354,7 @@
 //-------------------------------------------------------------------------------------------------
 int JetPlayer::loadFromFD(const int fd, const long long offset, const long long length)
 {
-    LOGV("JetPlayer::loadFromFD(): fd=%d offset=%lld length=%lld", fd, offset, length);
+    ALOGV("JetPlayer::loadFromFD(): fd=%d offset=%lld length=%lld", fd, offset, length);
     
     Mutex::Autolock lock(mMutex);
 
@@ -393,7 +384,7 @@
 //-------------------------------------------------------------------------------------------------
 int JetPlayer::play()
 {
-    LOGV("JetPlayer::play(): entering");
+    ALOGV("JetPlayer::play(): entering");
     Mutex::Autolock lock(mMutex);
 
     EAS_RESULT result = JET_Play(mEasData);
@@ -407,7 +398,7 @@
     fireUpdateOnStatusChange();
 
     // wake up render thread
-    LOGV("JetPlayer::play(): wakeup render thread");
+    ALOGV("JetPlayer::play(): wakeup render thread");
     mCondition.signal();
 
     return result;
@@ -435,7 +426,7 @@
 int JetPlayer::queueSegment(int segmentNum, int libNum, int repeatCount, int transpose,
         EAS_U32 muteFlags, EAS_U8 userID)
 {
-    LOGV("JetPlayer::queueSegment segmentNum=%d, libNum=%d, repeatCount=%d, transpose=%d",
+    ALOGV("JetPlayer::queueSegment segmentNum=%d, libNum=%d, repeatCount=%d, transpose=%d",
         segmentNum, libNum, repeatCount, transpose);
     Mutex::Autolock lock(mMutex);
     return JET_QueueSegment(mEasData, segmentNum, libNum, repeatCount, transpose, muteFlags, userID);
@@ -458,7 +449,7 @@
 //-------------------------------------------------------------------------------------------------
 int JetPlayer::triggerClip(int clipId)
 {
-    LOGV("JetPlayer::triggerClip clipId=%d", clipId);
+    ALOGV("JetPlayer::triggerClip clipId=%d", clipId);
     Mutex::Autolock lock(mMutex);
     return JET_TriggerClip(mEasData, clipId);
 }
@@ -466,7 +457,7 @@
 //-------------------------------------------------------------------------------------------------
 int JetPlayer::clearQueue()
 {
-    LOGV("JetPlayer::clearQueue");
+    ALOGV("JetPlayer::clearQueue");
     Mutex::Autolock lock(mMutex);
     return JET_Clear_Queue(mEasData);
 }
@@ -474,17 +465,17 @@
 //-------------------------------------------------------------------------------------------------
 void JetPlayer::dump()
 {
-    LOGE("JetPlayer dump: JET file=%s", mEasJetFileLoc->path);
+    ALOGE("JetPlayer dump: JET file=%s", mEasJetFileLoc->path);
 }
 
 void JetPlayer::dumpJetStatus(S_JET_STATUS* pJetStatus)
 {
     if(pJetStatus!=NULL)
-        LOGV(">> current JET player status: userID=%d segmentRepeatCount=%d numQueuedSegments=%d paused=%d",
+        ALOGV(">> current JET player status: userID=%d segmentRepeatCount=%d numQueuedSegments=%d paused=%d",
                 pJetStatus->currentUserID, pJetStatus->segmentRepeatCount,
                 pJetStatus->numQueuedSegments, pJetStatus->paused);
     else
-        LOGE(">> JET player status is NULL");
+        ALOGE(">> JET player status is NULL");
 }
 
 
diff --git a/media/libmedia/MediaProfiles.cpp b/media/libmedia/MediaProfiles.cpp
index 6096b72..c905762 100644
--- a/media/libmedia/MediaProfiles.cpp
+++ b/media/libmedia/MediaProfiles.cpp
@@ -82,67 +82,67 @@
 /*static*/ void
 MediaProfiles::logVideoCodec(const MediaProfiles::VideoCodec& codec)
 {
-    LOGV("video codec:");
-    LOGV("codec = %d", codec.mCodec);
-    LOGV("bit rate: %d", codec.mBitRate);
-    LOGV("frame width: %d", codec.mFrameWidth);
-    LOGV("frame height: %d", codec.mFrameHeight);
-    LOGV("frame rate: %d", codec.mFrameRate);
+    ALOGV("video codec:");
+    ALOGV("codec = %d", codec.mCodec);
+    ALOGV("bit rate: %d", codec.mBitRate);
+    ALOGV("frame width: %d", codec.mFrameWidth);
+    ALOGV("frame height: %d", codec.mFrameHeight);
+    ALOGV("frame rate: %d", codec.mFrameRate);
 }
 
 /*static*/ void
 MediaProfiles::logAudioCodec(const MediaProfiles::AudioCodec& codec)
 {
-    LOGV("audio codec:");
-    LOGV("codec = %d", codec.mCodec);
-    LOGV("bit rate: %d", codec.mBitRate);
-    LOGV("sample rate: %d", codec.mSampleRate);
-    LOGV("number of channels: %d", codec.mChannels);
+    ALOGV("audio codec:");
+    ALOGV("codec = %d", codec.mCodec);
+    ALOGV("bit rate: %d", codec.mBitRate);
+    ALOGV("sample rate: %d", codec.mSampleRate);
+    ALOGV("number of channels: %d", codec.mChannels);
 }
 
 /*static*/ void
 MediaProfiles::logVideoEncoderCap(const MediaProfiles::VideoEncoderCap& cap)
 {
-    LOGV("video encoder cap:");
-    LOGV("codec = %d", cap.mCodec);
-    LOGV("bit rate: min = %d and max = %d", cap.mMinBitRate, cap.mMaxBitRate);
-    LOGV("frame width: min = %d and max = %d", cap.mMinFrameWidth, cap.mMaxFrameWidth);
-    LOGV("frame height: min = %d and max = %d", cap.mMinFrameHeight, cap.mMaxFrameHeight);
-    LOGV("frame rate: min = %d and max = %d", cap.mMinFrameRate, cap.mMaxFrameRate);
+    ALOGV("video encoder cap:");
+    ALOGV("codec = %d", cap.mCodec);
+    ALOGV("bit rate: min = %d and max = %d", cap.mMinBitRate, cap.mMaxBitRate);
+    ALOGV("frame width: min = %d and max = %d", cap.mMinFrameWidth, cap.mMaxFrameWidth);
+    ALOGV("frame height: min = %d and max = %d", cap.mMinFrameHeight, cap.mMaxFrameHeight);
+    ALOGV("frame rate: min = %d and max = %d", cap.mMinFrameRate, cap.mMaxFrameRate);
 }
 
 /*static*/ void
 MediaProfiles::logAudioEncoderCap(const MediaProfiles::AudioEncoderCap& cap)
 {
-    LOGV("audio encoder cap:");
-    LOGV("codec = %d", cap.mCodec);
-    LOGV("bit rate: min = %d and max = %d", cap.mMinBitRate, cap.mMaxBitRate);
-    LOGV("sample rate: min = %d and max = %d", cap.mMinSampleRate, cap.mMaxSampleRate);
-    LOGV("number of channels: min = %d and max = %d", cap.mMinChannels, cap.mMaxChannels);
+    ALOGV("audio encoder cap:");
+    ALOGV("codec = %d", cap.mCodec);
+    ALOGV("bit rate: min = %d and max = %d", cap.mMinBitRate, cap.mMaxBitRate);
+    ALOGV("sample rate: min = %d and max = %d", cap.mMinSampleRate, cap.mMaxSampleRate);
+    ALOGV("number of channels: min = %d and max = %d", cap.mMinChannels, cap.mMaxChannels);
 }
 
 /*static*/ void
 MediaProfiles::logVideoDecoderCap(const MediaProfiles::VideoDecoderCap& cap)
 {
-    LOGV("video decoder cap:");
-    LOGV("codec = %d", cap.mCodec);
+    ALOGV("video decoder cap:");
+    ALOGV("codec = %d", cap.mCodec);
 }
 
 /*static*/ void
 MediaProfiles::logAudioDecoderCap(const MediaProfiles::AudioDecoderCap& cap)
 {
-    LOGV("audio codec cap:");
-    LOGV("codec = %d", cap.mCodec);
+    ALOGV("audio codec cap:");
+    ALOGV("codec = %d", cap.mCodec);
 }
 
 /*static*/ void
 MediaProfiles::logVideoEditorCap(const MediaProfiles::VideoEditorCap& cap)
 {
-    LOGV("videoeditor cap:");
-    LOGV("mMaxInputFrameWidth = %d", cap.mMaxInputFrameWidth);
-    LOGV("mMaxInputFrameHeight = %d", cap.mMaxInputFrameHeight);
-    LOGV("mMaxOutputFrameWidth = %d", cap.mMaxOutputFrameWidth);
-    LOGV("mMaxOutputFrameHeight = %d", cap.mMaxOutputFrameHeight);
+    ALOGV("videoeditor cap:");
+    ALOGV("mMaxInputFrameWidth = %d", cap.mMaxInputFrameWidth);
+    ALOGV("mMaxInputFrameHeight = %d", cap.mMaxInputFrameHeight);
+    ALOGV("mMaxOutputFrameWidth = %d", cap.mMaxOutputFrameWidth);
+    ALOGV("mMaxOutputFrameHeight = %d", cap.mMaxOutputFrameHeight);
 }
 
 /*static*/ int
@@ -349,7 +349,7 @@
 {
     CHECK(!strcmp("quality", atts[0]));
     int quality = atoi(atts[1]);
-    LOGV("%s: cameraId=%d, quality=%d\n", __func__, cameraId, quality);
+    ALOGV("%s: cameraId=%d, quality=%d\n", __func__, cameraId, quality);
     ImageEncodingQualityLevels *levels = findImageEncodingQualityLevels(cameraId);
 
     if (levels == NULL) {
@@ -377,7 +377,7 @@
         offsetTimeMs = atoi(atts[3]);
     }
 
-    LOGV("%s: cameraId=%d, offset=%d ms", __func__, cameraId, offsetTimeMs);
+    ALOGV("%s: cameraId=%d, offset=%d ms", __func__, cameraId, offsetTimeMs);
     mStartTimeOffsets.replaceValueFor(cameraId, offsetTimeMs);
 }
 /*static*/ MediaProfiles::ExportVideoProfile*
@@ -465,7 +465,7 @@
 }
 
 void MediaProfiles::initRequiredProfileRefs(const Vector<int>& cameraIds) {
-    LOGV("Number of camera ids: %d", cameraIds.size());
+    ALOGV("Number of camera ids: %d", cameraIds.size());
     CHECK(cameraIds.size() > 0);
     mRequiredProfileRefs = new RequiredProfiles[cameraIds.size()];
     for (size_t i = 0, n = cameraIds.size(); i < n; ++i) {
@@ -592,14 +592,14 @@
 
                 int index = getCamcorderProfileIndex(cameraId, profile->mQuality);
                 if (index != -1) {
-                    LOGV("Profile quality %d for camera %d already exists",
+                    ALOGV("Profile quality %d for camera %d already exists",
                         profile->mQuality, cameraId);
                     CHECK(index == refIndex);
                     continue;
                 }
 
                 // Insert the new profile
-                LOGV("Add a profile: quality %d=>%d for camera %d",
+                ALOGV("Add a profile: quality %d=>%d for camera %d",
                         mCamcorderProfiles[info->mRefProfileIndex]->mQuality,
                         profile->mQuality, cameraId);
 
@@ -612,7 +612,7 @@
 /*static*/ MediaProfiles*
 MediaProfiles::getInstance()
 {
-    LOGV("getInstance");
+    ALOGV("getInstance");
     Mutex::Autolock lock(sLock);
     if (!sIsInitialized) {
         char value[PROPERTY_VALUE_MAX];
@@ -620,7 +620,7 @@
             const char *defaultXmlFile = "/etc/media_profiles.xml";
             FILE *fp = fopen(defaultXmlFile, "r");
             if (fp == NULL) {
-                LOGW("could not find media config xml file");
+                ALOGW("could not find media config xml file");
                 sInstance = createDefaultInstance();
             } else {
                 fclose(fp);  // close the file first.
@@ -903,7 +903,7 @@
       expat is not compiled with -DXML_DTD. We don't have DTD parsing support.
 
       if (!::XML_SetParamEntityParsing(parser, XML_PARAM_ENTITY_PARSING_ALWAYS)) {
-          LOGE("failed to enable DTD support in the xml file");
+          ALOGE("failed to enable DTD support in the xml file");
           return UNKNOWN_ERROR;
       }
 
@@ -913,7 +913,7 @@
     for (;;) {
         void *buff = ::XML_GetBuffer(parser, BUFF_SIZE);
         if (buff == NULL) {
-            LOGE("failed to in call to XML_GetBuffer()");
+            ALOGE("failed to in call to XML_GetBuffer()");
             delete profiles;
             profiles = NULL;
             goto exit;
@@ -921,7 +921,7 @@
 
         int bytes_read = ::fread(buff, 1, BUFF_SIZE, fp);
         if (bytes_read < 0) {
-            LOGE("failed in call to read");
+            ALOGE("failed in call to read");
             delete profiles;
             profiles = NULL;
             goto exit;
@@ -954,7 +954,7 @@
 
 int MediaProfiles::getVideoEncoderParamByName(const char *name, video_encoder codec) const
 {
-    LOGV("getVideoEncoderParamByName: %s for codec %d", name, codec);
+    ALOGV("getVideoEncoderParamByName: %s for codec %d", name, codec);
     int index = -1;
     for (size_t i = 0, n = mVideoEncoders.size(); i < n; ++i) {
         if (mVideoEncoders[i]->mCodec == codec) {
@@ -963,7 +963,7 @@
         }
     }
     if (index == -1) {
-        LOGE("The given video encoder %d is not found", codec);
+        ALOGE("The given video encoder %d is not found", codec);
         return -1;
     }
 
@@ -976,13 +976,13 @@
     if (!strcmp("enc.vid.fps.min", name)) return mVideoEncoders[index]->mMinFrameRate;
     if (!strcmp("enc.vid.fps.max", name)) return mVideoEncoders[index]->mMaxFrameRate;
 
-    LOGE("The given video encoder param name %s is not found", name);
+    ALOGE("The given video encoder param name %s is not found", name);
     return -1;
 }
 int MediaProfiles::getVideoEditorExportParamByName(
     const char *name, int codec) const
 {
-    LOGV("getVideoEditorExportParamByName: name %s codec %d", name, codec);
+    ALOGV("getVideoEditorExportParamByName: name %s codec %d", name, codec);
     ExportVideoProfile *exportProfile = NULL;
     int index = -1;
     for (size_t i =0; i < mVideoEditorExportProfiles.size(); i++) {
@@ -993,7 +993,7 @@
         }
     }
     if (index == -1) {
-        LOGE("The given video decoder %d is not found", codec);
+        ALOGE("The given video decoder %d is not found", codec);
         return -1;
     }
     if (!strcmp("videoeditor.export.profile", name))
@@ -1001,15 +1001,15 @@
     if (!strcmp("videoeditor.export.level", name))
         return exportProfile->mLevel;
 
-    LOGE("The given video editor export param name %s is not found", name);
+    ALOGE("The given video editor export param name %s is not found", name);
     return -1;
 }
 int MediaProfiles::getVideoEditorCapParamByName(const char *name) const
 {
-    LOGV("getVideoEditorCapParamByName: %s", name);
+    ALOGV("getVideoEditorCapParamByName: %s", name);
 
     if (mVideoEditorCap == NULL) {
-        LOGE("The mVideoEditorCap is not created, then create default cap.");
+        ALOGE("The mVideoEditorCap is not created, then create default cap.");
         createDefaultVideoEditorCap(sInstance);
     }
 
@@ -1024,7 +1024,7 @@
     if (!strcmp("maxPrefetchYUVFrames", name))
         return mVideoEditorCap->mMaxPrefetchYUVFrames;
 
-    LOGE("The given video editor param name %s is not found", name);
+    ALOGE("The given video editor param name %s is not found", name);
     return -1;
 }
 
@@ -1039,7 +1039,7 @@
 
 int MediaProfiles::getAudioEncoderParamByName(const char *name, audio_encoder codec) const
 {
-    LOGV("getAudioEncoderParamByName: %s for codec %d", name, codec);
+    ALOGV("getAudioEncoderParamByName: %s for codec %d", name, codec);
     int index = -1;
     for (size_t i = 0, n = mAudioEncoders.size(); i < n; ++i) {
         if (mAudioEncoders[i]->mCodec == codec) {
@@ -1048,7 +1048,7 @@
         }
     }
     if (index == -1) {
-        LOGE("The given audio encoder %d is not found", codec);
+        ALOGE("The given audio encoder %d is not found", codec);
         return -1;
     }
 
@@ -1059,7 +1059,7 @@
     if (!strcmp("enc.aud.hz.min", name)) return mAudioEncoders[index]->mMinSampleRate;
     if (!strcmp("enc.aud.hz.max", name)) return mAudioEncoders[index]->mMaxSampleRate;
 
-    LOGE("The given audio encoder param name %s is not found", name);
+    ALOGE("The given audio encoder param name %s is not found", name);
     return -1;
 }
 
@@ -1098,12 +1098,12 @@
                                                   int cameraId,
                                                   camcorder_quality quality) const
 {
-    LOGV("getCamcorderProfileParamByName: %s for camera %d, quality %d",
+    ALOGV("getCamcorderProfileParamByName: %s for camera %d, quality %d",
          name, cameraId, quality);
 
     int index = getCamcorderProfileIndex(cameraId, quality);
     if (index == -1) {
-        LOGE("The given camcorder profile camera %d quality %d is not found",
+        ALOGE("The given camcorder profile camera %d quality %d is not found",
              cameraId, quality);
         return -1;
     }
@@ -1120,7 +1120,7 @@
     if (!strcmp("aud.ch", name)) return mCamcorderProfiles[index]->mAudioCodec->mChannels;
     if (!strcmp("aud.hz", name)) return mCamcorderProfiles[index]->mAudioCodec->mSampleRate;
 
-    LOGE("The given camcorder profile param id %d name %s is not found", cameraId, name);
+    ALOGE("The given camcorder profile param id %d name %s is not found", cameraId, name);
     return -1;
 }
 
@@ -1145,7 +1145,7 @@
     if (index >= 0) {
         offsetTimeMs = mStartTimeOffsets.valueFor(cameraId);
     }
-    LOGV("offsetTime=%d ms and cameraId=%d", offsetTimeMs, cameraId);
+    ALOGV("offsetTime=%d ms and cameraId=%d", offsetTimeMs, cameraId);
     return offsetTimeMs;
 }
 
diff --git a/media/libmedia/MediaScanner.cpp b/media/libmedia/MediaScanner.cpp
index 19dedfc..79cab74 100644
--- a/media/libmedia/MediaScanner.cpp
+++ b/media/libmedia/MediaScanner.cpp
@@ -135,7 +135,7 @@
     struct dirent* entry;
 
     if (shouldSkipDirectory(path)) {
-      LOGD("Skipping: %s", path);
+      ALOGD("Skipping: %s", path);
       return MEDIA_SCAN_RESULT_OK;
     }
 
@@ -143,7 +143,7 @@
     if (pathRemaining >= 8 /* strlen(".nomedia") */ ) {
         strcpy(fileSpot, ".nomedia");
         if (access(path, F_OK) == 0) {
-            LOGV("found .nomedia, setting noMedia flag\n");
+            ALOGV("found .nomedia, setting noMedia flag\n");
             noMedia = true;
         }
 
@@ -153,7 +153,7 @@
 
     DIR* dir = opendir(path);
     if (!dir) {
-        LOGW("Error opening directory '%s', skipping: %s.", path, strerror(errno));
+        ALOGW("Error opening directory '%s', skipping: %s.", path, strerror(errno));
         return MEDIA_SCAN_RESULT_SKIPPED;
     }
 
@@ -199,7 +199,7 @@
                 type = DT_DIR;
             }
         } else {
-            LOGD("stat() failed for %s: %s", path, strerror(errno) );
+            ALOGD("stat() failed for %s: %s", path, strerror(errno) );
         }
     }
     if (type == DT_DIR) {
diff --git a/media/libmedia/MediaScannerClient.cpp b/media/libmedia/MediaScannerClient.cpp
index 629b165..9fe1820 100644
--- a/media/libmedia/MediaScannerClient.cpp
+++ b/media/libmedia/MediaScannerClient.cpp
@@ -142,12 +142,12 @@
 
         UConverter *conv = ucnv_open(enc, &status);
         if (U_FAILURE(status)) {
-            LOGE("could not create UConverter for %s\n", enc);
+            ALOGE("could not create UConverter for %s\n", enc);
             return;
         }
         UConverter *utf8Conv = ucnv_open("UTF-8", &status);
         if (U_FAILURE(status)) {
-            LOGE("could not create UConverter for UTF-8\n");
+            ALOGE("could not create UConverter for UTF-8\n");
             ucnv_close(conv);
             return;
         }
@@ -173,6 +173,7 @@
             const char* source = mValues->getEntry(i);
             int targetLength = len * 3 + 1;
             char* buffer = new char[targetLength];
+            // don't normally check for NULL, but in this case targetLength may be large
             if (!buffer)
                 break;
             char* target = buffer;
@@ -180,7 +181,7 @@
             ucnv_convertEx(utf8Conv, conv, &target, target + targetLength,
                     &source, (const char *)dest, NULL, NULL, NULL, NULL, TRUE, TRUE, &status);
             if (U_FAILURE(status)) {
-                LOGE("ucnv_convertEx failed: %d\n", status);
+                ALOGE("ucnv_convertEx failed: %d\n", status);
                 mValues->setEntry(i, "???");
             } else {
                 // zero terminate
diff --git a/media/libmedia/Metadata.cpp b/media/libmedia/Metadata.cpp
index 8eeebbb..546a9b0 100644
--- a/media/libmedia/Metadata.cpp
+++ b/media/libmedia/Metadata.cpp
@@ -135,7 +135,7 @@
 {
     if (key < FIRST_SYSTEM_ID ||
         (LAST_SYSTEM_ID < key && key < FIRST_CUSTOM_ID)) {
-        LOGE("Bad key %d", key);
+        ALOGE("Bad key %d", key);
         return false;
     }
     size_t curr = mData->dataPosition();
@@ -152,7 +152,7 @@
             break;
         }
         if (mData->readInt32() == key) {
-            LOGE("Key exists already %d", key);
+            ALOGE("Key exists already %d", key);
             error = true;
             break;
         }
diff --git a/media/libmedia/ToneGenerator.cpp b/media/libmedia/ToneGenerator.cpp
index 7c2200e..9d32460 100644
--- a/media/libmedia/ToneGenerator.cpp
+++ b/media/libmedia/ToneGenerator.cpp
@@ -800,12 +800,12 @@
 ////////////////////////////////////////////////////////////////////////////////
 ToneGenerator::ToneGenerator(int streamType, float volume, bool threadCanCallJava) {
 
-    LOGV("ToneGenerator constructor: streamType=%d, volume=%f\n", streamType, volume);
+    ALOGV("ToneGenerator constructor: streamType=%d, volume=%f\n", streamType, volume);
 
     mState = TONE_IDLE;
 
     if (AudioSystem::getOutputSamplingRate(&mSamplingRate, streamType) != NO_ERROR) {
-        LOGE("Unable to marshal AudioFlinger");
+        ALOGE("Unable to marshal AudioFlinger");
         return;
     }
     mThreadCanCallJava = threadCanCallJava;
@@ -829,9 +829,9 @@
     }
 
     if (initAudioTrack()) {
-        LOGV("ToneGenerator INIT OK, time: %d\n", (unsigned int)(systemTime()/1000000));
+        ALOGV("ToneGenerator INIT OK, time: %d\n", (unsigned int)(systemTime()/1000000));
     } else {
-        LOGV("!!!ToneGenerator INIT FAILED!!!\n");
+        ALOGV("!!!ToneGenerator INIT FAILED!!!\n");
     }
 }
 
@@ -853,11 +853,11 @@
 //
 ////////////////////////////////////////////////////////////////////////////////
 ToneGenerator::~ToneGenerator() {
-    LOGV("ToneGenerator destructor\n");
+    ALOGV("ToneGenerator destructor\n");
 
     if (mpAudioTrack) {
         stopTone();
-        LOGV("Delete Track: %p\n", mpAudioTrack);
+        ALOGV("Delete Track: %p\n", mpAudioTrack);
         delete mpAudioTrack;
     }
 }
@@ -886,13 +886,13 @@
         return lResult;
 
     if (mState == TONE_IDLE) {
-        LOGV("startTone: try to re-init AudioTrack");
+        ALOGV("startTone: try to re-init AudioTrack");
         if (!initAudioTrack()) {
             return lResult;
         }
     }
 
-    LOGV("startTone\n");
+    ALOGV("startTone\n");
 
     mLock.lock();
 
@@ -903,10 +903,10 @@
     mDurationMs = durationMs;
 
     if (mState == TONE_STOPPED) {
-        LOGV("Start waiting for previous tone to stop");
+        ALOGV("Start waiting for previous tone to stop");
         lStatus = mWaitCbkCond.waitRelative(mLock, seconds(3));
         if (lStatus != NO_ERROR) {
-            LOGE("--- start wait for stop timed out, status %d", lStatus);
+            ALOGE("--- start wait for stop timed out, status %d", lStatus);
             mState = TONE_IDLE;
             mLock.unlock();
             return lResult;
@@ -915,17 +915,17 @@
 
     if (mState == TONE_INIT) {
         if (prepareWave()) {
-            LOGV("Immediate start, time %d\n", (unsigned int)(systemTime()/1000000));
+            ALOGV("Immediate start, time %d\n", (unsigned int)(systemTime()/1000000));
             lResult = true;
             mState = TONE_STARTING;
             mLock.unlock();
             mpAudioTrack->start();
             mLock.lock();
             if (mState == TONE_STARTING) {
-                LOGV("Wait for start callback");
+                ALOGV("Wait for start callback");
                 lStatus = mWaitCbkCond.waitRelative(mLock, seconds(3));
                 if (lStatus != NO_ERROR) {
-                    LOGE("--- Immediate start timed out, status %d", lStatus);
+                    ALOGE("--- Immediate start timed out, status %d", lStatus);
                     mState = TONE_IDLE;
                     lResult = false;
                 }
@@ -934,23 +934,23 @@
             mState = TONE_IDLE;
         }
     } else {
-        LOGV("Delayed start\n");
+        ALOGV("Delayed start\n");
         mState = TONE_RESTARTING;
         lStatus = mWaitCbkCond.waitRelative(mLock, seconds(3));
         if (lStatus == NO_ERROR) {
             if (mState != TONE_IDLE) {
                 lResult = true;
             }
-            LOGV("cond received");
+            ALOGV("cond received");
         } else {
-            LOGE("--- Delayed start timed out, status %d", lStatus);
+            ALOGE("--- Delayed start timed out, status %d", lStatus);
             mState = TONE_IDLE;
         }
     }
     mLock.unlock();
 
-    LOGV_IF(lResult, "Tone started, time %d\n", (unsigned int)(systemTime()/1000000));
-    LOGW_IF(!lResult, "Tone start failed!!!, time %d\n", (unsigned int)(systemTime()/1000000));
+    ALOGV_IF(lResult, "Tone started, time %d\n", (unsigned int)(systemTime()/1000000));
+    ALOGW_IF(!lResult, "Tone start failed!!!, time %d\n", (unsigned int)(systemTime()/1000000));
 
     return lResult;
 }
@@ -969,17 +969,17 @@
 //
 ////////////////////////////////////////////////////////////////////////////////
 void ToneGenerator::stopTone() {
-    LOGV("stopTone");
+    ALOGV("stopTone");
 
     mLock.lock();
     if (mState == TONE_PLAYING || mState == TONE_STARTING || mState == TONE_RESTARTING) {
         mState = TONE_STOPPING;
-        LOGV("waiting cond");
+        ALOGV("waiting cond");
         status_t lStatus = mWaitCbkCond.waitRelative(mLock, seconds(3));
         if (lStatus == NO_ERROR) {
-            LOGV("track stop complete, time %d", (unsigned int)(systemTime()/1000000));
+            ALOGV("track stop complete, time %d", (unsigned int)(systemTime()/1000000));
         } else {
-            LOGE("--- Stop timed out");
+            ALOGE("--- Stop timed out");
             mState = TONE_IDLE;
             mpAudioTrack->stop();
         }
@@ -1017,11 +1017,7 @@
 
    // Open audio track in mono, PCM 16bit, default sampling rate, default buffer size
     mpAudioTrack = new AudioTrack();
-    if (mpAudioTrack == 0) {
-        LOGE("AudioTrack allocation failed");
-        goto initAudioTrack_exit;
-    }
-    LOGV("Create Track: %p\n", mpAudioTrack);
+    ALOGV("Create Track: %p\n", mpAudioTrack);
 
     mpAudioTrack->set(mStreamType,
                       0,
@@ -1036,7 +1032,7 @@
                       mThreadCanCallJava);
 
     if (mpAudioTrack->initCheck() != NO_ERROR) {
-        LOGE("AudioTrack->initCheck failed");
+        ALOGE("AudioTrack->initCheck failed");
         goto initAudioTrack_exit;
     }
 
@@ -1050,7 +1046,7 @@
 
     // Cleanup
     if (mpAudioTrack) {
-        LOGV("Delete Track I: %p\n", mpAudioTrack);
+        ALOGV("Delete Track I: %p\n", mpAudioTrack);
         delete mpAudioTrack;
         mpAudioTrack = 0;
     }
@@ -1109,22 +1105,22 @@
             lWaveCmd = WaveGenerator::WAVEGEN_CONT;
             break;
         case TONE_STARTING:
-            LOGV("Starting Cbk");
+            ALOGV("Starting Cbk");
 
             lWaveCmd = WaveGenerator::WAVEGEN_START;
             break;
         case TONE_STOPPING:
         case TONE_RESTARTING:
-            LOGV("Stop/restart Cbk");
+            ALOGV("Stop/restart Cbk");
 
             lWaveCmd = WaveGenerator::WAVEGEN_STOP;
             lpToneGen->mNextSegSmp = TONEGEN_INF; // forced to skip state machine management below
             break;
         case TONE_STOPPED:
-            LOGV("Stopped Cbk");
+            ALOGV("Stopped Cbk");
             goto audioCallback_EndLoop;
         default:
-            LOGV("Extra Cbk");
+            ALOGV("Extra Cbk");
             goto audioCallback_EndLoop;
         }
 
@@ -1145,7 +1141,7 @@
         if (lpToneGen->mTotalSmp > lpToneGen->mNextSegSmp) {
             // Time to go to next sequence segment
 
-            LOGV("End Segment, time: %d\n", (unsigned int)(systemTime()/1000000));
+            ALOGV("End Segment, time: %d\n", (unsigned int)(systemTime()/1000000));
 
             lGenSmp = lReqSmp;
 
@@ -1160,13 +1156,13 @@
                     lpWaveGen->getSamples(lpOut, lGenSmp, lWaveCmd);
                     lFrequency = lpToneDesc->segments[lpToneGen->mCurSegment].waveFreq[++lFreqIdx];
                 }
-                LOGV("ON->OFF, lGenSmp: %d, lReqSmp: %d\n", lGenSmp, lReqSmp);
+                ALOGV("ON->OFF, lGenSmp: %d, lReqSmp: %d\n", lGenSmp, lReqSmp);
             }
 
             // check if we need to loop and loop for the reqd times
             if (lpToneDesc->segments[lpToneGen->mCurSegment].loopCnt) {
                 if (lpToneGen->mLoopCounter < lpToneDesc->segments[lpToneGen->mCurSegment].loopCnt) {
-                    LOGV ("in if loop loopCnt(%d) loopctr(%d), CurSeg(%d) \n",
+                    ALOGV ("in if loop loopCnt(%d) loopctr(%d), CurSeg(%d) \n",
                           lpToneDesc->segments[lpToneGen->mCurSegment].loopCnt,
                           lpToneGen->mLoopCounter,
                           lpToneGen->mCurSegment);
@@ -1176,14 +1172,14 @@
                     // completed loop. go to next segment
                     lpToneGen->mLoopCounter = 0;
                     lpToneGen->mCurSegment++;
-                    LOGV ("in else loop loopCnt(%d) loopctr(%d), CurSeg(%d) \n",
+                    ALOGV ("in else loop loopCnt(%d) loopctr(%d), CurSeg(%d) \n",
                           lpToneDesc->segments[lpToneGen->mCurSegment].loopCnt,
                           lpToneGen->mLoopCounter,
                           lpToneGen->mCurSegment);
                 }
             } else {
                 lpToneGen->mCurSegment++;
-                LOGV ("Goto next seg loopCnt(%d) loopctr(%d), CurSeg(%d) \n",
+                ALOGV ("Goto next seg loopCnt(%d) loopctr(%d), CurSeg(%d) \n",
                       lpToneDesc->segments[lpToneGen->mCurSegment].loopCnt,
                       lpToneGen->mLoopCounter,
                       lpToneGen->mCurSegment);
@@ -1192,32 +1188,32 @@
 
             // Handle loop if last segment reached
             if (lpToneDesc->segments[lpToneGen->mCurSegment].duration == 0) {
-                LOGV("Last Seg: %d\n", lpToneGen->mCurSegment);
+                ALOGV("Last Seg: %d\n", lpToneGen->mCurSegment);
 
                 // Pre increment loop count and restart if total count not reached. Stop sequence otherwise
                 if (++lpToneGen->mCurCount <= lpToneDesc->repeatCnt) {
-                    LOGV("Repeating Count: %d\n", lpToneGen->mCurCount);
+                    ALOGV("Repeating Count: %d\n", lpToneGen->mCurCount);
 
                     lpToneGen->mCurSegment = lpToneDesc->repeatSegment;
                     if (lpToneDesc->segments[lpToneDesc->repeatSegment].waveFreq[0] != 0) {
                         lWaveCmd = WaveGenerator::WAVEGEN_START;
                     }
 
-                    LOGV("New segment %d, Next Time: %d\n", lpToneGen->mCurSegment,
+                    ALOGV("New segment %d, Next Time: %d\n", lpToneGen->mCurSegment,
                             (lpToneGen->mNextSegSmp*1000)/lpToneGen->mSamplingRate);
 
                 } else {
                     lGenSmp = 0;
-                    LOGV("End repeat, time: %d\n", (unsigned int)(systemTime()/1000000));
+                    ALOGV("End repeat, time: %d\n", (unsigned int)(systemTime()/1000000));
                 }
             } else {
-                LOGV("New segment %d, Next Time: %d\n", lpToneGen->mCurSegment,
+                ALOGV("New segment %d, Next Time: %d\n", lpToneGen->mCurSegment,
                         (lpToneGen->mNextSegSmp*1000)/lpToneGen->mSamplingRate);
                 if (lpToneDesc->segments[lpToneGen->mCurSegment].waveFreq[0] != 0) {
                     // If next segment is not silent,  OFF -> ON transition : reset wave generator
                     lWaveCmd = WaveGenerator::WAVEGEN_START;
 
-                    LOGV("OFF->ON, lGenSmp: %d, lReqSmp: %d\n", lGenSmp, lReqSmp);
+                    ALOGV("OFF->ON, lGenSmp: %d, lReqSmp: %d\n", lGenSmp, lReqSmp);
                 } else {
                     lGenSmp = 0;
                 }
@@ -1255,13 +1251,13 @@
 
         switch (lpToneGen->mState) {
         case TONE_RESTARTING:
-            LOGV("Cbk restarting track\n");
+            ALOGV("Cbk restarting track\n");
             if (lpToneGen->prepareWave()) {
                 lpToneGen->mState = TONE_STARTING;
                 // must reload lpToneDesc as prepareWave() may change mpToneDesc
                 lpToneDesc = lpToneGen->mpToneDesc;
             } else {
-                LOGW("Cbk restarting prepareWave() failed\n");
+                ALOGW("Cbk restarting prepareWave() failed\n");
                 lpToneGen->mState = TONE_IDLE;
                 lpToneGen->mpAudioTrack->stop();
                 // Force loop exit
@@ -1270,14 +1266,14 @@
             lSignal = true;
             break;
         case TONE_STOPPING:
-            LOGV("Cbk Stopping\n");
+            ALOGV("Cbk Stopping\n");
             lpToneGen->mState = TONE_STOPPED;
             // Force loop exit
             lNumSmp = 0;
             break;
         case TONE_STOPPED:
             lpToneGen->mState = TONE_INIT;
-            LOGV("Cbk Stopped track\n");
+            ALOGV("Cbk Stopped track\n");
             lpToneGen->mpAudioTrack->stop();
             // Force loop exit
             lNumSmp = 0;
@@ -1285,7 +1281,7 @@
             lSignal = true;
             break;
         case TONE_STARTING:
-            LOGV("Cbk starting track\n");
+            ALOGV("Cbk starting track\n");
             lpToneGen->mState = TONE_PLAYING;
             lSignal = true;
            break;
@@ -1338,7 +1334,7 @@
         } else {
             mMaxSmp = (mDurationMs * mSamplingRate) / 1000;
         }
-        LOGV("prepareWave, duration limited to %d ms", mDurationMs);
+        ALOGV("prepareWave, duration limited to %d ms", mDurationMs);
     }
 
     while (mpToneDesc->segments[segmentIdx].duration) {
@@ -1353,9 +1349,6 @@
                         new ToneGenerator::WaveGenerator((unsigned short)mSamplingRate,
                                 frequency,
                                 TONEGEN_GAIN/lNumWaves);
-                if (lpWaveGen == 0) {
-                    goto prepareWave_exit;
-                }
                 mWaveGens.add(frequency, lpWaveGen);
             }
             frequency = mpNewToneDesc->segments[segmentIdx].waveFreq[++freqIdx];
@@ -1375,12 +1368,6 @@
     }
 
     return true;
-
-prepareWave_exit:
-
-    clearWaveGens();
-
-    return false;
 }
 
 
@@ -1425,7 +1412,7 @@
 //
 ////////////////////////////////////////////////////////////////////////////////
 void ToneGenerator::clearWaveGens() {
-    LOGV("Clearing mWaveGens:");
+    ALOGV("Clearing mWaveGens:");
 
     for (size_t lIdx = 0; lIdx < mWaveGens.size(); lIdx++) {
         delete mWaveGens.valueAt(lIdx);
@@ -1456,7 +1443,7 @@
         regionTone = sToneMappingTable[mRegion][toneType - FIRST_SUP_TONE];
     }
 
-    LOGV("getToneForRegion, tone %d, region %d, regionTone %d", toneType, mRegion, regionTone);
+    ALOGV("getToneForRegion, tone %d, region %d, regionTone %d", toneType, mRegion, regionTone);
 
     return regionTone;
 }
@@ -1504,7 +1491,7 @@
         d0 = 32767;
     mA1_Q14 = (short) d0;
 
-    LOGV("WaveGenerator init, mA1_Q14: %d, mS2_0: %d, mAmplitude_Q15: %d\n",
+    ALOGV("WaveGenerator init, mA1_Q14: %d, mS2_0: %d, mAmplitude_Q15: %d\n",
             mA1_Q14, mS2_0, mAmplitude_Q15);
 }
 
diff --git a/media/libmedia/Visualizer.cpp b/media/libmedia/Visualizer.cpp
index bf40481..66758d2 100644
--- a/media/libmedia/Visualizer.cpp
+++ b/media/libmedia/Visualizer.cpp
@@ -61,7 +61,7 @@
         if (enabled) {
             if (t->exitPending()) {
                 if (t->requestExitAndWait() == WOULD_BLOCK) {
-                    LOGE("Visualizer::enable() called from thread");
+                    ALOGE("Visualizer::enable() called from thread");
                     return INVALID_OPERATION;
                 }
             }
@@ -115,12 +115,8 @@
 
     if (cbk != NULL) {
         mCaptureThread = new CaptureThread(*this, rate, ((flags & CAPTURE_CALL_JAVA) != 0));
-        if (mCaptureThread == 0) {
-            LOGE("Could not create callback thread");
-            return NO_INIT;
-        }
     }
-    LOGV("setCaptureCallBack() rate: %d thread %p flags 0x%08x",
+    ALOGV("setCaptureCallBack() rate: %d thread %p flags 0x%08x",
             rate, mCaptureThread.get(), mCaptureFlags);
     return NO_ERROR;
 }
@@ -147,7 +143,7 @@
     *((int32_t *)p->data + 1)= size;
     status_t status = setParameter(p);
 
-    LOGV("setCaptureSize size %d  status %d p->status %d", size, status, p->status);
+    ALOGV("setCaptureSize size %d  status %d p->status %d", size, status, p->status);
 
     if (status == NO_ERROR) {
         status = p->status;
@@ -172,12 +168,12 @@
     if (mEnabled) {
         uint32_t replySize = mCaptureSize;
         status = command(VISUALIZER_CMD_CAPTURE, 0, NULL, &replySize, waveform);
-        LOGV("getWaveForm() command returned %d", status);
+        ALOGV("getWaveForm() command returned %d", status);
         if (replySize == 0) {
             status = NOT_ENOUGH_DATA;
         }
     } else {
-        LOGV("getWaveForm() disabled");
+        ALOGV("getWaveForm() disabled");
         memset(waveform, 0x80, mCaptureSize);
     }
     return status;
@@ -236,7 +232,7 @@
 void Visualizer::periodicCapture()
 {
     Mutex::Autolock _l(mLock);
-    LOGV("periodicCapture() %p mCaptureCallBack %p mCaptureFlags 0x%08x",
+    ALOGV("periodicCapture() %p mCaptureCallBack %p mCaptureFlags 0x%08x",
             this, mCaptureCallBack, mCaptureFlags);
     if (mCaptureCallBack != NULL &&
         (mCaptureFlags & (CAPTURE_WAVEFORM|CAPTURE_FFT)) &&
@@ -289,7 +285,7 @@
     }
     mCaptureSize = size;
 
-    LOGV("initCaptureSize size %d status %d", mCaptureSize, status);
+    ALOGV("initCaptureSize size %d status %d", mCaptureSize, status);
 
     return size;
 }
@@ -300,18 +296,18 @@
     : Thread(bCanCallJava), mReceiver(receiver)
 {
     mSleepTimeUs = 1000000000 / captureRate;
-    LOGV("CaptureThread cstor %p captureRate %d mSleepTimeUs %d", this, captureRate, mSleepTimeUs);
+    ALOGV("CaptureThread cstor %p captureRate %d mSleepTimeUs %d", this, captureRate, mSleepTimeUs);
 }
 
 bool Visualizer::CaptureThread::threadLoop()
 {
-    LOGV("CaptureThread %p enter", this);
+    ALOGV("CaptureThread %p enter", this);
     while (!exitPending())
     {
         usleep(mSleepTimeUs);
         mReceiver.periodicCapture();
     }
-    LOGV("CaptureThread %p exiting", this);
+    ALOGV("CaptureThread %p exiting", this);
     return false;
 }
 
diff --git a/media/libmedia/mediametadataretriever.cpp b/media/libmedia/mediametadataretriever.cpp
index cee06ab..88e269f 100644
--- a/media/libmedia/mediametadataretriever.cpp
+++ b/media/libmedia/mediametadataretriever.cpp
@@ -43,7 +43,7 @@
             if (binder != 0) {
                 break;
             }
-            LOGW("MediaPlayerService not published, waiting...");
+            ALOGW("MediaPlayerService not published, waiting...");
             usleep(500000); // 0.5 s
         } while(true);
         if (sDeathNotifier == NULL) {
@@ -52,35 +52,35 @@
         binder->linkToDeath(sDeathNotifier);
         sService = interface_cast<IMediaPlayerService>(binder);
     }
-    LOGE_IF(sService == 0, "no MediaPlayerService!?");
+    ALOGE_IF(sService == 0, "no MediaPlayerService!?");
     return sService;
 }
 
 MediaMetadataRetriever::MediaMetadataRetriever()
 {
-    LOGV("constructor");
+    ALOGV("constructor");
     const sp<IMediaPlayerService>& service(getService());
     if (service == 0) {
-        LOGE("failed to obtain MediaMetadataRetrieverService");
+        ALOGE("failed to obtain MediaMetadataRetrieverService");
         return;
     }
     sp<IMediaMetadataRetriever> retriever(service->createMetadataRetriever(getpid()));
     if (retriever == 0) {
-        LOGE("failed to create IMediaMetadataRetriever object from server");
+        ALOGE("failed to create IMediaMetadataRetriever object from server");
     }
     mRetriever = retriever;
 }
 
 MediaMetadataRetriever::~MediaMetadataRetriever()
 {
-    LOGV("destructor");
+    ALOGV("destructor");
     disconnect();
     IPCThreadState::self()->flushCommands();
 }
 
 void MediaMetadataRetriever::disconnect()
 {
-    LOGV("disconnect");
+    ALOGV("disconnect");
     sp<IMediaMetadataRetriever> retriever;
     {
         Mutex::Autolock _l(mLock);
@@ -95,30 +95,30 @@
 status_t MediaMetadataRetriever::setDataSource(
         const char *srcUrl, const KeyedVector<String8, String8> *headers)
 {
-    LOGV("setDataSource");
+    ALOGV("setDataSource");
     Mutex::Autolock _l(mLock);
     if (mRetriever == 0) {
-        LOGE("retriever is not initialized");
+        ALOGE("retriever is not initialized");
         return INVALID_OPERATION;
     }
     if (srcUrl == NULL) {
-        LOGE("data source is a null pointer");
+        ALOGE("data source is a null pointer");
         return UNKNOWN_ERROR;
     }
-    LOGV("data source (%s)", srcUrl);
+    ALOGV("data source (%s)", srcUrl);
     return mRetriever->setDataSource(srcUrl, headers);
 }
 
 status_t MediaMetadataRetriever::setDataSource(int fd, int64_t offset, int64_t length)
 {
-    LOGV("setDataSource(%d, %lld, %lld)", fd, offset, length);
+    ALOGV("setDataSource(%d, %lld, %lld)", fd, offset, length);
     Mutex::Autolock _l(mLock);
     if (mRetriever == 0) {
-        LOGE("retriever is not initialized");
+        ALOGE("retriever is not initialized");
         return INVALID_OPERATION;
     }
     if (fd < 0 || offset < 0 || length < 0) {
-        LOGE("Invalid negative argument");
+        ALOGE("Invalid negative argument");
         return UNKNOWN_ERROR;
     }
     return mRetriever->setDataSource(fd, offset, length);
@@ -126,10 +126,10 @@
 
 sp<IMemory> MediaMetadataRetriever::getFrameAtTime(int64_t timeUs, int option)
 {
-    LOGV("getFrameAtTime: time(%lld us) option(%d)", timeUs, option);
+    ALOGV("getFrameAtTime: time(%lld us) option(%d)", timeUs, option);
     Mutex::Autolock _l(mLock);
     if (mRetriever == 0) {
-        LOGE("retriever is not initialized");
+        ALOGE("retriever is not initialized");
         return NULL;
     }
     return mRetriever->getFrameAtTime(timeUs, option);
@@ -137,10 +137,10 @@
 
 const char* MediaMetadataRetriever::extractMetadata(int keyCode)
 {
-    LOGV("extractMetadata(%d)", keyCode);
+    ALOGV("extractMetadata(%d)", keyCode);
     Mutex::Autolock _l(mLock);
     if (mRetriever == 0) {
-        LOGE("retriever is not initialized");
+        ALOGE("retriever is not initialized");
         return NULL;
     }
     return mRetriever->extractMetadata(keyCode);
@@ -148,10 +148,10 @@
 
 sp<IMemory> MediaMetadataRetriever::extractAlbumArt()
 {
-    LOGV("extractAlbumArt");
+    ALOGV("extractAlbumArt");
     Mutex::Autolock _l(mLock);
     if (mRetriever == 0) {
-        LOGE("retriever is not initialized");
+        ALOGE("retriever is not initialized");
         return NULL;
     }
     return mRetriever->extractAlbumArt();
@@ -160,7 +160,7 @@
 void MediaMetadataRetriever::DeathNotifier::binderDied(const wp<IBinder>& who) {
     Mutex::Autolock lock(MediaMetadataRetriever::sServiceLock);
     MediaMetadataRetriever::sService.clear();
-    LOGW("MediaMetadataRetriever server died!");
+    ALOGW("MediaMetadataRetriever server died!");
 }
 
 MediaMetadataRetriever::DeathNotifier::~DeathNotifier()
diff --git a/media/libmedia/mediaplayer.cpp b/media/libmedia/mediaplayer.cpp
index c2e1ddf..4be960c 100644
--- a/media/libmedia/mediaplayer.cpp
+++ b/media/libmedia/mediaplayer.cpp
@@ -46,7 +46,7 @@
 
 MediaPlayer::MediaPlayer()
 {
-    LOGV("constructor");
+    ALOGV("constructor");
     mListener = NULL;
     mCookie = NULL;
     mDuration = -1;
@@ -67,7 +67,7 @@
 
 MediaPlayer::~MediaPlayer()
 {
-    LOGV("destructor");
+    ALOGV("destructor");
     AudioSystem::releaseAudioSessionId(mAudioSessionId);
     disconnect();
     IPCThreadState::self()->flushCommands();
@@ -75,7 +75,7 @@
 
 void MediaPlayer::disconnect()
 {
-    LOGV("disconnect");
+    ALOGV("disconnect");
     sp<IMediaPlayer> p;
     {
         Mutex::Autolock _l(mLock);
@@ -99,7 +99,7 @@
 
 status_t MediaPlayer::setListener(const sp<MediaPlayerListener>& listener)
 {
-    LOGV("setListener");
+    ALOGV("setListener");
     Mutex::Autolock _l(mLock);
     mListener = listener;
     return NO_ERROR;
@@ -115,7 +115,7 @@
 
         if ( !( (mCurrentState & MEDIA_PLAYER_IDLE) ||
                 (mCurrentState == MEDIA_PLAYER_STATE_ERROR ) ) ) {
-            LOGE("attachNewPlayer called in state %d", mCurrentState);
+            ALOGE("attachNewPlayer called in state %d", mCurrentState);
             return INVALID_OPERATION;
         }
 
@@ -126,7 +126,7 @@
             mCurrentState = MEDIA_PLAYER_INITIALIZED;
             err = NO_ERROR;
         } else {
-            LOGE("Unable to to create media player");
+            ALOGE("Unable to to create media player");
         }
     }
 
@@ -140,7 +140,7 @@
 status_t MediaPlayer::setDataSource(
         const char *url, const KeyedVector<String8, String8> *headers)
 {
-    LOGV("setDataSource(%s)", url);
+    ALOGV("setDataSource(%s)", url);
     status_t err = BAD_VALUE;
     if (url != NULL) {
         const sp<IMediaPlayerService>& service(getMediaPlayerService());
@@ -157,7 +157,7 @@
 
 status_t MediaPlayer::setDataSource(int fd, int64_t offset, int64_t length)
 {
-    LOGV("setDataSource(%d, %lld, %lld)", fd, offset, length);
+    ALOGV("setDataSource(%d, %lld, %lld)", fd, offset, length);
     status_t err = UNKNOWN_ERROR;
     const sp<IMediaPlayerService>& service(getMediaPlayerService());
     if (service != 0) {
@@ -172,7 +172,7 @@
 
 status_t MediaPlayer::setDataSource(const sp<IStreamSource> &source)
 {
-    LOGV("setDataSource");
+    ALOGV("setDataSource");
     status_t err = UNKNOWN_ERROR;
     const sp<IMediaPlayerService>& service(getMediaPlayerService());
     if (service != 0) {
@@ -192,16 +192,16 @@
             (mCurrentState != MEDIA_PLAYER_STATE_ERROR) &&
             ((mCurrentState & MEDIA_PLAYER_IDLE) != MEDIA_PLAYER_IDLE);
     if ((mPlayer != NULL) && hasBeenInitialized) {
-         LOGV("invoke %d", request.dataSize());
+         ALOGV("invoke %d", request.dataSize());
          return  mPlayer->invoke(request, reply);
     }
-    LOGE("invoke failed: wrong state %X", mCurrentState);
+    ALOGE("invoke failed: wrong state %X", mCurrentState);
     return INVALID_OPERATION;
 }
 
 status_t MediaPlayer::setMetadataFilter(const Parcel& filter)
 {
-    LOGD("setMetadataFilter");
+    ALOGD("setMetadataFilter");
     Mutex::Autolock lock(mLock);
     if (mPlayer == NULL) {
         return NO_INIT;
@@ -211,7 +211,7 @@
 
 status_t MediaPlayer::getMetadata(bool update_only, bool apply_filter, Parcel *metadata)
 {
-    LOGD("getMetadata");
+    ALOGD("getMetadata");
     Mutex::Autolock lock(mLock);
     if (mPlayer == NULL) {
         return NO_INIT;
@@ -222,7 +222,7 @@
 status_t MediaPlayer::setVideoSurfaceTexture(
         const sp<ISurfaceTexture>& surfaceTexture)
 {
-    LOGV("setVideoSurfaceTexture");
+    ALOGV("setVideoSurfaceTexture");
     Mutex::Autolock _l(mLock);
     if (mPlayer == 0) return NO_INIT;
     return mPlayer->setVideoSurfaceTexture(surfaceTexture);
@@ -236,7 +236,7 @@
         mCurrentState = MEDIA_PLAYER_PREPARING;
         return mPlayer->prepareAsync();
     }
-    LOGE("prepareAsync called in state %d", mCurrentState);
+    ALOGE("prepareAsync called in state %d", mCurrentState);
     return INVALID_OPERATION;
 }
 
@@ -246,7 +246,7 @@
 // code.
 status_t MediaPlayer::prepare()
 {
-    LOGV("prepare");
+    ALOGV("prepare");
     Mutex::Autolock _l(mLock);
     mLockThreadId = getThreadId();
     if (mPrepareSync) {
@@ -264,21 +264,21 @@
         mSignal.wait(mLock);  // wait for prepare done
         mPrepareSync = false;
     }
-    LOGV("prepare complete - status=%d", mPrepareStatus);
+    ALOGV("prepare complete - status=%d", mPrepareStatus);
     mLockThreadId = 0;
     return mPrepareStatus;
 }
 
 status_t MediaPlayer::prepareAsync()
 {
-    LOGV("prepareAsync");
+    ALOGV("prepareAsync");
     Mutex::Autolock _l(mLock);
     return prepareAsync_l();
 }
 
 status_t MediaPlayer::start()
 {
-    LOGV("start");
+    ALOGV("start");
     Mutex::Autolock _l(mLock);
     if (mCurrentState & MEDIA_PLAYER_STARTED)
         return NO_ERROR;
@@ -293,18 +293,18 @@
             mCurrentState = MEDIA_PLAYER_STATE_ERROR;
         } else {
             if (mCurrentState == MEDIA_PLAYER_PLAYBACK_COMPLETE) {
-                LOGV("playback completed immediately following start()");
+                ALOGV("playback completed immediately following start()");
             }
         }
         return ret;
     }
-    LOGE("start called in state %d", mCurrentState);
+    ALOGE("start called in state %d", mCurrentState);
     return INVALID_OPERATION;
 }
 
 status_t MediaPlayer::stop()
 {
-    LOGV("stop");
+    ALOGV("stop");
     Mutex::Autolock _l(mLock);
     if (mCurrentState & MEDIA_PLAYER_STOPPED) return NO_ERROR;
     if ( (mPlayer != 0) && ( mCurrentState & ( MEDIA_PLAYER_STARTED | MEDIA_PLAYER_PREPARED |
@@ -317,13 +317,13 @@
         }
         return ret;
     }
-    LOGE("stop called in state %d", mCurrentState);
+    ALOGE("stop called in state %d", mCurrentState);
     return INVALID_OPERATION;
 }
 
 status_t MediaPlayer::pause()
 {
-    LOGV("pause");
+    ALOGV("pause");
     Mutex::Autolock _l(mLock);
     if (mCurrentState & (MEDIA_PLAYER_PAUSED|MEDIA_PLAYER_PLAYBACK_COMPLETE))
         return NO_ERROR;
@@ -336,7 +336,7 @@
         }
         return ret;
     }
-    LOGE("pause called in state %d", mCurrentState);
+    ALOGE("pause called in state %d", mCurrentState);
     return INVALID_OPERATION;
 }
 
@@ -346,20 +346,20 @@
     if (mPlayer != 0) {
         bool temp = false;
         mPlayer->isPlaying(&temp);
-        LOGV("isPlaying: %d", temp);
+        ALOGV("isPlaying: %d", temp);
         if ((mCurrentState & MEDIA_PLAYER_STARTED) && ! temp) {
-            LOGE("internal/external state mismatch corrected");
+            ALOGE("internal/external state mismatch corrected");
             mCurrentState = MEDIA_PLAYER_PAUSED;
         }
         return temp;
     }
-    LOGV("isPlaying: no active player");
+    ALOGV("isPlaying: no active player");
     return false;
 }
 
 status_t MediaPlayer::getVideoWidth(int *w)
 {
-    LOGV("getVideoWidth");
+    ALOGV("getVideoWidth");
     Mutex::Autolock _l(mLock);
     if (mPlayer == 0) return INVALID_OPERATION;
     *w = mVideoWidth;
@@ -368,7 +368,7 @@
 
 status_t MediaPlayer::getVideoHeight(int *h)
 {
-    LOGV("getVideoHeight");
+    ALOGV("getVideoHeight");
     Mutex::Autolock _l(mLock);
     if (mPlayer == 0) return INVALID_OPERATION;
     *h = mVideoHeight;
@@ -377,11 +377,11 @@
 
 status_t MediaPlayer::getCurrentPosition(int *msec)
 {
-    LOGV("getCurrentPosition");
+    ALOGV("getCurrentPosition");
     Mutex::Autolock _l(mLock);
     if (mPlayer != 0) {
         if (mCurrentPosition >= 0) {
-            LOGV("Using cached seek position: %d", mCurrentPosition);
+            ALOGV("Using cached seek position: %d", mCurrentPosition);
             *msec = mCurrentPosition;
             return NO_ERROR;
         }
@@ -392,7 +392,7 @@
 
 status_t MediaPlayer::getDuration_l(int *msec)
 {
-    LOGV("getDuration");
+    ALOGV("getDuration");
     bool isValidState = (mCurrentState & (MEDIA_PLAYER_PREPARED | MEDIA_PLAYER_STARTED | MEDIA_PLAYER_PAUSED | MEDIA_PLAYER_STOPPED | MEDIA_PLAYER_PLAYBACK_COMPLETE));
     if (mPlayer != 0 && isValidState) {
         status_t ret = NO_ERROR;
@@ -402,7 +402,7 @@
             *msec = mDuration;
         return ret;
     }
-    LOGE("Attempt to call getDuration without a valid mediaplayer");
+    ALOGE("Attempt to call getDuration without a valid mediaplayer");
     return INVALID_OPERATION;
 }
 
@@ -414,13 +414,13 @@
 
 status_t MediaPlayer::seekTo_l(int msec)
 {
-    LOGV("seekTo %d", msec);
+    ALOGV("seekTo %d", msec);
     if ((mPlayer != 0) && ( mCurrentState & ( MEDIA_PLAYER_STARTED | MEDIA_PLAYER_PREPARED | MEDIA_PLAYER_PAUSED |  MEDIA_PLAYER_PLAYBACK_COMPLETE) ) ) {
         if ( msec < 0 ) {
-            LOGW("Attempt to seek to invalid position: %d", msec);
+            ALOGW("Attempt to seek to invalid position: %d", msec);
             msec = 0;
         } else if ((mDuration > 0) && (msec > mDuration)) {
-            LOGW("Attempt to seek to past end of file: request = %d, EOF = %d", msec, mDuration);
+            ALOGW("Attempt to seek to past end of file: request = %d, EOF = %d", msec, mDuration);
             msec = mDuration;
         }
         // cache duration
@@ -431,11 +431,11 @@
             return mPlayer->seekTo(msec);
         }
         else {
-            LOGV("Seek in progress - queue up seekTo[%d]", msec);
+            ALOGV("Seek in progress - queue up seekTo[%d]", msec);
             return NO_ERROR;
         }
     }
-    LOGE("Attempt to perform seekTo in wrong state: mPlayer=%p, mCurrentState=%u", mPlayer.get(), mCurrentState);
+    ALOGE("Attempt to perform seekTo in wrong state: mPlayer=%p, mCurrentState=%u", mPlayer.get(), mCurrentState);
     return INVALID_OPERATION;
 }
 
@@ -457,7 +457,7 @@
     if (mPlayer != 0) {
         status_t ret = mPlayer->reset();
         if (ret != NO_ERROR) {
-            LOGE("reset() failed with return code (%d)", ret);
+            ALOGE("reset() failed with return code (%d)", ret);
             mCurrentState = MEDIA_PLAYER_STATE_ERROR;
         } else {
             mCurrentState = MEDIA_PLAYER_IDLE;
@@ -473,20 +473,20 @@
 
 status_t MediaPlayer::reset()
 {
-    LOGV("reset");
+    ALOGV("reset");
     Mutex::Autolock _l(mLock);
     return reset_l();
 }
 
 status_t MediaPlayer::setAudioStreamType(int type)
 {
-    LOGV("MediaPlayer::setAudioStreamType");
+    ALOGV("MediaPlayer::setAudioStreamType");
     Mutex::Autolock _l(mLock);
     if (mStreamType == type) return NO_ERROR;
     if (mCurrentState & ( MEDIA_PLAYER_PREPARED | MEDIA_PLAYER_STARTED |
                 MEDIA_PLAYER_PAUSED | MEDIA_PLAYER_PLAYBACK_COMPLETE ) ) {
         // Can't change the stream type after prepare
-        LOGE("setAudioStream called in state %d", mCurrentState);
+        ALOGE("setAudioStream called in state %d", mCurrentState);
         return INVALID_OPERATION;
     }
     // cache
@@ -496,7 +496,7 @@
 
 status_t MediaPlayer::setLooping(int loop)
 {
-    LOGV("MediaPlayer::setLooping");
+    ALOGV("MediaPlayer::setLooping");
     Mutex::Autolock _l(mLock);
     mLoop = (loop != 0);
     if (mPlayer != 0) {
@@ -506,18 +506,18 @@
 }
 
 bool MediaPlayer::isLooping() {
-    LOGV("isLooping");
+    ALOGV("isLooping");
     Mutex::Autolock _l(mLock);
     if (mPlayer != 0) {
         return mLoop;
     }
-    LOGV("isLooping: no active player");
+    ALOGV("isLooping: no active player");
     return false;
 }
 
 status_t MediaPlayer::setVolume(float leftVolume, float rightVolume)
 {
-    LOGV("MediaPlayer::setVolume(%f, %f)", leftVolume, rightVolume);
+    ALOGV("MediaPlayer::setVolume(%f, %f)", leftVolume, rightVolume);
     Mutex::Autolock _l(mLock);
     mLeftVolume = leftVolume;
     mRightVolume = rightVolume;
@@ -529,10 +529,10 @@
 
 status_t MediaPlayer::setAudioSessionId(int sessionId)
 {
-    LOGV("MediaPlayer::setAudioSessionId(%d)", sessionId);
+    ALOGV("MediaPlayer::setAudioSessionId(%d)", sessionId);
     Mutex::Autolock _l(mLock);
     if (!(mCurrentState & MEDIA_PLAYER_IDLE)) {
-        LOGE("setAudioSessionId called in state %d", mCurrentState);
+        ALOGE("setAudioSessionId called in state %d", mCurrentState);
         return INVALID_OPERATION;
     }
     if (sessionId < 0) {
@@ -554,7 +554,7 @@
 
 status_t MediaPlayer::setAuxEffectSendLevel(float level)
 {
-    LOGV("MediaPlayer::setAuxEffectSendLevel(%f)", level);
+    ALOGV("MediaPlayer::setAuxEffectSendLevel(%f)", level);
     Mutex::Autolock _l(mLock);
     mSendLevel = level;
     if (mPlayer != 0) {
@@ -565,12 +565,12 @@
 
 status_t MediaPlayer::attachAuxEffect(int effectId)
 {
-    LOGV("MediaPlayer::attachAuxEffect(%d)", effectId);
+    ALOGV("MediaPlayer::attachAuxEffect(%d)", effectId);
     Mutex::Autolock _l(mLock);
     if (mPlayer == 0 ||
         (mCurrentState & MEDIA_PLAYER_IDLE) ||
         (mCurrentState == MEDIA_PLAYER_STATE_ERROR )) {
-        LOGE("attachAuxEffect called in state %d", mCurrentState);
+        ALOGE("attachAuxEffect called in state %d", mCurrentState);
         return INVALID_OPERATION;
     }
 
@@ -579,29 +579,29 @@
 
 status_t MediaPlayer::setParameter(int key, const Parcel& request)
 {
-    LOGV("MediaPlayer::setParameter(%d)", key);
+    ALOGV("MediaPlayer::setParameter(%d)", key);
     Mutex::Autolock _l(mLock);
     if (mPlayer != NULL) {
         return  mPlayer->setParameter(key, request);
     }
-    LOGV("setParameter: no active player");
+    ALOGV("setParameter: no active player");
     return INVALID_OPERATION;
 }
 
 status_t MediaPlayer::getParameter(int key, Parcel *reply)
 {
-    LOGV("MediaPlayer::getParameter(%d)", key);
+    ALOGV("MediaPlayer::getParameter(%d)", key);
     Mutex::Autolock _l(mLock);
     if (mPlayer != NULL) {
          return  mPlayer->getParameter(key, reply);
     }
-    LOGV("getParameter: no active player");
+    ALOGV("getParameter: no active player");
     return INVALID_OPERATION;
 }
 
 void MediaPlayer::notify(int msg, int ext1, int ext2, const Parcel *obj)
 {
-    LOGV("message received msg=%d, ext1=%d, ext2=%d", msg, ext1, ext2);
+    ALOGV("message received msg=%d, ext1=%d, ext2=%d", msg, ext1, ext2);
     bool send = true;
     bool locked = false;
 
@@ -620,7 +620,7 @@
 
     // Allows calls from JNI in idle state to notify errors
     if (!(msg == MEDIA_ERROR && mCurrentState == MEDIA_PLAYER_IDLE) && mPlayer == 0) {
-        LOGV("notify(%d, %d, %d) callback on disconnected mediaplayer", msg, ext1, ext2);
+        ALOGV("notify(%d, %d, %d) callback on disconnected mediaplayer", msg, ext1, ext2);
         if (locked) mLock.unlock();   // release the lock when done.
         return;
     }
@@ -629,19 +629,19 @@
     case MEDIA_NOP: // interface test message
         break;
     case MEDIA_PREPARED:
-        LOGV("prepared");
+        ALOGV("prepared");
         mCurrentState = MEDIA_PLAYER_PREPARED;
         if (mPrepareSync) {
-            LOGV("signal application thread");
+            ALOGV("signal application thread");
             mPrepareSync = false;
             mPrepareStatus = NO_ERROR;
             mSignal.signal();
         }
         break;
     case MEDIA_PLAYBACK_COMPLETE:
-        LOGV("playback complete");
+        ALOGV("playback complete");
         if (mCurrentState == MEDIA_PLAYER_IDLE) {
-            LOGE("playback complete in idle state");
+            ALOGE("playback complete in idle state");
         }
         if (!mLoop) {
             mCurrentState = MEDIA_PLAYER_PLAYBACK_COMPLETE;
@@ -651,11 +651,11 @@
         // Always log errors.
         // ext1: Media framework error code.
         // ext2: Implementation dependant error code.
-        LOGE("error (%d, %d)", ext1, ext2);
+        ALOGE("error (%d, %d)", ext1, ext2);
         mCurrentState = MEDIA_PLAYER_STATE_ERROR;
         if (mPrepareSync)
         {
-            LOGV("signal application thread");
+            ALOGV("signal application thread");
             mPrepareSync = false;
             mPrepareStatus = ext1;
             mSignal.signal();
@@ -666,34 +666,34 @@
         // ext1: Media framework error code.
         // ext2: Implementation dependant error code.
         if (ext1 != MEDIA_INFO_VIDEO_TRACK_LAGGING) {
-            LOGW("info/warning (%d, %d)", ext1, ext2);
+            ALOGW("info/warning (%d, %d)", ext1, ext2);
         }
         break;
     case MEDIA_SEEK_COMPLETE:
-        LOGV("Received seek complete");
+        ALOGV("Received seek complete");
         if (mSeekPosition != mCurrentPosition) {
-            LOGV("Executing queued seekTo(%d)", mSeekPosition);
+            ALOGV("Executing queued seekTo(%d)", mSeekPosition);
             mSeekPosition = -1;
             seekTo_l(mCurrentPosition);
         }
         else {
-            LOGV("All seeks complete - return to regularly scheduled program");
+            ALOGV("All seeks complete - return to regularly scheduled program");
             mCurrentPosition = mSeekPosition = -1;
         }
         break;
     case MEDIA_BUFFERING_UPDATE:
-        LOGV("buffering %d", ext1);
+        ALOGV("buffering %d", ext1);
         break;
     case MEDIA_SET_VIDEO_SIZE:
-        LOGV("New video size %d x %d", ext1, ext2);
+        ALOGV("New video size %d x %d", ext1, ext2);
         mVideoWidth = ext1;
         mVideoHeight = ext2;
         break;
     case MEDIA_TIMED_TEXT:
-        LOGV("Received timed text message");
+        ALOGV("Received timed text message");
         break;
     default:
-        LOGV("unrecognized message: (%d, %d, %d)", msg, ext1, ext2);
+        ALOGV("unrecognized message: (%d, %d, %d)", msg, ext1, ext2);
         break;
     }
 
@@ -703,21 +703,21 @@
     // this prevents re-entrant calls into client code
     if ((listener != 0) && send) {
         Mutex::Autolock _l(mNotifyLock);
-        LOGV("callback application");
+        ALOGV("callback application");
         listener->notify(msg, ext1, ext2, obj);
-        LOGV("back from callback");
+        ALOGV("back from callback");
     }
 }
 
-/*static*/ sp<IMemory> MediaPlayer::decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, int* pFormat)
+/*static*/ sp<IMemory> MediaPlayer::decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, audio_format_t* pFormat)
 {
-    LOGV("decode(%s)", url);
+    ALOGV("decode(%s)", url);
     sp<IMemory> p;
     const sp<IMediaPlayerService>& service = getMediaPlayerService();
     if (service != 0) {
         p = service->decode(url, pSampleRate, pNumChannels, pFormat);
     } else {
-        LOGE("Unable to locate media service");
+        ALOGE("Unable to locate media service");
     }
     return p;
 
@@ -725,19 +725,19 @@
 
 void MediaPlayer::died()
 {
-    LOGV("died");
+    ALOGV("died");
     notify(MEDIA_ERROR, MEDIA_ERROR_SERVER_DIED, 0);
 }
 
-/*static*/ sp<IMemory> MediaPlayer::decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, int* pFormat)
+/*static*/ sp<IMemory> MediaPlayer::decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, audio_format_t* pFormat)
 {
-    LOGV("decode(%d, %lld, %lld)", fd, offset, length);
+    ALOGV("decode(%d, %lld, %lld)", fd, offset, length);
     sp<IMemory> p;
     const sp<IMediaPlayerService>& service = getMediaPlayerService();
     if (service != 0) {
         p = service->decode(fd, offset, length, pSampleRate, pNumChannels, pFormat);
     } else {
-        LOGE("Unable to locate media service");
+        ALOGE("Unable to locate media service");
     }
     return p;
 
diff --git a/media/libmedia/mediarecorder.cpp b/media/libmedia/mediarecorder.cpp
index 11d281f..8d947d8 100644
--- a/media/libmedia/mediarecorder.cpp
+++ b/media/libmedia/mediarecorder.cpp
@@ -31,19 +31,19 @@
 
 status_t MediaRecorder::setCamera(const sp<ICamera>& camera, const sp<ICameraRecordingProxy>& proxy)
 {
-    LOGV("setCamera(%p,%p)", camera.get(), proxy.get());
+    ALOGV("setCamera(%p,%p)", camera.get(), proxy.get());
     if(mMediaRecorder == NULL) {
-        LOGE("media recorder is not initialized yet");
+        ALOGE("media recorder is not initialized yet");
         return INVALID_OPERATION;
     }
     if (!(mCurrentState & MEDIA_RECORDER_IDLE)) {
-        LOGE("setCamera called in an invalid state(%d)", mCurrentState);
+        ALOGE("setCamera called in an invalid state(%d)", mCurrentState);
         return INVALID_OPERATION;
     }
 
     status_t ret = mMediaRecorder->setCamera(camera, proxy);
     if (OK != ret) {
-        LOGV("setCamera failed: %d", ret);
+        ALOGV("setCamera failed: %d", ret);
         mCurrentState = MEDIA_RECORDER_ERROR;
         return ret;
     }
@@ -52,23 +52,23 @@
 
 status_t MediaRecorder::setPreviewSurface(const sp<Surface>& surface)
 {
-    LOGV("setPreviewSurface(%p)", surface.get());
+    ALOGV("setPreviewSurface(%p)", surface.get());
     if(mMediaRecorder == NULL) {
-        LOGE("media recorder is not initialized yet");
+        ALOGE("media recorder is not initialized yet");
         return INVALID_OPERATION;
     }
     if (!(mCurrentState & MEDIA_RECORDER_DATASOURCE_CONFIGURED)) {
-        LOGE("setPreviewSurface called in an invalid state(%d)", mCurrentState);
+        ALOGE("setPreviewSurface called in an invalid state(%d)", mCurrentState);
         return INVALID_OPERATION;
     }
     if (!mIsVideoSourceSet) {
-        LOGE("try to set preview surface without setting the video source first");
+        ALOGE("try to set preview surface without setting the video source first");
         return INVALID_OPERATION;
     }
 
     status_t ret = mMediaRecorder->setPreviewSurface(surface);
     if (OK != ret) {
-        LOGV("setPreviewSurface failed: %d", ret);
+        ALOGV("setPreviewSurface failed: %d", ret);
         mCurrentState = MEDIA_RECORDER_ERROR;
         return ret;
     }
@@ -77,26 +77,26 @@
 
 status_t MediaRecorder::init()
 {
-    LOGV("init");
+    ALOGV("init");
     if(mMediaRecorder == NULL) {
-        LOGE("media recorder is not initialized yet");
+        ALOGE("media recorder is not initialized yet");
         return INVALID_OPERATION;
     }
     if (!(mCurrentState & MEDIA_RECORDER_IDLE)) {
-        LOGE("init called in an invalid state(%d)", mCurrentState);
+        ALOGE("init called in an invalid state(%d)", mCurrentState);
         return INVALID_OPERATION;
     }
 
     status_t ret = mMediaRecorder->init();
     if (OK != ret) {
-        LOGV("init failed: %d", ret);
+        ALOGV("init failed: %d", ret);
         mCurrentState = MEDIA_RECORDER_ERROR;
         return ret;
     }
 
     ret = mMediaRecorder->setListener(this);
     if (OK != ret) {
-        LOGV("setListener failed: %d", ret);
+        ALOGV("setListener failed: %d", ret);
         mCurrentState = MEDIA_RECORDER_ERROR;
         return ret;
     }
@@ -107,24 +107,24 @@
 
 status_t MediaRecorder::setVideoSource(int vs)
 {
-    LOGV("setVideoSource(%d)", vs);
+    ALOGV("setVideoSource(%d)", vs);
     if(mMediaRecorder == NULL) {
-        LOGE("media recorder is not initialized yet");
+        ALOGE("media recorder is not initialized yet");
         return INVALID_OPERATION;
     }
     if (mIsVideoSourceSet) {
-        LOGE("video source has already been set");
+        ALOGE("video source has already been set");
         return INVALID_OPERATION;
     }
     if (mCurrentState & MEDIA_RECORDER_IDLE) {
-        LOGV("Call init() since the media recorder is not initialized yet");
+        ALOGV("Call init() since the media recorder is not initialized yet");
         status_t ret = init();
         if (OK != ret) {
             return ret;
         }
     }
     if (!(mCurrentState & MEDIA_RECORDER_INITIALIZED)) {
-        LOGE("setVideoSource called in an invalid state(%d)", mCurrentState);
+        ALOGE("setVideoSource called in an invalid state(%d)", mCurrentState);
         return INVALID_OPERATION;
     }
 
@@ -132,7 +132,7 @@
     status_t ret = mMediaRecorder->setVideoSource(vs);
 
     if (OK != ret) {
-        LOGV("setVideoSource failed: %d", ret);
+        ALOGV("setVideoSource failed: %d", ret);
         mCurrentState = MEDIA_RECORDER_ERROR;
         return ret;
     }
@@ -142,30 +142,30 @@
 
 status_t MediaRecorder::setAudioSource(int as)
 {
-    LOGV("setAudioSource(%d)", as);
+    ALOGV("setAudioSource(%d)", as);
     if(mMediaRecorder == NULL) {
-        LOGE("media recorder is not initialized yet");
+        ALOGE("media recorder is not initialized yet");
         return INVALID_OPERATION;
     }
     if (mCurrentState & MEDIA_RECORDER_IDLE) {
-        LOGV("Call init() since the media recorder is not initialized yet");
+        ALOGV("Call init() since the media recorder is not initialized yet");
         status_t ret = init();
         if (OK != ret) {
             return ret;
         }
     }
     if (mIsAudioSourceSet) {
-        LOGE("audio source has already been set");
+        ALOGE("audio source has already been set");
         return INVALID_OPERATION;
     }
     if (!(mCurrentState & MEDIA_RECORDER_INITIALIZED)) {
-        LOGE("setAudioSource called in an invalid state(%d)", mCurrentState);
+        ALOGE("setAudioSource called in an invalid state(%d)", mCurrentState);
         return INVALID_OPERATION;
     }
 
     status_t ret = mMediaRecorder->setAudioSource(as);
     if (OK != ret) {
-        LOGV("setAudioSource failed: %d", ret);
+        ALOGV("setAudioSource failed: %d", ret);
         mCurrentState = MEDIA_RECORDER_ERROR;
         return ret;
     }
@@ -175,23 +175,23 @@
 
 status_t MediaRecorder::setOutputFormat(int of)
 {
-    LOGV("setOutputFormat(%d)", of);
+    ALOGV("setOutputFormat(%d)", of);
     if(mMediaRecorder == NULL) {
-        LOGE("media recorder is not initialized yet");
+        ALOGE("media recorder is not initialized yet");
         return INVALID_OPERATION;
     }
     if (!(mCurrentState & MEDIA_RECORDER_INITIALIZED)) {
-        LOGE("setOutputFormat called in an invalid state: %d", mCurrentState);
+        ALOGE("setOutputFormat called in an invalid state: %d", mCurrentState);
         return INVALID_OPERATION;
     }
     if (mIsVideoSourceSet && of >= OUTPUT_FORMAT_AUDIO_ONLY_START && of != OUTPUT_FORMAT_RTP_AVP && of != OUTPUT_FORMAT_MPEG2TS) { //first non-video output format
-        LOGE("output format (%d) is meant for audio recording only and incompatible with video recording", of);
+        ALOGE("output format (%d) is meant for audio recording only and incompatible with video recording", of);
         return INVALID_OPERATION;
     }
 
     status_t ret = mMediaRecorder->setOutputFormat(of);
     if (OK != ret) {
-        LOGE("setOutputFormat failed: %d", ret);
+        ALOGE("setOutputFormat failed: %d", ret);
         mCurrentState = MEDIA_RECORDER_ERROR;
         return ret;
     }
@@ -201,27 +201,27 @@
 
 status_t MediaRecorder::setVideoEncoder(int ve)
 {
-    LOGV("setVideoEncoder(%d)", ve);
+    ALOGV("setVideoEncoder(%d)", ve);
     if(mMediaRecorder == NULL) {
-        LOGE("media recorder is not initialized yet");
+        ALOGE("media recorder is not initialized yet");
         return INVALID_OPERATION;
     }
     if (!mIsVideoSourceSet) {
-        LOGE("try to set the video encoder without setting the video source first");
+        ALOGE("try to set the video encoder without setting the video source first");
         return INVALID_OPERATION;
     }
     if (mIsVideoEncoderSet) {
-        LOGE("video encoder has already been set");
+        ALOGE("video encoder has already been set");
         return INVALID_OPERATION;
     }
     if (!(mCurrentState & MEDIA_RECORDER_DATASOURCE_CONFIGURED)) {
-        LOGE("setVideoEncoder called in an invalid state(%d)", mCurrentState);
+        ALOGE("setVideoEncoder called in an invalid state(%d)", mCurrentState);
         return INVALID_OPERATION;
     }
 
     status_t ret = mMediaRecorder->setVideoEncoder(ve);
     if (OK != ret) {
-        LOGV("setVideoEncoder failed: %d", ret);
+        ALOGV("setVideoEncoder failed: %d", ret);
         mCurrentState = MEDIA_RECORDER_ERROR;
         return ret;
     }
@@ -231,27 +231,27 @@
 
 status_t MediaRecorder::setAudioEncoder(int ae)
 {
-    LOGV("setAudioEncoder(%d)", ae);
+    ALOGV("setAudioEncoder(%d)", ae);
     if(mMediaRecorder == NULL) {
-        LOGE("media recorder is not initialized yet");
+        ALOGE("media recorder is not initialized yet");
         return INVALID_OPERATION;
     }
     if (!mIsAudioSourceSet) {
-        LOGE("try to set the audio encoder without setting the audio source first");
+        ALOGE("try to set the audio encoder without setting the audio source first");
         return INVALID_OPERATION;
     }
     if (mIsAudioEncoderSet) {
-        LOGE("audio encoder has already been set");
+        ALOGE("audio encoder has already been set");
         return INVALID_OPERATION;
     }
     if (!(mCurrentState & MEDIA_RECORDER_DATASOURCE_CONFIGURED)) {
-        LOGE("setAudioEncoder called in an invalid state(%d)", mCurrentState);
+        ALOGE("setAudioEncoder called in an invalid state(%d)", mCurrentState);
         return INVALID_OPERATION;
     }
 
     status_t ret = mMediaRecorder->setAudioEncoder(ae);
     if (OK != ret) {
-        LOGV("setAudioEncoder failed: %d", ret);
+        ALOGV("setAudioEncoder failed: %d", ret);
         mCurrentState = MEDIA_RECORDER_ERROR;
         return ret;
     }
@@ -261,23 +261,23 @@
 
 status_t MediaRecorder::setOutputFile(const char* path)
 {
-    LOGV("setOutputFile(%s)", path);
+    ALOGV("setOutputFile(%s)", path);
     if(mMediaRecorder == NULL) {
-        LOGE("media recorder is not initialized yet");
+        ALOGE("media recorder is not initialized yet");
         return INVALID_OPERATION;
     }
     if (mIsOutputFileSet) {
-        LOGE("output file has already been set");
+        ALOGE("output file has already been set");
         return INVALID_OPERATION;
     }
     if (!(mCurrentState & MEDIA_RECORDER_DATASOURCE_CONFIGURED)) {
-        LOGE("setOutputFile called in an invalid state(%d)", mCurrentState);
+        ALOGE("setOutputFile called in an invalid state(%d)", mCurrentState);
         return INVALID_OPERATION;
     }
 
     status_t ret = mMediaRecorder->setOutputFile(path);
     if (OK != ret) {
-        LOGV("setOutputFile failed: %d", ret);
+        ALOGV("setOutputFile failed: %d", ret);
         mCurrentState = MEDIA_RECORDER_ERROR;
         return ret;
     }
@@ -287,17 +287,17 @@
 
 status_t MediaRecorder::setOutputFile(int fd, int64_t offset, int64_t length)
 {
-    LOGV("setOutputFile(%d, %lld, %lld)", fd, offset, length);
+    ALOGV("setOutputFile(%d, %lld, %lld)", fd, offset, length);
     if(mMediaRecorder == NULL) {
-        LOGE("media recorder is not initialized yet");
+        ALOGE("media recorder is not initialized yet");
         return INVALID_OPERATION;
     }
     if (mIsOutputFileSet) {
-        LOGE("output file has already been set");
+        ALOGE("output file has already been set");
         return INVALID_OPERATION;
     }
     if (!(mCurrentState & MEDIA_RECORDER_DATASOURCE_CONFIGURED)) {
-        LOGE("setOutputFile called in an invalid state(%d)", mCurrentState);
+        ALOGE("setOutputFile called in an invalid state(%d)", mCurrentState);
         return INVALID_OPERATION;
     }
 
@@ -308,13 +308,13 @@
     // this issue by checking the file descriptor first before passing
     // it through binder call.
     if (fd < 0) {
-        LOGE("Invalid file descriptor: %d", fd);
+        ALOGE("Invalid file descriptor: %d", fd);
         return BAD_VALUE;
     }
 
     status_t ret = mMediaRecorder->setOutputFile(fd, offset, length);
     if (OK != ret) {
-        LOGV("setOutputFile failed: %d", ret);
+        ALOGV("setOutputFile failed: %d", ret);
         mCurrentState = MEDIA_RECORDER_ERROR;
         return ret;
     }
@@ -324,23 +324,23 @@
 
 status_t MediaRecorder::setVideoSize(int width, int height)
 {
-    LOGV("setVideoSize(%d, %d)", width, height);
+    ALOGV("setVideoSize(%d, %d)", width, height);
     if(mMediaRecorder == NULL) {
-        LOGE("media recorder is not initialized yet");
+        ALOGE("media recorder is not initialized yet");
         return INVALID_OPERATION;
     }
     if (!(mCurrentState & MEDIA_RECORDER_DATASOURCE_CONFIGURED)) {
-        LOGE("setVideoSize called in an invalid state: %d", mCurrentState);
+        ALOGE("setVideoSize called in an invalid state: %d", mCurrentState);
         return INVALID_OPERATION;
     }
     if (!mIsVideoSourceSet) {
-        LOGE("Cannot set video size without setting video source first");
+        ALOGE("Cannot set video size without setting video source first");
         return INVALID_OPERATION;
     }
 
     status_t ret = mMediaRecorder->setVideoSize(width, height);
     if (OK != ret) {
-        LOGE("setVideoSize failed: %d", ret);
+        ALOGE("setVideoSize failed: %d", ret);
         mCurrentState = MEDIA_RECORDER_ERROR;
         return ret;
     }
@@ -358,7 +358,7 @@
     mSurfaceMediaSource =
             mMediaRecorder->querySurfaceMediaSource();
     if (mSurfaceMediaSource == NULL) {
-        LOGE("SurfaceMediaSource could not be initialized!");
+        ALOGE("SurfaceMediaSource could not be initialized!");
     }
     return mSurfaceMediaSource;
 }
@@ -367,23 +367,23 @@
 
 status_t MediaRecorder::setVideoFrameRate(int frames_per_second)
 {
-    LOGV("setVideoFrameRate(%d)", frames_per_second);
+    ALOGV("setVideoFrameRate(%d)", frames_per_second);
     if(mMediaRecorder == NULL) {
-        LOGE("media recorder is not initialized yet");
+        ALOGE("media recorder is not initialized yet");
         return INVALID_OPERATION;
     }
     if (!(mCurrentState & MEDIA_RECORDER_DATASOURCE_CONFIGURED)) {
-        LOGE("setVideoFrameRate called in an invalid state: %d", mCurrentState);
+        ALOGE("setVideoFrameRate called in an invalid state: %d", mCurrentState);
         return INVALID_OPERATION;
     }
     if (!mIsVideoSourceSet) {
-        LOGE("Cannot set video frame rate without setting video source first");
+        ALOGE("Cannot set video frame rate without setting video source first");
         return INVALID_OPERATION;
     }
 
     status_t ret = mMediaRecorder->setVideoFrameRate(frames_per_second);
     if (OK != ret) {
-        LOGE("setVideoFrameRate failed: %d", ret);
+        ALOGE("setVideoFrameRate failed: %d", ret);
         mCurrentState = MEDIA_RECORDER_ERROR;
         return ret;
     }
@@ -391,9 +391,9 @@
 }
 
 status_t MediaRecorder::setParameters(const String8& params) {
-    LOGV("setParameters(%s)", params.string());
+    ALOGV("setParameters(%s)", params.string());
     if(mMediaRecorder == NULL) {
-        LOGE("media recorder is not initialized yet");
+        ALOGE("media recorder is not initialized yet");
         return INVALID_OPERATION;
     }
 
@@ -402,13 +402,13 @@
                             MEDIA_RECORDER_RECORDING |
                             MEDIA_RECORDER_ERROR));
     if (isInvalidState) {
-        LOGE("setParameters is called in an invalid state: %d", mCurrentState);
+        ALOGE("setParameters is called in an invalid state: %d", mCurrentState);
         return INVALID_OPERATION;
     }
 
     status_t ret = mMediaRecorder->setParameters(params);
     if (OK != ret) {
-        LOGE("setParameters(%s) failed: %d", params.string(), ret);
+        ALOGE("setParameters(%s) failed: %d", params.string(), ret);
         // Do not change our current state to MEDIA_RECORDER_ERROR, failures
         // of the only currently supported parameters, "max-duration" and
         // "max-filesize" are _not_ fatal.
@@ -419,36 +419,36 @@
 
 status_t MediaRecorder::prepare()
 {
-    LOGV("prepare");
+    ALOGV("prepare");
     if(mMediaRecorder == NULL) {
-        LOGE("media recorder is not initialized yet");
+        ALOGE("media recorder is not initialized yet");
         return INVALID_OPERATION;
     }
     if (!(mCurrentState & MEDIA_RECORDER_DATASOURCE_CONFIGURED)) {
-        LOGE("prepare called in an invalid state: %d", mCurrentState);
+        ALOGE("prepare called in an invalid state: %d", mCurrentState);
         return INVALID_OPERATION;
     }
     if (mIsAudioSourceSet != mIsAudioEncoderSet) {
         if (mIsAudioSourceSet) {
-            LOGE("audio source is set, but audio encoder is not set");
+            ALOGE("audio source is set, but audio encoder is not set");
         } else {  // must not happen, since setAudioEncoder checks this already
-            LOGE("audio encoder is set, but audio source is not set");
+            ALOGE("audio encoder is set, but audio source is not set");
         }
         return INVALID_OPERATION;
     }
 
     if (mIsVideoSourceSet != mIsVideoEncoderSet) {
         if (mIsVideoSourceSet) {
-            LOGE("video source is set, but video encoder is not set");
+            ALOGE("video source is set, but video encoder is not set");
         } else {  // must not happen, since setVideoEncoder checks this already
-            LOGE("video encoder is set, but video source is not set");
+            ALOGE("video encoder is set, but video source is not set");
         }
         return INVALID_OPERATION;
     }
 
     status_t ret = mMediaRecorder->prepare();
     if (OK != ret) {
-        LOGE("prepare failed: %d", ret);
+        ALOGE("prepare failed: %d", ret);
         mCurrentState = MEDIA_RECORDER_ERROR;
         return ret;
     }
@@ -458,19 +458,19 @@
 
 status_t MediaRecorder::getMaxAmplitude(int* max)
 {
-    LOGV("getMaxAmplitude");
+    ALOGV("getMaxAmplitude");
     if(mMediaRecorder == NULL) {
-        LOGE("media recorder is not initialized yet");
+        ALOGE("media recorder is not initialized yet");
         return INVALID_OPERATION;
     }
     if (mCurrentState & MEDIA_RECORDER_ERROR) {
-        LOGE("getMaxAmplitude called in an invalid state: %d", mCurrentState);
+        ALOGE("getMaxAmplitude called in an invalid state: %d", mCurrentState);
         return INVALID_OPERATION;
     }
 
     status_t ret = mMediaRecorder->getMaxAmplitude(max);
     if (OK != ret) {
-        LOGE("getMaxAmplitude failed: %d", ret);
+        ALOGE("getMaxAmplitude failed: %d", ret);
         mCurrentState = MEDIA_RECORDER_ERROR;
         return ret;
     }
@@ -479,19 +479,19 @@
 
 status_t MediaRecorder::start()
 {
-    LOGV("start");
+    ALOGV("start");
     if (mMediaRecorder == NULL) {
-        LOGE("media recorder is not initialized yet");
+        ALOGE("media recorder is not initialized yet");
         return INVALID_OPERATION;
     }
     if (!(mCurrentState & MEDIA_RECORDER_PREPARED)) {
-        LOGE("start called in an invalid state: %d", mCurrentState);
+        ALOGE("start called in an invalid state: %d", mCurrentState);
         return INVALID_OPERATION;
     }
 
     status_t ret = mMediaRecorder->start();
     if (OK != ret) {
-        LOGE("start failed: %d", ret);
+        ALOGE("start failed: %d", ret);
         mCurrentState = MEDIA_RECORDER_ERROR;
         return ret;
     }
@@ -501,19 +501,19 @@
 
 status_t MediaRecorder::stop()
 {
-    LOGV("stop");
+    ALOGV("stop");
     if (mMediaRecorder == NULL) {
-        LOGE("media recorder is not initialized yet");
+        ALOGE("media recorder is not initialized yet");
         return INVALID_OPERATION;
     }
     if (!(mCurrentState & MEDIA_RECORDER_RECORDING)) {
-        LOGE("stop called in an invalid state: %d", mCurrentState);
+        ALOGE("stop called in an invalid state: %d", mCurrentState);
         return INVALID_OPERATION;
     }
 
     status_t ret = mMediaRecorder->stop();
     if (OK != ret) {
-        LOGE("stop failed: %d", ret);
+        ALOGE("stop failed: %d", ret);
         mCurrentState = MEDIA_RECORDER_ERROR;
         return ret;
     }
@@ -529,9 +529,9 @@
 // Reset should be OK in any state
 status_t MediaRecorder::reset()
 {
-    LOGV("reset");
+    ALOGV("reset");
     if (mMediaRecorder == NULL) {
-        LOGE("media recorder is not initialized yet");
+        ALOGE("media recorder is not initialized yet");
         return INVALID_OPERATION;
     }
 
@@ -556,7 +556,7 @@
             break;
 
         default: {
-            LOGE("Unexpected non-existing state: %d", mCurrentState);
+            ALOGE("Unexpected non-existing state: %d", mCurrentState);
             break;
         }
     }
@@ -565,14 +565,14 @@
 
 status_t MediaRecorder::close()
 {
-    LOGV("close");
+    ALOGV("close");
     if (!(mCurrentState & MEDIA_RECORDER_INITIALIZED)) {
-        LOGE("close called in an invalid state: %d", mCurrentState);
+        ALOGE("close called in an invalid state: %d", mCurrentState);
         return INVALID_OPERATION;
     }
     status_t ret = mMediaRecorder->close();
     if (OK != ret) {
-        LOGE("close failed: %d", ret);
+        ALOGE("close failed: %d", ret);
         mCurrentState = MEDIA_RECORDER_ERROR;
         return UNKNOWN_ERROR;
     } else {
@@ -583,10 +583,10 @@
 
 status_t MediaRecorder::doReset()
 {
-    LOGV("doReset");
+    ALOGV("doReset");
     status_t ret = mMediaRecorder->reset();
     if (OK != ret) {
-        LOGE("doReset failed: %d", ret);
+        ALOGE("doReset failed: %d", ret);
         mCurrentState = MEDIA_RECORDER_ERROR;
         return ret;
     } else {
@@ -597,7 +597,7 @@
 
 void MediaRecorder::doCleanUp()
 {
-    LOGV("doCleanUp");
+    ALOGV("doCleanUp");
     mIsAudioSourceSet  = false;
     mIsVideoSourceSet  = false;
     mIsAudioEncoderSet = false;
@@ -608,7 +608,7 @@
 // Release should be OK in any state
 status_t MediaRecorder::release()
 {
-    LOGV("release");
+    ALOGV("release");
     if (mMediaRecorder != NULL) {
         return mMediaRecorder->release();
     }
@@ -617,7 +617,7 @@
 
 MediaRecorder::MediaRecorder() : mSurfaceMediaSource(NULL)
 {
-    LOGV("constructor");
+    ALOGV("constructor");
 
     const sp<IMediaPlayerService>& service(getMediaPlayerService());
     if (service != NULL) {
@@ -638,7 +638,7 @@
 
 MediaRecorder::~MediaRecorder()
 {
-    LOGV("destructor");
+    ALOGV("destructor");
     if (mMediaRecorder != NULL) {
         mMediaRecorder.clear();
     }
@@ -650,7 +650,7 @@
 
 status_t MediaRecorder::setListener(const sp<MediaRecorderListener>& listener)
 {
-    LOGV("setListener");
+    ALOGV("setListener");
     Mutex::Autolock _l(mLock);
     mListener = listener;
 
@@ -659,7 +659,7 @@
 
 void MediaRecorder::notify(int msg, int ext1, int ext2)
 {
-    LOGV("message received msg=%d, ext1=%d, ext2=%d", msg, ext1, ext2);
+    ALOGV("message received msg=%d, ext1=%d, ext2=%d", msg, ext1, ext2);
 
     sp<MediaRecorderListener> listener;
     mLock.lock();
@@ -668,15 +668,15 @@
 
     if (listener != NULL) {
         Mutex::Autolock _l(mNotifyLock);
-        LOGV("callback application");
+        ALOGV("callback application");
         listener->notify(msg, ext1, ext2);
-        LOGV("back from callback");
+        ALOGV("back from callback");
     }
 }
 
 void MediaRecorder::died()
 {
-    LOGV("died");
+    ALOGV("died");
     notify(MEDIA_RECORDER_EVENT_ERROR, MEDIA_ERROR_SERVER_DIED, 0);
 }
 
diff --git a/media/libmediaplayerservice/MediaPlayerService.cpp b/media/libmediaplayerservice/MediaPlayerService.cpp
index e8d0f0c..af58cac 100644
--- a/media/libmediaplayerservice/MediaPlayerService.cpp
+++ b/media/libmediaplayerservice/MediaPlayerService.cpp
@@ -112,14 +112,14 @@
     int32_t val;
     if (p.readInt32(&val) != OK)
     {
-        LOGE("Failed to read filter's length");
+        ALOGE("Failed to read filter's length");
         *status = NOT_ENOUGH_DATA;
         return false;
     }
 
     if( val > kMaxFilterSize || val < 0)
     {
-        LOGE("Invalid filter len %d", val);
+        ALOGE("Invalid filter len %d", val);
         *status = BAD_VALUE;
         return false;
     }
@@ -134,7 +134,7 @@
 
     if (p.dataAvail() < size)
     {
-        LOGE("Filter too short expected %d but got %d", size, p.dataAvail());
+        ALOGE("Filter too short expected %d but got %d", size, p.dataAvail());
         *status = NOT_ENOUGH_DATA;
         return false;
     }
@@ -144,7 +144,7 @@
 
     if (NULL == data)
     {
-        LOGE("Filter had no data");
+        ALOGE("Filter had no data");
         *status = BAD_VALUE;
         return false;
     }
@@ -184,7 +184,7 @@
 #endif
     if (getpid() == IPCThreadState::self()->getCallingPid()) return true;
     bool ok = checkCallingPermission(String16(permissionString));
-    if (!ok) LOGE("Request requires %s", permissionString);
+    if (!ok) ALOGE("Request requires %s", permissionString);
     return ok;
 }
 
@@ -215,7 +215,7 @@
 
 MediaPlayerService::MediaPlayerService()
 {
-    LOGV("MediaPlayerService created");
+    ALOGV("MediaPlayerService created");
     mNextConnId = 1;
 
     mBatteryAudio.refCount = 0;
@@ -230,7 +230,7 @@
 
 MediaPlayerService::~MediaPlayerService()
 {
-    LOGV("MediaPlayerService destroyed");
+    ALOGV("MediaPlayerService destroyed");
 }
 
 sp<IMediaRecorder> MediaPlayerService::createMediaRecorder(pid_t pid)
@@ -239,7 +239,7 @@
     wp<MediaRecorderClient> w = recorder;
     Mutex::Autolock lock(mLock);
     mMediaRecorderClients.add(w);
-    LOGV("Create new media recorder client from pid %d", pid);
+    ALOGV("Create new media recorder client from pid %d", pid);
     return recorder;
 }
 
@@ -247,13 +247,13 @@
 {
     Mutex::Autolock lock(mLock);
     mMediaRecorderClients.remove(client);
-    LOGV("Delete media recorder client");
+    ALOGV("Delete media recorder client");
 }
 
 sp<IMediaMetadataRetriever> MediaPlayerService::createMetadataRetriever(pid_t pid)
 {
     sp<MetadataRetrieverClient> retriever = new MetadataRetrieverClient(pid);
-    LOGV("Create new media retriever from pid %d", pid);
+    ALOGV("Create new media retriever from pid %d", pid);
     return retriever;
 }
 
@@ -266,7 +266,7 @@
             this, pid, connId, client, audioSessionId,
             IPCThreadState::self()->getCallingUid());
 
-    LOGV("Create new client(%d) from pid %d, uid %d, ", connId, pid,
+    ALOGV("Create new client(%d) from pid %d, uid %d, ", connId, pid,
          IPCThreadState::self()->getCallingUid());
 
     wp<Client> w = c;
@@ -478,7 +478,7 @@
         int32_t connId, const sp<IMediaPlayerClient>& client,
         int audioSessionId, uid_t uid)
 {
-    LOGV("Client(%d) constructor", connId);
+    ALOGV("Client(%d) constructor", connId);
     mPid = pid;
     mConnId = connId;
     mService = service;
@@ -489,14 +489,14 @@
     mUID = uid;
 
 #if CALLBACK_ANTAGONIZER
-    LOGD("create Antagonizer");
+    ALOGD("create Antagonizer");
     mAntagonizer = new Antagonizer(notify, this);
 #endif
 }
 
 MediaPlayerService::Client::~Client()
 {
-    LOGV("Client(%d) destructor pid = %d", mConnId, mPid);
+    ALOGV("Client(%d) destructor pid = %d", mConnId, mPid);
     mAudioOutput.clear();
     wp<Client> client(this);
     disconnect();
@@ -505,7 +505,7 @@
 
 void MediaPlayerService::Client::disconnect()
 {
-    LOGV("disconnect(%d) from pid %d", mConnId, mPid);
+    ALOGV("disconnect(%d) from pid %d", mConnId, mPid);
     // grab local reference and clear main reference to prevent future
     // access to object
     sp<MediaPlayerBase> p;
@@ -523,7 +523,7 @@
     if (p != 0) {
         p->setNotifyCallback(0, 0);
 #if CALLBACK_ANTAGONIZER
-        LOGD("kill Antagonizer");
+        ALOGD("kill Antagonizer");
         mAntagonizer->kill();
 #endif
         p->reset();
@@ -614,23 +614,23 @@
     sp<MediaPlayerBase> p;
     switch (playerType) {
         case SONIVOX_PLAYER:
-            LOGV(" create MidiFile");
+            ALOGV(" create MidiFile");
             p = new MidiFile();
             break;
         case STAGEFRIGHT_PLAYER:
-            LOGV(" create StagefrightPlayer");
+            ALOGV(" create StagefrightPlayer");
             p = new StagefrightPlayer;
             break;
         case NU_PLAYER:
-            LOGV(" create NuPlayer");
+            ALOGV(" create NuPlayer");
             p = new NuPlayerDriver;
             break;
         case TEST_PLAYER:
-            LOGV("Create Test Player stub");
+            ALOGV("Create Test Player stub");
             p = new TestPlayerStub();
             break;
         default:
-            LOGE("Unknown player type: %d", playerType);
+            ALOGE("Unknown player type: %d", playerType);
             return NULL;
     }
     if (p != NULL) {
@@ -641,7 +641,7 @@
         }
     }
     if (p == NULL) {
-        LOGE("Failed to create player object");
+        ALOGE("Failed to create player object");
     }
     return p;
 }
@@ -651,7 +651,7 @@
     // determine if we have the right player type
     sp<MediaPlayerBase> p = mPlayer;
     if ((p != NULL) && (p->playerType() != playerType)) {
-        LOGV("delete player");
+        ALOGV("delete player");
         p.clear();
     }
     if (p == NULL) {
@@ -668,7 +668,7 @@
 status_t MediaPlayerService::Client::setDataSource(
         const char *url, const KeyedVector<String8, String8> *headers)
 {
-    LOGV("setDataSource(%s)", url);
+    ALOGV("setDataSource(%s)", url);
     if (url == NULL)
         return UNKNOWN_ERROR;
 
@@ -688,7 +688,7 @@
         int fd = android::openContentProviderFile(url16);
         if (fd < 0)
         {
-            LOGE("Couldn't open fd for %s", url);
+            ALOGE("Couldn't open fd for %s", url);
             return UNKNOWN_ERROR;
         }
         setDataSource(fd, 0, 0x7fffffffffLL); // this sets mStatus
@@ -696,7 +696,7 @@
         return mStatus;
     } else {
         player_type playerType = getPlayerType(url);
-        LOGV("player type = %d", playerType);
+        ALOGV("player type = %d", playerType);
 
         // create the right type of player
         sp<MediaPlayerBase> p = createPlayer(playerType);
@@ -708,12 +708,12 @@
         }
 
         // now set data source
-        LOGV(" setDataSource");
+        ALOGV(" setDataSource");
         mStatus = p->setDataSource(url, headers);
         if (mStatus == NO_ERROR) {
             mPlayer = p;
         } else {
-            LOGE("  error: %d", mStatus);
+            ALOGE("  error: %d", mStatus);
         }
         return mStatus;
     }
@@ -721,32 +721,32 @@
 
 status_t MediaPlayerService::Client::setDataSource(int fd, int64_t offset, int64_t length)
 {
-    LOGV("setDataSource fd=%d, offset=%lld, length=%lld", fd, offset, length);
+    ALOGV("setDataSource fd=%d, offset=%lld, length=%lld", fd, offset, length);
     struct stat sb;
     int ret = fstat(fd, &sb);
     if (ret != 0) {
-        LOGE("fstat(%d) failed: %d, %s", fd, ret, strerror(errno));
+        ALOGE("fstat(%d) failed: %d, %s", fd, ret, strerror(errno));
         return UNKNOWN_ERROR;
     }
 
-    LOGV("st_dev  = %llu", sb.st_dev);
-    LOGV("st_mode = %u", sb.st_mode);
-    LOGV("st_uid  = %lu", sb.st_uid);
-    LOGV("st_gid  = %lu", sb.st_gid);
-    LOGV("st_size = %llu", sb.st_size);
+    ALOGV("st_dev  = %llu", sb.st_dev);
+    ALOGV("st_mode = %u", sb.st_mode);
+    ALOGV("st_uid  = %lu", sb.st_uid);
+    ALOGV("st_gid  = %lu", sb.st_gid);
+    ALOGV("st_size = %llu", sb.st_size);
 
     if (offset >= sb.st_size) {
-        LOGE("offset error");
+        ALOGE("offset error");
         ::close(fd);
         return UNKNOWN_ERROR;
     }
     if (offset + length > sb.st_size) {
         length = sb.st_size - offset;
-        LOGV("calculated length = %lld", length);
+        ALOGV("calculated length = %lld", length);
     }
 
     player_type playerType = getPlayerType(fd, offset, length);
-    LOGV("player type = %d", playerType);
+    ALOGV("player type = %d", playerType);
 
     // create the right type of player
     sp<MediaPlayerBase> p = createPlayer(playerType);
@@ -794,7 +794,7 @@
                 NATIVE_WINDOW_API_MEDIA);
 
         if (err != OK) {
-            LOGW("native_window_api_disconnect returned an error: %s (%d)",
+            ALOGW("native_window_api_disconnect returned an error: %s (%d)",
                     strerror(-err), err);
         }
     }
@@ -804,7 +804,7 @@
 status_t MediaPlayerService::Client::setVideoSurfaceTexture(
         const sp<ISurfaceTexture>& surfaceTexture)
 {
-    LOGV("[%d] setVideoSurfaceTexture(%p)", mConnId, surfaceTexture.get());
+    ALOGV("[%d] setVideoSurfaceTexture(%p)", mConnId, surfaceTexture.get());
     sp<MediaPlayerBase> p = getPlayer();
     if (p == 0) return UNKNOWN_ERROR;
 
@@ -821,7 +821,7 @@
                 NATIVE_WINDOW_API_MEDIA);
 
         if (err != OK) {
-            LOGE("setVideoSurfaceTexture failed: %d", err);
+            ALOGE("setVideoSurfaceTexture failed: %d", err);
             // Note that we must do the reset before disconnecting from the ANW.
             // Otherwise queue/dequeue calls could be made on the disconnected
             // ANW, which may result in errors.
@@ -905,7 +905,7 @@
 
     if (status != OK) {
         metadata.resetParcel();
-        LOGE("getMetadata failed %d", status);
+        ALOGE("getMetadata failed %d", status);
         return status;
     }
 
@@ -920,12 +920,12 @@
 
 status_t MediaPlayerService::Client::prepareAsync()
 {
-    LOGV("[%d] prepareAsync", mConnId);
+    ALOGV("[%d] prepareAsync", mConnId);
     sp<MediaPlayerBase> p = getPlayer();
     if (p == 0) return UNKNOWN_ERROR;
     status_t ret = p->prepareAsync();
 #if CALLBACK_ANTAGONIZER
-    LOGD("start Antagonizer");
+    ALOGD("start Antagonizer");
     if (ret == NO_ERROR) mAntagonizer->start();
 #endif
     return ret;
@@ -933,7 +933,7 @@
 
 status_t MediaPlayerService::Client::start()
 {
-    LOGV("[%d] start", mConnId);
+    ALOGV("[%d] start", mConnId);
     sp<MediaPlayerBase> p = getPlayer();
     if (p == 0) return UNKNOWN_ERROR;
     p->setLooping(mLoop);
@@ -942,7 +942,7 @@
 
 status_t MediaPlayerService::Client::stop()
 {
-    LOGV("[%d] stop", mConnId);
+    ALOGV("[%d] stop", mConnId);
     sp<MediaPlayerBase> p = getPlayer();
     if (p == 0) return UNKNOWN_ERROR;
     return p->stop();
@@ -950,7 +950,7 @@
 
 status_t MediaPlayerService::Client::pause()
 {
-    LOGV("[%d] pause", mConnId);
+    ALOGV("[%d] pause", mConnId);
     sp<MediaPlayerBase> p = getPlayer();
     if (p == 0) return UNKNOWN_ERROR;
     return p->pause();
@@ -962,41 +962,41 @@
     sp<MediaPlayerBase> p = getPlayer();
     if (p == 0) return UNKNOWN_ERROR;
     *state = p->isPlaying();
-    LOGV("[%d] isPlaying: %d", mConnId, *state);
+    ALOGV("[%d] isPlaying: %d", mConnId, *state);
     return NO_ERROR;
 }
 
 status_t MediaPlayerService::Client::getCurrentPosition(int *msec)
 {
-    LOGV("getCurrentPosition");
+    ALOGV("getCurrentPosition");
     sp<MediaPlayerBase> p = getPlayer();
     if (p == 0) return UNKNOWN_ERROR;
     status_t ret = p->getCurrentPosition(msec);
     if (ret == NO_ERROR) {
-        LOGV("[%d] getCurrentPosition = %d", mConnId, *msec);
+        ALOGV("[%d] getCurrentPosition = %d", mConnId, *msec);
     } else {
-        LOGE("getCurrentPosition returned %d", ret);
+        ALOGE("getCurrentPosition returned %d", ret);
     }
     return ret;
 }
 
 status_t MediaPlayerService::Client::getDuration(int *msec)
 {
-    LOGV("getDuration");
+    ALOGV("getDuration");
     sp<MediaPlayerBase> p = getPlayer();
     if (p == 0) return UNKNOWN_ERROR;
     status_t ret = p->getDuration(msec);
     if (ret == NO_ERROR) {
-        LOGV("[%d] getDuration = %d", mConnId, *msec);
+        ALOGV("[%d] getDuration = %d", mConnId, *msec);
     } else {
-        LOGE("getDuration returned %d", ret);
+        ALOGE("getDuration returned %d", ret);
     }
     return ret;
 }
 
 status_t MediaPlayerService::Client::seekTo(int msec)
 {
-    LOGV("[%d] seekTo(%d)", mConnId, msec);
+    ALOGV("[%d] seekTo(%d)", mConnId, msec);
     sp<MediaPlayerBase> p = getPlayer();
     if (p == 0) return UNKNOWN_ERROR;
     return p->seekTo(msec);
@@ -1004,7 +1004,7 @@
 
 status_t MediaPlayerService::Client::reset()
 {
-    LOGV("[%d] reset", mConnId);
+    ALOGV("[%d] reset", mConnId);
     sp<MediaPlayerBase> p = getPlayer();
     if (p == 0) return UNKNOWN_ERROR;
     return p->reset();
@@ -1012,7 +1012,7 @@
 
 status_t MediaPlayerService::Client::setAudioStreamType(int type)
 {
-    LOGV("[%d] setAudioStreamType(%d)", mConnId, type);
+    ALOGV("[%d] setAudioStreamType(%d)", mConnId, type);
     // TODO: for hardware output, call player instead
     Mutex::Autolock l(mLock);
     if (mAudioOutput != 0) mAudioOutput->setAudioStreamType(type);
@@ -1021,7 +1021,7 @@
 
 status_t MediaPlayerService::Client::setLooping(int loop)
 {
-    LOGV("[%d] setLooping(%d)", mConnId, loop);
+    ALOGV("[%d] setLooping(%d)", mConnId, loop);
     mLoop = loop;
     sp<MediaPlayerBase> p = getPlayer();
     if (p != 0) return p->setLooping(loop);
@@ -1030,7 +1030,7 @@
 
 status_t MediaPlayerService::Client::setVolume(float leftVolume, float rightVolume)
 {
-    LOGV("[%d] setVolume(%f, %f)", mConnId, leftVolume, rightVolume);
+    ALOGV("[%d] setVolume(%f, %f)", mConnId, leftVolume, rightVolume);
     // TODO: for hardware output, call player instead
     Mutex::Autolock l(mLock);
     if (mAudioOutput != 0) mAudioOutput->setVolume(leftVolume, rightVolume);
@@ -1039,7 +1039,7 @@
 
 status_t MediaPlayerService::Client::setAuxEffectSendLevel(float level)
 {
-    LOGV("[%d] setAuxEffectSendLevel(%f)", mConnId, level);
+    ALOGV("[%d] setAuxEffectSendLevel(%f)", mConnId, level);
     Mutex::Autolock l(mLock);
     if (mAudioOutput != 0) return mAudioOutput->setAuxEffectSendLevel(level);
     return NO_ERROR;
@@ -1047,21 +1047,21 @@
 
 status_t MediaPlayerService::Client::attachAuxEffect(int effectId)
 {
-    LOGV("[%d] attachAuxEffect(%d)", mConnId, effectId);
+    ALOGV("[%d] attachAuxEffect(%d)", mConnId, effectId);
     Mutex::Autolock l(mLock);
     if (mAudioOutput != 0) return mAudioOutput->attachAuxEffect(effectId);
     return NO_ERROR;
 }
 
 status_t MediaPlayerService::Client::setParameter(int key, const Parcel &request) {
-    LOGV("[%d] setParameter(%d)", mConnId, key);
+    ALOGV("[%d] setParameter(%d)", mConnId, key);
     sp<MediaPlayerBase> p = getPlayer();
     if (p == 0) return UNKNOWN_ERROR;
     return p->setParameter(key, request);
 }
 
 status_t MediaPlayerService::Client::getParameter(int key, Parcel *reply) {
-    LOGV("[%d] getParameter(%d)", mConnId, key);
+    ALOGV("[%d] getParameter(%d)", mConnId, key);
     sp<MediaPlayerBase> p = getPlayer();
     if (p == 0) return UNKNOWN_ERROR;
     return p->getParameter(key, reply);
@@ -1084,7 +1084,7 @@
         // also access mMetadataUpdated and clears it.
         client->addNewMetadataUpdate(metadata_type);
     }
-    LOGV("[%d] notify (%p, %d, %d, %d)", client->mConnId, cookie, msg, ext1, ext2);
+    ALOGV("[%d] notify (%p, %d, %d, %d)", client->mConnId, cookie, msg, ext1, ext2);
     client->mClient->notify(msg, ext1, ext2, obj);
 }
 
@@ -1131,27 +1131,27 @@
 
 int Antagonizer::callbackThread(void* user)
 {
-    LOGD("Antagonizer started");
+    ALOGD("Antagonizer started");
     Antagonizer* p = reinterpret_cast<Antagonizer*>(user);
     while (!p->mExit) {
         if (p->mActive) {
-            LOGV("send event");
+            ALOGV("send event");
             p->mCb(p->mClient, 0, 0, 0);
         }
         usleep(interval);
     }
     Mutex::Autolock _l(p->mLock);
     p->mCondition.signal();
-    LOGD("Antagonizer stopped");
+    ALOGD("Antagonizer stopped");
     return 0;
 }
 #endif
 
 static size_t kDefaultHeapSize = 1024 * 1024; // 1MB
 
-sp<IMemory> MediaPlayerService::decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, int* pFormat)
+sp<IMemory> MediaPlayerService::decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, audio_format_t* pFormat)
 {
-    LOGV("decode(%s)", url);
+    ALOGV("decode(%s)", url);
     sp<MemoryBase> mem;
     sp<MediaPlayerBase> player;
 
@@ -1160,12 +1160,12 @@
     // If the application wants to decode those, it should open a
     // filedescriptor for them and use that.
     if (url != NULL && strncmp(url, "http://", 7) != 0) {
-        LOGD("Can't decode %s by path, use filedescriptor instead", url);
+        ALOGD("Can't decode %s by path, use filedescriptor instead", url);
         return mem;
     }
 
     player_type playerType = getPlayerType(url);
-    LOGV("player type = %d", playerType);
+    ALOGV("player type = %d", playerType);
 
     // create the right type of player
     sp<AudioCache> cache = new AudioCache(url);
@@ -1178,16 +1178,16 @@
     // set data source
     if (player->setDataSource(url) != NO_ERROR) goto Exit;
 
-    LOGV("prepare");
+    ALOGV("prepare");
     player->prepareAsync();
 
-    LOGV("wait for prepare");
+    ALOGV("wait for prepare");
     if (cache->wait() != NO_ERROR) goto Exit;
 
-    LOGV("start");
+    ALOGV("start");
     player->start();
 
-    LOGV("wait for playback complete");
+    ALOGV("wait for playback complete");
     cache->wait();
     // in case of error, return what was successfully decoded.
     if (cache->size() == 0) {
@@ -1197,22 +1197,22 @@
     mem = new MemoryBase(cache->getHeap(), 0, cache->size());
     *pSampleRate = cache->sampleRate();
     *pNumChannels = cache->channelCount();
-    *pFormat = (int)cache->format();
-    LOGV("return memory @ %p, sampleRate=%u, channelCount = %d, format = %d", mem->pointer(), *pSampleRate, *pNumChannels, *pFormat);
+    *pFormat = cache->format();
+    ALOGV("return memory @ %p, sampleRate=%u, channelCount = %d, format = %d", mem->pointer(), *pSampleRate, *pNumChannels, *pFormat);
 
 Exit:
     if (player != 0) player->reset();
     return mem;
 }
 
-sp<IMemory> MediaPlayerService::decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, int* pFormat)
+sp<IMemory> MediaPlayerService::decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, audio_format_t* pFormat)
 {
-    LOGV("decode(%d, %lld, %lld)", fd, offset, length);
+    ALOGV("decode(%d, %lld, %lld)", fd, offset, length);
     sp<MemoryBase> mem;
     sp<MediaPlayerBase> player;
 
     player_type playerType = getPlayerType(fd, offset, length);
-    LOGV("player type = %d", playerType);
+    ALOGV("player type = %d", playerType);
 
     // create the right type of player
     sp<AudioCache> cache = new AudioCache("decode_fd");
@@ -1225,16 +1225,16 @@
     // set data source
     if (player->setDataSource(fd, offset, length) != NO_ERROR) goto Exit;
 
-    LOGV("prepare");
+    ALOGV("prepare");
     player->prepareAsync();
 
-    LOGV("wait for prepare");
+    ALOGV("wait for prepare");
     if (cache->wait() != NO_ERROR) goto Exit;
 
-    LOGV("start");
+    ALOGV("start");
     player->start();
 
-    LOGV("wait for playback complete");
+    ALOGV("wait for playback complete");
     cache->wait();
     // in case of error, return what was successfully decoded.
     if (cache->size() == 0) {
@@ -1245,7 +1245,7 @@
     *pSampleRate = cache->sampleRate();
     *pNumChannels = cache->channelCount();
     *pFormat = cache->format();
-    LOGV("return memory @ %p, sampleRate=%u, channelCount = %d, format = %d", mem->pointer(), *pSampleRate, *pNumChannels, *pFormat);
+    ALOGV("return memory @ %p, sampleRate=%u, channelCount = %d, format = %d", mem->pointer(), *pSampleRate, *pNumChannels, *pFormat);
 
 Exit:
     if (player != 0) player->reset();
@@ -1260,7 +1260,7 @@
     : mCallback(NULL),
       mCallbackCookie(NULL),
       mSessionId(sessionId) {
-    LOGV("AudioOutput(%d)", sessionId);
+    ALOGV("AudioOutput(%d)", sessionId);
     mTrack = 0;
     mStreamType = AUDIO_STREAM_MUSIC;
     mLeftVolume = 1.0;
@@ -1339,7 +1339,7 @@
 }
 
 status_t MediaPlayerService::AudioOutput::open(
-        uint32_t sampleRate, int channelCount, int format, int bufferCount,
+        uint32_t sampleRate, int channelCount, audio_format_t format, int bufferCount,
         AudioCallback cb, void *cookie)
 {
     mCallback = cb;
@@ -1347,11 +1347,11 @@
 
     // Check argument "bufferCount" against the mininum buffer count
     if (bufferCount < mMinBufferCount) {
-        LOGD("bufferCount (%d) is too small and increased to %d", bufferCount, mMinBufferCount);
+        ALOGD("bufferCount (%d) is too small and increased to %d", bufferCount, mMinBufferCount);
         bufferCount = mMinBufferCount;
 
     }
-    LOGV("open(%u, %d, %d, %d, %d)", sampleRate, channelCount, format, bufferCount,mSessionId);
+    ALOGV("open(%u, %d, %d, %d, %d)", sampleRate, channelCount, format, bufferCount,mSessionId);
     if (mTrack) close();
     int afSampleRate;
     int afFrameCount;
@@ -1394,12 +1394,12 @@
     }
 
     if ((t == 0) || (t->initCheck() != NO_ERROR)) {
-        LOGE("Unable to create audio track");
+        ALOGE("Unable to create audio track");
         delete t;
         return NO_INIT;
     }
 
-    LOGV("setVolume");
+    ALOGV("setVolume");
     t->setVolume(mLeftVolume, mRightVolume);
 
     mMsecsPerFrame = 1.e3 / (float) sampleRate;
@@ -1412,7 +1412,7 @@
 
 void MediaPlayerService::AudioOutput::start()
 {
-    LOGV("start");
+    ALOGV("start");
     if (mTrack) {
         mTrack->setVolume(mLeftVolume, mRightVolume);
         mTrack->setAuxEffectSendLevel(mSendLevel);
@@ -1426,7 +1426,7 @@
 {
     LOG_FATAL_IF(mCallback != NULL, "Don't call write if supplying a callback.");
 
-    //LOGV("write(%p, %u)", buffer, size);
+    //ALOGV("write(%p, %u)", buffer, size);
     if (mTrack) {
         ssize_t ret = mTrack->write(buffer, size);
         return ret;
@@ -1436,32 +1436,32 @@
 
 void MediaPlayerService::AudioOutput::stop()
 {
-    LOGV("stop");
+    ALOGV("stop");
     if (mTrack) mTrack->stop();
 }
 
 void MediaPlayerService::AudioOutput::flush()
 {
-    LOGV("flush");
+    ALOGV("flush");
     if (mTrack) mTrack->flush();
 }
 
 void MediaPlayerService::AudioOutput::pause()
 {
-    LOGV("pause");
+    ALOGV("pause");
     if (mTrack) mTrack->pause();
 }
 
 void MediaPlayerService::AudioOutput::close()
 {
-    LOGV("close");
+    ALOGV("close");
     delete mTrack;
     mTrack = 0;
 }
 
 void MediaPlayerService::AudioOutput::setVolume(float left, float right)
 {
-    LOGV("setVolume(%f, %f)", left, right);
+    ALOGV("setVolume(%f, %f)", left, right);
     mLeftVolume = left;
     mRightVolume = right;
     if (mTrack) {
@@ -1471,7 +1471,7 @@
 
 status_t MediaPlayerService::AudioOutput::setAuxEffectSendLevel(float level)
 {
-    LOGV("setAuxEffectSendLevel(%f)", level);
+    ALOGV("setAuxEffectSendLevel(%f)", level);
     mSendLevel = level;
     if (mTrack) {
         return mTrack->setAuxEffectSendLevel(level);
@@ -1481,7 +1481,7 @@
 
 status_t MediaPlayerService::AudioOutput::attachAuxEffect(int effectId)
 {
-    LOGV("attachAuxEffect(%d)", effectId);
+    ALOGV("attachAuxEffect(%d)", effectId);
     mAuxEffectId = effectId;
     if (mTrack) {
         return mTrack->attachAuxEffect(effectId);
@@ -1492,7 +1492,7 @@
 // static
 void MediaPlayerService::AudioOutput::CallbackWrapper(
         int event, void *cookie, void *info) {
-    //LOGV("callbackwrapper");
+    //ALOGV("callbackwrapper");
     if (event != AudioTrack::EVENT_MORE_DATA) {
         return;
     }
@@ -1611,17 +1611,17 @@
 ////////////////////////////////////////////////////////////////////////////////
 
 status_t MediaPlayerService::AudioCache::open(
-        uint32_t sampleRate, int channelCount, int format, int bufferCount,
+        uint32_t sampleRate, int channelCount, audio_format_t format, int bufferCount,
         AudioCallback cb, void *cookie)
 {
-    LOGV("open(%u, %d, %d, %d)", sampleRate, channelCount, format, bufferCount);
+    ALOGV("open(%u, %d, %d, %d)", sampleRate, channelCount, format, bufferCount);
     if (mHeap->getHeapID() < 0) {
         return NO_INIT;
     }
 
     mSampleRate = sampleRate;
     mChannelCount = (uint16_t)channelCount;
-    mFormat = (uint16_t)format;
+    mFormat = format;
     mMsecsPerFrame = 1.e3 / (float) sampleRate;
 
     if (cb != NULL) {
@@ -1644,15 +1644,15 @@
 
 ssize_t MediaPlayerService::AudioCache::write(const void* buffer, size_t size)
 {
-    LOGV("write(%p, %u)", buffer, size);
+    ALOGV("write(%p, %u)", buffer, size);
     if ((buffer == 0) || (size == 0)) return size;
 
     uint8_t* p = static_cast<uint8_t*>(mHeap->getBase());
     if (p == NULL) return NO_INIT;
     p += mSize;
-    LOGV("memcpy(%p, %p, %u)", p, buffer, size);
+    ALOGV("memcpy(%p, %p, %u)", p, buffer, size);
     if (mSize + size > mHeap->getSize()) {
-        LOGE("Heap size overflow! req size: %d, max size: %d", (mSize + size), mHeap->getSize());
+        ALOGE("Heap size overflow! req size: %d, max size: %d", (mSize + size), mHeap->getSize());
         size = mHeap->getSize() - mSize;
     }
     memcpy(p, buffer, size);
@@ -1670,9 +1670,9 @@
     mCommandComplete = false;
 
     if (mError == NO_ERROR) {
-        LOGV("wait - success");
+        ALOGV("wait - success");
     } else {
-        LOGV("wait - error");
+        ALOGV("wait - error");
     }
     return mError;
 }
@@ -1680,24 +1680,24 @@
 void MediaPlayerService::AudioCache::notify(
         void* cookie, int msg, int ext1, int ext2, const Parcel *obj)
 {
-    LOGV("notify(%p, %d, %d, %d)", cookie, msg, ext1, ext2);
+    ALOGV("notify(%p, %d, %d, %d)", cookie, msg, ext1, ext2);
     AudioCache* p = static_cast<AudioCache*>(cookie);
 
     // ignore buffering messages
     switch (msg)
     {
     case MEDIA_ERROR:
-        LOGE("Error %d, %d occurred", ext1, ext2);
+        ALOGE("Error %d, %d occurred", ext1, ext2);
         p->mError = ext1;
         break;
     case MEDIA_PREPARED:
-        LOGV("prepared");
+        ALOGV("prepared");
         break;
     case MEDIA_PLAYBACK_COMPLETE:
-        LOGV("playback complete");
+        ALOGV("playback complete");
         break;
     default:
-        LOGV("ignored");
+        ALOGV("ignored");
         return;
     }
 
@@ -1772,7 +1772,7 @@
 
     } else if (params & kBatteryDataAudioFlingerStop) {
         if (mBatteryAudio.refCount <= 0) {
-            LOGW("Battery track warning: refCount is <= 0");
+            ALOGW("Battery track warning: refCount is <= 0");
             return;
         }
 
@@ -1807,7 +1807,7 @@
         info.refCount = 0;
 
         if (mBatteryData.add(uid, info) == NO_MEMORY) {
-            LOGE("Battery track error: no memory for new app");
+            ALOGE("Battery track error: no memory for new app");
             return;
         }
     }
@@ -1825,10 +1825,10 @@
         }
     } else {
         if (info.refCount == 0) {
-            LOGW("Battery track warning: refCount is already 0");
+            ALOGW("Battery track warning: refCount is already 0");
             return;
         } else if (info.refCount < 0) {
-            LOGE("Battery track error: refCount < 0");
+            ALOGE("Battery track error: refCount < 0");
             mBatteryData.removeItem(uid);
             return;
         }
diff --git a/media/libmediaplayerservice/MediaPlayerService.h b/media/libmediaplayerservice/MediaPlayerService.h
index 04d9e28..66f245d 100644
--- a/media/libmediaplayerservice/MediaPlayerService.h
+++ b/media/libmediaplayerservice/MediaPlayerService.h
@@ -83,7 +83,7 @@
 
         virtual status_t        open(
                 uint32_t sampleRate, int channelCount,
-                int format, int bufferCount,
+                audio_format_t format, int bufferCount,
                 AudioCallback cb, void *cookie);
 
         virtual void            start();
@@ -139,7 +139,7 @@
         virtual int             getSessionId();
 
         virtual status_t        open(
-                uint32_t sampleRate, int channelCount, int format,
+                uint32_t sampleRate, int channelCount, audio_format_t format,
                 int bufferCount = 1,
                 AudioCallback cb = NULL, void *cookie = NULL);
 
@@ -152,7 +152,7 @@
                 void            setAudioStreamType(int streamType) {}
                 void            setVolume(float left, float right) {}
                 uint32_t        sampleRate() const { return mSampleRate; }
-                uint32_t        format() const { return (uint32_t)mFormat; }
+                audio_format_t  format() const { return mFormat; }
                 size_t          size() const { return mSize; }
                 status_t        wait();
 
@@ -170,7 +170,7 @@
         sp<MemoryHeapBase>  mHeap;
         float               mMsecsPerFrame;
         uint16_t            mChannelCount;
-        uint16_t            mFormat;
+        audio_format_t      mFormat;
         ssize_t             mFrameCount;
         uint32_t            mSampleRate;
         uint32_t            mSize;
@@ -190,8 +190,8 @@
 
     virtual sp<IMediaPlayer>    create(pid_t pid, const sp<IMediaPlayerClient>& client, int audioSessionId);
 
-    virtual sp<IMemory>         decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, int* pFormat);
-    virtual sp<IMemory>         decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, int* pFormat);
+    virtual sp<IMemory>         decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, audio_format_t* pFormat);
+    virtual sp<IMemory>         decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, audio_format_t* pFormat);
     virtual sp<IOMX>            getOMX();
 
     virtual status_t            dump(int fd, const Vector<String16>& args);
diff --git a/media/libmediaplayerservice/MediaRecorderClient.cpp b/media/libmediaplayerservice/MediaRecorderClient.cpp
index 6f80b35..d219fc2 100644
--- a/media/libmediaplayerservice/MediaRecorderClient.cpp
+++ b/media/libmediaplayerservice/MediaRecorderClient.cpp
@@ -54,17 +54,17 @@
 #endif
     if (getpid() == IPCThreadState::self()->getCallingPid()) return true;
     bool ok = checkCallingPermission(String16(permissionString));
-    if (!ok) LOGE("Request requires %s", permissionString);
+    if (!ok) ALOGE("Request requires %s", permissionString);
     return ok;
 }
 
 
 sp<ISurfaceTexture> MediaRecorderClient::querySurfaceMediaSource()
 {
-    LOGV("Query SurfaceMediaSource");
+    ALOGV("Query SurfaceMediaSource");
     Mutex::Autolock lock(mLock);
     if (mRecorder == NULL) {
-        LOGE("recorder is not initialized");
+        ALOGE("recorder is not initialized");
         return NULL;
     }
     return mRecorder->querySurfaceMediaSource();
@@ -75,10 +75,10 @@
 status_t MediaRecorderClient::setCamera(const sp<ICamera>& camera,
                                         const sp<ICameraRecordingProxy>& proxy)
 {
-    LOGV("setCamera");
+    ALOGV("setCamera");
     Mutex::Autolock lock(mLock);
     if (mRecorder == NULL) {
-        LOGE("recorder is not initialized");
+        ALOGE("recorder is not initialized");
         return NO_INIT;
     }
     return mRecorder->setCamera(camera, proxy);
@@ -86,10 +86,10 @@
 
 status_t MediaRecorderClient::setPreviewSurface(const sp<Surface>& surface)
 {
-    LOGV("setPreviewSurface");
+    ALOGV("setPreviewSurface");
     Mutex::Autolock lock(mLock);
     if (mRecorder == NULL) {
-        LOGE("recorder is not initialized");
+        ALOGE("recorder is not initialized");
         return NO_INIT;
     }
     return mRecorder->setPreviewSurface(surface);
@@ -97,13 +97,13 @@
 
 status_t MediaRecorderClient::setVideoSource(int vs)
 {
-    LOGV("setVideoSource(%d)", vs);
+    ALOGV("setVideoSource(%d)", vs);
     if (!checkPermission(cameraPermission)) {
         return PERMISSION_DENIED;
     }
     Mutex::Autolock lock(mLock);
     if (mRecorder == NULL)	{
-        LOGE("recorder is not initialized");
+        ALOGE("recorder is not initialized");
         return NO_INIT;
     }
     return mRecorder->setVideoSource((video_source)vs);
@@ -111,13 +111,13 @@
 
 status_t MediaRecorderClient::setAudioSource(int as)
 {
-    LOGV("setAudioSource(%d)", as);
+    ALOGV("setAudioSource(%d)", as);
     if (!checkPermission(recordAudioPermission)) {
         return PERMISSION_DENIED;
     }
     Mutex::Autolock lock(mLock);
     if (mRecorder == NULL)  {
-        LOGE("recorder is not initialized");
+        ALOGE("recorder is not initialized");
         return NO_INIT;
     }
     return mRecorder->setAudioSource((audio_source_t)as);
@@ -125,10 +125,10 @@
 
 status_t MediaRecorderClient::setOutputFormat(int of)
 {
-    LOGV("setOutputFormat(%d)", of);
+    ALOGV("setOutputFormat(%d)", of);
     Mutex::Autolock lock(mLock);
     if (mRecorder == NULL) {
-        LOGE("recorder is not initialized");
+        ALOGE("recorder is not initialized");
         return NO_INIT;
     }
     return mRecorder->setOutputFormat((output_format)of);
@@ -136,10 +136,10 @@
 
 status_t MediaRecorderClient::setVideoEncoder(int ve)
 {
-    LOGV("setVideoEncoder(%d)", ve);
+    ALOGV("setVideoEncoder(%d)", ve);
     Mutex::Autolock lock(mLock);
     if (mRecorder == NULL) {
-        LOGE("recorder is not initialized");
+        ALOGE("recorder is not initialized");
         return NO_INIT;
     }
     return mRecorder->setVideoEncoder((video_encoder)ve);
@@ -147,10 +147,10 @@
 
 status_t MediaRecorderClient::setAudioEncoder(int ae)
 {
-    LOGV("setAudioEncoder(%d)", ae);
+    ALOGV("setAudioEncoder(%d)", ae);
     Mutex::Autolock lock(mLock);
     if (mRecorder == NULL) {
-        LOGE("recorder is not initialized");
+        ALOGE("recorder is not initialized");
         return NO_INIT;
     }
     return mRecorder->setAudioEncoder((audio_encoder)ae);
@@ -158,10 +158,10 @@
 
 status_t MediaRecorderClient::setOutputFile(const char* path)
 {
-    LOGV("setOutputFile(%s)", path);
+    ALOGV("setOutputFile(%s)", path);
     Mutex::Autolock lock(mLock);
     if (mRecorder == NULL) {
-        LOGE("recorder is not initialized");
+        ALOGE("recorder is not initialized");
         return NO_INIT;
     }
     return mRecorder->setOutputFile(path);
@@ -169,10 +169,10 @@
 
 status_t MediaRecorderClient::setOutputFile(int fd, int64_t offset, int64_t length)
 {
-    LOGV("setOutputFile(%d, %lld, %lld)", fd, offset, length);
+    ALOGV("setOutputFile(%d, %lld, %lld)", fd, offset, length);
     Mutex::Autolock lock(mLock);
     if (mRecorder == NULL) {
-        LOGE("recorder is not initialized");
+        ALOGE("recorder is not initialized");
         return NO_INIT;
     }
     return mRecorder->setOutputFile(fd, offset, length);
@@ -180,10 +180,10 @@
 
 status_t MediaRecorderClient::setVideoSize(int width, int height)
 {
-    LOGV("setVideoSize(%dx%d)", width, height);
+    ALOGV("setVideoSize(%dx%d)", width, height);
     Mutex::Autolock lock(mLock);
     if (mRecorder == NULL) {
-        LOGE("recorder is not initialized");
+        ALOGE("recorder is not initialized");
         return NO_INIT;
     }
     return mRecorder->setVideoSize(width, height);
@@ -191,20 +191,20 @@
 
 status_t MediaRecorderClient::setVideoFrameRate(int frames_per_second)
 {
-    LOGV("setVideoFrameRate(%d)", frames_per_second);
+    ALOGV("setVideoFrameRate(%d)", frames_per_second);
     Mutex::Autolock lock(mLock);
     if (mRecorder == NULL) {
-        LOGE("recorder is not initialized");
+        ALOGE("recorder is not initialized");
         return NO_INIT;
     }
     return mRecorder->setVideoFrameRate(frames_per_second);
 }
 
 status_t MediaRecorderClient::setParameters(const String8& params) {
-    LOGV("setParameters(%s)", params.string());
+    ALOGV("setParameters(%s)", params.string());
     Mutex::Autolock lock(mLock);
     if (mRecorder == NULL) {
-        LOGE("recorder is not initialized");
+        ALOGE("recorder is not initialized");
         return NO_INIT;
     }
     return mRecorder->setParameters(params);
@@ -212,10 +212,10 @@
 
 status_t MediaRecorderClient::prepare()
 {
-    LOGV("prepare");
+    ALOGV("prepare");
     Mutex::Autolock lock(mLock);
     if (mRecorder == NULL) {
-        LOGE("recorder is not initialized");
+        ALOGE("recorder is not initialized");
         return NO_INIT;
     }
     return mRecorder->prepare();
@@ -224,10 +224,10 @@
 
 status_t MediaRecorderClient::getMaxAmplitude(int* max)
 {
-    LOGV("getMaxAmplitude");
+    ALOGV("getMaxAmplitude");
     Mutex::Autolock lock(mLock);
     if (mRecorder == NULL) {
-        LOGE("recorder is not initialized");
+        ALOGE("recorder is not initialized");
         return NO_INIT;
     }
     return mRecorder->getMaxAmplitude(max);
@@ -235,10 +235,10 @@
 
 status_t MediaRecorderClient::start()
 {
-    LOGV("start");
+    ALOGV("start");
     Mutex::Autolock lock(mLock);
     if (mRecorder == NULL) {
-        LOGE("recorder is not initialized");
+        ALOGE("recorder is not initialized");
         return NO_INIT;
     }
     return mRecorder->start();
@@ -247,10 +247,10 @@
 
 status_t MediaRecorderClient::stop()
 {
-    LOGV("stop");
+    ALOGV("stop");
     Mutex::Autolock lock(mLock);
     if (mRecorder == NULL) {
-        LOGE("recorder is not initialized");
+        ALOGE("recorder is not initialized");
         return NO_INIT;
     }
     return mRecorder->stop();
@@ -258,10 +258,10 @@
 
 status_t MediaRecorderClient::init()
 {
-    LOGV("init");
+    ALOGV("init");
     Mutex::Autolock lock(mLock);
     if (mRecorder == NULL) {
-        LOGE("recorder is not initialized");
+        ALOGE("recorder is not initialized");
         return NO_INIT;
     }
     return mRecorder->init();
@@ -269,10 +269,10 @@
 
 status_t MediaRecorderClient::close()
 {
-    LOGV("close");
+    ALOGV("close");
     Mutex::Autolock lock(mLock);
     if (mRecorder == NULL) {
-        LOGE("recorder is not initialized");
+        ALOGE("recorder is not initialized");
         return NO_INIT;
     }
     return mRecorder->close();
@@ -281,10 +281,10 @@
 
 status_t MediaRecorderClient::reset()
 {
-    LOGV("reset");
+    ALOGV("reset");
     Mutex::Autolock lock(mLock);
     if (mRecorder == NULL) {
-        LOGE("recorder is not initialized");
+        ALOGE("recorder is not initialized");
         return NO_INIT;
     }
     return mRecorder->reset();
@@ -292,7 +292,7 @@
 
 status_t MediaRecorderClient::release()
 {
-    LOGV("release");
+    ALOGV("release");
     Mutex::Autolock lock(mLock);
     if (mRecorder != NULL) {
         delete mRecorder;
@@ -305,7 +305,7 @@
 
 MediaRecorderClient::MediaRecorderClient(const sp<MediaPlayerService>& service, pid_t pid)
 {
-    LOGV("Client constructor");
+    ALOGV("Client constructor");
     mPid = pid;
     mRecorder = new StagefrightRecorder;
     mMediaPlayerService = service;
@@ -313,16 +313,16 @@
 
 MediaRecorderClient::~MediaRecorderClient()
 {
-    LOGV("Client destructor");
+    ALOGV("Client destructor");
     release();
 }
 
 status_t MediaRecorderClient::setListener(const sp<IMediaRecorderClient>& listener)
 {
-    LOGV("setListener");
+    ALOGV("setListener");
     Mutex::Autolock lock(mLock);
     if (mRecorder == NULL) {
-        LOGE("recorder is not initialized");
+        ALOGE("recorder is not initialized");
         return NO_INIT;
     }
     return mRecorder->setListener(listener);
diff --git a/media/libmediaplayerservice/MetadataRetrieverClient.cpp b/media/libmediaplayerservice/MetadataRetrieverClient.cpp
index d574ea3..7dbb57f 100644
--- a/media/libmediaplayerservice/MetadataRetrieverClient.cpp
+++ b/media/libmediaplayerservice/MetadataRetrieverClient.cpp
@@ -46,7 +46,7 @@
 
 MetadataRetrieverClient::MetadataRetrieverClient(pid_t pid)
 {
-    LOGV("MetadataRetrieverClient constructor pid(%d)", pid);
+    ALOGV("MetadataRetrieverClient constructor pid(%d)", pid);
     mPid = pid;
     mThumbnail = NULL;
     mAlbumArt = NULL;
@@ -55,7 +55,7 @@
 
 MetadataRetrieverClient::~MetadataRetrieverClient()
 {
-    LOGV("MetadataRetrieverClient destructor");
+    ALOGV("MetadataRetrieverClient destructor");
     disconnect();
 }
 
@@ -74,7 +74,7 @@
 
 void MetadataRetrieverClient::disconnect()
 {
-    LOGV("disconnect from pid %d", mPid);
+    ALOGV("disconnect from pid %d", mPid);
     Mutex::Autolock lock(mLock);
     mRetriever.clear();
     mThumbnail.clear();
@@ -92,17 +92,17 @@
             break;
         }
         case SONIVOX_PLAYER:
-            LOGV("create midi metadata retriever");
+            ALOGV("create midi metadata retriever");
             p = new MidiMetadataRetriever();
             break;
         default:
             // TODO:
             // support for TEST_PLAYER
-            LOGE("player type %d is not supported",  playerType);
+            ALOGE("player type %d is not supported",  playerType);
             break;
     }
     if (p == NULL) {
-        LOGE("failed to create a retriever object");
+        ALOGE("failed to create a retriever object");
     }
     return p;
 }
@@ -110,13 +110,13 @@
 status_t MetadataRetrieverClient::setDataSource(
         const char *url, const KeyedVector<String8, String8> *headers)
 {
-    LOGV("setDataSource(%s)", url);
+    ALOGV("setDataSource(%s)", url);
     Mutex::Autolock lock(mLock);
     if (url == NULL) {
         return UNKNOWN_ERROR;
     }
     player_type playerType = getPlayerType(url);
-    LOGV("player type = %d", playerType);
+    ALOGV("player type = %d", playerType);
     sp<MediaMetadataRetrieverBase> p = createRetriever(playerType);
     if (p == NULL) return NO_INIT;
     status_t ret = p->setDataSource(url, headers);
@@ -126,32 +126,32 @@
 
 status_t MetadataRetrieverClient::setDataSource(int fd, int64_t offset, int64_t length)
 {
-    LOGV("setDataSource fd=%d, offset=%lld, length=%lld", fd, offset, length);
+    ALOGV("setDataSource fd=%d, offset=%lld, length=%lld", fd, offset, length);
     Mutex::Autolock lock(mLock);
     struct stat sb;
     int ret = fstat(fd, &sb);
     if (ret != 0) {
-        LOGE("fstat(%d) failed: %d, %s", fd, ret, strerror(errno));
+        ALOGE("fstat(%d) failed: %d, %s", fd, ret, strerror(errno));
         return BAD_VALUE;
     }
-    LOGV("st_dev  = %llu", sb.st_dev);
-    LOGV("st_mode = %u", sb.st_mode);
-    LOGV("st_uid  = %lu", sb.st_uid);
-    LOGV("st_gid  = %lu", sb.st_gid);
-    LOGV("st_size = %llu", sb.st_size);
+    ALOGV("st_dev  = %llu", sb.st_dev);
+    ALOGV("st_mode = %u", sb.st_mode);
+    ALOGV("st_uid  = %lu", sb.st_uid);
+    ALOGV("st_gid  = %lu", sb.st_gid);
+    ALOGV("st_size = %llu", sb.st_size);
 
     if (offset >= sb.st_size) {
-        LOGE("offset (%lld) bigger than file size (%llu)", offset, sb.st_size);
+        ALOGE("offset (%lld) bigger than file size (%llu)", offset, sb.st_size);
         ::close(fd);
         return BAD_VALUE;
     }
     if (offset + length > sb.st_size) {
         length = sb.st_size - offset;
-        LOGV("calculated length = %lld", length);
+        ALOGV("calculated length = %lld", length);
     }
 
     player_type playerType = getPlayerType(fd, offset, length);
-    LOGV("player type = %d", playerType);
+    ALOGV("player type = %d", playerType);
     sp<MediaMetadataRetrieverBase> p = createRetriever(playerType);
     if (p == NULL) {
         ::close(fd);
@@ -165,28 +165,28 @@
 
 sp<IMemory> MetadataRetrieverClient::getFrameAtTime(int64_t timeUs, int option)
 {
-    LOGV("getFrameAtTime: time(%lld us) option(%d)", timeUs, option);
+    ALOGV("getFrameAtTime: time(%lld us) option(%d)", timeUs, option);
     Mutex::Autolock lock(mLock);
     mThumbnail.clear();
     if (mRetriever == NULL) {
-        LOGE("retriever is not initialized");
+        ALOGE("retriever is not initialized");
         return NULL;
     }
     VideoFrame *frame = mRetriever->getFrameAtTime(timeUs, option);
     if (frame == NULL) {
-        LOGE("failed to capture a video frame");
+        ALOGE("failed to capture a video frame");
         return NULL;
     }
     size_t size = sizeof(VideoFrame) + frame->mSize;
     sp<MemoryHeapBase> heap = new MemoryHeapBase(size, 0, "MetadataRetrieverClient");
     if (heap == NULL) {
-        LOGE("failed to create MemoryDealer");
+        ALOGE("failed to create MemoryDealer");
         delete frame;
         return NULL;
     }
     mThumbnail = new MemoryBase(heap, 0, size);
     if (mThumbnail == NULL) {
-        LOGE("not enough memory for VideoFrame size=%u", size);
+        ALOGE("not enough memory for VideoFrame size=%u", size);
         delete frame;
         return NULL;
     }
@@ -197,7 +197,7 @@
     frameCopy->mDisplayHeight = frame->mDisplayHeight;
     frameCopy->mSize = frame->mSize;
     frameCopy->mRotationAngle = frame->mRotationAngle;
-    LOGV("rotation: %d", frameCopy->mRotationAngle);
+    ALOGV("rotation: %d", frameCopy->mRotationAngle);
     frameCopy->mData = (uint8_t *)frameCopy + sizeof(VideoFrame);
     memcpy(frameCopy->mData, frame->mData, frame->mSize);
     delete frame;  // Fix memory leakage
@@ -206,28 +206,28 @@
 
 sp<IMemory> MetadataRetrieverClient::extractAlbumArt()
 {
-    LOGV("extractAlbumArt");
+    ALOGV("extractAlbumArt");
     Mutex::Autolock lock(mLock);
     mAlbumArt.clear();
     if (mRetriever == NULL) {
-        LOGE("retriever is not initialized");
+        ALOGE("retriever is not initialized");
         return NULL;
     }
     MediaAlbumArt *albumArt = mRetriever->extractAlbumArt();
     if (albumArt == NULL) {
-        LOGE("failed to extract an album art");
+        ALOGE("failed to extract an album art");
         return NULL;
     }
     size_t size = sizeof(MediaAlbumArt) + albumArt->mSize;
     sp<MemoryHeapBase> heap = new MemoryHeapBase(size, 0, "MetadataRetrieverClient");
     if (heap == NULL) {
-        LOGE("failed to create MemoryDealer object");
+        ALOGE("failed to create MemoryDealer object");
         delete albumArt;
         return NULL;
     }
     mAlbumArt = new MemoryBase(heap, 0, size);
     if (mAlbumArt == NULL) {
-        LOGE("not enough memory for MediaAlbumArt size=%u", size);
+        ALOGE("not enough memory for MediaAlbumArt size=%u", size);
         delete albumArt;
         return NULL;
     }
@@ -241,10 +241,10 @@
 
 const char* MetadataRetrieverClient::extractMetadata(int keyCode)
 {
-    LOGV("extractMetadata");
+    ALOGV("extractMetadata");
     Mutex::Autolock lock(mLock);
     if (mRetriever == NULL) {
-        LOGE("retriever is not initialized");
+        ALOGE("retriever is not initialized");
         return NULL;
     }
     return mRetriever->extractMetadata(keyCode);
diff --git a/media/libmediaplayerservice/MidiFile.cpp b/media/libmediaplayerservice/MidiFile.cpp
index 7e04523..7cb8c29 100644
--- a/media/libmediaplayerservice/MidiFile.cpp
+++ b/media/libmediaplayerservice/MidiFile.cpp
@@ -58,7 +58,7 @@
     mStreamType(AUDIO_STREAM_MUSIC), mLoop(false), mExit(false),
     mPaused(false), mRender(false), mTid(-1)
 {
-    LOGV("constructor");
+    ALOGV("constructor");
 
     mFileLocator.path = NULL;
     mFileLocator.fd = -1;
@@ -69,13 +69,13 @@
     if (pLibConfig == NULL)
         pLibConfig = EAS_Config();
     if ((pLibConfig == NULL) || (LIB_VERSION != pLibConfig->libVersion)) {
-        LOGE("EAS library/header mismatch");
+        ALOGE("EAS library/header mismatch");
         goto Failed;
     }
 
     // initialize EAS library
     if (EAS_Init(&mEasData) != EAS_SUCCESS) {
-        LOGE("EAS_Init failed");
+        ALOGE("EAS_Init failed");
         goto Failed;
     }
 
@@ -86,14 +86,15 @@
     // create playback thread
     {
         Mutex::Autolock l(mMutex);
-        createThreadEtc(renderThread, this, "midithread", ANDROID_PRIORITY_AUDIO);
+        mThread = new MidiFileThread(this);
+        mThread->run("midithread", ANDROID_PRIORITY_AUDIO);
         mCondition.wait(mMutex);
-        LOGV("thread started");
+        ALOGV("thread started");
     }
 
     // indicate success
     if (mTid > 0) {
-        LOGV(" render thread(%d) started", mTid);
+        ALOGV(" render thread(%d) started", mTid);
         mState = EAS_STATE_READY;
     }
 
@@ -108,13 +109,13 @@
 }
 
 MidiFile::~MidiFile() {
-    LOGV("MidiFile destructor");
+    ALOGV("MidiFile destructor");
     release();
 }
 
 status_t MidiFile::setDataSource(
         const char* path, const KeyedVector<String8, String8> *) {
-    LOGV("MidiFile::setDataSource url=%s", path);
+    ALOGV("MidiFile::setDataSource url=%s", path);
     Mutex::Autolock lock(mMutex);
 
     // file still open?
@@ -133,7 +134,7 @@
     }
 
     if (result != EAS_SUCCESS) {
-        LOGE("EAS_OpenFile failed: [%d]", (int)result);
+        ALOGE("EAS_OpenFile failed: [%d]", (int)result);
         mState = EAS_STATE_ERROR;
         return ERROR_OPEN_FAILED;
     }
@@ -145,7 +146,7 @@
 
 status_t MidiFile::setDataSource(int fd, int64_t offset, int64_t length)
 {
-    LOGV("MidiFile::setDataSource fd=%d", fd);
+    ALOGV("MidiFile::setDataSource fd=%d", fd);
     Mutex::Autolock lock(mMutex);
 
     // file still open?
@@ -161,7 +162,7 @@
     updateState();
 
     if (result != EAS_SUCCESS) {
-        LOGE("EAS_OpenFile failed: [%d]", (int)result);
+        ALOGE("EAS_OpenFile failed: [%d]", (int)result);
         mState = EAS_STATE_ERROR;
         return ERROR_OPEN_FAILED;
     }
@@ -173,14 +174,14 @@
 
 status_t MidiFile::prepare()
 {
-    LOGV("MidiFile::prepare");
+    ALOGV("MidiFile::prepare");
     Mutex::Autolock lock(mMutex);
     if (!mEasHandle) {
         return ERROR_NOT_OPEN;
     }
     EAS_RESULT result;
     if ((result = EAS_Prepare(mEasData, mEasHandle)) != EAS_SUCCESS) {
-        LOGE("EAS_Prepare failed: [%ld]", result);
+        ALOGE("EAS_Prepare failed: [%ld]", result);
         return ERROR_EAS_FAILURE;
     }
     updateState();
@@ -189,7 +190,7 @@
 
 status_t MidiFile::prepareAsync()
 {
-    LOGV("MidiFile::prepareAsync");
+    ALOGV("MidiFile::prepareAsync");
     status_t ret = prepare();
 
     // don't hold lock during callback
@@ -203,7 +204,7 @@
 
 status_t MidiFile::start()
 {
-    LOGV("MidiFile::start");
+    ALOGV("MidiFile::start");
     Mutex::Autolock lock(mMutex);
     if (!mEasHandle) {
         return ERROR_NOT_OPEN;
@@ -221,14 +222,14 @@
     mRender = true;
 
     // wake up render thread
-    LOGV("  wakeup render thread");
+    ALOGV("  wakeup render thread");
     mCondition.signal();
     return NO_ERROR;
 }
 
 status_t MidiFile::stop()
 {
-    LOGV("MidiFile::stop");
+    ALOGV("MidiFile::stop");
     Mutex::Autolock lock(mMutex);
     if (!mEasHandle) {
         return ERROR_NOT_OPEN;
@@ -236,7 +237,7 @@
     if (!mPaused && (mState != EAS_STATE_STOPPED)) {
         EAS_RESULT result = EAS_Pause(mEasData, mEasHandle);
         if (result != EAS_SUCCESS) {
-            LOGE("EAS_Pause returned error %ld", result);
+            ALOGE("EAS_Pause returned error %ld", result);
             return ERROR_EAS_FAILURE;
         }
     }
@@ -246,7 +247,7 @@
 
 status_t MidiFile::seekTo(int position)
 {
-    LOGV("MidiFile::seekTo %d", position);
+    ALOGV("MidiFile::seekTo %d", position);
     // hold lock during EAS calls
     {
         Mutex::Autolock lock(mMutex);
@@ -257,7 +258,7 @@
         if ((result = EAS_Locate(mEasData, mEasHandle, position, false))
                 != EAS_SUCCESS)
         {
-            LOGE("EAS_Locate returned %ld", result);
+            ALOGE("EAS_Locate returned %ld", result);
             return ERROR_EAS_FAILURE;
         }
         EAS_GetLocation(mEasData, mEasHandle, &mPlayTime);
@@ -268,7 +269,7 @@
 
 status_t MidiFile::pause()
 {
-    LOGV("MidiFile::pause");
+    ALOGV("MidiFile::pause");
     Mutex::Autolock lock(mMutex);
     if (!mEasHandle) {
         return ERROR_NOT_OPEN;
@@ -283,20 +284,20 @@
 
 bool MidiFile::isPlaying()
 {
-    LOGV("MidiFile::isPlaying, mState=%d", int(mState));
+    ALOGV("MidiFile::isPlaying, mState=%d", int(mState));
     if (!mEasHandle || mPaused) return false;
     return (mState == EAS_STATE_PLAY);
 }
 
 status_t MidiFile::getCurrentPosition(int* position)
 {
-    LOGV("MidiFile::getCurrentPosition");
+    ALOGV("MidiFile::getCurrentPosition");
     if (!mEasHandle) {
-        LOGE("getCurrentPosition(): file not open");
+        ALOGE("getCurrentPosition(): file not open");
         return ERROR_NOT_OPEN;
     }
     if (mPlayTime < 0) {
-        LOGE("getCurrentPosition(): mPlayTime = %ld", mPlayTime);
+        ALOGE("getCurrentPosition(): mPlayTime = %ld", mPlayTime);
         return ERROR_EAS_FAILURE;
     }
     *position = mPlayTime;
@@ -306,7 +307,7 @@
 status_t MidiFile::getDuration(int* duration)
 {
 
-    LOGV("MidiFile::getDuration");
+    ALOGV("MidiFile::getDuration");
     {
         Mutex::Autolock lock(mMutex);
         if (!mEasHandle) return ERROR_NOT_OPEN;
@@ -349,7 +350,7 @@
 
 status_t MidiFile::release()
 {
-    LOGV("MidiFile::release");
+    ALOGV("MidiFile::release");
     Mutex::Autolock l(mMutex);
     reset_nosync();
 
@@ -372,7 +373,7 @@
 
 status_t MidiFile::reset()
 {
-    LOGV("MidiFile::reset");
+    ALOGV("MidiFile::reset");
     Mutex::Autolock lock(mMutex);
     return reset_nosync();
 }
@@ -380,7 +381,7 @@
 // call only with mutex held
 status_t MidiFile::reset_nosync()
 {
-    LOGV("MidiFile::reset_nosync");
+    ALOGV("MidiFile::reset_nosync");
     // close file
     if (mEasHandle) {
         EAS_CloseFile(mEasData, mEasHandle);
@@ -407,7 +408,7 @@
 
 status_t MidiFile::setLooping(int loop)
 {
-    LOGV("MidiFile::setLooping");
+    ALOGV("MidiFile::setLooping");
     Mutex::Autolock lock(mMutex);
     if (!mEasHandle) {
         return ERROR_NOT_OPEN;
@@ -421,29 +422,24 @@
 
 status_t MidiFile::createOutputTrack() {
     if (mAudioSink->open(pLibConfig->sampleRate, pLibConfig->numChannels, AUDIO_FORMAT_PCM_16_BIT, 2) != NO_ERROR) {
-        LOGE("mAudioSink open failed");
+        ALOGE("mAudioSink open failed");
         return ERROR_OPEN_FAILED;
     }
     return NO_ERROR;
 }
 
-int MidiFile::renderThread(void* p) {
-
-    return ((MidiFile*)p)->render();
-}
-
 int MidiFile::render() {
     EAS_RESULT result = EAS_FAILURE;
     EAS_I32 count;
     int temp;
     bool audioStarted = false;
 
-    LOGV("MidiFile::render");
+    ALOGV("MidiFile::render");
 
     // allocate render buffer
     mAudioBuffer = new EAS_PCM[pLibConfig->mixBufferSize * pLibConfig->numChannels * NUM_BUFFERS];
     if (!mAudioBuffer) {
-        LOGE("mAudioBuffer allocate failed");
+        ALOGE("mAudioBuffer allocate failed");
         goto threadExit;
     }
 
@@ -451,7 +447,7 @@
     {
         Mutex::Autolock l(mMutex);
         mTid = gettid();
-        LOGV("render thread(%d) signal", mTid);
+        ALOGV("render thread(%d) signal", mTid);
         mCondition.signal();
     }
 
@@ -461,9 +457,9 @@
         // nothing to render, wait for client thread to wake us up
         while (!mRender && !mExit)
         {
-            LOGV("MidiFile::render - signal wait");
+            ALOGV("MidiFile::render - signal wait");
             mCondition.wait(mMutex);
-            LOGV("MidiFile::render - signal rx'd");
+            ALOGV("MidiFile::render - signal rx'd");
         }
         if (mExit) {
             mMutex.unlock();
@@ -471,41 +467,41 @@
         }
 
         // render midi data into the input buffer
-        //LOGV("MidiFile::render - rendering audio");
+        //ALOGV("MidiFile::render - rendering audio");
         int num_output = 0;
         EAS_PCM* p = mAudioBuffer;
         for (int i = 0; i < NUM_BUFFERS; i++) {
             result = EAS_Render(mEasData, p, pLibConfig->mixBufferSize, &count);
             if (result != EAS_SUCCESS) {
-                LOGE("EAS_Render returned %ld", result);
+                ALOGE("EAS_Render returned %ld", result);
             }
             p += count * pLibConfig->numChannels;
             num_output += count * pLibConfig->numChannels * sizeof(EAS_PCM);
         }
 
         // update playback state and position
-        // LOGV("MidiFile::render - updating state");
+        // ALOGV("MidiFile::render - updating state");
         EAS_GetLocation(mEasData, mEasHandle, &mPlayTime);
         EAS_State(mEasData, mEasHandle, &mState);
         mMutex.unlock();
 
         // create audio output track if necessary
         if (!mAudioSink->ready()) {
-            LOGV("MidiFile::render - create output track");
+            ALOGV("MidiFile::render - create output track");
             if (createOutputTrack() != NO_ERROR)
                 goto threadExit;
         }
 
         // Write data to the audio hardware
-        // LOGV("MidiFile::render - writing to audio output");
+        // ALOGV("MidiFile::render - writing to audio output");
         if ((temp = mAudioSink->write(mAudioBuffer, num_output)) < 0) {
-            LOGE("Error in writing:%d",temp);
+            ALOGE("Error in writing:%d",temp);
             return temp;
         }
 
         // start audio output if necessary
         if (!audioStarted) {
-            //LOGV("MidiFile::render - starting audio");
+            //ALOGV("MidiFile::render - starting audio");
             mAudioSink->start();
             audioStarted = true;
         }
@@ -517,18 +513,18 @@
             switch(mState) {
             case EAS_STATE_STOPPED:
             {
-                LOGV("MidiFile::render - stopped");
+                ALOGV("MidiFile::render - stopped");
                 sendEvent(MEDIA_PLAYBACK_COMPLETE);
                 break;
             }
             case EAS_STATE_ERROR:
             {
-                LOGE("MidiFile::render - error");
+                ALOGE("MidiFile::render - error");
                 sendEvent(MEDIA_ERROR, MEDIA_ERROR_UNKNOWN);
                 break;
             }
             case EAS_STATE_PAUSED:
-                LOGV("MidiFile::render - paused");
+                ALOGV("MidiFile::render - paused");
                 break;
             default:
                 break;
diff --git a/media/libmediaplayerservice/MidiFile.h b/media/libmediaplayerservice/MidiFile.h
index 3469389..2a0dcf9 100644
--- a/media/libmediaplayerservice/MidiFile.h
+++ b/media/libmediaplayerservice/MidiFile.h
@@ -24,6 +24,7 @@
 
 namespace android {
 
+// Note that the name MidiFile is misleading; this actually represents a MIDI file player
 class MidiFile : public MediaPlayerInterface {
 public:
                         MidiFile();
@@ -65,7 +66,6 @@
 private:
             status_t    createOutputTrack();
             status_t    reset_nosync();
-    static  int         renderThread(void*);
             int         render();
             void        updateState(){ EAS_State(mEasData, mEasHandle, &mState); }
 
@@ -84,6 +84,29 @@
     bool                mPaused;
     volatile bool       mRender;
     pid_t               mTid;
+
+    class MidiFileThread : public Thread {
+    public:
+        MidiFileThread(MidiFile *midiPlayer) : mMidiFile(midiPlayer) {
+        }
+
+    protected:
+        virtual ~MidiFileThread() {}
+
+    private:
+        MidiFile *mMidiFile;
+
+        bool threadLoop() {
+            int result;
+            result = mMidiFile->render();
+            return false;
+        }
+
+        MidiFileThread(const MidiFileThread &);
+        MidiFileThread &operator=(const MidiFileThread &);
+    };
+
+    sp<MidiFileThread> mThread;
 };
 
 }; // namespace android
diff --git a/media/libmediaplayerservice/MidiMetadataRetriever.cpp b/media/libmediaplayerservice/MidiMetadataRetriever.cpp
index aaf2d18..465209f 100644
--- a/media/libmediaplayerservice/MidiMetadataRetriever.cpp
+++ b/media/libmediaplayerservice/MidiMetadataRetriever.cpp
@@ -31,14 +31,14 @@
 
 void MidiMetadataRetriever::clearMetadataValues()
 {
-    LOGV("clearMetadataValues");
+    ALOGV("clearMetadataValues");
     mMetadataValues[0][0] = '\0';
 }
 
 status_t MidiMetadataRetriever::setDataSource(
         const char *url, const KeyedVector<String8, String8> *headers)
 {
-    LOGV("setDataSource: %s", url? url: "NULL pointer");
+    ALOGV("setDataSource: %s", url? url: "NULL pointer");
     Mutex::Autolock lock(mLock);
     clearMetadataValues();
     if (mMidiPlayer == 0) {
@@ -49,7 +49,7 @@
 
 status_t MidiMetadataRetriever::setDataSource(int fd, int64_t offset, int64_t length)
 {
-    LOGV("setDataSource: fd(%d), offset(%lld), and length(%lld)", fd, offset, length);
+    ALOGV("setDataSource: fd(%d), offset(%lld), and length(%lld)", fd, offset, length);
     Mutex::Autolock lock(mLock);
     clearMetadataValues();
     if (mMidiPlayer == 0) {
@@ -60,10 +60,10 @@
 
 const char* MidiMetadataRetriever::extractMetadata(int keyCode)
 {
-    LOGV("extractMetdata: key(%d)", keyCode);
+    ALOGV("extractMetdata: key(%d)", keyCode);
     Mutex::Autolock lock(mLock);
     if (mMidiPlayer == 0 || mMidiPlayer->initCheck() != NO_ERROR) {
-        LOGE("Midi player is not initialized yet");
+        ALOGE("Midi player is not initialized yet");
         return NULL;
     }
     switch (keyCode) {
@@ -72,17 +72,17 @@
             if (mMetadataValues[0][0] == '\0') {
                 int duration = -1;
                 if (mMidiPlayer->getDuration(&duration) != NO_ERROR) {
-                    LOGE("failed to get duration");
+                    ALOGE("failed to get duration");
                     return NULL;
                 }
                 snprintf(mMetadataValues[0], MAX_METADATA_STRING_LENGTH, "%d", duration);
             }
 
-            LOGV("duration: %s ms", mMetadataValues[0]);
+            ALOGV("duration: %s ms", mMetadataValues[0]);
             return mMetadataValues[0];
         }
     default:
-        LOGE("Unsupported key code (%d)", keyCode);
+        ALOGE("Unsupported key code (%d)", keyCode);
         return NULL;
     }
     return NULL;
diff --git a/media/libmediaplayerservice/StagefrightPlayer.cpp b/media/libmediaplayerservice/StagefrightPlayer.cpp
index 598d573..6d7771a 100644
--- a/media/libmediaplayerservice/StagefrightPlayer.cpp
+++ b/media/libmediaplayerservice/StagefrightPlayer.cpp
@@ -29,13 +29,13 @@
 
 StagefrightPlayer::StagefrightPlayer()
     : mPlayer(new AwesomePlayer) {
-    LOGV("StagefrightPlayer");
+    ALOGV("StagefrightPlayer");
 
     mPlayer->setListener(this);
 }
 
 StagefrightPlayer::~StagefrightPlayer() {
-    LOGV("~StagefrightPlayer");
+    ALOGV("~StagefrightPlayer");
     reset();
 
     delete mPlayer;
@@ -43,7 +43,7 @@
 }
 
 status_t StagefrightPlayer::initCheck() {
-    LOGV("initCheck");
+    ALOGV("initCheck");
     return OK;
 }
 
@@ -61,7 +61,7 @@
 // Warning: The filedescriptor passed into this method will only be valid until
 // the method returns, if you want to keep it, dup it!
 status_t StagefrightPlayer::setDataSource(int fd, int64_t offset, int64_t length) {
-    LOGV("setDataSource(%d, %lld, %lld)", fd, offset, length);
+    ALOGV("setDataSource(%d, %lld, %lld)", fd, offset, length);
     return mPlayer->setDataSource(dup(fd), offset, length);
 }
 
@@ -71,7 +71,7 @@
 
 status_t StagefrightPlayer::setVideoSurfaceTexture(
         const sp<ISurfaceTexture> &surfaceTexture) {
-    LOGV("setVideoSurfaceTexture");
+    ALOGV("setVideoSurfaceTexture");
 
     return mPlayer->setSurfaceTexture(surfaceTexture);
 }
@@ -85,30 +85,30 @@
 }
 
 status_t StagefrightPlayer::start() {
-    LOGV("start");
+    ALOGV("start");
 
     return mPlayer->play();
 }
 
 status_t StagefrightPlayer::stop() {
-    LOGV("stop");
+    ALOGV("stop");
 
     return pause();  // what's the difference?
 }
 
 status_t StagefrightPlayer::pause() {
-    LOGV("pause");
+    ALOGV("pause");
 
     return mPlayer->pause();
 }
 
 bool StagefrightPlayer::isPlaying() {
-    LOGV("isPlaying");
+    ALOGV("isPlaying");
     return mPlayer->isPlaying();
 }
 
 status_t StagefrightPlayer::seekTo(int msec) {
-    LOGV("seekTo %.2f secs", msec / 1E3);
+    ALOGV("seekTo %.2f secs", msec / 1E3);
 
     status_t err = mPlayer->seekTo((int64_t)msec * 1000);
 
@@ -116,7 +116,7 @@
 }
 
 status_t StagefrightPlayer::getCurrentPosition(int *msec) {
-    LOGV("getCurrentPosition");
+    ALOGV("getCurrentPosition");
 
     int64_t positionUs;
     status_t err = mPlayer->getPosition(&positionUs);
@@ -131,7 +131,7 @@
 }
 
 status_t StagefrightPlayer::getDuration(int *msec) {
-    LOGV("getDuration");
+    ALOGV("getDuration");
 
     int64_t durationUs;
     status_t err = mPlayer->getDuration(&durationUs);
@@ -147,7 +147,7 @@
 }
 
 status_t StagefrightPlayer::reset() {
-    LOGV("reset");
+    ALOGV("reset");
 
     mPlayer->reset();
 
@@ -155,13 +155,13 @@
 }
 
 status_t StagefrightPlayer::setLooping(int loop) {
-    LOGV("setLooping");
+    ALOGV("setLooping");
 
     return mPlayer->setLooping(loop);
 }
 
 player_type StagefrightPlayer::playerType() {
-    LOGV("playerType");
+    ALOGV("playerType");
     return STAGEFRIGHT_PLAYER;
 }
 
@@ -176,12 +176,12 @@
 }
 
 status_t StagefrightPlayer::setParameter(int key, const Parcel &request) {
-    LOGV("setParameter");
+    ALOGV("setParameter");
     return mPlayer->setParameter(key, request);
 }
 
 status_t StagefrightPlayer::getParameter(int key, Parcel *reply) {
-    LOGV("getParameter");
+    ALOGV("getParameter");
     return mPlayer->getParameter(key, reply);
 }
 
diff --git a/media/libmediaplayerservice/StagefrightRecorder.cpp b/media/libmediaplayerservice/StagefrightRecorder.cpp
index 6981668..4632016 100644
--- a/media/libmediaplayerservice/StagefrightRecorder.cpp
+++ b/media/libmediaplayerservice/StagefrightRecorder.cpp
@@ -71,17 +71,17 @@
       mVideoSource(VIDEO_SOURCE_LIST_END),
       mStarted(false), mSurfaceMediaSource(NULL) {
 
-    LOGV("Constructor");
+    ALOGV("Constructor");
     reset();
 }
 
 StagefrightRecorder::~StagefrightRecorder() {
-    LOGV("Destructor");
+    ALOGV("Destructor");
     stop();
 }
 
 status_t StagefrightRecorder::init() {
-    LOGV("init");
+    ALOGV("init");
     return OK;
 }
 
@@ -89,15 +89,15 @@
 // and return a interface reference. The client side will use that
 // while encoding GL Frames
 sp<ISurfaceTexture> StagefrightRecorder::querySurfaceMediaSource() const {
-    LOGV("Get SurfaceMediaSource");
+    ALOGV("Get SurfaceMediaSource");
     return mSurfaceMediaSource;
 }
 
 status_t StagefrightRecorder::setAudioSource(audio_source_t as) {
-    LOGV("setAudioSource: %d", as);
+    ALOGV("setAudioSource: %d", as);
     if (as < AUDIO_SOURCE_DEFAULT ||
         as >= AUDIO_SOURCE_CNT) {
-        LOGE("Invalid audio source: %d", as);
+        ALOGE("Invalid audio source: %d", as);
         return BAD_VALUE;
     }
 
@@ -111,10 +111,10 @@
 }
 
 status_t StagefrightRecorder::setVideoSource(video_source vs) {
-    LOGV("setVideoSource: %d", vs);
+    ALOGV("setVideoSource: %d", vs);
     if (vs < VIDEO_SOURCE_DEFAULT ||
         vs >= VIDEO_SOURCE_LIST_END) {
-        LOGE("Invalid video source: %d", vs);
+        ALOGE("Invalid video source: %d", vs);
         return BAD_VALUE;
     }
 
@@ -128,10 +128,10 @@
 }
 
 status_t StagefrightRecorder::setOutputFormat(output_format of) {
-    LOGV("setOutputFormat: %d", of);
+    ALOGV("setOutputFormat: %d", of);
     if (of < OUTPUT_FORMAT_DEFAULT ||
         of >= OUTPUT_FORMAT_LIST_END) {
-        LOGE("Invalid output format: %d", of);
+        ALOGE("Invalid output format: %d", of);
         return BAD_VALUE;
     }
 
@@ -145,10 +145,10 @@
 }
 
 status_t StagefrightRecorder::setAudioEncoder(audio_encoder ae) {
-    LOGV("setAudioEncoder: %d", ae);
+    ALOGV("setAudioEncoder: %d", ae);
     if (ae < AUDIO_ENCODER_DEFAULT ||
         ae >= AUDIO_ENCODER_LIST_END) {
-        LOGE("Invalid audio encoder: %d", ae);
+        ALOGE("Invalid audio encoder: %d", ae);
         return BAD_VALUE;
     }
 
@@ -162,10 +162,10 @@
 }
 
 status_t StagefrightRecorder::setVideoEncoder(video_encoder ve) {
-    LOGV("setVideoEncoder: %d", ve);
+    ALOGV("setVideoEncoder: %d", ve);
     if (ve < VIDEO_ENCODER_DEFAULT ||
         ve >= VIDEO_ENCODER_LIST_END) {
-        LOGE("Invalid video encoder: %d", ve);
+        ALOGE("Invalid video encoder: %d", ve);
         return BAD_VALUE;
     }
 
@@ -179,9 +179,9 @@
 }
 
 status_t StagefrightRecorder::setVideoSize(int width, int height) {
-    LOGV("setVideoSize: %dx%d", width, height);
+    ALOGV("setVideoSize: %dx%d", width, height);
     if (width <= 0 || height <= 0) {
-        LOGE("Invalid video size: %dx%d", width, height);
+        ALOGE("Invalid video size: %dx%d", width, height);
         return BAD_VALUE;
     }
 
@@ -193,10 +193,10 @@
 }
 
 status_t StagefrightRecorder::setVideoFrameRate(int frames_per_second) {
-    LOGV("setVideoFrameRate: %d", frames_per_second);
+    ALOGV("setVideoFrameRate: %d", frames_per_second);
     if ((frames_per_second <= 0 && frames_per_second != -1) ||
         frames_per_second > 120) {
-        LOGE("Invalid video frame rate: %d", frames_per_second);
+        ALOGE("Invalid video frame rate: %d", frames_per_second);
         return BAD_VALUE;
     }
 
@@ -208,13 +208,13 @@
 
 status_t StagefrightRecorder::setCamera(const sp<ICamera> &camera,
                                         const sp<ICameraRecordingProxy> &proxy) {
-    LOGV("setCamera");
+    ALOGV("setCamera");
     if (camera == 0) {
-        LOGE("camera is NULL");
+        ALOGE("camera is NULL");
         return BAD_VALUE;
     }
     if (proxy == 0) {
-        LOGE("camera proxy is NULL");
+        ALOGE("camera proxy is NULL");
         return BAD_VALUE;
     }
 
@@ -224,14 +224,14 @@
 }
 
 status_t StagefrightRecorder::setPreviewSurface(const sp<Surface> &surface) {
-    LOGV("setPreviewSurface: %p", surface.get());
+    ALOGV("setPreviewSurface: %p", surface.get());
     mPreviewSurface = surface;
 
     return OK;
 }
 
 status_t StagefrightRecorder::setOutputFile(const char *path) {
-    LOGE("setOutputFile(const char*) must not be called");
+    ALOGE("setOutputFile(const char*) must not be called");
     // We don't actually support this at all, as the media_server process
     // no longer has permissions to create files.
 
@@ -239,13 +239,13 @@
 }
 
 status_t StagefrightRecorder::setOutputFile(int fd, int64_t offset, int64_t length) {
-    LOGV("setOutputFile: %d, %lld, %lld", fd, offset, length);
+    ALOGV("setOutputFile: %d, %lld, %lld", fd, offset, length);
     // These don't make any sense, do they?
     CHECK_EQ(offset, 0);
     CHECK_EQ(length, 0);
 
     if (fd < 0) {
-        LOGE("Invalid file descriptor: %d", fd);
+        ALOGE("Invalid file descriptor: %d", fd);
         return -EBADF;
     }
 
@@ -313,9 +313,9 @@
 }
 
 status_t StagefrightRecorder::setParamAudioSamplingRate(int32_t sampleRate) {
-    LOGV("setParamAudioSamplingRate: %d", sampleRate);
+    ALOGV("setParamAudioSamplingRate: %d", sampleRate);
     if (sampleRate <= 0) {
-        LOGE("Invalid audio sampling rate: %d", sampleRate);
+        ALOGE("Invalid audio sampling rate: %d", sampleRate);
         return BAD_VALUE;
     }
 
@@ -325,9 +325,9 @@
 }
 
 status_t StagefrightRecorder::setParamAudioNumberOfChannels(int32_t channels) {
-    LOGV("setParamAudioNumberOfChannels: %d", channels);
+    ALOGV("setParamAudioNumberOfChannels: %d", channels);
     if (channels <= 0 || channels >= 3) {
-        LOGE("Invalid number of audio channels: %d", channels);
+        ALOGE("Invalid number of audio channels: %d", channels);
         return BAD_VALUE;
     }
 
@@ -337,9 +337,9 @@
 }
 
 status_t StagefrightRecorder::setParamAudioEncodingBitRate(int32_t bitRate) {
-    LOGV("setParamAudioEncodingBitRate: %d", bitRate);
+    ALOGV("setParamAudioEncodingBitRate: %d", bitRate);
     if (bitRate <= 0) {
-        LOGE("Invalid audio encoding bit rate: %d", bitRate);
+        ALOGE("Invalid audio encoding bit rate: %d", bitRate);
         return BAD_VALUE;
     }
 
@@ -352,9 +352,9 @@
 }
 
 status_t StagefrightRecorder::setParamVideoEncodingBitRate(int32_t bitRate) {
-    LOGV("setParamVideoEncodingBitRate: %d", bitRate);
+    ALOGV("setParamVideoEncodingBitRate: %d", bitRate);
     if (bitRate <= 0) {
-        LOGE("Invalid video encoding bit rate: %d", bitRate);
+        ALOGE("Invalid video encoding bit rate: %d", bitRate);
         return BAD_VALUE;
     }
 
@@ -368,9 +368,9 @@
 
 // Always rotate clockwise, and only support 0, 90, 180 and 270 for now.
 status_t StagefrightRecorder::setParamVideoRotation(int32_t degrees) {
-    LOGV("setParamVideoRotation: %d", degrees);
+    ALOGV("setParamVideoRotation: %d", degrees);
     if (degrees < 0 || degrees % 90 != 0) {
-        LOGE("Unsupported video rotation angle: %d", degrees);
+        ALOGE("Unsupported video rotation angle: %d", degrees);
         return BAD_VALUE;
     }
     mRotationDegrees = degrees % 360;
@@ -378,39 +378,39 @@
 }
 
 status_t StagefrightRecorder::setParamMaxFileDurationUs(int64_t timeUs) {
-    LOGV("setParamMaxFileDurationUs: %lld us", timeUs);
+    ALOGV("setParamMaxFileDurationUs: %lld us", timeUs);
 
     // This is meant for backward compatibility for MediaRecorder.java
     if (timeUs <= 0) {
-        LOGW("Max file duration is not positive: %lld us. Disabling duration limit.", timeUs);
+        ALOGW("Max file duration is not positive: %lld us. Disabling duration limit.", timeUs);
         timeUs = 0; // Disable the duration limit for zero or negative values.
     } else if (timeUs <= 100000LL) {  // XXX: 100 milli-seconds
-        LOGE("Max file duration is too short: %lld us", timeUs);
+        ALOGE("Max file duration is too short: %lld us", timeUs);
         return BAD_VALUE;
     }
 
     if (timeUs <= 15 * 1000000LL) {
-        LOGW("Target duration (%lld us) too short to be respected", timeUs);
+        ALOGW("Target duration (%lld us) too short to be respected", timeUs);
     }
     mMaxFileDurationUs = timeUs;
     return OK;
 }
 
 status_t StagefrightRecorder::setParamMaxFileSizeBytes(int64_t bytes) {
-    LOGV("setParamMaxFileSizeBytes: %lld bytes", bytes);
+    ALOGV("setParamMaxFileSizeBytes: %lld bytes", bytes);
 
     // This is meant for backward compatibility for MediaRecorder.java
     if (bytes <= 0) {
-        LOGW("Max file size is not positive: %lld bytes. "
+        ALOGW("Max file size is not positive: %lld bytes. "
              "Disabling file size limit.", bytes);
         bytes = 0; // Disable the file size limit for zero or negative values.
     } else if (bytes <= 1024) {  // XXX: 1 kB
-        LOGE("Max file size is too small: %lld bytes", bytes);
+        ALOGE("Max file size is too small: %lld bytes", bytes);
         return BAD_VALUE;
     }
 
     if (bytes <= 100 * 1024) {
-        LOGW("Target file size (%lld bytes) is too small to be respected", bytes);
+        ALOGW("Target file size (%lld bytes) is too small to be respected", bytes);
     }
 
     mMaxFileSizeBytes = bytes;
@@ -418,18 +418,18 @@
 }
 
 status_t StagefrightRecorder::setParamInterleaveDuration(int32_t durationUs) {
-    LOGV("setParamInterleaveDuration: %d", durationUs);
+    ALOGV("setParamInterleaveDuration: %d", durationUs);
     if (durationUs <= 500000) {           //  500 ms
         // If interleave duration is too small, it is very inefficient to do
         // interleaving since the metadata overhead will count for a significant
         // portion of the saved contents
-        LOGE("Audio/video interleave duration is too small: %d us", durationUs);
+        ALOGE("Audio/video interleave duration is too small: %d us", durationUs);
         return BAD_VALUE;
     } else if (durationUs >= 10000000) {  // 10 seconds
         // If interleaving duration is too large, it can cause the recording
         // session to use too much memory since we have to save the output
         // data before we write them out
-        LOGE("Audio/video interleave duration is too large: %d us", durationUs);
+        ALOGE("Audio/video interleave duration is too large: %d us", durationUs);
         return BAD_VALUE;
     }
     mInterleaveDurationUs = durationUs;
@@ -440,20 +440,20 @@
 // If seconds == 0, all frames are encoded as I frames. No P frames
 // If seconds >  0, it is the time spacing (seconds) between 2 neighboring I frames
 status_t StagefrightRecorder::setParamVideoIFramesInterval(int32_t seconds) {
-    LOGV("setParamVideoIFramesInterval: %d seconds", seconds);
+    ALOGV("setParamVideoIFramesInterval: %d seconds", seconds);
     mIFramesIntervalSec = seconds;
     return OK;
 }
 
 status_t StagefrightRecorder::setParam64BitFileOffset(bool use64Bit) {
-    LOGV("setParam64BitFileOffset: %s",
+    ALOGV("setParam64BitFileOffset: %s",
         use64Bit? "use 64 bit file offset": "use 32 bit file offset");
     mUse64BitFileOffset = use64Bit;
     return OK;
 }
 
 status_t StagefrightRecorder::setParamVideoCameraId(int32_t cameraId) {
-    LOGV("setParamVideoCameraId: %d", cameraId);
+    ALOGV("setParamVideoCameraId: %d", cameraId);
     if (cameraId < 0) {
         return BAD_VALUE;
     }
@@ -462,9 +462,9 @@
 }
 
 status_t StagefrightRecorder::setParamTrackTimeStatus(int64_t timeDurationUs) {
-    LOGV("setParamTrackTimeStatus: %lld", timeDurationUs);
+    ALOGV("setParamTrackTimeStatus: %lld", timeDurationUs);
     if (timeDurationUs < 20000) {  // Infeasible if shorter than 20 ms?
-        LOGE("Tracking time duration too short: %lld us", timeDurationUs);
+        ALOGE("Tracking time duration too short: %lld us", timeDurationUs);
         return BAD_VALUE;
     }
     mTrackEveryTimeDurationUs = timeDurationUs;
@@ -472,7 +472,7 @@
 }
 
 status_t StagefrightRecorder::setParamVideoEncoderProfile(int32_t profile) {
-    LOGV("setParamVideoEncoderProfile: %d", profile);
+    ALOGV("setParamVideoEncoderProfile: %d", profile);
 
     // Additional check will be done later when we load the encoder.
     // For now, we are accepting values defined in OpenMAX IL.
@@ -481,7 +481,7 @@
 }
 
 status_t StagefrightRecorder::setParamVideoEncoderLevel(int32_t level) {
-    LOGV("setParamVideoEncoderLevel: %d", level);
+    ALOGV("setParamVideoEncoderLevel: %d", level);
 
     // Additional check will be done later when we load the encoder.
     // For now, we are accepting values defined in OpenMAX IL.
@@ -490,12 +490,12 @@
 }
 
 status_t StagefrightRecorder::setParamMovieTimeScale(int32_t timeScale) {
-    LOGV("setParamMovieTimeScale: %d", timeScale);
+    ALOGV("setParamMovieTimeScale: %d", timeScale);
 
     // The range is set to be the same as the audio's time scale range
     // since audio's time scale has a wider range.
     if (timeScale < 600 || timeScale > 96000) {
-        LOGE("Time scale (%d) for movie is out of range [600, 96000]", timeScale);
+        ALOGE("Time scale (%d) for movie is out of range [600, 96000]", timeScale);
         return BAD_VALUE;
     }
     mMovieTimeScale = timeScale;
@@ -503,12 +503,12 @@
 }
 
 status_t StagefrightRecorder::setParamVideoTimeScale(int32_t timeScale) {
-    LOGV("setParamVideoTimeScale: %d", timeScale);
+    ALOGV("setParamVideoTimeScale: %d", timeScale);
 
     // 60000 is chosen to make sure that each video frame from a 60-fps
     // video has 1000 ticks.
     if (timeScale < 600 || timeScale > 60000) {
-        LOGE("Time scale (%d) for video is out of range [600, 60000]", timeScale);
+        ALOGE("Time scale (%d) for video is out of range [600, 60000]", timeScale);
         return BAD_VALUE;
     }
     mVideoTimeScale = timeScale;
@@ -516,11 +516,11 @@
 }
 
 status_t StagefrightRecorder::setParamAudioTimeScale(int32_t timeScale) {
-    LOGV("setParamAudioTimeScale: %d", timeScale);
+    ALOGV("setParamAudioTimeScale: %d", timeScale);
 
     // 96000 Hz is the highest sampling rate support in AAC.
     if (timeScale < 600 || timeScale > 96000) {
-        LOGE("Time scale (%d) for audio is out of range [600, 96000]", timeScale);
+        ALOGE("Time scale (%d) for audio is out of range [600, 96000]", timeScale);
         return BAD_VALUE;
     }
     mAudioTimeScale = timeScale;
@@ -528,7 +528,7 @@
 }
 
 status_t StagefrightRecorder::setParamTimeLapseEnable(int32_t timeLapseEnable) {
-    LOGV("setParamTimeLapseEnable: %d", timeLapseEnable);
+    ALOGV("setParamTimeLapseEnable: %d", timeLapseEnable);
 
     if(timeLapseEnable == 0) {
         mCaptureTimeLapse = false;
@@ -541,11 +541,11 @@
 }
 
 status_t StagefrightRecorder::setParamTimeBetweenTimeLapseFrameCapture(int64_t timeUs) {
-    LOGV("setParamTimeBetweenTimeLapseFrameCapture: %lld us", timeUs);
+    ALOGV("setParamTimeBetweenTimeLapseFrameCapture: %lld us", timeUs);
 
     // Not allowing time more than a day
     if (timeUs <= 0 || timeUs > 86400*1E6) {
-        LOGE("Time between time lapse frame capture (%lld) is out of range [0, 1 Day]", timeUs);
+        ALOGE("Time between time lapse frame capture (%lld) is out of range [0, 1 Day]", timeUs);
         return BAD_VALUE;
     }
 
@@ -575,7 +575,7 @@
 
 status_t StagefrightRecorder::setParameter(
         const String8 &key, const String8 &value) {
-    LOGV("setParameter: key (%s) => value (%s)", key.string(), value.string());
+    ALOGV("setParameter: key (%s) => value (%s)", key.string(), value.string());
     if (key == "max-duration") {
         int64_t max_duration_ms;
         if (safe_strtoi64(value.string(), &max_duration_ms)) {
@@ -683,25 +683,25 @@
                     1000LL * timeBetweenTimeLapseFrameCaptureMs);
         }
     } else {
-        LOGE("setParameter: failed to find key %s", key.string());
+        ALOGE("setParameter: failed to find key %s", key.string());
     }
     return BAD_VALUE;
 }
 
 status_t StagefrightRecorder::setParameters(const String8 &params) {
-    LOGV("setParameters: %s", params.string());
+    ALOGV("setParameters: %s", params.string());
     const char *cparams = params.string();
     const char *key_start = cparams;
     for (;;) {
         const char *equal_pos = strchr(key_start, '=');
         if (equal_pos == NULL) {
-            LOGE("Parameters %s miss a value", cparams);
+            ALOGE("Parameters %s miss a value", cparams);
             return BAD_VALUE;
         }
         String8 key(key_start, equal_pos - key_start);
         TrimString(&key);
         if (key.length() == 0) {
-            LOGE("Parameters %s contains an empty key", cparams);
+            ALOGE("Parameters %s contains an empty key", cparams);
             return BAD_VALUE;
         }
         const char *value_start = equal_pos + 1;
@@ -737,7 +737,7 @@
     CHECK(mOutputFd >= 0);
 
     if (mWriter != NULL) {
-        LOGE("File writer is not avaialble");
+        ALOGE("File writer is not avaialble");
         return UNKNOWN_ERROR;
     }
 
@@ -769,7 +769,7 @@
             break;
 
         default:
-            LOGE("Unsupported output file format: %d", mOutputFormat);
+            ALOGE("Unsupported output file format: %d", mOutputFormat);
             status = UNKNOWN_ERROR;
             break;
     }
@@ -801,7 +801,7 @@
     status_t err = audioSource->initCheck();
 
     if (err != OK) {
-        LOGE("audio source is not initialized");
+        ALOGE("audio source is not initialized");
         return NULL;
     }
 
@@ -819,7 +819,7 @@
             mime = MEDIA_MIMETYPE_AUDIO_AAC;
             break;
         default:
-            LOGE("Unknown audio encoder: %d", mAudioEncoder);
+            ALOGE("Unknown audio encoder: %d", mAudioEncoder);
             return NULL;
     }
     encMeta->setCString(kKeyMIMEType, mime);
@@ -872,13 +872,13 @@
     if (mOutputFormat == OUTPUT_FORMAT_AMR_NB) {
         if (mAudioEncoder != AUDIO_ENCODER_DEFAULT &&
             mAudioEncoder != AUDIO_ENCODER_AMR_NB) {
-            LOGE("Invalid encoder %d used for AMRNB recording",
+            ALOGE("Invalid encoder %d used for AMRNB recording",
                     mAudioEncoder);
             return BAD_VALUE;
         }
     } else {  // mOutputFormat must be OUTPUT_FORMAT_AMR_WB
         if (mAudioEncoder != AUDIO_ENCODER_AMR_WB) {
-            LOGE("Invlaid encoder %d used for AMRWB recording",
+            ALOGE("Invlaid encoder %d used for AMRWB recording",
                     mAudioEncoder);
             return BAD_VALUE;
         }
@@ -895,7 +895,7 @@
 
 status_t StagefrightRecorder::startRawAudioRecording() {
     if (mAudioSource >= AUDIO_SOURCE_CNT) {
-        LOGE("Invalid audio source: %d", mAudioSource);
+        ALOGE("Invalid audio source: %d", mAudioSource);
         return BAD_VALUE;
     }
 
@@ -1016,51 +1016,51 @@
 }
 
 void StagefrightRecorder::clipVideoFrameRate() {
-    LOGV("clipVideoFrameRate: encoder %d", mVideoEncoder);
+    ALOGV("clipVideoFrameRate: encoder %d", mVideoEncoder);
     int minFrameRate = mEncoderProfiles->getVideoEncoderParamByName(
                         "enc.vid.fps.min", mVideoEncoder);
     int maxFrameRate = mEncoderProfiles->getVideoEncoderParamByName(
                         "enc.vid.fps.max", mVideoEncoder);
     if (mFrameRate < minFrameRate && mFrameRate != -1) {
-        LOGW("Intended video encoding frame rate (%d fps) is too small"
+        ALOGW("Intended video encoding frame rate (%d fps) is too small"
              " and will be set to (%d fps)", mFrameRate, minFrameRate);
         mFrameRate = minFrameRate;
     } else if (mFrameRate > maxFrameRate) {
-        LOGW("Intended video encoding frame rate (%d fps) is too large"
+        ALOGW("Intended video encoding frame rate (%d fps) is too large"
              " and will be set to (%d fps)", mFrameRate, maxFrameRate);
         mFrameRate = maxFrameRate;
     }
 }
 
 void StagefrightRecorder::clipVideoBitRate() {
-    LOGV("clipVideoBitRate: encoder %d", mVideoEncoder);
+    ALOGV("clipVideoBitRate: encoder %d", mVideoEncoder);
     int minBitRate = mEncoderProfiles->getVideoEncoderParamByName(
                         "enc.vid.bps.min", mVideoEncoder);
     int maxBitRate = mEncoderProfiles->getVideoEncoderParamByName(
                         "enc.vid.bps.max", mVideoEncoder);
     if (mVideoBitRate < minBitRate) {
-        LOGW("Intended video encoding bit rate (%d bps) is too small"
+        ALOGW("Intended video encoding bit rate (%d bps) is too small"
              " and will be set to (%d bps)", mVideoBitRate, minBitRate);
         mVideoBitRate = minBitRate;
     } else if (mVideoBitRate > maxBitRate) {
-        LOGW("Intended video encoding bit rate (%d bps) is too large"
+        ALOGW("Intended video encoding bit rate (%d bps) is too large"
              " and will be set to (%d bps)", mVideoBitRate, maxBitRate);
         mVideoBitRate = maxBitRate;
     }
 }
 
 void StagefrightRecorder::clipVideoFrameWidth() {
-    LOGV("clipVideoFrameWidth: encoder %d", mVideoEncoder);
+    ALOGV("clipVideoFrameWidth: encoder %d", mVideoEncoder);
     int minFrameWidth = mEncoderProfiles->getVideoEncoderParamByName(
                         "enc.vid.width.min", mVideoEncoder);
     int maxFrameWidth = mEncoderProfiles->getVideoEncoderParamByName(
                         "enc.vid.width.max", mVideoEncoder);
     if (mVideoWidth < minFrameWidth) {
-        LOGW("Intended video encoding frame width (%d) is too small"
+        ALOGW("Intended video encoding frame width (%d) is too small"
              " and will be set to (%d)", mVideoWidth, minFrameWidth);
         mVideoWidth = minFrameWidth;
     } else if (mVideoWidth > maxFrameWidth) {
-        LOGW("Intended video encoding frame width (%d) is too large"
+        ALOGW("Intended video encoding frame width (%d) is too large"
              " and will be set to (%d)", mVideoWidth, maxFrameWidth);
         mVideoWidth = maxFrameWidth;
     }
@@ -1082,7 +1082,7 @@
 // Set to use AVC baseline profile if the encoding parameters matches
 // CAMCORDER_QUALITY_LOW profile; this is for the sake of MMS service.
 void StagefrightRecorder::setDefaultProfileIfNecessary() {
-    LOGV("setDefaultProfileIfNecessary");
+    ALOGV("setDefaultProfileIfNecessary");
 
     camcorder_quality quality = CAMCORDER_QUALITY_LOW;
 
@@ -1131,7 +1131,7 @@
         audioSampleRate == mSampleRate &&
         audioChannels == mAudioChannels) {
         if (videoCodec == VIDEO_ENCODER_H264) {
-            LOGI("Force to use AVC baseline profile");
+            ALOGI("Force to use AVC baseline profile");
             setParamVideoEncoderProfile(OMX_VIDEO_AVCProfileBaseline);
         }
     }
@@ -1145,13 +1145,13 @@
 }
 
 void StagefrightRecorder::clipAudioBitRate() {
-    LOGV("clipAudioBitRate: encoder %d", mAudioEncoder);
+    ALOGV("clipAudioBitRate: encoder %d", mAudioEncoder);
 
     int minAudioBitRate =
             mEncoderProfiles->getAudioEncoderParamByName(
                 "enc.aud.bps.min", mAudioEncoder);
     if (mAudioBitRate < minAudioBitRate) {
-        LOGW("Intended audio encoding bit rate (%d) is too small"
+        ALOGW("Intended audio encoding bit rate (%d) is too small"
             " and will be set to (%d)", mAudioBitRate, minAudioBitRate);
         mAudioBitRate = minAudioBitRate;
     }
@@ -1160,20 +1160,20 @@
             mEncoderProfiles->getAudioEncoderParamByName(
                 "enc.aud.bps.max", mAudioEncoder);
     if (mAudioBitRate > maxAudioBitRate) {
-        LOGW("Intended audio encoding bit rate (%d) is too large"
+        ALOGW("Intended audio encoding bit rate (%d) is too large"
             " and will be set to (%d)", mAudioBitRate, maxAudioBitRate);
         mAudioBitRate = maxAudioBitRate;
     }
 }
 
 void StagefrightRecorder::clipAudioSampleRate() {
-    LOGV("clipAudioSampleRate: encoder %d", mAudioEncoder);
+    ALOGV("clipAudioSampleRate: encoder %d", mAudioEncoder);
 
     int minSampleRate =
             mEncoderProfiles->getAudioEncoderParamByName(
                 "enc.aud.hz.min", mAudioEncoder);
     if (mSampleRate < minSampleRate) {
-        LOGW("Intended audio sample rate (%d) is too small"
+        ALOGW("Intended audio sample rate (%d) is too small"
             " and will be set to (%d)", mSampleRate, minSampleRate);
         mSampleRate = minSampleRate;
     }
@@ -1182,20 +1182,20 @@
             mEncoderProfiles->getAudioEncoderParamByName(
                 "enc.aud.hz.max", mAudioEncoder);
     if (mSampleRate > maxSampleRate) {
-        LOGW("Intended audio sample rate (%d) is too large"
+        ALOGW("Intended audio sample rate (%d) is too large"
             " and will be set to (%d)", mSampleRate, maxSampleRate);
         mSampleRate = maxSampleRate;
     }
 }
 
 void StagefrightRecorder::clipNumberOfAudioChannels() {
-    LOGV("clipNumberOfAudioChannels: encoder %d", mAudioEncoder);
+    ALOGV("clipNumberOfAudioChannels: encoder %d", mAudioEncoder);
 
     int minChannels =
             mEncoderProfiles->getAudioEncoderParamByName(
                 "enc.aud.ch.min", mAudioEncoder);
     if (mAudioChannels < minChannels) {
-        LOGW("Intended number of audio channels (%d) is too small"
+        ALOGW("Intended number of audio channels (%d) is too small"
             " and will be set to (%d)", mAudioChannels, minChannels);
         mAudioChannels = minChannels;
     }
@@ -1204,24 +1204,24 @@
             mEncoderProfiles->getAudioEncoderParamByName(
                 "enc.aud.ch.max", mAudioEncoder);
     if (mAudioChannels > maxChannels) {
-        LOGW("Intended number of audio channels (%d) is too large"
+        ALOGW("Intended number of audio channels (%d) is too large"
             " and will be set to (%d)", mAudioChannels, maxChannels);
         mAudioChannels = maxChannels;
     }
 }
 
 void StagefrightRecorder::clipVideoFrameHeight() {
-    LOGV("clipVideoFrameHeight: encoder %d", mVideoEncoder);
+    ALOGV("clipVideoFrameHeight: encoder %d", mVideoEncoder);
     int minFrameHeight = mEncoderProfiles->getVideoEncoderParamByName(
                         "enc.vid.height.min", mVideoEncoder);
     int maxFrameHeight = mEncoderProfiles->getVideoEncoderParamByName(
                         "enc.vid.height.max", mVideoEncoder);
     if (mVideoHeight < minFrameHeight) {
-        LOGW("Intended video encoding frame height (%d) is too small"
+        ALOGW("Intended video encoding frame height (%d) is too small"
              " and will be set to (%d)", mVideoHeight, minFrameHeight);
         mVideoHeight = minFrameHeight;
     } else if (mVideoHeight > maxFrameHeight) {
-        LOGW("Intended video encoding frame height (%d) is too large"
+        ALOGW("Intended video encoding frame height (%d) is too large"
              " and will be set to (%d)", mVideoHeight, maxFrameHeight);
         mVideoHeight = maxFrameHeight;
     }
@@ -1268,7 +1268,7 @@
         int32_t frameRate = 0;
         CHECK (mSurfaceMediaSource->getFormat()->findInt32(
                                         kKeyFrameRate, &frameRate));
-        LOGI("Frame rate is not explicitly set. Use the current frame "
+        ALOGI("Frame rate is not explicitly set. Use the current frame "
              "rate (%d fps)", frameRate);
         mFrameRate = frameRate;
     } else {
@@ -1319,7 +1319,7 @@
         int32_t frameRate = 0;
         CHECK ((*cameraSource)->getFormat()->findInt32(
                     kKeyFrameRate, &frameRate));
-        LOGI("Frame rate is not explicitly set. Use the current frame "
+        ALOGI("Frame rate is not explicitly set. Use the current frame "
              "rate (%d fps)", frameRate);
         mFrameRate = frameRate;
     }
@@ -1406,7 +1406,7 @@
             true /* createEncoder */, cameraSource,
             NULL, encoder_flags);
     if (encoder == NULL) {
-        LOGW("Failed to create the encoder");
+        ALOGW("Failed to create the encoder");
         // When the encoder fails to be created, we need
         // release the camera source due to the camera's lock
         // and unlock mechanism.
@@ -1432,7 +1432,7 @@
             break;
 
         default:
-            LOGE("Unsupported audio encoder: %d", mAudioEncoder);
+            ALOGE("Unsupported audio encoder: %d", mAudioEncoder);
             return UNKNOWN_ERROR;
     }
 
@@ -1548,7 +1548,7 @@
 }
 
 status_t StagefrightRecorder::pause() {
-    LOGV("pause");
+    ALOGV("pause");
     if (mWriter == NULL) {
         return UNKNOWN_ERROR;
     }
@@ -1573,7 +1573,7 @@
 }
 
 status_t StagefrightRecorder::stop() {
-    LOGV("stop");
+    ALOGV("stop");
     status_t err = OK;
 
     if (mCaptureTimeLapse && mCameraSourceTimeLapse != NULL) {
@@ -1610,14 +1610,14 @@
 }
 
 status_t StagefrightRecorder::close() {
-    LOGV("close");
+    ALOGV("close");
     stop();
 
     return OK;
 }
 
 status_t StagefrightRecorder::reset() {
-    LOGV("reset");
+    ALOGV("reset");
     stop();
 
     // No audio or video source by default
@@ -1664,10 +1664,10 @@
 }
 
 status_t StagefrightRecorder::getMaxAmplitude(int *max) {
-    LOGV("getMaxAmplitude");
+    ALOGV("getMaxAmplitude");
 
     if (max == NULL) {
-        LOGE("Null pointer argument");
+        ALOGE("Null pointer argument");
         return BAD_VALUE;
     }
 
@@ -1682,7 +1682,7 @@
 
 status_t StagefrightRecorder::dump(
         int fd, const Vector<String16>& args) const {
-    LOGV("dump");
+    ALOGV("dump");
     const size_t SIZE = 256;
     char buffer[SIZE];
     String8 result;
diff --git a/media/libmediaplayerservice/TestPlayerStub.cpp b/media/libmediaplayerservice/TestPlayerStub.cpp
index 169e49a..5d9728a 100644
--- a/media/libmediaplayerservice/TestPlayerStub.cpp
+++ b/media/libmediaplayerservice/TestPlayerStub.cpp
@@ -134,7 +134,7 @@
     // None of the entry points should be NULL.
     mHandle = ::dlopen(mFilename, RTLD_NOW | RTLD_GLOBAL);
     if (!mHandle) {
-        LOGE("dlopen failed: %s", ::dlerror());
+        ALOGE("dlopen failed: %s", ::dlerror());
         resetInternal();
         return UNKNOWN_ERROR;
     }
@@ -147,7 +147,7 @@
     if (err || mNewPlayer == NULL) {
         // if err is NULL the string <null> is inserted in the logs =>
         // mNewPlayer was NULL.
-        LOGE("dlsym for newPlayer failed %s", err);
+        ALOGE("dlsym for newPlayer failed %s", err);
         resetInternal();
         return UNKNOWN_ERROR;
     }
@@ -156,7 +156,7 @@
                                                           "deletePlayer"));
     err = ::dlerror();
     if (err || mDeletePlayer == NULL) {
-        LOGE("dlsym for deletePlayer failed %s", err);
+        ALOGE("dlsym for deletePlayer failed %s", err);
         resetInternal();
         return UNKNOWN_ERROR;
     }
@@ -176,7 +176,7 @@
     mContentUrl = NULL;
 
     if (mPlayer) {
-        LOG_ASSERT(mDeletePlayer != NULL, "mDeletePlayer is null");
+        ALOG_ASSERT(mDeletePlayer != NULL, "mDeletePlayer is null");
         (*mDeletePlayer)(mPlayer);
         mPlayer = NULL;
     }
diff --git a/media/libmediaplayerservice/nuplayer/HTTPLiveSource.cpp b/media/libmediaplayerservice/nuplayer/HTTPLiveSource.cpp
index 079f6fa..22b8847 100644
--- a/media/libmediaplayerservice/nuplayer/HTTPLiveSource.cpp
+++ b/media/libmediaplayerservice/nuplayer/HTTPLiveSource.cpp
@@ -111,9 +111,9 @@
             break;
         } else if (n < 0) {
             if (n != ERROR_END_OF_STREAM) {
-                LOGI("input data EOS reached, error %ld", n);
+                ALOGI("input data EOS reached, error %ld", n);
             } else {
-                LOGI("input data EOS reached.");
+                ALOGI("input data EOS reached.");
             }
             mTSParser->signalEOS(n);
             mFinalResult = n;
@@ -131,7 +131,7 @@
                 status_t err = mTSParser->feedTSPacket(buffer, sizeof(buffer));
 
                 if (err != OK) {
-                    LOGE("TS Parser returned error %d", err);
+                    ALOGE("TS Parser returned error %d", err);
                     mTSParser->signalEOS(err);
                     mFinalResult = err;
                     break;
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
index 93ab704..b731d0f 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
+++ b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
@@ -160,7 +160,7 @@
     switch (msg->what()) {
         case kWhatSetDataSource:
         {
-            LOGV("kWhatSetDataSource");
+            ALOGV("kWhatSetDataSource");
 
             CHECK(mSource == NULL);
 
@@ -173,7 +173,7 @@
 
         case kWhatSetVideoNativeWindow:
         {
-            LOGV("kWhatSetVideoNativeWindow");
+            ALOGV("kWhatSetVideoNativeWindow");
 
             sp<RefBase> obj;
             CHECK(msg->findObject("native-window", &obj));
@@ -184,7 +184,7 @@
 
         case kWhatSetAudioSink:
         {
-            LOGV("kWhatSetAudioSink");
+            ALOGV("kWhatSetAudioSink");
 
             sp<RefBase> obj;
             CHECK(msg->findObject("sink", &obj));
@@ -195,7 +195,7 @@
 
         case kWhatStart:
         {
-            LOGV("kWhatStart");
+            ALOGV("kWhatStart");
 
             mVideoIsAVC = false;
             mAudioEOS = false;
@@ -229,7 +229,7 @@
 
             mScanSourcesPending = false;
 
-            LOGV("scanning sources haveAudio=%d, haveVideo=%d",
+            ALOGV("scanning sources haveAudio=%d, haveVideo=%d",
                  mAudioDecoder != NULL, mVideoDecoder != NULL);
 
             instantiateDecoder(false, &mVideoDecoder);
@@ -285,9 +285,9 @@
                 CHECK(codecRequest->findInt32("err", &err));
 
                 if (err == ERROR_END_OF_STREAM) {
-                    LOGV("got %s decoder EOS", audio ? "audio" : "video");
+                    ALOGV("got %s decoder EOS", audio ? "audio" : "video");
                 } else {
-                    LOGV("got %s decoder EOS w/ error %d",
+                    ALOGV("got %s decoder EOS w/ error %d",
                          audio ? "audio" : "video",
                          err);
                 }
@@ -306,10 +306,10 @@
                     mVideoLateByUs = 0;
                 }
 
-                LOGV("decoder %s flush completed", audio ? "audio" : "video");
+                ALOGV("decoder %s flush completed", audio ? "audio" : "video");
 
                 if (needShutdown) {
-                    LOGV("initiating %s decoder shutdown",
+                    ALOGV("initiating %s decoder shutdown",
                          audio ? "audio" : "video");
 
                     (audio ? mAudioDecoder : mVideoDecoder)->initiateShutdown();
@@ -330,7 +330,7 @@
                     int32_t sampleRate;
                     CHECK(codecRequest->findInt32("sample-rate", &sampleRate));
 
-                    LOGV("Audio output format changed to %d Hz, %d channels",
+                    ALOGV("Audio output format changed to %d Hz, %d channels",
                          sampleRate, numChannels);
 
                     mAudioSink->close();
@@ -355,7 +355,7 @@
                                 "crop",
                                 &cropLeft, &cropTop, &cropRight, &cropBottom));
 
-                    LOGV("Video output format changed to %d x %d "
+                    ALOGV("Video output format changed to %d x %d "
                          "(crop: %d x %d @ (%d, %d))",
                          width, height,
                          (cropRight - cropLeft + 1),
@@ -368,7 +368,7 @@
                             cropBottom - cropTop + 1);
                 }
             } else if (what == ACodec::kWhatShutdownCompleted) {
-                LOGV("%s shutdown completed", audio ? "audio" : "video");
+                ALOGV("%s shutdown completed", audio ? "audio" : "video");
                 if (audio) {
                     mAudioDecoder.clear();
 
@@ -383,7 +383,7 @@
 
                 finishFlushIfPossible();
             } else if (what == ACodec::kWhatError) {
-                LOGE("Received error from %s decoder, aborting playback.",
+                ALOGE("Received error from %s decoder, aborting playback.",
                      audio ? "audio" : "video");
 
                 mRenderer->queueEOS(audio, UNKNOWN_ERROR);
@@ -415,9 +415,9 @@
                 }
 
                 if (finalResult == ERROR_END_OF_STREAM) {
-                    LOGV("reached %s EOS", audio ? "audio" : "video");
+                    ALOGV("reached %s EOS", audio ? "audio" : "video");
                 } else {
-                    LOGE("%s track encountered an error (%d)",
+                    ALOGE("%s track encountered an error (%d)",
                          audio ? "audio" : "video", finalResult);
 
                     notifyListener(
@@ -449,7 +449,7 @@
                 int32_t audio;
                 CHECK(msg->findInt32("audio", &audio));
 
-                LOGV("renderer %s flush completed.", audio ? "audio" : "video");
+                ALOGV("renderer %s flush completed.", audio ? "audio" : "video");
             }
             break;
         }
@@ -461,7 +461,7 @@
 
         case kWhatReset:
         {
-            LOGV("kWhatReset");
+            ALOGV("kWhatReset");
 
             if (mRenderer != NULL) {
                 // There's an edge case where the renderer owns all output
@@ -479,8 +479,8 @@
                 // We're currently flushing, postpone the reset until that's
                 // completed.
 
-                LOGV("postponing reset mFlushingAudio=%d, mFlushingVideo=%d",
-                        mFlushingAudio, mFlushingVideo);
+                ALOGV("postponing reset mFlushingAudio=%d, mFlushingVideo=%d",
+                      mFlushingAudio, mFlushingVideo);
 
                 mResetPostponed = true;
                 break;
@@ -510,7 +510,7 @@
             int64_t seekTimeUs;
             CHECK(msg->findInt64("seekTimeUs", &seekTimeUs));
 
-            LOGV("kWhatSeek seekTimeUs=%lld us (%.2f secs)",
+            ALOGV("kWhatSeek seekTimeUs=%lld us (%.2f secs)",
                  seekTimeUs, seekTimeUs / 1E6);
 
             mSource->seekTo(seekTimeUs);
@@ -554,7 +554,7 @@
         return;
     }
 
-    LOGV("both audio and video are flushed now.");
+    ALOGV("both audio and video are flushed now.");
 
     if (mTimeDiscontinuityPending) {
         mRenderer->signalTimeDiscontinuity();
@@ -573,7 +573,7 @@
     mFlushingVideo = NONE;
 
     if (mResetInProgress) {
-        LOGV("reset completed");
+        ALOGV("reset completed");
 
         mResetInProgress = false;
         finishReset();
@@ -689,7 +689,7 @@
 
                 bool timeChange = (type & ATSParser::DISCONTINUITY_TIME) != 0;
 
-                LOGI("%s discontinuity (formatChange=%d, time=%d)",
+                ALOGI("%s discontinuity (formatChange=%d, time=%d)",
                      audio ? "audio" : "video", formatChange, timeChange);
 
                 if (audio) {
@@ -705,7 +705,7 @@
                         int64_t resumeAtMediaTimeUs;
                         if (extra->findInt64(
                                     "resume-at-mediatimeUs", &resumeAtMediaTimeUs)) {
-                            LOGI("suppressing rendering of %s until %lld us",
+                            ALOGI("suppressing rendering of %s until %lld us",
                                     audio ? "audio" : "video", resumeAtMediaTimeUs);
 
                             if (audio) {
@@ -758,12 +758,12 @@
         }
     } while (dropAccessUnit);
 
-    // LOGV("returned a valid buffer of %s data", audio ? "audio" : "video");
+    // ALOGV("returned a valid buffer of %s data", audio ? "audio" : "video");
 
 #if 0
     int64_t mediaTimeUs;
     CHECK(accessUnit->meta()->findInt64("timeUs", &mediaTimeUs));
-    LOGV("feeding %s input buffer at media time %.2f secs",
+    ALOGV("feeding %s input buffer at media time %.2f secs",
          audio ? "audio" : "video",
          mediaTimeUs / 1E6);
 #endif
@@ -775,7 +775,7 @@
 }
 
 void NuPlayer::renderBuffer(bool audio, const sp<AMessage> &msg) {
-    // LOGV("renderBuffer %s", audio ? "audio" : "video");
+    // ALOGV("renderBuffer %s", audio ? "audio" : "video");
 
     sp<AMessage> reply;
     CHECK(msg->findMessage("reply", &reply));
@@ -786,7 +786,7 @@
         // so we don't want any output buffers it sent us (from before
         // we initiated the flush) to be stuck in the renderer's queue.
 
-        LOGV("we're still flushing the %s decoder, sending its output buffer"
+        ALOGV("we're still flushing the %s decoder, sending its output buffer"
              " right back.", audio ? "audio" : "video");
 
         reply->post();
@@ -808,7 +808,7 @@
         CHECK(buffer->meta()->findInt64("timeUs", &mediaTimeUs));
 
         if (mediaTimeUs < skipUntilMediaTimeUs) {
-            LOGV("dropping %s buffer at time %lld as requested.",
+            ALOGV("dropping %s buffer at time %lld as requested.",
                  audio ? "audio" : "video",
                  mediaTimeUs);
 
@@ -838,7 +838,7 @@
 
 void NuPlayer::flushDecoder(bool audio, bool needShutdown) {
     if ((audio && mAudioDecoder == NULL) || (!audio && mVideoDecoder == NULL)) {
-        LOGI("flushDecoder %s without decoder present",
+        ALOGI("flushDecoder %s without decoder present",
              audio ? "audio" : "video");
     }
 
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp
index 0cb7f45..15259cb 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp
+++ b/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp
@@ -228,9 +228,9 @@
 
 #if 0
     if (numFramesAvailableToWrite == mAudioSink->frameCount()) {
-        LOGI("audio sink underrun");
+        ALOGI("audio sink underrun");
     } else {
-        LOGV("audio queue has %d frames left to play",
+        ALOGV("audio queue has %d frames left to play",
              mAudioSink->frameCount() - numFramesAvailableToWrite);
     }
 #endif
@@ -255,7 +255,7 @@
             int64_t mediaTimeUs;
             CHECK(entry->mBuffer->meta()->findInt64("timeUs", &mediaTimeUs));
 
-            LOGV("rendering audio at media time %.2f secs", mediaTimeUs / 1E6);
+            ALOGV("rendering audio at media time %.2f secs", mediaTimeUs / 1E6);
 
             mAnchorTimeMediaUs = mediaTimeUs;
 
@@ -270,7 +270,7 @@
                     + numFramesPendingPlayout
                         * mAudioSink->msecsPerFrame()) * 1000ll;
 
-            // LOGI("realTimeOffsetUs = %lld us", realTimeOffsetUs);
+            // ALOGI("realTimeOffsetUs = %lld us", realTimeOffsetUs);
 
             mAnchorTimeRealUs =
                 ALooper::GetNowUs() + realTimeOffsetUs;
@@ -376,9 +376,9 @@
     bool tooLate = (mVideoLateByUs > 40000);
 
     if (tooLate) {
-        LOGV("video late by %lld us (%.2f secs)", lateByUs, lateByUs / 1E6);
+        ALOGV("video late by %lld us (%.2f secs)", mVideoLateByUs, mVideoLateByUs / 1E6);
     } else {
-        LOGV("rendering video at media time %.2f secs", mediaTimeUs / 1E6);
+        ALOGV("rendering video at media time %.2f secs", mediaTimeUs / 1E6);
     }
 
     entry->mNotifyConsumed->setInt32("render", !tooLate);
@@ -454,7 +454,7 @@
 
     int64_t diff = firstVideoTimeUs - firstAudioTimeUs;
 
-    LOGV("queueDiff = %.2f secs", diff / 1E6);
+    ALOGV("queueDiff = %.2f secs", diff / 1E6);
 
     if (diff > 100000ll) {
         // Audio data starts More than 0.1 secs before video.
@@ -628,8 +628,8 @@
         mAudioSink->pause();
     }
 
-    LOGV("now paused audio queue has %d entries, video has %d entries",
-         mAudioQueue.size(), mVideoQueue.size());
+    ALOGV("now paused audio queue has %d entries, video has %d entries",
+          mAudioQueue.size(), mVideoQueue.size());
 
     mPaused = true;
 }
diff --git a/media/libmediaplayerservice/nuplayer/RTSPSource.cpp b/media/libmediaplayerservice/nuplayer/RTSPSource.cpp
index a3f2bf6..6eb0d07 100644
--- a/media/libmediaplayerservice/nuplayer/RTSPSource.cpp
+++ b/media/libmediaplayerservice/nuplayer/RTSPSource.cpp
@@ -226,7 +226,7 @@
             int32_t damaged;
             if (accessUnit->meta()->findInt32("damaged", &damaged)
                     && damaged) {
-                LOGI("dropping damaged access unit.");
+                ALOGI("dropping damaged access unit.");
                 break;
             }
 
@@ -242,7 +242,7 @@
                     // playtime mapping. Assume the first packets correspond
                     // to time 0.
 
-                    LOGV("This is a live stream, assuming time = 0");
+                    ALOGV("This is a live stream, assuming time = 0");
 
                     info->mRTPTime = rtpTime;
                     info->mNormalPlaytimeUs = 0ll;
diff --git a/media/libmediaplayerservice/nuplayer/StreamingSource.cpp b/media/libmediaplayerservice/nuplayer/StreamingSource.cpp
index 2e63b3b..7c9bc5e 100644
--- a/media/libmediaplayerservice/nuplayer/StreamingSource.cpp
+++ b/media/libmediaplayerservice/nuplayer/StreamingSource.cpp
@@ -58,7 +58,7 @@
         ssize_t n = mStreamListener->read(buffer, sizeof(buffer), &extra);
 
         if (n == 0) {
-            LOGI("input data EOS reached.");
+            ALOGI("input data EOS reached.");
             mTSParser->signalEOS(ERROR_END_OF_STREAM);
             mFinalResult = ERROR_END_OF_STREAM;
             break;
@@ -70,7 +70,7 @@
                     && extra->findInt32(
                         IStreamListener::kKeyDiscontinuityMask, &mask)) {
                 if (mask == 0) {
-                    LOGE("Client specified an illegal discontinuity type.");
+                    ALOGE("Client specified an illegal discontinuity type.");
                     return ERROR_UNSUPPORTED;
                 }
 
@@ -94,7 +94,7 @@
                 status_t err = mTSParser->feedTSPacket(buffer, sizeof(buffer));
 
                 if (err != OK) {
-                    LOGE("TS Parser returned error %d", err);
+                    ALOGE("TS Parser returned error %d", err);
 
                     mTSParser->signalEOS(err);
                     mFinalResult = err;
diff --git a/media/libstagefright/AACExtractor.cpp b/media/libstagefright/AACExtractor.cpp
index 52b1200..33f22f2 100644
--- a/media/libstagefright/AACExtractor.cpp
+++ b/media/libstagefright/AACExtractor.cpp
@@ -22,6 +22,7 @@
 #include "include/avc_utils.h"
 
 #include <media/stagefright/foundation/ABuffer.h>
+#include <media/stagefright/foundation/AMessage.h>
 #include <media/stagefright/DataSource.h>
 #include <media/stagefright/MediaBufferGroup.h>
 #include <media/stagefright/MediaDebug.h>
@@ -131,18 +132,28 @@
     return frameSize;
 }
 
-AACExtractor::AACExtractor(const sp<DataSource> &source)
+AACExtractor::AACExtractor(
+        const sp<DataSource> &source, const sp<AMessage> &_meta)
     : mDataSource(source),
       mInitCheck(NO_INIT),
       mFrameDurationUs(0) {
-    String8 mimeType;
-    float confidence;
-    if (!SniffAAC(mDataSource, &mimeType, &confidence, NULL)) {
-        return;
+    sp<AMessage> meta = _meta;
+
+    if (meta == NULL) {
+        String8 mimeType;
+        float confidence;
+        sp<AMessage> _meta;
+
+        if (!SniffAAC(mDataSource, &mimeType, &confidence, &meta)) {
+            return;
+        }
     }
 
+    int64_t offset;
+    CHECK(meta->findInt64("offset", &offset));
+
     uint8_t profile, sf_index, channel, header[2];
-    if (mDataSource->readAt(2, &header, 2) < 2) {
+    if (mDataSource->readAt(offset + 2, &header, 2) < 2) {
         return;
     }
 
@@ -156,7 +167,6 @@
 
     mMeta = MakeAACCodecSpecificData(profile, sf_index, channel);
 
-    off64_t offset = 0;
     off64_t streamSize, numFrames = 0;
     size_t frameSize = 0;
     int64_t duration = 0;
@@ -245,7 +255,12 @@
 status_t AACSource::start(MetaData *params) {
     CHECK(!mStarted);
 
-    mOffset = 0;
+    if (mOffsetVector.empty()) {
+        mOffset = 0;
+    } else {
+        mOffset = mOffsetVector.itemAt(0);
+    }
+
     mCurrentTimeUs = 0;
     mGroup = new MediaBufferGroup;
     mGroup->add_buffer(new MediaBuffer(kMaxFrameSize));
@@ -318,10 +333,39 @@
 
 bool SniffAAC(
         const sp<DataSource> &source, String8 *mimeType, float *confidence,
-        sp<AMessage> *) {
+        sp<AMessage> *meta) {
+    off64_t pos = 0;
+
+    for (;;) {
+        uint8_t id3header[10];
+        if (source->readAt(pos, id3header, sizeof(id3header))
+                < (ssize_t)sizeof(id3header)) {
+            return false;
+        }
+
+        if (memcmp("ID3", id3header, 3)) {
+            break;
+        }
+
+        // Skip the ID3v2 header.
+
+        size_t len =
+            ((id3header[6] & 0x7f) << 21)
+            | ((id3header[7] & 0x7f) << 14)
+            | ((id3header[8] & 0x7f) << 7)
+            | (id3header[9] & 0x7f);
+
+        len += 10;
+
+        pos += len;
+
+        ALOGV("skipped ID3 tag, new starting offset is %lld (0x%016llx)",
+             pos, pos);
+    }
+
     uint8_t header[2];
 
-    if (source->readAt(0, &header, 2) != 2) {
+    if (source->readAt(pos, &header, 2) != 2) {
         return false;
     }
 
@@ -329,6 +373,10 @@
     if ((header[0] == 0xff) && ((header[1] & 0xf6) == 0xf0)) {
         *mimeType = MEDIA_MIMETYPE_AUDIO_AAC_ADTS;
         *confidence = 0.2;
+
+        *meta = new AMessage;
+        (*meta)->setInt64("offset", pos);
+
         return true;
     }
 
diff --git a/media/libstagefright/AACWriter.cpp b/media/libstagefright/AACWriter.cpp
index d133e91..1673ccd 100644
--- a/media/libstagefright/AACWriter.cpp
+++ b/media/libstagefright/AACWriter.cpp
@@ -40,7 +40,7 @@
       mChannelCount(-1),
       mSampleRate(-1) {
 
-    LOGV("AACWriter Constructor");
+    ALOGV("AACWriter Constructor");
 
     mFd = open(filename, O_CREAT | O_LARGEFILE | O_TRUNC | O_RDWR);
     if (mFd >= 0) {
@@ -84,7 +84,7 @@
     }
 
     if (mSource != NULL) {
-        LOGE("AAC files only support a single track of audio.");
+        ALOGE("AAC files only support a single track of audio.");
         return UNKNOWN_ERROR;
     }
 
@@ -209,14 +209,14 @@
     *tableIndex = 0;
     for (int index = 0; index < tableSize; ++index) {
         if (sampleRate == kSampleRateTable[index]) {
-            LOGV("Sample rate: %d and index: %d",
+            ALOGV("Sample rate: %d and index: %d",
                 sampleRate, index);
             *tableIndex = index;
             return true;
         }
     }
 
-    LOGE("Sampling rate %d bps is not supported", sampleRate);
+    ALOGE("Sampling rate %d bps is not supported", sampleRate);
     return false;
 }
 
@@ -322,7 +322,7 @@
 
         int32_t isCodecSpecific = 0;
         if (buffer->meta_data()->findInt32(kKeyIsCodecConfig, &isCodecSpecific) && isCodecSpecific) {
-            LOGV("Drop codec specific info buffer");
+            ALOGV("Drop codec specific info buffer");
             buffer->release();
             buffer = NULL;
             continue;
@@ -338,7 +338,7 @@
             mResumed = false;
         }
         timestampUs -= previousPausedDurationUs;
-        LOGV("time stamp: %lld, previous paused duration: %lld",
+        ALOGV("time stamp: %lld, previous paused duration: %lld",
             timestampUs, previousPausedDurationUs);
         if (timestampUs > maxTimestampUs) {
             maxTimestampUs = timestampUs;
diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp
index dbc9b7e..ca44ea3 100644
--- a/media/libstagefright/ACodec.cpp
+++ b/media/libstagefright/ACodec.cpp
@@ -342,7 +342,7 @@
 }
 
 void ACodec::signalFlush() {
-    LOGV("[%s] signalFlush", mComponentName.c_str());
+    ALOGV("[%s] signalFlush", mComponentName.c_str());
     (new AMessage(kWhatFlush, id()))->post();
 }
 
@@ -375,7 +375,7 @@
         return err;
     }
 
-    LOGV("[%s] Allocating %lu buffers of size %lu on %s port",
+    ALOGV("[%s] Allocating %lu buffers of size %lu on %s port",
             mComponentName.c_str(),
             def.nBufferCountActual, def.nBufferSize,
             portIndex == kPortIndexInput ? "input" : "output");
@@ -394,7 +394,7 @@
             if (portIndex == kPortIndexInput && i == 0) {
                 // Only log this warning once per allocation round.
 
-                LOGW("OMX.TI.DUCATI1.VIDEO.DECODER requires the use of "
+                ALOGW("OMX.TI.DUCATI1.VIDEO.DECODER requires the use of "
                      "OMX_AllocateBuffer instead of the preferred "
                      "OMX_UseBuffer. Vendor must fix this.");
             }
@@ -445,7 +445,7 @@
             def.format.video.eColorFormat);
 
     if (err != 0) {
-        LOGE("native_window_set_buffers_geometry failed: %s (%d)",
+        ALOGE("native_window_set_buffers_geometry failed: %s (%d)",
                 strerror(-err), -err);
         return err;
     }
@@ -454,7 +454,7 @@
     OMX_U32 usage = 0;
     err = mOMX->getGraphicBufferUsage(mNode, kPortIndexOutput, &usage);
     if (err != 0) {
-        LOGW("querying usage flags from OMX IL component failed: %d", err);
+        ALOGW("querying usage flags from OMX IL component failed: %d", err);
         // XXX: Currently this error is logged, but not fatal.
         usage = 0;
     }
@@ -464,7 +464,7 @@
             usage | GRALLOC_USAGE_HW_TEXTURE | GRALLOC_USAGE_EXTERNAL_DISP);
 
     if (err != 0) {
-        LOGE("native_window_set_usage failed: %s (%d)", strerror(-err), -err);
+        ALOGE("native_window_set_usage failed: %s (%d)", strerror(-err), -err);
         return err;
     }
 
@@ -474,7 +474,7 @@
             &minUndequeuedBufs);
 
     if (err != 0) {
-        LOGE("NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS query failed: %s (%d)",
+        ALOGE("NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS query failed: %s (%d)",
                 strerror(-err), -err);
         return err;
     }
@@ -489,7 +489,7 @@
                 mNode, OMX_IndexParamPortDefinition, &def, sizeof(def));
 
         if (err != OK) {
-            LOGE("[%s] setting nBufferCountActual to %lu failed: %d",
+            ALOGE("[%s] setting nBufferCountActual to %lu failed: %d",
                     mComponentName.c_str(), newBufferCount, err);
             return err;
         }
@@ -499,12 +499,12 @@
             mNativeWindow.get(), def.nBufferCountActual);
 
     if (err != 0) {
-        LOGE("native_window_set_buffer_count failed: %s (%d)", strerror(-err),
+        ALOGE("native_window_set_buffer_count failed: %s (%d)", strerror(-err),
                 -err);
         return err;
     }
 
-    LOGV("[%s] Allocating %lu buffers from a native window of size %lu on "
+    ALOGV("[%s] Allocating %lu buffers from a native window of size %lu on "
          "output port",
          mComponentName.c_str(), def.nBufferCountActual, def.nBufferSize);
 
@@ -513,7 +513,7 @@
         ANativeWindowBuffer *buf;
         err = mNativeWindow->dequeueBuffer(mNativeWindow.get(), &buf);
         if (err != 0) {
-            LOGE("dequeueBuffer failed: %s (%d)", strerror(-err), -err);
+            ALOGE("dequeueBuffer failed: %s (%d)", strerror(-err), -err);
             break;
         }
 
@@ -528,14 +528,14 @@
         err = mOMX->useGraphicBuffer(mNode, kPortIndexOutput, graphicBuffer,
                 &bufferId);
         if (err != 0) {
-            LOGE("registering GraphicBuffer %lu with OMX IL component failed: "
+            ALOGE("registering GraphicBuffer %lu with OMX IL component failed: "
                  "%d", i, err);
             break;
         }
 
         mBuffers[kPortIndexOutput].editItemAt(i).mBufferID = bufferId;
 
-        LOGV("[%s] Registered graphic buffer with ID %p (pointer = %p)",
+        ALOGV("[%s] Registered graphic buffer with ID %p (pointer = %p)",
              mComponentName.c_str(),
              bufferId, graphicBuffer.get());
     }
@@ -565,7 +565,7 @@
 status_t ACodec::cancelBufferToNativeWindow(BufferInfo *info) {
     CHECK_EQ((int)info->mStatus, (int)BufferInfo::OWNED_BY_US);
 
-    LOGV("[%s] Calling cancelBuffer on buffer %p",
+    ALOGV("[%s] Calling cancelBuffer on buffer %p",
          mComponentName.c_str(), info->mBufferID);
 
     int err = mNativeWindow->cancelBuffer(
@@ -581,7 +581,7 @@
 ACodec::BufferInfo *ACodec::dequeueBufferFromNativeWindow() {
     ANativeWindowBuffer *buf;
     if (mNativeWindow->dequeueBuffer(mNativeWindow.get(), &buf) != 0) {
-        LOGE("dequeueBuffer failed.");
+        ALOGE("dequeueBuffer failed.");
         return NULL;
     }
 
@@ -734,7 +734,7 @@
                 &roleParams, sizeof(roleParams));
 
         if (err != OK) {
-            LOGW("[%s] Failed to set standard component role '%s'.",
+            ALOGW("[%s] Failed to set standard component role '%s'.",
                  mComponentName.c_str(), role);
         }
     }
@@ -1114,7 +1114,7 @@
 
         if (info->mStatus != BufferInfo::OWNED_BY_US
                 && info->mStatus != BufferInfo::OWNED_BY_NATIVE_WINDOW) {
-            LOGV("[%s] Buffer %p on port %ld still has status %d",
+            ALOGV("[%s] Buffer %p on port %ld still has status %d",
                     mComponentName.c_str(),
                     info->mBufferID, portIndex, info->mStatus);
             return false;
@@ -1361,13 +1361,13 @@
 bool ACodec::BaseState::onOMXEvent(
         OMX_EVENTTYPE event, OMX_U32 data1, OMX_U32 data2) {
     if (event != OMX_EventError) {
-        LOGV("[%s] EVENT(%d, 0x%08lx, 0x%08lx)",
+        ALOGV("[%s] EVENT(%d, 0x%08lx, 0x%08lx)",
              mCodec->mComponentName.c_str(), event, data1, data2);
 
         return false;
     }
 
-    LOGE("[%s] ERROR(0x%08lx)", mCodec->mComponentName.c_str(), data1);
+    ALOGE("[%s] ERROR(0x%08lx)", mCodec->mComponentName.c_str(), data1);
 
     mCodec->signalError((OMX_ERRORTYPE)data1);
 
@@ -1375,7 +1375,7 @@
 }
 
 bool ACodec::BaseState::onOMXEmptyBufferDone(IOMX::buffer_id bufferID) {
-    LOGV("[%s] onOMXEmptyBufferDone %p",
+    ALOGV("[%s] onOMXEmptyBufferDone %p",
          mCodec->mComponentName.c_str(), bufferID);
 
     BufferInfo *info =
@@ -1438,7 +1438,7 @@
     if (!msg->findObject("buffer", &obj)) {
         CHECK(msg->findInt32("err", &err));
 
-        LOGV("[%s] saw error %d instead of an input buffer",
+        ALOGV("[%s] saw error %d instead of an input buffer",
              mCodec->mComponentName.c_str(), err);
 
         obj.clear();
@@ -1482,7 +1482,7 @@
 
                 if (buffer != info->mData) {
                     if (0 && !(flags & OMX_BUFFERFLAG_CODECCONFIG)) {
-                        LOGV("[%s] Needs to copy input data.",
+                        ALOGV("[%s] Needs to copy input data.",
                              mCodec->mComponentName.c_str());
                     }
 
@@ -1491,10 +1491,10 @@
                 }
 
                 if (flags & OMX_BUFFERFLAG_CODECCONFIG) {
-                    LOGV("[%s] calling emptyBuffer %p w/ codec specific data",
+                    ALOGV("[%s] calling emptyBuffer %p w/ codec specific data",
                          mCodec->mComponentName.c_str(), bufferID);
                 } else {
-                    LOGV("[%s] calling emptyBuffer %p w/ time %lld us",
+                    ALOGV("[%s] calling emptyBuffer %p w/ time %lld us",
                          mCodec->mComponentName.c_str(), bufferID, timeUs);
                 }
 
@@ -1512,15 +1512,15 @@
                 getMoreInputDataIfPossible();
             } else if (!mCodec->mPortEOS[kPortIndexInput]) {
                 if (err != ERROR_END_OF_STREAM) {
-                    LOGV("[%s] Signalling EOS on the input port "
+                    ALOGV("[%s] Signalling EOS on the input port "
                          "due to error %d",
                          mCodec->mComponentName.c_str(), err);
                 } else {
-                    LOGV("[%s] Signalling EOS on the input port",
+                    ALOGV("[%s] Signalling EOS on the input port",
                          mCodec->mComponentName.c_str());
                 }
 
-                LOGV("[%s] calling emptyBuffer %p signalling EOS",
+                ALOGV("[%s] calling emptyBuffer %p signalling EOS",
                      mCodec->mComponentName.c_str(), bufferID);
 
                 CHECK_EQ(mCodec->mOMX->emptyBuffer(
@@ -1582,7 +1582,7 @@
         int64_t timeUs,
         void *platformPrivate,
         void *dataPtr) {
-    LOGV("[%s] onOMXFillBufferDone %p time %lld us",
+    ALOGV("[%s] onOMXFillBufferDone %p time %lld us",
          mCodec->mComponentName.c_str(), bufferID, timeUs);
 
     ssize_t index;
@@ -1603,7 +1603,7 @@
         {
             if (rangeLength == 0) {
                 if (!(flags & OMX_BUFFERFLAG_EOS)) {
-                    LOGV("[%s] calling fillBuffer %p",
+                    ALOGV("[%s] calling fillBuffer %p",
                          mCodec->mComponentName.c_str(), info->mBufferID);
 
                     CHECK_EQ(mCodec->mOMX->fillBuffer(
@@ -1717,7 +1717,7 @@
                 }
 
                 if (info != NULL) {
-                    LOGV("[%s] calling fillBuffer %p",
+                    ALOGV("[%s] calling fillBuffer %p",
                          mCodec->mComponentName.c_str(), info->mBufferID);
 
                     CHECK_EQ(mCodec->mOMX->fillBuffer(mCodec->mNode, info->mBufferID),
@@ -1826,7 +1826,7 @@
     }
 
     if (node == NULL) {
-        LOGE("Unable to instantiate a decoder for type '%s'.", mime.c_str());
+        ALOGE("Unable to instantiate a decoder for type '%s'.", mime.c_str());
 
         mCodec->signalError(OMX_ErrorComponentNotFound);
         return;
@@ -1870,11 +1870,11 @@
 }
 
 void ACodec::LoadedToIdleState::stateEntered() {
-    LOGV("[%s] Now Loaded->Idle", mCodec->mComponentName.c_str());
+    ALOGV("[%s] Now Loaded->Idle", mCodec->mComponentName.c_str());
 
     status_t err;
     if ((err = allocateBuffers()) != OK) {
-        LOGE("Failed to allocate buffers after transitioning to IDLE state "
+        ALOGE("Failed to allocate buffers after transitioning to IDLE state "
              "(error 0x%08x)",
              err);
 
@@ -1934,7 +1934,7 @@
 }
 
 void ACodec::IdleToExecutingState::stateEntered() {
-    LOGV("[%s] Now Idle->Executing", mCodec->mComponentName.c_str());
+    ALOGV("[%s] Now Idle->Executing", mCodec->mComponentName.c_str());
 }
 
 bool ACodec::IdleToExecutingState::onMessageReceived(const sp<AMessage> &msg) {
@@ -2001,7 +2001,7 @@
             CHECK_EQ((int)info->mStatus, (int)BufferInfo::OWNED_BY_US);
         }
 
-        LOGV("[%s] calling fillBuffer %p",
+        ALOGV("[%s] calling fillBuffer %p",
              mCodec->mComponentName.c_str(), info->mBufferID);
 
         CHECK_EQ(mCodec->mOMX->fillBuffer(mCodec->mNode, info->mBufferID),
@@ -2013,7 +2013,7 @@
 
 void ACodec::ExecutingState::resume() {
     if (mActive) {
-        LOGV("[%s] We're already active, no need to resume.",
+        ALOGV("[%s] We're already active, no need to resume.",
              mCodec->mComponentName.c_str());
 
         return;
@@ -2031,7 +2031,7 @@
 }
 
 void ACodec::ExecutingState::stateEntered() {
-    LOGV("[%s] Now Executing", mCodec->mComponentName.c_str());
+    ALOGV("[%s] Now Executing", mCodec->mComponentName.c_str());
 
     mCodec->processDeferredMessages();
 }
@@ -2056,7 +2056,7 @@
 
         case kWhatFlush:
         {
-            LOGV("[%s] ExecutingState flushing now "
+            ALOGV("[%s] ExecutingState flushing now "
                  "(codec owns %d/%d input, %d/%d output).",
                     mCodec->mComponentName.c_str(),
                     mCodec->countBuffersOwnedByComponent(kPortIndexInput),
@@ -2111,7 +2111,7 @@
             } else if (data2 == OMX_IndexConfigCommonOutputCrop) {
                 mCodec->mSentFormat = false;
             } else {
-                LOGV("[%s] OMX_EventPortSettingsChanged 0x%08lx",
+                ALOGV("[%s] OMX_EventPortSettingsChanged 0x%08lx",
                      mCodec->mComponentName.c_str(), data2);
             }
 
@@ -2156,7 +2156,7 @@
         case kWhatResume:
         {
             if (msg->what() == kWhatResume) {
-                LOGV("[%s] Deferring resume", mCodec->mComponentName.c_str());
+                ALOGV("[%s] Deferring resume", mCodec->mComponentName.c_str());
             }
 
             mCodec->deferMessage(msg);
@@ -2173,7 +2173,7 @@
 }
 
 void ACodec::OutputPortSettingsChangedState::stateEntered() {
-    LOGV("[%s] Now handling output port settings change",
+    ALOGV("[%s] Now handling output port settings change",
          mCodec->mComponentName.c_str());
 }
 
@@ -2185,7 +2185,7 @@
             if (data1 == (OMX_U32)OMX_CommandPortDisable) {
                 CHECK_EQ(data2, (OMX_U32)kPortIndexOutput);
 
-                LOGV("[%s] Output port now disabled.",
+                ALOGV("[%s] Output port now disabled.",
                         mCodec->mComponentName.c_str());
 
                 CHECK(mCodec->mBuffers[kPortIndexOutput].isEmpty());
@@ -2198,7 +2198,7 @@
                 status_t err;
                 if ((err = mCodec->allocateBuffersOnPort(
                                 kPortIndexOutput)) != OK) {
-                    LOGE("Failed to allocate output port buffers after "
+                    ALOGE("Failed to allocate output port buffers after "
                          "port reconfiguration (error 0x%08x)",
                          err);
 
@@ -2217,7 +2217,7 @@
 
                 mCodec->mSentFormat = false;
 
-                LOGV("[%s] Output port now reenabled.",
+                ALOGV("[%s] Output port now reenabled.",
                         mCodec->mComponentName.c_str());
 
                 if (mCodec->mExecutingState->active()) {
@@ -2272,7 +2272,7 @@
 }
 
 void ACodec::ExecutingToIdleState::stateEntered() {
-    LOGV("[%s] Now Executing->Idle", mCodec->mComponentName.c_str());
+    ALOGV("[%s] Now Executing->Idle", mCodec->mComponentName.c_str());
 
     mCodec->mSentFormat = false;
 }
@@ -2364,7 +2364,7 @@
 }
 
 void ACodec::IdleToLoadedState::stateEntered() {
-    LOGV("[%s] Now Idle->Loaded", mCodec->mComponentName.c_str());
+    ALOGV("[%s] Now Idle->Loaded", mCodec->mComponentName.c_str());
 }
 
 bool ACodec::IdleToLoadedState::onOMXEvent(
@@ -2375,7 +2375,7 @@
             CHECK_EQ(data1, (OMX_U32)OMX_CommandStateSet);
             CHECK_EQ(data2, (OMX_U32)OMX_StateLoaded);
 
-            LOGV("[%s] Now Loaded", mCodec->mComponentName.c_str());
+            ALOGV("[%s] Now Loaded", mCodec->mComponentName.c_str());
 
             CHECK_EQ(mCodec->mOMX->freeNode(mCodec->mNode), (status_t)OK);
 
@@ -2405,7 +2405,7 @@
 }
 
 void ACodec::FlushingState::stateEntered() {
-    LOGV("[%s] Now Flushing", mCodec->mComponentName.c_str());
+    ALOGV("[%s] Now Flushing", mCodec->mComponentName.c_str());
 
     mFlushComplete[kPortIndexInput] = mFlushComplete[kPortIndexOutput] = false;
 }
@@ -2437,7 +2437,7 @@
 
 bool ACodec::FlushingState::onOMXEvent(
         OMX_EVENTTYPE event, OMX_U32 data1, OMX_U32 data2) {
-    LOGV("[%s] FlushingState onOMXEvent(%d,%ld)",
+    ALOGV("[%s] FlushingState onOMXEvent(%d,%ld)",
             mCodec->mComponentName.c_str(), event, data1);
 
     switch (event) {
@@ -2473,7 +2473,7 @@
             msg->setInt32("data1", data1);
             msg->setInt32("data2", data2);
 
-            LOGV("[%s] Deferring OMX_EventPortSettingsChanged",
+            ALOGV("[%s] Deferring OMX_EventPortSettingsChanged",
                  mCodec->mComponentName.c_str());
 
             mCodec->deferMessage(msg);
diff --git a/media/libstagefright/AMRExtractor.cpp b/media/libstagefright/AMRExtractor.cpp
index 7eca5e4..5a28347 100644
--- a/media/libstagefright/AMRExtractor.cpp
+++ b/media/libstagefright/AMRExtractor.cpp
@@ -85,7 +85,7 @@
     };
 
     if (FT > 15 || (isWide && FT > 9 && FT < 14) || (!isWide && FT > 11 && FT < 15)) {
-        LOGE("illegal AMR frame type %d", FT);
+        ALOGE("illegal AMR frame type %d", FT);
         return 0;
     }
 
@@ -285,7 +285,7 @@
     if (header & 0x83) {
         // Padding bits must be 0.
 
-        LOGE("padding bits must be 0, header is 0x%02x", header);
+        ALOGE("padding bits must be 0, header is 0x%02x", header);
 
         return ERROR_MALFORMED;
     }
diff --git a/media/libstagefright/AMRWriter.cpp b/media/libstagefright/AMRWriter.cpp
index 6436071..6c4e307 100644
--- a/media/libstagefright/AMRWriter.cpp
+++ b/media/libstagefright/AMRWriter.cpp
@@ -235,7 +235,7 @@
             mResumed = false;
         }
         timestampUs -= previousPausedDurationUs;
-        LOGV("time stamp: %lld, previous paused duration: %lld",
+        ALOGV("time stamp: %lld, previous paused duration: %lld",
                 timestampUs, previousPausedDurationUs);
         if (timestampUs > maxTimestampUs) {
             maxTimestampUs = timestampUs;
diff --git a/media/libstagefright/AVIExtractor.cpp b/media/libstagefright/AVIExtractor.cpp
index 815f987..a3187b7 100644
--- a/media/libstagefright/AVIExtractor.cpp
+++ b/media/libstagefright/AVIExtractor.cpp
@@ -457,7 +457,7 @@
 
         uint32_t subFourcc = U32_AT(&tmp[8]);
 
-        LOGV("%s offset 0x%08llx LIST of '%c%c%c%c', size %d",
+        ALOGV("%s offset 0x%08llx LIST of '%c%c%c%c', size %d",
              prefix,
              offset,
              (char)(subFourcc >> 24),
@@ -486,7 +486,7 @@
             }
         }
     } else {
-        LOGV("%s offset 0x%08llx CHUNK '%c%c%c%c'",
+        ALOGV("%s offset 0x%08llx CHUNK '%c%c%c%c'",
              prefix,
              offset,
              (char)(fourcc >> 24),
@@ -625,7 +625,7 @@
         }
 
         if (mime == NULL) {
-            LOGW("Unsupported video format '%c%c%c%c'",
+            ALOGW("Unsupported video format '%c%c%c%c'",
                  (char)(handler >> 24),
                  (char)((handler >> 16) & 0xff),
                  (char)((handler >> 8) & 0xff),
@@ -705,7 +705,7 @@
         if (format == 0x55) {
             track->mMeta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_AUDIO_MPEG);
         } else {
-            LOGW("Unsupported audio format = 0x%04x", format);
+            ALOGW("Unsupported audio format = 0x%04x", format);
         }
 
         uint32_t numChannels = U16LE_AT(&data[2]);
@@ -856,7 +856,7 @@
             }
         }
 
-        LOGV("Chunk offsets are %s",
+        ALOGV("Chunk offsets are %s",
              mOffsetsAreAbsolute ? "absolute" : "movie-chunk relative");
     }
 
@@ -908,7 +908,7 @@
         CHECK_EQ((status_t)OK,
                  getSampleTime(i, track->mSamples.size() - 1, &durationUs));
 
-        LOGV("track %d duration = %.2f secs", i, durationUs / 1E6);
+        ALOGV("track %d duration = %.2f secs", i, durationUs / 1E6);
 
         track->mMeta->setInt64(kKeyDuration, durationUs);
         track->mMeta->setInt32(kKeyMaxInputSize, track->mMaxSampleSize);
@@ -1080,7 +1080,7 @@
     sp<MetaData> meta = MakeAVCCodecSpecificData(buffer);
 
     if (meta == NULL) {
-        LOGE("Unable to extract AVC codec specific data");
+        ALOGE("Unable to extract AVC codec specific data");
         return ERROR_MALFORMED;
     }
 
diff --git a/media/libstagefright/Android.mk b/media/libstagefright/Android.mk
index 690deac..0aeb515 100644
--- a/media/libstagefright/Android.mk
+++ b/media/libstagefright/Android.mk
@@ -9,6 +9,7 @@
         AACWriter.cpp                     \
         AMRExtractor.cpp                  \
         AMRWriter.cpp                     \
+        AVIExtractor.cpp                  \
         AudioPlayer.cpp                   \
         AudioSource.cpp                   \
         AwesomePlayer.cpp                 \
diff --git a/media/libstagefright/AudioPlayer.cpp b/media/libstagefright/AudioPlayer.cpp
index 2581a62..9a9c3ef 100644
--- a/media/libstagefright/AudioPlayer.cpp
+++ b/media/libstagefright/AudioPlayer.cpp
@@ -92,7 +92,7 @@
 
     mFirstBufferResult = mSource->read(&mFirstBuffer, &options);
     if (mFirstBufferResult == INFO_FORMAT_CHANGED) {
-        LOGV("INFO_FORMAT_CHANGED!!!");
+        ALOGV("INFO_FORMAT_CHANGED!!!");
 
         CHECK(mFirstBuffer == NULL);
         mFirstBufferResult = OK;
@@ -223,7 +223,7 @@
     }
 
     if (mInputBuffer != NULL) {
-        LOGV("AudioPlayer releasing input buffer.");
+        ALOGV("AudioPlayer releasing input buffer.");
 
         mInputBuffer->release();
         mInputBuffer = NULL;
@@ -310,7 +310,7 @@
 
 size_t AudioPlayer::fillBuffer(void *data, size_t size) {
     if (mNumFramesPlayed == 0) {
-        LOGV("AudioCallback");
+        ALOGV("AudioCallback");
     }
 
     if (mReachedEOS) {
@@ -390,12 +390,12 @@
                     int64_t timeToCompletionUs =
                         (1000000ll * numFramesPendingPlayout) / mSampleRate;
 
-                    LOGV("total number of frames played: %lld (%lld us)",
+                    ALOGV("total number of frames played: %lld (%lld us)",
                             (mNumFramesPlayed + numAdditionalFrames),
                             1000000ll * (mNumFramesPlayed + numAdditionalFrames)
                                 / mSampleRate);
 
-                    LOGV("%d frames left to play, %lld us (%.2f secs)",
+                    ALOGV("%d frames left to play, %lld us (%.2f secs)",
                          numFramesPendingPlayout,
                          timeToCompletionUs, timeToCompletionUs / 1E6);
 
@@ -415,7 +415,7 @@
                 ((mNumFramesPlayed + size_done / mFrameSize) * 1000000)
                     / mSampleRate;
 
-            LOGV("buffer->size() = %d, "
+            ALOGV("buffer->size() = %d, "
                  "mPositionTimeMediaUs=%.2f mPositionTimeRealUs=%.2f",
                  mInputBuffer->range_length(),
                  mPositionTimeMediaUs / 1E6, mPositionTimeRealUs / 1E6);
diff --git a/media/libstagefright/AudioSource.cpp b/media/libstagefright/AudioSource.cpp
index 99c3682..2172cc0 100644
--- a/media/libstagefright/AudioSource.cpp
+++ b/media/libstagefright/AudioSource.cpp
@@ -37,7 +37,7 @@
             break;
         }
         case AudioRecord::EVENT_OVERRUN: {
-            LOGW("AudioRecord reported overrun!");
+            ALOGW("AudioRecord reported overrun!");
             break;
         }
         default:
@@ -54,7 +54,7 @@
       mNumFramesReceived(0),
       mNumClientOwnedBuffers(0) {
 
-    LOGV("sampleRate: %d, channels: %d", sampleRate, channels);
+    ALOGV("sampleRate: %d, channels: %d", sampleRate, channels);
     CHECK(channels == 1 || channels == 2);
     uint32_t flags = AudioRecord::RECORD_AGC_ENABLE |
                      AudioRecord::RECORD_NS_ENABLE  |
@@ -114,7 +114,7 @@
 }
 
 void AudioSource::releaseQueuedFrames_l() {
-    LOGV("releaseQueuedFrames_l");
+    ALOGV("releaseQueuedFrames_l");
     List<MediaBuffer *>::iterator it;
     while (!mBuffersReceived.empty()) {
         it = mBuffersReceived.begin();
@@ -124,7 +124,7 @@
 }
 
 void AudioSource::waitOutstandingEncodingFrames_l() {
-    LOGV("waitOutstandingEncodingFrames_l: %lld", mNumClientOwnedBuffers);
+    ALOGV("waitOutstandingEncodingFrames_l: %lld", mNumClientOwnedBuffers);
     while (mNumClientOwnedBuffers > 0) {
         mFrameEncodingCompletionCondition.wait(mLock);
     }
@@ -245,7 +245,7 @@
 }
 
 void AudioSource::signalBufferReturned(MediaBuffer *buffer) {
-    LOGV("signalBufferReturned: %p", buffer->data());
+    ALOGV("signalBufferReturned: %p", buffer->data());
     Mutex::Autolock autoLock(mLock);
     --mNumClientOwnedBuffers;
     buffer->setObserver(0);
@@ -256,17 +256,17 @@
 
 status_t AudioSource::dataCallbackTimestamp(
         const AudioRecord::Buffer& audioBuffer, int64_t timeUs) {
-    LOGV("dataCallbackTimestamp: %lld us", timeUs);
+    ALOGV("dataCallbackTimestamp: %lld us", timeUs);
     Mutex::Autolock autoLock(mLock);
     if (!mStarted) {
-        LOGW("Spurious callback from AudioRecord. Drop the audio data.");
+        ALOGW("Spurious callback from AudioRecord. Drop the audio data.");
         return OK;
     }
 
     // Drop retrieved and previously lost audio data.
     if (mNumFramesReceived == 0 && timeUs < mStartTimeUs) {
         mRecord->getInputFramesLost();
-        LOGV("Drop audio data at %lld/%lld us", timeUs, mStartTimeUs);
+        ALOGV("Drop audio data at %lld/%lld us", timeUs, mStartTimeUs);
         return OK;
     }
 
@@ -301,7 +301,7 @@
                     audioBuffer.i16, audioBuffer.size);
     } else {
         if (audioBuffer.size == 0) {
-            LOGW("Nothing is available from AudioRecord callback buffer");
+            ALOGW("Nothing is available from AudioRecord callback buffer");
             buffer->release();
             return OK;
         }
@@ -345,7 +345,7 @@
     }
     int16_t value = mMaxAmplitude;
     mMaxAmplitude = 0;
-    LOGV("max amplitude since last call: %d", value);
+    ALOGV("max amplitude since last call: %d", value);
     return value;
 }
 
diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp
index bc45f83..8480b6d 100644
--- a/media/libstagefright/AwesomePlayer.cpp
+++ b/media/libstagefright/AwesomePlayer.cpp
@@ -132,7 +132,7 @@
         status_t err = mNativeWindow->queueBuffer(
                 mNativeWindow.get(), buffer->graphicBuffer().get());
         if (err != 0) {
-            LOGE("queueBuffer failed with error %s (%d)", strerror(-err),
+            ALOGE("queueBuffer failed with error %s (%d)", strerror(-err),
                     -err);
             return;
         }
@@ -247,7 +247,7 @@
 }
 
 void AwesomePlayer::setUID(uid_t uid) {
-    LOGV("AwesomePlayer running on behalf of uid %d", uid);
+    ALOGV("AwesomePlayer running on behalf of uid %d", uid);
 
     mUID = uid;
     mUIDValid = true;
@@ -280,9 +280,9 @@
     }
 
     if (!(mFlags & INCOGNITO)) {
-        LOGI("setDataSource_l('%s')", mUri.string());
+        ALOGI("setDataSource_l('%s')", mUri.string());
     } else {
-        LOGI("setDataSource_l(URL suppressed)");
+        ALOGI("setDataSource_l(URL suppressed)");
     }
 
     // The actual work will be done during preparation in the call to
@@ -335,6 +335,14 @@
         return UNKNOWN_ERROR;
     }
 
+    if (extractor->getDrmFlag()) {
+        checkDrmStatus(dataSource);
+    }
+
+    return setDataSource_l(extractor);
+}
+
+void AwesomePlayer::checkDrmStatus(const sp<DataSource>& dataSource) {
     dataSource->getDrmInfo(mDecryptHandle, &mDrmManagerClient);
     if (mDecryptHandle != NULL) {
         CHECK(mDrmManagerClient);
@@ -342,8 +350,6 @@
             notifyListener_l(MEDIA_ERROR, MEDIA_ERROR_UNKNOWN, ERROR_DRM_NO_LICENSE);
         }
     }
-
-    return setDataSource_l(extractor);
 }
 
 status_t AwesomePlayer::setDataSource_l(const sp<MediaExtractor> &extractor) {
@@ -360,7 +366,7 @@
         if (!meta->findInt32(kKeyBitRate, &bitrate)) {
             const char *mime;
             CHECK(meta->findCString(kKeyMIMEType, &mime));
-            LOGV("track of type '%s' does not publish bitrate", mime);
+            ALOGV("track of type '%s' does not publish bitrate", mime);
 
             totalBitRate = -1;
             break;
@@ -371,7 +377,7 @@
 
     mBitrate = totalBitRate;
 
-    LOGV("mBitrate = %lld bits/sec", mBitrate);
+    ALOGV("mBitrate = %lld bits/sec", mBitrate);
 
     {
         Mutex::Autolock autoLock(mStatsLock);
@@ -483,7 +489,7 @@
     if (mFlags & PREPARING) {
         modifyFlags(PREPARE_CANCELLED, SET);
         if (mConnectingDataSource != NULL) {
-            LOGI("interrupting the connection process");
+            ALOGI("interrupting the connection process");
             mConnectingDataSource->disconnect();
         }
 
@@ -637,7 +643,7 @@
     int64_t videoLateByUs = audioTimeUs - mVideoTimeUs;
 
     if (!(mFlags & VIDEO_AT_EOS) && videoLateByUs > 300000ll) {
-        LOGV("video late by %lld ms.", videoLateByUs / 1000ll);
+        ALOGV("video late by %lld ms.", videoLateByUs / 1000ll);
 
         notifyListener_l(
                 MEDIA_INFO,
@@ -665,7 +671,7 @@
                 notifyListener_l(MEDIA_BUFFERING_UPDATE, 100);
             }
             if (mFlags & PREPARING) {
-                LOGV("cache has reached EOS, prepare is done.");
+                ALOGV("cache has reached EOS, prepare is done.");
                 finishAsyncPrepare_l();
             }
         } else {
@@ -686,7 +692,7 @@
 
                 if ((mFlags & PLAYING) && !eos
                         && (cachedDataRemaining < kLowWaterMarkBytes)) {
-                    LOGI("cache is running low (< %d) , pausing.",
+                    ALOGI("cache is running low (< %d) , pausing.",
                          kLowWaterMarkBytes);
                     modifyFlags(CACHE_UNDERRUN, SET);
                     pause_l();
@@ -695,13 +701,13 @@
                     notifyListener_l(MEDIA_INFO, MEDIA_INFO_BUFFERING_START);
                 } else if (eos || cachedDataRemaining > kHighWaterMarkBytes) {
                     if (mFlags & CACHE_UNDERRUN) {
-                        LOGI("cache has filled up (> %d), resuming.",
+                        ALOGI("cache has filled up (> %d), resuming.",
                              kHighWaterMarkBytes);
                         modifyFlags(CACHE_UNDERRUN, CLEAR);
                         play_l();
                         notifyListener_l(MEDIA_INFO, MEDIA_INFO_BUFFERING_END);
                     } else if (mFlags & PREPARING) {
-                        LOGV("cache has filled up (> %d), prepare is done",
+                        ALOGV("cache has filled up (> %d), prepare is done",
                              kHighWaterMarkBytes);
                         finishAsyncPrepare_l();
                     }
@@ -721,7 +727,7 @@
                 notifyListener_l(MEDIA_BUFFERING_UPDATE, 100);
             }
             if (mFlags & PREPARING) {
-                LOGV("cache has reached EOS, prepare is done.");
+                ALOGV("cache has reached EOS, prepare is done.");
                 finishAsyncPrepare_l();
             }
         } else {
@@ -737,12 +743,12 @@
     int64_t cachedDurationUs;
     bool eos;
     if (getCachedDuration_l(&cachedDurationUs, &eos)) {
-        LOGV("cachedDurationUs = %.2f secs, eos=%d",
+        ALOGV("cachedDurationUs = %.2f secs, eos=%d",
              cachedDurationUs / 1E6, eos);
 
         if ((mFlags & PLAYING) && !eos
                 && (cachedDurationUs < kLowWaterMarkUs)) {
-            LOGI("cache is running low (%.2f secs) , pausing.",
+            ALOGI("cache is running low (%.2f secs) , pausing.",
                  cachedDurationUs / 1E6);
             modifyFlags(CACHE_UNDERRUN, SET);
             pause_l();
@@ -751,13 +757,13 @@
             notifyListener_l(MEDIA_INFO, MEDIA_INFO_BUFFERING_START);
         } else if (eos || cachedDurationUs > kHighWaterMarkUs) {
             if (mFlags & CACHE_UNDERRUN) {
-                LOGI("cache has filled up (%.2f secs), resuming.",
+                ALOGI("cache has filled up (%.2f secs), resuming.",
                      cachedDurationUs / 1E6);
                 modifyFlags(CACHE_UNDERRUN, CLEAR);
                 play_l();
                 notifyListener_l(MEDIA_INFO, MEDIA_INFO_BUFFERING_END);
             } else if (mFlags & PREPARING) {
-                LOGV("cache has filled up (%.2f secs), prepare is done",
+                ALOGV("cache has filled up (%.2f secs), prepare is done",
                      cachedDurationUs / 1E6);
                 finishAsyncPrepare_l();
             }
@@ -789,7 +795,7 @@
     mStreamDoneEventPending = false;
 
     if (mStreamDoneStatus != ERROR_END_OF_STREAM) {
-        LOGV("MEDIA_ERROR %d", mStreamDoneStatus);
+        ALOGV("MEDIA_ERROR %d", mStreamDoneStatus);
 
         notifyListener_l(
                 MEDIA_ERROR, MEDIA_ERROR_UNKNOWN, mStreamDoneStatus);
@@ -820,7 +826,7 @@
             postVideoEvent_l();
         }
     } else {
-        LOGV("MEDIA_PLAYBACK_COMPLETE");
+        ALOGV("MEDIA_PLAYBACK_COMPLETE");
         notifyListener_l(MEDIA_PLAYBACK_COMPLETE);
 
         pause_l(true /* at eos */);
@@ -991,20 +997,20 @@
         cropRight = width - 1;
         cropBottom = height - 1;
 
-        LOGV("got dimensions only %d x %d", width, height);
+        ALOGV("got dimensions only %d x %d", width, height);
     } else {
-        LOGV("got crop rect %d, %d, %d, %d",
+        ALOGV("got crop rect %d, %d, %d, %d",
              cropLeft, cropTop, cropRight, cropBottom);
     }
 
     int32_t displayWidth;
     if (meta->findInt32(kKeyDisplayWidth, &displayWidth)) {
-        LOGV("Display width changed (%d=>%d)", mDisplayWidth, displayWidth);
+        ALOGV("Display width changed (%d=>%d)", mDisplayWidth, displayWidth);
         mDisplayWidth = displayWidth;
     }
     int32_t displayHeight;
     if (meta->findInt32(kKeyDisplayHeight, &displayHeight)) {
-        LOGV("Display height changed (%d=>%d)", mDisplayHeight, displayHeight);
+        ALOGV("Display height changed (%d=>%d)", mDisplayHeight, displayHeight);
         mDisplayHeight = displayHeight;
     }
 
@@ -1170,7 +1176,7 @@
         usleep(1000);
     }
     IPCThreadState::self()->flushCommands();
-    LOGV("video decoder shutdown completed");
+    ALOGV("video decoder shutdown completed");
 }
 
 status_t AwesomePlayer::setNativeWindow_l(const sp<ANativeWindow> &native) {
@@ -1180,7 +1186,7 @@
         return OK;
     }
 
-    LOGV("attempting to reconfigure to use new surface");
+    ALOGV("attempting to reconfigure to use new surface");
 
     bool wasPlaying = (mFlags & PLAYING) != 0;
 
@@ -1192,7 +1198,7 @@
     status_t err = initVideoDecoder();
 
     if (err != OK) {
-        LOGE("failed to reinstantiate video decoder after surface change.");
+        ALOGE("failed to reinstantiate video decoder after surface change.");
         return err;
     }
 
@@ -1317,7 +1323,7 @@
     }
 
     if (!(mFlags & PLAYING)) {
-        LOGV("seeking while paused, sending SEEK_COMPLETE notification"
+        ALOGV("seeking while paused, sending SEEK_COMPLETE notification"
              " immediately.");
 
         notifyListener_l(MEDIA_SEEK_COMPLETE);
@@ -1470,7 +1476,7 @@
         flags |= OMXCodec::kEnableGrallocUsageProtected;
     }
 #endif
-    LOGV("initVideoDecoder flags=0x%x", flags);
+    ALOGV("initVideoDecoder flags=0x%x", flags);
     mVideoSource = OMXCodec::Create(
             mClient.interface(), mVideoTrack->getFormat(),
             false, // createEncoder
@@ -1534,7 +1540,7 @@
     }
 
     if (mAudioPlayer != NULL) {
-        LOGV("seeking audio to %lld us (%.2f secs).", videoTimeUs, videoTimeUs / 1E6);
+        ALOGV("seeking audio to %lld us (%.2f secs).", videoTimeUs, videoTimeUs / 1E6);
 
         // If we don't have a video time, seek audio to the originally
         // requested seek time instead.
@@ -1597,7 +1603,7 @@
     if (!mVideoBuffer) {
         MediaSource::ReadOptions options;
         if (mSeeking != NO_SEEK) {
-            LOGV("seeking to %lld us (%.2f secs)", mSeekTimeUs, mSeekTimeUs / 1E6);
+            ALOGV("seeking to %lld us (%.2f secs)", mSeekTimeUs, mSeekTimeUs / 1E6);
 
             options.setSeekTo(
                     mSeekTimeUs,
@@ -1613,7 +1619,7 @@
                 CHECK(mVideoBuffer == NULL);
 
                 if (err == INFO_FORMAT_CHANGED) {
-                    LOGV("VideoSource signalled format change.");
+                    ALOGV("VideoSource signalled format change.");
 
                     notifyVideoSize_l();
 
@@ -1628,7 +1634,7 @@
                 // a seek request pending that needs to be applied
                 // to the audio track.
                 if (mSeeking != NO_SEEK) {
-                    LOGV("video stream ended while seeking!");
+                    ALOGV("video stream ended while seeking!");
                 }
                 finishSeekIfNecessary(-1);
 
@@ -1667,7 +1673,7 @@
 
     if (mSeeking == SEEK_VIDEO_ONLY) {
         if (mSeekTimeUs > timeUs) {
-            LOGI("XXX mSeekTimeUs = %lld us, timeUs = %lld us",
+            ALOGI("XXX mSeekTimeUs = %lld us, timeUs = %lld us",
                  mSeekTimeUs, timeUs);
         }
     }
@@ -1683,7 +1689,7 @@
     if (mAudioPlayer != NULL && !(mFlags & (AUDIO_RUNNING | SEEK_PREVIEW))) {
         status_t err = startAudioPlayer_l();
         if (err != OK) {
-            LOGE("Starting the audio player failed w/ err %d", err);
+            ALOGE("Starting the audio player failed w/ err %d", err);
             return;
         }
     }
@@ -1715,7 +1721,7 @@
         int64_t latenessUs = nowUs - timeUs;
 
         if (latenessUs > 0) {
-            LOGI("after SEEK_VIDEO_ONLY we're late by %.2f secs", latenessUs / 1E6);
+            ALOGI("after SEEK_VIDEO_ONLY we're late by %.2f secs", latenessUs / 1E6);
         }
     }
 
@@ -1730,7 +1736,7 @@
                 && mAudioPlayer != NULL
                 && mAudioPlayer->getMediaTimeMapping(
                     &realTimeUs, &mediaTimeUs)) {
-            LOGI("we're much too late (%.2f secs), video skipping ahead",
+            ALOGI("we're much too late (%.2f secs), video skipping ahead",
                  latenessUs / 1E6);
 
             mVideoBuffer->release();
@@ -1745,13 +1751,13 @@
 
         if (latenessUs > 40000) {
             // We're more than 40ms late.
-            LOGV("we're late by %lld us (%.2f secs)",
+            ALOGV("we're late by %lld us (%.2f secs)",
                  latenessUs, latenessUs / 1E6);
 
             if (!(mFlags & SLOW_DECODER_HACK)
                     || mSinceLastDropped > FRAME_DROP_FREQ)
             {
-                LOGV("we're late by %lld us (%.2f secs) dropping "
+                ALOGV("we're late by %lld us (%.2f secs) dropping "
                      "one after %d frames",
                      latenessUs, latenessUs / 1E6, mSinceLastDropped);
 
@@ -1979,7 +1985,7 @@
         if (err != OK) {
             mConnectingDataSource.clear();
 
-            LOGI("mConnectingDataSource->connect() returned %d", err);
+            ALOGI("mConnectingDataSource->connect() returned %d", err);
             return err;
         }
 
@@ -2042,7 +2048,7 @@
                         break;
                     }
 
-                    LOGV("now cached %d bytes of data", cachedDataRemaining);
+                    ALOGV("now cached %d bytes of data", cachedDataRemaining);
 
                     if (metaDataSize < 0
                             && cachedDataRemaining >= kMinBytesForSniffing) {
@@ -2067,7 +2073,7 @@
                         }
 
                         CHECK_GE(metaDataSize, 0ll);
-                        LOGV("metaDataSize = %lld bytes", metaDataSize);
+                        ALOGV("metaDataSize = %lld bytes", metaDataSize);
                     }
 
                     usleep(200000);
@@ -2077,7 +2083,7 @@
             }
 
             if (mFlags & PREPARE_CANCELLED) {
-                LOGI("Prepare cancelled while waiting for initial cache fill.");
+                ALOGI("Prepare cancelled while waiting for initial cache fill.");
                 return UNKNOWN_ERROR;
             }
         }
@@ -2095,7 +2101,7 @@
         String8 mimeType;
         float confidence;
         sp<AMessage> dummy;
-        bool success = SniffDRM(dataSource, &mimeType, &confidence, &dummy);
+        bool success = SniffWVM(dataSource, &mimeType, &confidence, &dummy);
 
         if (!success
                 || strcasecmp(
@@ -2115,13 +2121,8 @@
         }
     }
 
-    dataSource->getDrmInfo(mDecryptHandle, &mDrmManagerClient);
-
-    if (mDecryptHandle != NULL) {
-        CHECK(mDrmManagerClient);
-        if (RightsStatus::RIGHTS_VALID != mDecryptHandle->status) {
-            notifyListener_l(MEDIA_ERROR, MEDIA_ERROR_UNKNOWN, ERROR_DRM_NO_LICENSE);
-        }
+    if (extractor->getDrmFlag()) {
+        checkDrmStatus(dataSource);
     }
 
     status_t err = setDataSource_l(extractor);
@@ -2159,7 +2160,7 @@
     Mutex::Autolock autoLock(mLock);
 
     if (mFlags & PREPARE_CANCELLED) {
-        LOGI("prepare was cancelled before doing anything");
+        ALOGI("prepare was cancelled before doing anything");
         abortPrepare(UNKNOWN_ERROR);
         return;
     }
@@ -2260,7 +2261,7 @@
 status_t AwesomePlayer::setCacheStatCollectFreq(const Parcel &request) {
     if (mCachedSource != NULL) {
         int32_t freqMs = request.readInt32();
-        LOGD("Request to keep cache stats in the past %d ms",
+        ALOGD("Request to keep cache stats in the past %d ms",
             freqMs);
         return mCachedSource->setCacheStatCollectFreq(freqMs);
     }
diff --git a/media/libstagefright/CameraSource.cpp b/media/libstagefright/CameraSource.cpp
index 57989c5..1850c9c 100755
--- a/media/libstagefright/CameraSource.cpp
+++ b/media/libstagefright/CameraSource.cpp
@@ -63,12 +63,12 @@
 }
 
 void CameraSourceListener::notify(int32_t msgType, int32_t ext1, int32_t ext2) {
-    LOGV("notify(%d, %d, %d)", msgType, ext1, ext2);
+    ALOGV("notify(%d, %d, %d)", msgType, ext1, ext2);
 }
 
 void CameraSourceListener::postData(int32_t msgType, const sp<IMemory> &dataPtr,
                                     camera_frame_metadata_t *metadata) {
-    LOGV("postData(%d, ptr:%p, size:%d)",
+    ALOGV("postData(%d, ptr:%p, size:%d)",
          msgType, dataPtr->pointer(), dataPtr->size());
 
     sp<CameraSource> source = mSource.promote();
@@ -111,7 +111,7 @@
        return OMX_TI_COLOR_FormatYUV420PackedSemiPlanar;
     }
 
-    LOGE("Uknown color format (%s), please add it to "
+    ALOGE("Uknown color format (%s), please add it to "
          "CameraSource::getColorFormat", colorFormat);
 
     CHECK_EQ(0, "Unknown color format");
@@ -217,7 +217,7 @@
     int32_t width, int32_t height,
     const Vector<Size>& supportedSizes) {
 
-    LOGV("isVideoSizeSupported");
+    ALOGV("isVideoSizeSupported");
     for (size_t i = 0; i < supportedSizes.size(); ++i) {
         if (width  == supportedSizes[i].width &&
             height == supportedSizes[i].height) {
@@ -254,7 +254,7 @@
     *isSetVideoSizeSupported = true;
     params.getSupportedVideoSizes(sizes);
     if (sizes.size() == 0) {
-        LOGD("Camera does not support setVideoSize()");
+        ALOGD("Camera does not support setVideoSize()");
         params.getSupportedPreviewSizes(sizes);
         *isSetVideoSizeSupported = false;
     }
@@ -294,14 +294,14 @@
         CameraParameters* params,
         int32_t width, int32_t height,
         int32_t frameRate) {
-    LOGV("configureCamera");
+    ALOGV("configureCamera");
     Vector<Size> sizes;
     bool isSetVideoSizeSupportedByCamera = true;
     getSupportedVideoSizes(*params, &isSetVideoSizeSupportedByCamera, sizes);
     bool isCameraParamChanged = false;
     if (width != -1 && height != -1) {
         if (!isVideoSizeSupported(width, height, sizes)) {
-            LOGE("Video dimension (%dx%d) is unsupported", width, height);
+            ALOGE("Video dimension (%dx%d) is unsupported", width, height);
             return BAD_VALUE;
         }
         if (isSetVideoSizeSupportedByCamera) {
@@ -314,7 +314,7 @@
                (width != -1 && height == -1)) {
         // If one and only one of the width and height is -1
         // we reject such a request.
-        LOGE("Requested video size (%dx%d) is not supported", width, height);
+        ALOGE("Requested video size (%dx%d) is not supported", width, height);
         return BAD_VALUE;
     } else {  // width == -1 && height == -1
         // Do not configure the camera.
@@ -326,11 +326,11 @@
         const char* supportedFrameRates =
                 params->get(CameraParameters::KEY_SUPPORTED_PREVIEW_FRAME_RATES);
         CHECK(supportedFrameRates != NULL);
-        LOGV("Supported frame rates: %s", supportedFrameRates);
+        ALOGV("Supported frame rates: %s", supportedFrameRates);
         char buf[4];
         snprintf(buf, 4, "%d", frameRate);
         if (strstr(supportedFrameRates, buf) == NULL) {
-            LOGE("Requested frame rate (%d) is not supported: %s",
+            ALOGE("Requested frame rate (%d) is not supported: %s",
                 frameRate, supportedFrameRates);
             return BAD_VALUE;
         }
@@ -347,7 +347,7 @@
         // Either frame rate or frame size needs to be changed.
         String8 s = params->flatten();
         if (OK != mCamera->setParameters(s)) {
-            LOGE("Could not change settings."
+            ALOGE("Could not change settings."
                  " Someone else is using camera %p?", mCamera.get());
             return -EBUSY;
         }
@@ -370,7 +370,7 @@
         const CameraParameters& params,
         int32_t width, int32_t height) {
 
-    LOGV("checkVideoSize");
+    ALOGV("checkVideoSize");
     // The actual video size is the same as the preview size
     // if the camera hal does not support separate video and
     // preview output. In this case, we retrieve the video
@@ -387,7 +387,7 @@
         params.getVideoSize(&frameWidthActual, &frameHeightActual);
     }
     if (frameWidthActual < 0 || frameHeightActual < 0) {
-        LOGE("Failed to retrieve video frame size (%dx%d)",
+        ALOGE("Failed to retrieve video frame size (%dx%d)",
                 frameWidthActual, frameHeightActual);
         return UNKNOWN_ERROR;
     }
@@ -396,7 +396,7 @@
     // video frame size.
     if (width != -1 && height != -1) {
         if (frameWidthActual != width || frameHeightActual != height) {
-            LOGE("Failed to set video frame size to %dx%d. "
+            ALOGE("Failed to set video frame size to %dx%d. "
                     "The actual video size is %dx%d ", width, height,
                     frameWidthActual, frameHeightActual);
             return UNKNOWN_ERROR;
@@ -422,17 +422,17 @@
         const CameraParameters& params,
         int32_t frameRate) {
 
-    LOGV("checkFrameRate");
+    ALOGV("checkFrameRate");
     int32_t frameRateActual = params.getPreviewFrameRate();
     if (frameRateActual < 0) {
-        LOGE("Failed to retrieve preview frame rate (%d)", frameRateActual);
+        ALOGE("Failed to retrieve preview frame rate (%d)", frameRateActual);
         return UNKNOWN_ERROR;
     }
 
     // Check the actual video frame rate against the target/requested
     // video frame rate.
     if (frameRate != -1 && (frameRateActual - frameRate) != 0) {
-        LOGE("Failed to set preview frame rate to %d fps. The actual "
+        ALOGE("Failed to set preview frame rate to %d fps. The actual "
                 "frame rate is %d", frameRate, frameRateActual);
         return UNKNOWN_ERROR;
     }
@@ -468,7 +468,7 @@
         int32_t frameRate,
         bool storeMetaDataInVideoBuffers) {
 
-    LOGV("init");
+    ALOGV("init");
     status_t err = OK;
     int64_t token = IPCThreadState::self()->clearCallingIdentity();
     err = initWithCameraAccess(camera, proxy, cameraId,
@@ -485,11 +485,11 @@
         Size videoSize,
         int32_t frameRate,
         bool storeMetaDataInVideoBuffers) {
-    LOGV("initWithCameraAccess");
+    ALOGV("initWithCameraAccess");
     status_t err = OK;
 
     if ((err = isCameraAvailable(camera, proxy, cameraId)) != OK) {
-        LOGE("Camera connection could not be established.");
+        ALOGE("Camera connection could not be established.");
         return err;
     }
     CameraParameters params(mCamera->getParameters());
@@ -558,7 +558,7 @@
 }
 
 void CameraSource::startCameraRecording() {
-    LOGV("startCameraRecording");
+    ALOGV("startCameraRecording");
     // Reset the identity to the current thread because media server owns the
     // camera and recording is started by the applications. The applications
     // will connect to the camera in ICameraRecordingProxy::startRecording.
@@ -576,10 +576,10 @@
 }
 
 status_t CameraSource::start(MetaData *meta) {
-    LOGV("start");
+    ALOGV("start");
     CHECK(!mStarted);
     if (mInitCheck != OK) {
-        LOGE("CameraSource is not initialized yet");
+        ALOGE("CameraSource is not initialized yet");
         return mInitCheck;
     }
 
@@ -602,7 +602,7 @@
 }
 
 void CameraSource::stopCameraRecording() {
-    LOGV("stopCameraRecording");
+    ALOGV("stopCameraRecording");
     if (mCameraFlags & FLAGS_HOT_CAMERA) {
         mCameraRecordingProxy->stopRecording();
     } else {
@@ -612,11 +612,11 @@
 }
 
 void CameraSource::releaseCamera() {
-    LOGV("releaseCamera");
+    ALOGV("releaseCamera");
     if (mCamera != 0) {
         int64_t token = IPCThreadState::self()->clearCallingIdentity();
         if ((mCameraFlags & FLAGS_HOT_CAMERA) == 0) {
-            LOGV("Camera was cold when we started, stopping preview");
+            ALOGV("Camera was cold when we started, stopping preview");
             mCamera->stopPreview();
             mCamera->disconnect();
         }
@@ -633,7 +633,7 @@
 }
 
 status_t CameraSource::stop() {
-    LOGD("stop: E");
+    ALOGD("stop: E");
     Mutex::Autolock autoLock(mLock);
     mStarted = false;
     mFrameAvailableCondition.signal();
@@ -649,7 +649,7 @@
         if (NO_ERROR !=
             mFrameCompleteCondition.waitRelative(mLock,
                     mTimeBetweenFrameCaptureUs * 1000LL + CAMERA_SOURCE_TIMEOUT_NS)) {
-            LOGW("Timed out waiting for outstanding frames being encoded: %d",
+            ALOGW("Timed out waiting for outstanding frames being encoded: %d",
                 mFramesBeingEncoded.size());
         }
     }
@@ -660,22 +660,22 @@
     }
 
     if (mCollectStats) {
-        LOGI("Frames received/encoded/dropped: %d/%d/%d in %lld us",
+        ALOGI("Frames received/encoded/dropped: %d/%d/%d in %lld us",
                 mNumFramesReceived, mNumFramesEncoded, mNumFramesDropped,
                 mLastFrameTimestampUs - mFirstFrameTimeUs);
     }
 
     if (mNumGlitches > 0) {
-        LOGW("%d long delays between neighboring video frames", mNumGlitches);
+        ALOGW("%d long delays between neighboring video frames", mNumGlitches);
     }
 
     CHECK_EQ(mNumFramesReceived, mNumFramesEncoded + mNumFramesDropped);
-    LOGD("stop: X");
+    ALOGD("stop: X");
     return OK;
 }
 
 void CameraSource::releaseRecordingFrame(const sp<IMemory>& frame) {
-    LOGV("releaseRecordingFrame");
+    ALOGV("releaseRecordingFrame");
     if (mCameraRecordingProxy != NULL) {
         mCameraRecordingProxy->releaseRecordingFrame(frame);
     } else if (mCamera != NULL) {
@@ -704,7 +704,7 @@
 }
 
 void CameraSource::signalBufferReturned(MediaBuffer *buffer) {
-    LOGV("signalBufferReturned: %p", buffer->data());
+    ALOGV("signalBufferReturned: %p", buffer->data());
     Mutex::Autolock autoLock(mLock);
     for (List<sp<IMemory> >::iterator it = mFramesBeingEncoded.begin();
          it != mFramesBeingEncoded.end(); ++it) {
@@ -723,7 +723,7 @@
 
 status_t CameraSource::read(
         MediaBuffer **buffer, const ReadOptions *options) {
-    LOGV("read");
+    ALOGV("read");
 
     *buffer = NULL;
 
@@ -744,10 +744,10 @@
                     mTimeBetweenFrameCaptureUs * 1000LL + CAMERA_SOURCE_TIMEOUT_NS)) {
                 if (mCameraRecordingProxy != 0 &&
                     !mCameraRecordingProxy->asBinder()->isBinderAlive()) {
-                    LOGW("camera recording proxy is gone");
+                    ALOGW("camera recording proxy is gone");
                     return ERROR_END_OF_STREAM;
                 }
-                LOGW("Timed out waiting for incoming camera video frames: %lld us",
+                ALOGW("Timed out waiting for incoming camera video frames: %lld us",
                     mLastFrameTimestampUs);
             }
         }
@@ -770,10 +770,10 @@
 
 void CameraSource::dataCallbackTimestamp(int64_t timestampUs,
         int32_t msgType, const sp<IMemory> &data) {
-    LOGV("dataCallbackTimestamp: timestamp %lld us", timestampUs);
+    ALOGV("dataCallbackTimestamp: timestamp %lld us", timestampUs);
     Mutex::Autolock autoLock(mLock);
     if (!mStarted || (mNumFramesReceived == 0 && timestampUs < mStartTimeUs)) {
-        LOGV("Drop frame at %lld/%lld us", timestampUs, mStartTimeUs);
+        ALOGV("Drop frame at %lld/%lld us", timestampUs, mStartTimeUs);
         releaseOneRecordingFrame(data);
         return;
     }
@@ -812,13 +812,13 @@
     mFramesReceived.push_back(data);
     int64_t timeUs = mStartTimeUs + (timestampUs - mFirstFrameTimeUs);
     mFrameTimes.push_back(timeUs);
-    LOGV("initial delay: %lld, current time stamp: %lld",
+    ALOGV("initial delay: %lld, current time stamp: %lld",
         mStartTimeUs, timeUs);
     mFrameAvailableCondition.signal();
 }
 
 bool CameraSource::isMetaDataStoredInVideoBuffers() const {
-    LOGV("isMetaDataStoredInVideoBuffers");
+    ALOGV("isMetaDataStoredInVideoBuffers");
     return mIsMetaDataStoredInVideoBuffers;
 }
 
@@ -832,7 +832,7 @@
 }
 
 void CameraSource::DeathNotifier::binderDied(const wp<IBinder>& who) {
-    LOGI("Camera recording proxy died");
+    ALOGI("Camera recording proxy died");
 }
 
 }  // namespace android
diff --git a/media/libstagefright/CameraSourceTimeLapse.cpp b/media/libstagefright/CameraSourceTimeLapse.cpp
index eb456f4..263ab50 100644
--- a/media/libstagefright/CameraSourceTimeLapse.cpp
+++ b/media/libstagefright/CameraSourceTimeLapse.cpp
@@ -69,7 +69,7 @@
       mSkipCurrentFrame(false) {
 
     mTimeBetweenFrameCaptureUs = timeBetweenFrameCaptureUs;
-    LOGD("starting time lapse mode: %lld us",
+    ALOGD("starting time lapse mode: %lld us",
         mTimeBetweenFrameCaptureUs);
 
     mVideoWidth = videoSize.width;
@@ -90,7 +90,7 @@
 }
 
 void CameraSourceTimeLapse::startQuickReadReturns() {
-    LOGV("startQuickReadReturns");
+    ALOGV("startQuickReadReturns");
     Mutex::Autolock autoLock(mQuickStopLock);
 
     // Enable quick stop mode.
@@ -105,7 +105,7 @@
 bool CameraSourceTimeLapse::trySettingVideoSize(
         int32_t width, int32_t height) {
 
-    LOGV("trySettingVideoSize");
+    ALOGV("trySettingVideoSize");
     int64_t token = IPCThreadState::self()->clearCallingIdentity();
     String8 s = mCamera->getParameters();
 
@@ -131,7 +131,7 @@
 
     bool isSuccessful = false;
     if (videoSizeSupported) {
-        LOGV("Video size (%d, %d) is supported", width, height);
+        ALOGV("Video size (%d, %d) is supported", width, height);
         if (videoOutputSupported) {
             params.setVideoSize(width, height);
         } else {
@@ -140,7 +140,7 @@
         if (mCamera->setParameters(params.flatten()) == OK) {
             isSuccessful = true;
         } else {
-            LOGE("Failed to set preview size to %dx%d", width, height);
+            ALOGE("Failed to set preview size to %dx%d", width, height);
             isSuccessful = false;
         }
     }
@@ -150,7 +150,7 @@
 }
 
 void CameraSourceTimeLapse::signalBufferReturned(MediaBuffer* buffer) {
-    LOGV("signalBufferReturned");
+    ALOGV("signalBufferReturned");
     Mutex::Autolock autoLock(mQuickStopLock);
     if (mQuickStop && (buffer == mLastReadBufferCopy)) {
         buffer->setObserver(NULL);
@@ -165,7 +165,7 @@
         int64_t frameTime,
         MediaBuffer **newBuffer) {
 
-    LOGV("createMediaBufferCopy");
+    ALOGV("createMediaBufferCopy");
     size_t sourceSize = sourceBuffer.size();
     void* sourcePointer = sourceBuffer.data();
 
@@ -176,7 +176,7 @@
 }
 
 void CameraSourceTimeLapse::fillLastReadBufferCopy(MediaBuffer& sourceBuffer) {
-    LOGV("fillLastReadBufferCopy");
+    ALOGV("fillLastReadBufferCopy");
     int64_t frameTime;
     CHECK(sourceBuffer.meta_data()->findInt64(kKeyTime, &frameTime));
     createMediaBufferCopy(sourceBuffer, frameTime, &mLastReadBufferCopy);
@@ -186,7 +186,7 @@
 
 status_t CameraSourceTimeLapse::read(
         MediaBuffer **buffer, const ReadOptions *options) {
-    LOGV("read");
+    ALOGV("read");
     if (mLastReadBufferCopy == NULL) {
         mLastReadStatus = CameraSource::read(buffer, options);
 
@@ -205,7 +205,7 @@
 }
 
 void CameraSourceTimeLapse::stopCameraRecording() {
-    LOGV("stopCameraRecording");
+    ALOGV("stopCameraRecording");
     CameraSource::stopCameraRecording();
     if (mLastReadBufferCopy) {
         mLastReadBufferCopy->release();
@@ -216,7 +216,7 @@
 sp<IMemory> CameraSourceTimeLapse::createIMemoryCopy(
         const sp<IMemory> &source_data) {
 
-    LOGV("createIMemoryCopy");
+    ALOGV("createIMemoryCopy");
     size_t source_size = source_data->size();
     void* source_pointer = source_data->pointer();
 
@@ -227,7 +227,7 @@
 }
 
 bool CameraSourceTimeLapse::skipCurrentFrame(int64_t timestampUs) {
-    LOGV("skipCurrentFrame");
+    ALOGV("skipCurrentFrame");
     if (mSkipCurrentFrame) {
         mSkipCurrentFrame = false;
         return true;
@@ -237,11 +237,11 @@
 }
 
 bool CameraSourceTimeLapse::skipFrameAndModifyTimeStamp(int64_t *timestampUs) {
-    LOGV("skipFrameAndModifyTimeStamp");
+    ALOGV("skipFrameAndModifyTimeStamp");
     if (mLastTimeLapseFrameRealTimestampUs == 0) {
         // First time lapse frame. Initialize mLastTimeLapseFrameRealTimestampUs
         // to current time (timestampUs) and save frame data.
-        LOGV("dataCallbackTimestamp timelapse: initial frame");
+        ALOGV("dataCallbackTimestamp timelapse: initial frame");
 
         mLastTimeLapseFrameRealTimestampUs = *timestampUs;
         return false;
@@ -253,14 +253,14 @@
         // mForceRead may be set to true by startQuickReadReturns(). In that
         // case don't skip this frame.
         if (mForceRead) {
-            LOGV("dataCallbackTimestamp timelapse: forced read");
+            ALOGV("dataCallbackTimestamp timelapse: forced read");
             mForceRead = false;
             *timestampUs =
                 mLastFrameTimestampUs + mTimeBetweenTimeLapseVideoFramesUs;
 
             // Really make sure that this video recording frame will not be dropped.
             if (*timestampUs < mStartTimeUs) {
-                LOGI("set timestampUs to start time stamp %lld us", mStartTimeUs);
+                ALOGI("set timestampUs to start time stamp %lld us", mStartTimeUs);
                 *timestampUs = mStartTimeUs;
             }
             return false;
@@ -275,14 +275,14 @@
         // Skip all frames from last encoded frame until
         // sufficient time (mTimeBetweenFrameCaptureUs) has passed.
         // Tell the camera to release its recording frame and return.
-        LOGV("dataCallbackTimestamp timelapse: skipping intermediate frame");
+        ALOGV("dataCallbackTimestamp timelapse: skipping intermediate frame");
         return true;
     } else {
         // Desired frame has arrived after mTimeBetweenFrameCaptureUs time:
         // - Reset mLastTimeLapseFrameRealTimestampUs to current time.
         // - Artificially modify timestampUs to be one frame time (1/framerate) ahead
         // of the last encoded frame's time stamp.
-        LOGV("dataCallbackTimestamp timelapse: got timelapse frame");
+        ALOGV("dataCallbackTimestamp timelapse: got timelapse frame");
 
         mLastTimeLapseFrameRealTimestampUs = *timestampUs;
         *timestampUs = mLastFrameTimestampUs + mTimeBetweenTimeLapseVideoFramesUs;
@@ -293,7 +293,7 @@
 
 void CameraSourceTimeLapse::dataCallbackTimestamp(int64_t timestampUs, int32_t msgType,
             const sp<IMemory> &data) {
-    LOGV("dataCallbackTimestamp");
+    ALOGV("dataCallbackTimestamp");
     mSkipCurrentFrame = skipFrameAndModifyTimeStamp(&timestampUs);
     CameraSource::dataCallbackTimestamp(timestampUs, msgType, data);
 }
diff --git a/media/libstagefright/DRMExtractor.cpp b/media/libstagefright/DRMExtractor.cpp
index 1f3d581..afc4a80 100644
--- a/media/libstagefright/DRMExtractor.cpp
+++ b/media/libstagefright/DRMExtractor.cpp
@@ -282,13 +282,13 @@
     if (decryptHandle != NULL) {
         if (decryptHandle->decryptApiType == DecryptApiType::CONTAINER_BASED) {
             *mimeType = String8("drm+container_based+") + decryptHandle->mimeType;
+            *confidence = 10.0f;
         } else if (decryptHandle->decryptApiType == DecryptApiType::ELEMENTARY_STREAM_BASED) {
             *mimeType = String8("drm+es_based+") + decryptHandle->mimeType;
-        } else if (decryptHandle->decryptApiType == DecryptApiType::WV_BASED) {
-            *mimeType = MEDIA_MIMETYPE_CONTAINER_WVM;
-            LOGW("SniffWVM: found match\n");
+            *confidence = 10.0f;
+        } else {
+            return false;
         }
-        *confidence = 10.0f;
 
         return true;
     }
diff --git a/media/libstagefright/DataSource.cpp b/media/libstagefright/DataSource.cpp
index 43539bb..d0a7880 100644
--- a/media/libstagefright/DataSource.cpp
+++ b/media/libstagefright/DataSource.cpp
@@ -15,6 +15,12 @@
  */
 
 #include "include/AMRExtractor.h"
+#include "include/AVIExtractor.h"
+
+#if CHROMIUM_AVAILABLE
+#include "include/DataUriSource.h"
+#endif
+
 #include "include/MP3Extractor.h"
 #include "include/MPEG4Extractor.h"
 #include "include/WAVExtractor.h"
@@ -26,6 +32,7 @@
 #include "include/DRMExtractor.h"
 #include "include/FLACExtractor.h"
 #include "include/AACExtractor.h"
+#include "include/WVMExtractor.h"
 
 #include "matroska/MatroskaExtractor.h"
 
@@ -112,7 +119,9 @@
     RegisterSniffer(SniffMPEG2TS);
     RegisterSniffer(SniffMP3);
     RegisterSniffer(SniffAAC);
+    RegisterSniffer(SniffAVI);
     RegisterSniffer(SniffMPEG2PS);
+    RegisterSniffer(SniffWVM);
 
     char value[PROPERTY_VALUE_MAX];
     if (property_get("drm.service.enabled", value, NULL)
@@ -134,6 +143,10 @@
             return NULL;
         }
         source = new NuCachedSource2(httpSource);
+# if CHROMIUM_AVAILABLE
+    } else if (!strncasecmp("data:", uri, 5)) {
+        source = new DataUriSource(uri);
+#endif
     } else {
         // Assume it's a filename.
         source = new FileSource(uri);
diff --git a/media/libstagefright/ESDS.cpp b/media/libstagefright/ESDS.cpp
index 1f7ee25..4a0c35c 100644
--- a/media/libstagefright/ESDS.cpp
+++ b/media/libstagefright/ESDS.cpp
@@ -91,7 +91,7 @@
     }
     while (more);
 
-    LOGV("tag=0x%02x data_size=%d", *tag, *data_size);
+    ALOGV("tag=0x%02x data_size=%d", *tag, *data_size);
 
     if (*data_size > size) {
         return ERROR_MALFORMED;
@@ -162,7 +162,7 @@
             offset -= 2;
             size += 2;
 
-            LOGW("Found malformed 'esds' atom, ignoring missing OCR_ES_Id.");
+            ALOGW("Found malformed 'esds' atom, ignoring missing OCR_ES_Id.");
         }
     }
 
diff --git a/media/libstagefright/FLACExtractor.cpp b/media/libstagefright/FLACExtractor.cpp
index 8ba5a2d..668d7f7 100644
--- a/media/libstagefright/FLACExtractor.cpp
+++ b/media/libstagefright/FLACExtractor.cpp
@@ -327,7 +327,7 @@
         mWriteCompleted = true;
         return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
     } else {
-        LOGE("FLACParser::writeCallback unexpected");
+        ALOGE("FLACParser::writeCallback unexpected");
         return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
     }
 }
@@ -340,7 +340,7 @@
             mStreamInfo = metadata->data.stream_info;
             mStreamInfoValid = true;
         } else {
-            LOGE("FLACParser::metadataCallback unexpected STREAMINFO");
+            ALOGE("FLACParser::metadataCallback unexpected STREAMINFO");
         }
         break;
     case FLAC__METADATA_TYPE_VORBIS_COMMENT:
@@ -366,14 +366,14 @@
         }
         break;
     default:
-        LOGW("FLACParser::metadataCallback unexpected type %u", metadata->type);
+        ALOGW("FLACParser::metadataCallback unexpected type %u", metadata->type);
         break;
     }
 }
 
 void FLACParser::errorCallback(FLAC__StreamDecoderErrorStatus status)
 {
-    LOGE("FLACParser::errorCallback status=%d", status);
+    ALOGE("FLACParser::errorCallback status=%d", status);
     mErrorStatus = status;
 }
 
@@ -454,7 +454,7 @@
       mWriteBuffer(NULL),
       mErrorStatus((FLAC__StreamDecoderErrorStatus) -1)
 {
-    LOGV("FLACParser::FLACParser");
+    ALOGV("FLACParser::FLACParser");
     memset(&mStreamInfo, 0, sizeof(mStreamInfo));
     memset(&mWriteHeader, 0, sizeof(mWriteHeader));
     mInitCheck = init();
@@ -462,7 +462,7 @@
 
 FLACParser::~FLACParser()
 {
-    LOGV("FLACParser::~FLACParser");
+    ALOGV("FLACParser::~FLACParser");
     if (mDecoder != NULL) {
         FLAC__stream_decoder_delete(mDecoder);
         mDecoder = NULL;
@@ -477,7 +477,7 @@
         // The new should succeed, since probably all it does is a malloc
         // that always succeeds in Android.  But to avoid dependence on the
         // libFLAC internals, we check and log here.
-        LOGE("new failed");
+        ALOGE("new failed");
         return NO_INIT;
     }
     FLAC__stream_decoder_set_md5_checking(mDecoder, false);
@@ -497,12 +497,12 @@
     if (initStatus != FLAC__STREAM_DECODER_INIT_STATUS_OK) {
         // A failure here probably indicates a programming error and so is
         // unlikely to happen. But we check and log here similarly to above.
-        LOGE("init_stream failed %d", initStatus);
+        ALOGE("init_stream failed %d", initStatus);
         return NO_INIT;
     }
     // parse all metadata
     if (!FLAC__stream_decoder_process_until_end_of_metadata(mDecoder)) {
-        LOGE("end_of_metadata failed");
+        ALOGE("end_of_metadata failed");
         return NO_INIT;
     }
     if (mStreamInfoValid) {
@@ -512,7 +512,7 @@
         case 2:
             break;
         default:
-            LOGE("unsupported channel count %u", getChannels());
+            ALOGE("unsupported channel count %u", getChannels());
             return NO_INIT;
         }
         // check bit depth
@@ -522,7 +522,7 @@
         case 24:
             break;
         default:
-            LOGE("unsupported bits per sample %u", getBitsPerSample());
+            ALOGE("unsupported bits per sample %u", getBitsPerSample());
             return NO_INIT;
         }
         // check sample rate
@@ -539,7 +539,7 @@
             break;
         default:
             // 96000 would require a proper downsampler in AudioFlinger
-            LOGE("unsupported sample rate %u", getSampleRate());
+            ALOGE("unsupported sample rate %u", getSampleRate());
             return NO_INIT;
         }
         // configure the appropriate copy function, defaulting to trespass
@@ -572,7 +572,7 @@
                     (getTotalSamples() * 1000000LL) / getSampleRate());
         }
     } else {
-        LOGE("missing STREAMINFO");
+        ALOGE("missing STREAMINFO");
         return NO_INIT;
     }
     if (mFileMetadata != 0) {
@@ -603,30 +603,30 @@
     if (doSeek) {
         // We implement the seek callback, so this works without explicit flush
         if (!FLAC__stream_decoder_seek_absolute(mDecoder, sample)) {
-            LOGE("FLACParser::readBuffer seek to sample %llu failed", sample);
+            ALOGE("FLACParser::readBuffer seek to sample %llu failed", sample);
             return NULL;
         }
-        LOGV("FLACParser::readBuffer seek to sample %llu succeeded", sample);
+        ALOGV("FLACParser::readBuffer seek to sample %llu succeeded", sample);
     } else {
         if (!FLAC__stream_decoder_process_single(mDecoder)) {
-            LOGE("FLACParser::readBuffer process_single failed");
+            ALOGE("FLACParser::readBuffer process_single failed");
             return NULL;
         }
     }
     if (!mWriteCompleted) {
-        LOGV("FLACParser::readBuffer write did not complete");
+        ALOGV("FLACParser::readBuffer write did not complete");
         return NULL;
     }
     // verify that block header keeps the promises made by STREAMINFO
     unsigned blocksize = mWriteHeader.blocksize;
     if (blocksize == 0 || blocksize > getMaxBlockSize()) {
-        LOGE("FLACParser::readBuffer write invalid blocksize %u", blocksize);
+        ALOGE("FLACParser::readBuffer write invalid blocksize %u", blocksize);
         return NULL;
     }
     if (mWriteHeader.sample_rate != getSampleRate() ||
         mWriteHeader.channels != getChannels() ||
         mWriteHeader.bits_per_sample != getBitsPerSample()) {
-        LOGE("FLACParser::readBuffer write changed parameters mid-stream");
+        ALOGE("FLACParser::readBuffer write changed parameters mid-stream");
     }
     // acquire a media buffer
     CHECK(mGroup != NULL);
@@ -661,13 +661,13 @@
       mInitCheck(false),
       mStarted(false)
 {
-    LOGV("FLACSource::FLACSource");
+    ALOGV("FLACSource::FLACSource");
     mInitCheck = init();
 }
 
 FLACSource::~FLACSource()
 {
-    LOGV("~FLACSource::FLACSource");
+    ALOGV("~FLACSource::FLACSource");
     if (mStarted) {
         stop();
     }
@@ -675,7 +675,7 @@
 
 status_t FLACSource::start(MetaData *params)
 {
-    LOGV("FLACSource::start");
+    ALOGV("FLACSource::start");
 
     CHECK(!mStarted);
     mParser->allocateBuffers();
@@ -686,7 +686,7 @@
 
 status_t FLACSource::stop()
 {
-    LOGV("FLACSource::stop");
+    ALOGV("FLACSource::stop");
 
     CHECK(mStarted);
     mParser->releaseBuffers();
@@ -729,7 +729,7 @@
 
 status_t FLACSource::init()
 {
-    LOGV("FLACSource::init");
+    ALOGV("FLACSource::init");
     // re-use the same track metadata passed into constructor from FLACExtractor
     mParser = new FLACParser(mDataSource);
     return mParser->initCheck();
@@ -742,13 +742,13 @@
     : mDataSource(dataSource),
       mInitCheck(false)
 {
-    LOGV("FLACExtractor::FLACExtractor");
+    ALOGV("FLACExtractor::FLACExtractor");
     mInitCheck = init();
 }
 
 FLACExtractor::~FLACExtractor()
 {
-    LOGV("~FLACExtractor::FLACExtractor");
+    ALOGV("~FLACExtractor::FLACExtractor");
 }
 
 size_t FLACExtractor::countTracks()
diff --git a/media/libstagefright/FileSource.cpp b/media/libstagefright/FileSource.cpp
index 0794f57..01f53e4 100644
--- a/media/libstagefright/FileSource.cpp
+++ b/media/libstagefright/FileSource.cpp
@@ -101,7 +101,7 @@
    } else {
         off64_t result = lseek64(mFd, offset + mOffset, SEEK_SET);
         if (result == -1) {
-            LOGE("seek to %lld failed", offset + mOffset);
+            ALOGE("seek to %lld failed", offset + mOffset);
             return UNKNOWN_ERROR;
         }
 
@@ -127,7 +127,7 @@
     return OK;
 }
 
-sp<DecryptHandle> FileSource::DrmInitialization() {
+sp<DecryptHandle> FileSource::DrmInitialization(const char *mime) {
     if (mDrmManagerClient == NULL) {
         mDrmManagerClient = new DrmManagerClient();
     }
@@ -138,7 +138,7 @@
 
     if (mDecryptHandle == NULL) {
         mDecryptHandle = mDrmManagerClient->openDecryptSession(
-                mFd, mOffset, mLength);
+                mFd, mOffset, mLength, mime);
     }
 
     if (mDecryptHandle == NULL) {
diff --git a/media/libstagefright/HTTPBase.cpp b/media/libstagefright/HTTPBase.cpp
index 3c5a8a5..d7eea3f 100644
--- a/media/libstagefright/HTTPBase.cpp
+++ b/media/libstagefright/HTTPBase.cpp
@@ -111,11 +111,11 @@
     if (freqMs < kMinBandwidthCollectFreqMs
             || freqMs > kMaxBandwidthCollectFreqMs) {
 
-        LOGE("frequency (%d ms) is out of range [1000, 60000]", freqMs);
+        ALOGE("frequency (%d ms) is out of range [1000, 60000]", freqMs);
         return BAD_VALUE;
     }
 
-    LOGI("frequency set to %d ms", freqMs);
+    ALOGI("frequency set to %d ms", freqMs);
     mBandWidthCollectFreqMs = freqMs;
     return OK;
 }
@@ -139,7 +139,7 @@
 void HTTPBase::RegisterSocketUserTag(int sockfd, uid_t uid, uint32_t kTag) {
     int res = qtaguid_tagSocket(sockfd, kTag, uid);
     if (res != 0) {
-        LOGE("Failed tagging socket %d for uid %d (My UID=%d)", sockfd, uid, geteuid());
+        ALOGE("Failed tagging socket %d for uid %d (My UID=%d)", sockfd, uid, geteuid());
     }
 }
 
@@ -147,7 +147,7 @@
 void HTTPBase::UnRegisterSocketUserTag(int sockfd) {
     int res = qtaguid_untagSocket(sockfd);
     if (res != 0) {
-        LOGE("Failed untagging socket %d (My UID=%d)", sockfd, geteuid());
+        ALOGE("Failed untagging socket %d (My UID=%d)", sockfd, geteuid());
     }
 }
 
diff --git a/media/libstagefright/MP3Extractor.cpp b/media/libstagefright/MP3Extractor.cpp
index 34e9cd7..2215c07 100644
--- a/media/libstagefright/MP3Extractor.cpp
+++ b/media/libstagefright/MP3Extractor.cpp
@@ -81,7 +81,7 @@
 
             *inout_pos += len;
 
-            LOGV("skipped ID3 tag, new starting offset is %lld (0x%016llx)",
+            ALOGV("skipped ID3 tag, new starting offset is %lld (0x%016llx)",
                  *inout_pos, *inout_pos);
         }
 
@@ -105,7 +105,7 @@
     do {
         if (pos >= *inout_pos + kMaxBytesChecked) {
             // Don't scan forever.
-            LOGV("giving up at offset %lld", pos);
+            ALOGV("giving up at offset %lld", pos);
             break;
         }
 
@@ -155,7 +155,7 @@
             continue;
         }
 
-        LOGV("found possible 1st frame at %lld (header = 0x%08x)", pos, header);
+        ALOGV("found possible 1st frame at %lld (header = 0x%08x)", pos, header);
 
         // We found what looks like a valid frame,
         // now find its successors.
@@ -172,7 +172,7 @@
 
             uint32_t test_header = U32_AT(tmp);
 
-            LOGV("subsequent header is %08x", test_header);
+            ALOGV("subsequent header is %08x", test_header);
 
             if ((test_header & kMask) != (header & kMask)) {
                 valid = false;
@@ -186,7 +186,7 @@
                 break;
             }
 
-            LOGV("found subsequent frame #%d at %lld", j + 2, test_pos);
+            ALOGV("found subsequent frame #%d at %lld", j + 2, test_pos);
 
             test_pos += test_frame_size;
         }
@@ -198,7 +198,7 @@
                 *out_header = header;
             }
         } else {
-            LOGV("no dice, no valid sequence of frames found.");
+            ALOGV("no dice, no valid sequence of frames found.");
         }
 
         ++pos;
@@ -431,7 +431,7 @@
             int32_t bitrate;
             if (!mMeta->findInt32(kKeyBitRate, &bitrate)) {
                 // bitrate is in bits/sec.
-                LOGI("no bitrate");
+                ALOGI("no bitrate");
 
                 return ERROR_UNSUPPORTED;
             }
@@ -483,11 +483,11 @@
         }
 
         // Lost sync.
-        LOGV("lost sync! header = 0x%08x, old header = 0x%08x\n", header, mFixedHeader);
+        ALOGV("lost sync! header = 0x%08x, old header = 0x%08x\n", header, mFixedHeader);
 
         off64_t pos = mCurrentPos;
         if (!Resync(mDataSource, mFixedHeader, &pos, NULL, NULL)) {
-            LOGE("Unable to resync. Signalling end of stream.");
+            ALOGE("Unable to resync. Signalling end of stream.");
 
             buffer->release();
             buffer = NULL;
diff --git a/media/libstagefright/MPEG2TSWriter.cpp b/media/libstagefright/MPEG2TSWriter.cpp
index 02eeb40..36009ab 100644
--- a/media/libstagefright/MPEG2TSWriter.cpp
+++ b/media/libstagefright/MPEG2TSWriter.cpp
@@ -644,7 +644,7 @@
                 CHECK(source->lastAccessUnit() == NULL);
                 source->setLastAccessUnit(buffer);
 
-                LOGV("lastAccessUnitTimeUs[%d] = %.2f secs",
+                ALOGV("lastAccessUnitTimeUs[%d] = %.2f secs",
                      sourceIndex, source->lastAccessUnitTimeUs() / 1E6);
 
                 int64_t minTimeUs = -1;
@@ -668,11 +668,11 @@
                 }
 
                 if (minTimeUs < 0) {
-                    LOGV("not a all tracks have valid data.");
+                    ALOGV("not a all tracks have valid data.");
                     break;
                 }
 
-                LOGV("writing access unit at time %.2f secs (index %d)",
+                ALOGV("writing access unit at time %.2f secs (index %d)",
                      minTimeUs / 1E6, minIndex);
 
                 source = mSources.editItemAt(minIndex);
diff --git a/media/libstagefright/MPEG4Extractor.cpp b/media/libstagefright/MPEG4Extractor.cpp
index f6b06c7..bc88015 100644
--- a/media/libstagefright/MPEG4Extractor.cpp
+++ b/media/libstagefright/MPEG4Extractor.cpp
@@ -683,7 +683,7 @@
         case FOURCC('i', 'l', 's', 't'):
         {
             if (chunk_type == FOURCC('s', 't', 'b', 'l')) {
-                LOGV("sampleTable chunk is %d bytes long.", (size_t)chunk_size);
+                ALOGV("sampleTable chunk is %d bytes long.", (size_t)chunk_size);
 
                 if (mDataSource->flags()
                         & (DataSource::kWantsPrefetching
@@ -1250,7 +1250,7 @@
             char buffer[23];
             if (chunk_data_size != 7 &&
                 chunk_data_size != 23) {
-                LOGE("Incorrect D263 box size %lld", chunk_data_size);
+                ALOGE("Incorrect D263 box size %lld", chunk_data_size);
                 return ERROR_MALFORMED;
             }
 
@@ -1372,8 +1372,9 @@
 
             uint32_t type = ntohl(buffer);
             // For the 3GPP file format, the handler-type within the 'hdlr' box
-            // shall be 'text'
-            if (type == FOURCC('t', 'e', 'x', 't')) {
+            // shall be 'text'. We also want to support 'sbtl' handler type
+            // for a practical reason as various MPEG4 containers use it.
+            if (type == FOURCC('t', 'e', 'x', 't') || type == FOURCC('s', 'b', 't', 'l')) {
                 mLastTrack->meta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_TEXT_3GPP);
             }
 
@@ -1417,7 +1418,7 @@
         case FOURCC('c', 'o', 'v', 'r'):
         {
             if (mFileMetaData != NULL) {
-                LOGV("chunk_data_size = %lld and data_offset = %lld",
+                ALOGV("chunk_data_size = %lld and data_offset = %lld",
                         chunk_data_size, data_offset);
                 uint8_t *buffer = new uint8_t[chunk_data_size + 1];
                 if (mDataSource->readAt(
@@ -1499,9 +1500,9 @@
     int32_t dy = U32_AT(&buffer[matrixOffset + 20]);
 
 #if 0
-    LOGI("x' = %.2f * x + %.2f * y + %.2f",
+    ALOGI("x' = %.2f * x + %.2f * y + %.2f",
          a00 / 65536.0f, a01 / 65536.0f, dx / 65536.0f);
-    LOGI("y' = %.2f * x + %.2f * y + %.2f",
+    ALOGI("y' = %.2f * x + %.2f * y + %.2f",
          a10 / 65536.0f, a11 / 65536.0f, dy / 65536.0f);
 #endif
 
@@ -1518,7 +1519,7 @@
     } else if (a00 == -kFixedOne && a01 == 0 && a10 == 0 && a11 == -kFixedOne) {
         rotationDegrees = 180;
     } else {
-        LOGW("We only support 0,90,180,270 degree rotation matrices");
+        ALOGW("We only support 0,90,180,270 degree rotation matrices");
         rotationDegrees = 0;
     }
 
@@ -1750,7 +1751,7 @@
         // The media subtype is MP3 audio
         // Our software MP3 audio decoder may not be able to handle
         // packetized MP3 audio; for now, lets just return ERROR_UNSUPPORTED
-        LOGE("MP3 track in MP4/3GPP file is not supported");
+        ALOGE("MP3 track in MP4/3GPP file is not supported");
         return ERROR_UNSUPPORTED;
     }
 
@@ -1820,7 +1821,7 @@
     CHECK(mLastTrack->meta->findInt32(kKeySampleRate, &prevSampleRate));
 
     if (prevSampleRate != sampleRate) {
-        LOGV("mpeg4 audio sample rate different from previous setting. "
+        ALOGV("mpeg4 audio sample rate different from previous setting. "
              "was: %d, now: %d", prevSampleRate, sampleRate);
     }
 
@@ -1830,7 +1831,7 @@
     CHECK(mLastTrack->meta->findInt32(kKeyChannelCount, &prevChannelCount));
 
     if (prevChannelCount != numChannels) {
-        LOGV("mpeg4 audio channel count different from previous setting. "
+        ALOGV("mpeg4 audio channel count different from previous setting. "
              "was: %d, now: %d", prevChannelCount, numChannels);
     }
 
@@ -2035,7 +2036,7 @@
         CHECK_EQ(OK, mSampleTable->getMetaDataForSample(
                     syncSampleIndex, NULL, NULL, &syncSampleTime));
 
-        LOGI("seek to time %lld us => sample at time %lld us, "
+        ALOGI("seek to time %lld us => sample at time %lld us, "
              "sync sample at time %lld us",
              seekTimeUs,
              sampleTime * 1000000ll / mTimescale,
@@ -2122,7 +2123,7 @@
 
         size_t nal_size = parseNALSize(src);
         if (mBuffer->range_length() < mNALLengthSize + nal_size) {
-            LOGE("incomplete NAL unit.");
+            ALOGE("incomplete NAL unit.");
 
             mBuffer->release();
             mBuffer = NULL;
@@ -2186,7 +2187,7 @@
                 }
 
                 if (isMalFormed) {
-                    LOGE("Video is malformed");
+                    ALOGE("Video is malformed");
                     mBuffer->release();
                     mBuffer = NULL;
                     return ERROR_MALFORMED;
@@ -2407,7 +2408,7 @@
         *meta = new AMessage;
         (*meta)->setInt64("meta-data-size", moovAtomEndOffset);
 
-        LOGV("found metadata size: %lld", moovAtomEndOffset);
+        ALOGV("found metadata size: %lld", moovAtomEndOffset);
     }
 
     return true;
@@ -2421,7 +2422,7 @@
     }
 
     if (LegacySniffMPEG4(source, mimeType, confidence)) {
-        LOGW("Identified supported mpeg4 through LegacySniffMPEG4.");
+        ALOGW("Identified supported mpeg4 through LegacySniffMPEG4.");
         return true;
     }
 
diff --git a/media/libstagefright/MPEG4Writer.cpp b/media/libstagefright/MPEG4Writer.cpp
index 46d87df..06dd875 100755
--- a/media/libstagefright/MPEG4Writer.cpp
+++ b/media/libstagefright/MPEG4Writer.cpp
@@ -327,7 +327,7 @@
 status_t MPEG4Writer::addSource(const sp<MediaSource> &source) {
     Mutex::Autolock l(mLock);
     if (mStarted) {
-        LOGE("Attempt to add source AFTER recording is started");
+        ALOGE("Attempt to add source AFTER recording is started");
         return UNKNOWN_ERROR;
     }
     Track *track = new Track(this, source, mTracks.size());
@@ -406,7 +406,7 @@
         size = MAX_MOOV_BOX_SIZE;
     }
 
-    LOGI("limits: %lld/%lld bytes/us, bit rate: %d bps and the estimated"
+    ALOGI("limits: %lld/%lld bytes/us, bit rate: %d bps and the estimated"
          " moov size %lld bytes",
          mMaxFileSizeLimitBytes, mMaxFileDurationLimitUs, bitRate, size);
     return factor * size;
@@ -443,7 +443,7 @@
         // If file size is set to be larger than the 32 bit file
         // size limit, treat it as an error.
         if (mMaxFileSizeLimitBytes > kMax32BitFileSize) {
-            LOGW("32-bit file size limit (%lld bytes) too big. "
+            ALOGW("32-bit file size limit (%lld bytes) too big. "
                  "It is changed to %lld bytes",
                 mMaxFileSizeLimitBytes, kMax32BitFileSize);
             mMaxFileSizeLimitBytes = kMax32BitFileSize;
@@ -472,7 +472,7 @@
         mTimeScale = 1000;
     }
     CHECK(mTimeScale > 0);
-    LOGV("movie time scale: %d", mTimeScale);
+    ALOGV("movie time scale: %d", mTimeScale);
 
     mStreamableFile = true;
     mWriteMoovBoxToMemory = false;
@@ -539,7 +539,7 @@
 }
 
 void MPEG4Writer::stopWriterThread() {
-    LOGD("Stopping writer thread");
+    ALOGD("Stopping writer thread");
     if (!mWriterThreadStarted) {
         return;
     }
@@ -554,7 +554,7 @@
     void *dummy;
     pthread_join(mThread, &dummy);
     mWriterThreadStarted = false;
-    LOGD("Writer thread stopped");
+    ALOGD("Writer thread stopped");
 }
 
 /*
@@ -569,7 +569,7 @@
  * u, v and w is in 2.30 format.
  */
 void MPEG4Writer::writeCompositionMatrix(int degrees) {
-    LOGV("writeCompositionMatrix");
+    ALOGV("writeCompositionMatrix");
     uint32_t a = 0x00010000;
     uint32_t b = 0;
     uint32_t c = 0;
@@ -650,7 +650,7 @@
     }
 
     if (mTracks.size() > 1) {
-        LOGD("Duration from tracks range is [%lld, %lld] us",
+        ALOGD("Duration from tracks range is [%lld, %lld] us",
             minDurationUs, maxDurationUs);
     }
 
@@ -701,7 +701,7 @@
         mMoovBoxBuffer = NULL;
         mMoovBoxBufferOffset = 0;
     } else {
-        LOGI("The mp4 file will not be streamable.");
+        ALOGI("The mp4 file will not be streamable.");
     }
 
     CHECK(mBoxes.empty());
@@ -1084,12 +1084,12 @@
 }
 
 void MPEG4Writer::setStartTimestampUs(int64_t timeUs) {
-    LOGI("setStartTimestampUs: %lld", timeUs);
+    ALOGI("setStartTimestampUs: %lld", timeUs);
     CHECK(timeUs >= 0);
     Mutex::Autolock autoLock(mLock);
     if (mStartTimestampUs < 0 || mStartTimestampUs > timeUs) {
         mStartTimestampUs = timeUs;
-        LOGI("Earliest track starting time: %lld", mStartTimestampUs);
+        ALOGI("Earliest track starting time: %lld", mStartTimestampUs);
     }
 }
 
@@ -1173,7 +1173,7 @@
         size_t sampleCount, int32_t duration) {
 
     if (duration == 0) {
-        LOGW("0-duration samples found: %d", sampleCount);
+        ALOGW("0-duration samples found: %d", sampleCount);
     }
     SttsTableEntry sttsEntry(sampleCount, duration);
     mSttsTableEntries.push_back(sttsEntry);
@@ -1200,7 +1200,7 @@
 }
 
 void MPEG4Writer::Track::setTimeScale() {
-    LOGV("setTimeScale");
+    ALOGV("setTimeScale");
     // Default time scale
     mTimeScale = 90000;
 
@@ -1262,14 +1262,14 @@
 }
 
 void MPEG4Writer::Track::initTrackingProgressStatus(MetaData *params) {
-    LOGV("initTrackingProgressStatus");
+    ALOGV("initTrackingProgressStatus");
     mPreviousTrackTimeUs = -1;
     mTrackingProgressStatus = false;
     mTrackEveryTimeDurationUs = 0;
     {
         int64_t timeUs;
         if (params && params->findInt64(kKeyTrackTimeStatus, &timeUs)) {
-            LOGV("Receive request to track progress status for every %lld us", timeUs);
+            ALOGV("Receive request to track progress status for every %lld us", timeUs);
             mTrackEveryTimeDurationUs = timeUs;
             mTrackingProgressStatus = true;
         }
@@ -1278,14 +1278,14 @@
 
 // static
 void *MPEG4Writer::ThreadWrapper(void *me) {
-    LOGV("ThreadWrapper: %p", me);
+    ALOGV("ThreadWrapper: %p", me);
     MPEG4Writer *writer = static_cast<MPEG4Writer *>(me);
     writer->threadFunc();
     return NULL;
 }
 
 void MPEG4Writer::bufferChunk(const Chunk& chunk) {
-    LOGV("bufferChunk: %p", chunk.mTrack);
+    ALOGV("bufferChunk: %p", chunk.mTrack);
     Mutex::Autolock autolock(mLock);
     CHECK_EQ(mDone, false);
 
@@ -1303,7 +1303,7 @@
 }
 
 void MPEG4Writer::writeChunkToFile(Chunk* chunk) {
-    LOGV("writeChunkToFile: %lld from %s track",
+    ALOGV("writeChunkToFile: %lld from %s track",
         chunk->mTimeStampUs, chunk->mTrack->isAudio()? "audio": "video");
 
     int32_t isFirstSample = true;
@@ -1327,7 +1327,7 @@
 }
 
 void MPEG4Writer::writeAllChunks() {
-    LOGV("writeAllChunks");
+    ALOGV("writeAllChunks");
     size_t outstandingChunks = 0;
     Chunk chunk;
     while (findChunkToWrite(&chunk)) {
@@ -1338,11 +1338,11 @@
     sendSessionSummary();
 
     mChunkInfos.clear();
-    LOGD("%d chunks are written in the last batch", outstandingChunks);
+    ALOGD("%d chunks are written in the last batch", outstandingChunks);
 }
 
 bool MPEG4Writer::findChunkToWrite(Chunk *chunk) {
-    LOGV("findChunkToWrite");
+    ALOGV("findChunkToWrite");
 
     int64_t minTimestampUs = 0x7FFFFFFFFFFFFFFFLL;
     Track *track = NULL;
@@ -1358,7 +1358,7 @@
     }
 
     if (track == NULL) {
-        LOGV("Nothing to be written after all");
+        ALOGV("Nothing to be written after all");
         return false;
     }
 
@@ -1387,7 +1387,7 @@
 }
 
 void MPEG4Writer::threadFunc() {
-    LOGV("threadFunc");
+    ALOGV("threadFunc");
 
     prctl(PR_SET_NAME, (unsigned long)"MPEG4Writer", 0, 0, 0);
 
@@ -1413,7 +1413,7 @@
 }
 
 status_t MPEG4Writer::startWriterThread() {
-    LOGV("startWriterThread");
+    ALOGV("startWriterThread");
 
     mDone = false;
     mIsFirstChunk = true;
@@ -1481,7 +1481,7 @@
             startTimeOffsetUs = kInitialDelayTimeUs;
         }
         startTimeUs += startTimeOffsetUs;
-        LOGI("Start time offset: %lld us", startTimeOffsetUs);
+        ALOGI("Start time offset: %lld us", startTimeOffsetUs);
     }
 
     meta->setInt64(kKeyTime, startTimeUs);
@@ -1523,9 +1523,9 @@
 }
 
 status_t MPEG4Writer::Track::stop() {
-    LOGD("Stopping %s track", mIsAudio? "Audio": "Video");
+    ALOGD("Stopping %s track", mIsAudio? "Audio": "Video");
     if (!mStarted) {
-        LOGE("Stop() called but track is not started");
+        ALOGE("Stop() called but track is not started");
         return ERROR_END_OF_STREAM;
     }
 
@@ -1539,7 +1539,7 @@
 
     status_t err = (status_t) dummy;
 
-    LOGD("Stopping %s track source", mIsAudio? "Audio": "Video");
+    ALOGD("Stopping %s track source", mIsAudio? "Audio": "Video");
     {
         status_t status = mSource->stop();
         if (err == OK && status != OK && status != ERROR_END_OF_STREAM) {
@@ -1547,7 +1547,7 @@
         }
     }
 
-    LOGD("%s track stopped", mIsAudio? "Audio": "Video");
+    ALOGD("%s track stopped", mIsAudio? "Audio": "Video");
     return err;
 }
 
@@ -1564,7 +1564,7 @@
 }
 
 static void getNalUnitType(uint8_t byte, uint8_t* type) {
-    LOGV("getNalUnitType: %d", byte);
+    ALOGV("getNalUnitType: %d", byte);
 
     // nal_unit_type: 5-bit unsigned integer
     *type = (byte & 0x1F);
@@ -1573,7 +1573,7 @@
 static const uint8_t *findNextStartCode(
         const uint8_t *data, size_t length) {
 
-    LOGV("findNextStartCode: %p %d", data, length);
+    ALOGV("findNextStartCode: %p %d", data, length);
 
     size_t bytesLeft = length;
     while (bytesLeft > 4  &&
@@ -1589,21 +1589,21 @@
 const uint8_t *MPEG4Writer::Track::parseParamSet(
         const uint8_t *data, size_t length, int type, size_t *paramSetLen) {
 
-    LOGV("parseParamSet");
+    ALOGV("parseParamSet");
     CHECK(type == kNalUnitTypeSeqParamSet ||
           type == kNalUnitTypePicParamSet);
 
     const uint8_t *nextStartCode = findNextStartCode(data, length);
     *paramSetLen = nextStartCode - data;
     if (*paramSetLen == 0) {
-        LOGE("Param set is malformed, since its length is 0");
+        ALOGE("Param set is malformed, since its length is 0");
         return NULL;
     }
 
     AVCParamSet paramSet(*paramSetLen, data);
     if (type == kNalUnitTypeSeqParamSet) {
         if (*paramSetLen < 4) {
-            LOGE("Seq parameter set malformed");
+            ALOGE("Seq parameter set malformed");
             return NULL;
         }
         if (mSeqParamSets.empty()) {
@@ -1614,7 +1614,7 @@
             if (mProfileIdc != data[1] ||
                 mProfileCompatible != data[2] ||
                 mLevelIdc != data[3]) {
-                LOGE("Inconsistent profile/level found in seq parameter sets");
+                ALOGE("Inconsistent profile/level found in seq parameter sets");
                 return NULL;
             }
         }
@@ -1627,12 +1627,12 @@
 
 status_t MPEG4Writer::Track::copyAVCCodecSpecificData(
         const uint8_t *data, size_t size) {
-    LOGV("copyAVCCodecSpecificData");
+    ALOGV("copyAVCCodecSpecificData");
 
     // 2 bytes for each of the parameter set length field
     // plus the 7 bytes for the header
     if (size < 4 + 7) {
-        LOGE("Codec specific data length too short: %d", size);
+        ALOGE("Codec specific data length too short: %d", size);
         return ERROR_MALFORMED;
     }
 
@@ -1645,7 +1645,7 @@
 status_t MPEG4Writer::Track::parseAVCCodecSpecificData(
         const uint8_t *data, size_t size) {
 
-    LOGV("parseAVCCodecSpecificData");
+    ALOGV("parseAVCCodecSpecificData");
     // Data starts with a start code.
     // SPS and PPS are separated with start codes.
     // Also, SPS must come before PPS
@@ -1661,7 +1661,7 @@
         getNalUnitType(*(tmp + 4), &type);
         if (type == kNalUnitTypeSeqParamSet) {
             if (gotPps) {
-                LOGE("SPS must come before PPS");
+                ALOGE("SPS must come before PPS");
                 return ERROR_MALFORMED;
             }
             if (!gotSps) {
@@ -1670,7 +1670,7 @@
             nextStartCode = parseParamSet(tmp + 4, bytesLeft - 4, type, &paramSetLen);
         } else if (type == kNalUnitTypePicParamSet) {
             if (!gotSps) {
-                LOGE("SPS must come before PPS");
+                ALOGE("SPS must come before PPS");
                 return ERROR_MALFORMED;
             }
             if (!gotPps) {
@@ -1678,7 +1678,7 @@
             }
             nextStartCode = parseParamSet(tmp + 4, bytesLeft - 4, type, &paramSetLen);
         } else {
-            LOGE("Only SPS and PPS Nal units are expected");
+            ALOGE("Only SPS and PPS Nal units are expected");
             return ERROR_MALFORMED;
         }
 
@@ -1696,12 +1696,12 @@
         // Check on the number of seq parameter sets
         size_t nSeqParamSets = mSeqParamSets.size();
         if (nSeqParamSets == 0) {
-            LOGE("Cound not find sequence parameter set");
+            ALOGE("Cound not find sequence parameter set");
             return ERROR_MALFORMED;
         }
 
         if (nSeqParamSets > 0x1F) {
-            LOGE("Too many seq parameter sets (%d) found", nSeqParamSets);
+            ALOGE("Too many seq parameter sets (%d) found", nSeqParamSets);
             return ERROR_MALFORMED;
         }
     }
@@ -1710,11 +1710,11 @@
         // Check on the number of pic parameter sets
         size_t nPicParamSets = mPicParamSets.size();
         if (nPicParamSets == 0) {
-            LOGE("Cound not find picture parameter set");
+            ALOGE("Cound not find picture parameter set");
             return ERROR_MALFORMED;
         }
         if (nPicParamSets > 0xFF) {
-            LOGE("Too many pic parameter sets (%d) found", nPicParamSets);
+            ALOGE("Too many pic parameter sets (%d) found", nPicParamSets);
             return ERROR_MALFORMED;
         }
     }
@@ -1727,7 +1727,7 @@
         // These profiles requires additional parameter set extensions
         if (mProfileIdc == 100 || mProfileIdc == 110 ||
             mProfileIdc == 122 || mProfileIdc == 144) {
-            LOGE("Sorry, no support for profile_idc: %d!", mProfileIdc);
+            ALOGE("Sorry, no support for profile_idc: %d!", mProfileIdc);
             return BAD_VALUE;
         }
     }
@@ -1739,12 +1739,12 @@
         const uint8_t *data, size_t size) {
 
     if (mCodecSpecificData != NULL) {
-        LOGE("Already have codec specific data");
+        ALOGE("Already have codec specific data");
         return ERROR_MALFORMED;
     }
 
     if (size < 4) {
-        LOGE("Codec specific data length too short: %d", size);
+        ALOGE("Codec specific data length too short: %d", size);
         return ERROR_MALFORMED;
     }
 
@@ -1987,7 +1987,7 @@
             int64_t timeUs = decodingTimeUs;
             cttsDeltaTimeUs = timestampUs - decodingTimeUs;
             timestampUs = decodingTimeUs;
-            LOGV("decoding time: %lld and ctts delta time: %lld",
+            ALOGV("decoding time: %lld and ctts delta time: %lld",
                 timestampUs, cttsDeltaTimeUs);
         }
 
@@ -1998,7 +1998,7 @@
         }
 
         CHECK(timestampUs >= 0);
-        LOGV("%s media time stamp: %lld and previous paused duration %lld",
+        ALOGV("%s media time stamp: %lld and previous paused duration %lld",
                 mIsAudio? "Audio": "Video", timestampUs, previousPausedDurationUs);
         if (timestampUs > mTrackDurationUs) {
             mTrackDurationUs = timestampUs;
@@ -2020,7 +2020,7 @@
             // Force the first sample to have its own stts entry so that
             // we can adjust its value later to maintain the A/V sync.
             if (mNumSamples == 3 || currDurationTicks != lastDurationTicks) {
-                LOGV("%s lastDurationUs: %lld us, currDurationTicks: %lld us",
+                ALOGV("%s lastDurationUs: %lld us, currDurationTicks: %lld us",
                         mIsAudio? "Audio": "Video", lastDurationUs, currDurationTicks);
                 addOneSttsTableEntry(sampleCount, lastDurationTicks);
                 sampleCount = 1;
@@ -2046,7 +2046,7 @@
             }
             previousSampleSize = sampleSize;
         }
-        LOGV("%s timestampUs/lastTimestampUs: %lld/%lld",
+        ALOGV("%s timestampUs/lastTimestampUs: %lld/%lld",
                 mIsAudio? "Audio": "Video", timestampUs, lastTimestampUs);
         lastDurationUs = timestampUs - lastTimestampUs;
         lastDurationTicks = currDurationTicks;
@@ -2146,10 +2146,10 @@
 
     sendTrackSummary(hasMultipleTracks);
 
-    LOGI("Received total/0-length (%d/%d) buffers and encoded %d frames. - %s",
+    ALOGI("Received total/0-length (%d/%d) buffers and encoded %d frames. - %s",
             count, nZeroLengthFrames, mNumSamples, mIsAudio? "audio": "video");
     if (mIsAudio) {
-        LOGI("Audio track drift time: %lld us", mOwner->getDriftTimeUs());
+        ALOGI("Audio track drift time: %lld us", mOwner->getDriftTimeUs());
     }
 
     if (err == ERROR_END_OF_STREAM) {
@@ -2160,12 +2160,12 @@
 
 bool MPEG4Writer::Track::isTrackMalFormed() const {
     if (mSampleSizes.empty()) {                      // no samples written
-        LOGE("The number of recorded samples is 0");
+        ALOGE("The number of recorded samples is 0");
         return true;
     }
 
     if (!mIsAudio && mNumStssTableEntries == 0) {  // no sync frames for video
-        LOGE("There are no sync frames for video track");
+        ALOGE("There are no sync frames for video track");
         return true;
     }
 
@@ -2232,10 +2232,10 @@
 }
 
 void MPEG4Writer::Track::trackProgressStatus(int64_t timeUs, status_t err) {
-    LOGV("trackProgressStatus: %lld us", timeUs);
+    ALOGV("trackProgressStatus: %lld us", timeUs);
     if (mTrackEveryTimeDurationUs > 0 &&
         timeUs - mPreviousTrackTimeUs >= mTrackEveryTimeDurationUs) {
-        LOGV("Fire time tracking progress status at %lld us", timeUs);
+        ALOGV("Fire time tracking progress status at %lld us", timeUs);
         mOwner->trackProgressStatus(mTrackId, timeUs - mPreviousTrackTimeUs, err);
         mPreviousTrackTimeUs = timeUs;
     }
@@ -2269,13 +2269,13 @@
 }
 
 void MPEG4Writer::setDriftTimeUs(int64_t driftTimeUs) {
-    LOGV("setDriftTimeUs: %lld us", driftTimeUs);
+    ALOGV("setDriftTimeUs: %lld us", driftTimeUs);
     Mutex::Autolock autolock(mLock);
     mDriftTimeUs = driftTimeUs;
 }
 
 int64_t MPEG4Writer::getDriftTimeUs() {
-    LOGV("getDriftTimeUs: %lld us", mDriftTimeUs);
+    ALOGV("getDriftTimeUs: %lld us", mDriftTimeUs);
     Mutex::Autolock autolock(mLock);
     return mDriftTimeUs;
 }
@@ -2285,7 +2285,7 @@
 }
 
 void MPEG4Writer::Track::bufferChunk(int64_t timestampUs) {
-    LOGV("bufferChunk");
+    ALOGV("bufferChunk");
 
     Chunk chunk(this, timestampUs, mChunkSamples);
     mOwner->bufferChunk(chunk);
@@ -2308,13 +2308,13 @@
         !strcasecmp(MEDIA_MIMETYPE_VIDEO_AVC, mime)) {
         if (!mCodecSpecificData ||
             mCodecSpecificDataSize <= 0) {
-            LOGE("Missing codec specific data");
+            ALOGE("Missing codec specific data");
             return ERROR_MALFORMED;
         }
     } else {
         if (mCodecSpecificData ||
             mCodecSpecificDataSize > 0) {
-            LOGE("Unexepected codec specific data found");
+            ALOGE("Unexepected codec specific data found");
             return ERROR_MALFORMED;
         }
     }
@@ -2323,7 +2323,7 @@
 
 void MPEG4Writer::Track::writeTrackHeader(bool use32BitOffset) {
 
-    LOGV("%s track time scale: %d",
+    ALOGV("%s track time scale: %d",
         mIsAudio? "Audio": "Video", mTimeScale);
 
     time_t now = time(NULL);
@@ -2378,7 +2378,7 @@
     } else if (!strcasecmp(MEDIA_MIMETYPE_VIDEO_AVC, mime)) {
         mOwner->beginBox("avc1");
     } else {
-        LOGE("Unknown mime type '%s'.", mime);
+        ALOGE("Unknown mime type '%s'.", mime);
         CHECK(!"should not be here, unknown mime type.");
     }
 
@@ -2432,7 +2432,7 @@
     } else if (!strcasecmp(MEDIA_MIMETYPE_AUDIO_AAC, mime)) {
         fourcc = "mp4a";
     } else {
-        LOGE("Unknown mime type '%s'.", mime);
+        ALOGE("Unknown mime type '%s'.", mime);
         CHECK(!"should not be here, unknown mime type.");
     }
 
@@ -2730,7 +2730,7 @@
         return;
     }
 
-    LOGV("ctts box has %d entries", mNumCttsTableEntries);
+    ALOGV("ctts box has %d entries", mNumCttsTableEntries);
 
     mOwner->beginBox("ctts");
     if (mHasNegativeCttsDeltaDuration) {
diff --git a/media/libstagefright/MediaBuffer.cpp b/media/libstagefright/MediaBuffer.cpp
index 0b14f1e..96271e4 100644
--- a/media/libstagefright/MediaBuffer.cpp
+++ b/media/libstagefright/MediaBuffer.cpp
@@ -135,7 +135,7 @@
 
 void MediaBuffer::set_range(size_t offset, size_t length) {
     if ((mGraphicBuffer == NULL) && (offset + length > mSize)) {
-        LOGE("offset = %d, length = %d, mSize = %d", offset, length, mSize);
+        ALOGE("offset = %d, length = %d, mSize = %d", offset, length, mSize);
     }
     CHECK((mGraphicBuffer != NULL) || (offset + length <= mSize));
 
diff --git a/media/libstagefright/MediaExtractor.cpp b/media/libstagefright/MediaExtractor.cpp
index 374ecf7..2171492 100644
--- a/media/libstagefright/MediaExtractor.cpp
+++ b/media/libstagefright/MediaExtractor.cpp
@@ -19,6 +19,7 @@
 #include <utils/Log.h>
 
 #include "include/AMRExtractor.h"
+#include "include/AVIExtractor.h"
 #include "include/MP3Extractor.h"
 #include "include/MPEG4Extractor.h"
 #include "include/WAVExtractor.h"
@@ -58,13 +59,13 @@
     if (mime == NULL) {
         float confidence;
         if (!source->sniff(&tmp, &confidence, &meta)) {
-            LOGV("FAILED to autodetect media content.");
+            ALOGV("FAILED to autodetect media content.");
 
             return NULL;
         }
 
         mime = tmp.string();
-        LOGV("Autodetected media content as '%s' with confidence %.2f",
+        ALOGV("Autodetected media content as '%s' with confidence %.2f",
              mime, confidence);
     }
 
@@ -109,10 +110,12 @@
         ret = new MatroskaExtractor(source);
     } else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_MPEG2TS)) {
         ret = new MPEG2TSExtractor(source);
+    } else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_AVI)) {
+        ret = new AVIExtractor(source);
     } else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_WVM)) {
         ret = new WVMExtractor(source);
     } else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AAC_ADTS)) {
-        ret = new AACExtractor(source);
+        ret = new AACExtractor(source, meta);
     } else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_MPEG2PS)) {
         ret = new MPEG2PSExtractor(source);
     }
diff --git a/media/libstagefright/MediaSourceSplitter.cpp b/media/libstagefright/MediaSourceSplitter.cpp
index abc7012..8af0694 100644
--- a/media/libstagefright/MediaSourceSplitter.cpp
+++ b/media/libstagefright/MediaSourceSplitter.cpp
@@ -51,7 +51,7 @@
 status_t MediaSourceSplitter::start(int clientId, MetaData *params) {
     Mutex::Autolock autoLock(mLock);
 
-    LOGV("start client (%d)", clientId);
+    ALOGV("start client (%d)", clientId);
     if (mClientsStarted[clientId]) {
         return OK;
     }
@@ -59,7 +59,7 @@
     mNumberOfClientsStarted++;
 
     if (!mSourceStarted) {
-        LOGV("Starting real source from client (%d)", clientId);
+        ALOGV("Starting real source from client (%d)", clientId);
         status_t err = mSource->start(params);
 
         if (err == OK) {
@@ -85,12 +85,12 @@
 status_t MediaSourceSplitter::stop(int clientId) {
     Mutex::Autolock autoLock(mLock);
 
-    LOGV("stop client (%d)", clientId);
+    ALOGV("stop client (%d)", clientId);
     CHECK(clientId >= 0 && clientId < mNumberOfClients);
     CHECK(mClientsStarted[clientId]);
 
     if (--mNumberOfClientsStarted == 0) {
-        LOGV("Stopping real source from client (%d)", clientId);
+        ALOGV("Stopping real source from client (%d)", clientId);
         status_t err = mSource->stop();
         mSourceStarted = false;
         mClientsStarted.editItemAt(clientId) = false;
@@ -114,7 +114,7 @@
 sp<MetaData> MediaSourceSplitter::getFormat(int clientId) {
     Mutex::Autolock autoLock(mLock);
 
-    LOGV("getFormat client (%d)", clientId);
+    ALOGV("getFormat client (%d)", clientId);
     return mSource->getFormat();
 }
 
@@ -124,7 +124,7 @@
 
     CHECK(clientId >= 0 && clientId < mNumberOfClients);
 
-    LOGV("read client (%d)", clientId);
+    ALOGV("read client (%d)", clientId);
     *buffer = NULL;
 
     if (!mClientsStarted[clientId]) {
diff --git a/media/libstagefright/NuCachedSource2.cpp b/media/libstagefright/NuCachedSource2.cpp
index 1e1de04..693c506 100644
--- a/media/libstagefright/NuCachedSource2.cpp
+++ b/media/libstagefright/NuCachedSource2.cpp
@@ -135,7 +135,7 @@
 }
 
 void PageCache::copy(size_t from, void *data, size_t size) {
-    LOGV("copy from %d size %d", from, size);
+    ALOGV("copy from %d size %d", from, size);
 
     if (size == 0) {
         return;
@@ -277,7 +277,7 @@
 }
 
 void NuCachedSource2::fetchInternal() {
-    LOGV("fetchInternal");
+    ALOGV("fetchInternal");
 
     bool reconnect = false;
 
@@ -302,7 +302,7 @@
             mNumRetriesLeft = 0;
             return;
         } else if (err != OK) {
-            LOGI("The attempt to reconnect failed, %d retries remaining",
+            ALOGI("The attempt to reconnect failed, %d retries remaining",
                  mNumRetriesLeft);
 
             return;
@@ -317,11 +317,11 @@
     Mutex::Autolock autoLock(mLock);
 
     if (n < 0) {
-        LOGE("source returned error %ld, %d retries left", n, mNumRetriesLeft);
+        ALOGE("source returned error %ld, %d retries left", n, mNumRetriesLeft);
         mFinalStatus = n;
         mCache->releasePage(page);
     } else if (n == 0) {
-        LOGI("ERROR_END_OF_STREAM");
+        ALOGI("ERROR_END_OF_STREAM");
 
         mNumRetriesLeft = 0;
         mFinalStatus = ERROR_END_OF_STREAM;
@@ -329,7 +329,7 @@
         mCache->releasePage(page);
     } else {
         if (mFinalStatus != OK) {
-            LOGI("retrying a previously failed read succeeded.");
+            ALOGI("retrying a previously failed read succeeded.");
         }
         mNumRetriesLeft = kMaxNumRetries;
         mFinalStatus = OK;
@@ -340,10 +340,10 @@
 }
 
 void NuCachedSource2::onFetch() {
-    LOGV("onFetch");
+    ALOGV("onFetch");
 
     if (mFinalStatus != OK && mNumRetriesLeft == 0) {
-        LOGV("EOS reached, done prefetching for now");
+        ALOGV("EOS reached, done prefetching for now");
         mFetching = false;
     }
 
@@ -355,7 +355,7 @@
 
     if (mFetching || keepAlive) {
         if (keepAlive) {
-            LOGI("Keep alive");
+            ALOGI("Keep alive");
         }
 
         fetchInternal();
@@ -363,12 +363,12 @@
         mLastFetchTimeUs = ALooper::GetNowUs();
 
         if (mFetching && mCache->totalSize() >= mHighwaterThresholdBytes) {
-            LOGI("Cache full, done prefetching for now");
+            ALOGI("Cache full, done prefetching for now");
             mFetching = false;
 
             if (mDisconnectAtHighwatermark
                     && (mSource->flags() & DataSource::kIsHTTPBasedSource)) {
-                LOGV("Disconnecting at high watermark");
+                ALOGV("Disconnecting at high watermark");
                 static_cast<HTTPBase *>(mSource.get())->disconnect();
             }
         }
@@ -393,7 +393,7 @@
 }
 
 void NuCachedSource2::onRead(const sp<AMessage> &msg) {
-    LOGV("onRead");
+    ALOGV("onRead");
 
     int64_t offset;
     CHECK(msg->findInt64("offset", &offset));
@@ -448,14 +448,14 @@
     size_t actualBytes = mCache->releaseFromStart(maxBytes);
     mCacheOffset += actualBytes;
 
-    LOGI("restarting prefetcher, totalSize = %d", mCache->totalSize());
+    ALOGI("restarting prefetcher, totalSize = %d", mCache->totalSize());
     mFetching = true;
 }
 
 ssize_t NuCachedSource2::readAt(off64_t offset, void *data, size_t size) {
     Mutex::Autolock autoSerializer(mSerializer);
 
-    LOGV("readAt offset %lld, size %d", offset, size);
+    ALOGV("readAt offset %lld, size %d", offset, size);
 
     Mutex::Autolock autoLock(mLock);
 
@@ -523,7 +523,7 @@
 ssize_t NuCachedSource2::readInternal(off64_t offset, void *data, size_t size) {
     CHECK_LE(size, (size_t)mHighwaterThresholdBytes);
 
-    LOGV("readInternal offset %lld size %d", offset, size);
+    ALOGV("readInternal offset %lld size %d", offset, size);
 
     Mutex::Autolock autoLock(mLock);
 
@@ -571,7 +571,7 @@
         return size;
     }
 
-    LOGV("deferring read");
+    ALOGV("deferring read");
 
     return -EAGAIN;
 }
@@ -584,7 +584,7 @@
         return OK;
     }
 
-    LOGI("new range: offset= %lld", offset);
+    ALOGI("new range: offset= %lld", offset);
 
     mCacheOffset = offset;
 
@@ -603,8 +603,8 @@
     restartPrefetcherIfNecessary_l(true /* ignore low water threshold */);
 }
 
-sp<DecryptHandle> NuCachedSource2::DrmInitialization() {
-    return mSource->DrmInitialization();
+sp<DecryptHandle> NuCachedSource2::DrmInitialization(const char* mime) {
+    return mSource->DrmInitialization(mime);
 }
 
 void NuCachedSource2::getDrmInfo(sp<DecryptHandle> &handle, DrmManagerClient **client) {
@@ -634,7 +634,7 @@
 
     if (sscanf(s, "%ld/%ld/%d",
                &lowwaterMarkKb, &highwaterMarkKb, &keepAliveSecs) != 3) {
-        LOGE("Failed to parse cache parameters from '%s'.", s);
+        ALOGE("Failed to parse cache parameters from '%s'.", s);
         return;
     }
 
@@ -651,7 +651,7 @@
     }
 
     if (mLowwaterThresholdBytes >= mHighwaterThresholdBytes) {
-        LOGE("Illegal low/highwater marks specified, reverting to defaults.");
+        ALOGE("Illegal low/highwater marks specified, reverting to defaults.");
 
         mLowwaterThresholdBytes = kDefaultLowWaterThreshold;
         mHighwaterThresholdBytes = kDefaultHighWaterThreshold;
@@ -663,7 +663,7 @@
         mKeepAliveIntervalUs = kDefaultKeepAliveIntervalUs;
     }
 
-    LOGV("lowwater = %d bytes, highwater = %d bytes, keepalive = %lld us",
+    ALOGV("lowwater = %d bytes, highwater = %d bytes, keepalive = %lld us",
          mLowwaterThresholdBytes,
          mHighwaterThresholdBytes,
          mKeepAliveIntervalUs);
@@ -687,7 +687,7 @@
 
         headers->removeItemsAt(index);
 
-        LOGV("Using special cache config '%s'", cacheConfig->string());
+        ALOGV("Using special cache config '%s'", cacheConfig->string());
     }
 
     if ((index = headers->indexOfKey(
@@ -695,7 +695,7 @@
         *disconnectAtHighwatermark = true;
         headers->removeItemsAt(index);
 
-        LOGV("Client requested disconnection at highwater mark");
+        ALOGV("Client requested disconnection at highwater mark");
     }
 }
 
diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp
index 86b3fe4..60d9bb7 100755
--- a/media/libstagefright/OMXCodec.cpp
+++ b/media/libstagefright/OMXCodec.cpp
@@ -179,9 +179,9 @@
 
 #undef OPTIONAL
 
-#define CODEC_LOGI(x, ...) LOGI("[%s] "x, mComponentName, ##__VA_ARGS__)
-#define CODEC_LOGV(x, ...) LOGV("[%s] "x, mComponentName, ##__VA_ARGS__)
-#define CODEC_LOGE(x, ...) LOGE("[%s] "x, mComponentName, ##__VA_ARGS__)
+#define CODEC_LOGI(x, ...) ALOGI("[%s] "x, mComponentName, ##__VA_ARGS__)
+#define CODEC_LOGV(x, ...) ALOGV("[%s] "x, mComponentName, ##__VA_ARGS__)
+#define CODEC_LOGE(x, ...) ALOGE("[%s] "x, mComponentName, ##__VA_ARGS__)
 
 struct OMXCodecObserver : public BnOMXObserver {
     OMXCodecObserver() {
@@ -467,13 +467,13 @@
                 InstantiateSoftwareEncoder(componentName, source, meta);
 
             if (softwareCodec != NULL) {
-                LOGV("Successfully allocated software codec '%s'", componentName);
+                ALOGV("Successfully allocated software codec '%s'", componentName);
 
                 return softwareCodec;
             }
         }
 
-        LOGV("Attempting to allocate OMX node '%s'", componentName);
+        ALOGV("Attempting to allocate OMX node '%s'", componentName);
 
         uint32_t quirks = getComponentQuirks(componentNameBase, createEncoder);
 
@@ -484,7 +484,7 @@
                 // For OMX.SEC.* decoders we can enable a special mode that
                 // gives the client access to the framebuffer contents.
 
-                LOGW("Component '%s' does not give the client access to "
+                ALOGW("Component '%s' does not give the client access to "
                      "the framebuffer contents. Skipping.",
                      componentName);
 
@@ -494,7 +494,7 @@
 
         status_t err = omx->allocateNode(componentName, observer, &node);
         if (err == OK) {
-            LOGV("Successfully allocated OMX node '%s'", componentName);
+            ALOGV("Successfully allocated OMX node '%s'", componentName);
 
             sp<OMXCodec> codec = new OMXCodec(
                     omx, node, quirks, flags,
@@ -513,7 +513,7 @@
                 return codec;
             }
 
-            LOGV("Failed to configure codec '%s'", componentName);
+            ALOGV("Failed to configure codec '%s'", componentName);
         }
     }
 
@@ -600,7 +600,7 @@
 }
 
 status_t OMXCodec::configureCodec(const sp<MetaData> &meta) {
-    LOGV("configureCodec protected=%d",
+    ALOGV("configureCodec protected=%d",
          (mFlags & kEnableGrallocUsageProtected) ? 1 : 0);
 
     if (!(mFlags & kIgnoreCodecSpecificData)) {
@@ -625,7 +625,7 @@
             status_t err;
             if ((err = parseAVCCodecSpecificData(
                             data, size, &profile, &level)) != OK) {
-                LOGE("Malformed AVC codec specific data.");
+                ALOGE("Malformed AVC codec specific data.");
                 return err;
             }
 
@@ -639,7 +639,7 @@
                 // does not handle this gracefully and would clobber the heap
                 // and wreak havoc instead...
 
-                LOGE("Profile and/or level exceed the decoder's capabilities.");
+                ALOGE("Profile and/or level exceed the decoder's capabilities.");
                 return ERROR_UNSUPPORTED;
             }
         } else if (meta->findData(kKeyVorbisInfo, &type, &data, &size)) {
@@ -904,7 +904,7 @@
 
 status_t OMXCodec::findTargetColorFormat(
         const sp<MetaData>& meta, OMX_COLOR_FORMATTYPE *colorFormat) {
-    LOGV("findTargetColorFormat");
+    ALOGV("findTargetColorFormat");
     CHECK(mIsEncoder);
 
     *colorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
@@ -924,7 +924,7 @@
 
 status_t OMXCodec::isColorFormatSupported(
         OMX_COLOR_FORMATTYPE colorFormat, int portIndex) {
-    LOGV("isColorFormatSupported: %d", static_cast<int>(colorFormat));
+    ALOGV("isColorFormatSupported: %d", static_cast<int>(colorFormat));
 
     // Enumerate all the color formats supported by
     // the omx component to see whether the given
@@ -981,7 +981,7 @@
     } else if (!strcasecmp(MEDIA_MIMETYPE_VIDEO_H263, mime)) {
         compressionFormat = OMX_VIDEO_CodingH263;
     } else {
-        LOGE("Not a supported video mime type: %s", mime);
+        ALOGE("Not a supported video mime type: %s", mime);
         CHECK(!"Should not be here. Not a supported video mime type.");
     }
 
@@ -1093,7 +1093,7 @@
             mNode, OMX_IndexParamVideoErrorCorrection,
             &errorCorrectionType, sizeof(errorCorrectionType));
     if (err != OK) {
-        LOGW("Error correction param query is not supported");
+        ALOGW("Error correction param query is not supported");
         return OK;  // Optional feature. Ignore this failure
     }
 
@@ -1107,7 +1107,7 @@
             mNode, OMX_IndexParamVideoErrorCorrection,
             &errorCorrectionType, sizeof(errorCorrectionType));
     if (err != OK) {
-        LOGW("Error correction param configuration is not supported");
+        ALOGW("Error correction param configuration is not supported");
     }
 
     // Optional feature. Ignore the failure.
@@ -1375,7 +1375,7 @@
     } else if (!strcasecmp(MEDIA_MIMETYPE_VIDEO_MPEG2, mime)) {
         compressionFormat = OMX_VIDEO_CodingMPEG2;
     } else {
-        LOGE("Not a supported video mime type: %s", mime);
+        ALOGE("Not a supported video mime type: %s", mime);
         CHECK(!"Should not be here. Not a supported video mime type.");
     }
 
@@ -1579,7 +1579,7 @@
                 &roleParams, sizeof(roleParams));
 
         if (err != OK) {
-            LOGW("Failed to set standard component role '%s'.", role);
+            ALOGW("Failed to set standard component role '%s'.", role);
         }
     }
 }
@@ -1664,7 +1664,7 @@
     }
 
     if ((mFlags & kEnableGrallocUsageProtected) && portIndex == kPortIndexOutput) {
-        LOGE("protected output buffers must be stent to an ANativeWindow");
+        ALOGE("protected output buffers must be stent to an ANativeWindow");
         return PERMISSION_DENIED;
     }
 
@@ -1673,7 +1673,7 @@
             && portIndex == kPortIndexInput) {
         err = mOMX->storeMetaDataInBuffers(mNode, kPortIndexInput, OMX_TRUE);
         if (err != OK) {
-            LOGE("Storing meta data in video buffers is not supported");
+            ALOGE("Storing meta data in video buffers is not supported");
             return err;
         }
     }
@@ -1735,7 +1735,7 @@
         }
 
         if (err != OK) {
-            LOGE("allocate_buffer_with_backup failed");
+            ALOGE("allocate_buffer_with_backup failed");
             return err;
         }
 
@@ -1849,7 +1849,7 @@
             def.format.video.eColorFormat);
 
     if (err != 0) {
-        LOGE("native_window_set_buffers_geometry failed: %s (%d)",
+        ALOGE("native_window_set_buffers_geometry failed: %s (%d)",
                 strerror(-err), -err);
         return err;
     }
@@ -1863,7 +1863,7 @@
     OMX_U32 usage = 0;
     err = mOMX->getGraphicBufferUsage(mNode, kPortIndexOutput, &usage);
     if (err != 0) {
-        LOGW("querying usage flags from OMX IL component failed: %d", err);
+        ALOGW("querying usage flags from OMX IL component failed: %d", err);
         // XXX: Currently this error is logged, but not fatal.
         usage = 0;
     }
@@ -1881,20 +1881,20 @@
                 mNativeWindow.get(), NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER,
                 &queuesToNativeWindow);
         if (err != 0) {
-            LOGE("error authenticating native window: %d", err);
+            ALOGE("error authenticating native window: %d", err);
             return err;
         }
         if (queuesToNativeWindow != 1) {
-            LOGE("native window could not be authenticated");
+            ALOGE("native window could not be authenticated");
             return PERMISSION_DENIED;
         }
     }
 
-    LOGV("native_window_set_usage usage=0x%lx", usage);
+    ALOGV("native_window_set_usage usage=0x%lx", usage);
     err = native_window_set_usage(
             mNativeWindow.get(), usage | GRALLOC_USAGE_HW_TEXTURE | GRALLOC_USAGE_EXTERNAL_DISP);
     if (err != 0) {
-        LOGE("native_window_set_usage failed: %s (%d)", strerror(-err), -err);
+        ALOGE("native_window_set_usage failed: %s (%d)", strerror(-err), -err);
         return err;
     }
 
@@ -1902,7 +1902,7 @@
     err = mNativeWindow->query(mNativeWindow.get(),
             NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS, &minUndequeuedBufs);
     if (err != 0) {
-        LOGE("NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS query failed: %s (%d)",
+        ALOGE("NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS query failed: %s (%d)",
                 strerror(-err), -err);
         return err;
     }
@@ -1925,7 +1925,7 @@
     err = native_window_set_buffer_count(
             mNativeWindow.get(), def.nBufferCountActual);
     if (err != 0) {
-        LOGE("native_window_set_buffer_count failed: %s (%d)", strerror(-err),
+        ALOGE("native_window_set_buffer_count failed: %s (%d)", strerror(-err),
                 -err);
         return err;
     }
@@ -1938,7 +1938,7 @@
         ANativeWindowBuffer* buf;
         err = mNativeWindow->dequeueBuffer(mNativeWindow.get(), &buf);
         if (err != 0) {
-            LOGE("dequeueBuffer failed: %s (%d)", strerror(-err), -err);
+            ALOGE("dequeueBuffer failed: %s (%d)", strerror(-err), -err);
             break;
         }
 
@@ -2052,7 +2052,7 @@
     err = native_window_api_disconnect(mNativeWindow.get(),
             NATIVE_WINDOW_API_MEDIA);
     if (err != NO_ERROR) {
-        LOGE("error pushing blank frames: api_disconnect failed: %s (%d)",
+        ALOGE("error pushing blank frames: api_disconnect failed: %s (%d)",
                 strerror(-err), -err);
         return err;
     }
@@ -2060,7 +2060,7 @@
     err = native_window_api_connect(mNativeWindow.get(),
             NATIVE_WINDOW_API_CPU);
     if (err != NO_ERROR) {
-        LOGE("error pushing blank frames: api_connect failed: %s (%d)",
+        ALOGE("error pushing blank frames: api_connect failed: %s (%d)",
                 strerror(-err), -err);
         return err;
     }
@@ -2068,7 +2068,7 @@
     err = native_window_set_scaling_mode(mNativeWindow.get(),
             NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW);
     if (err != NO_ERROR) {
-        LOGE("error pushing blank frames: set_buffers_geometry failed: %s (%d)",
+        ALOGE("error pushing blank frames: set_buffers_geometry failed: %s (%d)",
                 strerror(-err), -err);
         goto error;
     }
@@ -2076,7 +2076,7 @@
     err = native_window_set_buffers_geometry(mNativeWindow.get(), 1, 1,
             HAL_PIXEL_FORMAT_RGBX_8888);
     if (err != NO_ERROR) {
-        LOGE("error pushing blank frames: set_buffers_geometry failed: %s (%d)",
+        ALOGE("error pushing blank frames: set_buffers_geometry failed: %s (%d)",
                 strerror(-err), -err);
         goto error;
     }
@@ -2084,7 +2084,7 @@
     err = native_window_set_usage(mNativeWindow.get(),
             GRALLOC_USAGE_SW_WRITE_OFTEN);
     if (err != NO_ERROR) {
-        LOGE("error pushing blank frames: set_usage failed: %s (%d)",
+        ALOGE("error pushing blank frames: set_usage failed: %s (%d)",
                 strerror(-err), -err);
         goto error;
     }
@@ -2092,7 +2092,7 @@
     err = mNativeWindow->query(mNativeWindow.get(),
             NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS, &minUndequeuedBufs);
     if (err != NO_ERROR) {
-        LOGE("error pushing blank frames: MIN_UNDEQUEUED_BUFFERS query "
+        ALOGE("error pushing blank frames: MIN_UNDEQUEUED_BUFFERS query "
                 "failed: %s (%d)", strerror(-err), -err);
         goto error;
     }
@@ -2100,7 +2100,7 @@
     numBufs = minUndequeuedBufs + 1;
     err = native_window_set_buffer_count(mNativeWindow.get(), numBufs);
     if (err != NO_ERROR) {
-        LOGE("error pushing blank frames: set_buffer_count failed: %s (%d)",
+        ALOGE("error pushing blank frames: set_buffer_count failed: %s (%d)",
                 strerror(-err), -err);
         goto error;
     }
@@ -2112,7 +2112,7 @@
     for (int i = 0; i < numBufs + 1; i++) {
         err = mNativeWindow->dequeueBuffer(mNativeWindow.get(), &anb);
         if (err != NO_ERROR) {
-            LOGE("error pushing blank frames: dequeueBuffer failed: %s (%d)",
+            ALOGE("error pushing blank frames: dequeueBuffer failed: %s (%d)",
                     strerror(-err), -err);
             goto error;
         }
@@ -2121,7 +2121,7 @@
         err = mNativeWindow->lockBuffer(mNativeWindow.get(),
                 buf->getNativeBuffer());
         if (err != NO_ERROR) {
-            LOGE("error pushing blank frames: lockBuffer failed: %s (%d)",
+            ALOGE("error pushing blank frames: lockBuffer failed: %s (%d)",
                     strerror(-err), -err);
             goto error;
         }
@@ -2130,7 +2130,7 @@
         uint32_t* img = NULL;
         err = buf->lock(GRALLOC_USAGE_SW_WRITE_OFTEN, (void**)(&img));
         if (err != NO_ERROR) {
-            LOGE("error pushing blank frames: lock failed: %s (%d)",
+            ALOGE("error pushing blank frames: lock failed: %s (%d)",
                     strerror(-err), -err);
             goto error;
         }
@@ -2139,7 +2139,7 @@
 
         err = buf->unlock();
         if (err != NO_ERROR) {
-            LOGE("error pushing blank frames: unlock failed: %s (%d)",
+            ALOGE("error pushing blank frames: unlock failed: %s (%d)",
                     strerror(-err), -err);
             goto error;
         }
@@ -2147,7 +2147,7 @@
         err = mNativeWindow->queueBuffer(mNativeWindow.get(),
                 buf->getNativeBuffer());
         if (err != NO_ERROR) {
-            LOGE("error pushing blank frames: queueBuffer failed: %s (%d)",
+            ALOGE("error pushing blank frames: queueBuffer failed: %s (%d)",
                     strerror(-err), -err);
             goto error;
         }
@@ -2174,7 +2174,7 @@
         err = native_window_api_disconnect(mNativeWindow.get(),
                 NATIVE_WINDOW_API_CPU);
         if (err != NO_ERROR) {
-            LOGE("error pushing blank frames: api_disconnect failed: %s (%d)",
+            ALOGE("error pushing blank frames: api_disconnect failed: %s (%d)",
                     strerror(-err), -err);
             return err;
         }
@@ -2182,7 +2182,7 @@
         err = native_window_api_connect(mNativeWindow.get(),
                 NATIVE_WINDOW_API_MEDIA);
         if (err != NO_ERROR) {
-            LOGE("error pushing blank frames: api_connect failed: %s (%d)",
+            ALOGE("error pushing blank frames: api_connect failed: %s (%d)",
                     strerror(-err), -err);
             return err;
         }
@@ -2214,7 +2214,7 @@
 
 void OMXCodec::on_message(const omx_message &msg) {
     if (mState == ERROR) {
-        LOGW("Dropping OMX message - we're in ERROR state.");
+        ALOGW("Dropping OMX message - we're in ERROR state.");
         return;
     }
 
@@ -2242,7 +2242,7 @@
 
             CHECK(i < buffers->size());
             if ((*buffers)[i].mStatus != OWNED_BY_COMPONENT) {
-                LOGW("We already own input buffer %p, yet received "
+                ALOGW("We already own input buffer %p, yet received "
                      "an EMPTY_BUFFER_DONE.", buffer);
             }
 
@@ -2302,7 +2302,7 @@
             BufferInfo *info = &buffers->editItemAt(i);
 
             if (info->mStatus != OWNED_BY_COMPONENT) {
-                LOGW("We already own output buffer %p, yet received "
+                ALOGW("We already own output buffer %p, yet received "
                      "a FILL_BUFFER_DONE.", buffer);
             }
 
@@ -2568,7 +2568,7 @@
                         // The scale is in 16.16 format.
                         // scale 1.0 = 0x010000. When there is no
                         // need to change the display, skip it.
-                        LOGV("Get OMX_IndexConfigScale: 0x%lx/0x%lx",
+                        ALOGV("Get OMX_IndexConfigScale: 0x%lx/0x%lx",
                                 scale.xWidth, scale.xHeight);
 
                         if (scale.xWidth != 0x010000) {
@@ -3296,7 +3296,7 @@
     }
 
     if (n > 1) {
-        LOGV("coalesced %d frames into one input buffer", n);
+        ALOGV("coalesced %d frames into one input buffer", n);
     }
 
     OMX_U32 flags = OMX_BUFFERFLAG_ENDOFFRAME;
@@ -3556,7 +3556,7 @@
 
 status_t OMXCodec::setAACFormat(int32_t numChannels, int32_t sampleRate, int32_t bitRate) {
     if (numChannels > 2)
-        LOGW("Number of channels: (%d) \n", numChannels);
+        ALOGW("Number of channels: (%d) \n", numChannels);
 
     if (mIsEncoder) {
         //////////////// input port ////////////////////
@@ -4466,14 +4466,14 @@
                 inputFormat->findInt32(kKeySampleRate, &sampleRate);
 
                 if ((OMX_U32)numChannels != params.nChannels) {
-                    LOGV("Codec outputs a different number of channels than "
+                    ALOGV("Codec outputs a different number of channels than "
                          "the input stream contains (contains %d channels, "
                          "codec outputs %ld channels).",
                          numChannels, params.nChannels);
                 }
 
                 if (sampleRate != (int32_t)params.nSamplingRate) {
-                    LOGV("Codec outputs at different sampling rate than "
+                    ALOGV("Codec outputs at different sampling rate than "
                          "what the input stream contains (contains data at "
                          "%d Hz, codec outputs %lu Hz)",
                          sampleRate, params.nSamplingRate);
diff --git a/media/libstagefright/OggExtractor.cpp b/media/libstagefright/OggExtractor.cpp
index 29e6907..73efc27 100644
--- a/media/libstagefright/OggExtractor.cpp
+++ b/media/libstagefright/OggExtractor.cpp
@@ -189,9 +189,9 @@
 #if 0
     int64_t timeUs;
     if (packet->meta_data()->findInt64(kKeyTime, &timeUs)) {
-        LOGI("found time = %lld us", timeUs);
+        ALOGI("found time = %lld us", timeUs);
     } else {
-        LOGI("NO time");
+        ALOGI("NO time");
     }
 #endif
 
@@ -244,7 +244,7 @@
 
         if (!memcmp(signature, "OggS", 4)) {
             if (*pageOffset > startOffset) {
-                LOGV("skipped %lld bytes of junk to reach next frame",
+                ALOGV("skipped %lld bytes of junk to reach next frame",
                      *pageOffset - startOffset);
             }
 
@@ -272,7 +272,7 @@
             prevGuess = 0;
         }
 
-        LOGV("backing up %lld bytes", pageOffset - prevGuess);
+        ALOGV("backing up %lld bytes", pageOffset - prevGuess);
 
         status_t err = findNextPage(prevGuess, &prevPageOffset);
         if (err != OK) {
@@ -289,7 +289,7 @@
         return UNKNOWN_ERROR;
     }
 
-    LOGV("prevPageOffset at %lld, pageOffset at %lld",
+    ALOGV("prevPageOffset at %lld, pageOffset at %lld",
          prevPageOffset, pageOffset);
 
     for (;;) {
@@ -315,7 +315,7 @@
 
         off64_t pos = timeUs * approxBitrate() / 8000000ll;
 
-        LOGV("seeking to offset %lld", pos);
+        ALOGV("seeking to offset %lld", pos);
         return seekToOffset(pos);
     }
 
@@ -338,7 +338,7 @@
 
     const TOCEntry &entry = mTableOfContents.itemAt(left);
 
-    LOGV("seeking to entry %d / %d at offset %lld",
+    ALOGV("seeking to entry %d / %d at offset %lld",
          left, mTableOfContents.size(), entry.mPageOffset);
 
     return seekToOffset(entry.mPageOffset);
@@ -381,7 +381,7 @@
     ssize_t n;
     if ((n = mSource->readAt(offset, header, sizeof(header)))
             < (ssize_t)sizeof(header)) {
-        LOGV("failed to read %d bytes at offset 0x%016llx, got %ld bytes",
+        ALOGV("failed to read %d bytes at offset 0x%016llx, got %ld bytes",
              sizeof(header), offset, n);
 
         if (n < 0) {
@@ -441,7 +441,7 @@
         tmp.append(x);
     }
 
-    LOGV("%c %s", page->mFlags & 1 ? '+' : ' ', tmp.string());
+    ALOGV("%c %s", page->mFlags & 1 ? '+' : ' ', tmp.string());
 #endif
 
     return sizeof(header) + page->mNumSegments + totalSize;
@@ -505,7 +505,7 @@
                     packetSize);
 
             if (n < (ssize_t)packetSize) {
-                LOGV("failed to read %d bytes at 0x%016llx, got %ld bytes",
+                ALOGV("failed to read %d bytes at 0x%016llx, got %ld bytes",
                      packetSize, dataOffset, n);
                 return ERROR_IO;
             }
@@ -546,7 +546,7 @@
                 buffer = NULL;
             }
 
-            LOGV("readPage returned %ld", n);
+            ALOGV("readPage returned %ld", n);
 
             return n < 0 ? n : (status_t)ERROR_END_OF_STREAM;
         }
@@ -590,7 +590,7 @@
     if ((err = readNextPacket(&packet)) != OK) {
         return err;
     }
-    LOGV("read packet of size %d\n", packet->range_length());
+    ALOGV("read packet of size %d\n", packet->range_length());
     err = verifyHeader(packet, 1);
     packet->release();
     packet = NULL;
@@ -601,7 +601,7 @@
     if ((err = readNextPacket(&packet)) != OK) {
         return err;
     }
-    LOGV("read packet of size %d\n", packet->range_length());
+    ALOGV("read packet of size %d\n", packet->range_length());
     err = verifyHeader(packet, 3);
     packet->release();
     packet = NULL;
@@ -612,7 +612,7 @@
     if ((err = readNextPacket(&packet)) != OK) {
         return err;
     }
-    LOGV("read packet of size %d\n", packet->range_length());
+    ALOGV("read packet of size %d\n", packet->range_length());
     err = verifyHeader(packet, 5);
     packet->release();
     packet = NULL;
@@ -722,10 +722,10 @@
             mMeta->setInt32(kKeySampleRate, mVi.rate);
             mMeta->setInt32(kKeyChannelCount, mVi.channels);
 
-            LOGV("lower-bitrate = %ld", mVi.bitrate_lower);
-            LOGV("upper-bitrate = %ld", mVi.bitrate_upper);
-            LOGV("nominal-bitrate = %ld", mVi.bitrate_nominal);
-            LOGV("window-bitrate = %ld", mVi.bitrate_window);
+            ALOGV("lower-bitrate = %ld", mVi.bitrate_lower);
+            ALOGV("upper-bitrate = %ld", mVi.bitrate_upper);
+            ALOGV("nominal-bitrate = %ld", mVi.bitrate_nominal);
+            ALOGV("window-bitrate = %ld", mVi.bitrate_window);
 
             off64_t size;
             if (mSource->getSize(&size) == OK) {
@@ -777,7 +777,7 @@
         const char *comment = mVc.user_comments[i];
         size_t commentLength = mVc.comment_lengths[i];
         parseVorbisComment(mFileMeta, comment, commentLength);
-        //LOGI("comment #%d: '%s'", i + 1, mVc.user_comments[i]);
+        //ALOGI("comment #%d: '%s'", i + 1, mVc.user_comments[i]);
     }
 }
 
@@ -893,17 +893,17 @@
 
 static void extractAlbumArt(
         const sp<MetaData> &fileMeta, const void *data, size_t size) {
-    LOGV("extractAlbumArt from '%s'", (const char *)data);
+    ALOGV("extractAlbumArt from '%s'", (const char *)data);
 
     size_t flacSize;
     uint8_t *flac = DecodeBase64((const char *)data, size, &flacSize);
 
     if (flac == NULL) {
-        LOGE("malformed base64 encoded data.");
+        ALOGE("malformed base64 encoded data.");
         return;
     }
 
-    LOGV("got flac of size %d", flacSize);
+    ALOGV("got flac of size %d", flacSize);
 
     uint32_t picType;
     uint32_t typeLen;
@@ -934,7 +934,7 @@
     memcpy(type, &flac[8], typeLen);
     type[typeLen] = '\0';
 
-    LOGV("picType = %d, type = '%s'", picType, type);
+    ALOGV("picType = %d, type = '%s'", picType, type);
 
     if (!strcmp(type, "-->")) {
         // This is not inline cover art, but an external url instead.
@@ -953,7 +953,7 @@
         goto exit;
     }
 
-    LOGV("got image data, %d trailing bytes",
+    ALOGV("got image data, %d trailing bytes",
          flacSize - 32 - typeLen - descLen - dataLen);
 
     fileMeta->setData(
diff --git a/media/libstagefright/SampleIterator.cpp b/media/libstagefright/SampleIterator.cpp
index c7b00b1..81ec5c1 100644
--- a/media/libstagefright/SampleIterator.cpp
+++ b/media/libstagefright/SampleIterator.cpp
@@ -52,7 +52,7 @@
 }
 
 status_t SampleIterator::seekTo(uint32_t sampleIndex) {
-    LOGV("seekTo(%d)", sampleIndex);
+    ALOGV("seekTo(%d)", sampleIndex);
 
     if (sampleIndex >= mTable->mNumSampleSizes) {
         return ERROR_END_OF_STREAM;
@@ -77,7 +77,7 @@
     if (sampleIndex >= mStopChunkSampleIndex) {
         status_t err;
         if ((err = findChunkRange(sampleIndex)) != OK) {
-            LOGE("findChunkRange failed");
+            ALOGE("findChunkRange failed");
             return err;
         }
     }
@@ -93,7 +93,7 @@
 
         status_t err;
         if ((err = getChunkOffset(chunk, &mCurrentChunkOffset)) != OK) {
-            LOGE("getChunkOffset return error");
+            ALOGE("getChunkOffset return error");
             return err;
         }
 
@@ -107,7 +107,7 @@
             size_t sampleSize;
             if ((err = getSampleSizeDirect(
                             firstChunkSampleIndex + i, &sampleSize)) != OK) {
-                LOGE("getSampleSizeDirect return error");
+                ALOGE("getSampleSizeDirect return error");
                 return err;
             }
 
@@ -134,7 +134,7 @@
 
     status_t err;
     if ((err = findSampleTime(sampleIndex, &mCurrentSampleTime)) != OK) {
-        LOGE("findSampleTime return error");
+        ALOGE("findSampleTime return error");
         return err;
     }
 
diff --git a/media/libstagefright/SampleTable.cpp b/media/libstagefright/SampleTable.cpp
index bf31947..d9858d7 100644
--- a/media/libstagefright/SampleTable.cpp
+++ b/media/libstagefright/SampleTable.cpp
@@ -347,7 +347,7 @@
 
 status_t SampleTable::setCompositionTimeToSampleParams(
         off64_t data_offset, size_t data_size) {
-    LOGI("There are reordered frames present.");
+    ALOGI("There are reordered frames present.");
 
     if (mCompositionTimeDeltaEntries != NULL || data_size < 8) {
         return ERROR_MALFORMED;
@@ -414,7 +414,7 @@
     mNumSyncSamples = U32_AT(&header[4]);
 
     if (mNumSyncSamples < 2) {
-        LOGV("Table of sync samples is empty or has only a single entry!");
+        ALOGV("Table of sync samples is empty or has only a single entry!");
     }
 
     mSyncSamples = new uint32_t[mNumSyncSamples];
@@ -618,26 +618,31 @@
     }
 
     uint32_t left = 0;
-    while (left < mNumSyncSamples) {
-        uint32_t x = mSyncSamples[left];
+    uint32_t right = mNumSyncSamples;
+    while (left < right) {
+        uint32_t center = left + (right - left) / 2;
+        uint32_t x = mSyncSamples[center];
 
-        if (x >= start_sample_index) {
+        if (start_sample_index < x) {
+            right = center;
+        } else if (start_sample_index > x) {
+            left = center + 1;
+        } else {
+            left = center;
             break;
         }
-
-        ++left;
     }
-
     if (left == mNumSyncSamples) {
         if (flags == kFlagAfter) {
-            LOGE("tried to find a sync frame after the last one: %d", left);
+            ALOGE("tried to find a sync frame after the last one: %d", left);
             return ERROR_OUT_OF_RANGE;
         }
+        left = left - 1;
     }
 
-    if (left > 0) {
-        --left;
-    }
+    // Now ssi[left] is the sync sample index just before (or at)
+    // start_sample_index.
+    // Also start_sample_index < ssi[left + 1], if left + 1 < mNumSyncSamples.
 
     uint32_t x = mSyncSamples[left];
 
@@ -682,7 +687,11 @@
 
                 x = mSyncSamples[left - 1];
 
-                CHECK(x <= start_sample_index);
+                if (x > start_sample_index) {
+                    // The table of sync sample indices was not sorted
+                    // properly.
+                    return ERROR_MALFORMED;
+                }
             }
             break;
         }
@@ -696,7 +705,11 @@
 
                 x = mSyncSamples[left + 1];
 
-                CHECK(x >= start_sample_index);
+                if (x < start_sample_index) {
+                    // The table of sync sample indices was not sorted
+                    // properly.
+                    return ERROR_MALFORMED;
+                }
             }
 
             break;
diff --git a/media/libstagefright/StagefrightMediaScanner.cpp b/media/libstagefright/StagefrightMediaScanner.cpp
index 2505096..bd7a226 100644
--- a/media/libstagefright/StagefrightMediaScanner.cpp
+++ b/media/libstagefright/StagefrightMediaScanner.cpp
@@ -57,7 +57,7 @@
     // get the library configuration and do sanity check
     const S_EAS_LIB_CONFIG* pLibConfig = EAS_Config();
     if ((pLibConfig == NULL) || (LIB_VERSION != pLibConfig->libVersion)) {
-        LOGE("EAS library/header mismatch\n");
+        ALOGE("EAS library/header mismatch\n");
         return MEDIA_SCAN_RESULT_ERROR;
     }
     EAS_I32 temp;
@@ -103,7 +103,7 @@
 MediaScanResult StagefrightMediaScanner::processFile(
         const char *path, const char *mimeType,
         MediaScannerClient &client) {
-    LOGV("processFile '%s'.", path);
+    ALOGV("processFile '%s'.", path);
 
     client.setLocale(locale());
     client.beginFile();
@@ -188,7 +188,7 @@
 }
 
 char *StagefrightMediaScanner::extractAlbumArt(int fd) {
-    LOGV("extractAlbumArt %d", fd);
+    ALOGV("extractAlbumArt %d", fd);
 
     off64_t size = lseek64(fd, 0, SEEK_END);
     if (size < 0) {
diff --git a/media/libstagefright/StagefrightMetadataRetriever.cpp b/media/libstagefright/StagefrightMetadataRetriever.cpp
index 4491c97..43bfd9e 100644
--- a/media/libstagefright/StagefrightMetadataRetriever.cpp
+++ b/media/libstagefright/StagefrightMetadataRetriever.cpp
@@ -34,14 +34,14 @@
 StagefrightMetadataRetriever::StagefrightMetadataRetriever()
     : mParsedMetaData(false),
       mAlbumArt(NULL) {
-    LOGV("StagefrightMetadataRetriever()");
+    ALOGV("StagefrightMetadataRetriever()");
 
     DataSource::RegisterDefaultSniffers();
     CHECK_EQ(mClient.connect(), OK);
 }
 
 StagefrightMetadataRetriever::~StagefrightMetadataRetriever() {
-    LOGV("~StagefrightMetadataRetriever()");
+    ALOGV("~StagefrightMetadataRetriever()");
 
     delete mAlbumArt;
     mAlbumArt = NULL;
@@ -51,7 +51,7 @@
 
 status_t StagefrightMetadataRetriever::setDataSource(
         const char *uri, const KeyedVector<String8, String8> *headers) {
-    LOGV("setDataSource(%s)", uri);
+    ALOGV("setDataSource(%s)", uri);
 
     mParsedMetaData = false;
     mMetaData.clear();
@@ -80,7 +80,7 @@
         int fd, int64_t offset, int64_t length) {
     fd = dup(fd);
 
-    LOGV("setDataSource(%d, %lld, %lld)", fd, offset, length);
+    ALOGV("setDataSource(%d, %lld, %lld)", fd, offset, length);
 
     mParsedMetaData = false;
     mMetaData.clear();
@@ -120,14 +120,14 @@
                 NULL, flags | OMXCodec::kClientNeedsFramebuffer);
 
     if (decoder.get() == NULL) {
-        LOGV("unable to instantiate video decoder.");
+        ALOGV("unable to instantiate video decoder.");
 
         return NULL;
     }
 
     status_t err = decoder->start();
     if (err != OK) {
-        LOGW("OMXCodec::start returned error %d (0x%08x)\n", err, err);
+        ALOGW("OMXCodec::start returned error %d (0x%08x)\n", err, err);
         return NULL;
     }
 
@@ -138,7 +138,7 @@
     if (seekMode < MediaSource::ReadOptions::SEEK_PREVIOUS_SYNC ||
         seekMode > MediaSource::ReadOptions::SEEK_CLOSEST) {
 
-        LOGE("Unknown seek mode: %d", seekMode);
+        ALOGE("Unknown seek mode: %d", seekMode);
         return NULL;
     }
 
@@ -171,18 +171,18 @@
     if (err != OK) {
         CHECK_EQ(buffer, NULL);
 
-        LOGV("decoding frame failed.");
+        ALOGV("decoding frame failed.");
         decoder->stop();
 
         return NULL;
     }
 
-    LOGV("successfully decoded video frame.");
+    ALOGV("successfully decoded video frame.");
 
     int32_t unreadable;
     if (buffer->meta_data()->findInt32(kKeyIsUnreadable, &unreadable)
             && unreadable != 0) {
-        LOGV("video frame is unreadable, decoder does not give us access "
+        ALOGV("video frame is unreadable, decoder does not give us access "
              "to the video data.");
 
         buffer->release();
@@ -200,7 +200,7 @@
             const char *mime;
             CHECK(trackMeta->findCString(kKeyMIMEType, &mime));
 
-            LOGV("thumbNailTime = %lld us, timeUs = %lld us, mime = %s",
+            ALOGV("thumbNailTime = %lld us, timeUs = %lld us, mime = %s",
                  thumbNailTime, timeUs, mime);
         }
     }
@@ -264,7 +264,7 @@
     decoder->stop();
 
     if (err != OK) {
-        LOGE("Colorconverter failed to convert frame.");
+        ALOGE("Colorconverter failed to convert frame.");
 
         delete frame;
         frame = NULL;
@@ -276,23 +276,23 @@
 VideoFrame *StagefrightMetadataRetriever::getFrameAtTime(
         int64_t timeUs, int option) {
 
-    LOGV("getFrameAtTime: %lld us option: %d", timeUs, option);
+    ALOGV("getFrameAtTime: %lld us option: %d", timeUs, option);
 
     if (mExtractor.get() == NULL) {
-        LOGV("no extractor.");
+        ALOGV("no extractor.");
         return NULL;
     }
 
     sp<MetaData> fileMeta = mExtractor->getMetaData();
 
     if (fileMeta == NULL) {
-        LOGV("extractor doesn't publish metadata, failed to initialize?");
+        ALOGV("extractor doesn't publish metadata, failed to initialize?");
         return NULL;
     }
 
     int32_t drm = 0;
     if (fileMeta->findInt32(kKeyIsDRM, &drm) && drm != 0) {
-        LOGE("frame grab not allowed.");
+        ALOGE("frame grab not allowed.");
         return NULL;
     }
 
@@ -310,7 +310,7 @@
     }
 
     if (i == n) {
-        LOGV("no video track found.");
+        ALOGV("no video track found.");
         return NULL;
     }
 
@@ -320,7 +320,7 @@
     sp<MediaSource> source = mExtractor->getTrack(i);
 
     if (source.get() == NULL) {
-        LOGV("unable to instantiate video track.");
+        ALOGV("unable to instantiate video track.");
         return NULL;
     }
 
@@ -341,7 +341,7 @@
                 timeUs, option);
 
     if (frame == NULL) {
-        LOGV("Software decoder failed to extract thumbnail, "
+        ALOGV("Software decoder failed to extract thumbnail, "
              "trying hardware decoder.");
 
         frame = extractVideoFrameWithCodecFlags(&mClient, trackMeta, source, 0,
@@ -352,7 +352,7 @@
 }
 
 MediaAlbumArt *StagefrightMetadataRetriever::extractAlbumArt() {
-    LOGV("extractAlbumArt (extractor: %s)", mExtractor.get() != NULL ? "YES" : "NO");
+    ALOGV("extractAlbumArt (extractor: %s)", mExtractor.get() != NULL ? "YES" : "NO");
 
     if (mExtractor == NULL) {
         return NULL;
@@ -395,7 +395,7 @@
     sp<MetaData> meta = mExtractor->getMetaData();
 
     if (meta == NULL) {
-        LOGV("extractor doesn't publish metadata, failed to initialize?");
+        ALOGV("extractor doesn't publish metadata, failed to initialize?");
         return;
     }
 
diff --git a/media/libstagefright/SurfaceMediaSource.cpp b/media/libstagefright/SurfaceMediaSource.cpp
index 38daf72..2233d1b 100644
--- a/media/libstagefright/SurfaceMediaSource.cpp
+++ b/media/libstagefright/SurfaceMediaSource.cpp
@@ -32,6 +32,8 @@
 #include <utils/Log.h>
 #include <utils/String8.h>
 
+#include <private/gui/ComposerService.h>
+
 namespace android {
 
 SurfaceMediaSource::SurfaceMediaSource(uint32_t bufW, uint32_t bufH) :
@@ -50,13 +52,13 @@
                 mNumFramesReceived(0),
                 mNumFramesEncoded(0),
                 mFirstFrameTimestamp(0) {
-    LOGV("SurfaceMediaSource::SurfaceMediaSource");
+    ALOGV("SurfaceMediaSource::SurfaceMediaSource");
     sp<ISurfaceComposer> composer(ComposerService::getComposerService());
     mGraphicBufferAlloc = composer->createGraphicBufferAlloc();
 }
 
 SurfaceMediaSource::~SurfaceMediaSource() {
-    LOGV("SurfaceMediaSource::~SurfaceMediaSource");
+    ALOGV("SurfaceMediaSource::~SurfaceMediaSource");
     if (!mStopped) {
         stop();
     }
@@ -108,9 +110,9 @@
 }
 
 status_t SurfaceMediaSource::setBufferCount(int bufferCount) {
-    LOGV("SurfaceMediaSource::setBufferCount");
+    ALOGV("SurfaceMediaSource::setBufferCount");
     if (bufferCount > NUM_BUFFER_SLOTS) {
-        LOGE("setBufferCount: bufferCount is larger than the number of buffer slots");
+        ALOGE("setBufferCount: bufferCount is larger than the number of buffer slots");
         return BAD_VALUE;
     }
 
@@ -118,7 +120,7 @@
     // Error out if the user has dequeued buffers
     for (int i = 0 ; i < mBufferCount ; i++) {
         if (mSlots[i].mBufferState == BufferSlot::DEQUEUED) {
-            LOGE("setBufferCount: client owns some buffers");
+            ALOGE("setBufferCount: client owns some buffers");
             return INVALID_OPERATION;
         }
     }
@@ -150,10 +152,10 @@
 }
 
 status_t SurfaceMediaSource::requestBuffer(int slot, sp<GraphicBuffer>* buf) {
-    LOGV("SurfaceMediaSource::requestBuffer");
+    ALOGV("SurfaceMediaSource::requestBuffer");
     Mutex::Autolock lock(mMutex);
     if (slot < 0 || mBufferCount <= slot) {
-        LOGE("requestBuffer: slot index out of range [0, %d]: %d",
+        ALOGE("requestBuffer: slot index out of range [0, %d]: %d",
                 mBufferCount, slot);
         return BAD_VALUE;
     }
@@ -164,7 +166,7 @@
 
 status_t SurfaceMediaSource::dequeueBuffer(int *outBuf, uint32_t w, uint32_t h,
                                             uint32_t format, uint32_t usage) {
-    LOGV("dequeueBuffer");
+    ALOGV("dequeueBuffer");
     Mutex::Autolock lock(mMutex);
 
     // Check for the buffer size- the client should just use the
@@ -181,7 +183,7 @@
     // we might declare mHeight and mWidth and check against those here.
     if ((w != 0) || (h != 0)) {
         if ((w != mDefaultWidth) || (h != mDefaultHeight)) {
-            LOGE("dequeuebuffer: invalid buffer size! Req: %dx%d, Found: %dx%d",
+            ALOGE("dequeuebuffer: invalid buffer size! Req: %dx%d, Found: %dx%d",
                     mDefaultWidth, mDefaultHeight, w, h);
             return BAD_VALUE;
         }
@@ -215,7 +217,7 @@
                         (mServerBufferCount < minBufferCountNeeded))) {
             // wait for the FIFO to drain
             while (!mQueue.isEmpty()) {
-                LOGV("Waiting for the FIFO to drain");
+                ALOGV("Waiting for the FIFO to drain");
                 mDequeueCondition.wait(mMutex);
             }
             if (mStopped) {
@@ -282,7 +284,7 @@
             // than allowed.
             const int avail = mBufferCount - (dequeuedCount+1);
             if (avail < (MIN_UNDEQUEUED_BUFFERS-int(mSynchronousMode))) {
-                LOGE("dequeueBuffer: MIN_UNDEQUEUED_BUFFERS=%d exceeded (dequeued=%d)",
+                ALOGE("dequeueBuffer: MIN_UNDEQUEUED_BUFFERS=%d exceeded (dequeued=%d)",
                         MIN_UNDEQUEUED_BUFFERS-int(mSynchronousMode),
                         dequeuedCount);
                 return -EBUSY;
@@ -293,7 +295,7 @@
         // for for some buffers to be consumed
         tryAgain = mSynchronousMode && (foundSync == INVALID_BUFFER_SLOT);
         if (tryAgain) {
-            LOGV("Waiting..In synchronous mode and no buffer to dequeue");
+            ALOGV("Waiting..In synchronous mode and no buffer to dequeue");
             mDequeueCondition.wait(mMutex);
         }
         if (mStopped) {
@@ -344,7 +346,7 @@
                     mGraphicBufferAlloc->createGraphicBuffer(
                                     w, h, format, usage, &error));
             if (graphicBuffer == 0) {
-                LOGE("dequeueBuffer: SurfaceComposer::createGraphicBuffer failed");
+                ALOGE("dequeueBuffer: SurfaceComposer::createGraphicBuffer failed");
                 return error;
             }
             if (updateFormat) {
@@ -361,13 +363,13 @@
 status_t SurfaceMediaSource::setSynchronousMode(bool enabled) {
     Mutex::Autolock lock(mMutex);
     if (mStopped) {
-        LOGE("setSynchronousMode: SurfaceMediaSource has been stopped!");
+        ALOGE("setSynchronousMode: SurfaceMediaSource has been stopped!");
         return NO_INIT;
     }
 
     if (!enabled) {
         // Async mode is not allowed
-        LOGE("SurfaceMediaSource can be used only synchronous mode!");
+        ALOGE("SurfaceMediaSource can be used only synchronous mode!");
         return INVALID_OPERATION;
     }
 
@@ -384,11 +386,11 @@
 
 status_t SurfaceMediaSource::connect(int api,
         uint32_t* outWidth, uint32_t* outHeight, uint32_t* outTransform) {
-    LOGV("SurfaceMediaSource::connect");
+    ALOGV("SurfaceMediaSource::connect");
     Mutex::Autolock lock(mMutex);
 
     if (mStopped) {
-        LOGE("Connect: SurfaceMediaSource has been stopped!");
+        ALOGE("Connect: SurfaceMediaSource has been stopped!");
         return NO_INIT;
     }
 
@@ -425,11 +427,11 @@
 // that need not be required since the thread supplying the
 // frames is separate than the one calling stop.
 status_t SurfaceMediaSource::disconnect(int api) {
-    LOGV("SurfaceMediaSource::disconnect");
+    ALOGV("SurfaceMediaSource::disconnect");
     Mutex::Autolock lock(mMutex);
 
     if (mStopped) {
-        LOGE("disconnect: SurfaceMediaSoource is already stopped!");
+        ALOGE("disconnect: SurfaceMediaSoource is already stopped!");
         return NO_INIT;
     }
 
@@ -457,7 +459,7 @@
 
 status_t SurfaceMediaSource::queueBuffer(int bufIndex, int64_t timestamp,
         uint32_t* outWidth, uint32_t* outHeight, uint32_t* outTransform) {
-    LOGV("queueBuffer");
+    ALOGV("queueBuffer");
 
     Mutex::Autolock lock(mMutex);
     *outWidth = mDefaultWidth;
@@ -465,15 +467,15 @@
     *outTransform = 0;
 
     if (bufIndex < 0 || bufIndex >= mBufferCount) {
-        LOGE("queueBuffer: slot index out of range [0, %d]: %d",
+        ALOGE("queueBuffer: slot index out of range [0, %d]: %d",
                 mBufferCount, bufIndex);
         return -EINVAL;
     } else if (mSlots[bufIndex].mBufferState != BufferSlot::DEQUEUED) {
-        LOGE("queueBuffer: slot %d is not owned by the client (state=%d)",
+        ALOGE("queueBuffer: slot %d is not owned by the client (state=%d)",
                 bufIndex, mSlots[bufIndex].mBufferState);
         return -EINVAL;
     } else if (!mSlots[bufIndex].mRequestBufferCalled) {
-        LOGE("queueBuffer: slot %d was enqueued without requesting a "
+        ALOGE("queueBuffer: slot %d was enqueued without requesting a "
                 "buffer", bufIndex);
         return -EINVAL;
     }
@@ -497,7 +499,7 @@
     if (mSynchronousMode) {
         // in synchronous mode we queue all buffers in a FIFO
         mQueue.push_back(bufIndex);
-        LOGV("Client queued buf# %d @slot: %d, Q size = %d, handle = %p, timestamp = %lld",
+        ALOGV("Client queued buf# %d @slot: %d, Q size = %d, handle = %p, timestamp = %lld",
             mNumFramesReceived, bufIndex, mQueue.size(),
             mSlots[bufIndex].mGraphicBuffer->handle, timestamp);
     } else {
@@ -536,7 +538,7 @@
 // wait to hear from StageFrightRecorder to set the buffer FREE
 // Make sure this is called when the mutex is locked
 status_t SurfaceMediaSource::onFrameReceivedLocked() {
-    LOGV("On Frame Received locked");
+    ALOGV("On Frame Received locked");
     // Signal the encoder that a new frame has arrived
     mFrameAvailableCondition.signal();
 
@@ -556,14 +558,14 @@
 
 
 void SurfaceMediaSource::cancelBuffer(int bufIndex) {
-    LOGV("SurfaceMediaSource::cancelBuffer");
+    ALOGV("SurfaceMediaSource::cancelBuffer");
     Mutex::Autolock lock(mMutex);
     if (bufIndex < 0 || bufIndex >= mBufferCount) {
-        LOGE("cancelBuffer: slot index out of range [0, %d]: %d",
+        ALOGE("cancelBuffer: slot index out of range [0, %d]: %d",
                 mBufferCount, bufIndex);
         return;
     } else if (mSlots[bufIndex].mBufferState != BufferSlot::DEQUEUED) {
-        LOGE("cancelBuffer: slot %d is not owned by the client (state=%d)",
+        ALOGE("cancelBuffer: slot %d is not owned by the client (state=%d)",
                 bufIndex, mSlots[bufIndex].mBufferState);
         return;
     }
@@ -572,7 +574,7 @@
 }
 
 nsecs_t SurfaceMediaSource::getTimestamp() {
-    LOGV("SurfaceMediaSource::getTimestamp");
+    ALOGV("SurfaceMediaSource::getTimestamp");
     Mutex::Autolock lock(mMutex);
     return mCurrentTimestamp;
 }
@@ -580,13 +582,13 @@
 
 void SurfaceMediaSource::setFrameAvailableListener(
         const sp<FrameAvailableListener>& listener) {
-    LOGV("SurfaceMediaSource::setFrameAvailableListener");
+    ALOGV("SurfaceMediaSource::setFrameAvailableListener");
     Mutex::Autolock lock(mMutex);
     mFrameAvailableListener = listener;
 }
 
 void SurfaceMediaSource::freeAllBuffersLocked() {
-    LOGV("freeAllBuffersLocked");
+    ALOGV("freeAllBuffersLocked");
     for (int i = 0; i < NUM_BUFFER_SLOTS; i++) {
         mSlots[i].mGraphicBuffer = 0;
         mSlots[i].mBufferState = BufferSlot::FREE;
@@ -600,7 +602,7 @@
 
 int SurfaceMediaSource::query(int what, int* outValue)
 {
-    LOGV("query");
+    ALOGV("query");
     Mutex::Autolock lock(mMutex);
     int value;
     switch (what) {
@@ -691,7 +693,7 @@
 }
 
 bool SurfaceMediaSource::isMetaDataStoredInVideoBuffers() const {
-    LOGV("isMetaDataStoredInVideoBuffers");
+    ALOGV("isMetaDataStoredInVideoBuffers");
     return true;
 }
 
@@ -702,7 +704,7 @@
 
 status_t SurfaceMediaSource::start(MetaData *params)
 {
-    LOGV("started!");
+    ALOGV("started!");
 
     mStartTimeNs = 0;
     int64_t startTimeUs;
@@ -716,7 +718,7 @@
 
 status_t SurfaceMediaSource::stop()
 {
-    LOGV("Stop");
+    ALOGV("Stop");
 
     Mutex::Autolock lock(mMutex);
     // TODO: Add waiting on mFrameCompletedCondition here?
@@ -731,7 +733,7 @@
 
 sp<MetaData> SurfaceMediaSource::getFormat()
 {
-    LOGV("getFormat");
+    ALOGV("getFormat");
     Mutex::Autolock autoLock(mMutex);
     sp<MetaData> meta = new MetaData;
 
@@ -753,20 +755,20 @@
 {
     Mutex::Autolock autoLock(mMutex) ;
 
-    LOGV("Read. Size of queued buffer: %d", mQueue.size());
+    ALOGV("Read. Size of queued buffer: %d", mQueue.size());
     *buffer = NULL;
 
     // If the recording has started and the queue is empty, then just
     // wait here till the frames come in from the client side
     while (!mStopped && mQueue.empty()) {
-        LOGV("NO FRAMES! Recorder waiting for FrameAvailableCondition");
+        ALOGV("NO FRAMES! Recorder waiting for FrameAvailableCondition");
         mFrameAvailableCondition.wait(mMutex);
     }
 
     // If the loop was exited as a result of stopping the recording,
     // it is OK
     if (mStopped) {
-        LOGV("Read: SurfaceMediaSource is stopped. Returning ERROR_END_OF_STREAM.");
+        ALOGV("Read: SurfaceMediaSource is stopped. Returning ERROR_END_OF_STREAM.");
         return ERROR_END_OF_STREAM;
     }
 
@@ -787,7 +789,7 @@
     (*buffer)->setObserver(this);
     (*buffer)->add_ref();
     (*buffer)->meta_data()->setInt64(kKeyTime, mCurrentTimestamp / 1000);
-    LOGV("Frames encoded = %d, timestamp = %lld, time diff = %lld",
+    ALOGV("Frames encoded = %d, timestamp = %lld, time diff = %lld",
             mNumFramesEncoded, mCurrentTimestamp / 1000,
             mCurrentTimestamp / 1000 - prevTimeStamp / 1000);
 
@@ -806,13 +808,13 @@
 // --------------------------------------------------------------
 // Note: Call only when you have the lock
 void SurfaceMediaSource::passMetadataBufferLocked(MediaBuffer **buffer) {
-    LOGV("passMetadataBuffer");
+    ALOGV("passMetadataBuffer");
     // MediaBuffer allocates and owns this data
     MediaBuffer *tempBuffer =
         new MediaBuffer(4 + sizeof(buffer_handle_t));
     char *data = (char *)tempBuffer->data();
     if (data == NULL) {
-        LOGE("Cannot allocate memory for metadata buffer!");
+        ALOGE("Cannot allocate memory for metadata buffer!");
         return;
     }
     OMX_U32 type = kMetadataBufferTypeGrallocSource;
@@ -820,18 +822,18 @@
     memcpy(data + 4, &(mCurrentBuf->handle), sizeof(buffer_handle_t));
     *buffer = tempBuffer;
 
-    LOGV("handle = %p, , offset = %d, length = %d",
+    ALOGV("handle = %p, , offset = %d, length = %d",
             mCurrentBuf->handle, (*buffer)->range_length(), (*buffer)->range_offset());
 }
 
 void SurfaceMediaSource::signalBufferReturned(MediaBuffer *buffer) {
-    LOGV("signalBufferReturned");
+    ALOGV("signalBufferReturned");
 
     bool foundBuffer = false;
     Mutex::Autolock autoLock(mMutex);
 
     if (mStopped) {
-        LOGV("signalBufferReturned: mStopped = true! Nothing to do!");
+        ALOGV("signalBufferReturned: mStopped = true! Nothing to do!");
         return;
     }
 
@@ -840,7 +842,7 @@
             continue;
         }
         if (checkBufferMatchesSlot(id, buffer)) {
-            LOGV("Slot %d returned, matches handle = %p", id,
+            ALOGV("Slot %d returned, matches handle = %p", id,
                     mSlots[id].mGraphicBuffer->handle);
             mSlots[id].mBufferState = BufferSlot::FREE;
             buffer->setObserver(0);
@@ -858,7 +860,7 @@
 }
 
 bool SurfaceMediaSource::checkBufferMatchesSlot(int slot, MediaBuffer *buffer) {
-    LOGV("Check if Buffer matches slot");
+    ALOGV("Check if Buffer matches slot");
     // need to convert to char* for pointer arithmetic and then
     // copy the byte stream into our handle
     buffer_handle_t bufferHandle ;
diff --git a/media/libstagefright/TimedEventQueue.cpp b/media/libstagefright/TimedEventQueue.cpp
index 100d8a3..12c9c36 100644
--- a/media/libstagefright/TimedEventQueue.cpp
+++ b/media/libstagefright/TimedEventQueue.cpp
@@ -173,7 +173,7 @@
             mQueueHeadChangedCondition.signal();
         }
 
-        LOGV("cancelling event %d", (*it).event->eventID());
+        ALOGV("cancelling event %d", (*it).event->eventID());
 
         (*it).event->setEventID(0);
         it = mQueue.erase(it);
@@ -265,7 +265,7 @@
                 static int64_t kMaxTimeoutUs = 10000000ll;  // 10 secs
                 bool timeoutCapped = false;
                 if (delay_us > kMaxTimeoutUs) {
-                    LOGW("delay_us exceeds max timeout: %lld us", delay_us);
+                    ALOGW("delay_us exceeds max timeout: %lld us", delay_us);
 
                     // We'll never block for more than 10 secs, instead
                     // we will split up the full timeout into chunks of
@@ -315,7 +315,7 @@
         }
     }
 
-    LOGW("Event %d was not found in the queue, already cancelled?", id);
+    ALOGW("Event %d was not found in the queue, already cancelled?", id);
 
     return NULL;
 }
diff --git a/media/libstagefright/VBRISeeker.cpp b/media/libstagefright/VBRISeeker.cpp
index 6f968be..6ac5a83 100644
--- a/media/libstagefright/VBRISeeker.cpp
+++ b/media/libstagefright/VBRISeeker.cpp
@@ -69,13 +69,13 @@
     int64_t durationUs =
         numFrames * 1000000ll * (sampleRate >= 32000 ? 1152 : 576) / sampleRate;
 
-    LOGV("duration = %.2f secs", durationUs / 1E6);
+    ALOGV("duration = %.2f secs", durationUs / 1E6);
 
     size_t numEntries = U16_AT(&vbriHeader[18]);
     size_t entrySize = U16_AT(&vbriHeader[22]);
     size_t scale = U16_AT(&vbriHeader[20]);
 
-    LOGV("%d entries, scale=%d, size_per_entry=%d",
+    ALOGV("%d entries, scale=%d, size_per_entry=%d",
          numEntries,
          scale,
          entrySize);
@@ -113,14 +113,14 @@
 
         seeker->mSegments.push(numBytes);
 
-        LOGV("entry #%d: %d offset 0x%08lx", i, numBytes, offset);
+        ALOGV("entry #%d: %d offset 0x%08lx", i, numBytes, offset);
         offset += numBytes;
     }
 
     delete[] buffer;
     buffer = NULL;
 
-    LOGI("Found VBRI header.");
+    ALOGI("Found VBRI header.");
 
     return seeker;
 }
@@ -154,7 +154,7 @@
         *pos += mSegments.itemAt(segmentIndex++);
     }
 
-    LOGV("getOffsetForTime %lld us => 0x%08lx", *timeUs, *pos);
+    ALOGV("getOffsetForTime %lld us => 0x%08lx", *timeUs, *pos);
 
     *timeUs = nowUs;
 
diff --git a/media/libstagefright/VideoSourceDownSampler.cpp b/media/libstagefright/VideoSourceDownSampler.cpp
index ea7b09a..1b66990 100644
--- a/media/libstagefright/VideoSourceDownSampler.cpp
+++ b/media/libstagefright/VideoSourceDownSampler.cpp
@@ -29,7 +29,7 @@
 
 VideoSourceDownSampler::VideoSourceDownSampler(const sp<MediaSource> &videoSource,
         int32_t width, int32_t height) {
-    LOGV("Construct VideoSourceDownSampler");
+    ALOGV("Construct VideoSourceDownSampler");
     CHECK(width > 0);
     CHECK(height > 0);
 
@@ -94,23 +94,23 @@
 }
 
 status_t VideoSourceDownSampler::start(MetaData *params) {
-    LOGV("start");
+    ALOGV("start");
     return mRealVideoSource->start();
 }
 
 status_t VideoSourceDownSampler::stop() {
-    LOGV("stop");
+    ALOGV("stop");
     return mRealVideoSource->stop();
 }
 
 sp<MetaData> VideoSourceDownSampler::getFormat() {
-    LOGV("getFormat");
+    ALOGV("getFormat");
     return mMeta;
 }
 
 status_t VideoSourceDownSampler::read(
         MediaBuffer **buffer, const ReadOptions *options) {
-    LOGV("read");
+    ALOGV("read");
     MediaBuffer *realBuffer;
     status_t err = mRealVideoSource->read(&realBuffer, options);
 
@@ -135,7 +135,7 @@
 }
 
 status_t VideoSourceDownSampler::pause() {
-    LOGV("pause");
+    ALOGV("pause");
     return mRealVideoSource->pause();
 }
 
diff --git a/media/libstagefright/WAVExtractor.cpp b/media/libstagefright/WAVExtractor.cpp
index c406964..0bcaf08 100644
--- a/media/libstagefright/WAVExtractor.cpp
+++ b/media/libstagefright/WAVExtractor.cpp
@@ -275,7 +275,7 @@
 }
 
 status_t WAVSource::start(MetaData *params) {
-    LOGV("WAVSource::start");
+    ALOGV("WAVSource::start");
 
     CHECK(!mStarted);
 
@@ -295,7 +295,7 @@
 }
 
 status_t WAVSource::stop() {
-    LOGV("WAVSource::stop");
+    ALOGV("WAVSource::stop");
 
     CHECK(mStarted);
 
@@ -308,7 +308,7 @@
 }
 
 sp<MetaData> WAVSource::getFormat() {
-    LOGV("WAVSource::getFormat");
+    ALOGV("WAVSource::getFormat");
 
     return mMeta;
 }
diff --git a/media/libstagefright/WVMExtractor.cpp b/media/libstagefright/WVMExtractor.cpp
index 26eda0c..1e4e049 100644
--- a/media/libstagefright/WVMExtractor.cpp
+++ b/media/libstagefright/WVMExtractor.cpp
@@ -45,17 +45,12 @@
 static Mutex gWVMutex;
 
 WVMExtractor::WVMExtractor(const sp<DataSource> &source)
-    : mDataSource(source) {
-    {
-        Mutex::Autolock autoLock(gWVMutex);
-        if (gVendorLibHandle == NULL) {
-            gVendorLibHandle = dlopen("libwvm.so", RTLD_NOW);
-        }
+    : mDataSource(source)
+{
+    Mutex::Autolock autoLock(gWVMutex);
 
-        if (gVendorLibHandle == NULL) {
-            LOGE("Failed to open libwvm.so");
-            return;
-        }
+    if (!getVendorLibHandle()) {
+        return;
     }
 
     typedef WVMLoadableExtractor *(*GetInstanceFunc)(sp<DataSource>);
@@ -64,13 +59,28 @@
                 "_ZN7android11GetInstanceENS_2spINS_10DataSourceEEE");
 
     if (getInstanceFunc) {
+        CHECK(source->DrmInitialization(MEDIA_MIMETYPE_CONTAINER_WVM) != NULL);
         mImpl = (*getInstanceFunc)(source);
         CHECK(mImpl != NULL);
+        setDrmFlag(true);
     } else {
-        LOGE("Failed to locate GetInstance in libwvm.so");
+        ALOGE("Failed to locate GetInstance in libwvm.so");
     }
 }
 
+bool WVMExtractor::getVendorLibHandle()
+{
+    if (gVendorLibHandle == NULL) {
+        gVendorLibHandle = dlopen("libwvm.so", RTLD_NOW);
+    }
+
+    if (gVendorLibHandle == NULL) {
+        ALOGE("Failed to open libwvm.so");
+    }
+
+    return gVendorLibHandle != NULL;
+}
+
 WVMExtractor::~WVMExtractor() {
 }
 
@@ -113,5 +123,33 @@
     }
 }
 
+bool SniffWVM(
+    const sp<DataSource> &source, String8 *mimeType, float *confidence,
+        sp<AMessage> *) {
+
+    Mutex::Autolock autoLock(gWVMutex);
+
+    if (!WVMExtractor::getVendorLibHandle()) {
+        return false;
+    }
+
+    typedef WVMLoadableExtractor *(*SnifferFunc)(const sp<DataSource>&);
+    SnifferFunc snifferFunc =
+        (SnifferFunc) dlsym(gVendorLibHandle,
+                            "_ZN7android15IsWidevineMediaERKNS_2spINS_10DataSourceEEE");
+
+    if (snifferFunc) {
+        if ((*snifferFunc)(source)) {
+            *mimeType = MEDIA_MIMETYPE_CONTAINER_WVM;
+            *confidence = 10.0f;
+            return true;
+        }
+    } else {
+        ALOGE("IsWidevineMedia not found in libwvm.so");
+    }
+
+    return false;
+}
+
 } //namespace android
 
diff --git a/media/libstagefright/avc_utils.cpp b/media/libstagefright/avc_utils.cpp
index 153ee33..65c1848 100644
--- a/media/libstagefright/avc_utils.cpp
+++ b/media/libstagefright/avc_utils.cpp
@@ -119,7 +119,7 @@
             cropUnitY = subHeightC * (2 - frame_mbs_only_flag);
         }
 
-        LOGV("frame_crop = (%u, %u, %u, %u), cropUnitX = %u, cropUnitY = %u",
+        ALOGV("frame_crop = (%u, %u, %u, %u), cropUnitX = %u, cropUnitY = %u",
              frame_crop_left_offset, frame_crop_right_offset,
              frame_crop_top_offset, frame_crop_bottom_offset,
              cropUnitX, cropUnitY);
@@ -290,7 +290,7 @@
     memcpy(out, picParamSet->data(), picParamSet->size());
 
 #if 0
-    LOGI("AVC seq param set");
+    ALOGI("AVC seq param set");
     hexdump(seqParamSet->data(), seqParamSet->size());
 #endif
 
@@ -301,7 +301,7 @@
     meta->setInt32(kKeyWidth, width);
     meta->setInt32(kKeyHeight, height);
 
-    LOGI("found AVC codec config (%d x %d, %s-profile level %d.%d)",
+    ALOGI("found AVC codec config (%d x %d, %s-profile level %d.%d)",
          width, height, AVCProfileToString(profile), level / 10, level % 10);
 
     return meta;
diff --git a/media/libstagefright/chromium_http/Android.mk b/media/libstagefright/chromium_http/Android.mk
index 6573e3c..63775f1 100644
--- a/media/libstagefright/chromium_http/Android.mk
+++ b/media/libstagefright/chromium_http/Android.mk
@@ -3,8 +3,9 @@
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES:=       \
-        ChromiumHTTPDataSource.cpp        \
-        support.cpp                     \
+        DataUriSource.cpp \
+        ChromiumHTTPDataSource.cpp \
+        support.cpp
 
 LOCAL_C_INCLUDES:= \
         $(JNI_H_INCLUDE) \
diff --git a/media/libstagefright/chromium_http/ChromiumHTTPDataSource.cpp b/media/libstagefright/chromium_http/ChromiumHTTPDataSource.cpp
index 180460b..76f7946 100644
--- a/media/libstagefright/chromium_http/ChromiumHTTPDataSource.cpp
+++ b/media/libstagefright/chromium_http/ChromiumHTTPDataSource.cpp
@@ -259,7 +259,7 @@
     mCondition.broadcast();
 }
 
-sp<DecryptHandle> ChromiumHTTPDataSource::DrmInitialization() {
+sp<DecryptHandle> ChromiumHTTPDataSource::DrmInitialization(const char* mime) {
     Mutex::Autolock autoLock(mLock);
 
     if (mDrmManagerClient == NULL) {
@@ -275,7 +275,7 @@
          * original one
          */
         mDecryptHandle = mDrmManagerClient->openDecryptSession(
-                String8(mURI.c_str()));
+                String8(mURI.c_str()), mime);
     }
 
     if (mDecryptHandle == NULL) {
diff --git a/media/libstagefright/chromium_http/DataUriSource.cpp b/media/libstagefright/chromium_http/DataUriSource.cpp
new file mode 100644
index 0000000..ecf3fa1
--- /dev/null
+++ b/media/libstagefright/chromium_http/DataUriSource.cpp
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#include <include/DataUriSource.h>
+
+#include <net/base/data_url.h>
+#include <googleurl/src/gurl.h>
+
+
+namespace android {
+
+DataUriSource::DataUriSource(const char *uri) :
+    mDataUri(uri),
+    mInited(NO_INIT) {
+
+    // Copy1: const char *uri -> String8 mDataUri.
+    std::string mimeTypeStr, unusedCharsetStr, dataStr;
+    // Copy2: String8 mDataUri -> std::string
+    const bool ret = net::DataURL::Parse(
+            GURL(std::string(mDataUri.string())),
+            &mimeTypeStr, &unusedCharsetStr, &dataStr);
+    // Copy3: std::string dataStr -> AString mData
+    mData.setTo(dataStr.data(), dataStr.length());
+    mInited = ret ? OK : UNKNOWN_ERROR;
+
+    // The chromium data url implementation defaults to using "text/plain"
+    // if no mime type is specified. We prefer to leave this unspecified
+    // instead, since the mime type is sniffed in most cases.
+    if (mimeTypeStr != "text/plain") {
+        mMimeType = mimeTypeStr.c_str();
+    }
+}
+
+ssize_t DataUriSource::readAt(off64_t offset, void *out, size_t size) {
+    if (mInited != OK) {
+        return mInited;
+    }
+
+    const off64_t length = mData.size();
+    if (offset >= length) {
+        return UNKNOWN_ERROR;
+    }
+
+    const char *dataBuf = mData.c_str();
+    const size_t bytesToCopy =
+            offset + size >= length ? (length - offset) : size;
+
+    if (bytesToCopy > 0) {
+        memcpy(out, dataBuf + offset, bytesToCopy);
+    }
+
+    return bytesToCopy;
+}
+
+}  // namespace android
diff --git a/media/libstagefright/codecs/aacdec/SoftAAC.cpp b/media/libstagefright/codecs/aacdec/SoftAAC.cpp
index 2abdb56..da9d280 100644
--- a/media/libstagefright/codecs/aacdec/SoftAAC.cpp
+++ b/media/libstagefright/codecs/aacdec/SoftAAC.cpp
@@ -116,7 +116,7 @@
 
     Int err = PVMP4AudioDecoderInitLibrary(mConfig, mDecoderBuf);
     if (err != MP4AUDEC_SUCCESS) {
-        LOGE("Failed to initialize MP4 audio decoder");
+        ALOGE("Failed to initialize MP4 audio decoder");
         return UNKNOWN_ERROR;
     }
 
@@ -317,16 +317,16 @@
          * AAC+/eAAC+ until the first data frame is decoded.
          */
         if (decoderErr == MP4AUDEC_SUCCESS && mInputBufferCount <= 2) {
-            LOGV("audio/extended audio object type: %d + %d",
+            ALOGV("audio/extended audio object type: %d + %d",
                 mConfig->audioObjectType, mConfig->extendedAudioObjectType);
-            LOGV("aac+ upsampling factor: %d desired channels: %d",
+            ALOGV("aac+ upsampling factor: %d desired channels: %d",
                 mConfig->aacPlusUpsamplingFactor, mConfig->desiredChannels);
 
             if (mInputBufferCount == 1) {
                 mUpsamplingFactor = mConfig->aacPlusUpsamplingFactor;
                 // Check on the sampling rate to see whether it is changed.
                 if (mConfig->samplingRate != prevSamplingRate) {
-                    LOGW("Sample rate was %d Hz, but now is %d Hz",
+                    ALOGW("Sample rate was %d Hz, but now is %d Hz",
                             prevSamplingRate, mConfig->samplingRate);
 
                     // We'll hold onto the input buffer and will decode
@@ -341,7 +341,7 @@
                     mConfig->extendedAudioObjectType == MP4AUDIO_LTP) {
                     if (mUpsamplingFactor == 2) {
                         // The stream turns out to be not aacPlus mode anyway
-                        LOGW("Disable AAC+/eAAC+ since extended audio object "
+                        ALOGW("Disable AAC+/eAAC+ since extended audio object "
                              "type is %d",
                              mConfig->extendedAudioObjectType);
                         mConfig->aacPlusEnabled = 0;
@@ -351,7 +351,7 @@
                         // aacPlus mode does not buy us anything, but to cause
                         // 1. CPU load to increase, and
                         // 2. a half speed of decoding
-                        LOGW("Disable AAC+/eAAC+ since upsampling factor is 1");
+                        ALOGW("Disable AAC+/eAAC+ since upsampling factor is 1");
                         mConfig->aacPlusEnabled = 0;
                     }
                 }
@@ -367,7 +367,7 @@
             inHeader->nFilledLen -= mConfig->inputBufferUsedLength;
             inHeader->nOffset += mConfig->inputBufferUsedLength;
         } else {
-            LOGW("AAC decoder returned error %d, substituting silence",
+            ALOGW("AAC decoder returned error %d, substituting silence",
                  decoderErr);
 
             memset(outHeader->pBuffer + outHeader->nOffset, 0, numOutBytes);
diff --git a/media/libstagefright/codecs/aacenc/AACEncoder.cpp b/media/libstagefright/codecs/aacenc/AACEncoder.cpp
index 0bff52d..2b8633d 100644
--- a/media/libstagefright/codecs/aacenc/AACEncoder.cpp
+++ b/media/libstagefright/codecs/aacenc/AACEncoder.cpp
@@ -53,7 +53,7 @@
     CHECK(mApiHandle);
 
     if (VO_ERR_NONE != voGetAACEncAPI(mApiHandle)) {
-        LOGE("Failed to get api handle");
+        ALOGE("Failed to get api handle");
         return UNKNOWN_ERROR;
     }
 
@@ -70,11 +70,11 @@
     userData.memflag = VO_IMF_USERMEMOPERATOR;
     userData.memData = (VO_PTR) mMemOperator;
     if (VO_ERR_NONE != mApiHandle->Init(&mEncoderHandle, VO_AUDIO_CodingAAC, &userData)) {
-        LOGE("Failed to init AAC encoder");
+        ALOGE("Failed to init AAC encoder");
         return UNKNOWN_ERROR;
     }
     if (OK != setAudioSpecificConfigData()) {
-        LOGE("Failed to configure AAC encoder");
+        ALOGE("Failed to configure AAC encoder");
         return UNKNOWN_ERROR;
     }
 
@@ -86,7 +86,7 @@
     params.nChannels = mChannels;
     params.adtsUsed = 0;  // We add adts header in the file writer if needed.
     if (VO_ERR_NONE != mApiHandle->SetParam(mEncoderHandle, VO_PID_AAC_ENCPARAM,  &params)) {
-        LOGE("Failed to set AAC encoder parameters");
+        ALOGE("Failed to set AAC encoder parameters");
         return UNKNOWN_ERROR;
     }
 
@@ -106,18 +106,18 @@
         }
     }
 
-    LOGE("Sampling rate %d bps is not supported", sampleRate);
+    ALOGE("Sampling rate %d bps is not supported", sampleRate);
     return UNKNOWN_ERROR;
 }
 
 status_t AACEncoder::setAudioSpecificConfigData() {
-    LOGV("setAudioSpecificConfigData: %d hz, %d bps, and %d channels",
+    ALOGV("setAudioSpecificConfigData: %d hz, %d bps, and %d channels",
          mSampleRate, mBitRate, mChannels);
 
     int32_t index;
     CHECK_EQ(OK, getSampleRateTableIndex(mSampleRate, index));
     if (mChannels > 2 || mChannels <= 0) {
-        LOGE("Unsupported number of channels(%d)", mChannels);
+        ALOGE("Unsupported number of channels(%d)", mChannels);
         return UNKNOWN_ERROR;
     }
 
@@ -135,7 +135,7 @@
 
 status_t AACEncoder::start(MetaData *params) {
     if (mStarted) {
-        LOGW("Call start() when encoder already started");
+        ALOGW("Call start() when encoder already started");
         return OK;
     }
 
@@ -153,7 +153,7 @@
 
     status_t err = mSource->start(params);
     if (err != OK) {
-         LOGE("AudioSource is not available");
+         ALOGE("AudioSource is not available");
         return err;
     }
 
@@ -177,7 +177,7 @@
     }
 
     if (!mStarted) {
-        LOGW("Call stop() when encoder has not started");
+        ALOGW("Call stop() when encoder has not started");
         return ERROR_END_OF_STREAM;
     }
 
diff --git a/media/libstagefright/codecs/amrnb/dec/SoftAMR.cpp b/media/libstagefright/codecs/amrnb/dec/SoftAMR.cpp
index c0a588f..7602f2d 100644
--- a/media/libstagefright/codecs/amrnb/dec/SoftAMR.cpp
+++ b/media/libstagefright/codecs/amrnb/dec/SoftAMR.cpp
@@ -304,7 +304,7 @@
                   MIME_IETF);
 
             if (numBytesRead == -1) {
-                LOGE("PV AMR decoder AMRDecode() call failed");
+                ALOGE("PV AMR decoder AMRDecode() call failed");
 
                 notify(OMX_EventError, OMX_ErrorUndefined, 0, NULL);
                 mSignalledError = true;
diff --git a/media/libstagefright/codecs/amrnb/enc/AMRNBEncoder.cpp b/media/libstagefright/codecs/amrnb/enc/AMRNBEncoder.cpp
index d361ef4..3afbc4f 100644
--- a/media/libstagefright/codecs/amrnb/enc/AMRNBEncoder.cpp
+++ b/media/libstagefright/codecs/amrnb/enc/AMRNBEncoder.cpp
@@ -71,7 +71,7 @@
 
 status_t AMRNBEncoder::start(MetaData *params) {
     if (mStarted) {
-        LOGW("Call start() when encoder already started");
+        ALOGW("Call start() when encoder already started");
         return OK;
     }
 
@@ -84,7 +84,7 @@
 
     status_t err = mSource->start(params);
     if (err != OK) {
-        LOGE("AudioSource is not available");
+        ALOGE("AudioSource is not available");
         return err;
     }
 
@@ -105,7 +105,7 @@
 
 status_t AMRNBEncoder::stop() {
     if (!mStarted) {
-        LOGW("Call stop() when encoder has not started.");
+        ALOGW("Call stop() when encoder has not started.");
         return OK;
     }
 
diff --git a/media/libstagefright/codecs/amrwbenc/AMRWBEncoder.cpp b/media/libstagefright/codecs/amrwbenc/AMRWBEncoder.cpp
index 5eacc16..60b1163 100644
--- a/media/libstagefright/codecs/amrwbenc/AMRWBEncoder.cpp
+++ b/media/libstagefright/codecs/amrwbenc/AMRWBEncoder.cpp
@@ -80,7 +80,7 @@
     CHECK(mApiHandle);
 
     if (VO_ERR_NONE != voGetAMRWBEncAPI(mApiHandle)) {
-        LOGE("Failed to get api handle");
+        ALOGE("Failed to get api handle");
         return UNKNOWN_ERROR;
     }
 
@@ -97,20 +97,20 @@
     userData.memflag = VO_IMF_USERMEMOPERATOR;
     userData.memData = (VO_PTR) mMemOperator;
     if (VO_ERR_NONE != mApiHandle->Init(&mEncoderHandle, VO_AUDIO_CodingAMRWB, &userData)) {
-        LOGE("Failed to init AMRWB encoder");
+        ALOGE("Failed to init AMRWB encoder");
         return UNKNOWN_ERROR;
     }
 
     // Configure AMRWB encoder$
     VOAMRWBMODE mode = pickModeFromBitRate(mBitRate);
     if (VO_ERR_NONE != mApiHandle->SetParam(mEncoderHandle, VO_PID_AMRWB_MODE,  &mode)) {
-        LOGE("Failed to set AMRWB encoder mode to %d", mode);
+        ALOGE("Failed to set AMRWB encoder mode to %d", mode);
         return UNKNOWN_ERROR;
     }
 
     VOAMRWBFRAMETYPE type = VOAMRWB_RFC3267;
     if (VO_ERR_NONE != mApiHandle->SetParam(mEncoderHandle, VO_PID_AMRWB_FRAMETYPE, &type)) {
-        LOGE("Failed to set AMRWB encoder frame type to %d", type);
+        ALOGE("Failed to set AMRWB encoder frame type to %d", type);
         return UNKNOWN_ERROR;
     }
 
@@ -125,7 +125,7 @@
 
 status_t AMRWBEncoder::start(MetaData *params) {
     if (mStarted) {
-        LOGW("Call start() when encoder already started");
+        ALOGW("Call start() when encoder already started");
         return OK;
     }
 
@@ -140,7 +140,7 @@
 
     status_t err = mSource->start(params);
     if (err != OK) {
-        LOGE("AudioSource is not available");
+        ALOGE("AudioSource is not available");
         return err;
     }
     mStarted = true;
@@ -150,7 +150,7 @@
 
 status_t AMRWBEncoder::stop() {
     if (!mStarted) {
-        LOGW("Call stop() when encoder has not started");
+        ALOGW("Call stop() when encoder has not started");
         return OK;
     }
 
diff --git a/media/libstagefright/codecs/avc/enc/AVCEncoder.cpp b/media/libstagefright/codecs/avc/enc/AVCEncoder.cpp
index 0096760..e202a2b 100644
--- a/media/libstagefright/codecs/avc/enc/AVCEncoder.cpp
+++ b/media/libstagefright/codecs/avc/enc/AVCEncoder.cpp
@@ -35,20 +35,20 @@
 
 static status_t ConvertOmxAvcProfileToAvcSpecProfile(
         int32_t omxProfile, AVCProfile* pvProfile) {
-    LOGV("ConvertOmxAvcProfileToAvcSpecProfile: %d", omxProfile);
+    ALOGV("ConvertOmxAvcProfileToAvcSpecProfile: %d", omxProfile);
     switch (omxProfile) {
         case OMX_VIDEO_AVCProfileBaseline:
             *pvProfile = AVC_BASELINE;
             return OK;
         default:
-            LOGE("Unsupported omx profile: %d", omxProfile);
+            ALOGE("Unsupported omx profile: %d", omxProfile);
     }
     return BAD_VALUE;
 }
 
 static status_t ConvertOmxAvcLevelToAvcSpecLevel(
         int32_t omxLevel, AVCLevel *pvLevel) {
-    LOGV("ConvertOmxAvcLevelToAvcSpecLevel: %d", omxLevel);
+    ALOGV("ConvertOmxAvcLevelToAvcSpecLevel: %d", omxLevel);
     AVCLevel level = AVC_LEVEL5_1;
     switch (omxLevel) {
         case OMX_VIDEO_AVCLevel1:
@@ -100,7 +100,7 @@
             level = AVC_LEVEL5_1;
             break;
         default:
-            LOGE("Unknown omx level: %d", omxLevel);
+            ALOGE("Unknown omx level: %d", omxLevel);
             return BAD_VALUE;
     }
     *pvLevel = level;
@@ -178,7 +178,7 @@
       mInputFrameData(NULL),
       mGroup(NULL) {
 
-    LOGI("Construct software AVCEncoder");
+    ALOGI("Construct software AVCEncoder");
 
     mHandle = new tagAVCHandle;
     memset(mHandle, 0, sizeof(tagAVCHandle));
@@ -194,7 +194,7 @@
 }
 
 AVCEncoder::~AVCEncoder() {
-    LOGV("Destruct software AVCEncoder");
+    ALOGV("Destruct software AVCEncoder");
     if (mStarted) {
         stop();
     }
@@ -204,7 +204,7 @@
 }
 
 status_t AVCEncoder::initCheck(const sp<MetaData>& meta) {
-    LOGV("initCheck");
+    ALOGV("initCheck");
     CHECK(meta->findInt32(kKeyWidth, &mVideoWidth));
     CHECK(meta->findInt32(kKeyHeight, &mVideoHeight));
     CHECK(meta->findInt32(kKeyFrameRate, &mVideoFrameRate));
@@ -214,7 +214,7 @@
     CHECK(meta->findInt32(kKeyColorFormat, &mVideoColorFormat));
     if (mVideoColorFormat != OMX_COLOR_FormatYUV420Planar) {
         if (mVideoColorFormat != OMX_COLOR_FormatYUV420SemiPlanar) {
-            LOGE("Color format %d is not supported", mVideoColorFormat);
+            ALOGE("Color format %d is not supported", mVideoColorFormat);
             return BAD_VALUE;
         }
         // Allocate spare buffer only when color conversion is needed.
@@ -226,7 +226,7 @@
 
     // XXX: Remove this restriction
     if (mVideoWidth % 16 != 0 || mVideoHeight % 16 != 0) {
-        LOGE("Video frame size %dx%d must be a multiple of 16",
+        ALOGE("Video frame size %dx%d must be a multiple of 16",
             mVideoWidth, mVideoHeight);
         return BAD_VALUE;
     }
@@ -295,7 +295,7 @@
         mEncParams->idr_period =
             (iFramesIntervalSec * mVideoFrameRate);
     }
-    LOGV("idr_period: %d, I-frames interval: %d seconds, and frame rate: %d",
+    ALOGV("idr_period: %d, I-frames interval: %d seconds, and frame rate: %d",
         mEncParams->idr_period, iFramesIntervalSec, mVideoFrameRate);
 
     // Set profile and level
@@ -330,20 +330,20 @@
 }
 
 status_t AVCEncoder::start(MetaData *params) {
-    LOGV("start");
+    ALOGV("start");
     if (mInitCheck != OK) {
         return mInitCheck;
     }
 
     if (mStarted) {
-        LOGW("Call start() when encoder already started");
+        ALOGW("Call start() when encoder already started");
         return OK;
     }
 
     AVCEnc_Status err;
     err = PVAVCEncInitialize(mHandle, mEncParams, NULL, NULL);
     if (err != AVCENC_SUCCESS) {
-        LOGE("Failed to initialize the encoder: %d", err);
+        ALOGE("Failed to initialize the encoder: %d", err);
         return UNKNOWN_ERROR;
     }
 
@@ -366,9 +366,9 @@
 }
 
 status_t AVCEncoder::stop() {
-    LOGV("stop");
+    ALOGV("stop");
     if (!mStarted) {
-        LOGW("Call stop() when encoder has not started");
+        ALOGW("Call stop() when encoder has not started");
         return OK;
     }
 
@@ -396,7 +396,7 @@
 }
 
 void AVCEncoder::releaseOutputBuffers() {
-    LOGV("releaseOutputBuffers");
+    ALOGV("releaseOutputBuffers");
     for (size_t i = 0; i < mOutputBuffers.size(); ++i) {
         MediaBuffer *buffer = mOutputBuffers.editItemAt(i);
         buffer->setObserver(NULL);
@@ -406,7 +406,7 @@
 }
 
 sp<MetaData> AVCEncoder::getFormat() {
-    LOGV("getFormat");
+    ALOGV("getFormat");
     return mFormat;
 }
 
@@ -461,7 +461,7 @@
                     *out = outputBuffer;
                     return OK;
                 default:
-                    LOGE("Nal type (%d) other than SPS/PPS is unexpected", type);
+                    ALOGE("Nal type (%d) other than SPS/PPS is unexpected", type);
                     return UNKNOWN_ERROR;
             }
         }
@@ -476,7 +476,7 @@
         status_t err = mSource->read(&mInputBuffer, options);
         if (err != OK) {
             if (err != ERROR_END_OF_STREAM) {
-                LOGE("Failed to read input video frame: %d", err);
+                ALOGE("Failed to read input video frame: %d", err);
             }
             outputBuffer->release();
             return err;
@@ -563,7 +563,7 @@
         if (mIsIDRFrame) {
             outputBuffer->meta_data()->setInt32(kKeyIsSyncFrame, mIsIDRFrame);
             mIsIDRFrame = 0;
-            LOGV("Output an IDR frame");
+            ALOGV("Output an IDR frame");
         }
         mReadyForNextFrame = true;
         AVCFrameIO recon;
diff --git a/media/libstagefright/codecs/g711/dec/SoftG711.cpp b/media/libstagefright/codecs/g711/dec/SoftG711.cpp
index 15e2c26..32ef003 100644
--- a/media/libstagefright/codecs/g711/dec/SoftG711.cpp
+++ b/media/libstagefright/codecs/g711/dec/SoftG711.cpp
@@ -210,7 +210,7 @@
         }
 
         if (inHeader->nFilledLen > kMaxNumSamplesPerFrame) {
-            LOGE("input buffer too large (%ld).", inHeader->nFilledLen);
+            ALOGE("input buffer too large (%ld).", inHeader->nFilledLen);
 
             notify(OMX_EventError, OMX_ErrorUndefined, 0, NULL);
             mSignalledError = true;
diff --git a/media/libstagefright/codecs/m4v_h263/dec/SoftMPEG4.cpp b/media/libstagefright/codecs/m4v_h263/dec/SoftMPEG4.cpp
index aa07e57..a34a0ca 100644
--- a/media/libstagefright/codecs/m4v_h263/dec/SoftMPEG4.cpp
+++ b/media/libstagefright/codecs/m4v_h263/dec/SoftMPEG4.cpp
@@ -207,7 +207,7 @@
                     (OMX_VIDEO_PARAM_PROFILELEVELTYPE *) params;
 
             if (profileLevel->nPortIndex != 0) {  // Input port only
-                LOGE("Invalid port index: %ld", profileLevel->nPortIndex);
+                ALOGE("Invalid port index: %ld", profileLevel->nPortIndex);
                 return OMX_ErrorUnsupportedIndex;
             }
 
@@ -371,7 +371,7 @@
                     mHandle, vol_data, &vol_size, 1, mWidth, mHeight, mode);
 
             if (!success) {
-                LOGW("PVInitVideoDecoder failed. Unsupported content?");
+                ALOGW("PVInitVideoDecoder failed. Unsupported content?");
 
                 notify(OMX_EventError, OMX_ErrorUndefined, 0, NULL);
                 mSignalledError = true;
@@ -430,7 +430,7 @@
                     mHandle, &bitstream, &timestamp, &tmp,
                     &useExtTimestamp,
                     outHeader->pBuffer) != PV_TRUE) {
-            LOGE("failed to decode video frame.");
+            ALOGE("failed to decode video frame.");
 
             notify(OMX_EventError, OMX_ErrorUndefined, 0, NULL);
             mSignalledError = true;
@@ -489,7 +489,7 @@
     CHECK_LE(disp_width, buf_width);
     CHECK_LE(disp_height, buf_height);
 
-    LOGV("disp_width = %d, disp_height = %d, buf_width = %d, buf_height = %d",
+    ALOGV("disp_width = %d, disp_height = %d, buf_width = %d, buf_height = %d",
             disp_width, disp_height, buf_width, buf_height);
 
     if (mCropRight != disp_width - 1
diff --git a/media/libstagefright/codecs/m4v_h263/enc/M4vH263Encoder.cpp b/media/libstagefright/codecs/m4v_h263/enc/M4vH263Encoder.cpp
index d7249c1..d538603 100644
--- a/media/libstagefright/codecs/m4v_h263/enc/M4vH263Encoder.cpp
+++ b/media/libstagefright/codecs/m4v_h263/enc/M4vH263Encoder.cpp
@@ -37,22 +37,22 @@
         int32_t omxProfile,
         int32_t omxLevel,
         ProfileLevelType* pvProfileLevel) {
-    LOGV("ConvertOmxProfileLevel: %d/%d/%d", mode, omxProfile, omxLevel);
+    ALOGV("ConvertOmxProfileLevel: %d/%d/%d", mode, omxProfile, omxLevel);
     ProfileLevelType profileLevel;
     if (mode == H263_MODE) {
         switch (omxProfile) {
             case OMX_VIDEO_H263ProfileBaseline:
                 if (omxLevel > OMX_VIDEO_H263Level45) {
-                    LOGE("Unsupported level (%d) for H263", omxLevel);
+                    ALOGE("Unsupported level (%d) for H263", omxLevel);
                     return BAD_VALUE;
                 } else {
-                    LOGW("PV does not support level configuration for H263");
+                    ALOGW("PV does not support level configuration for H263");
                     profileLevel = CORE_PROFILE_LEVEL2;
                     break;
                 }
                 break;
             default:
-                LOGE("Unsupported profile (%d) for H263", omxProfile);
+                ALOGE("Unsupported profile (%d) for H263", omxProfile);
                 return BAD_VALUE;
         }
     } else {  // MPEG4
@@ -72,7 +72,7 @@
                         profileLevel = SIMPLE_PROFILE_LEVEL3;
                         break;
                     default:
-                        LOGE("Unsupported level (%d) for MPEG4 simple profile",
+                        ALOGE("Unsupported level (%d) for MPEG4 simple profile",
                             omxLevel);
                         return BAD_VALUE;
                 }
@@ -89,7 +89,7 @@
                         profileLevel = SIMPLE_SCALABLE_PROFILE_LEVEL2;
                         break;
                     default:
-                        LOGE("Unsupported level (%d) for MPEG4 simple "
+                        ALOGE("Unsupported level (%d) for MPEG4 simple "
                              "scalable profile", omxLevel);
                         return BAD_VALUE;
                 }
@@ -103,7 +103,7 @@
                         profileLevel = CORE_PROFILE_LEVEL2;
                         break;
                     default:
-                        LOGE("Unsupported level (%d) for MPEG4 core "
+                        ALOGE("Unsupported level (%d) for MPEG4 core "
                              "profile", omxLevel);
                         return BAD_VALUE;
                 }
@@ -120,13 +120,13 @@
                         profileLevel = CORE_SCALABLE_PROFILE_LEVEL3;
                         break;
                     default:
-                        LOGE("Unsupported level (%d) for MPEG4 core "
+                        ALOGE("Unsupported level (%d) for MPEG4 core "
                              "scalable profile", omxLevel);
                         return BAD_VALUE;
                 }
                 break;
             default:
-                LOGE("Unsupported MPEG4 profile (%d)", omxProfile);
+                ALOGE("Unsupported MPEG4 profile (%d)", omxProfile);
                 return BAD_VALUE;
         }
     }
@@ -178,7 +178,7 @@
       mInputFrameData(NULL),
       mGroup(NULL) {
 
-    LOGI("Construct software M4vH263Encoder");
+    ALOGI("Construct software M4vH263Encoder");
 
     mHandle = new tagvideoEncControls;
     memset(mHandle, 0, sizeof(tagvideoEncControls));
@@ -187,7 +187,7 @@
 }
 
 M4vH263Encoder::~M4vH263Encoder() {
-    LOGV("Destruct software M4vH263Encoder");
+    ALOGV("Destruct software M4vH263Encoder");
     if (mStarted) {
         stop();
     }
@@ -197,7 +197,7 @@
 }
 
 status_t M4vH263Encoder::initCheck(const sp<MetaData>& meta) {
-    LOGV("initCheck");
+    ALOGV("initCheck");
     CHECK(meta->findInt32(kKeyWidth, &mVideoWidth));
     CHECK(meta->findInt32(kKeyHeight, &mVideoHeight));
     CHECK(meta->findInt32(kKeyFrameRate, &mVideoFrameRate));
@@ -207,7 +207,7 @@
     CHECK(meta->findInt32(kKeyColorFormat, &mVideoColorFormat));
     if (mVideoColorFormat != OMX_COLOR_FormatYUV420Planar) {
         if (mVideoColorFormat != OMX_COLOR_FormatYUV420SemiPlanar) {
-            LOGE("Color format %d is not supported", mVideoColorFormat);
+            ALOGE("Color format %d is not supported", mVideoColorFormat);
             return BAD_VALUE;
         }
         // Allocate spare buffer only when color conversion is needed.
@@ -219,7 +219,7 @@
 
     // XXX: Remove this restriction
     if (mVideoWidth % 16 != 0 || mVideoHeight % 16 != 0) {
-        LOGE("Video frame size %dx%d must be a multiple of 16",
+        ALOGE("Video frame size %dx%d must be a multiple of 16",
             mVideoWidth, mVideoHeight);
         return BAD_VALUE;
     }
@@ -227,7 +227,7 @@
     mEncParams = new tagvideoEncOptions;
     memset(mEncParams, 0, sizeof(tagvideoEncOptions));
     if (!PVGetDefaultEncOption(mEncParams, 0)) {
-        LOGE("Failed to get default encoding parameters");
+        ALOGE("Failed to get default encoding parameters");
         return BAD_VALUE;
     }
 
@@ -308,18 +308,18 @@
 }
 
 status_t M4vH263Encoder::start(MetaData *params) {
-    LOGV("start");
+    ALOGV("start");
     if (mInitCheck != OK) {
         return mInitCheck;
     }
 
     if (mStarted) {
-        LOGW("Call start() when encoder already started");
+        ALOGW("Call start() when encoder already started");
         return OK;
     }
 
     if (!PVInitVideoEncoder(mHandle, mEncParams)) {
-        LOGE("Failed to initialize the encoder");
+        ALOGE("Failed to initialize the encoder");
         return UNKNOWN_ERROR;
     }
 
@@ -328,7 +328,7 @@
     if (!PVGetMaxVideoFrameSize(mHandle, &maxSize)) {
         maxSize = 256 * 1024;  // Magic #
     }
-    LOGV("Max output buffer size: %d", maxSize);
+    ALOGV("Max output buffer size: %d", maxSize);
     mGroup->add_buffer(new MediaBuffer(maxSize));
 
     mSource->start(params);
@@ -339,9 +339,9 @@
 }
 
 status_t M4vH263Encoder::stop() {
-    LOGV("stop");
+    ALOGV("stop");
     if (!mStarted) {
-        LOGW("Call stop() when encoder has not started");
+        ALOGW("Call stop() when encoder has not started");
         return OK;
     }
 
@@ -369,7 +369,7 @@
 }
 
 sp<MetaData> M4vH263Encoder::getFormat() {
-    LOGV("getFormat");
+    ALOGV("getFormat");
     return mFormat;
 }
 
@@ -386,10 +386,10 @@
     // Output codec specific data
     if (mNumInputFrames < 0) {
         if (!PVGetVolHeader(mHandle, outPtr, &dataLength, 0)) {
-            LOGE("Failed to get VOL header");
+            ALOGE("Failed to get VOL header");
             return UNKNOWN_ERROR;
         }
-        LOGV("Output VOL header: %d bytes", dataLength);
+        ALOGV("Output VOL header: %d bytes", dataLength);
         outputBuffer->meta_data()->setInt32(kKeyIsCodecConfig, 1);
         outputBuffer->set_range(0, dataLength);
         *out = outputBuffer;
@@ -401,7 +401,7 @@
     status_t err = mSource->read(&mInputBuffer, options);
     if (OK != err) {
         if (err != ERROR_END_OF_STREAM) {
-            LOGE("Failed to read from data source");
+            ALOGE("Failed to read from data source");
         }
         outputBuffer->release();
         return err;
@@ -460,7 +460,7 @@
     if (!PVEncodeVideoFrame(mHandle, &vin, &vout,
             &modTimeMs, outPtr, &dataLength, &nLayer) ||
         !PVGetHintTrack(mHandle, &hintTrack)) {
-        LOGE("Failed to encode frame or get hink track at frame %lld",
+        ALOGE("Failed to encode frame or get hink track at frame %lld",
             mNumInputFrames);
         outputBuffer->release();
         mInputBuffer->release();
diff --git a/media/libstagefright/codecs/mp3dec/SoftMP3.cpp b/media/libstagefright/codecs/mp3dec/SoftMP3.cpp
index 066c88e..ad55295 100644
--- a/media/libstagefright/codecs/mp3dec/SoftMP3.cpp
+++ b/media/libstagefright/codecs/mp3dec/SoftMP3.cpp
@@ -219,14 +219,14 @@
         ERROR_CODE decoderErr;
         if ((decoderErr = pvmp3_framedecoder(mConfig, mDecoderBuf))
                 != NO_DECODING_ERROR) {
-            LOGV("mp3 decoder returned error %d", decoderErr);
+            ALOGV("mp3 decoder returned error %d", decoderErr);
 
             if (decoderErr != NO_ENOUGH_MAIN_DATA_ERROR ||
                     mConfig->outputFrameSize == 0) {
-                LOGE("mp3 decoder returned error %d", decoderErr);
+                ALOGE("mp3 decoder returned error %d", decoderErr);
 
                 if (mConfig->outputFrameSize == 0) {
-                    LOGE("Output frame size is 0");
+                    ALOGE("Output frame size is 0");
                 }
 
                 notify(OMX_EventError, OMX_ErrorUndefined, decoderErr, NULL);
diff --git a/media/libstagefright/codecs/on2/dec/SoftVPX.cpp b/media/libstagefright/codecs/on2/dec/SoftVPX.cpp
index 61a02ac..bf9ab3a 100644
--- a/media/libstagefright/codecs/on2/dec/SoftVPX.cpp
+++ b/media/libstagefright/codecs/on2/dec/SoftVPX.cpp
@@ -126,7 +126,7 @@
     cpuCoreCount = sysconf(_SC_NPROC_ONLN);
 #endif
     CHECK(cpuCoreCount >= 1);
-    LOGV("Number of CPU cores: %d", cpuCoreCount);
+    ALOGV("Number of CPU cores: %d", cpuCoreCount);
     return cpuCoreCount;
 }
 
@@ -138,7 +138,7 @@
     cfg.threads = GetCPUCoreCount();
     if ((vpx_err = vpx_codec_dec_init(
                 (vpx_codec_ctx_t *)mCtx, &vpx_codec_vp8_dx_algo, &cfg, 0))) {
-        LOGE("on2 decoder failed to initialize. (%d)", vpx_err);
+        ALOGE("on2 decoder failed to initialize. (%d)", vpx_err);
         return UNKNOWN_ERROR;
     }
 
@@ -254,7 +254,7 @@
                     inHeader->nFilledLen,
                     NULL,
                     0)) {
-            LOGE("on2 decoder failed to decode frame.");
+            ALOGE("on2 decoder failed to decode frame.");
 
             notify(OMX_EventError, OMX_ErrorUndefined, 0, NULL);
             return;
diff --git a/media/libstagefright/codecs/on2/h264dec/SoftAVC.cpp b/media/libstagefright/codecs/on2/h264dec/SoftAVC.cpp
index dede3ac..6c3f834 100644
--- a/media/libstagefright/codecs/on2/h264dec/SoftAVC.cpp
+++ b/media/libstagefright/codecs/on2/h264dec/SoftAVC.cpp
@@ -204,7 +204,7 @@
                     (OMX_VIDEO_PARAM_PROFILELEVELTYPE *) params;
 
             if (profileLevel->nPortIndex != kInputPortIndex) {
-                LOGE("Invalid port index: %ld", profileLevel->nPortIndex);
+                ALOGE("Invalid port index: %ld", profileLevel->nPortIndex);
                 return OMX_ErrorUnsupportedIndex;
             }
 
@@ -371,7 +371,7 @@
                 }
                 inPicture.dataLen = 0;
                 if (ret < 0) {
-                    LOGE("Decoder failed: %d", ret);
+                    ALOGE("Decoder failed: %d", ret);
 
                     notify(OMX_EventError, OMX_ErrorUndefined,
                            ERROR_MALFORMED, NULL);
diff --git a/media/libstagefright/codecs/vorbis/dec/SoftVorbis.cpp b/media/libstagefright/codecs/vorbis/dec/SoftVorbis.cpp
index 4091111..ac88107 100644
--- a/media/libstagefright/codecs/vorbis/dec/SoftVorbis.cpp
+++ b/media/libstagefright/codecs/vorbis/dec/SoftVorbis.cpp
@@ -353,21 +353,21 @@
 
         int err = vorbis_dsp_synthesis(mState, &pack, 1);
         if (err != 0) {
-            LOGW("vorbis_dsp_synthesis returned %d", err);
+            ALOGW("vorbis_dsp_synthesis returned %d", err);
         } else {
             numFrames = vorbis_dsp_pcmout(
                     mState, (int16_t *)outHeader->pBuffer,
                     kMaxNumSamplesPerBuffer);
 
             if (numFrames < 0) {
-                LOGE("vorbis_dsp_pcmout returned %d", numFrames);
+                ALOGE("vorbis_dsp_pcmout returned %d", numFrames);
                 numFrames = 0;
             }
         }
 
         if (mNumFramesLeftOnPage >= 0) {
             if (numFrames > mNumFramesLeftOnPage) {
-                LOGV("discarding %d frames at end of page",
+                ALOGV("discarding %d frames at end of page",
                      numFrames - mNumFramesLeftOnPage);
                 numFrames = mNumFramesLeftOnPage;
             }
diff --git a/media/libstagefright/colorconversion/SoftwareRenderer.cpp b/media/libstagefright/colorconversion/SoftwareRenderer.cpp
index 3246021..e892f92 100644
--- a/media/libstagefright/colorconversion/SoftwareRenderer.cpp
+++ b/media/libstagefright/colorconversion/SoftwareRenderer.cpp
@@ -135,7 +135,7 @@
     ANativeWindowBuffer *buf;
     int err;
     if ((err = mNativeWindow->dequeueBuffer(mNativeWindow.get(), &buf)) != 0) {
-        LOGW("Surface::dequeueBuffer returned error %d", err);
+        ALOGW("Surface::dequeueBuffer returned error %d", err);
         return;
     }
 
@@ -225,7 +225,7 @@
     CHECK_EQ(0, mapper.unlock(buf->handle));
 
     if ((err = mNativeWindow->queueBuffer(mNativeWindow.get(), buf)) != 0) {
-        LOGW("Surface::queueBuffer returned error %d", err);
+        ALOGW("Surface::queueBuffer returned error %d", err);
     }
     buf = NULL;
 }
diff --git a/media/libstagefright/foundation/AHierarchicalStateMachine.cpp b/media/libstagefright/foundation/AHierarchicalStateMachine.cpp
index 3b3f786..40c5a3c 100644
--- a/media/libstagefright/foundation/AHierarchicalStateMachine.cpp
+++ b/media/libstagefright/foundation/AHierarchicalStateMachine.cpp
@@ -63,7 +63,7 @@
         return;
     }
 
-    LOGW("Warning message %s unhandled in root state.",
+    ALOGW("Warning message %s unhandled in root state.",
          msg->debugString().c_str());
 }
 
diff --git a/media/libstagefright/foundation/ALooperRoster.cpp b/media/libstagefright/foundation/ALooperRoster.cpp
index e399f2f..dff931d 100644
--- a/media/libstagefright/foundation/ALooperRoster.cpp
+++ b/media/libstagefright/foundation/ALooperRoster.cpp
@@ -82,7 +82,7 @@
     ssize_t index = mHandlers.indexOfKey(msg->target());
 
     if (index < 0) {
-        LOGW("failed to post message. Target handler not registered.");
+        ALOGW("failed to post message. Target handler not registered.");
         return -ENOENT;
     }
 
@@ -91,7 +91,7 @@
     sp<ALooper> looper = info.mLooper.promote();
 
     if (looper == NULL) {
-        LOGW("failed to post message. "
+        ALOGW("failed to post message. "
              "Target handler %d still registered, but object gone.",
              msg->target());
 
@@ -113,7 +113,7 @@
         ssize_t index = mHandlers.indexOfKey(msg->target());
 
         if (index < 0) {
-            LOGW("failed to deliver message. Target handler not registered.");
+            ALOGW("failed to deliver message. Target handler not registered.");
             return;
         }
 
@@ -121,7 +121,7 @@
         handler = info.mHandler.promote();
 
         if (handler == NULL) {
-            LOGW("failed to deliver message. "
+            ALOGW("failed to deliver message. "
                  "Target handler %d registered, but object gone.",
                  msg->target());
 
diff --git a/media/libstagefright/foundation/AMessage.cpp b/media/libstagefright/foundation/AMessage.cpp
index f039bc1..0a6776e 100644
--- a/media/libstagefright/foundation/AMessage.cpp
+++ b/media/libstagefright/foundation/AMessage.cpp
@@ -471,7 +471,7 @@
 
             default:
             {
-                LOGE("This type of object cannot cross process boundaries.");
+                ALOGE("This type of object cannot cross process boundaries.");
                 TRESPASS();
             }
         }
@@ -535,7 +535,7 @@
 
             default:
             {
-                LOGE("This type of object cannot cross process boundaries.");
+                ALOGE("This type of object cannot cross process boundaries.");
                 TRESPASS();
             }
         }
diff --git a/media/libstagefright/foundation/hexdump.cpp b/media/libstagefright/foundation/hexdump.cpp
index 9f6bf9e..16c1ca5 100644
--- a/media/libstagefright/foundation/hexdump.cpp
+++ b/media/libstagefright/foundation/hexdump.cpp
@@ -67,7 +67,7 @@
             }
         }
 
-        LOGI("%s", line.c_str());
+        ALOGI("%s", line.c_str());
 
         offset += 16;
     }
diff --git a/media/libstagefright/httplive/LiveDataSource.cpp b/media/libstagefright/httplive/LiveDataSource.cpp
index 5f5c6d4..7560642 100644
--- a/media/libstagefright/httplive/LiveDataSource.cpp
+++ b/media/libstagefright/httplive/LiveDataSource.cpp
@@ -59,7 +59,7 @@
     Mutex::Autolock autoLock(mLock);
 
     if (offset != mOffset) {
-        LOGE("Attempt at reading non-sequentially from LiveDataSource.");
+        ALOGE("Attempt at reading non-sequentially from LiveDataSource.");
         return -EPIPE;
     }
 
@@ -89,7 +89,7 @@
 
 ssize_t LiveDataSource::readAt_l(off64_t offset, void *data, size_t size) {
     if (offset != mOffset) {
-        LOGE("Attempt at reading non-sequentially from LiveDataSource.");
+        ALOGE("Attempt at reading non-sequentially from LiveDataSource.");
         return -EPIPE;
     }
 
diff --git a/media/libstagefright/httplive/LiveSession.cpp b/media/libstagefright/httplive/LiveSession.cpp
index f67cdac..0cddd2e 100644
--- a/media/libstagefright/httplive/LiveSession.cpp
+++ b/media/libstagefright/httplive/LiveSession.cpp
@@ -168,9 +168,9 @@
     }
 
     if (!(mFlags & kFlagIncognito)) {
-        LOGI("onConnect '%s'", url.c_str());
+        ALOGI("onConnect '%s'", url.c_str());
     } else {
-        LOGI("onConnect <URL suppressed>");
+        ALOGI("onConnect <URL suppressed>");
     }
 
     mMasterURL = url;
@@ -179,7 +179,7 @@
     sp<M3UParser> playlist = fetchPlaylist(url.c_str(), &dummy);
 
     if (playlist == NULL) {
-        LOGE("unable to fetch master playlist '%s'.", url.c_str());
+        ALOGE("unable to fetch master playlist '%s'.", url.c_str());
 
         mDataSource->queueEOS(ERROR_IO);
         return;
@@ -207,7 +207,7 @@
 }
 
 void LiveSession::onDisconnect() {
-    LOGI("onDisconnect");
+    ALOGI("onDisconnect");
 
     mDataSource->queueEOS(ERROR_END_OF_STREAM);
 
@@ -215,7 +215,9 @@
     mDisconnectPending = false;
 }
 
-status_t LiveSession::fetchFile(const char *url, sp<ABuffer> *out) {
+status_t LiveSession::fetchFile(
+        const char *url, sp<ABuffer> *out,
+        int64_t range_offset, int64_t range_length) {
     *out = NULL;
 
     sp<DataSource> source;
@@ -234,8 +236,18 @@
             }
         }
 
-        status_t err = mHTTPDataSource->connect(
-                url, mExtraHeaders.isEmpty() ? NULL : &mExtraHeaders);
+        KeyedVector<String8, String8> headers = mExtraHeaders;
+        if (range_offset > 0 || range_length >= 0) {
+            headers.add(
+                    String8("Range"),
+                    String8(
+                        StringPrintf(
+                            "bytes=%lld-%s",
+                            range_offset,
+                            range_length < 0
+                                ? "" : StringPrintf("%lld", range_offset + range_length - 1).c_str()).c_str()));
+        }
+        status_t err = mHTTPDataSource->connect(url, &headers);
 
         if (err != OK) {
             return err;
@@ -260,7 +272,7 @@
         if (bufferRemaining == 0) {
             bufferRemaining = 32768;
 
-            LOGV("increasing download buffer to %d bytes",
+            ALOGV("increasing download buffer to %d bytes",
                  buffer->size() + bufferRemaining);
 
             sp<ABuffer> copy = new ABuffer(buffer->size() + bufferRemaining);
@@ -270,9 +282,21 @@
             buffer = copy;
         }
 
+        size_t maxBytesToRead = bufferRemaining;
+        if (range_length >= 0) {
+            int64_t bytesLeftInRange = range_length - buffer->size();
+            if (bytesLeftInRange < maxBytesToRead) {
+                maxBytesToRead = bytesLeftInRange;
+
+                if (bytesLeftInRange == 0) {
+                    break;
+                }
+            }
+        }
+
         ssize_t n = source->readAt(
                 buffer->size(), buffer->data() + buffer->size(),
-                bufferRemaining);
+                maxBytesToRead);
 
         if (n < 0) {
             return n;
@@ -321,7 +345,7 @@
 
         *unchanged = true;
 
-        LOGV("Playlist unchanged, refresh state is now %d",
+        ALOGV("Playlist unchanged, refresh state is now %d",
              (int)mRefreshState);
 
         return NULL;
@@ -336,7 +360,7 @@
         new M3UParser(url, buffer->data(), buffer->size());
 
     if (playlist->initCheck() != OK) {
-        LOGE("failed to parse .m3u8 playlist");
+        ALOGE("failed to parse .m3u8 playlist");
 
         return NULL;
     }
@@ -357,9 +381,9 @@
     int32_t bandwidthBps;
     if (mHTTPDataSource != NULL
             && mHTTPDataSource->estimateBandwidth(&bandwidthBps)) {
-        LOGV("bandwidth estimated at %.2f kbps", bandwidthBps / 1024.0f);
+        ALOGV("bandwidth estimated at %.2f kbps", bandwidthBps / 1024.0f);
     } else {
-        LOGV("no bandwidth estimate.");
+        ALOGV("no bandwidth estimate.");
         return 0;  // Pick the lowest bandwidth stream by default.
     }
 
@@ -369,7 +393,7 @@
         long maxBw = strtoul(value, &end, 10);
         if (end > value && *end == '\0') {
             if (maxBw > 0 && bandwidthBps > maxBw) {
-                LOGV("bandwidth capped to %ld bps", maxBw);
+                ALOGV("bandwidth capped to %ld bps", maxBw);
                 bandwidthBps = maxBw;
             }
         }
@@ -507,7 +531,7 @@
                 // We succeeded in fetching the playlist, but it was
                 // unchanged from the last time we tried.
             } else {
-                LOGE("failed to load playlist at url '%s'", url.c_str());
+                ALOGE("failed to load playlist at url '%s'", url.c_str());
                 mDataSource->queueEOS(ERROR_IO);
                 return;
             }
@@ -572,7 +596,7 @@
                 int32_t newSeqNumber = firstSeqNumberInPlaylist + index;
 
                 if (newSeqNumber != mSeqNumber) {
-                    LOGI("seeking to seq no %d", newSeqNumber);
+                    ALOGI("seeking to seq no %d", newSeqNumber);
 
                     mSeqNumber = newSeqNumber;
 
@@ -609,7 +633,7 @@
         if (mPrevBandwidthIndex != (ssize_t)bandwidthIndex) {
             // Go back to the previous bandwidth.
 
-            LOGI("new bandwidth does not have the sequence number "
+            ALOGI("new bandwidth does not have the sequence number "
                  "we're looking for, switching back to previous bandwidth");
 
             mLastPlaylistFetchTimeUs = -1;
@@ -629,13 +653,13 @@
             // we've missed the boat, let's start from the lowest sequence
             // number available and signal a discontinuity.
 
-            LOGI("We've missed the boat, restarting playback.");
+            ALOGI("We've missed the boat, restarting playback.");
             mSeqNumber = lastSeqNumberInPlaylist;
             explicitDiscontinuity = true;
 
             // fall through
         } else {
-            LOGE("Cannot find sequence number %d in playlist "
+            ALOGE("Cannot find sequence number %d in playlist "
                  "(contains %d - %d)",
                  mSeqNumber, firstSeqNumberInPlaylist,
                  firstSeqNumberInPlaylist + mPlaylist->size() - 1);
@@ -659,10 +683,17 @@
         explicitDiscontinuity = true;
     }
 
+    int64_t range_offset, range_length;
+    if (!itemMeta->findInt64("range-offset", &range_offset)
+            || !itemMeta->findInt64("range-length", &range_length)) {
+        range_offset = 0;
+        range_length = -1;
+    }
+
     sp<ABuffer> buffer;
-    status_t err = fetchFile(uri.c_str(), &buffer);
+    status_t err = fetchFile(uri.c_str(), &buffer, range_offset, range_length);
     if (err != OK) {
-        LOGE("failed to fetch .ts segment at url '%s'", uri.c_str());
+        ALOGE("failed to fetch .ts segment at url '%s'", uri.c_str());
         mDataSource->queueEOS(err);
         return;
     }
@@ -672,7 +703,7 @@
     err = decryptBuffer(mSeqNumber - firstSeqNumberInPlaylist, buffer);
 
     if (err != OK) {
-        LOGE("decryptBuffer failed w/ error %d", err);
+        ALOGE("decryptBuffer failed w/ error %d", err);
 
         mDataSource->queueEOS(err);
         return;
@@ -681,7 +712,7 @@
     if (buffer->size() == 0 || buffer->data()[0] != 0x47) {
         // Not a transport stream???
 
-        LOGE("This doesn't look like a transport stream...");
+        ALOGE("This doesn't look like a transport stream...");
 
         mBandwidthItems.removeAt(bandwidthIndex);
 
@@ -690,7 +721,7 @@
             return;
         }
 
-        LOGI("Retrying with a different bandwidth stream.");
+        ALOGI("Retrying with a different bandwidth stream.");
 
         mLastPlaylistFetchTimeUs = -1;
         bandwidthIndex = getBandwidthIndex();
@@ -713,7 +744,7 @@
     if (seekDiscontinuity || explicitDiscontinuity || bandwidthChanged) {
         // Signal discontinuity.
 
-        LOGI("queueing discontinuity (seek=%d, explicit=%d, bandwidthChanged=%d)",
+        ALOGI("queueing discontinuity (seek=%d, explicit=%d, bandwidthChanged=%d)",
              seekDiscontinuity, explicitDiscontinuity, bandwidthChanged);
 
         sp<ABuffer> tmp = new ABuffer(188);
@@ -765,13 +796,13 @@
     if (method == "NONE") {
         return OK;
     } else if (!(method == "AES-128")) {
-        LOGE("Unsupported cipher method '%s'", method.c_str());
+        ALOGE("Unsupported cipher method '%s'", method.c_str());
         return ERROR_UNSUPPORTED;
     }
 
     AString keyURI;
     if (!itemMeta->findString("cipher-uri", &keyURI)) {
-        LOGE("Missing key uri");
+        ALOGE("Missing key uri");
         return ERROR_MALFORMED;
     }
 
@@ -813,7 +844,7 @@
         }
 
         if (err != OK) {
-            LOGE("failed to fetch cipher key from '%s'.", keyURI.c_str());
+            ALOGE("failed to fetch cipher key from '%s'.", keyURI.c_str());
             return ERROR_IO;
         }
 
@@ -822,7 +853,7 @@
 
     AES_KEY aes_key;
     if (AES_set_decrypt_key(key->data(), 128, &aes_key) != 0) {
-        LOGE("failed to set AES decryption key.");
+        ALOGE("failed to set AES decryption key.");
         return UNKNOWN_ERROR;
     }
 
@@ -832,7 +863,7 @@
     if (itemMeta->findString("cipher-iv", &iv)) {
         if ((!iv.startsWith("0x") && !iv.startsWith("0X"))
                 || iv.size() != 16 * 2 + 2) {
-            LOGE("malformed cipher IV '%s'.", iv.c_str());
+            ALOGE("malformed cipher IV '%s'.", iv.c_str());
             return ERROR_MALFORMED;
         }
 
@@ -841,7 +872,7 @@
             char c1 = tolower(iv.c_str()[2 + 2 * i]);
             char c2 = tolower(iv.c_str()[3 + 2 * i]);
             if (!isxdigit(c1) || !isxdigit(c2)) {
-                LOGE("malformed cipher IV '%s'.", iv.c_str());
+                ALOGE("malformed cipher IV '%s'.", iv.c_str());
                 return ERROR_MALFORMED;
             }
             uint8_t nibble1 = isdigit(c1) ? c1 - '0' : c1 - 'a' + 10;
diff --git a/media/libstagefright/httplive/M3UParser.cpp b/media/libstagefright/httplive/M3UParser.cpp
index 9df9f59..7d3cf05 100644
--- a/media/libstagefright/httplive/M3UParser.cpp
+++ b/media/libstagefright/httplive/M3UParser.cpp
@@ -101,7 +101,7 @@
         // "url" is already an absolute URL, ignore base URL.
         out->setTo(url);
 
-        LOGV("base:'%s', url:'%s' => '%s'", baseURL, url, out->c_str());
+        ALOGV("base:'%s', url:'%s' => '%s'", baseURL, url, out->c_str());
 
         return true;
     }
@@ -140,7 +140,7 @@
         }
     }
 
-    LOGV("base:'%s', url:'%s' => '%s'", baseURL, url, out->c_str());
+    ALOGV("base:'%s', url:'%s' => '%s'", baseURL, url, out->c_str());
 
     return true;
 }
@@ -152,6 +152,7 @@
 
     const char *data = (const char *)_data;
     size_t offset = 0;
+    uint64_t segmentRangeOffset = 0;
     while (offset < size) {
         size_t offsetLF = offset;
         while (offsetLF < size && data[offsetLF] != '\n') {
@@ -168,7 +169,7 @@
             line.setTo(&data[offset], offsetLF - offset);
         }
 
-        // LOGI("#%s#", line.c_str());
+        // ALOGI("#%s#", line.c_str());
 
         if (line.empty()) {
             offset = offsetLF + 1;
@@ -218,6 +219,24 @@
                 }
                 mIsVariantPlaylist = true;
                 err = parseStreamInf(line, &itemMeta);
+            } else if (line.startsWith("#EXT-X-BYTERANGE")) {
+                if (mIsVariantPlaylist) {
+                    return ERROR_MALFORMED;
+                }
+
+                uint64_t length, offset;
+                err = parseByteRange(line, segmentRangeOffset, &length, &offset);
+
+                if (err == OK) {
+                    if (itemMeta == NULL) {
+                        itemMeta = new AMessage;
+                    }
+
+                    itemMeta->setInt64("range-offset", offset);
+                    itemMeta->setInt64("range-length", length);
+
+                    segmentRangeOffset = offset + length;
+                }
             }
 
             if (err != OK) {
@@ -332,7 +351,7 @@
         AString val(attr, equalPos + 1, attr.size() - equalPos - 1);
         val.trim();
 
-        LOGV("key=%s value=%s", key.c_str(), val.c_str());
+        ALOGV("key=%s value=%s", key.c_str(), val.c_str());
 
         if (!strcasecmp("bandwidth", key.c_str())) {
             const char *s = val.c_str();
@@ -410,7 +429,7 @@
         AString val(attr, equalPos + 1, attr.size() - equalPos - 1);
         val.trim();
 
-        LOGV("key=%s value=%s", key.c_str(), val.c_str());
+        ALOGV("key=%s value=%s", key.c_str(), val.c_str());
 
         key.tolower();
 
@@ -432,7 +451,7 @@
                 if (MakeURL(baseURI.c_str(), val.c_str(), &absURI)) {
                     val = absURI;
                 } else {
-                    LOGE("failed to make absolute url for '%s'.",
+                    ALOGE("failed to make absolute url for '%s'.",
                          val.c_str());
                 }
             }
@@ -447,6 +466,52 @@
 }
 
 // static
+status_t M3UParser::parseByteRange(
+        const AString &line, uint64_t curOffset,
+        uint64_t *length, uint64_t *offset) {
+    ssize_t colonPos = line.find(":");
+
+    if (colonPos < 0) {
+        return ERROR_MALFORMED;
+    }
+
+    ssize_t atPos = line.find("@", colonPos + 1);
+
+    AString lenStr;
+    if (atPos < 0) {
+        lenStr = AString(line, colonPos + 1, line.size() - colonPos - 1);
+    } else {
+        lenStr = AString(line, colonPos + 1, atPos - colonPos - 1);
+    }
+
+    lenStr.trim();
+
+    const char *s = lenStr.c_str();
+    char *end;
+    *length = strtoull(s, &end, 10);
+
+    if (s == end || *end != '\0') {
+        return ERROR_MALFORMED;
+    }
+
+    if (atPos >= 0) {
+        AString offStr = AString(line, atPos + 1, line.size() - atPos - 1);
+        offStr.trim();
+
+        const char *s = offStr.c_str();
+        *offset = strtoull(s, &end, 10);
+
+        if (s == end || *end != '\0') {
+            return ERROR_MALFORMED;
+        }
+    } else {
+        *offset = curOffset;
+    }
+
+    return OK;
+}
+
+// static
 status_t M3UParser::ParseInt32(const char *s, int32_t *x) {
     char *end;
     long lval = strtol(s, &end, 10);
diff --git a/media/libstagefright/id3/ID3.cpp b/media/libstagefright/id3/ID3.cpp
index 45e018d..6dde9d8 100644
--- a/media/libstagefright/id3/ID3.cpp
+++ b/media/libstagefright/id3/ID3.cpp
@@ -129,7 +129,7 @@
     }
 
     if (size > kMaxMetadataSize) {
-        LOGE("skipping huge ID3 metadata of size %d", size);
+        ALOGE("skipping huge ID3 metadata of size %d", size);
         return false;
     }
 
@@ -160,7 +160,7 @@
             success = removeUnsynchronizationV2_4(true /* iTunesHack */);
 
             if (success) {
-                LOGV("Had to apply the iTunes hack to parse this ID3 tag");
+                ALOGV("Had to apply the iTunes hack to parse this ID3 tag");
             }
         }
 
@@ -174,7 +174,7 @@
             return false;
         }
     } else if (header.flags & 0x80) {
-        LOGV("removing unsynchronization");
+        ALOGV("removing unsynchronization");
 
         removeUnsynchronization();
     }
@@ -219,7 +219,7 @@
             }
 
             if (extendedFlags & 0x8000) {
-                LOGV("have crc");
+                ALOGV("have crc");
             }
         }
     } else if (header.version_major == 4 && (header.flags & 0x40)) {
@@ -580,7 +580,7 @@
             mFrameSize += 6;
 
             if (mOffset + mFrameSize > mParent.mSize) {
-                LOGV("partial frame at offset %d (size = %d, bytes-remaining = %d)",
+                ALOGV("partial frame at offset %d (size = %d, bytes-remaining = %d)",
                      mOffset, mFrameSize, mParent.mSize - mOffset - 6);
                 return;
             }
@@ -621,7 +621,7 @@
             mFrameSize = 10 + baseSize;
 
             if (mOffset + mFrameSize > mParent.mSize) {
-                LOGV("partial frame at offset %d (size = %d, bytes-remaining = %d)",
+                ALOGV("partial frame at offset %d (size = %d, bytes-remaining = %d)",
                      mOffset, mFrameSize, mParent.mSize - mOffset - 10);
                 return;
             }
@@ -634,7 +634,7 @@
                 // Per-frame unsynchronization and data-length indicator
                 // have already been taken care of.
 
-                LOGV("Skipping unsupported frame (compression, encryption "
+                ALOGV("Skipping unsupported frame (compression, encryption "
                      "or per-frame unsynchronization flagged");
 
                 mOffset += mFrameSize;
diff --git a/media/libstagefright/include/AACExtractor.h b/media/libstagefright/include/AACExtractor.h
index 8e5657b..e98ca82 100644
--- a/media/libstagefright/include/AACExtractor.h
+++ b/media/libstagefright/include/AACExtractor.h
@@ -29,7 +29,7 @@
 
 class AACExtractor : public MediaExtractor {
 public:
-    AACExtractor(const sp<DataSource> &source);
+    AACExtractor(const sp<DataSource> &source, const sp<AMessage> &meta);
 
     virtual size_t countTracks();
     virtual sp<MediaSource> getTrack(size_t index);
diff --git a/media/libstagefright/include/AwesomePlayer.h b/media/libstagefright/include/AwesomePlayer.h
index 0985f47..82c6476 100644
--- a/media/libstagefright/include/AwesomePlayer.h
+++ b/media/libstagefright/include/AwesomePlayer.h
@@ -290,6 +290,7 @@
 
     bool isStreamingHTTP() const;
     void sendCacheStats();
+    void checkDrmStatus(const sp<DataSource>& dataSource);
 
     enum FlagMode {
         SET,
diff --git a/media/libstagefright/include/ChromiumHTTPDataSource.h b/media/libstagefright/include/ChromiumHTTPDataSource.h
index 18f8913..82e08fd 100644
--- a/media/libstagefright/include/ChromiumHTTPDataSource.h
+++ b/media/libstagefright/include/ChromiumHTTPDataSource.h
@@ -43,7 +43,7 @@
     virtual status_t getSize(off64_t *size);
     virtual uint32_t flags();
 
-    virtual sp<DecryptHandle> DrmInitialization();
+    virtual sp<DecryptHandle> DrmInitialization(const char *mime);
 
     virtual void getDrmInfo(sp<DecryptHandle> &handle, DrmManagerClient **client);
 
diff --git a/media/libstagefright/include/DataUriSource.h b/media/libstagefright/include/DataUriSource.h
new file mode 100644
index 0000000..d223c06
--- /dev/null
+++ b/media/libstagefright/include/DataUriSource.h
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2011 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 DATA_URI_SOURCE_H_
+
+#define DATA_URI_SOURCE_H_
+
+#include <stdio.h>
+
+#include <media/stagefright/DataSource.h>
+#include <media/stagefright/MediaErrors.h>
+#include <media/stagefright/foundation/AString.h>
+
+namespace android {
+
+class DataUriSource : public DataSource {
+public:
+    DataUriSource(const char *uri);
+
+    virtual status_t initCheck() const {
+        return mInited;
+    }
+
+    virtual ssize_t readAt(off64_t offset, void *data, size_t size);
+
+    virtual status_t getSize(off64_t *size) {
+        if (mInited != OK) {
+            return mInited;
+        }
+
+        *size = mData.size();
+        return OK;
+    }
+
+    virtual String8 getUri() {
+        return mDataUri;
+    }
+
+    virtual String8 getMIMEType() const {
+        return mMimeType;
+    }
+
+protected:
+    virtual ~DataUriSource() {
+        // Nothing to delete.
+    }
+
+private:
+    const String8 mDataUri;
+
+    String8 mMimeType;
+    // Use AString because individual bytes may not be valid UTF8 chars.
+    AString mData;
+    status_t mInited;
+
+    // Disallow copy and assign.
+    DataUriSource(const DataUriSource &);
+    DataUriSource &operator=(const DataUriSource &);
+};
+
+}  // namespace android
+
+#endif  // DATA_URI_SOURCE_H_
diff --git a/media/libstagefright/include/LiveSession.h b/media/libstagefright/include/LiveSession.h
index 116ed0e..3a11612 100644
--- a/media/libstagefright/include/LiveSession.h
+++ b/media/libstagefright/include/LiveSession.h
@@ -120,7 +120,10 @@
     void onMonitorQueue();
     void onSeek(const sp<AMessage> &msg);
 
-    status_t fetchFile(const char *url, sp<ABuffer> *out);
+    status_t fetchFile(
+            const char *url, sp<ABuffer> *out,
+            int64_t range_offset = 0, int64_t range_length = -1);
+
     sp<M3UParser> fetchPlaylist(const char *url, bool *unchanged);
     size_t getBandwidthIndex();
 
diff --git a/media/libstagefright/include/M3UParser.h b/media/libstagefright/include/M3UParser.h
index 478582d..e30d6fd 100644
--- a/media/libstagefright/include/M3UParser.h
+++ b/media/libstagefright/include/M3UParser.h
@@ -72,6 +72,10 @@
     static status_t parseCipherInfo(
             const AString &line, sp<AMessage> *meta, const AString &baseURI);
 
+    static status_t parseByteRange(
+            const AString &line, uint64_t curOffset,
+            uint64_t *length, uint64_t *offset);
+
     static status_t ParseInt32(const char *s, int32_t *x);
     static status_t ParseDouble(const char *s, double *x);
 
diff --git a/media/libstagefright/include/NuCachedSource2.h b/media/libstagefright/include/NuCachedSource2.h
index 7a03e7e..c27a29b 100644
--- a/media/libstagefright/include/NuCachedSource2.h
+++ b/media/libstagefright/include/NuCachedSource2.h
@@ -40,7 +40,7 @@
     virtual status_t getSize(off64_t *size);
     virtual uint32_t flags();
 
-    virtual sp<DecryptHandle> DrmInitialization();
+    virtual sp<DecryptHandle> DrmInitialization(const char* mime);
     virtual void getDrmInfo(sp<DecryptHandle> &handle, DrmManagerClient **client);
     virtual String8 getUri();
 
diff --git a/media/libstagefright/include/WVMExtractor.h b/media/libstagefright/include/WVMExtractor.h
index deecd25..9f763f9 100644
--- a/media/libstagefright/include/WVMExtractor.h
+++ b/media/libstagefright/include/WVMExtractor.h
@@ -23,6 +23,8 @@
 
 namespace android {
 
+struct AMessage;
+class String8;
 class DataSource;
 
 class WVMLoadableExtractor : public MediaExtractor {
@@ -58,6 +60,8 @@
     // is used.
     void setAdaptiveStreamingMode(bool adaptive);
 
+    static bool getVendorLibHandle();
+
 protected:
     virtual ~WVMExtractor();
 
@@ -69,6 +73,10 @@
     WVMExtractor &operator=(const WVMExtractor &);
 };
 
+bool SniffWVM(
+        const sp<DataSource> &source, String8 *mimeType, float *confidence,
+        sp<AMessage> *);
+
 }  // namespace android
 
 #endif  // DRM_EXTRACTOR_H_
diff --git a/media/libstagefright/matroska/MatroskaExtractor.cpp b/media/libstagefright/matroska/MatroskaExtractor.cpp
index 20a25d7..4fbf47e 100644
--- a/media/libstagefright/matroska/MatroskaExtractor.cpp
+++ b/media/libstagefright/matroska/MatroskaExtractor.cpp
@@ -180,7 +180,7 @@
         CHECK_GE(avccSize, 5u);
 
         mNALSizeLen = 1 + (avcc[4] & 3);
-        LOGV("mNALSizeLen = %d", mNALSizeLen);
+        ALOGV("mNALSizeLen = %d", mNALSizeLen);
     } else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AAC)) {
         mType = AAC;
     }
@@ -230,7 +230,7 @@
 void BlockIterator::advance_l() {
     for (;;) {
         long res = mCluster->GetEntry(mBlockEntryIndex, mBlockEntry);
-        LOGV("GetEntry returned %ld", res);
+        ALOGV("GetEntry returned %ld", res);
 
         long long pos;
         long len;
@@ -240,12 +240,12 @@
             CHECK_EQ(res, mkvparser::E_BUFFER_NOT_FULL);
 
             res = mCluster->Parse(pos, len);
-            LOGV("Parse returned %ld", res);
+            ALOGV("Parse returned %ld", res);
 
             if (res < 0) {
                 // I/O error
 
-                LOGE("Cluster::Parse returned result %ld", res);
+                ALOGE("Cluster::Parse returned result %ld", res);
 
                 mCluster = NULL;
                 break;
@@ -258,7 +258,7 @@
             const mkvparser::Cluster *nextCluster;
             res = mExtractor->mSegment->ParseNext(
                     mCluster, nextCluster, pos, len);
-            LOGV("ParseNext returned %ld", res);
+            ALOGV("ParseNext returned %ld", res);
 
             if (res > 0) {
                 // EOF
@@ -274,7 +274,7 @@
             mCluster = nextCluster;
 
             res = mCluster->Parse(pos, len);
-            LOGV("Parse (2) returned %ld", res);
+            ALOGV("Parse (2) returned %ld", res);
             CHECK_GE(res, 0);
 
             mBlockEntryIndex = 0;
@@ -563,7 +563,7 @@
 
 #if 0
     const mkvparser::SegmentInfo *info = mSegment->GetInfo();
-    LOGI("muxing app: %s, writing app: %s",
+    ALOGI("muxing app: %s, writing app: %s",
          info->GetMuxingAppAsUTF8(),
          info->GetWritingAppAsUTF8());
 #endif
@@ -687,8 +687,8 @@
         }
 
         const char *const codecID = track->GetCodecId();
-        LOGV("codec id = %s", codecID);
-        LOGV("codec name = %s", track->GetCodecNameAsUTF8());
+        ALOGV("codec id = %s", codecID);
+        ALOGV("codec name = %s", track->GetCodecNameAsUTF8());
 
         size_t codecPrivateSize;
         const unsigned char *codecPrivate =
diff --git a/media/libstagefright/mpeg2ts/ATSParser.cpp b/media/libstagefright/mpeg2ts/ATSParser.cpp
index 6cec63a..3f4de1f 100644
--- a/media/libstagefright/mpeg2ts/ATSParser.cpp
+++ b/media/libstagefright/mpeg2ts/ATSParser.cpp
@@ -39,7 +39,7 @@
 
 // I want the expression "y" evaluated even if verbose logging is off.
 #define MY_LOGV(x, y) \
-    do { unsigned tmp = y; LOGV(x, tmp); } while (0)
+    do { unsigned tmp = y; ALOGV(x, tmp); } while (0)
 
 static const size_t kTSPacketSize = 188;
 
@@ -138,7 +138,7 @@
       mProgramMapPID(programMapPID),
       mFirstPTSValid(false),
       mFirstPTS(0) {
-    LOGV("new program number %u", programNumber);
+    ALOGV("new program number %u", programNumber);
 }
 
 bool ATSParser::Program::parsePID(
@@ -188,18 +188,18 @@
 
 status_t ATSParser::Program::parseProgramMap(ABitReader *br) {
     unsigned table_id = br->getBits(8);
-    LOGV("  table_id = %u", table_id);
+    ALOGV("  table_id = %u", table_id);
     CHECK_EQ(table_id, 0x02u);
 
     unsigned section_syntax_indicator = br->getBits(1);
-    LOGV("  section_syntax_indicator = %u", section_syntax_indicator);
+    ALOGV("  section_syntax_indicator = %u", section_syntax_indicator);
     CHECK_EQ(section_syntax_indicator, 1u);
 
     CHECK_EQ(br->getBits(1), 0u);
     MY_LOGV("  reserved = %u", br->getBits(2));
 
     unsigned section_length = br->getBits(12);
-    LOGV("  section_length = %u", section_length);
+    ALOGV("  section_length = %u", section_length);
     CHECK_EQ(section_length & 0xc00, 0u);
     CHECK_LE(section_length, 1021u);
 
@@ -214,7 +214,7 @@
     MY_LOGV("  reserved = %u", br->getBits(4));
 
     unsigned program_info_length = br->getBits(12);
-    LOGV("  program_info_length = %u", program_info_length);
+    ALOGV("  program_info_length = %u", program_info_length);
     CHECK_EQ(program_info_length & 0xc00, 0u);
 
     br->skipBits(program_info_length * 8);  // skip descriptors
@@ -230,17 +230,17 @@
         CHECK_GE(infoBytesRemaining, 5u);
 
         unsigned streamType = br->getBits(8);
-        LOGV("    stream_type = 0x%02x", streamType);
+        ALOGV("    stream_type = 0x%02x", streamType);
 
         MY_LOGV("    reserved = %u", br->getBits(3));
 
         unsigned elementaryPID = br->getBits(13);
-        LOGV("    elementary_PID = 0x%04x", elementaryPID);
+        ALOGV("    elementary_PID = 0x%04x", elementaryPID);
 
         MY_LOGV("    reserved = %u", br->getBits(4));
 
         unsigned ES_info_length = br->getBits(12);
-        LOGV("    ES_info_length = %u", ES_info_length);
+        ALOGV("    ES_info_length = %u", ES_info_length);
         CHECK_EQ(ES_info_length & 0xc00, 0u);
 
         CHECK_GE(infoBytesRemaining - 5, ES_info_length);
@@ -253,7 +253,7 @@
             MY_LOGV("      tag = 0x%02x", br->getBits(8));
 
             unsigned descLength = br->getBits(8);
-            LOGV("      len = %u", descLength);
+            ALOGV("      len = %u", descLength);
 
             CHECK_GE(info_bytes_remaining, 2 + descLength);
 
@@ -282,7 +282,7 @@
         ssize_t index = mStreams.indexOfKey(info.mPID);
 
         if (index >= 0 && mStreams.editValueAt(index)->type() != info.mType) {
-            LOGI("uh oh. stream PIDs have changed.");
+            ALOGI("uh oh. stream PIDs have changed.");
             PIDsChanged = true;
             break;
         }
@@ -290,18 +290,18 @@
 
     if (PIDsChanged) {
 #if 0
-        LOGI("before:");
+        ALOGI("before:");
         for (size_t i = 0; i < mStreams.size(); ++i) {
             sp<Stream> stream = mStreams.editValueAt(i);
 
-            LOGI("PID 0x%08x => type 0x%02x", stream->pid(), stream->type());
+            ALOGI("PID 0x%08x => type 0x%02x", stream->pid(), stream->type());
         }
 
-        LOGI("after:");
+        ALOGI("after:");
         for (size_t i = 0; i < infos.size(); ++i) {
             StreamInfo &info = infos.editItemAt(i);
 
-            LOGI("PID 0x%08x => type 0x%02x", info.mPID, info.mType);
+            ALOGI("PID 0x%08x => type 0x%02x", info.mPID, info.mType);
         }
 #endif
 
@@ -340,7 +340,7 @@
         }
 
         if (!success) {
-            LOGI("Stream PIDs changed and we cannot recover.");
+            ALOGI("Stream PIDs changed and we cannot recover.");
             return ERROR_MALFORMED;
         }
     }
@@ -428,7 +428,7 @@
             break;
     }
 
-    LOGV("new stream PID 0x%02x, type 0x%02x", elementaryPID, streamType);
+    ALOGV("new stream PID 0x%02x, type 0x%02x", elementaryPID, streamType);
 
     if (mQueue != NULL) {
         mBuffer = new ABuffer(192 * 1024);
@@ -475,7 +475,7 @@
         // Increment in multiples of 64K.
         neededSize = (neededSize + 65535) & ~65535;
 
-        LOGI("resizing buffer to %d bytes", neededSize);
+        ALOGI("resizing buffer to %d bytes", neededSize);
 
         sp<ABuffer> newBuffer = new ABuffer(neededSize);
         memcpy(newBuffer->data(), mBuffer->data(), mBuffer->size());
@@ -563,10 +563,10 @@
 status_t ATSParser::Stream::parsePES(ABitReader *br) {
     unsigned packet_startcode_prefix = br->getBits(24);
 
-    LOGV("packet_startcode_prefix = 0x%08x", packet_startcode_prefix);
+    ALOGV("packet_startcode_prefix = 0x%08x", packet_startcode_prefix);
 
     if (packet_startcode_prefix != 1) {
-        LOGV("Supposedly payload_unit_start=1 unit does not start "
+        ALOGV("Supposedly payload_unit_start=1 unit does not start "
              "with startcode.");
 
         return ERROR_MALFORMED;
@@ -575,10 +575,10 @@
     CHECK_EQ(packet_startcode_prefix, 0x000001u);
 
     unsigned stream_id = br->getBits(8);
-    LOGV("stream_id = 0x%02x", stream_id);
+    ALOGV("stream_id = 0x%02x", stream_id);
 
     unsigned PES_packet_length = br->getBits(16);
-    LOGV("PES_packet_length = %u", PES_packet_length);
+    ALOGV("PES_packet_length = %u", PES_packet_length);
 
     if (stream_id != 0xbc  // program_stream_map
             && stream_id != 0xbe  // padding_stream
@@ -597,25 +597,25 @@
         MY_LOGV("original_or_copy = %u", br->getBits(1));
 
         unsigned PTS_DTS_flags = br->getBits(2);
-        LOGV("PTS_DTS_flags = %u", PTS_DTS_flags);
+        ALOGV("PTS_DTS_flags = %u", PTS_DTS_flags);
 
         unsigned ESCR_flag = br->getBits(1);
-        LOGV("ESCR_flag = %u", ESCR_flag);
+        ALOGV("ESCR_flag = %u", ESCR_flag);
 
         unsigned ES_rate_flag = br->getBits(1);
-        LOGV("ES_rate_flag = %u", ES_rate_flag);
+        ALOGV("ES_rate_flag = %u", ES_rate_flag);
 
         unsigned DSM_trick_mode_flag = br->getBits(1);
-        LOGV("DSM_trick_mode_flag = %u", DSM_trick_mode_flag);
+        ALOGV("DSM_trick_mode_flag = %u", DSM_trick_mode_flag);
 
         unsigned additional_copy_info_flag = br->getBits(1);
-        LOGV("additional_copy_info_flag = %u", additional_copy_info_flag);
+        ALOGV("additional_copy_info_flag = %u", additional_copy_info_flag);
 
         MY_LOGV("PES_CRC_flag = %u", br->getBits(1));
         MY_LOGV("PES_extension_flag = %u", br->getBits(1));
 
         unsigned PES_header_data_length = br->getBits(8);
-        LOGV("PES_header_data_length = %u", PES_header_data_length);
+        ALOGV("PES_header_data_length = %u", PES_header_data_length);
 
         unsigned optional_bytes_remaining = PES_header_data_length;
 
@@ -633,8 +633,8 @@
             PTS |= br->getBits(15);
             CHECK_EQ(br->getBits(1), 1u);
 
-            LOGV("PTS = %llu", PTS);
-            // LOGI("PTS = %.2f secs", PTS / 90000.0f);
+            ALOGV("PTS = %llu", PTS);
+            // ALOGI("PTS = %.2f secs", PTS / 90000.0f);
 
             optional_bytes_remaining -= 5;
 
@@ -650,7 +650,7 @@
                 DTS |= br->getBits(15);
                 CHECK_EQ(br->getBits(1), 1u);
 
-                LOGV("DTS = %llu", DTS);
+                ALOGV("DTS = %llu", DTS);
 
                 optional_bytes_remaining -= 5;
             }
@@ -668,7 +668,7 @@
             ESCR |= br->getBits(15);
             CHECK_EQ(br->getBits(1), 1u);
 
-            LOGV("ESCR = %llu", ESCR);
+            ALOGV("ESCR = %llu", ESCR);
             MY_LOGV("ESCR_extension = %u", br->getBits(9));
 
             CHECK_EQ(br->getBits(1), 1u);
@@ -697,7 +697,7 @@
                 PES_packet_length - 3 - PES_header_data_length;
 
             if (br->numBitsLeft() < dataLength * 8) {
-                LOGE("PES packet does not carry enough data to contain "
+                ALOGE("PES packet does not carry enough data to contain "
                      "payload. (numBitsLeft = %d, required = %d)",
                      br->numBitsLeft(), dataLength * 8);
 
@@ -718,7 +718,7 @@
             size_t payloadSizeBits = br->numBitsLeft();
             CHECK_EQ(payloadSizeBits % 8, 0u);
 
-            LOGV("There's %d bytes of payload.", payloadSizeBits / 8);
+            ALOGV("There's %d bytes of payload.", payloadSizeBits / 8);
         }
     } else if (stream_id == 0xbe) {  // padding_stream
         CHECK_NE(PES_packet_length, 0u);
@@ -736,7 +736,7 @@
         return OK;
     }
 
-    LOGV("flushing stream 0x%04x size = %d", mElementaryPID, mBuffer->size());
+    ALOGV("flushing stream 0x%04x size = %d", mElementaryPID, mBuffer->size());
 
     ABitReader br(mBuffer->data(), mBuffer->size());
 
@@ -750,7 +750,7 @@
 void ATSParser::Stream::onPayloadData(
         unsigned PTS_DTS_flags, uint64_t PTS, uint64_t DTS,
         const uint8_t *data, size_t size) {
-    LOGV("onPayloadData mStreamType=0x%02x", mStreamType);
+    ALOGV("onPayloadData mStreamType=0x%02x", mStreamType);
 
     int64_t timeUs = 0ll;  // no presentation timestamp available.
     if (PTS_DTS_flags == 2 || PTS_DTS_flags == 3) {
@@ -769,7 +769,7 @@
             sp<MetaData> meta = mQueue->getFormat();
 
             if (meta != NULL) {
-                LOGV("Stream PID 0x%08x of type 0x%02x now has data.",
+                ALOGV("Stream PID 0x%08x of type 0x%02x now has data.",
                      mElementaryPID, mStreamType);
 
                 mSource = new AnotherPacketSource(meta);
@@ -846,18 +846,18 @@
 
 void ATSParser::parseProgramAssociationTable(ABitReader *br) {
     unsigned table_id = br->getBits(8);
-    LOGV("  table_id = %u", table_id);
+    ALOGV("  table_id = %u", table_id);
     CHECK_EQ(table_id, 0x00u);
 
     unsigned section_syntax_indictor = br->getBits(1);
-    LOGV("  section_syntax_indictor = %u", section_syntax_indictor);
+    ALOGV("  section_syntax_indictor = %u", section_syntax_indictor);
     CHECK_EQ(section_syntax_indictor, 1u);
 
     CHECK_EQ(br->getBits(1), 0u);
     MY_LOGV("  reserved = %u", br->getBits(2));
 
     unsigned section_length = br->getBits(12);
-    LOGV("  section_length = %u", section_length);
+    ALOGV("  section_length = %u", section_length);
     CHECK_EQ(section_length & 0xc00, 0u);
 
     MY_LOGV("  transport_stream_id = %u", br->getBits(16));
@@ -872,7 +872,7 @@
 
     for (size_t i = 0; i < numProgramBytes / 4; ++i) {
         unsigned program_number = br->getBits(16);
-        LOGV("    program_number = %u", program_number);
+        ALOGV("    program_number = %u", program_number);
 
         MY_LOGV("    reserved = %u", br->getBits(3));
 
@@ -881,7 +881,7 @@
         } else {
             unsigned programMapPID = br->getBits(13);
 
-            LOGV("    program_map_PID = 0x%04x", programMapPID);
+            ALOGV("    program_map_PID = 0x%04x", programMapPID);
 
             bool found = false;
             for (size_t index = 0; index < mPrograms.size(); ++index) {
@@ -931,7 +931,7 @@
     }
 
     if (!handled) {
-        LOGV("PID 0x%04x not handled.", PID);
+        ALOGV("PID 0x%04x not handled.", PID);
     }
 
     return OK;
@@ -945,7 +945,7 @@
 }
 
 status_t ATSParser::parseTS(ABitReader *br) {
-    LOGV("---");
+    ALOGV("---");
 
     unsigned sync_byte = br->getBits(8);
     CHECK_EQ(sync_byte, 0x47u);
@@ -953,22 +953,22 @@
     MY_LOGV("transport_error_indicator = %u", br->getBits(1));
 
     unsigned payload_unit_start_indicator = br->getBits(1);
-    LOGV("payload_unit_start_indicator = %u", payload_unit_start_indicator);
+    ALOGV("payload_unit_start_indicator = %u", payload_unit_start_indicator);
 
     MY_LOGV("transport_priority = %u", br->getBits(1));
 
     unsigned PID = br->getBits(13);
-    LOGV("PID = 0x%04x", PID);
+    ALOGV("PID = 0x%04x", PID);
 
     MY_LOGV("transport_scrambling_control = %u", br->getBits(2));
 
     unsigned adaptation_field_control = br->getBits(2);
-    LOGV("adaptation_field_control = %u", adaptation_field_control);
+    ALOGV("adaptation_field_control = %u", adaptation_field_control);
 
     unsigned continuity_counter = br->getBits(4);
-    LOGV("continuity_counter = %u", continuity_counter);
+    ALOGV("continuity_counter = %u", continuity_counter);
 
-    // LOGI("PID = 0x%04x, continuity_counter = %u", PID, continuity_counter);
+    // ALOGI("PID = 0x%04x, continuity_counter = %u", PID, continuity_counter);
 
     if (adaptation_field_control == 2 || adaptation_field_control == 3) {
         parseAdaptationField(br);
diff --git a/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp b/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp
index f782ce5..d708ba6 100644
--- a/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp
+++ b/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp
@@ -143,7 +143,7 @@
 
     int64_t timeUs;
     CHECK(buffer->meta()->findInt64("timeUs", &timeUs));
-    LOGV("queueAccessUnit timeUs=%lld us (%.2f secs)", timeUs, timeUs / 1E6);
+    ALOGV("queueAccessUnit timeUs=%lld us (%.2f secs)", timeUs, timeUs / 1E6);
 
     Mutex::Autolock autoLock(mLock);
     mBuffers.push_back(buffer);
diff --git a/media/libstagefright/mpeg2ts/ESQueue.cpp b/media/libstagefright/mpeg2ts/ESQueue.cpp
index b9a4826..7fd99a8 100644
--- a/media/libstagefright/mpeg2ts/ESQueue.cpp
+++ b/media/libstagefright/mpeg2ts/ESQueue.cpp
@@ -144,7 +144,7 @@
                 }
 
                 if (startOffset > 0) {
-                    LOGI("found something resembling an H.264/MPEG syncword at "
+                    ALOGI("found something resembling an H.264/MPEG syncword at "
                          "offset %ld",
                          startOffset);
                 }
@@ -177,7 +177,7 @@
                 }
 
                 if (startOffset > 0) {
-                    LOGI("found something resembling an H.264/MPEG syncword at "
+                    ALOGI("found something resembling an H.264/MPEG syncword at "
                          "offset %ld",
                          startOffset);
                 }
@@ -210,7 +210,7 @@
                 }
 
                 if (startOffset > 0) {
-                    LOGI("found something resembling an AAC syncword at offset %ld",
+                    ALOGI("found something resembling an AAC syncword at offset %ld",
                          startOffset);
                 }
 
@@ -237,7 +237,7 @@
                 }
 
                 if (startOffset > 0) {
-                    LOGI("found something resembling an MPEG audio "
+                    ALOGI("found something resembling an MPEG audio "
                          "syncword at offset %ld",
                          startOffset);
                 }
@@ -257,7 +257,7 @@
     if (mBuffer == NULL || neededSize > mBuffer->capacity()) {
         neededSize = (neededSize + 65535) & ~65535;
 
-        LOGV("resizing buffer to size %d", neededSize);
+        ALOGV("resizing buffer to size %d", neededSize);
 
         sp<ABuffer> buffer = new ABuffer(neededSize);
         if (mBuffer != NULL) {
@@ -280,7 +280,7 @@
 
 #if 0
     if (mMode == AAC) {
-        LOGI("size = %d, timeUs = %.2f secs", size, timeUs / 1E6);
+        ALOGI("size = %d, timeUs = %.2f secs", size, timeUs / 1E6);
         hexdump(data, size);
     }
 #endif
@@ -337,7 +337,7 @@
             CHECK(mFormat->findInt32(kKeySampleRate, &sampleRate));
             CHECK(mFormat->findInt32(kKeyChannelCount, &numChannels));
 
-            LOGI("found AAC codec config (%d Hz, %d channels)",
+            ALOGI("found AAC codec config (%d Hz, %d channels)",
                  sampleRate, numChannels);
         } else {
             // profile_ObjectType, sampling_frequency_index, private_bits,
@@ -408,7 +408,7 @@
     if (timeUs >= 0) {
         accessUnit->meta()->setInt64("timeUs", timeUs);
     } else {
-        LOGW("no time for AAC access unit");
+        ALOGW("no time for AAC access unit");
     }
 
     return accessUnit;
@@ -445,7 +445,7 @@
     }
 
     if (timeUs == 0ll) {
-        LOGV("Returning 0 timestamp");
+        ALOGV("Returning 0 timestamp");
     }
 
     return timeUs;
@@ -529,7 +529,7 @@
                 dstOffset += pos.nalSize + 4;
             }
 
-            LOGV("accessUnit contains nal types %s", out.c_str());
+            ALOGV("accessUnit contains nal types %s", out.c_str());
 
             const NALPosition &pos = nals.itemAt(nals.size() - 1);
             size_t nextScan = pos.nalOffset + pos.nalSize;
@@ -714,7 +714,7 @@
                 mFormat->setInt32(kKeyWidth, width);
                 mFormat->setInt32(kKeyHeight, height);
 
-                LOGI("found MPEG2 video codec config (%d x %d)", width, height);
+                ALOGI("found MPEG2 video codec config (%d x %d)", width, height);
 
                 sp<ABuffer> csd = new ABuffer(offset);
                 memcpy(csd->data(), data, offset);
@@ -760,7 +760,7 @@
 
                 accessUnit->meta()->setInt64("timeUs", timeUs);
 
-                LOGV("returning MPEG video access unit at time %lld us",
+                ALOGV("returning MPEG video access unit at time %lld us",
                       timeUs);
 
                 // hexdump(accessUnit->data(), accessUnit->size());
@@ -880,7 +880,7 @@
                     mFormat->setInt32(kKeyWidth, width);
                     mFormat->setInt32(kKeyHeight, height);
 
-                    LOGI("found MPEG4 video codec config (%d x %d)",
+                    ALOGI("found MPEG4 video codec config (%d x %d)",
                          width, height);
 
                     sp<ABuffer> csd = new ABuffer(offset);
@@ -919,7 +919,7 @@
 
                     accessUnit->meta()->setInt64("timeUs", timeUs);
 
-                    LOGV("returning MPEG4 video access unit at time %lld us",
+                    ALOGV("returning MPEG4 video access unit at time %lld us",
                          timeUs);
 
                     // hexdump(accessUnit->data(), accessUnit->size());
diff --git a/media/libstagefright/mpeg2ts/MPEG2PSExtractor.cpp b/media/libstagefright/mpeg2ts/MPEG2PSExtractor.cpp
index a089dbf..dd714c9 100644
--- a/media/libstagefright/mpeg2ts/MPEG2PSExtractor.cpp
+++ b/media/libstagefright/mpeg2ts/MPEG2PSExtractor.cpp
@@ -274,10 +274,10 @@
 
     unsigned packet_startcode_prefix = br.getBits(24);
 
-    LOGV("packet_startcode_prefix = 0x%08x", packet_startcode_prefix);
+    ALOGV("packet_startcode_prefix = 0x%08x", packet_startcode_prefix);
 
     if (packet_startcode_prefix != 1) {
-        LOGV("Supposedly payload_unit_start=1 unit does not start "
+        ALOGV("Supposedly payload_unit_start=1 unit does not start "
              "with startcode.");
 
         return ERROR_MALFORMED;
@@ -286,7 +286,7 @@
     CHECK_EQ(packet_startcode_prefix, 0x000001u);
 
     unsigned stream_id = br.getBits(8);
-    LOGV("stream_id = 0x%02x", stream_id);
+    ALOGV("stream_id = 0x%02x", stream_id);
 
     /* unsigned PES_packet_length = */br.getBits(16);
 
@@ -315,7 +315,7 @@
             unsigned descriptor_tag = br.getBits(8);
             unsigned descriptor_length = br.getBits(8);
 
-            LOGI("found descriptor tag 0x%02x of length %u",
+            ALOGI("found descriptor tag 0x%02x of length %u",
                  descriptor_tag, descriptor_length);
 
             if (offset + 2 + descriptor_length > program_stream_info_length) {
@@ -338,7 +338,7 @@
             unsigned stream_type = br.getBits(8);
             unsigned elementary_stream_id = br.getBits(8);
 
-            LOGI("elementary stream id 0x%02x has stream type 0x%02x",
+            ALOGI("elementary stream id 0x%02x has stream type 0x%02x",
                  elementary_stream_id, stream_type);
 
             mStreamTypeByESID.add(elementary_stream_id, stream_type);
@@ -372,25 +372,25 @@
         /* unsigned original_or_copy = */br.getBits(1);
 
         unsigned PTS_DTS_flags = br.getBits(2);
-        LOGV("PTS_DTS_flags = %u", PTS_DTS_flags);
+        ALOGV("PTS_DTS_flags = %u", PTS_DTS_flags);
 
         unsigned ESCR_flag = br.getBits(1);
-        LOGV("ESCR_flag = %u", ESCR_flag);
+        ALOGV("ESCR_flag = %u", ESCR_flag);
 
         unsigned ES_rate_flag = br.getBits(1);
-        LOGV("ES_rate_flag = %u", ES_rate_flag);
+        ALOGV("ES_rate_flag = %u", ES_rate_flag);
 
         unsigned DSM_trick_mode_flag = br.getBits(1);
-        LOGV("DSM_trick_mode_flag = %u", DSM_trick_mode_flag);
+        ALOGV("DSM_trick_mode_flag = %u", DSM_trick_mode_flag);
 
         unsigned additional_copy_info_flag = br.getBits(1);
-        LOGV("additional_copy_info_flag = %u", additional_copy_info_flag);
+        ALOGV("additional_copy_info_flag = %u", additional_copy_info_flag);
 
         /* unsigned PES_CRC_flag = */br.getBits(1);
         /* PES_extension_flag = */br.getBits(1);
 
         unsigned PES_header_data_length = br.getBits(8);
-        LOGV("PES_header_data_length = %u", PES_header_data_length);
+        ALOGV("PES_header_data_length = %u", PES_header_data_length);
 
         unsigned optional_bytes_remaining = PES_header_data_length;
 
@@ -408,8 +408,8 @@
             PTS |= br.getBits(15);
             CHECK_EQ(br.getBits(1), 1u);
 
-            LOGV("PTS = %llu", PTS);
-            // LOGI("PTS = %.2f secs", PTS / 90000.0f);
+            ALOGV("PTS = %llu", PTS);
+            // ALOGI("PTS = %.2f secs", PTS / 90000.0f);
 
             optional_bytes_remaining -= 5;
 
@@ -425,7 +425,7 @@
                 DTS |= br.getBits(15);
                 CHECK_EQ(br.getBits(1), 1u);
 
-                LOGV("DTS = %llu", DTS);
+                ALOGV("DTS = %llu", DTS);
 
                 optional_bytes_remaining -= 5;
             }
@@ -443,7 +443,7 @@
             ESCR |= br.getBits(15);
             CHECK_EQ(br.getBits(1), 1u);
 
-            LOGV("ESCR = %llu", ESCR);
+            ALOGV("ESCR = %llu", ESCR);
             /* unsigned ESCR_extension = */br.getBits(9);
 
             CHECK_EQ(br.getBits(1), 1u);
@@ -471,7 +471,7 @@
             PES_packet_length - 3 - PES_header_data_length;
 
         if (br.numBitsLeft() < dataLength * 8) {
-            LOGE("PES packet does not carry enough data to contain "
+            ALOGE("PES packet does not carry enough data to contain "
                  "payload. (numBitsLeft = %d, required = %d)",
                  br.numBitsLeft(), dataLength * 8);
 
@@ -568,7 +568,7 @@
     if (supported) {
         mQueue = new ElementaryStreamQueue(mode);
     } else {
-        LOGI("unsupported stream ID 0x%02x", stream_id);
+        ALOGI("unsupported stream ID 0x%02x", stream_id);
     }
 }
 
@@ -650,7 +650,7 @@
             sp<MetaData> meta = mQueue->getFormat();
 
             if (meta != NULL) {
-                LOGV("Stream ID 0x%02x now has data.", mStreamID);
+                ALOGV("Stream ID 0x%02x now has data.", mStreamID);
 
                 mSource = new AnotherPacketSource(meta);
                 mSource->queueAccessUnit(accessUnit);
diff --git a/media/libstagefright/mpeg2ts/MPEG2TSExtractor.cpp b/media/libstagefright/mpeg2ts/MPEG2TSExtractor.cpp
index 17cf45a..03033f5 100644
--- a/media/libstagefright/mpeg2ts/MPEG2TSExtractor.cpp
+++ b/media/libstagefright/mpeg2ts/MPEG2TSExtractor.cpp
@@ -199,7 +199,7 @@
         }
     }
 
-    LOGI("haveAudio=%d, haveVideo=%d", haveAudio, haveVideo);
+    ALOGI("haveAudio=%d, haveVideo=%d", haveAudio, haveVideo);
 }
 
 status_t MPEG2TSExtractor::feedMore() {
diff --git a/media/libstagefright/omx/OMX.cpp b/media/libstagefright/omx/OMX.cpp
index 3715fe9..694b12d 100644
--- a/media/libstagefright/omx/OMX.cpp
+++ b/media/libstagefright/omx/OMX.cpp
@@ -115,7 +115,7 @@
 
 void OMX::CallbackDispatcher::dispatch(const omx_message &msg) {
     if (mOwner == NULL) {
-        LOGV("Would have dispatched a message to a node that's already gone.");
+        ALOGV("Would have dispatched a message to a node that's already gone.");
         return;
     }
     mOwner->onMessage(msg);
@@ -231,7 +231,7 @@
             instance, &handle);
 
     if (err != OMX_ErrorNone) {
-        LOGV("FAILED to allocate omx component '%s'", name);
+        ALOGV("FAILED to allocate omx component '%s'", name);
 
         instance->onGetHandleFailed();
 
@@ -384,7 +384,7 @@
         OMX_IN OMX_U32 nData1,
         OMX_IN OMX_U32 nData2,
         OMX_IN OMX_PTR pEventData) {
-    LOGV("OnEvent(%d, %ld, %ld)", eEvent, nData1, nData2);
+    ALOGV("OnEvent(%d, %ld, %ld)", eEvent, nData1, nData2);
 
     omx_message msg;
     msg.type = omx_message::EVENT;
@@ -400,7 +400,7 @@
 
 OMX_ERRORTYPE OMX::OnEmptyBufferDone(
         node_id node, OMX_IN OMX_BUFFERHEADERTYPE *pBuffer) {
-    LOGV("OnEmptyBufferDone buffer=%p", pBuffer);
+    ALOGV("OnEmptyBufferDone buffer=%p", pBuffer);
 
     omx_message msg;
     msg.type = omx_message::EMPTY_BUFFER_DONE;
@@ -414,7 +414,7 @@
 
 OMX_ERRORTYPE OMX::OnFillBufferDone(
         node_id node, OMX_IN OMX_BUFFERHEADERTYPE *pBuffer) {
-    LOGV("OnFillBufferDone buffer=%p", pBuffer);
+    ALOGV("OnFillBufferDone buffer=%p", pBuffer);
 
     omx_message msg;
     msg.type = omx_message::FILL_BUFFER_DONE;
diff --git a/media/libstagefright/omx/OMXMaster.cpp b/media/libstagefright/omx/OMXMaster.cpp
index c8278ab..d698939 100644
--- a/media/libstagefright/omx/OMXMaster.cpp
+++ b/media/libstagefright/omx/OMXMaster.cpp
@@ -81,7 +81,7 @@
         String8 name8(name);
 
         if (mPluginByComponentName.indexOfKey(name8) >= 0) {
-            LOGE("A component of name '%s' already exists, ignoring this one.",
+            ALOGE("A component of name '%s' already exists, ignoring this one.",
                  name8.string());
 
             continue;
@@ -91,7 +91,7 @@
     }
 
     if (err != OMX_ErrorNoMore) {
-        LOGE("OMX plugin failed w/ error 0x%08x after registering %d "
+        ALOGE("OMX plugin failed w/ error 0x%08x after registering %d "
              "components", err, mPluginByComponentName.size());
     }
 }
diff --git a/media/libstagefright/omx/OMXNodeInstance.cpp b/media/libstagefright/omx/OMXNodeInstance.cpp
index 0ff398a..8938e33 100644
--- a/media/libstagefright/omx/OMXNodeInstance.cpp
+++ b/media/libstagefright/omx/OMXNodeInstance.cpp
@@ -142,7 +142,7 @@
     switch (state) {
         case OMX_StateExecuting:
         {
-            LOGV("forcing Executing->Idle");
+            ALOGV("forcing Executing->Idle");
             sendCommand(OMX_CommandStateSet, OMX_StateIdle);
             OMX_ERRORTYPE err;
             int32_t iteration = 0;
@@ -150,7 +150,7 @@
                    && state != OMX_StateIdle
                    && state != OMX_StateInvalid) {
                 if (++iteration > kMaxNumIterations) {
-                    LOGE("component failed to enter Idle state, aborting.");
+                    ALOGE("component failed to enter Idle state, aborting.");
                     state = OMX_StateInvalid;
                     break;
                 }
@@ -168,7 +168,7 @@
 
         case OMX_StateIdle:
         {
-            LOGV("forcing Idle->Loaded");
+            ALOGV("forcing Idle->Loaded");
             sendCommand(OMX_CommandStateSet, OMX_StateLoaded);
 
             freeActiveBuffers();
@@ -179,12 +179,12 @@
                    && state != OMX_StateLoaded
                    && state != OMX_StateInvalid) {
                 if (++iteration > kMaxNumIterations) {
-                    LOGE("component failed to enter Loaded state, aborting.");
+                    ALOGE("component failed to enter Loaded state, aborting.");
                     state = OMX_StateInvalid;
                     break;
                 }
 
-                LOGV("waiting for Loaded state...");
+                ALOGV("waiting for Loaded state...");
                 usleep(100000);
             }
             CHECK_EQ(err, OMX_ErrorNone);
@@ -201,21 +201,21 @@
             break;
     }
 
-    LOGV("calling destroyComponentInstance");
+    ALOGV("calling destroyComponentInstance");
     OMX_ERRORTYPE err = master->destroyComponentInstance(
             static_cast<OMX_COMPONENTTYPE *>(mHandle));
-    LOGV("destroyComponentInstance returned err %d", err);
+    ALOGV("destroyComponentInstance returned err %d", err);
 
     mHandle = NULL;
 
     if (err != OMX_ErrorNone) {
-        LOGE("FreeHandle FAILED with error 0x%08x.", err);
+        ALOGE("FreeHandle FAILED with error 0x%08x.", err);
     }
 
     mOwner->invalidateNodeID(mNodeID);
     mNodeID = NULL;
 
-    LOGV("OMXNodeInstance going away.");
+    ALOGV("OMXNodeInstance going away.");
     delete this;
 
     return StatusFromOMXError(err);
@@ -285,7 +285,7 @@
             &index);
 
     if (err != OMX_ErrorNone) {
-        LOGE("OMX_GetExtensionIndex failed");
+        ALOGE("OMX_GetExtensionIndex failed");
 
         return StatusFromOMXError(err);
     }
@@ -302,7 +302,7 @@
     err = OMX_SetParameter(mHandle, index, &params);
 
     if (err != OMX_ErrorNone) {
-        LOGE("OMX_EnableAndroidNativeBuffers failed with error %d (0x%08x)",
+        ALOGE("OMX_EnableAndroidNativeBuffers failed with error %d (0x%08x)",
                 err, err);
 
         return UNKNOWN_ERROR;
@@ -323,7 +323,7 @@
             &index);
 
     if (err != OMX_ErrorNone) {
-        LOGE("OMX_GetExtensionIndex failed");
+        ALOGE("OMX_GetExtensionIndex failed");
 
         return StatusFromOMXError(err);
     }
@@ -340,7 +340,7 @@
     err = OMX_GetParameter(mHandle, index, &params);
 
     if (err != OMX_ErrorNone) {
-        LOGE("OMX_GetAndroidNativeBufferUsage failed with error %d (0x%08x)",
+        ALOGE("OMX_GetAndroidNativeBufferUsage failed with error %d (0x%08x)",
                 err, err);
         return UNKNOWN_ERROR;
     }
@@ -361,7 +361,7 @@
 
     OMX_ERRORTYPE err = OMX_GetExtensionIndex(mHandle, name, &index);
     if (err != OMX_ErrorNone) {
-        LOGE("OMX_GetExtensionIndex %s failed", name);
+        ALOGE("OMX_GetExtensionIndex %s failed", name);
         return StatusFromOMXError(err);
     }
 
@@ -375,7 +375,7 @@
     params.nPortIndex = portIndex;
     params.bStoreMetaData = enable;
     if ((err = OMX_SetParameter(mHandle, index, &params)) != OMX_ErrorNone) {
-        LOGE("OMX_SetParameter() failed for StoreMetaDataInBuffers: 0x%08x", err);
+        ALOGE("OMX_SetParameter() failed for StoreMetaDataInBuffers: 0x%08x", err);
         return UNKNOWN_ERROR;
     }
     return err;
@@ -395,7 +395,7 @@
             params->size(), static_cast<OMX_U8 *>(params->pointer()));
 
     if (err != OMX_ErrorNone) {
-        LOGE("OMX_UseBuffer failed with error %d (0x%08x)", err, err);
+        ALOGE("OMX_UseBuffer failed with error %d (0x%08x)", err, err);
 
         delete buffer_meta;
         buffer_meta = NULL;
@@ -429,7 +429,7 @@
     OMX_ERRORTYPE err = OMX_GetParameter(mHandle, OMX_IndexParamPortDefinition, &def);
     if (err != OMX_ErrorNone)
     {
-        LOGE("%s::%d:Error getting OMX_IndexParamPortDefinition", __FUNCTION__, __LINE__);
+        ALOGE("%s::%d:Error getting OMX_IndexParamPortDefinition", __FUNCTION__, __LINE__);
         return err;
     }
 
@@ -448,7 +448,7 @@
             bufferHandle);
 
     if (err != OMX_ErrorNone) {
-        LOGE("OMX_UseBuffer failed with error %d (0x%08x)", err, err);
+        ALOGE("OMX_UseBuffer failed with error %d (0x%08x)", err, err);
         delete bufferMeta;
         bufferMeta = NULL;
         *buffer = 0;
@@ -488,7 +488,7 @@
             &index);
 
     if (err != OMX_ErrorNone) {
-        LOGE("OMX_GetExtensionIndex failed");
+        ALOGE("OMX_GetExtensionIndex failed");
 
         return StatusFromOMXError(err);
     }
@@ -510,7 +510,7 @@
     err = OMX_SetParameter(mHandle, index, &params);
 
     if (err != OMX_ErrorNone) {
-        LOGE("OMX_UseAndroidNativeBuffer failed with error %d (0x%08x)", err,
+        ALOGE("OMX_UseAndroidNativeBuffer failed with error %d (0x%08x)", err,
                 err);
 
         delete bufferMeta;
@@ -543,7 +543,7 @@
             mHandle, &header, portIndex, buffer_meta, size);
 
     if (err != OMX_ErrorNone) {
-        LOGE("OMX_AllocateBuffer failed with error %d (0x%08x)", err, err);
+        ALOGE("OMX_AllocateBuffer failed with error %d (0x%08x)", err, err);
 
         delete buffer_meta;
         buffer_meta = NULL;
@@ -576,7 +576,7 @@
             mHandle, &header, portIndex, buffer_meta, params->size());
 
     if (err != OMX_ErrorNone) {
-        LOGE("OMX_AllocateBuffer failed with error %d (0x%08x)", err, err);
+        ALOGE("OMX_AllocateBuffer failed with error %d (0x%08x)", err, err);
 
         delete buffer_meta;
         buffer_meta = NULL;
@@ -672,7 +672,7 @@
 }
 
 void OMXNodeInstance::onObserverDied(OMXMaster *master) {
-    LOGE("!!! Observer died. Quickly, do something, ... anything...");
+    ALOGE("!!! Observer died. Quickly, do something, ... anything...");
 
     // Try to force shutdown of the node and hope for the best.
     freeNode(master);
@@ -742,7 +742,7 @@
     }
 
     if (!found) {
-        LOGW("Attempt to remove an active buffer we know nothing about...");
+        ALOGW("Attempt to remove an active buffer we know nothing about...");
     }
 }
 
diff --git a/media/libstagefright/omx/SimpleSoftOMXComponent.cpp b/media/libstagefright/omx/SimpleSoftOMXComponent.cpp
index b705d00..0914f32 100644
--- a/media/libstagefright/omx/SimpleSoftOMXComponent.cpp
+++ b/media/libstagefright/omx/SimpleSoftOMXComponent.cpp
@@ -589,7 +589,7 @@
 
         if (port->mTransition == PortInfo::DISABLING) {
             if (port->mBuffers.empty()) {
-                LOGV("Port %d now disabled.", i);
+                ALOGV("Port %d now disabled.", i);
 
                 port->mTransition = PortInfo::NONE;
                 notify(OMX_EventCmdComplete, OMX_CommandPortDisable, i, NULL);
@@ -598,7 +598,7 @@
             }
         } else if (port->mTransition == PortInfo::ENABLING) {
             if (port->mDef.bPopulated == OMX_TRUE) {
-                LOGV("Port %d now enabled.", i);
+                ALOGV("Port %d now enabled.", i);
 
                 port->mTransition = PortInfo::NONE;
                 port->mDef.bEnabled = OMX_TRUE;
diff --git a/media/libstagefright/omx/SoftOMXPlugin.cpp b/media/libstagefright/omx/SoftOMXPlugin.cpp
index 1e33f05..da3ae42 100644
--- a/media/libstagefright/omx/SoftOMXPlugin.cpp
+++ b/media/libstagefright/omx/SoftOMXPlugin.cpp
@@ -58,7 +58,7 @@
         const OMX_CALLBACKTYPE *callbacks,
         OMX_PTR appData,
         OMX_COMPONENTTYPE **component) {
-    LOGV("makeComponentInstance '%s'", name);
+    ALOGV("makeComponentInstance '%s'", name);
 
     for (size_t i = 0; i < kNumComponents; ++i) {
         if (strcmp(name, kComponents[i].mName)) {
@@ -72,7 +72,7 @@
         void *libHandle = dlopen(libName.c_str(), RTLD_NOW);
 
         if (libHandle == NULL) {
-            LOGE("unable to dlopen %s", libName.c_str());
+            ALOGE("unable to dlopen %s", libName.c_str());
 
             return OMX_ErrorComponentNotFound;
         }
diff --git a/media/libstagefright/omx/tests/OMXHarness.cpp b/media/libstagefright/omx/tests/OMXHarness.cpp
index d4354db..8faf544 100644
--- a/media/libstagefright/omx/tests/OMXHarness.cpp
+++ b/media/libstagefright/omx/tests/OMXHarness.cpp
@@ -174,7 +174,7 @@
 
 #define EXPECT(condition, info) \
     if (!(condition)) {         \
-        LOGE(info); printf("\n  * " info "\n"); return UNKNOWN_ERROR; \
+        ALOGE(info); printf("\n  * " info "\n"); return UNKNOWN_ERROR; \
     }
 
 #define EXPECT_SUCCESS(err, info) \
@@ -571,7 +571,7 @@
     const char *mime = GetMimeFromComponentRole(componentRole);
 
     if (!mime) {
-        LOGI("Cannot perform seek test with this componentRole (%s)",
+        ALOGI("Cannot perform seek test with this componentRole (%s)",
              componentRole);
 
         return OK;
@@ -597,7 +597,7 @@
     int64_t durationUs;
     CHECK(source->getFormat()->findInt64(kKeyDuration, &durationUs));
 
-    LOGI("stream duration is %lld us (%.2f secs)",
+    ALOGI("stream duration is %lld us (%.2f secs)",
          durationUs, durationUs / 1E6);
 
     static const int32_t kNumIterations = 5000;
@@ -617,19 +617,19 @@
 
             requestedSeekTimeUs = -1;
 
-            LOGI("requesting linear read");
+            ALOGI("requesting linear read");
         } else {
             if (i == 0 || r < 0.55) {
                 // 5% chance of seeking beyond end of stream.
 
                 requestedSeekTimeUs = durationUs;
 
-                LOGI("requesting seek beyond EOF");
+                ALOGI("requesting seek beyond EOF");
             } else {
                 requestedSeekTimeUs =
                     (int64_t)(uniform_rand() * durationUs);
 
-                LOGI("requesting seek to %lld us (%.2f secs)",
+                ALOGI("requesting seek to %lld us (%.2f secs)",
                      requestedSeekTimeUs, requestedSeekTimeUs / 1E6);
             }
 
@@ -649,7 +649,7 @@
                 buffer = NULL;
             }
 
-            LOGI("nearest keyframe is at %lld us (%.2f secs)",
+            ALOGI("nearest keyframe is at %lld us (%.2f secs)",
                  actualSeekTimeUs, actualSeekTimeUs / 1E6);
         }
 
@@ -733,7 +733,7 @@
 status_t Harness::test(
         const char *componentName, const char *componentRole) {
     printf("testing %s [%s] ... ", componentName, componentRole);
-    LOGI("testing %s [%s].", componentName, componentRole);
+    ALOGI("testing %s [%s].", componentName, componentRole);
 
     status_t err1 = testStateTransitions(componentName, componentRole);
     status_t err2 = testSeek(componentName, componentRole);
diff --git a/media/libstagefright/rtsp/AAMRAssembler.cpp b/media/libstagefright/rtsp/AAMRAssembler.cpp
index 328cadf..9d72b1f 100644
--- a/media/libstagefright/rtsp/AAMRAssembler.cpp
+++ b/media/libstagefright/rtsp/AAMRAssembler.cpp
@@ -127,7 +127,7 @@
         mNextExpectedSeqNoValid = true;
         mNextExpectedSeqNo = (uint32_t)buffer->int32Data();
     } else if ((uint32_t)buffer->int32Data() != mNextExpectedSeqNo) {
-        LOGV("Not the sequence number I expected");
+        ALOGV("Not the sequence number I expected");
 
         return WRONG_SEQUENCE_NUMBER;
     }
@@ -138,7 +138,7 @@
         queue->erase(queue->begin());
         ++mNextExpectedSeqNo;
 
-        LOGV("AMR packet too short.");
+        ALOGV("AMR packet too short.");
 
         return MALFORMED_PACKET;
     }
@@ -156,7 +156,7 @@
             queue->erase(queue->begin());
             ++mNextExpectedSeqNo;
 
-            LOGV("Unable to parse TOC.");
+            ALOGV("Unable to parse TOC.");
 
             return MALFORMED_PACKET;
         }
@@ -170,7 +170,7 @@
             queue->erase(queue->begin());
             ++mNextExpectedSeqNo;
 
-            LOGV("Illegal TOC entry.");
+            ALOGV("Illegal TOC entry.");
 
             return MALFORMED_PACKET;
         }
@@ -197,7 +197,7 @@
             queue->erase(queue->begin());
             ++mNextExpectedSeqNo;
 
-            LOGV("AMR packet too short.");
+            ALOGV("AMR packet too short.");
 
             return MALFORMED_PACKET;
         }
diff --git a/media/libstagefright/rtsp/AAVCAssembler.cpp b/media/libstagefright/rtsp/AAVCAssembler.cpp
index 11c6ae7..ed8b1df 100644
--- a/media/libstagefright/rtsp/AAVCAssembler.cpp
+++ b/media/libstagefright/rtsp/AAVCAssembler.cpp
@@ -72,7 +72,7 @@
         mNextExpectedSeqNoValid = true;
         mNextExpectedSeqNo = (uint32_t)buffer->int32Data();
     } else if ((uint32_t)buffer->int32Data() != mNextExpectedSeqNo) {
-        LOGV("Not the sequence number I expected");
+        ALOGV("Not the sequence number I expected");
 
         return WRONG_SEQUENCE_NUMBER;
     }
@@ -83,7 +83,7 @@
     if (size < 1 || (data[0] & 0x80)) {
         // Corrupt.
 
-        LOGV("Ignoring corrupt buffer.");
+        ALOGV("Ignoring corrupt buffer.");
         queue->erase(queue->begin());
 
         ++mNextExpectedSeqNo;
@@ -107,7 +107,7 @@
 
         return success ? OK : MALFORMED_PACKET;
     } else {
-        LOGV("Ignoring unsupported buffer (nalType=%d)", nalType);
+        ALOGV("Ignoring unsupported buffer (nalType=%d)", nalType);
 
         queue->erase(queue->begin());
         ++mNextExpectedSeqNo;
@@ -117,7 +117,7 @@
 }
 
 void AAVCAssembler::addSingleNALUnit(const sp<ABuffer> &buffer) {
-    LOGV("addSingleNALUnit of size %d", buffer->size());
+    ALOGV("addSingleNALUnit of size %d", buffer->size());
 #if !LOG_NDEBUG
     hexdump(buffer->data(), buffer->size());
 #endif
@@ -138,7 +138,7 @@
     size_t size = buffer->size();
 
     if (size < 3) {
-        LOGV("Discarding too small STAP-A packet.");
+        ALOGV("Discarding too small STAP-A packet.");
         return false;
     }
 
@@ -148,7 +148,7 @@
         size_t nalSize = (data[0] << 8) | data[1];
 
         if (size < nalSize + 2) {
-            LOGV("Discarding malformed STAP-A packet.");
+            ALOGV("Discarding malformed STAP-A packet.");
             return false;
         }
 
@@ -164,7 +164,7 @@
     }
 
     if (size != 0) {
-        LOGV("Unexpected padding at end of STAP-A packet.");
+        ALOGV("Unexpected padding at end of STAP-A packet.");
     }
 
     return true;
@@ -184,7 +184,7 @@
     CHECK((indicator & 0x1f) == 28);
 
     if (size < 2) {
-        LOGV("Ignoring malformed FU buffer (size = %d)", size);
+        ALOGV("Ignoring malformed FU buffer (size = %d)", size);
 
         queue->erase(queue->begin());
         ++mNextExpectedSeqNo;
@@ -194,7 +194,7 @@
     if (!(data[1] & 0x80)) {
         // Start bit not set on the first buffer.
 
-        LOGV("Start bit not set on first buffer");
+        ALOGV("Start bit not set on first buffer");
 
         queue->erase(queue->begin());
         ++mNextExpectedSeqNo;
@@ -212,13 +212,13 @@
     if (data[1] & 0x40) {
         // Huh? End bit also set on the first buffer.
 
-        LOGV("Grrr. This isn't fragmented at all.");
+        ALOGV("Grrr. This isn't fragmented at all.");
 
         complete = true;
     } else {
         List<sp<ABuffer> >::iterator it = ++queue->begin();
         while (it != queue->end()) {
-            LOGV("sequence length %d", totalCount);
+            ALOGV("sequence length %d", totalCount);
 
             const sp<ABuffer> &buffer = *it;
 
@@ -226,7 +226,7 @@
             size_t size = buffer->size();
 
             if ((uint32_t)buffer->int32Data() != expectedSeqNo) {
-                LOGV("sequence not complete, expected seqNo %d, got %d",
+                ALOGV("sequence not complete, expected seqNo %d, got %d",
                      expectedSeqNo, (uint32_t)buffer->int32Data());
 
                 return WRONG_SEQUENCE_NUMBER;
@@ -236,7 +236,7 @@
                     || data[0] != indicator
                     || (data[1] & 0x1f) != nalType
                     || (data[1] & 0x80)) {
-                LOGV("Ignoring malformed FU buffer.");
+                ALOGV("Ignoring malformed FU buffer.");
 
                 // Delete the whole start of the FU.
 
@@ -287,7 +287,7 @@
     for (size_t i = 0; i < totalCount; ++i) {
         const sp<ABuffer> &buffer = *it;
 
-        LOGV("piece #%d/%d", i + 1, totalCount);
+        ALOGV("piece #%d/%d", i + 1, totalCount);
 #if !LOG_NDEBUG
         hexdump(buffer->data(), buffer->size());
 #endif
@@ -302,7 +302,7 @@
 
     addSingleNALUnit(unit);
 
-    LOGV("successfully assembled a NAL unit from fragments.");
+    ALOGV("successfully assembled a NAL unit from fragments.");
 
     return OK;
 }
@@ -310,7 +310,7 @@
 void AAVCAssembler::submitAccessUnit() {
     CHECK(!mNALUnits.empty());
 
-    LOGV("Access unit complete (%d nal units)", mNALUnits.size());
+    ALOGV("Access unit complete (%d nal units)", mNALUnits.size());
 
     size_t totalSize = 0;
     for (List<sp<ABuffer> >::iterator it = mNALUnits.begin();
@@ -360,7 +360,7 @@
 
 void AAVCAssembler::packetLost() {
     CHECK(mNextExpectedSeqNoValid);
-    LOGV("packetLost (expected %d)", mNextExpectedSeqNo);
+    ALOGV("packetLost (expected %d)", mNextExpectedSeqNo);
 
     ++mNextExpectedSeqNo;
 
diff --git a/media/libstagefright/rtsp/AMPEG4AudioAssembler.cpp b/media/libstagefright/rtsp/AMPEG4AudioAssembler.cpp
index 11d9c22..b0c7007 100644
--- a/media/libstagefright/rtsp/AMPEG4AudioAssembler.cpp
+++ b/media/libstagefright/rtsp/AMPEG4AudioAssembler.cpp
@@ -196,7 +196,7 @@
 
         unsigned syncExtensionType = bits->getBits(11);
         if (syncExtensionType == 0x2b7) {
-            LOGI("found syncExtension");
+            ALOGI("found syncExtension");
 
             CHECK_EQ(parseAudioObjectType(bits, &extensionAudioObjectType),
                      (status_t)OK);
@@ -217,7 +217,7 @@
                 // Apparently an extension is always considered an even
                 // multiple of 8 bits long.
 
-                LOGI("Skipping %d bits after sync extension",
+                ALOGI("Skipping %d bits after sync extension",
                      8 - (numBitsInExtension & 7));
 
                 bits->skipBits(8 - (numBitsInExtension & 7));
@@ -424,7 +424,7 @@
     }
 
     if (offset < buffer->size()) {
-        LOGI("ignoring %d bytes of trailing data", buffer->size() - offset);
+        ALOGI("ignoring %d bytes of trailing data", buffer->size() - offset);
     }
     CHECK_LE(offset, buffer->size());
 
diff --git a/media/libstagefright/rtsp/AMPEG4ElementaryAssembler.cpp b/media/libstagefright/rtsp/AMPEG4ElementaryAssembler.cpp
index 9f6bd29..2f2e2c2 100644
--- a/media/libstagefright/rtsp/AMPEG4ElementaryAssembler.cpp
+++ b/media/libstagefright/rtsp/AMPEG4ElementaryAssembler.cpp
@@ -203,7 +203,7 @@
         mNextExpectedSeqNoValid = true;
         mNextExpectedSeqNo = (uint32_t)buffer->int32Data();
     } else if ((uint32_t)buffer->int32Data() != mNextExpectedSeqNo) {
-        LOGV("Not the sequence number I expected");
+        ALOGV("Not the sequence number I expected");
 
         return WRONG_SEQUENCE_NUMBER;
     }
@@ -336,7 +336,7 @@
 void AMPEG4ElementaryAssembler::submitAccessUnit() {
     CHECK(!mPackets.empty());
 
-    LOGV("Access unit complete (%d nal units)", mPackets.size());
+    ALOGV("Access unit complete (%d nal units)", mPackets.size());
 
     size_t totalSize = 0;
     for (List<sp<ABuffer> >::iterator it = mPackets.begin();
@@ -383,7 +383,7 @@
 
 void AMPEG4ElementaryAssembler::packetLost() {
     CHECK(mNextExpectedSeqNoValid);
-    LOGV("packetLost (expected %d)", mNextExpectedSeqNo);
+    ALOGV("packetLost (expected %d)", mNextExpectedSeqNo);
 
     ++mNextExpectedSeqNo;
 
diff --git a/media/libstagefright/rtsp/APacketSource.cpp b/media/libstagefright/rtsp/APacketSource.cpp
index 3f4cdb5..6cf1301 100644
--- a/media/libstagefright/rtsp/APacketSource.cpp
+++ b/media/libstagefright/rtsp/APacketSource.cpp
@@ -193,7 +193,7 @@
 
         if (i == 0) {
             FindAVCDimensions(nal, width, height);
-            LOGI("dimensions %dx%d", *width, *height);
+            ALOGI("dimensions %dx%d", *width, *height);
         }
     }
 
@@ -371,7 +371,7 @@
         return NULL;
     }
 
-    LOGI("VOL dimensions = %dx%d", *width, *height);
+    ALOGI("VOL dimensions = %dx%d", *width, *height);
 
     size_t len1 = config->size() + GetSizeWidth(config->size()) + 1;
     size_t len2 = len1 + GetSizeWidth(len1) + 1 + 13;
diff --git a/media/libstagefright/rtsp/ARTPConnection.cpp b/media/libstagefright/rtsp/ARTPConnection.cpp
index cd374e2..8c9dd8d 100644
--- a/media/libstagefright/rtsp/ARTPConnection.cpp
+++ b/media/libstagefright/rtsp/ARTPConnection.cpp
@@ -294,7 +294,7 @@
             if (err == -ECONNRESET) {
                 // socket failure, this stream is dead, Jim.
 
-                LOGW("failed to receive RTP/RTCP datagram.");
+                ALOGW("failed to receive RTP/RTCP datagram.");
                 it = mStreams.erase(it);
                 continue;
             }
@@ -336,7 +336,7 @@
             }
 
             if (buffer->size() > 0) {
-                LOGV("Sending RR...");
+                ALOGV("Sending RR...");
 
                 ssize_t n;
                 do {
@@ -347,7 +347,7 @@
                 } while (n < 0 && errno == EINTR);
 
                 if (n <= 0) {
-                    LOGW("failed to send RTCP receiver report (%s).",
+                    ALOGW("failed to send RTCP receiver report (%s).",
                          n == 0 ? "connection gone" : strerror(errno));
 
                     it = mStreams.erase(it);
@@ -369,7 +369,7 @@
 }
 
 status_t ARTPConnection::receive(StreamInfo *s, bool receiveRTP) {
-    LOGV("receiving %s", receiveRTP ? "RTP" : "RTCP");
+    ALOGV("receiving %s", receiveRTP ? "RTP" : "RTCP");
 
     CHECK(!s->mIsInjected);
 
@@ -396,7 +396,7 @@
 
     buffer->setRange(0, nbytes);
 
-    // LOGI("received %d bytes.", buffer->size());
+    // ALOGI("received %d bytes.", buffer->size());
 
     status_t err;
     if (receiveRTP) {
@@ -561,7 +561,7 @@
 
             default:
             {
-                LOGW("Unknown RTCP packet type %u of size %d",
+                ALOGW("Unknown RTCP packet type %u of size %d",
                      (unsigned)data[1], headerLength);
                 break;
             }
@@ -606,7 +606,7 @@
     uint32_t rtpTime = u32at(&data[16]);
 
 #if 0
-    LOGI("XXX timeUpdate: ssrc=0x%08x, rtpTime %u == ntpTime %.3f",
+    ALOGI("XXX timeUpdate: ssrc=0x%08x, rtpTime %u == ntpTime %.3f",
          id,
          rtpTime,
          (ntpTime >> 32) + (double)(ntpTime & 0xffffffff) / (1ll << 32));
diff --git a/media/libstagefright/rtsp/ARTPSession.cpp b/media/libstagefright/rtsp/ARTPSession.cpp
index c6bcb12..7a05b88 100644
--- a/media/libstagefright/rtsp/ARTPSession.cpp
+++ b/media/libstagefright/rtsp/ARTPSession.cpp
@@ -53,24 +53,24 @@
         if (!mDesc->findAttribute(i, "c=", &connection)) {
             // No per-stream connection information, try global fallback.
             if (!mDesc->findAttribute(0, "c=", &connection)) {
-                LOGE("Unable to find connection attribute.");
+                ALOGE("Unable to find connection attribute.");
                 return mInitCheck;
             }
         }
         if (!(connection == "IN IP4 127.0.0.1")) {
-            LOGE("We only support localhost connections for now.");
+            ALOGE("We only support localhost connections for now.");
             return mInitCheck;
         }
 
         unsigned port;
         if (!validateMediaFormat(i, &port) || (port & 1) != 0) {
-            LOGE("Invalid media format.");
+            ALOGE("Invalid media format.");
             return mInitCheck;
         }
 
         sp<APacketSource> source = new APacketSource(mDesc, i);
         if (source->initCheck() != OK) {
-            LOGE("Unsupported format.");
+            ALOGE("Unsupported format.");
             return mInitCheck;
         }
 
@@ -159,7 +159,7 @@
             printf("access unit complete size=%d\tntp-time=0x%016llx\n",
                    accessUnit->size(), ntpTime);
 #else
-            LOGI("access unit complete, size=%d, ntp-time=%llu",
+            ALOGI("access unit complete, size=%d, ntp-time=%llu",
                  accessUnit->size(), ntpTime);
             hexdump(accessUnit->data(), accessUnit->size());
 #endif
@@ -170,7 +170,7 @@
             CHECK(!memcmp("\x00\x00\x00\x01", accessUnit->data(), 4));
             unsigned x = accessUnit->data()[4];
 
-            LOGI("access unit complete: nalType=0x%02x, nalRefIdc=0x%02x",
+            ALOGI("access unit complete: nalType=0x%02x, nalRefIdc=0x%02x",
                  x & 0x1f, (x & 0x60) >> 5);
 #endif
 
@@ -181,7 +181,7 @@
             int32_t damaged;
             if (accessUnit->meta()->findInt32("damaged", &damaged)
                     && damaged != 0) {
-                LOGI("ignoring damaged AU");
+                ALOGI("ignoring damaged AU");
             } else
 #endif
             {
diff --git a/media/libstagefright/rtsp/ARTPSource.cpp b/media/libstagefright/rtsp/ARTPSource.cpp
index 3aa07ce..ed68790 100644
--- a/media/libstagefright/rtsp/ARTPSource.cpp
+++ b/media/libstagefright/rtsp/ARTPSource.cpp
@@ -147,7 +147,7 @@
     }
 
     if (it != mQueue.end() && (uint32_t)(*it)->int32Data() == seqNum) {
-        LOGW("Discarding duplicate buffer");
+        ALOGW("Discarding duplicate buffer");
         return false;
     }
 
@@ -174,7 +174,7 @@
     mLastFIRRequestUs = nowUs;
 
     if (buffer->size() + 20 > buffer->capacity()) {
-        LOGW("RTCP buffer too small to accomodate FIR.");
+        ALOGW("RTCP buffer too small to accomodate FIR.");
         return;
     }
 
@@ -207,12 +207,12 @@
 
     buffer->setRange(buffer->offset(), buffer->size() + 20);
 
-    LOGV("Added FIR request.");
+    ALOGV("Added FIR request.");
 }
 
 void ARTPSource::addReceiverReport(const sp<ABuffer> &buffer) {
     if (buffer->size() + 32 > buffer->capacity()) {
-        LOGW("RTCP buffer too small to accomodate RR.");
+        ALOGW("RTCP buffer too small to accomodate RR.");
         return;
     }
 
diff --git a/media/libstagefright/rtsp/ARTPWriter.cpp b/media/libstagefright/rtsp/ARTPWriter.cpp
index 5a033e1..0d07043 100644
--- a/media/libstagefright/rtsp/ARTPWriter.cpp
+++ b/media/libstagefright/rtsp/ARTPWriter.cpp
@@ -269,7 +269,7 @@
     status_t err = mSource->read(&mediaBuf);
 
     if (err != OK) {
-        LOGI("reached EOS.");
+        ALOGI("reached EOS.");
 
         Mutex::Autolock autoLock(mLock);
         mFlags |= kFlagEOS;
@@ -277,7 +277,7 @@
     }
 
     if (mediaBuf->range_length() > 0) {
-        LOGV("read buffer of size %d", mediaBuf->range_length());
+        ALOGV("read buffer of size %d", mediaBuf->range_length());
 
         if (mMode == H264) {
             StripStartcode(mediaBuf);
@@ -520,7 +520,7 @@
         sdp.append("a=fmtp:" PT_STR " octed-align\r\n");
     }
 
-    LOGI("%s", sdp.c_str());
+    ALOGI("%s", sdp.c_str());
 }
 
 void ARTPWriter::makeH264SPropParamSets(MediaBuffer *buffer) {
diff --git a/media/libstagefright/rtsp/ARTSPConnection.cpp b/media/libstagefright/rtsp/ARTSPConnection.cpp
index 380b3dc..80a010e 100644
--- a/media/libstagefright/rtsp/ARTSPConnection.cpp
+++ b/media/libstagefright/rtsp/ARTSPConnection.cpp
@@ -55,7 +55,7 @@
 
 ARTSPConnection::~ARTSPConnection() {
     if (mSocket >= 0) {
-        LOGE("Connection is still open, closing the socket.");
+        ALOGE("Connection is still open, closing the socket.");
         if (mUIDValid) {
             HTTPBase::UnRegisterSocketUserTag(mSocket);
         }
@@ -235,7 +235,7 @@
         // right here, since we currently have no way of asking the user
         // for this information.
 
-        LOGE("Malformed rtsp url %s", url.c_str());
+        ALOGE("Malformed rtsp url %s", url.c_str());
 
         reply->setInt32("result", ERROR_MALFORMED);
         reply->post();
@@ -245,12 +245,12 @@
     }
 
     if (mUser.size() > 0) {
-        LOGV("user = '%s', pass = '%s'", mUser.c_str(), mPass.c_str());
+        ALOGV("user = '%s', pass = '%s'", mUser.c_str(), mPass.c_str());
     }
 
     struct hostent *ent = gethostbyname(host.c_str());
     if (ent == NULL) {
-        LOGE("Unknown host %s", host.c_str());
+        ALOGE("Unknown host %s", host.c_str());
 
         reply->setInt32("result", -ENOENT);
         reply->post();
@@ -376,7 +376,7 @@
     CHECK_EQ(optionLen, (socklen_t)sizeof(err));
 
     if (err != 0) {
-        LOGE("err = %d (%s)", err, strerror(err));
+        ALOGE("err = %d (%s)", err, strerror(err));
 
         reply->setInt32("result", -err);
 
@@ -429,7 +429,7 @@
 
     request.insert(cseqHeader, i + 2);
 
-    LOGV("request: '%s'", request.c_str());
+    ALOGV("request: '%s'", request.c_str());
 
     size_t numBytesSent = 0;
     while (numBytesSent < request.size()) {
@@ -446,12 +446,12 @@
 
             if (n == 0) {
                 // Server closed the connection.
-                LOGE("Server unexpectedly closed the connection.");
+                ALOGE("Server unexpectedly closed the connection.");
 
                 reply->setInt32("result", ERROR_IO);
                 reply->post();
             } else {
-                LOGE("Error sending rtsp request. (%s)", strerror(errno));
+                ALOGE("Error sending rtsp request. (%s)", strerror(errno));
                 reply->setInt32("result", -errno);
                 reply->post();
             }
@@ -536,10 +536,10 @@
 
             if (n == 0) {
                 // Server closed the connection.
-                LOGE("Server unexpectedly closed the connection.");
+                ALOGE("Server unexpectedly closed the connection.");
                 return ERROR_IO;
             } else {
-                LOGE("Error reading rtsp response. (%s)", strerror(errno));
+                ALOGE("Error reading rtsp response. (%s)", strerror(errno));
                 return -errno;
             }
         }
@@ -615,7 +615,7 @@
             notify->setObject("buffer", buffer);
             notify->post();
         } else {
-            LOGW("received binary data, but no one cares.");
+            ALOGW("received binary data, but no one cares.");
         }
 
         return true;
@@ -624,7 +624,7 @@
     sp<ARTSPResponse> response = new ARTSPResponse;
     response->mStatusLine = statusLine;
 
-    LOGI("status: %s", response->mStatusLine.c_str());
+    ALOGI("status: %s", response->mStatusLine.c_str());
 
     ssize_t space1 = response->mStatusLine.find(" ");
     if (space1 < 0) {
@@ -669,7 +669,7 @@
             break;
         }
 
-        LOGV("line: '%s'", line.c_str());
+        ALOGV("line: '%s'", line.c_str());
 
         if (line.c_str()[0] == ' ' || line.c_str()[0] == '\t') {
             // Support for folded header values.
@@ -740,7 +740,7 @@
             msg->setMessage("reply", reply);
             msg->setString("request", request.c_str(), request.size());
 
-            LOGI("re-sending request with authentication headers...");
+            ALOGI("re-sending request with authentication headers...");
             onSendRequest(msg);
 
             return true;
@@ -793,9 +793,9 @@
         if (n <= 0) {
             if (n == 0) {
                 // Server closed the connection.
-                LOGE("Server unexpectedly closed the connection.");
+                ALOGE("Server unexpectedly closed the connection.");
             } else {
-                LOGE("Error sending rtsp response (%s).", strerror(errno));
+                ALOGE("Error sending rtsp response (%s).", strerror(errno));
             }
 
             performDisconnect();
diff --git a/media/libstagefright/rtsp/ARawAudioAssembler.cpp b/media/libstagefright/rtsp/ARawAudioAssembler.cpp
index dd47ea3..98bee82 100644
--- a/media/libstagefright/rtsp/ARawAudioAssembler.cpp
+++ b/media/libstagefright/rtsp/ARawAudioAssembler.cpp
@@ -77,7 +77,7 @@
         mNextExpectedSeqNoValid = true;
         mNextExpectedSeqNo = (uint32_t)buffer->int32Data();
     } else if ((uint32_t)buffer->int32Data() != mNextExpectedSeqNo) {
-        LOGV("Not the sequence number I expected");
+        ALOGV("Not the sequence number I expected");
 
         return WRONG_SEQUENCE_NUMBER;
     }
@@ -88,7 +88,7 @@
         queue->erase(queue->begin());
         ++mNextExpectedSeqNo;
 
-        LOGV("raw audio packet too short.");
+        ALOGV("raw audio packet too short.");
 
         return MALFORMED_PACKET;
     }
diff --git a/media/libstagefright/rtsp/ASessionDescription.cpp b/media/libstagefright/rtsp/ASessionDescription.cpp
index f03f7a2..a9b3330 100644
--- a/media/libstagefright/rtsp/ASessionDescription.cpp
+++ b/media/libstagefright/rtsp/ASessionDescription.cpp
@@ -80,7 +80,7 @@
             return false;
         }
 
-        LOGI("%s", line.c_str());
+        ALOGI("%s", line.c_str());
 
         switch (line.c_str()[0]) {
             case 'v':
@@ -120,7 +120,7 @@
                 key.trim();
                 value.trim();
 
-                LOGV("adding '%s' => '%s'", key.c_str(), value.c_str());
+                ALOGV("adding '%s' => '%s'", key.c_str(), value.c_str());
 
                 mTracks.editItemAt(mTracks.size() - 1).add(key, value);
                 break;
@@ -128,7 +128,7 @@
 
             case 'm':
             {
-                LOGV("new section '%s'",
+                ALOGV("new section '%s'",
                      AString(line, 2, line.size() - 2).c_str());
 
                 mTracks.push(Attribs());
@@ -148,7 +148,7 @@
                 key.trim();
                 value.trim();
 
-                LOGV("adding '%s' => '%s'", key.c_str(), value.c_str());
+                ALOGV("adding '%s' => '%s'", key.c_str(), value.c_str());
 
                 mTracks.editItemAt(mTracks.size() - 1).add(key, value);
                 break;
diff --git a/media/libstagefright/rtsp/MyHandler.h b/media/libstagefright/rtsp/MyHandler.h
index 5a95f9c..2391c5c 100644
--- a/media/libstagefright/rtsp/MyHandler.h
+++ b/media/libstagefright/rtsp/MyHandler.h
@@ -155,7 +155,7 @@
             mSessionURL.append(StringPrintf("%u", port));
             mSessionURL.append(path);
 
-            LOGI("rewritten session url: '%s'", mSessionURL.c_str());
+            ALOGI("rewritten session url: '%s'", mSessionURL.c_str());
         }
 
         mSessionHost = host;
@@ -264,12 +264,12 @@
         if (!GetAttribute(transport.c_str(),
                           "source",
                           &source)) {
-            LOGW("Missing 'source' field in Transport response. Using "
+            ALOGW("Missing 'source' field in Transport response. Using "
                  "RTSP endpoint address.");
 
             struct hostent *ent = gethostbyname(mSessionHost.c_str());
             if (ent == NULL) {
-                LOGE("Failed to look up address of session host '%s'",
+                ALOGE("Failed to look up address of session host '%s'",
                      mSessionHost.c_str());
 
                 return false;
@@ -283,7 +283,7 @@
         if (!GetAttribute(transport.c_str(),
                                  "server_port",
                                  &server_port)) {
-            LOGI("Missing 'server_port' field in Transport response.");
+            ALOGI("Missing 'server_port' field in Transport response.");
             return false;
         }
 
@@ -292,7 +292,7 @@
                 || rtpPort <= 0 || rtpPort > 65535
                 || rtcpPort <=0 || rtcpPort > 65535
                 || rtcpPort != rtpPort + 1) {
-            LOGE("Server picked invalid RTP/RTCP port pair %s,"
+            ALOGE("Server picked invalid RTP/RTCP port pair %s,"
                  " RTP port must be even, RTCP port must be one higher.",
                  server_port.c_str());
 
@@ -300,7 +300,7 @@
         }
 
         if (rtpPort & 1) {
-            LOGW("Server picked an odd RTP port, it should've picked an "
+            ALOGW("Server picked an odd RTP port, it should've picked an "
                  "even one, we'll let it pass for now, but this may break "
                  "in the future.");
         }
@@ -327,7 +327,7 @@
                 (const sockaddr *)&addr, sizeof(addr));
 
         if (n < (ssize_t)buf->size()) {
-            LOGE("failed to poke a hole for RTP packets");
+            ALOGE("failed to poke a hole for RTP packets");
             return false;
         }
 
@@ -338,11 +338,11 @@
                 (const sockaddr *)&addr, sizeof(addr));
 
         if (n < (ssize_t)buf->size()) {
-            LOGE("failed to poke a hole for RTCP packets");
+            ALOGE("failed to poke a hole for RTCP packets");
             return false;
         }
 
-        LOGV("successfully poked holes.");
+        ALOGV("successfully poked holes.");
 
         return true;
     }
@@ -354,7 +354,7 @@
                 int32_t result;
                 CHECK(msg->findInt32("result", &result));
 
-                LOGI("connection request completed with result %d (%s)",
+                ALOGI("connection request completed with result %d (%s)",
                      result, strerror(-result));
 
                 if (result == OK) {
@@ -392,7 +392,7 @@
                 int32_t result;
                 CHECK(msg->findInt32("result", &result));
 
-                LOGI("DESCRIBE completed with result %d (%s)",
+                ALOGI("DESCRIBE completed with result %d (%s)",
                      result, strerror(-result));
 
                 if (result == OK) {
@@ -429,7 +429,7 @@
                                 response->mContent->size());
 
                         if (!mSessionDesc->isValid()) {
-                            LOGE("Failed to parse session description.");
+                            ALOGE("Failed to parse session description.");
                             result = ERROR_MALFORMED;
                         } else {
                             ssize_t i = response->mHeaders.indexOfKey("content-base");
@@ -450,7 +450,7 @@
                                 // it with the absolute session URL to get
                                 // something usable...
 
-                                LOGW("Server specified a non-absolute base URL"
+                                ALOGW("Server specified a non-absolute base URL"
                                      ", combining it with the session URL to "
                                      "get something usable...");
 
@@ -468,7 +468,7 @@
                                 // The first "track" is merely session meta
                                 // data.
 
-                                LOGW("Session doesn't contain any playable "
+                                ALOGW("Session doesn't contain any playable "
                                      "tracks. Aborting.");
                                 result = ERROR_UNSUPPORTED;
                             } else {
@@ -499,7 +499,7 @@
                 int32_t result;
                 CHECK(msg->findInt32("result", &result));
 
-                LOGI("SETUP(%d) completed with result %d (%s)",
+                ALOGI("SETUP(%d) completed with result %d (%s)",
                      index, result, strerror(-result));
 
                 if (result == OK) {
@@ -527,12 +527,12 @@
                                 strtoul(timeoutStr.c_str(), &end, 10);
 
                             if (end == timeoutStr.c_str() || *end != '\0') {
-                                LOGW("server specified malformed timeout '%s'",
+                                ALOGW("server specified malformed timeout '%s'",
                                      timeoutStr.c_str());
 
                                 mKeepAliveTimeoutUs = kDefaultKeepAliveTimeoutUs;
                             } else if (timeoutSecs < 15) {
-                                LOGW("server specified too short a timeout "
+                                ALOGW("server specified too short a timeout "
                                      "(%lu secs), using default.",
                                      timeoutSecs);
 
@@ -540,7 +540,7 @@
                             } else {
                                 mKeepAliveTimeoutUs = timeoutSecs * 1000000ll;
 
-                                LOGI("server specified timeout of %lu secs.",
+                                ALOGI("server specified timeout of %lu secs.",
                                      timeoutSecs);
                             }
                         }
@@ -625,7 +625,7 @@
                 int32_t result;
                 CHECK(msg->findInt32("result", &result));
 
-                LOGI("PLAY completed with result %d (%s)",
+                ALOGI("PLAY completed with result %d (%s)",
                      result, strerror(-result));
 
                 if (result == OK) {
@@ -682,7 +682,7 @@
                 int32_t result;
                 CHECK(msg->findInt32("result", &result));
 
-                LOGI("OPTIONS completed with result %d (%s)",
+                ALOGI("OPTIONS completed with result %d (%s)",
                      result, strerror(-result));
 
                 int32_t generation;
@@ -759,7 +759,7 @@
                 int32_t result;
                 CHECK(msg->findInt32("result", &result));
 
-                LOGI("TEARDOWN completed with result %d (%s)",
+                ALOGI("TEARDOWN completed with result %d (%s)",
                      result, strerror(-result));
 
                 sp<AMessage> reply = new AMessage('disc', id());
@@ -793,11 +793,11 @@
 
                 if (mNumAccessUnitsReceived == 0) {
 #if 1
-                    LOGI("stream ended? aborting.");
+                    ALOGI("stream ended? aborting.");
                     (new AMessage('abor', id()))->post();
                     break;
 #else
-                    LOGI("haven't seen an AU in a looong time.");
+                    ALOGI("haven't seen an AU in a looong time.");
 #endif
                 }
 
@@ -840,7 +840,7 @@
                 CHECK(msg->findSize("track-index", &trackIndex));
 
                 if (trackIndex >= mTracks.size()) {
-                    LOGV("late packets ignored.");
+                    ALOGV("late packets ignored.");
                     break;
                 }
 
@@ -848,7 +848,7 @@
 
                 int32_t eos;
                 if (msg->findInt32("eos", &eos)) {
-                    LOGI("received BYE on track index %d", trackIndex);
+                    ALOGI("received BYE on track index %d", trackIndex);
 #if 0
                     track->mPacketSource->signalEOS(ERROR_END_OF_STREAM);
 #endif
@@ -863,12 +863,12 @@
                 uint32_t seqNum = (uint32_t)accessUnit->int32Data();
 
                 if (mSeekPending) {
-                    LOGV("we're seeking, dropping stale packet.");
+                    ALOGV("we're seeking, dropping stale packet.");
                     break;
                 }
 
                 if (seqNum < track->mFirstSeqNumInSegment) {
-                    LOGV("dropping stale access-unit (%d < %d)",
+                    ALOGV("dropping stale access-unit (%d < %d)",
                          seqNum, track->mFirstSeqNumInSegment);
                     break;
                 }
@@ -884,7 +884,7 @@
             case 'seek':
             {
                 if (!mSeekable) {
-                    LOGW("This is a live stream, ignoring seek request.");
+                    ALOGW("This is a live stream, ignoring seek request.");
 
                     sp<AMessage> msg = mNotify->dup();
                     msg->setInt32("what", kWhatSeekDone);
@@ -961,7 +961,7 @@
                 int32_t result;
                 CHECK(msg->findInt32("result", &result));
 
-                LOGI("PLAY completed with result %d (%s)",
+                ALOGI("PLAY completed with result %d (%s)",
                      result, strerror(-result));
 
                 mCheckPending = false;
@@ -981,14 +981,14 @@
                         ssize_t i = response->mHeaders.indexOfKey("rtp-info");
                         CHECK_GE(i, 0);
 
-                        LOGV("rtp-info: %s", response->mHeaders.valueAt(i).c_str());
+                        ALOGV("rtp-info: %s", response->mHeaders.valueAt(i).c_str());
 
-                        LOGI("seek completed.");
+                        ALOGI("seek completed.");
                     }
                 }
 
                 if (result != OK) {
-                    LOGE("seek failed, aborting.");
+                    ALOGE("seek failed, aborting.");
                     (new AMessage('abor', id()))->post();
                 }
 
@@ -1017,7 +1017,7 @@
             {
                 if (!mReceivedFirstRTCPPacket) {
                     if (mReceivedFirstRTPPacket && !mTryFakeRTCP) {
-                        LOGW("We received RTP packets but no RTCP packets, "
+                        ALOGW("We received RTP packets but no RTCP packets, "
                              "using fake timestamps.");
 
                         mTryFakeRTCP = true;
@@ -1026,7 +1026,7 @@
 
                         fakeTimestamps();
                     } else if (!mReceivedFirstRTPPacket && !mTryTCPInterleaving) {
-                        LOGW("Never received any data, switching transports.");
+                        ALOGW("Never received any data, switching transports.");
 
                         mTryTCPInterleaving = true;
 
@@ -1034,7 +1034,7 @@
                         msg->setInt32("reconnect", true);
                         msg->post();
                     } else {
-                        LOGW("Never received any data, disconnecting.");
+                        ALOGW("Never received any data, disconnecting.");
                         (new AMessage('abor', id()))->post();
                     }
                 }
@@ -1092,7 +1092,7 @@
         }
 
         AString range = response->mHeaders.valueAt(i);
-        LOGV("Range: %s", range.c_str());
+        ALOGV("Range: %s", range.c_str());
 
         AString val;
         CHECK(GetAttribute(range.c_str(), "npt", &val));
@@ -1101,7 +1101,7 @@
         if (!ASessionDescription::parseNTPRange(val.c_str(), &npt1, &npt2)) {
             // This is a live stream and therefore not seekable.
 
-            LOGI("This is a live stream");
+            ALOGI("This is a live stream");
             return;
         }
 
@@ -1116,7 +1116,7 @@
         for (List<AString>::iterator it = streamInfos.begin();
              it != streamInfos.end(); ++it) {
             (*it).trim();
-            LOGV("streamInfo[%d] = %s", n, (*it).c_str());
+            ALOGV("streamInfo[%d] = %s", n, (*it).c_str());
 
             CHECK(GetAttribute((*it).c_str(), "url", &val));
 
@@ -1140,7 +1140,7 @@
 
             uint32_t rtpTime = strtoul(val.c_str(), &end, 10);
 
-            LOGV("track #%d: rtpTime=%u <=> npt=%.2f", n, rtpTime, npt1);
+            ALOGV("track #%d: rtpTime=%u <=> npt=%.2f", n, rtpTime, npt1);
 
             info->mNormalPlayTimeRTP = rtpTime;
             info->mNormalPlayTimeUs = (int64_t)(npt1 * 1E6);
@@ -1233,7 +1233,7 @@
             new APacketSource(mSessionDesc, index);
 
         if (source->initCheck() != OK) {
-            LOGW("Unsupported format. Ignoring track #%d.", index);
+            ALOGW("Unsupported format. Ignoring track #%d.", index);
 
             sp<AMessage> reply = new AMessage('setu', id());
             reply->setSize("index", index);
@@ -1272,7 +1272,7 @@
 
         info->mTimeScale = timescale;
 
-        LOGV("track #%d URL=%s", mTracks.size(), trackURL.c_str());
+        ALOGV("track #%d URL=%s", mTracks.size(), trackURL.c_str());
 
         AString request = "SETUP ";
         request.append(trackURL);
@@ -1363,7 +1363,7 @@
     }
 
     void onTimeUpdate(int32_t trackIndex, uint32_t rtpTime, uint64_t ntpTime) {
-        LOGV("onTimeUpdate track %d, rtpTime = 0x%08x, ntpTime = 0x%016llx",
+        ALOGV("onTimeUpdate track %d, rtpTime = 0x%08x, ntpTime = 0x%016llx",
              trackIndex, rtpTime, ntpTime);
 
         int64_t ntpTimeUs = (int64_t)(ntpTime * 1E6 / (1ll << 32));
@@ -1381,7 +1381,7 @@
 
     void onAccessUnitComplete(
             int32_t trackIndex, const sp<ABuffer> &accessUnit) {
-        LOGV("onAccessUnitComplete track %d", trackIndex);
+        ALOGV("onAccessUnitComplete track %d", trackIndex);
 
         if (mFirstAccessUnit) {
             sp<AMessage> msg = mNotify->dup();
@@ -1404,7 +1404,7 @@
         TrackInfo *track = &mTracks.editItemAt(trackIndex);
 
         if (mNTPAnchorUs < 0 || mMediaAnchorUs < 0 || track->mNTPAnchorUs < 0) {
-            LOGV("storing accessUnit, no time established yet");
+            ALOGV("storing accessUnit, no time established yet");
             track->mPackets.push_back(accessUnit);
             return;
         }
@@ -1443,11 +1443,11 @@
         }
 
         if (mediaTimeUs < 0) {
-            LOGV("dropping early accessUnit.");
+            ALOGV("dropping early accessUnit.");
             return false;
         }
 
-        LOGV("track %d rtpTime=%d mediaTimeUs = %lld us (%.2f secs)",
+        ALOGV("track %d rtpTime=%d mediaTimeUs = %lld us (%.2f secs)",
              trackIndex, rtpTime, mediaTimeUs, mediaTimeUs / 1E6);
 
         accessUnit->meta()->setInt64("timeUs", mediaTimeUs);
diff --git a/media/libstagefright/rtsp/UDPPusher.cpp b/media/libstagefright/rtsp/UDPPusher.cpp
index 576b3ca..47ea6f1 100644
--- a/media/libstagefright/rtsp/UDPPusher.cpp
+++ b/media/libstagefright/rtsp/UDPPusher.cpp
@@ -71,7 +71,7 @@
 bool UDPPusher::onPush() {
     uint32_t length;
     if (fread(&length, 1, sizeof(length), mFile) < sizeof(length)) {
-        LOGI("No more data to push.");
+        ALOGI("No more data to push.");
         return false;
     }
 
@@ -81,7 +81,7 @@
 
     sp<ABuffer> buffer = new ABuffer(length);
     if (fread(buffer->data(), 1, length, mFile) < length) {
-        LOGE("File truncated?.");
+        ALOGE("File truncated?.");
         return false;
     }
 
@@ -93,7 +93,7 @@
 
     uint32_t timeMs;
     if (fread(&timeMs, 1, sizeof(timeMs), mFile) < sizeof(timeMs)) {
-        LOGI("No more data to push.");
+        ALOGI("No more data to push.");
         return false;
     }
 
@@ -113,7 +113,7 @@
         case kWhatPush:
         {
             if (!onPush() && !(ntohs(mRemoteAddr.sin_port) & 1)) {
-                LOGI("emulating BYE packet");
+                ALOGI("emulating BYE packet");
 
                 sp<ABuffer> buffer = new ABuffer(8);
                 uint8_t *data = buffer->data();
diff --git a/media/libstagefright/rtsp/rtp_test.cpp b/media/libstagefright/rtsp/rtp_test.cpp
index f0cb5a5..d43cd2a 100644
--- a/media/libstagefright/rtsp/rtp_test.cpp
+++ b/media/libstagefright/rtsp/rtp_test.cpp
@@ -204,7 +204,7 @@
                 continue;
             }
 
-            LOGE("decoder returned error 0x%08x", err);
+            ALOGE("decoder returned error 0x%08x", err);
             break;
         }
 
diff --git a/media/libstagefright/tests/DummyRecorder.cpp b/media/libstagefright/tests/DummyRecorder.cpp
index 8d75d6b..ac37b28 100644
--- a/media/libstagefright/tests/DummyRecorder.cpp
+++ b/media/libstagefright/tests/DummyRecorder.cpp
@@ -27,7 +27,7 @@
 
 // static
 void *DummyRecorder::threadWrapper(void *pthis) {
-    LOGV("ThreadWrapper: %p", pthis);
+    ALOGV("ThreadWrapper: %p", pthis);
     DummyRecorder *writer = static_cast<DummyRecorder *>(pthis);
     writer->readFromSource();
     return NULL;
@@ -35,7 +35,7 @@
 
 
 status_t DummyRecorder::start() {
-    LOGV("Start");
+    ALOGV("Start");
     mStarted = true;
 
     mSource->start();
@@ -47,7 +47,7 @@
     pthread_attr_destroy(&attr);
 
     if (err) {
-        LOGE("Error creating thread!");
+        ALOGE("Error creating thread!");
         return -ENODEV;
     }
     return OK;
@@ -55,7 +55,7 @@
 
 
 status_t DummyRecorder::stop() {
-    LOGV("Stop");
+    ALOGV("Stop");
     mStarted = false;
 
     mSource->stop();
@@ -63,20 +63,20 @@
     pthread_join(mThread, &dummy);
     status_t err = (status_t) dummy;
 
-    LOGV("Ending the reading thread");
+    ALOGV("Ending the reading thread");
     return err;
 }
 
 // pretend to read the source buffers
 void DummyRecorder::readFromSource() {
-    LOGV("ReadFromSource");
+    ALOGV("ReadFromSource");
     if (!mStarted) {
         return;
     }
 
     status_t err = OK;
     MediaBuffer *buffer;
-    LOGV("A fake writer accessing the frames");
+    ALOGV("A fake writer accessing the frames");
     while (mStarted && (err = mSource->read(&buffer)) == OK){
         // if not getting a valid buffer from source, then exit
         if (buffer == NULL) {
diff --git a/media/libstagefright/tests/SurfaceMediaSource_test.cpp b/media/libstagefright/tests/SurfaceMediaSource_test.cpp
index d7bb703..76b507f 100644
--- a/media/libstagefright/tests/SurfaceMediaSource_test.cpp
+++ b/media/libstagefright/tests/SurfaceMediaSource_test.cpp
@@ -58,7 +58,7 @@
     }
 
     virtual void SetUp() {
-        LOGV("GLTest::SetUp()");
+        ALOGV("GLTest::SetUp()");
         mEglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
         ASSERT_EQ(EGL_SUCCESS, eglGetError());
         ASSERT_NE(EGL_NO_DISPLAY, mEglDisplay);
@@ -106,7 +106,7 @@
             mEglSurface = eglCreateWindowSurface(mEglDisplay, mGlConfig,
                     window.get(), NULL);
         } else {
-            LOGV("No actual display. Choosing EGLSurface based on SurfaceMediaSource");
+            ALOGV("No actual display. Choosing EGLSurface based on SurfaceMediaSource");
             sp<SurfaceMediaSource> sms = new SurfaceMediaSource(
                     getSurfaceWidth(), getSurfaceHeight());
             sp<SurfaceTextureClient> stc = new SurfaceTextureClient(sms);
@@ -162,7 +162,7 @@
     }
 
     virtual EGLint const* getConfigAttribs() {
-        LOGV("GLTest getConfigAttribs");
+        ALOGV("GLTest getConfigAttribs");
         static EGLint sDefaultConfigAttribs[] = {
             EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
             EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
@@ -392,7 +392,7 @@
 protected:
 
     virtual void SetUp() {
-        LOGV("SMS-GLTest::SetUp()");
+        ALOGV("SMS-GLTest::SetUp()");
         android::ProcessState::self()->startThreadPool();
         mSMS = new SurfaceMediaSource(mYuvTexWidth, mYuvTexHeight);
         mSTC = new SurfaceTextureClient(mSMS);
@@ -423,7 +423,7 @@
 // Methods in SurfaceMediaSourceGLTest
 /////////////////////////////////////////////////////////////////////
 EGLint const* SurfaceMediaSourceGLTest::getConfigAttribs() {
-        LOGV("SurfaceMediaSourceGLTest getConfigAttribs");
+        ALOGV("SurfaceMediaSourceGLTest getConfigAttribs");
     static EGLint sDefaultConfigAttribs[] = {
         EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
         EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
@@ -474,7 +474,7 @@
     mr->setVideoSize(width, height);
     mr->setVideoFrameRate(fps);
     mr->prepare();
-    LOGV("Starting MediaRecorder...");
+    ALOGV("Starting MediaRecorder...");
     CHECK_EQ(OK, mr->start());
     return mr;
 }
@@ -624,8 +624,8 @@
 // Dummy Encoder
 static int testId = 1;
 TEST_F(SurfaceMediaSourceTest, DISABLED_DummyEncodingFromCpuFilledYV12BufferNpotOneBufferPass) {
-    LOGV("Test # %d", testId++);
-    LOGV("Testing OneBufferPass ******************************");
+    ALOGV("Test # %d", testId++);
+    ALOGV("Testing OneBufferPass ******************************");
 
     ASSERT_EQ(NO_ERROR, native_window_set_buffers_format(mANW.get(),
             HAL_PIXEL_FORMAT_YV12));
@@ -635,8 +635,8 @@
 // Pass the buffer with the wrong height and weight and should not be accepted
 // Dummy Encoder
 TEST_F(SurfaceMediaSourceTest, DISABLED_DummyEncodingFromCpuFilledYV12BufferNpotWrongSizeBufferPass) {
-    LOGV("Test # %d", testId++);
-    LOGV("Testing Wrong size BufferPass ******************************");
+    ALOGV("Test # %d", testId++);
+    ALOGV("Testing Wrong size BufferPass ******************************");
 
     // setting the client side buffer size different than the server size
     ASSERT_EQ(NO_ERROR, native_window_set_buffers_dimensions(mANW.get(),
@@ -653,8 +653,8 @@
 // pass multiple buffers from the native_window the SurfaceMediaSource
 // Dummy Encoder
 TEST_F(SurfaceMediaSourceTest,  DISABLED_DummyEncodingFromCpuFilledYV12BufferNpotMultiBufferPass) {
-    LOGV("Test # %d", testId++);
-    LOGV("Testing MultiBufferPass, Dummy Recorder *********************");
+    ALOGV("Test # %d", testId++);
+    ALOGV("Testing MultiBufferPass, Dummy Recorder *********************");
     ASSERT_EQ(NO_ERROR, native_window_set_buffers_format(mANW.get(),
             HAL_PIXEL_FORMAT_YV12));
 
@@ -675,8 +675,8 @@
 // Delayed pass of multiple buffers from the native_window the SurfaceMediaSource
 // Dummy Encoder
 TEST_F(SurfaceMediaSourceTest,  DISABLED_DummyLagEncodingFromCpuFilledYV12BufferNpotMultiBufferPass) {
-    LOGV("Test # %d", testId++);
-    LOGV("Testing MultiBufferPass, Dummy Recorder Lagging **************");
+    ALOGV("Test # %d", testId++);
+    ALOGV("Testing MultiBufferPass, Dummy Recorder Lagging **************");
 
     ASSERT_EQ(NO_ERROR, native_window_set_buffers_format(mANW.get(),
             HAL_PIXEL_FORMAT_YV12));
@@ -700,8 +700,8 @@
 // pass multiple buffers from the native_window the SurfaceMediaSource
 // A dummy writer (MULTITHREADED) is used to simulate actual MPEG4Writer
 TEST_F(SurfaceMediaSourceTest, DISABLED_DummyThreadedEncodingFromCpuFilledYV12BufferNpotMultiBufferPass) {
-    LOGV("Test # %d", testId++);
-    LOGV("Testing MultiBufferPass, Dummy Recorder Multi-Threaded **********");
+    ALOGV("Test # %d", testId++);
+    ALOGV("Testing MultiBufferPass, Dummy Recorder Multi-Threaded **********");
     ASSERT_EQ(NO_ERROR, native_window_set_buffers_format(mANW.get(),
             HAL_PIXEL_FORMAT_YV12));
 
@@ -724,14 +724,14 @@
 // Very close to the actual camera, except that the
 // buffers are filled and queueud by the CPU instead of GL.
 TEST_F(SurfaceMediaSourceTest, DISABLED_EncodingFromCpuYV12BufferNpotWriteMediaServer) {
-    LOGV("Test # %d", testId++);
-    LOGV("************** Testing the whole pipeline with actual MediaRecorder ***********");
-    LOGV("************** SurfaceMediaSource is same process as mediaserver    ***********");
+    ALOGV("Test # %d", testId++);
+    ALOGV("************** Testing the whole pipeline with actual MediaRecorder ***********");
+    ALOGV("************** SurfaceMediaSource is same process as mediaserver    ***********");
 
     const char *fileName = "/sdcard/outputSurfEncMSource.mp4";
     int fd = open(fileName, O_RDWR | O_CREAT, 0744);
     if (fd < 0) {
-        LOGE("ERROR: Could not open the the file %s, fd = %d !!", fileName, fd);
+        ALOGE("ERROR: Could not open the the file %s, fd = %d !!", fileName, fd);
     }
     CHECK(fd >= 0);
 
@@ -752,11 +752,11 @@
     while (nFramesCount <= 300) {
         oneBufferPassNoFill(mYuvTexWidth, mYuvTexHeight);
         nFramesCount++;
-        LOGV("framesCount = %d", nFramesCount);
+        ALOGV("framesCount = %d", nFramesCount);
     }
 
     ASSERT_EQ(NO_ERROR, native_window_api_disconnect(mANW.get(), NATIVE_WINDOW_API_CPU));
-    LOGV("Stopping MediaRecorder...");
+    ALOGV("Stopping MediaRecorder...");
     CHECK_EQ(OK, mr->stop());
     mr.clear();
     close(fd);
@@ -769,8 +769,8 @@
 // Test to examine whether we can choose the Recordable Android GLConfig
 // DummyRecorder used- no real encoding here
 TEST_F(SurfaceMediaSourceGLTest, ChooseAndroidRecordableEGLConfigDummyWriter) {
-    LOGV("Test # %d", testId++);
-    LOGV("Verify creating a surface w/ right config + dummy writer*********");
+    ALOGV("Test # %d", testId++);
+    ALOGV("Verify creating a surface w/ right config + dummy writer*********");
 
     mSMS = new SurfaceMediaSource(mYuvTexWidth, mYuvTexHeight);
     mSTC = new SurfaceTextureClient(mSMS);
@@ -792,7 +792,7 @@
     while (nFramesCount <= 300) {
         oneBufferPassGL();
         nFramesCount++;
-        LOGV("framesCount = %d", nFramesCount);
+        ALOGV("framesCount = %d", nFramesCount);
     }
 
     EXPECT_TRUE(eglMakeCurrent(mEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE,
@@ -806,8 +806,8 @@
 // Test to examine whether we can render GL buffers in to the surface
 // created with the native window handle
 TEST_F(SurfaceMediaSourceGLTest, RenderingToRecordableEGLSurfaceWorks) {
-    LOGV("Test # %d", testId++);
-    LOGV("RenderingToRecordableEGLSurfaceWorks *********************");
+    ALOGV("Test # %d", testId++);
+    ALOGV("RenderingToRecordableEGLSurfaceWorks *********************");
     // Do the producer side of things
     glClearColor(0.6, 0.6, 0.6, 0.6);
     glClear(GL_COLOR_BUFFER_BIT);
@@ -852,16 +852,16 @@
 // Actual encoder, Actual GL Buffers Filled SurfaceMediaSource
 // The same pattern is rendered every frame
 TEST_F(SurfaceMediaSourceGLTest, EncodingFromGLRgbaSameImageEachBufNpotWrite) {
-    LOGV("Test # %d", testId++);
-    LOGV("************** Testing the whole pipeline with actual Recorder ***********");
-    LOGV("************** GL Filling the buffers ***********");
+    ALOGV("Test # %d", testId++);
+    ALOGV("************** Testing the whole pipeline with actual Recorder ***********");
+    ALOGV("************** GL Filling the buffers ***********");
     // Note: No need to set the colorformat for the buffers. The colorformat is
     // in the GRAlloc buffers itself.
 
     const char *fileName = "/sdcard/outputSurfEncMSourceGL.mp4";
     int fd = open(fileName, O_RDWR | O_CREAT, 0744);
     if (fd < 0) {
-        LOGE("ERROR: Could not open the the file %s, fd = %d !!", fileName, fd);
+        ALOGE("ERROR: Could not open the the file %s, fd = %d !!", fileName, fd);
     }
     CHECK(fd >= 0);
 
@@ -876,7 +876,7 @@
     while (nFramesCount <= 300) {
         oneBufferPassGL();
         nFramesCount++;
-        LOGV("framesCount = %d", nFramesCount);
+        ALOGV("framesCount = %d", nFramesCount);
     }
 
     EXPECT_TRUE(eglMakeCurrent(mEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE,
@@ -885,7 +885,7 @@
     eglDestroySurface(mEglDisplay, mEglSurface);
     mEglSurface = EGL_NO_SURFACE;
 
-    LOGV("Stopping MediaRecorder...");
+    ALOGV("Stopping MediaRecorder...");
     CHECK_EQ(OK, mr->stop());
     mr.clear();
     close(fd);
@@ -895,16 +895,16 @@
 // Actual encoder, Actual GL Buffers Filled SurfaceMediaSource
 // A different pattern is rendered every frame
 TEST_F(SurfaceMediaSourceGLTest, EncodingFromGLRgbaDiffImageEachBufNpotWrite) {
-    LOGV("Test # %d", testId++);
-    LOGV("************** Testing the whole pipeline with actual Recorder ***********");
-    LOGV("************** Diff GL Filling the buffers ***********");
+    ALOGV("Test # %d", testId++);
+    ALOGV("************** Testing the whole pipeline with actual Recorder ***********");
+    ALOGV("************** Diff GL Filling the buffers ***********");
     // Note: No need to set the colorformat for the buffers. The colorformat is
     // in the GRAlloc buffers itself.
 
     const char *fileName = "/sdcard/outputSurfEncMSourceGLDiff.mp4";
     int fd = open(fileName, O_RDWR | O_CREAT, 0744);
     if (fd < 0) {
-        LOGE("ERROR: Could not open the the file %s, fd = %d !!", fileName, fd);
+        ALOGE("ERROR: Could not open the the file %s, fd = %d !!", fileName, fd);
     }
     CHECK(fd >= 0);
 
@@ -919,7 +919,7 @@
     while (nFramesCount <= 300) {
         oneBufferPassGL(nFramesCount);
         nFramesCount++;
-        LOGV("framesCount = %d", nFramesCount);
+        ALOGV("framesCount = %d", nFramesCount);
     }
 
     EXPECT_TRUE(eglMakeCurrent(mEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE,
@@ -928,7 +928,7 @@
     eglDestroySurface(mEglDisplay, mEglSurface);
     mEglSurface = EGL_NO_SURFACE;
 
-    LOGV("Stopping MediaRecorder...");
+    ALOGV("Stopping MediaRecorder...");
     CHECK_EQ(OK, mr->stop());
     mr.clear();
     close(fd);
diff --git a/media/libstagefright/timedtext/TimedTextParser.cpp b/media/libstagefright/timedtext/TimedTextParser.cpp
index 0bada16..caea0a4 100644
--- a/media/libstagefright/timedtext/TimedTextParser.cpp
+++ b/media/libstagefright/timedtext/TimedTextParser.cpp
@@ -128,7 +128,7 @@
  *  Subtitle number
  *  Start time --> End time
  *  Text of subtitle (one or more lines)
- *  Blank line
+ *  Blank lines
  *
  * .srt file example:
  *  1
@@ -143,15 +143,20 @@
         off64_t *offset, int64_t *startTimeUs, TextInfo *info) {
     AString data;
     status_t err;
+
+    // To skip blank lines.
+    do {
+        if ((err = readNextLine(offset, &data)) != OK) {
+            return err;
+        }
+        data.trim();
+    } while(data.empty());
+
+    // Just ignore the first non-blank line which is subtitle sequence number.
+
     if ((err = readNextLine(offset, &data)) != OK) {
         return err;
     }
-
-    // to skip the first line
-    if ((err = readNextLine(offset, &data)) != OK) {
-        return err;
-    }
-
     int hour1, hour2, min1, min2, sec1, sec2, msec1, msec2;
     // the start time format is: hours:minutes:seconds,milliseconds
     // 00:00:24,600 --> 00:00:27,800
diff --git a/media/libstagefright/timedtext/TimedTextPlayer.cpp b/media/libstagefright/timedtext/TimedTextPlayer.cpp
index 7c8a747..3014b0b 100644
--- a/media/libstagefright/timedtext/TimedTextPlayer.cpp
+++ b/media/libstagefright/timedtext/TimedTextPlayer.cpp
@@ -91,7 +91,7 @@
 
     if (index >=
             mTextTrackVector.size() + mTextOutOfBandVector.size()) {
-        LOGE("Incorrect text track index: %d", index);
+        ALOGE("Incorrect text track index: %d", index);
         return BAD_VALUE;
     }
 
diff --git a/media/libstagefright/yuv/YUVImage.cpp b/media/libstagefright/yuv/YUVImage.cpp
index b712062..0d67c96 100644
--- a/media/libstagefright/yuv/YUVImage.cpp
+++ b/media/libstagefright/yuv/YUVImage.cpp
@@ -54,7 +54,7 @@
         // Y takes numberOfPixels bytes and U/V take numberOfPixels/4 bytes each.
         numberOfBytes = (size_t)(numberOfPixels + (numberOfPixels >> 1));
     } else {
-        LOGE("Format not supported");
+        ALOGE("Format not supported");
     }
     return numberOfBytes;
 }
@@ -74,7 +74,7 @@
         mVdata = mYdata + numberOfPixels;
         mUdata = mVdata + 1;
     } else {
-        LOGE("Format not supported");
+        ALOGE("Format not supported");
         return false;
     }
     return true;
@@ -98,7 +98,7 @@
         *uOffset = 2*uvOffset;
         *vOffset = 2*uvOffset;
     } else {
-        LOGE("Format not supported");
+        ALOGE("Format not supported");
         return false;
     }
 
@@ -122,7 +122,7 @@
         *uDataOffsetIncrement = 2*uvDataOffsetIncrement;
         *vDataOffsetIncrement = 2*uvDataOffsetIncrement;
     } else {
-        LOGE("Format not supported");
+        ALOGE("Format not supported");
         return false;
     }
 
diff --git a/media/mediaserver/main_mediaserver.cpp b/media/mediaserver/main_mediaserver.cpp
index 7094cfa..1520c01 100644
--- a/media/mediaserver/main_mediaserver.cpp
+++ b/media/mediaserver/main_mediaserver.cpp
@@ -15,10 +15,7 @@
 ** limitations under the License.
 */
 
-// System headers required for setgroups, etc.
-#include <sys/types.h>
-#include <unistd.h>
-#include <grp.h>
+#define LOG_TAG "mediaserver"
 
 #include <binder/IPCThreadState.h>
 #include <binder/ProcessState.h>
@@ -29,7 +26,6 @@
 #include <CameraService.h>
 #include <MediaPlayerService.h>
 #include <AudioPolicyService.h>
-#include <private/android_filesystem_config.h>
 
 using namespace android;
 
@@ -37,7 +33,7 @@
 {
     sp<ProcessState> proc(ProcessState::self());
     sp<IServiceManager> sm = defaultServiceManager();
-    LOGI("ServiceManager: %p", sm.get());
+    ALOGI("ServiceManager: %p", sm.get());
     AudioFlinger::instantiate();
     MediaPlayerService::instantiate();
     CameraService::instantiate();
diff --git a/media/mtp/MtpDataPacket.cpp b/media/mtp/MtpDataPacket.cpp
index cfea7e8..930f0b0 100644
--- a/media/mtp/MtpDataPacket.cpp
+++ b/media/mtp/MtpDataPacket.cpp
@@ -418,7 +418,7 @@
 // Queue a read request.  Call readDataWait to wait for result
 int MtpDataPacket::readDataAsync(struct usb_request *req) {
     if (usb_request_queue(req)) {
-        LOGE("usb_endpoint_queue failed, errno: %d", errno);
+        ALOGE("usb_endpoint_queue failed, errno: %d", errno);
         return -1;
     }
     return 0;
diff --git a/media/mtp/MtpDevice.cpp b/media/mtp/MtpDevice.cpp
index 2e86159..bf7795c 100644
--- a/media/mtp/MtpDevice.cpp
+++ b/media/mtp/MtpDevice.cpp
@@ -53,7 +53,7 @@
 MtpDevice* MtpDevice::open(const char* deviceName, int fd) {
     struct usb_device *device = usb_device_new(deviceName, fd);
     if (!device) {
-        LOGE("usb_device_new failed for %s", deviceName);
+        ALOGE("usb_device_new failed for %s", deviceName);
         return NULL;
     }
 
@@ -72,7 +72,7 @@
             {
                 char* manufacturerName = usb_device_get_manufacturer_name(device);
                 char* productName = usb_device_get_product_name(device);
-                LOGD("Found camera: \"%s\" \"%s\"\n", manufacturerName, productName);
+                ALOGD("Found camera: \"%s\" \"%s\"\n", manufacturerName, productName);
                 free(manufacturerName);
                 free(productName);
             } else if (interface->bInterfaceClass == 0xFF &&
@@ -90,7 +90,7 @@
                 // Looks like an android style MTP device
                 char* manufacturerName = usb_device_get_manufacturer_name(device);
                 char* productName = usb_device_get_product_name(device);
-                LOGD("Found MTP device: \"%s\" \"%s\"\n", manufacturerName, productName);
+                ALOGD("Found MTP device: \"%s\" \"%s\"\n", manufacturerName, productName);
                 free(manufacturerName);
                 free(productName);
             }
@@ -134,7 +134,7 @@
             for (int i = 0; i < 3; i++) {
                 ep = (struct usb_endpoint_descriptor *)usb_descriptor_iter_next(&iter);
                 if (!ep || ep->bDescriptorType != USB_DT_ENDPOINT) {
-                    LOGE("endpoints not found\n");
+                    ALOGE("endpoints not found\n");
                     usb_device_close(device);
                     return NULL;
                 }
@@ -149,13 +149,13 @@
                 }
             }
             if (!ep_in_desc || !ep_out_desc || !ep_intr_desc) {
-                LOGE("endpoints not found\n");
+                ALOGE("endpoints not found\n");
                 usb_device_close(device);
                 return NULL;
             }
 
             if (usb_device_claim_interface(device, interface->bInterfaceNumber)) {
-                LOGE("usb_device_claim_interface failed errno: %d\n", errno);
+                ALOGE("usb_device_claim_interface failed errno: %d\n", errno);
                 usb_device_close(device);
                 return NULL;
             }
@@ -168,7 +168,7 @@
     }
 
     usb_device_close(device);
-    LOGE("device not found");
+    ALOGE("device not found");
     return NULL;
 }
 
@@ -232,7 +232,7 @@
         mDeviceInfo->print();
 
         if (mDeviceInfo->mDeviceProperties) {
-            LOGI("***** DEVICE PROPERTIES *****\n");
+            ALOGI("***** DEVICE PROPERTIES *****\n");
             int count = mDeviceInfo->mDeviceProperties->size();
             for (int i = 0; i < count; i++) {
                 MtpDeviceProperty propCode = (*mDeviceInfo->mDeviceProperties)[i];
@@ -246,11 +246,11 @@
     }
 
     if (mDeviceInfo->mPlaybackFormats) {
-            LOGI("***** OBJECT PROPERTIES *****\n");
+            ALOGI("***** OBJECT PROPERTIES *****\n");
         int count = mDeviceInfo->mPlaybackFormats->size();
         for (int i = 0; i < count; i++) {
             MtpObjectFormat format = (*mDeviceInfo->mPlaybackFormats)[i];
-            LOGI("*** FORMAT: %s\n", MtpDebug::getFormatCodeName(format));
+            ALOGI("*** FORMAT: %s\n", MtpDebug::getFormatCodeName(format));
             MtpObjectPropertyList* props = getObjectPropsSupported(format);
             if (props) {
                 for (int j = 0; j < props->size(); j++) {
@@ -260,7 +260,7 @@
                         property->print();
                         delete property;
                     } else {
-                        LOGE("could not fetch property: %s",
+                        ALOGE("could not fetch property: %s",
                                 MtpDebug::getObjectPropCodeName(prop));
                     }
                 }
@@ -584,7 +584,7 @@
             && mData.readDataHeader(mRequestIn1)) {
         uint32_t length = mData.getContainerLength();
         if (length - MTP_CONTAINER_HEADER_SIZE != objectSize) {
-            LOGE("readObject error objectSize: %d, length: %d",
+            ALOGE("readObject error objectSize: %d, length: %d",
                     objectSize, length);
             goto fail;
         }
@@ -617,7 +617,7 @@
                 // queue up a read request
                 req->buffer_length = (remaining > sizeof(buffer1) ? sizeof(buffer1) : remaining);
                 if (mData.readDataAsync(req)) {
-                    LOGE("readDataAsync failed");
+                    ALOGE("readDataAsync failed");
                     goto fail;
                 }
             } else {
@@ -627,7 +627,7 @@
             if (writeBuffer) {
                 // write previous buffer
                 if (!callback(writeBuffer, offset, writeLength, clientData)) {
-                    LOGE("write failed");
+                    ALOGE("write failed");
                     // wait for pending read before failing
                     if (req)
                         mData.readDataWait(mDevice);
@@ -666,10 +666,10 @@
 
 // reads the object's data and writes it to the specified file path
 bool MtpDevice::readObject(MtpObjectHandle handle, const char* destPath, int group, int perm) {
-    LOGD("readObject: %s", destPath);
+    ALOGD("readObject: %s", destPath);
     int fd = ::open(destPath, O_RDWR | O_CREAT | O_TRUNC);
     if (fd < 0) {
-        LOGE("open failed for %s", destPath);
+        ALOGE("open failed for %s", destPath);
         return false;
     }
 
@@ -718,7 +718,7 @@
                 // queue up a read request
                 req->buffer_length = (remaining > sizeof(buffer1) ? sizeof(buffer1) : remaining);
                 if (mData.readDataAsync(req)) {
-                    LOGE("readDataAsync failed");
+                    ALOGE("readDataAsync failed");
                     goto fail;
                 }
             } else {
@@ -728,7 +728,7 @@
             if (writeBuffer) {
                 // write previous buffer
                 if (write(fd, writeBuffer, writeLength) != writeLength) {
-                    LOGE("write failed");
+                    ALOGE("write failed");
                     // wait for pending read before failing
                     if (req)
                         mData.readDataWait(mDevice);
@@ -765,7 +765,7 @@
 }
 
 bool MtpDevice::sendRequest(MtpOperationCode operation) {
-    LOGV("sendRequest: %s\n", MtpDebug::getOperationCodeName(operation));
+    ALOGV("sendRequest: %s\n", MtpDebug::getOperationCodeName(operation));
     mReceivedResponse = false;
     mRequest.setOperationCode(operation);
     if (mTransactionID > 0)
@@ -776,7 +776,7 @@
 }
 
 bool MtpDevice::sendData() {
-    LOGV("sendData\n");
+    ALOGV("sendData\n");
     mData.setOperationCode(mRequest.getOperationCode());
     mData.setTransactionID(mRequest.getTransactionID());
     int ret = mData.write(mRequestOut);
@@ -787,10 +787,10 @@
 bool MtpDevice::readData() {
     mData.reset();
     int ret = mData.read(mRequestIn1);
-    LOGV("readData returned %d\n", ret);
+    ALOGV("readData returned %d\n", ret);
     if (ret >= MTP_CONTAINER_HEADER_SIZE) {
         if (mData.getContainerType() == MTP_CONTAINER_TYPE_RESPONSE) {
-            LOGD("got response packet instead of data packet");
+            ALOGD("got response packet instead of data packet");
             // we got a response packet rather than data
             // copy it to mResponse
             mResponse.copyFrom(mData);
@@ -801,7 +801,7 @@
         return true;
     }
     else {
-        LOGV("readResponse failed\n");
+        ALOGV("readResponse failed\n");
         return false;
     }
 }
@@ -813,7 +813,7 @@
 }
 
 MtpResponseCode MtpDevice::readResponse() {
-    LOGV("readResponse\n");
+    ALOGV("readResponse\n");
     if (mReceivedResponse) {
         mReceivedResponse = false;
         return mResponse.getResponseCode();
@@ -827,7 +827,7 @@
         mResponse.dump();
         return mResponse.getResponseCode();
     } else {
-        LOGD("readResponse failed\n");
+        ALOGD("readResponse failed\n");
         return -1;
     }
 }
diff --git a/media/mtp/MtpDeviceInfo.cpp b/media/mtp/MtpDeviceInfo.cpp
index 5a9322e..108e2b8 100644
--- a/media/mtp/MtpDeviceInfo.cpp
+++ b/media/mtp/MtpDeviceInfo.cpp
@@ -88,9 +88,9 @@
 }
 
 void MtpDeviceInfo::print() {
-    LOGV("Device Info:\n\tmStandardVersion: %d\n\tmVendorExtensionID: %d\n\tmVendorExtensionVersiony: %d\n",
+    ALOGV("Device Info:\n\tmStandardVersion: %d\n\tmVendorExtensionID: %d\n\tmVendorExtensionVersiony: %d\n",
             mStandardVersion, mVendorExtensionID, mVendorExtensionVersion);
-    LOGV("\tmVendorExtensionDesc: %s\n\tmFunctionalCode: %d\n\tmManufacturer: %s\n\tmModel: %s\n\tmVersion: %s\n\tmSerial: %s\n",
+    ALOGV("\tmVendorExtensionDesc: %s\n\tmFunctionalCode: %d\n\tmManufacturer: %s\n\tmModel: %s\n\tmVersion: %s\n\tmSerial: %s\n",
             mVendorExtensionDesc, mFunctionalCode, mManufacturer, mModel, mVersion, mSerial);
 }
 
diff --git a/media/mtp/MtpObjectInfo.cpp b/media/mtp/MtpObjectInfo.cpp
index ea68c3b..cd15343 100644
--- a/media/mtp/MtpObjectInfo.cpp
+++ b/media/mtp/MtpObjectInfo.cpp
@@ -91,17 +91,17 @@
 }
 
 void MtpObjectInfo::print() {
-    LOGD("MtpObject Info %08X: %s\n", mHandle, mName);
-    LOGD("  mStorageID: %08X mFormat: %04X mProtectionStatus: %d\n",
+    ALOGD("MtpObject Info %08X: %s\n", mHandle, mName);
+    ALOGD("  mStorageID: %08X mFormat: %04X mProtectionStatus: %d\n",
             mStorageID, mFormat, mProtectionStatus);
-    LOGD("  mCompressedSize: %d mThumbFormat: %04X mThumbCompressedSize: %d\n",
+    ALOGD("  mCompressedSize: %d mThumbFormat: %04X mThumbCompressedSize: %d\n",
             mCompressedSize, mFormat, mThumbCompressedSize);
-    LOGD("  mThumbPixWidth: %d mThumbPixHeight: %d\n", mThumbPixWidth, mThumbPixHeight);
-    LOGD("  mImagePixWidth: %d mImagePixHeight: %d mImagePixDepth: %d\n",
+    ALOGD("  mThumbPixWidth: %d mThumbPixHeight: %d\n", mThumbPixWidth, mThumbPixHeight);
+    ALOGD("  mImagePixWidth: %d mImagePixHeight: %d mImagePixDepth: %d\n",
             mImagePixWidth, mImagePixHeight, mImagePixDepth);
-    LOGD("  mParent: %08X mAssociationType: %04X mAssociationDesc: %04X\n",
+    ALOGD("  mParent: %08X mAssociationType: %04X mAssociationDesc: %04X\n",
             mParent, mAssociationType, mAssociationDesc);
-    LOGD("  mSequenceNumber: %d mDateCreated: %ld mDateModified: %ld mKeywords: %s\n",
+    ALOGD("  mSequenceNumber: %d mDateCreated: %ld mDateModified: %ld mKeywords: %s\n",
             mSequenceNumber, mDateCreated, mDateModified, mKeywords);
 }
 
diff --git a/media/mtp/MtpPacket.cpp b/media/mtp/MtpPacket.cpp
index baf99e5..dd07843 100644
--- a/media/mtp/MtpPacket.cpp
+++ b/media/mtp/MtpPacket.cpp
@@ -36,7 +36,7 @@
 {
     mBuffer = (uint8_t *)malloc(bufferSize);
     if (!mBuffer) {
-        LOGE("out of memory!");
+        ALOGE("out of memory!");
         abort();
     }
 }
@@ -57,7 +57,7 @@
         int newLength = length + mAllocationIncrement;
         mBuffer = (uint8_t *)realloc(mBuffer, newLength);
         if (!mBuffer) {
-            LOGE("out of memory!");
+            ALOGE("out of memory!");
             abort();
         }
         mBufferSize = newLength;
@@ -73,15 +73,15 @@
         sprintf(bufptr, "%02X ", mBuffer[i]);
         bufptr += strlen(bufptr);
         if (i % DUMP_BYTES_PER_ROW == (DUMP_BYTES_PER_ROW - 1)) {
-            LOGV("%s", buffer);
+            ALOGV("%s", buffer);
             bufptr = buffer;
         }
     }
     if (bufptr != buffer) {
         // print last line
-        LOGV("%s", buffer);
+        ALOGV("%s", buffer);
     }
-    LOGV("\n");
+    ALOGV("\n");
 }
 
 void MtpPacket::copyFrom(const MtpPacket& src) {
@@ -134,7 +134,7 @@
 
 uint32_t MtpPacket::getParameter(int index) const {
     if (index < 1 || index > 5) {
-        LOGE("index %d out of range in MtpPacket::getParameter", index);
+        ALOGE("index %d out of range in MtpPacket::getParameter", index);
         return 0;
     }
     return getUInt32(MTP_CONTAINER_PARAMETER_OFFSET + (index - 1) * sizeof(uint32_t));
@@ -142,7 +142,7 @@
 
 void MtpPacket::setParameter(int index, uint32_t value) {
     if (index < 1 || index > 5) {
-        LOGE("index %d out of range in MtpPacket::setParameter", index);
+        ALOGE("index %d out of range in MtpPacket::setParameter", index);
         return;
     }
     int offset = MTP_CONTAINER_PARAMETER_OFFSET + (index - 1) * sizeof(uint32_t);
diff --git a/media/mtp/MtpProperty.cpp b/media/mtp/MtpProperty.cpp
index 8016c35..64dd45b 100644
--- a/media/mtp/MtpProperty.cpp
+++ b/media/mtp/MtpProperty.cpp
@@ -91,7 +91,7 @@
                 mDefaultValue.u.u64 = defaultValue;
                 break;
             default:
-                LOGE("unknown type %04X in MtpProperty::MtpProperty", type);
+                ALOGE("unknown type %04X in MtpProperty::MtpProperty", type);
         }
     }
 }
@@ -267,7 +267,7 @@
             mStepSize.u.u64 = step;
             break;
         default:
-            LOGE("unsupported type for MtpProperty::setRange");
+            ALOGE("unsupported type for MtpProperty::setRange");
             break;
     }
 }
@@ -306,7 +306,7 @@
                     mEnumValues[i].u.u64 = value;
                     break;
                 default:
-                    LOGE("unsupported type for MtpProperty::setEnum");
+                    ALOGE("unsupported type for MtpProperty::setEnum");
                     break;
         }
     }
@@ -320,18 +320,18 @@
     MtpString buffer;
     bool deviceProp = isDeviceProperty();
     if (deviceProp)
-        LOGI("    %s (%04X)", MtpDebug::getDevicePropCodeName(mCode), mCode);
+        ALOGI("    %s (%04X)", MtpDebug::getDevicePropCodeName(mCode), mCode);
     else
-        LOGI("    %s (%04X)", MtpDebug::getObjectPropCodeName(mCode), mCode);
-    LOGI("    type %04X", mType);
-    LOGI("    writeable %s", (mWriteable ? "true" : "false"));
+        ALOGI("    %s (%04X)", MtpDebug::getObjectPropCodeName(mCode), mCode);
+    ALOGI("    type %04X", mType);
+    ALOGI("    writeable %s", (mWriteable ? "true" : "false"));
     buffer = "    default value: ";
     print(mDefaultValue, buffer);
-    LOGI("%s", (const char *)buffer);
+    ALOGI("%s", (const char *)buffer);
     if (deviceProp) {
         buffer = "    current value: ";
         print(mCurrentValue, buffer);
-        LOGI("%s", (const char *)buffer);
+        ALOGI("%s", (const char *)buffer);
     }
     switch (mFormFlag) {
         case kFormNone:
@@ -344,7 +344,7 @@
             buffer += ", ";
             print(mStepSize, buffer);
             buffer += ")";
-            LOGI("%s", (const char *)buffer);
+            ALOGI("%s", (const char *)buffer);
             break;
         case kFormEnum:
             buffer = "    Enum { ";
@@ -353,13 +353,13 @@
                 buffer += " ";
             }
             buffer += "}";
-            LOGI("%s", (const char *)buffer);
+            ALOGI("%s", (const char *)buffer);
             break;
         case kFormDateTime:
-            LOGI("    DateTime\n");
+            ALOGI("    DateTime\n");
             break;
         default:
-            LOGI("    form %d\n", mFormFlag);
+            ALOGI("    form %d\n", mFormFlag);
             break;
     }
 }
@@ -402,7 +402,7 @@
             buffer.appendFormat("%s", value.str);
             break;
         default:
-            LOGE("unsupported type for MtpProperty::print\n");
+            ALOGE("unsupported type for MtpProperty::print\n");
             break;
     }
 }
@@ -456,7 +456,7 @@
             value.str = strdup(stringBuffer);
             break;
         default:
-            LOGE("unknown type %04X in MtpProperty::readValue", mType);
+            ALOGE("unknown type %04X in MtpProperty::readValue", mType);
     }
 }
 
@@ -511,7 +511,7 @@
                 packet.putEmptyString();
             break;
         default:
-            LOGE("unknown type %04X in MtpProperty::writeValue", mType);
+            ALOGE("unknown type %04X in MtpProperty::writeValue", mType);
     }
 }
 
diff --git a/media/mtp/MtpServer.cpp b/media/mtp/MtpServer.cpp
index 1dcfb74..5606187 100644
--- a/media/mtp/MtpServer.cpp
+++ b/media/mtp/MtpServer.cpp
@@ -153,12 +153,12 @@
 void MtpServer::run() {
     int fd = mFD;
 
-    LOGV("MtpServer::run fd: %d\n", fd);
+    ALOGV("MtpServer::run fd: %d\n", fd);
 
     while (1) {
         int ret = mRequest.read(fd);
         if (ret < 0) {
-            LOGV("request read returned %d, errno: %d", ret, errno);
+            ALOGV("request read returned %d, errno: %d", ret, errno);
             if (errno == ECANCELED) {
                 // return to top of loop and wait for next command
                 continue;
@@ -168,7 +168,7 @@
         MtpOperationCode operation = mRequest.getOperationCode();
         MtpTransactionID transaction = mRequest.getTransactionID();
 
-        LOGV("operation: %s", MtpDebug::getOperationCodeName(operation));
+        ALOGV("operation: %s", MtpDebug::getOperationCodeName(operation));
         mRequest.dump();
 
         // FIXME need to generalize this
@@ -179,14 +179,14 @@
         if (dataIn) {
             int ret = mData.read(fd);
             if (ret < 0) {
-                LOGE("data read returned %d, errno: %d", ret, errno);
+                ALOGE("data read returned %d, errno: %d", ret, errno);
                 if (errno == ECANCELED) {
                     // return to top of loop and wait for next command
                     continue;
                 }
                 break;
             }
-            LOGV("received data:");
+            ALOGV("received data:");
             mData.dump();
         } else {
             mData.reset();
@@ -196,11 +196,11 @@
             if (!dataIn && mData.hasData()) {
                 mData.setOperationCode(operation);
                 mData.setTransactionID(transaction);
-                LOGV("sending data:");
+                ALOGV("sending data:");
                 mData.dump();
                 ret = mData.write(fd);
                 if (ret < 0) {
-                    LOGE("request write returned %d, errno: %d", ret, errno);
+                    ALOGE("request write returned %d, errno: %d", ret, errno);
                     if (errno == ECANCELED) {
                         // return to top of loop and wait for next command
                         continue;
@@ -210,11 +210,11 @@
             }
 
             mResponse.setTransactionID(transaction);
-            LOGV("sending response %04X", mResponse.getResponseCode());
+            ALOGV("sending response %04X", mResponse.getResponseCode());
             ret = mResponse.write(fd);
             mResponse.dump();
             if (ret < 0) {
-                LOGE("request write returned %d, errno: %d", ret, errno);
+                ALOGE("request write returned %d, errno: %d", ret, errno);
                 if (errno == ECANCELED) {
                     // return to top of loop and wait for next command
                     continue;
@@ -222,7 +222,7 @@
                 break;
             }
         } else {
-            LOGV("skipping response\n");
+            ALOGV("skipping response\n");
         }
     }
 
@@ -242,22 +242,22 @@
 }
 
 void MtpServer::sendObjectAdded(MtpObjectHandle handle) {
-    LOGV("sendObjectAdded %d\n", handle);
+    ALOGV("sendObjectAdded %d\n", handle);
     sendEvent(MTP_EVENT_OBJECT_ADDED, handle);
 }
 
 void MtpServer::sendObjectRemoved(MtpObjectHandle handle) {
-    LOGV("sendObjectRemoved %d\n", handle);
+    ALOGV("sendObjectRemoved %d\n", handle);
     sendEvent(MTP_EVENT_OBJECT_REMOVED, handle);
 }
 
 void MtpServer::sendStoreAdded(MtpStorageID id) {
-    LOGV("sendStoreAdded %08X\n", id);
+    ALOGV("sendStoreAdded %08X\n", id);
     sendEvent(MTP_EVENT_STORE_ADDED, id);
 }
 
 void MtpServer::sendStoreRemoved(MtpStorageID id) {
-    LOGV("sendStoreRemoved %08X\n", id);
+    ALOGV("sendStoreRemoved %08X\n", id);
     sendEvent(MTP_EVENT_STORE_REMOVED, id);
 }
 
@@ -267,7 +267,7 @@
         mEvent.setTransactionID(mRequest.getTransactionID());
         mEvent.setParameter(1, param1);
         int ret = mEvent.write(mFD);
-        LOGV("mEvent.write returned %d\n", ret);
+        ALOGV("mEvent.write returned %d\n", ret);
     }
 }
 
@@ -296,7 +296,7 @@
             return;
         }
     }
-    LOGE("ObjectEdit not found in removeEditObject");
+    ALOGE("ObjectEdit not found in removeEditObject");
 }
 
 void MtpServer::commitEdit(ObjectEdit* edit) {
@@ -314,7 +314,7 @@
 
     if (mSendObjectHandle != kInvalidObjectHandle && operation != MTP_OPERATION_SEND_OBJECT) {
         // FIXME - need to delete mSendObjectHandle from the database
-        LOGE("expected SendObject after SendObjectInfo");
+        ALOGE("expected SendObject after SendObjectInfo");
         mSendObjectHandle = kInvalidObjectHandle;
     }
 
@@ -408,7 +408,7 @@
             response = doEndEditObject();
             break;
         default:
-            LOGE("got unsupported command %s", MtpDebug::getOperationCodeName(operation));
+            ALOGE("got unsupported command %s", MtpDebug::getOperationCodeName(operation));
             response = MTP_RESPONSE_OPERATION_NOT_SUPPORTED;
             break;
     }
@@ -614,7 +614,7 @@
         return MTP_RESPONSE_INVALID_OBJECT_HANDLE;
     MtpObjectHandle handle = mRequest.getParameter(1);
     MtpObjectProperty property = mRequest.getParameter(2);
-    LOGV("GetObjectPropValue %d %s\n", handle,
+    ALOGV("GetObjectPropValue %d %s\n", handle,
             MtpDebug::getObjectPropCodeName(property));
 
     return mDatabase->getObjectPropertyValue(handle, property, mData);
@@ -625,7 +625,7 @@
         return MTP_RESPONSE_INVALID_OBJECT_HANDLE;
     MtpObjectHandle handle = mRequest.getParameter(1);
     MtpObjectProperty property = mRequest.getParameter(2);
-    LOGV("SetObjectPropValue %d %s\n", handle,
+    ALOGV("SetObjectPropValue %d %s\n", handle,
             MtpDebug::getObjectPropCodeName(property));
 
     return mDatabase->setObjectPropertyValue(handle, property, mData);
@@ -633,7 +633,7 @@
 
 MtpResponseCode MtpServer::doGetDevicePropValue() {
     MtpDeviceProperty property = mRequest.getParameter(1);
-    LOGV("GetDevicePropValue %s\n",
+    ALOGV("GetDevicePropValue %s\n",
             MtpDebug::getDevicePropCodeName(property));
 
     return mDatabase->getDevicePropertyValue(property, mData);
@@ -641,7 +641,7 @@
 
 MtpResponseCode MtpServer::doSetDevicePropValue() {
     MtpDeviceProperty property = mRequest.getParameter(1);
-    LOGV("SetDevicePropValue %s\n",
+    ALOGV("SetDevicePropValue %s\n",
             MtpDebug::getDevicePropCodeName(property));
 
     return mDatabase->setDevicePropertyValue(property, mData);
@@ -649,7 +649,7 @@
 
 MtpResponseCode MtpServer::doResetDevicePropValue() {
     MtpDeviceProperty property = mRequest.getParameter(1);
-    LOGV("ResetDevicePropValue %s\n",
+    ALOGV("ResetDevicePropValue %s\n",
             MtpDebug::getDevicePropCodeName(property));
 
     return mDatabase->resetDeviceProperty(property);
@@ -665,7 +665,7 @@
     uint32_t property = mRequest.getParameter(3);
     int groupCode = mRequest.getParameter(4);
     int depth = mRequest.getParameter(5);
-   LOGV("GetObjectPropList %d format: %s property: %s group: %d depth: %d\n",
+   ALOGV("GetObjectPropList %d format: %s property: %s group: %d depth: %d\n",
             handle, MtpDebug::getFormatCodeName(format),
             MtpDebug::getObjectPropCodeName(property), groupCode, depth);
 
@@ -736,7 +736,7 @@
 
     // then transfer the file
     int ret = ioctl(mFD, MTP_SEND_FILE_WITH_HEADER, (unsigned long)&mfr);
-    LOGV("MTP_SEND_FILE_WITH_HEADER returned %d\n", ret);
+    ALOGV("MTP_SEND_FILE_WITH_HEADER returned %d\n", ret);
     close(mfr.fd);
     if (ret < 0) {
         if (errno == ECANCELED)
@@ -802,7 +802,7 @@
 
     // transfer the file
     int ret = ioctl(mFD, MTP_SEND_FILE_WITH_HEADER, (unsigned long)&mfr);
-    LOGV("MTP_SEND_FILE_WITH_HEADER returned %d\n", ret);
+    ALOGV("MTP_SEND_FILE_WITH_HEADER returned %d\n", ret);
     close(mfr.fd);
     if (ret < 0) {
         if (errno == ECANCELED)
@@ -857,7 +857,7 @@
     mData.getString(modified);     // date modified
     // keywords follow
 
-    LOGV("name: %s format: %04X\n", (const char *)name, format);
+    ALOGV("name: %s format: %04X\n", (const char *)name, format);
     time_t modifiedTime;
     if (!parseDateTime(modified, modifiedTime))
         modifiedTime = 0;
@@ -878,7 +878,7 @@
             return MTP_RESPONSE_OBJECT_TOO_LARGE;
     }
 
-LOGD("path: %s parent: %d storageID: %08X", (const char*)path, parent, storageID);
+    ALOGD("path: %s parent: %d storageID: %08X", (const char*)path, parent, storageID);
     MtpObjectHandle handle = mDatabase->beginSendObject((const char*)path,
             format, parent, storageID, mSendObjectFileSize, modifiedTime);
     if (handle == kInvalidObjectHandle) {
@@ -917,7 +917,7 @@
     int ret, initialData;
 
     if (mSendObjectHandle == kInvalidObjectHandle) {
-        LOGE("Expected SendObjectInfo before SendObject");
+        ALOGE("Expected SendObjectInfo before SendObject");
         result = MTP_RESPONSE_NO_VALID_OBJECT_INFO;
         goto done;
     }
@@ -954,10 +954,10 @@
             mfr.length = mSendObjectFileSize - initialData;
         }
 
-        LOGV("receiving %s\n", (const char *)mSendObjectFilePath);
+        ALOGV("receiving %s\n", (const char *)mSendObjectFilePath);
         // transfer the file
         ret = ioctl(mFD, MTP_RECEIVE_FILE, (unsigned long)&mfr);
-        LOGV("MTP_RECEIVE_FILE returned %d\n", ret);
+        ALOGV("MTP_RECEIVE_FILE returned %d\n", ret);
     }
     close(mfr.fd);
 
@@ -984,7 +984,7 @@
     char pathbuf[PATH_MAX];
     int pathLength = strlen(path);
     if (pathLength >= sizeof(pathbuf) - 1) {
-        LOGE("path too long: %s\n", path);
+        ALOGE("path too long: %s\n", path);
     }
     strcpy(pathbuf, path);
     if (pathbuf[pathLength - 1] != '/') {
@@ -995,7 +995,7 @@
 
     DIR* dir = opendir(path);
     if (!dir) {
-        LOGE("opendir %s failed: %s", path, strerror(errno));
+        ALOGE("opendir %s failed: %s", path, strerror(errno));
         return;
     }
 
@@ -1010,7 +1010,7 @@
 
         int nameLength = strlen(name);
         if (nameLength > pathRemaining) {
-            LOGE("path %s/%s too long\n", path, name);
+            ALOGE("path %s/%s too long\n", path, name);
             continue;
         }
         strcpy(fileSpot, name);
@@ -1036,7 +1036,7 @@
             unlink(path);
         }
     } else {
-        LOGE("deletePath stat failed for %s: %s", path, strerror(errno));
+        ALOGE("deletePath stat failed for %s: %s", path, strerror(errno));
     }
 }
 
@@ -1052,7 +1052,7 @@
     int64_t fileLength;
     int result = mDatabase->getObjectFilePath(handle, filePath, fileLength, format);
     if (result == MTP_RESPONSE_OK) {
-        LOGV("deleting %s", (const char *)filePath);
+        ALOGV("deleting %s", (const char *)filePath);
         result = mDatabase->deleteFile(handle);
         // Don't delete the actual files unless the database deletion is allowed
         if (result == MTP_RESPONSE_OK) {
@@ -1066,7 +1066,7 @@
 MtpResponseCode MtpServer::doGetObjectPropDesc() {
     MtpObjectProperty propCode = mRequest.getParameter(1);
     MtpObjectFormat format = mRequest.getParameter(2);
-    LOGV("GetObjectPropDesc %s %s\n", MtpDebug::getObjectPropCodeName(propCode),
+    ALOGV("GetObjectPropDesc %s %s\n", MtpDebug::getObjectPropCodeName(propCode),
                                         MtpDebug::getFormatCodeName(format));
     MtpProperty* property = mDatabase->getObjectPropertyDesc(propCode, format);
     if (!property)
@@ -1078,7 +1078,7 @@
 
 MtpResponseCode MtpServer::doGetDevicePropDesc() {
     MtpDeviceProperty propCode = mRequest.getParameter(1);
-    LOGV("GetDevicePropDesc %s\n", MtpDebug::getDevicePropCodeName(propCode));
+    ALOGV("GetDevicePropDesc %s\n", MtpDebug::getDevicePropCodeName(propCode));
     MtpProperty* property = mDatabase->getDevicePropertyDesc(propCode);
     if (!property)
         return MTP_RESPONSE_DEVICE_PROP_NOT_SUPPORTED;
@@ -1098,18 +1098,18 @@
 
     ObjectEdit* edit = getEditObject(handle);
     if (!edit) {
-        LOGE("object not open for edit in doSendPartialObject");
+        ALOGE("object not open for edit in doSendPartialObject");
         return MTP_RESPONSE_GENERAL_ERROR;
     }
 
     // can't start writing past the end of the file
     if (offset > edit->mSize) {
-        LOGD("writing past end of object, offset: %lld, edit->mSize: %lld", offset, edit->mSize);
+        ALOGD("writing past end of object, offset: %lld, edit->mSize: %lld", offset, edit->mSize);
         return MTP_RESPONSE_GENERAL_ERROR;
     }
 
     const char* filePath = (const char *)edit->mPath;
-    LOGV("receiving partial %s %lld %lld\n", filePath, offset, length);
+    ALOGV("receiving partial %s %lld %lld\n", filePath, offset, length);
 
     // read the header, and possibly some data
     int ret = mData.read(mFD);
@@ -1131,7 +1131,7 @@
 
         // transfer the file
         ret = ioctl(mFD, MTP_RECEIVE_FILE, (unsigned long)&mfr);
-        LOGV("MTP_RECEIVE_FILE returned %d", ret);
+        ALOGV("MTP_RECEIVE_FILE returned %d", ret);
     }
     if (ret < 0) {
         mResponse.setParameter(1, 0);
@@ -1155,7 +1155,7 @@
     MtpObjectHandle handle = mRequest.getParameter(1);
     ObjectEdit* edit = getEditObject(handle);
     if (!edit) {
-        LOGE("object not open for edit in doTruncateObject");
+        ALOGE("object not open for edit in doTruncateObject");
         return MTP_RESPONSE_GENERAL_ERROR;
     }
 
@@ -1173,7 +1173,7 @@
 MtpResponseCode MtpServer::doBeginEditObject() {
     MtpObjectHandle handle = mRequest.getParameter(1);
     if (getEditObject(handle)) {
-        LOGE("object already open for edit in doBeginEditObject");
+        ALOGE("object already open for edit in doBeginEditObject");
         return MTP_RESPONSE_GENERAL_ERROR;
     }
 
@@ -1186,7 +1186,7 @@
 
     int fd = open((const char *)path, O_RDWR | O_EXCL);
     if (fd < 0) {
-        LOGE("open failed for %s in doBeginEditObject (%d)", (const char *)path, errno);
+        ALOGE("open failed for %s in doBeginEditObject (%d)", (const char *)path, errno);
         return MTP_RESPONSE_GENERAL_ERROR;
     }
 
@@ -1198,7 +1198,7 @@
     MtpObjectHandle handle = mRequest.getParameter(1);
     ObjectEdit* edit = getEditObject(handle);
     if (!edit) {
-        LOGE("object not open for edit in doEndEditObject");
+        ALOGE("object not open for edit in doEndEditObject");
         return MTP_RESPONSE_GENERAL_ERROR;
     }
 
diff --git a/media/mtp/MtpStorage.cpp b/media/mtp/MtpStorage.cpp
index 941e303..d77ca72 100644
--- a/media/mtp/MtpStorage.cpp
+++ b/media/mtp/MtpStorage.cpp
@@ -43,7 +43,7 @@
         mReserveSpace(reserveSpace),
         mRemovable(removable)
 {
-    LOGV("MtpStorage id: %d path: %s\n", id, filePath);
+    ALOGV("MtpStorage id: %d path: %s\n", id, filePath);
 }
 
 MtpStorage::~MtpStorage() {
diff --git a/media/mtp/MtpStorageInfo.cpp b/media/mtp/MtpStorageInfo.cpp
index ca64ac0..dcd37cd 100644
--- a/media/mtp/MtpStorageInfo.cpp
+++ b/media/mtp/MtpStorageInfo.cpp
@@ -61,11 +61,11 @@
 }
 
 void MtpStorageInfo::print() {
-    LOGD("Storage Info %08X:\n\tmStorageType: %d\n\tmFileSystemType: %d\n\tmAccessCapability: %d\n",
+    ALOGD("Storage Info %08X:\n\tmStorageType: %d\n\tmFileSystemType: %d\n\tmAccessCapability: %d\n",
             mStorageID, mStorageType, mFileSystemType, mAccessCapability);
-    LOGD("\tmMaxCapacity: %lld\n\tmFreeSpaceBytes: %lld\n\tmFreeSpaceObjects: %d\n",
+    ALOGD("\tmMaxCapacity: %lld\n\tmFreeSpaceBytes: %lld\n\tmFreeSpaceObjects: %d\n",
             mMaxCapacity, mFreeSpaceBytes, mFreeSpaceObjects);
-    LOGD("\tmStorageDescription: %s\n\tmVolumeIdentifier: %s\n",
+    ALOGD("\tmStorageDescription: %s\n\tmVolumeIdentifier: %s\n",
             mStorageDescription, mVolumeIdentifier);
 }
 
diff --git a/services/audioflinger/Android.mk b/services/audioflinger/Android.mk
index fa49592..52834db 100644
--- a/services/audioflinger/Android.mk
+++ b/services/audioflinger/Android.mk
@@ -11,9 +11,11 @@
     AudioPolicyService.cpp
 
 LOCAL_C_INCLUDES := \
-    system/media/audio_effects/include
+    system/media/audio_effects/include \
+    system/media/audio_utils/include
 
 LOCAL_SHARED_LIBRARIES := \
+    libaudioutils \
     libcutils \
     libutils \
     libbinder \
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index 060a632..9fb666e 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -35,10 +35,12 @@
 
 #include <cutils/bitops.h>
 #include <cutils/properties.h>
+#include <cutils/compiler.h>
 
 #include <media/AudioTrack.h>
 #include <media/AudioRecord.h>
 #include <media/IMediaPlayerService.h>
+#include <media/IMediaDeathNotifier.h>
 
 #include <private/media/AudioTrackShared.h>
 #include <private/media/AudioEffectShared.h>
@@ -54,6 +56,8 @@
 #include <audio_effects/effect_ns.h>
 #include <audio_effects/effect_aec.h>
 
+#include <audio_utils/primitives.h>
+
 #include <cpustats/ThreadCpuUsage.h>
 #include <powermanager/PowerManager.h>
 // #define DEBUG_CPU_USAGE 10  // log statistics every n wall clock seconds
@@ -63,8 +67,8 @@
 
 namespace android {
 
-static const char* kDeadlockedString = "AudioFlinger may be deadlocked\n";
-static const char* kHardwareLockedString = "Hardware lock is taken\n";
+static const char kDeadlockedString[] = "AudioFlinger may be deadlocked\n";
+static const char kHardwareLockedString[] = "Hardware lock is taken\n";
 
 //static const nsecs_t kStandbyTimeInNsecs = seconds(3);
 static const float MAX_GAIN = 4096.0f;
@@ -80,14 +84,16 @@
 static const int8_t kMaxTrackRetriesDirect = 2;
 
 static const int kDumpLockRetries = 50;
-static const int kDumpLockSleep = 20000;
+static const int kDumpLockSleepUs = 20000;
 
-static const nsecs_t kWarningThrottle = seconds(5);
+// don't warn about blocked writes or record buffer overflows more often than this
+static const nsecs_t kWarningThrottleNs = seconds(5);
 
 // RecordThread loop sleep time upon application overrun or audio HAL read error
 static const int kRecordThreadSleepUs = 5000;
 
-static const nsecs_t kSetParametersTimeout = seconds(2);
+// maximum time to wait for setParameters to complete
+static const nsecs_t kSetParametersTimeoutNs = seconds(2);
 
 // minimum sleep time for the mixer thread loop when tracks are active but in underrun
 static const uint32_t kMinThreadSleepTimeUs = 5000;
@@ -100,24 +106,22 @@
 static bool recordingAllowed() {
     if (getpid() == IPCThreadState::self()->getCallingPid()) return true;
     bool ok = checkCallingPermission(String16("android.permission.RECORD_AUDIO"));
-    if (!ok) LOGE("Request requires android.permission.RECORD_AUDIO");
+    if (!ok) ALOGE("Request requires android.permission.RECORD_AUDIO");
     return ok;
 }
 
 static bool settingsAllowed() {
     if (getpid() == IPCThreadState::self()->getCallingPid()) return true;
     bool ok = checkCallingPermission(String16("android.permission.MODIFY_AUDIO_SETTINGS"));
-    if (!ok) LOGE("Request requires android.permission.MODIFY_AUDIO_SETTINGS");
+    if (!ok) ALOGE("Request requires android.permission.MODIFY_AUDIO_SETTINGS");
     return ok;
 }
 
 // To collect the amplifier usage
 static void addBatteryData(uint32_t params) {
-    sp<IBinder> binder =
-        defaultServiceManager()->getService(String16("media.player"));
-    sp<IMediaPlayerService> service = interface_cast<IMediaPlayerService>(binder);
-    if (service.get() == NULL) {
-        LOGW("Cannot connect to the MediaPlayerService for battery tracking");
+    sp<IMediaPlayerService> service = IMediaDeathNotifier::getMediaPlayerService();
+    if (service == NULL) {
+        // it already logged
         return;
     }
 
@@ -134,7 +138,7 @@
         goto out;
 
     rc = audio_hw_device_open(*mod, dev);
-    LOGE_IF(rc, "couldn't open audio hw device in %s.%s (%s)",
+    ALOGE_IF(rc, "couldn't open audio hw device in %s.%s (%s)",
             AUDIO_HARDWARE_MODULE_ID, if_name, strerror(-rc));
     if (rc)
         goto out;
@@ -147,7 +151,7 @@
     return rc;
 }
 
-static const char *audio_interfaces[] = {
+static const char * const audio_interfaces[] = {
     "primary",
     "a2dp",
     "usb",
@@ -158,7 +162,7 @@
 
 AudioFlinger::AudioFlinger()
     : BnAudioFlinger(),
-        mPrimaryHardwareDev(0), mMasterVolume(1.0f), mMasterMute(false), mNextUniqueId(1),
+        mPrimaryHardwareDev(NULL), mMasterVolume(1.0f), mMasterMute(false), mNextUniqueId(1),
         mBtNrecIsOff(false)
 {
 }
@@ -180,13 +184,13 @@
         if (rc)
             continue;
 
-        LOGI("Loaded %s audio interface from %s (%s)", audio_interfaces[i],
+        ALOGI("Loaded %s audio interface from %s (%s)", audio_interfaces[i],
              mod->name, mod->id);
         mAudioHwDevs.push(dev);
 
         if (!mPrimaryHardwareDev) {
             mPrimaryHardwareDev = dev;
-            LOGI("Using '%s' (%s.%s) as the primary audio interface",
+            ALOGI("Using '%s' (%s.%s) as the primary audio interface",
                  mod->name, mod->id, audio_interfaces[i]);
         }
     }
@@ -194,7 +198,7 @@
     mHardwareStatus = AUDIO_HW_INIT;
 
     if (!mPrimaryHardwareDev || mAudioHwDevs.size() == 0) {
-        LOGE("Primary audio interface not found");
+        ALOGE("Primary audio interface not found");
         return;
     }
 
@@ -290,7 +294,7 @@
     const size_t SIZE = 256;
     char buffer[SIZE];
     String8 result;
-    int hardwareStatus = mHardwareStatus;
+    hardware_call_state hardwareStatus = mHardwareStatus;
 
     snprintf(buffer, SIZE, "Hardware status: %d\n", hardwareStatus);
     result.append(buffer);
@@ -320,7 +324,7 @@
             locked = true;
             break;
         }
-        usleep(kDumpLockSleep);
+        usleep(kDumpLockSleepUs);
     }
     return locked;
 }
@@ -395,7 +399,7 @@
     int lSessionId;
 
     if (streamType >= AUDIO_STREAM_CNT) {
-        LOGE("invalid stream type");
+        ALOGE("createTrack() invalid stream type %d", streamType);
         lStatus = BAD_VALUE;
         goto Exit;
     }
@@ -405,7 +409,7 @@
         PlaybackThread *thread = checkPlaybackThread_l(output);
         PlaybackThread *effectThread = NULL;
         if (thread == NULL) {
-            LOGE("unknown output thread");
+            ALOGE("unknown output thread");
             lStatus = BAD_VALUE;
             goto Exit;
         }
@@ -419,7 +423,7 @@
             mClients.add(pid, client);
         }
 
-        LOGV("createTrack() sessionId: %d", (sessionId == NULL) ? -2 : *sessionId);
+        ALOGV("createTrack() sessionId: %d", (sessionId == NULL) ? -2 : *sessionId);
         if (sessionId != NULL && *sessionId != AUDIO_SESSION_OUTPUT_MIX) {
             for (size_t i = 0; i < mPlaybackThreads.size(); i++) {
                 sp<PlaybackThread> t = mPlaybackThreads.valueAt(i);
@@ -427,6 +431,7 @@
                     // prevent same audio session on different output threads
                     uint32_t sessions = t->hasAudioSession(*sessionId);
                     if (sessions & PlaybackThread::TRACK_SESSION) {
+                        ALOGE("createTrack() session ID %d already in use", *sessionId);
                         lStatus = BAD_VALUE;
                         goto Exit;
                     }
@@ -444,7 +449,7 @@
                 *sessionId = lSessionId;
             }
         }
-        LOGV("createTrack() lSessionId: %d", lSessionId);
+        ALOGV("createTrack() lSessionId: %d", lSessionId);
 
         track = thread->createTrack_l(client, streamType, sampleRate, format,
                 channelMask, frameCount, sharedBuffer, lSessionId, &lStatus);
@@ -478,7 +483,7 @@
     Mutex::Autolock _l(mLock);
     PlaybackThread *thread = checkPlaybackThread_l(output);
     if (thread == NULL) {
-        LOGW("sampleRate() unknown thread %d", output);
+        ALOGW("sampleRate() unknown thread %d", output);
         return 0;
     }
     return thread->sampleRate();
@@ -489,7 +494,7 @@
     Mutex::Autolock _l(mLock);
     PlaybackThread *thread = checkPlaybackThread_l(output);
     if (thread == NULL) {
-        LOGW("channelCount() unknown thread %d", output);
+        ALOGW("channelCount() unknown thread %d", output);
         return 0;
     }
     return thread->channelCount();
@@ -500,7 +505,7 @@
     Mutex::Autolock _l(mLock);
     PlaybackThread *thread = checkPlaybackThread_l(output);
     if (thread == NULL) {
-        LOGW("format() unknown thread %d", output);
+        ALOGW("format() unknown thread %d", output);
         return 0;
     }
     return thread->format();
@@ -511,7 +516,7 @@
     Mutex::Autolock _l(mLock);
     PlaybackThread *thread = checkPlaybackThread_l(output);
     if (thread == NULL) {
-        LOGW("frameCount() unknown thread %d", output);
+        ALOGW("frameCount() unknown thread %d", output);
         return 0;
     }
     return thread->frameCount();
@@ -522,7 +527,7 @@
     Mutex::Autolock _l(mLock);
     PlaybackThread *thread = checkPlaybackThread_l(output);
     if (thread == NULL) {
-        LOGW("latency() unknown thread %d", output);
+        ALOGW("latency() unknown thread %d", output);
         return 0;
     }
     return thread->latency();
@@ -569,8 +574,8 @@
     if (!settingsAllowed()) {
         return PERMISSION_DENIED;
     }
-    if ((mode < 0) || (mode >= AUDIO_MODE_CNT)) {
-        LOGW("Illegal value: setMode(%d)", mode);
+    if (uint32_t(mode) >= AUDIO_MODE_CNT) {
+        ALOGW("Illegal value: setMode(%d)", mode);
         return BAD_VALUE;
     }
 
@@ -657,6 +662,7 @@
     }
 
     if (stream < 0 || uint32_t(stream) >= AUDIO_STREAM_CNT) {
+        ALOGE("setStreamVolume() invalid stream %d", stream);
         return BAD_VALUE;
     }
 
@@ -691,6 +697,7 @@
 
     if (stream < 0 || uint32_t(stream) >= AUDIO_STREAM_CNT ||
         uint32_t(stream) == AUDIO_STREAM_ENFORCED_AUDIBLE) {
+        ALOGE("setStreamMute() invalid stream %d", stream);
         return BAD_VALUE;
     }
 
@@ -736,7 +743,7 @@
 {
     status_t result;
 
-    LOGV("setParameters(): io %d, keyvalue %s, tid %d, calling tid %d",
+    ALOGV("setParameters(): io %d, keyvalue %s, tid %d, calling tid %d",
             ioHandle, keyValuePairs.string(), gettid(), IPCThreadState::self()->getCallingPid());
     // check calling permissions
     if (!settingsAllowed()) {
@@ -810,7 +817,7 @@
 
 String8 AudioFlinger::getParameters(int ioHandle, const String8& keys)
 {
-//    LOGV("getParameters() io %d, keys %s, tid %d, calling tid %d",
+//    ALOGV("getParameters() io %d, keys %s, tid %d, calling tid %d",
 //            ioHandle, keys.string(), gettid(), IPCThreadState::self()->getCallingPid());
 
     if (ioHandle == 0) {
@@ -907,7 +914,7 @@
         sp<NotificationClient> notificationClient = new NotificationClient(this,
                                                                             client,
                                                                             pid);
-        LOGV("registerClient() client %p, pid %d", notificationClient.get(), pid);
+        ALOGV("registerClient() client %p, pid %d", notificationClient.get(), pid);
 
         mNotificationClients.add(pid, notificationClient);
 
@@ -933,18 +940,18 @@
     int index = mNotificationClients.indexOfKey(pid);
     if (index >= 0) {
         sp <NotificationClient> client = mNotificationClients.valueFor(pid);
-        LOGV("removeNotificationClient() %p, pid %d", client.get(), pid);
+        ALOGV("removeNotificationClient() %p, pid %d", client.get(), pid);
         mNotificationClients.removeItem(pid);
     }
 
-    LOGV("%d died, releasing its sessions", pid);
+    ALOGV("%d died, releasing its sessions", pid);
     int num = mAudioSessionRefs.size();
     bool removed = false;
     for (int i = 0; i< num; i++) {
         AudioSessionRef *ref = mAudioSessionRefs.itemAt(i);
-        LOGV(" pid %d @ %d", ref->pid, i);
+        ALOGV(" pid %d @ %d", ref->pid, i);
         if (ref->pid == pid) {
-            LOGV(" removing entry for pid %d session %d", pid, ref->sessionid);
+            ALOGV(" removing entry for pid %d session %d", pid, ref->sessionid);
             mAudioSessionRefs.removeAt(i);
             delete ref;
             removed = true;
@@ -969,7 +976,7 @@
 // removeClient_l() must be called with AudioFlinger::mLock held
 void AudioFlinger::removeClient_l(pid_t pid)
 {
-    LOGV("removeClient_l() pid %d, tid %d, calling tid %d", pid, gettid(), IPCThreadState::self()->getCallingPid());
+    ALOGV("removeClient_l() pid %d, tid %d, calling tid %d", pid, gettid(), IPCThreadState::self()->getCallingPid());
     mClients.removeItem(pid);
 }
 
@@ -988,7 +995,6 @@
 AudioFlinger::ThreadBase::~ThreadBase()
 {
     mParamCond.broadcast();
-    mNewParameters.clear();
     // do not lock the mutex in destructor
     releaseWakeLock_l();
     if (mPowerManager != 0) {
@@ -999,13 +1005,13 @@
 
 void AudioFlinger::ThreadBase::exit()
 {
-    // keep a strong ref on ourself so that we wont get
+    // keep a strong ref on ourself so that we won't get
     // destroyed in the middle of requestExitAndWait()
     sp <ThreadBase> strongMe = this;
 
-    LOGV("ThreadBase::exit");
+    ALOGV("ThreadBase::exit");
     {
-        AutoMutex lock(&mLock);
+        AutoMutex lock(mLock);
         mExiting = true;
         requestExit();
         mWaitWorkCV.signal();
@@ -1037,14 +1043,14 @@
 {
     status_t status;
 
-    LOGV("ThreadBase::setParameters() %s", keyValuePairs.string());
+    ALOGV("ThreadBase::setParameters() %s", keyValuePairs.string());
     Mutex::Autolock _l(mLock);
 
     mNewParameters.add(keyValuePairs);
     mWaitWorkCV.signal();
     // wait condition with timeout in case the thread loop has exited
     // before the request could be processed
-    if (mParamCond.waitRelative(mLock, kSetParametersTimeout) == NO_ERROR) {
+    if (mParamCond.waitRelative(mLock, kSetParametersTimeoutNs) == NO_ERROR) {
         status = mParamStatus;
         mWaitWorkCV.signal();
     } else {
@@ -1062,11 +1068,11 @@
 // sendConfigEvent_l() must be called with ThreadBase::mLock held
 void AudioFlinger::ThreadBase::sendConfigEvent_l(int event, int param)
 {
-    ConfigEvent *configEvent = new ConfigEvent();
-    configEvent->mEvent = event;
-    configEvent->mParam = param;
+    ConfigEvent configEvent;
+    configEvent.mEvent = event;
+    configEvent.mParam = param;
     mConfigEvents.add(configEvent);
-    LOGV("sendConfigEvent() num events %d event %d, param %d", mConfigEvents.size(), event, param);
+    ALOGV("sendConfigEvent() num events %d event %d, param %d", mConfigEvents.size(), event, param);
     mWaitWorkCV.signal();
 }
 
@@ -1074,16 +1080,15 @@
 {
     mLock.lock();
     while(!mConfigEvents.isEmpty()) {
-        LOGV("processConfigEvents() remaining events %d", mConfigEvents.size());
-        ConfigEvent *configEvent = mConfigEvents[0];
+        ALOGV("processConfigEvents() remaining events %d", mConfigEvents.size());
+        ConfigEvent configEvent = mConfigEvents[0];
         mConfigEvents.removeAt(0);
         // release mLock before locking AudioFlinger mLock: lock order is always
         // AudioFlinger then ThreadBase to avoid cross deadlock
         mLock.unlock();
         mAudioFlinger->mLock.lock();
-        audioConfigChanged_l(configEvent->mEvent, configEvent->mParam);
+        audioConfigChanged_l(configEvent.mEvent, configEvent.mParam);
         mAudioFlinger->mLock.unlock();
-        delete configEvent;
         mLock.lock();
     }
     mLock.unlock();
@@ -1130,7 +1135,7 @@
     snprintf(buffer, SIZE, " Index event param\n");
     result.append(buffer);
     for (size_t i = 0; i < mConfigEvents.size(); i++) {
-        snprintf(buffer, SIZE, " %02d    %02d    %d\n", i, mConfigEvents[i]->mEvent, mConfigEvents[i]->mParam);
+        snprintf(buffer, SIZE, " %02d    %02d    %d\n", i, mConfigEvents[i].mEvent, mConfigEvents[i].mParam);
         result.append(buffer);
     }
     result.append("\n");
@@ -1174,7 +1179,7 @@
         sp<IBinder> binder =
             defaultServiceManager()->checkService(String16("power"));
         if (binder == 0) {
-            LOGW("Thread %s cannot connect to the power manager service", mName);
+            ALOGW("Thread %s cannot connect to the power manager service", mName);
         } else {
             mPowerManager = interface_cast<IPowerManager>(binder);
             binder->linkToDeath(mDeathRecipient);
@@ -1188,7 +1193,7 @@
         if (status == NO_ERROR) {
             mWakeLockToken = binder;
         }
-        LOGV("acquireWakeLock_l() %s status %d", mName, status);
+        ALOGV("acquireWakeLock_l() %s status %d", mName, status);
     }
 }
 
@@ -1201,7 +1206,7 @@
 void AudioFlinger::ThreadBase::releaseWakeLock_l()
 {
     if (mWakeLockToken != 0) {
-        LOGV("releaseWakeLock_l() %s", mName);
+        ALOGV("releaseWakeLock_l() %s", mName);
         if (mPowerManager != 0) {
             mPowerManager->releaseWakeLock(mWakeLockToken, 0);
         }
@@ -1222,7 +1227,7 @@
     if (thread != 0) {
         thread->clearPowerManager();
     }
-    LOGW("power manager service died !!!");
+    ALOGW("power manager service died !!!");
 }
 
 void AudioFlinger::ThreadBase::setEffectSuspended(
@@ -1264,7 +1269,7 @@
             if (sessionEffects.keyAt(i) == EffectChain::kKeyForSuspendAll) {
                 chain->setEffectSuspendedAll_l(true);
             } else {
-                LOGV("checkSuspendOnAddEffectChain_l() suspending effects %08x",
+                ALOGV("checkSuspendOnAddEffectChain_l() suspending effects %08x",
                      desc->mType.timeLow);
                 chain->setEffectSuspended_l(&desc->mType, true);
             }
@@ -1310,7 +1315,7 @@
                 memcpy(&desc->mType, type, sizeof(effect_uuid_t));
             }
             sessionEffects.add(key, desc);
-            LOGV("updateSuspendedSessions_l() suspend adding effect %08x", key);
+            ALOGV("updateSuspendedSessions_l() suspend adding effect %08x", key);
         }
         desc->mRefCount++;
     } else {
@@ -1319,10 +1324,10 @@
         }
         desc = sessionEffects.valueAt(index);
         if (--desc->mRefCount == 0) {
-            LOGV("updateSuspendedSessions_l() restore removing effect %08x", key);
+            ALOGV("updateSuspendedSessions_l() restore removing effect %08x", key);
             sessionEffects.removeItemsAt(index);
             if (sessionEffects.isEmpty()) {
-                LOGV("updateSuspendedSessions_l() restore removing session %d",
+                ALOGV("updateSuspendedSessions_l() restore removing session %d",
                                  sessionId);
                 mSuspendedSessions.removeItem(sessionId);
             }
@@ -1367,7 +1372,7 @@
                                              int id,
                                              uint32_t device)
     :   ThreadBase(audioFlinger, id, device),
-        mMixBuffer(0), mSuspended(0), mBytesWritten(0), mOutput(output),
+        mMixBuffer(NULL), mSuspended(0), mBytesWritten(0), mOutput(output),
         mLastWriteTime(0), mNumWrites(0), mNumDelayedWrites(0), mInWrite(false)
 {
     snprintf(mName, kNameLength, "AudioOut_%d", id);
@@ -1463,9 +1468,9 @@
 {
     status_t status = initCheck();
     if (status == NO_ERROR) {
-        LOGI("AudioFlinger's thread %p ready to run", this);
+        ALOGI("AudioFlinger's thread %p ready to run", this);
     } else {
-        LOGE("No working audio driver found.");
+        ALOGE("No working audio driver found.");
     }
     return status;
 }
@@ -1493,7 +1498,7 @@
     if (mType == DIRECT) {
         if ((format & AUDIO_FORMAT_MAIN_MASK) == AUDIO_FORMAT_PCM) {
             if (sampleRate != mSampleRate || format != mFormat || channelMask != mChannelMask) {
-                LOGE("createTrack_l() Bad parameter: sampleRate %d format %d, channelMask 0x%08x \""
+                ALOGE("createTrack_l() Bad parameter: sampleRate %d format %d, channelMask 0x%08x \""
                         "for output %p with format %d",
                         sampleRate, format, channelMask, mOutput, mFormat);
                 lStatus = BAD_VALUE;
@@ -1503,7 +1508,7 @@
     } else {
         // Resampler implementation limits input sampling rate to 2 x output sampling rate.
         if (sampleRate > mSampleRate*2) {
-            LOGE("Sample rate out of range: %d mSampleRate %d", sampleRate, mSampleRate);
+            ALOGE("Sample rate out of range: %d mSampleRate %d", sampleRate, mSampleRate);
             lStatus = BAD_VALUE;
             goto Exit;
         }
@@ -1511,7 +1516,7 @@
 
     lStatus = initCheck();
     if (lStatus != NO_ERROR) {
-        LOGE("Audio driver not initialized.");
+        ALOGE("Audio driver not initialized.");
         goto Exit;
     }
 
@@ -1526,8 +1531,10 @@
         for (size_t i = 0; i < mTracks.size(); ++i) {
             sp<Track> t = mTracks[i];
             if (t != 0) {
-                if (sessionId == t->sessionId() &&
-                        strategy != AudioSystem::getStrategyForStream((audio_stream_type_t)t->type())) {
+                uint32_t actual = AudioSystem::getStrategyForStream((audio_stream_type_t)t->type());
+                if (sessionId == t->sessionId() && strategy != actual) {
+                    ALOGE("createTrack_l() mismatched strategy; expected %u but found %u",
+                            strategy, actual);
                     lStatus = BAD_VALUE;
                     goto Exit;
                 }
@@ -1544,7 +1551,7 @@
 
         sp<EffectChain> chain = getEffectChain_l(sessionId);
         if (chain != 0) {
-            LOGV("createTrack_l() setting main buffer %p", chain->inBuffer());
+            ALOGV("createTrack_l() setting main buffer %p", chain->inBuffer());
             track->setMainBuffer(chain->inBuffer());
             chain->setStrategy(AudioSystem::getStrategyForStream((audio_stream_type_t)track->type()));
             chain->incTrackCnt();
@@ -1553,7 +1560,7 @@
         // invalidate track immediately if the stream type was moved to another thread since
         // createTrack() was called by the client process.
         if (!mStreamTypes[streamType].valid) {
-            LOGW("createTrack_l() on thread %p: invalidating track on stream %d",
+            ALOGW("createTrack_l() on thread %p: invalidating track on stream %d",
                  this, streamType);
             android_atomic_or(CBLK_INVALID_ON, &track->mCblk->flags);
         }
@@ -1638,7 +1645,7 @@
         if (track->mainBuffer() != mMixBuffer) {
             sp<EffectChain> chain = getEffectChain_l(track->sessionId());
             if (chain != 0) {
-                LOGV("addTrack_l() starting track on chain %p for session %d", chain.get(), track->sessionId());
+                ALOGV("addTrack_l() starting track on chain %p for session %d", chain.get(), track->sessionId());
                 chain->incActiveTrackCnt();
             }
         }
@@ -1646,7 +1653,7 @@
         status = NO_ERROR;
     }
 
-    LOGV("mWaitWorkCV.broadcast");
+    ALOGV("mWaitWorkCV.broadcast");
     mWaitWorkCV.broadcast();
 
     return status;
@@ -1692,7 +1699,7 @@
     AudioSystem::OutputDescriptor desc;
     void *param2 = 0;
 
-    LOGV("PlaybackThread::audioConfigChanged_l, thread %p, event %d, param %d", this, event, param);
+    ALOGV("PlaybackThread::audioConfigChanged_l, thread %p, event %d, param %d", this, event, param);
 
     switch (event) {
     case AudioSystem::OUTPUT_OPENED:
@@ -1832,14 +1839,14 @@
 
 AudioFlinger::MixerThread::MixerThread(const sp<AudioFlinger>& audioFlinger, AudioStreamOut* output, int id, uint32_t device)
     :   PlaybackThread(audioFlinger, output, id, device),
-        mAudioMixer(0)
+        mAudioMixer(NULL)
 {
     mType = ThreadBase::MIXER;
     mAudioMixer = new AudioMixer(mFrameCount, mSampleRate);
 
     // FIXME - Current mixer implementation only supports stereo output
     if (mChannelCount == 1) {
-        LOGE("Invalid audio hardware channel count");
+        ALOGE("Invalid audio hardware channel count");
     }
 }
 
@@ -1889,7 +1896,7 @@
                 double minimum = stats.minimum();
                 double maximum = stats.maximum();
                 cpu.resetStatistics();
-                LOGI("CPU usage over past %.1f secs (%u mixer loops at %.1f mean ms per loop):\n  us per mix loop: mean=%.0f stddev=%.0f min=%.0f max=%.0f\n  %% of wall: mean=%.1f stddev=%.1f min=%.1f max=%.1f",
+                ALOGI("CPU usage over past %.1f secs (%u mixer loops at %.1f mean ms per loop):\n  us per mix loop: mean=%.0f stddev=%.0f min=%.0f max=%.0f\n  %% of wall: mean=%.1f stddev=%.1f min=%.1f max=%.1f",
                         elapsed * .000000001, n, perLoop * .000001,
                         mean * .001,
                         stddev * .001,
@@ -1923,10 +1930,10 @@
             const SortedVector< wp<Track> >& activeTracks = mActiveTracks;
 
             // put audio hardware into standby after short delay
-            if UNLIKELY((!activeTracks.size() && systemTime() > standbyTime) ||
-                        mSuspended) {
+            if (CC_UNLIKELY((!activeTracks.size() && systemTime() > standbyTime) ||
+                        mSuspended)) {
                 if (!mStandby) {
-                    LOGV("Audio hardware entering standby, mixer %p, mSuspended %d\n", this, mSuspended);
+                    ALOGV("Audio hardware entering standby, mixer %p, mSuspended %d\n", this, mSuspended);
                     mOutput->stream->common.standby(&mOutput->stream->common);
                     mStandby = true;
                     mBytesWritten = 0;
@@ -1940,16 +1947,16 @@
 
                     releaseWakeLock_l();
                     // wait until we have something to do...
-                    LOGV("MixerThread %p TID %d going to sleep\n", this, gettid());
+                    ALOGV("MixerThread %p TID %d going to sleep\n", this, gettid());
                     mWaitWorkCV.wait(mLock);
-                    LOGV("MixerThread %p TID %d waking up\n", this, gettid());
+                    ALOGV("MixerThread %p TID %d waking up\n", this, gettid());
                     acquireWakeLock_l();
 
                     if (mMasterMute == false) {
                         char value[PROPERTY_VALUE_MAX];
                         property_get("ro.audio.silent", value, "0");
                         if (atoi(value)) {
-                            LOGD("Silence is golden");
+                            ALOGD("Silence is golden");
                             setMasterMute(true);
                         }
                     }
@@ -1967,9 +1974,9 @@
             // during mixing and effect process as the audio buffers could be deleted
             // or modified if an effect is created or deleted
             lockEffectChains_l(effectChains);
-       }
+        }
 
-        if (LIKELY(mixerStatus == MIXER_TRACKS_READY)) {
+        if (CC_LIKELY(mixerStatus == MIXER_TRACKS_READY)) {
             // mix buffers...
             mAudioMixer->process();
             sleepTime = 0;
@@ -2002,7 +2009,7 @@
                        (mixerStatus == MIXER_TRACKS_ENABLED && longStandbyExit)) {
                 memset (mMixBuffer, 0, mixBufferSize);
                 sleepTime = 0;
-                LOGV_IF((mBytesWritten == 0 && (mixerStatus == MIXER_TRACKS_ENABLED && longStandbyExit)), "anticipated start");
+                ALOGV_IF((mBytesWritten == 0 && (mixerStatus == MIXER_TRACKS_ENABLED && longStandbyExit)), "anticipated start");
             }
             // TODO add standby time extension fct of effect tail
         }
@@ -2012,11 +2019,11 @@
         }
         // sleepTime == 0 means we must write to audio hardware
         if (sleepTime == 0) {
-             for (size_t i = 0; i < effectChains.size(); i ++) {
-                 effectChains[i]->process_l();
-             }
-             // enable changes in effect chain
-             unlockEffectChains(effectChains);
+            for (size_t i = 0; i < effectChains.size(); i ++) {
+                effectChains[i]->process_l();
+            }
+            // enable changes in effect chain
+            unlockEffectChains(effectChains);
             mLastWriteTime = systemTime();
             mInWrite = true;
             mBytesWritten += mixBufferSize;
@@ -2029,8 +2036,8 @@
             nsecs_t delta = now - mLastWriteTime;
             if (!mStandby && delta > maxPeriod) {
                 mNumDelayedWrites++;
-                if ((now - lastWarning) > kWarningThrottle) {
-                    LOGW("write blocked for %llu msecs, %d delayed writes, thread %p",
+                if ((now - lastWarning) > kWarningThrottleNs) {
+                    ALOGW("write blocked for %llu msecs, %d delayed writes, thread %p",
                             ns2ms(delta), mNumDelayedWrites, this);
                     lastWarning = now;
                 }
@@ -2061,7 +2068,7 @@
 
     releaseWakeLock();
 
-    LOGV("MixerThread %p exiting", this);
+    ALOGV("MixerThread %p exiting", this);
     return false;
 }
 
@@ -2094,12 +2101,13 @@
         sp<Track> t = activeTracks[i].promote();
         if (t == 0) continue;
 
+        // this const just means the local variable doesn't change
         Track* const track = t.get();
         audio_track_cblk_t* cblk = track->cblk();
 
         // The first time a track is added we wait
         // for all its buffers to be filled before processing it
-        mAudioMixer->setActiveTrack(track->name());
+        int name = track->name();
         // make sure that we have enough frames to mix one full buffer.
         // enforce this condition only once to enable draining the buffer in case the client
         // app does not call stop() and relies on underrun to stop:
@@ -2119,13 +2127,13 @@
                 // the minimum track buffer size is normally twice the number of frames necessary
                 // to fill one buffer and the resampler should not leave more than one buffer worth
                 // of unreleased frames after each pass, but just in case...
-                LOG_ASSERT(minFrames <= cblk->frameCount);
+                ALOG_ASSERT(minFrames <= cblk->frameCount);
             }
         }
         if ((cblk->framesReady() >= minFrames) && track->isReady() &&
                 !track->isPaused() && !track->isTerminated())
         {
-            //LOGV("track %d u=%08x, s=%08x [OK] on thread %p", track->name(), cblk->user, cblk->server, this);
+            //ALOGV("track %d u=%08x, s=%08x [OK] on thread %p", name, cblk->user, cblk->server, this);
 
             mixedTracks++;
 
@@ -2138,8 +2146,8 @@
                 if (chain != 0) {
                     tracksWithEffect++;
                 } else {
-                    LOGW("prepareTracks_l(): track %08x attached to effect but no chain found on session %d",
-                            track->name(), track->sessionId());
+                    ALOGW("prepareTracks_l(): track %d attached to effect but no chain found on session %d",
+                            name, track->sessionId());
                 }
             }
 
@@ -2152,7 +2160,7 @@
                     track->mState = TrackBase::ACTIVE;
                     param = AudioMixer::RAMP_VOLUME;
                 }
-                mAudioMixer->setParameter(AudioMixer::RESAMPLE, AudioMixer::RESET, NULL);
+                mAudioMixer->setParameter(name, AudioMixer::RESAMPLE, AudioMixer::RESET, NULL);
             } else if (cblk->server != 0) {
                 // If the track is stopped before the first frame was mixed,
                 // do not apply ramp
@@ -2204,26 +2212,31 @@
             aux = int16_t(va);
 
             // XXX: these things DON'T need to be done each time
-            mAudioMixer->setBufferProvider(track);
-            mAudioMixer->enable(AudioMixer::MIXING);
+            mAudioMixer->setBufferProvider(name, track);
+            mAudioMixer->enable(name);
 
-            mAudioMixer->setParameter(param, AudioMixer::VOLUME0, (void *)left);
-            mAudioMixer->setParameter(param, AudioMixer::VOLUME1, (void *)right);
-            mAudioMixer->setParameter(param, AudioMixer::AUXLEVEL, (void *)aux);
+            mAudioMixer->setParameter(name, param, AudioMixer::VOLUME0, (void *)left);
+            mAudioMixer->setParameter(name, param, AudioMixer::VOLUME1, (void *)right);
+            mAudioMixer->setParameter(name, param, AudioMixer::AUXLEVEL, (void *)aux);
             mAudioMixer->setParameter(
+                name,
                 AudioMixer::TRACK,
                 AudioMixer::FORMAT, (void *)track->format());
             mAudioMixer->setParameter(
+                name,
                 AudioMixer::TRACK,
                 AudioMixer::CHANNEL_MASK, (void *)track->channelMask());
             mAudioMixer->setParameter(
+                name,
                 AudioMixer::RESAMPLE,
                 AudioMixer::SAMPLE_RATE,
                 (void *)(cblk->sampleRate));
             mAudioMixer->setParameter(
+                name,
                 AudioMixer::TRACK,
                 AudioMixer::MAIN_BUFFER, (void *)track->mainBuffer());
             mAudioMixer->setParameter(
+                name,
                 AudioMixer::TRACK,
                 AudioMixer::AUX_BUFFER, (void *)track->auxBuffer());
 
@@ -2231,7 +2244,7 @@
             track->mRetryCount = kMaxTrackRetries;
             mixerStatus = MIXER_TRACKS_READY;
         } else {
-            //LOGV("track %d u=%08x, s=%08x [NOT READY] on thread %p", track->name(), cblk->user, cblk->server, this);
+            //ALOGV("track %d u=%08x, s=%08x [NOT READY] on thread %p", name, cblk->user, cblk->server, this);
             if (track->isStopped()) {
                 track->reset();
             }
@@ -2243,7 +2256,7 @@
                 // No buffers for this track. Give it a few chances to
                 // fill a buffer, then remove it from active list.
                 if (--(track->mRetryCount) <= 0) {
-                    LOGV("BUFFER TIMEOUT: remove(%d) from active list on thread %p", track->name(), this);
+                    ALOGV("BUFFER TIMEOUT: remove(%d) from active list on thread %p", name, this);
                     tracksToRemove->add(track);
                     // indicate to client process that the track was disabled because of underrun
                     android_atomic_or(CBLK_DISABLED_ON, &cblk->flags);
@@ -2251,20 +2264,20 @@
                     mixerStatus = MIXER_TRACKS_ENABLED;
                 }
             }
-            mAudioMixer->disable(AudioMixer::MIXING);
+            mAudioMixer->disable(name);
         }
     }
 
     // remove all the tracks that need to be...
     count = tracksToRemove->size();
-    if (UNLIKELY(count)) {
+    if (CC_UNLIKELY(count)) {
         for (size_t i=0 ; i<count ; i++) {
             const sp<Track>& track = tracksToRemove->itemAt(i);
             mActiveTracks.remove(track);
             if (track->mainBuffer() != mMixBuffer) {
                 chain = getEffectChain_l(track->sessionId());
                 if (chain != 0) {
-                    LOGV("stopping track on chain %p for session Id: %d", chain.get(), track->sessionId());
+                    ALOGV("stopping track on chain %p for session Id: %d", chain.get(), track->sessionId());
                     chain->decActiveTrackCnt();
                 }
             }
@@ -2286,7 +2299,7 @@
 
 void AudioFlinger::MixerThread::invalidateTracks(int streamType)
 {
-    LOGV ("MixerThread::invalidateTracks() mixer %p, streamType %d, mTracks.size %d",
+    ALOGV ("MixerThread::invalidateTracks() mixer %p, streamType %d, mTracks.size %d",
             this,  streamType, mTracks.size());
     Mutex::Autolock _l(mLock);
 
@@ -2302,7 +2315,7 @@
 
 void AudioFlinger::PlaybackThread::setStreamValid(int streamType, bool valid)
 {
-    LOGV ("PlaybackThread::setStreamValid() thread %p, streamType %d, valid %d",
+    ALOGV ("PlaybackThread::setStreamValid() thread %p, streamType %d, valid %d",
             this,  streamType, valid);
     Mutex::Autolock _l(mLock);
 
@@ -2318,7 +2331,7 @@
 // deleteTrackName_l() must be called with ThreadBase::mLock held
 void AudioFlinger::MixerThread::deleteTrackName_l(int name)
 {
-    LOGV("remove track (%d) and delete from mixer", name);
+    ALOGV("remove track (%d) and delete from mixer", name);
     mAudioMixer->deleteTrackName(name);
 }
 
@@ -2352,7 +2365,7 @@
         }
         if (param.getInt(String8(AudioParameter::keyFrameCount), value) == NO_ERROR) {
             // do not accept frame count changes if tracks are open as the track buffer
-            // size depends on frame count and correct behavior would not be garantied
+            // size depends on frame count and correct behavior would not be guaranteed
             // if frame count is changed after track creation
             if (!mTracks.isEmpty()) {
                 status = INVALID_OPERATION;
@@ -2423,7 +2436,7 @@
         mParamCond.signal();
         // wait for condition with time out in case the thread calling ThreadBase::setParameters()
         // already timed out waiting for the status and will never signal the condition.
-        mWaitWorkCV.waitRelative(mLock, kSetParametersTimeout);
+        mWaitWorkCV.waitRelative(mLock, kSetParametersTimeoutNs);
     }
     return reconfig;
 }
@@ -2463,14 +2476,6 @@
 {
 }
 
-
-static inline int16_t clamp16(int32_t sample)
-{
-    if ((sample>>15) ^ (sample>>31))
-        sample = 0x7FFF ^ (sample>>31);
-    return sample;
-}
-
 static inline
 int32_t mul(int16_t in, int16_t v)
 {
@@ -2600,11 +2605,11 @@
             }
 
             // put audio hardware into standby after short delay
-            if UNLIKELY((!mActiveTracks.size() && systemTime() > standbyTime) ||
-                        mSuspended) {
+            if (CC_UNLIKELY((!mActiveTracks.size() && systemTime() > standbyTime) ||
+                        mSuspended)) {
                 // wait until we have something to do...
                 if (!mStandby) {
-                    LOGV("Audio hardware entering standby, mixer %p\n", this);
+                    ALOGV("Audio hardware entering standby, mixer %p\n", this);
                     mOutput->stream->common.standby(&mOutput->stream->common);
                     mStandby = true;
                     mBytesWritten = 0;
@@ -2617,16 +2622,16 @@
                     if (exitPending()) break;
 
                     releaseWakeLock_l();
-                    LOGV("DirectOutputThread %p TID %d going to sleep\n", this, gettid());
+                    ALOGV("DirectOutputThread %p TID %d going to sleep\n", this, gettid());
                     mWaitWorkCV.wait(mLock);
-                    LOGV("DirectOutputThread %p TID %d waking up in active mode\n", this, gettid());
+                    ALOGV("DirectOutputThread %p TID %d waking up in active mode\n", this, gettid());
                     acquireWakeLock_l();
 
                     if (mMasterMute == false) {
                         char value[PROPERTY_VALUE_MAX];
                         property_get("ro.audio.silent", value, "0");
                         if (atoi(value)) {
-                            LOGD("Silence is golden");
+                            ALOGD("Silence is golden");
                             setMasterMute(true);
                         }
                     }
@@ -2652,7 +2657,7 @@
                 if (cblk->framesReady() && track->isReady() &&
                         !track->isPaused() && !track->isTerminated())
                 {
-                    //LOGV("track %d u=%08x, s=%08x [OK]", track->name(), cblk->user, cblk->server);
+                    //ALOGV("track %d u=%08x, s=%08x [OK]", track->name(), cblk->user, cblk->server);
 
                     if (track->mFillingUpStatus == Track::FS_FILLED) {
                         track->mFillingUpStatus = Track::FS_ACTIVE;
@@ -2729,7 +2734,7 @@
                     activeTrack = t;
                     mixerStatus = MIXER_TRACKS_READY;
                 } else {
-                    //LOGV("track %d u=%08x, s=%08x [NOT READY]", track->name(), cblk->user, cblk->server);
+                    //ALOGV("track %d u=%08x, s=%08x [NOT READY]", track->name(), cblk->user, cblk->server);
                     if (track->isStopped()) {
                         track->reset();
                     }
@@ -2741,7 +2746,7 @@
                         // No buffers for this track. Give it a few chances to
                         // fill a buffer, then remove it from active list.
                         if (--(track->mRetryCount) <= 0) {
-                            LOGV("BUFFER TIMEOUT: remove(%d) from active list", track->name());
+                            ALOGV("BUFFER TIMEOUT: remove(%d) from active list", track->name());
                             trackToRemove = track;
                         } else {
                             mixerStatus = MIXER_TRACKS_ENABLED;
@@ -2751,10 +2756,10 @@
             }
 
             // remove all the tracks that need to be...
-            if (UNLIKELY(trackToRemove != 0)) {
+            if (CC_UNLIKELY(trackToRemove != 0)) {
                 mActiveTracks.remove(trackToRemove);
                 if (!effectChains.isEmpty()) {
-                    LOGV("stopping track on chain %p for session Id: %d", effectChains[0].get(),
+                    ALOGV("stopping track on chain %p for session Id: %d", effectChains[0].get(),
                             trackToRemove->sessionId());
                     effectChains[0]->decActiveTrackCnt();
                 }
@@ -2766,7 +2771,7 @@
             lockEffectChains_l(effectChains);
        }
 
-        if (LIKELY(mixerStatus == MIXER_TRACKS_READY)) {
+        if (CC_LIKELY(mixerStatus == MIXER_TRACKS_READY)) {
             AudioBufferProvider::Buffer buffer;
             size_t frameCount = mFrameCount;
             curBuf = (int8_t *)mMixBuffer;
@@ -2774,7 +2779,7 @@
             while (frameCount) {
                 buffer.frameCount = frameCount;
                 activeTrack->getNextBuffer(&buffer);
-                if (UNLIKELY(buffer.raw == 0)) {
+                if (CC_UNLIKELY(buffer.raw == NULL)) {
                     memset(curBuf, 0, frameCount * mFrameSize);
                     break;
                 }
@@ -2841,7 +2846,7 @@
 
     releaseWakeLock();
 
-    LOGV("DirectOutputThread %p exiting", this);
+    ALOGV("DirectOutputThread %p exiting", this);
     return false;
 }
 
@@ -2899,7 +2904,7 @@
         mParamCond.signal();
         // wait for condition with time out in case the thread calling ThreadBase::setParameters()
         // already timed out waiting for the status and will never signal the condition.
-        mWaitWorkCV.waitRelative(mLock, kSetParametersTimeout);
+        mWaitWorkCV.waitRelative(mLock, kSetParametersTimeoutNs);
     }
     return reconfig;
 }
@@ -2993,8 +2998,8 @@
             }
 
             // put audio hardware into standby after short delay
-            if UNLIKELY((!activeTracks.size() && systemTime() > standbyTime) ||
-                         mSuspended) {
+            if (CC_UNLIKELY((!activeTracks.size() && systemTime() > standbyTime) ||
+                         mSuspended)) {
                 if (!mStandby) {
                     for (size_t i = 0; i < outputTracks.size(); i++) {
                         outputTracks[i]->stop();
@@ -3011,16 +3016,16 @@
                     if (exitPending()) break;
 
                     releaseWakeLock_l();
-                    LOGV("DuplicatingThread %p TID %d going to sleep\n", this, gettid());
+                    ALOGV("DuplicatingThread %p TID %d going to sleep\n", this, gettid());
                     mWaitWorkCV.wait(mLock);
-                    LOGV("DuplicatingThread %p TID %d waking up\n", this, gettid());
+                    ALOGV("DuplicatingThread %p TID %d waking up\n", this, gettid());
                     acquireWakeLock_l();
 
                     if (mMasterMute == false) {
                         char value[PROPERTY_VALUE_MAX];
                         property_get("ro.audio.silent", value, "0");
                         if (atoi(value)) {
-                            LOGD("Silence is golden");
+                            ALOGD("Silence is golden");
                             setMasterMute(true);
                         }
                     }
@@ -3039,7 +3044,7 @@
             lockEffectChains_l(effectChains);
         }
 
-        if (LIKELY(mixerStatus == MIXER_TRACKS_READY)) {
+        if (CC_LIKELY(mixerStatus == MIXER_TRACKS_READY)) {
             // mix buffers...
             if (outputsReady(outputTracks)) {
                 mAudioMixer->process();
@@ -3119,7 +3124,7 @@
     if (outputTrack->cblk() != NULL) {
         thread->setStreamVolume(AUDIO_STREAM_CNT, 1.0f);
         mOutputTracks.add(outputTrack);
-        LOGV("addOutputTrack() track %p, on thread %p", outputTrack, thread);
+        ALOGV("addOutputTrack() track %p, on thread %p", outputTrack, thread);
         updateWaitTime();
     }
 }
@@ -3135,7 +3140,7 @@
             return;
         }
     }
-    LOGV("removeOutputTrack(): unkonwn thread: %p", thread);
+    ALOGV("removeOutputTrack(): unkonwn thread: %p", thread);
 }
 
 void AudioFlinger::DuplicatingThread::updateWaitTime()
@@ -3158,12 +3163,12 @@
     for (size_t i = 0; i < outputTracks.size(); i++) {
         sp <ThreadBase> thread = outputTracks[i]->thread().promote();
         if (thread == 0) {
-            LOGW("DuplicatingThread::outputsReady() could not promote thread on output track %p", outputTracks[i].get());
+            ALOGW("DuplicatingThread::outputsReady() could not promote thread on output track %p", outputTracks[i].get());
             return false;
         }
         PlaybackThread *playbackThread = (PlaybackThread *)thread.get();
         if (playbackThread->standby() && !playbackThread->isSuspended()) {
-            LOGV("DuplicatingThread output track %p on thread %p Not Ready", outputTracks[i].get(), thread.get());
+            ALOGV("DuplicatingThread output track %p on thread %p Not Ready", outputTracks[i].get(), thread.get());
             return false;
         }
     }
@@ -3199,9 +3204,9 @@
         mFlags(flags & ~SYSTEM_FLAGS_MASK),
         mSessionId(sessionId)
 {
-    LOGV_IF(sharedBuffer != 0, "sharedBuffer: %p, size: %d", sharedBuffer->pointer(), sharedBuffer->size());
+    ALOGV_IF(sharedBuffer != 0, "sharedBuffer: %p, size: %d", sharedBuffer->pointer(), sharedBuffer->size());
 
-    // LOGD("Creating track with %d buffers @ %d bytes", bufferCount, bufferSize);
+    // ALOGD("Creating track with %d buffers @ %d bytes", bufferCount, bufferSize);
    size_t size = sizeof(audio_track_cblk_t);
    uint8_t channelCount = popcount(channelMask);
    size_t bufferSize = frameCount*channelCount*sizeof(int16_t);
@@ -3232,13 +3237,13 @@
                 mBufferEnd = (uint8_t *)mBuffer + bufferSize;
             }
         } else {
-            LOGE("not enough memory for AudioTrack size=%u", size);
+            ALOGE("not enough memory for AudioTrack size=%u", size);
             client->heap()->dump("AudioTrack");
             return;
         }
    } else {
        mCblk = (audio_track_cblk_t *)(new uint8_t[size]);
-       if (mCblk) { // construct the shared structure in-place.
+           // construct the shared structure in-place.
            new(mCblk) audio_track_cblk_t();
            // clear all buffers
            mCblk->frameCount = frameCount;
@@ -3251,7 +3256,6 @@
            // written to buffer (other flags are cleared)
            mCblk->flags = CBLK_UNDERRUN_ON;
            mBufferEnd = (uint8_t *)mBuffer + bufferSize;
-       }
    }
 }
 
@@ -3272,7 +3276,7 @@
 
 void AudioFlinger::ThreadBase::TrackBase::releaseBuffer(AudioBufferProvider::Buffer* buffer)
 {
-    buffer->raw = 0;
+    buffer->raw = NULL;
     mFrameCount = buffer->frameCount;
     step();
     buffer->frameCount = 0;
@@ -3284,7 +3288,7 @@
 
     result = cblk->stepServer(mFrameCount);
     if (!result) {
-        LOGV("stepServer failed acquiring cblk mutex");
+        ALOGV("stepServer failed acquiring cblk mutex");
         mFlags |= STEPSERVER_FAILED;
     }
     return result;
@@ -3298,7 +3302,7 @@
     cblk->userBase = 0;
     cblk->serverBase = 0;
     mFlags &= (uint32_t)(~SYSTEM_FLAGS_MASK);
-    LOGV("TrackBase::reset");
+    ALOGV("TrackBase::reset");
 }
 
 sp<IMemory> AudioFlinger::ThreadBase::TrackBase::getCblk() const
@@ -3326,7 +3330,7 @@
     // Check validity of returned pointer in case the track control block would have been corrupted.
     if (bufferStart < mBuffer || bufferStart > bufferEnd || bufferEnd > mBufferEnd ||
         ((unsigned long)bufferStart & (unsigned long)(cblk->frameSize - 1))) {
-        LOGE("TrackBase::getBuffer buffer out of range:\n    start: %p, end %p , mBuffer %p mBufferEnd %p\n    \
+        ALOGE("TrackBase::getBuffer buffer out of range:\n    start: %p, end %p , mBuffer %p mBufferEnd %p\n    \
                 server %d, serverBase %d, user %d, userBase %d",
                 bufferStart, bufferEnd, mBuffer, mBufferEnd,
                 cblk->server, cblk->serverBase, cblk->user, cblk->userBase);
@@ -3360,9 +3364,9 @@
             mName = playbackThread->getTrackName_l();
             mMainBuffer = playbackThread->mixBuffer();
         }
-        LOGV("Track constructor name %d, calling thread %d", mName, IPCThreadState::self()->getCallingPid());
+        ALOGV("Track constructor name %d, calling thread %d", mName, IPCThreadState::self()->getCallingPid());
         if (mName < 0) {
-            LOGE("no more track names available");
+            ALOGE("no more track names available");
         }
         mVolume[0] = 1.0f;
         mVolume[1] = 1.0f;
@@ -3375,7 +3379,7 @@
 
 AudioFlinger::PlaybackThread::Track::~Track()
 {
-    LOGV("PlaybackThread::Track destructor");
+    ALOGV("PlaybackThread::Track destructor");
     sp<ThreadBase> thread = mThread.promote();
     if (thread != 0) {
         Mutex::Autolock _l(thread->mLock);
@@ -3446,13 +3450,13 @@
      // Check if last stepServer failed, try to step now
      if (mFlags & TrackBase::STEPSERVER_FAILED) {
          if (!step())  goto getNextBuffer_exit;
-         LOGV("stepServer recovered");
+         ALOGV("stepServer recovered");
          mFlags &= ~TrackBase::STEPSERVER_FAILED;
      }
 
      framesReady = cblk->framesReady();
 
-     if (LIKELY(framesReady)) {
+     if (CC_LIKELY(framesReady)) {
         uint32_t s = cblk->server;
         uint32_t bufferEnd = cblk->serverBase + cblk->frameCount;
 
@@ -3465,16 +3469,16 @@
         }
 
          buffer->raw = getBuffer(s, framesReq);
-         if (buffer->raw == 0) goto getNextBuffer_exit;
+         if (buffer->raw == NULL) goto getNextBuffer_exit;
 
          buffer->frameCount = framesReq;
         return NO_ERROR;
      }
 
 getNextBuffer_exit:
-     buffer->raw = 0;
+     buffer->raw = NULL;
      buffer->frameCount = 0;
-     LOGV("getNextBuffer() no more data for track %d on thread %p", mName, mThread.unsafe_get());
+     ALOGV("getNextBuffer() no more data for track %d on thread %p", mName, mThread.unsafe_get());
      return NOT_ENOUGH_DATA;
 }
 
@@ -3493,7 +3497,7 @@
 status_t AudioFlinger::PlaybackThread::Track::start()
 {
     status_t status = NO_ERROR;
-    LOGV("start(%d), calling thread %d session %d",
+    ALOGV("start(%d), calling thread %d session %d",
             mName, IPCThreadState::self()->getCallingPid(), mSessionId);
     sp<ThreadBase> thread = mThread.promote();
     if (thread != 0) {
@@ -3503,10 +3507,10 @@
         // in both cases "unstop" the track
         if (mState == PAUSED) {
             mState = TrackBase::RESUMING;
-            LOGV("PAUSED => RESUMING (%d) on thread %p", mName, this);
+            ALOGV("PAUSED => RESUMING (%d) on thread %p", mName, this);
         } else {
             mState = TrackBase::ACTIVE;
-            LOGV("? => ACTIVE (%d) on thread %p", mName, this);
+            ALOGV("? => ACTIVE (%d) on thread %p", mName, this);
         }
 
         if (!isOutputTrack() && state != ACTIVE && state != RESUMING) {
@@ -3535,7 +3539,7 @@
 
 void AudioFlinger::PlaybackThread::Track::stop()
 {
-    LOGV("stop(%d), calling thread %d", mName, IPCThreadState::self()->getCallingPid());
+    ALOGV("stop(%d), calling thread %d", mName, IPCThreadState::self()->getCallingPid());
     sp<ThreadBase> thread = mThread.promote();
     if (thread != 0) {
         Mutex::Autolock _l(thread->mLock);
@@ -3547,7 +3551,7 @@
             if (playbackThread->mActiveTracks.indexOf(this) < 0) {
                 reset();
             }
-            LOGV("(> STOPPED) => STOPPED (%d) on thread %p", mName, playbackThread);
+            ALOGV("(> STOPPED) => STOPPED (%d) on thread %p", mName, playbackThread);
         }
         if (!isOutputTrack() && (state == ACTIVE || state == RESUMING)) {
             thread->mLock.unlock();
@@ -3564,13 +3568,13 @@
 
 void AudioFlinger::PlaybackThread::Track::pause()
 {
-    LOGV("pause(%d), calling thread %d", mName, IPCThreadState::self()->getCallingPid());
+    ALOGV("pause(%d), calling thread %d", mName, IPCThreadState::self()->getCallingPid());
     sp<ThreadBase> thread = mThread.promote();
     if (thread != 0) {
         Mutex::Autolock _l(thread->mLock);
         if (mState == ACTIVE || mState == RESUMING) {
             mState = PAUSING;
-            LOGV("ACTIVE/RESUMING => PAUSING (%d) on thread %p", mName, thread.get());
+            ALOGV("ACTIVE/RESUMING => PAUSING (%d) on thread %p", mName, thread.get());
             if (!isOutputTrack()) {
                 thread->mLock.unlock();
                 AudioSystem::stopOutput(thread->id(),
@@ -3587,7 +3591,7 @@
 
 void AudioFlinger::PlaybackThread::Track::flush()
 {
-    LOGV("flush(%d)", mName);
+    ALOGV("flush(%d)", mName);
     sp<ThreadBase> thread = mThread.promote();
     if (thread != 0) {
         Mutex::Autolock _l(thread->mLock);
@@ -3667,7 +3671,7 @@
         mOverflow(false)
 {
     if (mCblk != NULL) {
-       LOGV("RecordTrack constructor, size %d", (int)mBufferEnd - (int)mBuffer);
+       ALOGV("RecordTrack constructor, size %d", (int)mBufferEnd - (int)mBuffer);
        if (format == AUDIO_FORMAT_PCM_16_BIT) {
            mCblk->frameSize = mChannelCount * sizeof(int16_t);
        } else if (format == AUDIO_FORMAT_PCM_8_BIT) {
@@ -3695,13 +3699,13 @@
      // Check if last stepServer failed, try to step now
     if (mFlags & TrackBase::STEPSERVER_FAILED) {
         if (!step()) goto getNextBuffer_exit;
-        LOGV("stepServer recovered");
+        ALOGV("stepServer recovered");
         mFlags &= ~TrackBase::STEPSERVER_FAILED;
     }
 
     framesAvail = cblk->framesAvailable_l();
 
-    if (LIKELY(framesAvail)) {
+    if (CC_LIKELY(framesAvail)) {
         uint32_t s = cblk->server;
         uint32_t bufferEnd = cblk->serverBase + cblk->frameCount;
 
@@ -3713,14 +3717,14 @@
         }
 
         buffer->raw = getBuffer(s, framesReq);
-        if (buffer->raw == 0) goto getNextBuffer_exit;
+        if (buffer->raw == NULL) goto getNextBuffer_exit;
 
         buffer->frameCount = framesReq;
         return NO_ERROR;
     }
 
 getNextBuffer_exit:
-    buffer->raw = 0;
+    buffer->raw = NULL;
     buffer->frameCount = 0;
     return NOT_ENOUGH_DATA;
 }
@@ -3784,12 +3788,12 @@
         mCblk->volume[0] = mCblk->volume[1] = 0x1000;
         mOutBuffer.frameCount = 0;
         playbackThread->mTracks.add(this);
-        LOGV("OutputTrack constructor mCblk %p, mBuffer %p, mCblk->buffers %p, " \
+        ALOGV("OutputTrack constructor mCblk %p, mBuffer %p, mCblk->buffers %p, " \
                 "mCblk->frameCount %d, mCblk->sampleRate %d, mChannelMask 0x%08x mBufferEnd %p",
                 mCblk, mBuffer, mCblk->buffers,
                 mCblk->frameCount, mCblk->sampleRate, mChannelMask, mBufferEnd);
     } else {
-        LOGW("Error creating output track on thread %p", playbackThread);
+        ALOGW("Error creating output track on thread %p", playbackThread);
     }
 }
 
@@ -3844,7 +3848,7 @@
                     memset(pInBuffer->raw, 0, startFrames * channelCount * sizeof(int16_t));
                     mBufferQueue.add(pInBuffer);
                 } else {
-                    LOGW ("OutputTrack::write() %p no more buffers in queue", this);
+                    ALOGW ("OutputTrack::write() %p no more buffers in queue", this);
                 }
             }
         }
@@ -3866,7 +3870,7 @@
             mOutBuffer.frameCount = pInBuffer->frameCount;
             nsecs_t startTime = systemTime();
             if (obtainBuffer(&mOutBuffer, waitTimeLeftMs) == (status_t)AudioTrack::NO_MORE_BUFFERS) {
-                LOGV ("OutputTrack::write() %p thread %p no more output buffers", this, mThread.unsafe_get());
+                ALOGV ("OutputTrack::write() %p thread %p no more output buffers", this, mThread.unsafe_get());
                 outputBufferFull = true;
                 break;
             }
@@ -3891,7 +3895,7 @@
                 mBufferQueue.removeAt(0);
                 delete [] pInBuffer->mBuffer;
                 delete pInBuffer;
-                LOGV("OutputTrack::write() %p thread %p released overflow buffer %d", this, mThread.unsafe_get(), mBufferQueue.size());
+                ALOGV("OutputTrack::write() %p thread %p released overflow buffer %d", this, mThread.unsafe_get(), mBufferQueue.size());
             } else {
                 break;
             }
@@ -3909,9 +3913,9 @@
                 pInBuffer->i16 = pInBuffer->mBuffer;
                 memcpy(pInBuffer->raw, inBuffer.raw, inBuffer.frameCount * channelCount * sizeof(int16_t));
                 mBufferQueue.add(pInBuffer);
-                LOGV("OutputTrack::write() %p thread %p adding overflow buffer %d", this, mThread.unsafe_get(), mBufferQueue.size());
+                ALOGV("OutputTrack::write() %p thread %p adding overflow buffer %d", this, mThread.unsafe_get(), mBufferQueue.size());
             } else {
-                LOGW("OutputTrack::write() %p thread %p no more overflow buffers", mThread.unsafe_get(), this);
+                ALOGW("OutputTrack::write() %p thread %p no more overflow buffers", mThread.unsafe_get(), this);
             }
         }
     }
@@ -3943,7 +3947,7 @@
     audio_track_cblk_t* cblk = mCblk;
     uint32_t framesReq = buffer->frameCount;
 
-//    LOGV("OutputTrack::obtainBuffer user %d, server %d", cblk->user, cblk->server);
+//    ALOGV("OutputTrack::obtainBuffer user %d, server %d", cblk->user, cblk->server);
     buffer->frameCount  = 0;
 
     uint32_t framesAvail = cblk->framesAvailable();
@@ -3954,8 +3958,8 @@
         goto start_loop_here;
         while (framesAvail == 0) {
             active = mActive;
-            if (UNLIKELY(!active)) {
-                LOGV("Not active and NO_MORE_BUFFERS");
+            if (CC_UNLIKELY(!active)) {
+                ALOGV("Not active and NO_MORE_BUFFERS");
                 return AudioTrack::NO_MORE_BUFFERS;
             }
             result = cblk->cv.waitRelative(cblk->lock, milliseconds(waitTimeMs));
@@ -4197,12 +4201,12 @@
 }
 
 status_t AudioFlinger::RecordHandle::start() {
-    LOGV("RecordHandle::start()");
+    ALOGV("RecordHandle::start()");
     return mRecordTrack->start();
 }
 
 void AudioFlinger::RecordHandle::stop() {
-    LOGV("RecordHandle::stop()");
+    ALOGV("RecordHandle::stop()");
     mRecordTrack->stop();
 }
 
@@ -4225,7 +4229,7 @@
                                          int id,
                                          uint32_t device) :
     ThreadBase(audioFlinger, id, device),
-    mInput(input), mTrack(NULL), mResampler(0), mRsmpOutBuffer(0), mRsmpInBuffer(0)
+    mInput(input), mTrack(NULL), mResampler(NULL), mRsmpOutBuffer(NULL), mRsmpInBuffer(NULL)
 {
     mType = ThreadBase::RECORD;
 
@@ -4240,7 +4244,7 @@
 AudioFlinger::RecordThread::~RecordThread()
 {
     delete[] mRsmpInBuffer;
-    if (mResampler != 0) {
+    if (mResampler != NULL) {
         delete mResampler;
         delete[] mRsmpOutBuffer;
     }
@@ -4254,7 +4258,7 @@
 status_t AudioFlinger::RecordThread::readyToRun()
 {
     status_t status = initCheck();
-    LOGW_IF(status != NO_ERROR,"RecordThread %p could not initialize", this);
+    ALOGW_IF(status != NO_ERROR,"RecordThread %p could not initialize", this);
     return status;
 }
 
@@ -4285,10 +4289,10 @@
                 if (exitPending()) break;
 
                 releaseWakeLock_l();
-                LOGV("RecordThread: loop stopping");
+                ALOGV("RecordThread: loop stopping");
                 // go to sleep
                 mWaitWorkCV.wait(mLock);
-                LOGV("RecordThread: loop starting");
+                ALOGV("RecordThread: loop starting");
                 acquireWakeLock_l();
                 continue;
             }
@@ -4332,9 +4336,9 @@
             }
 
             buffer.frameCount = mFrameCount;
-            if (LIKELY(mActiveTrack->getNextBuffer(&buffer) == NO_ERROR)) {
+            if (CC_LIKELY(mActiveTrack->getNextBuffer(&buffer) == NO_ERROR)) {
                 size_t framesOut = buffer.frameCount;
-                if (mResampler == 0) {
+                if (mResampler == NULL) {
                     // no resampling
                     while (framesOut) {
                         size_t framesIn = mFrameCount - mRsmpInIndex;
@@ -4374,7 +4378,7 @@
                                 mRsmpInIndex = 0;
                             }
                             if (mBytesRead < 0) {
-                                LOGE("Error reading audio input");
+                                ALOGE("Error reading audio input");
                                 if (mActiveTrack->mState == TrackBase::ACTIVE) {
                                     // Force input into standby so that it tries to
                                     // recover at next read attempt
@@ -4399,7 +4403,7 @@
                     // ditherAndClamp() works as long as all buffers returned by mActiveTrack->getNextBuffer()
                     // are 32 bit aligned which should be always true.
                     if (mChannelCount == 2 && mReqChannelCount == 1) {
-                        AudioMixer::ditherAndClamp(mRsmpOutBuffer, mRsmpOutBuffer, framesOut);
+                        ditherAndClamp(mRsmpOutBuffer, mRsmpOutBuffer, framesOut);
                         // the resampler always outputs stereo samples: do post stereo to mono conversion
                         int16_t *src = (int16_t *)mRsmpOutBuffer;
                         int16_t *dst = buffer.i16;
@@ -4408,7 +4412,7 @@
                             src += 2;
                         }
                     } else {
-                        AudioMixer::ditherAndClamp((int32_t *)buffer.raw, mRsmpOutBuffer, framesOut);
+                        ditherAndClamp((int32_t *)buffer.raw, mRsmpOutBuffer, framesOut);
                     }
 
                 }
@@ -4419,8 +4423,8 @@
             else {
                 if (!mActiveTrack->setOverflow()) {
                     nsecs_t now = systemTime();
-                    if ((now - lastWarning) > kWarningThrottle) {
-                        LOGW("RecordThread: buffer overflow");
+                    if ((now - lastWarning) > kWarningThrottleNs) {
+                        ALOGW("RecordThread: buffer overflow");
                         lastWarning = now;
                     }
                 }
@@ -4444,7 +4448,7 @@
 
     releaseWakeLock();
 
-    LOGV("RecordThread %p exiting", this);
+    ALOGV("RecordThread %p exiting", this);
     return false;
 }
 
@@ -4464,7 +4468,7 @@
 
     lStatus = initCheck();
     if (lStatus != NO_ERROR) {
-        LOGE("Audio driver not initialized.");
+        ALOGE("Audio driver not initialized.");
         goto Exit;
     }
 
@@ -4497,11 +4501,11 @@
 
 status_t AudioFlinger::RecordThread::start(RecordThread::RecordTrack* recordTrack)
 {
-    LOGV("RecordThread::start");
+    ALOGV("RecordThread::start");
     sp <ThreadBase> strongMe = this;
     status_t status = NO_ERROR;
     {
-        AutoMutex lock(&mLock);
+        AutoMutex lock(mLock);
         if (mActiveTrack != 0) {
             if (recordTrack != mActiveTrack.get()) {
                 status = -EBUSY;
@@ -4527,7 +4531,7 @@
         }
         mActiveTrack->mState = TrackBase::RESUMING;
         // signal thread to start
-        LOGV("Signal record thread");
+        ALOGV("Signal record thread");
         mWaitWorkCV.signal();
         // do not wait for mStartStopCond if exiting
         if (mExiting) {
@@ -4537,11 +4541,11 @@
         }
         mStartStopCond.wait(mLock);
         if (mActiveTrack == 0) {
-            LOGV("Record failed to start");
+            ALOGV("Record failed to start");
             status = BAD_VALUE;
             goto startError;
         }
-        LOGV("Record started OK");
+        ALOGV("Record started OK");
         return status;
     }
 startError:
@@ -4550,10 +4554,10 @@
 }
 
 void AudioFlinger::RecordThread::stop(RecordThread::RecordTrack* recordTrack) {
-    LOGV("RecordThread::stop");
+    ALOGV("RecordThread::stop");
     sp <ThreadBase> strongMe = this;
     {
-        AutoMutex lock(&mLock);
+        AutoMutex lock(mLock);
         if (mActiveTrack != 0 && recordTrack == mActiveTrack.get()) {
             mActiveTrack->mState = TrackBase::PAUSING;
             // do not wait for mStartStopCond if exiting
@@ -4566,7 +4570,7 @@
                 mLock.unlock();
                 AudioSystem::stopInput(mId);
                 mLock.lock();
-                LOGV("Record stopped OK");
+                ALOGV("Record stopped OK");
             }
         }
     }
@@ -4592,7 +4596,7 @@
         result.append(buffer);
         snprintf(buffer, SIZE, "In size: %d\n", mInputBytes);
         result.append(buffer);
-        snprintf(buffer, SIZE, "Resampling: %d\n", (mResampler != 0));
+        snprintf(buffer, SIZE, "Resampling: %d\n", (mResampler != NULL));
         result.append(buffer);
         snprintf(buffer, SIZE, "Out channel count: %d\n", mReqChannelCount);
         result.append(buffer);
@@ -4620,14 +4624,14 @@
     if (framesReady == 0) {
         mBytesRead = mInput->stream->read(mInput->stream, mRsmpInBuffer, mInputBytes);
         if (mBytesRead < 0) {
-            LOGE("RecordThread::getNextBuffer() Error reading audio input");
+            ALOGE("RecordThread::getNextBuffer() Error reading audio input");
             if (mActiveTrack->mState == TrackBase::ACTIVE) {
                 // Force input into standby so that it tries to
                 // recover at next read attempt
                 mInput->stream->common.standby(&mInput->stream->common);
                 usleep(kRecordThreadSleepUs);
             }
-            buffer->raw = 0;
+            buffer->raw = NULL;
             buffer->frameCount = 0;
             return NOT_ENOUGH_DATA;
         }
@@ -4742,7 +4746,7 @@
         mParamCond.signal();
         // wait for condition with time out in case the thread calling ThreadBase::setParameters()
         // already timed out waiting for the status and will never signal the condition.
-        mWaitWorkCV.waitRelative(mLock, kSetParametersTimeout);
+        mWaitWorkCV.waitRelative(mLock, kSetParametersTimeoutNs);
     }
     return reconfig;
 }
@@ -4790,7 +4794,7 @@
     if (mRsmpInBuffer) delete mRsmpInBuffer;
     if (mRsmpOutBuffer) delete mRsmpOutBuffer;
     if (mResampler) delete mResampler;
-    mResampler = 0;
+    mResampler = NULL;
 
     mSampleRate = mInput->stream->common.get_sample_rate(&mInput->stream->common);
     mChannelMask = mInput->stream->common.get_channels(&mInput->stream->common);
@@ -4899,7 +4903,7 @@
     audio_stream_out_t *outStream;
     audio_hw_device_t *outHwDev;
 
-    LOGV("openOutput(), Device %x, SamplingRate %d, Format %d, Channels %x, flags %x",
+    ALOGV("openOutput(), Device %x, SamplingRate %d, Format %d, Channels %x, flags %x",
             pDevices ? *pDevices : 0,
             samplingRate,
             format,
@@ -4918,7 +4922,7 @@
 
     status = outHwDev->open_output_stream(outHwDev, *pDevices, (int *)&format,
                                           &channels, &samplingRate, &outStream);
-    LOGV("openOutput() openOutputStream returned output %p, SamplingRate %d, Format %d, Channels %x, status %d",
+    ALOGV("openOutput() openOutputStream returned output %p, SamplingRate %d, Format %d, Channels %x, status %d",
             outStream,
             samplingRate,
             format,
@@ -4934,10 +4938,10 @@
             (format != AUDIO_FORMAT_PCM_16_BIT) ||
             (channels != AUDIO_CHANNEL_OUT_STEREO)) {
             thread = new DirectOutputThread(this, output, id, *pDevices);
-            LOGV("openOutput() created direct output: ID %d thread %p", id, thread);
+            ALOGV("openOutput() created direct output: ID %d thread %p", id, thread);
         } else {
             thread = new MixerThread(this, output, id, *pDevices);
-            LOGV("openOutput() created mixer output: ID %d thread %p", id, thread);
+            ALOGV("openOutput() created mixer output: ID %d thread %p", id, thread);
         }
         mPlaybackThreads.add(id, thread);
 
@@ -4961,7 +4965,7 @@
     MixerThread *thread2 = checkMixerThread_l(output2);
 
     if (thread1 == NULL || thread2 == NULL) {
-        LOGW("openDuplicateOutput() wrong output mixer type for output %d or %d", output1, output2);
+        ALOGW("openDuplicateOutput() wrong output mixer type for output %d or %d", output1, output2);
         return 0;
     }
 
@@ -4986,7 +4990,7 @@
             return BAD_VALUE;
         }
 
-        LOGV("closeOutput() %d", output);
+        ALOGV("closeOutput() %d", output);
 
         if (thread->type() == ThreadBase::MIXER) {
             for (size_t i = 0; i < mPlaybackThreads.size(); i++) {
@@ -5020,7 +5024,7 @@
         return BAD_VALUE;
     }
 
-    LOGV("suspendOutput() %d", output);
+    ALOGV("suspendOutput() %d", output);
     thread->suspend();
 
     return NO_ERROR;
@@ -5035,7 +5039,7 @@
         return BAD_VALUE;
     }
 
-    LOGV("restoreOutput() %d", output);
+    ALOGV("restoreOutput() %d", output);
 
     thread->restore();
 
@@ -5073,7 +5077,7 @@
                                         &channels, &samplingRate,
                                         (audio_in_acoustics_t)acoustics,
                                         &inStream);
-    LOGV("openInput() openInputStream returned input %p, SamplingRate %d, Format %d, Channels %x, acoustics %x, status %d",
+    ALOGV("openInput() openInputStream returned input %p, SamplingRate %d, Format %d, Channels %x, acoustics %x, status %d",
             inStream,
             samplingRate,
             format,
@@ -5088,7 +5092,7 @@
         reqFormat == format && format == AUDIO_FORMAT_PCM_16_BIT &&
         (samplingRate <= 2 * reqSamplingRate) &&
         (popcount(channels) < 3) && (popcount(reqChannels) < 3)) {
-        LOGV("openInput() reopening with proposed sampling rate and channels");
+        ALOGV("openInput() reopening with proposed sampling rate and channels");
         status = inHwDev->open_input_stream(inHwDev, *pDevices, (int *)&format,
                                             &channels, &samplingRate,
                                             (audio_in_acoustics_t)acoustics,
@@ -5110,7 +5114,7 @@
                                   id,
                                   device);
         mRecordThreads.add(id, thread);
-        LOGV("openInput() created record thread: ID %d thread %p", id, thread);
+        ALOGV("openInput() created record thread: ID %d thread %p", id, thread);
         if (pSamplingRate) *pSamplingRate = reqSamplingRate;
         if (pFormat) *pFormat = format;
         if (pChannels) *pChannels = reqChannels;
@@ -5137,7 +5141,7 @@
             return BAD_VALUE;
         }
 
-        LOGV("closeInput() %d", input);
+        ALOGV("closeInput() %d", input);
         void *param2 = 0;
         audioConfigChanged_l(AudioSystem::INPUT_CLOSED, input, param2);
         mRecordThreads.removeItem(input);
@@ -5157,11 +5161,11 @@
     Mutex::Autolock _l(mLock);
     MixerThread *dstThread = checkMixerThread_l(output);
     if (dstThread == NULL) {
-        LOGW("setStreamOutput() bad output id %d", output);
+        ALOGW("setStreamOutput() bad output id %d", output);
         return BAD_VALUE;
     }
 
-    LOGV("setStreamOutput() stream %d to output %d", stream, output);
+    ALOGV("setStreamOutput() stream %d to output %d", stream, output);
     audioConfigChanged_l(AudioSystem::STREAM_CONFIG_CHANGED, output, &stream);
 
     dstThread->setStreamValid(stream, true);
@@ -5189,13 +5193,13 @@
 {
     Mutex::Autolock _l(mLock);
     int caller = IPCThreadState::self()->getCallingPid();
-    LOGV("acquiring %d from %d", audioSession, caller);
+    ALOGV("acquiring %d from %d", audioSession, caller);
     int num = mAudioSessionRefs.size();
     for (int i = 0; i< num; i++) {
         AudioSessionRef *ref = mAudioSessionRefs.editItemAt(i);
         if (ref->sessionid == audioSession && ref->pid == caller) {
             ref->cnt++;
-            LOGV(" incremented refcount to %d", ref->cnt);
+            ALOGV(" incremented refcount to %d", ref->cnt);
             return;
         }
     }
@@ -5204,20 +5208,20 @@
     ref->pid = caller;
     ref->cnt = 1;
     mAudioSessionRefs.push(ref);
-    LOGV(" added new entry for %d", ref->sessionid);
+    ALOGV(" added new entry for %d", ref->sessionid);
 }
 
 void AudioFlinger::releaseAudioSessionId(int audioSession)
 {
     Mutex::Autolock _l(mLock);
     int caller = IPCThreadState::self()->getCallingPid();
-    LOGV("releasing %d from %d", audioSession, caller);
+    ALOGV("releasing %d from %d", audioSession, caller);
     int num = mAudioSessionRefs.size();
     for (int i = 0; i< num; i++) {
         AudioSessionRef *ref = mAudioSessionRefs.itemAt(i);
         if (ref->sessionid == audioSession && ref->pid == caller) {
             ref->cnt--;
-            LOGV(" decremented refcount to %d", ref->cnt);
+            ALOGV(" decremented refcount to %d", ref->cnt);
             if (ref->cnt == 0) {
                 mAudioSessionRefs.removeAt(i);
                 delete ref;
@@ -5226,12 +5230,12 @@
             return;
         }
     }
-    LOGW("session id %d not found for pid %d", audioSession, caller);
+    ALOGW("session id %d not found for pid %d", audioSession, caller);
 }
 
 void AudioFlinger::purgeStaleEffects_l() {
 
-    LOGV("purging stale effects");
+    ALOGV("purging stale effects");
 
     Vector< sp<EffectChain> > chains;
 
@@ -5264,7 +5268,7 @@
         for (size_t k = 0; k < numsessionrefs; k++) {
             AudioSessionRef *ref = mAudioSessionRefs.itemAt(k);
             if (ref->sessionid == sessionid) {
-                LOGV(" session %d still exists for %d with %d refs",
+                ALOGV(" session %d still exists for %d with %d refs",
                      sessionid, ref->pid, ref->cnt);
                 found = true;
                 break;
@@ -5394,7 +5398,7 @@
     sp<Client> client;
     wp<Client> wclient;
 
-    LOGV("createEffect pid %d, client %p, priority %d, sessionId %d, io %d",
+    ALOGV("createEffect pid %d, client %p, priority %d, sessionId %d, io %d",
             pid, effectClient.get(), priority, sessionId, io);
 
     if (pDesc == NULL) {
@@ -5437,14 +5441,14 @@
             // if uuid is specified, request effect descriptor
             lStatus = EffectGetDescriptor(&pDesc->uuid, &desc);
             if (lStatus < 0) {
-                LOGW("createEffect() error %d from EffectGetDescriptor", lStatus);
+                ALOGW("createEffect() error %d from EffectGetDescriptor", lStatus);
                 goto Exit;
             }
         } else {
             // if uuid is not specified, look for an available implementation
             // of the required type in effect factory
             if (EffectIsNullUuid(&pDesc->type)) {
-                LOGW("createEffect() no effect type");
+                ALOGW("createEffect() no effect type");
                 lStatus = BAD_VALUE;
                 goto Exit;
             }
@@ -5455,13 +5459,13 @@
 
             lStatus = EffectQueryNumberEffects(&numEffects);
             if (lStatus < 0) {
-                LOGW("createEffect() error %d from EffectQueryNumberEffects", lStatus);
+                ALOGW("createEffect() error %d from EffectQueryNumberEffects", lStatus);
                 goto Exit;
             }
             for (uint32_t i = 0; i < numEffects; i++) {
                 lStatus = EffectQueryEffect(i, &desc);
                 if (lStatus < 0) {
-                    LOGW("createEffect() error %d from EffectQueryEffect", lStatus);
+                    ALOGW("createEffect() error %d from EffectQueryEffect", lStatus);
                     continue;
                 }
                 if (memcmp(&desc.type, &pDesc->type, sizeof(effect_uuid_t)) == 0) {
@@ -5478,7 +5482,7 @@
             }
             if (!found) {
                 lStatus = BAD_VALUE;
-                LOGW("createEffect() effect not found");
+                ALOGW("createEffect() effect not found");
                 goto Exit;
             }
             // For same effect type, chose auxiliary version over insert version if
@@ -5533,13 +5537,13 @@
             if (io == 0 && mPlaybackThreads.size()) {
                 io = mPlaybackThreads.keyAt(0);
             }
-            LOGV("createEffect() got io %d for effect %s", io, desc.name);
+            ALOGV("createEffect() got io %d for effect %s", io, desc.name);
         }
         ThreadBase *thread = checkRecordThread_l(io);
         if (thread == NULL) {
             thread = checkPlaybackThread_l(io);
             if (thread == NULL) {
-                LOGE("createEffect() unknown output thread");
+                ALOGE("createEffect() unknown output thread");
                 lStatus = BAD_VALUE;
                 goto Exit;
             }
@@ -5571,21 +5575,21 @@
 
 status_t AudioFlinger::moveEffects(int sessionId, int srcOutput, int dstOutput)
 {
-    LOGV("moveEffects() session %d, srcOutput %d, dstOutput %d",
+    ALOGV("moveEffects() session %d, srcOutput %d, dstOutput %d",
             sessionId, srcOutput, dstOutput);
     Mutex::Autolock _l(mLock);
     if (srcOutput == dstOutput) {
-        LOGW("moveEffects() same dst and src outputs %d", dstOutput);
+        ALOGW("moveEffects() same dst and src outputs %d", dstOutput);
         return NO_ERROR;
     }
     PlaybackThread *srcThread = checkPlaybackThread_l(srcOutput);
     if (srcThread == NULL) {
-        LOGW("moveEffects() bad srcOutput %d", srcOutput);
+        ALOGW("moveEffects() bad srcOutput %d", srcOutput);
         return BAD_VALUE;
     }
     PlaybackThread *dstThread = checkPlaybackThread_l(dstOutput);
     if (dstThread == NULL) {
-        LOGW("moveEffects() bad dstOutput %d", dstOutput);
+        ALOGW("moveEffects() bad dstOutput %d", dstOutput);
         return BAD_VALUE;
     }
 
@@ -5602,12 +5606,12 @@
                                    AudioFlinger::PlaybackThread *dstThread,
                                    bool reRegister)
 {
-    LOGV("moveEffectChain_l() session %d from thread %p to thread %p",
+    ALOGV("moveEffectChain_l() session %d from thread %p to thread %p",
             sessionId, srcThread, dstThread);
 
     sp<EffectChain> chain = srcThread->getEffectChain_l(sessionId);
     if (chain == 0) {
-        LOGW("moveEffectChain_l() effect chain for session %d not on source thread %p",
+        ALOGW("moveEffectChain_l() effect chain for session %d not on source thread %p",
                 sessionId, srcThread);
         return INVALID_OPERATION;
     }
@@ -5637,7 +5641,7 @@
         if (dstChain == 0) {
             dstChain = effect->chain().promote();
             if (dstChain == 0) {
-                LOGW("moveEffectChain_l() cannot get chain from effect %p", effect.get());
+                ALOGW("moveEffectChain_l() cannot get chain from effect %p", effect.get());
                 srcThread->addEffect_l(effect);
                 return NO_INIT;
             }
@@ -5679,14 +5683,14 @@
 
     lStatus = initCheck();
     if (lStatus != NO_ERROR) {
-        LOGW("createEffect_l() Audio driver not initialized.");
+        ALOGW("createEffect_l() Audio driver not initialized.");
         goto Exit;
     }
 
     // Do not allow effects with session ID 0 on direct output or duplicating threads
     // TODO: add rule for hw accelerated effects on direct outputs with non PCM format
     if (sessionId == AUDIO_SESSION_OUTPUT_MIX && mType != MIXER) {
-        LOGW("createEffect_l() Cannot add auxiliary effect %s to session %d",
+        ALOGW("createEffect_l() Cannot add auxiliary effect %s to session %d",
                 desc->name, sessionId);
         lStatus = BAD_VALUE;
         goto Exit;
@@ -5696,13 +5700,13 @@
             (desc->flags & EFFECT_FLAG_TYPE_MASK) != EFFECT_FLAG_TYPE_PRE_PROC) ||
             (mType != RECORD &&
                     (desc->flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_PRE_PROC)) {
-        LOGW("createEffect_l() effect %s (flags %08x) created on wrong thread type %d",
+        ALOGW("createEffect_l() effect %s (flags %08x) created on wrong thread type %d",
                 desc->name, desc->flags, mType);
         lStatus = BAD_VALUE;
         goto Exit;
     }
 
-    LOGV("createEffect_l() thread %p effect %s on session %d", this, desc->name, sessionId);
+    ALOGV("createEffect_l() thread %p effect %s on session %d", this, desc->name, sessionId);
 
     { // scope for mLock
         Mutex::Autolock _l(mLock);
@@ -5711,7 +5715,7 @@
         chain = getEffectChain_l(sessionId);
         if (chain == 0) {
             // create a new chain for this session
-            LOGV("createEffect_l() new effect chain for session %d", sessionId);
+            ALOGV("createEffect_l() new effect chain for session %d", sessionId);
             chain = new EffectChain(this, sessionId);
             addEffectChain_l(chain);
             chain->setStrategy(getStrategyForSession_l(sessionId));
@@ -5720,7 +5724,7 @@
             effect = chain->getEffectFromDesc_l(desc);
         }
 
-        LOGV("createEffect_l() got effect %p on chain %p", effect == 0 ? 0 : effect.get(), chain.get());
+        ALOGV("createEffect_l() got effect %p on chain %p", effect == 0 ? 0 : effect.get(), chain.get());
 
         if (effect == 0) {
             int id = mAudioFlinger->nextUniqueId();
@@ -5796,16 +5800,16 @@
 
     if (chain == 0) {
         // create a new chain for this session
-        LOGV("addEffect_l() new effect chain for session %d", sessionId);
+        ALOGV("addEffect_l() new effect chain for session %d", sessionId);
         chain = new EffectChain(this, sessionId);
         addEffectChain_l(chain);
         chain->setStrategy(getStrategyForSession_l(sessionId));
         chainCreated = true;
     }
-    LOGV("addEffect_l() %p chain %p effect %p", this, chain.get(), effect.get());
+    ALOGV("addEffect_l() %p chain %p effect %p", this, chain.get(), effect.get());
 
     if (chain->getEffectFromId_l(effect->id()) != 0) {
-        LOGW("addEffect_l() %p effect %s already present in chain %p",
+        ALOGW("addEffect_l() %p effect %s already present in chain %p",
                 this, effect->desc().name, chain.get());
         return BAD_VALUE;
     }
@@ -5825,7 +5829,7 @@
 
 void AudioFlinger::ThreadBase::removeEffect_l(const sp<EffectModule>& effect) {
 
-    LOGV("removeEffect_l() %p effect %p", this, effect.get());
+    ALOGV("removeEffect_l() %p effect %p", this, effect.get());
     effect_descriptor_t desc = effect->desc();
     if ((desc.flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_AUXILIARY) {
         detachAuxEffect_l(effect->id());
@@ -5838,7 +5842,7 @@
             removeEffectChain_l(chain);
         }
     } else {
-        LOGW("removeEffect_l() %p cannot promote chain for effect %p", this, effect.get());
+        ALOGW("removeEffect_l() %p cannot promote chain for effect %p", this, effect.get());
     }
 }
 
@@ -5893,7 +5897,7 @@
                                                     bool unpiniflast) {
 
     Mutex::Autolock _l(mLock);
-    LOGV("disconnectEffect() %p effect %p", this, effect.get());
+    ALOGV("disconnectEffect() %p effect %p", this, effect.get());
     // delete the effect module if removing last handle on it
     if (effect->removeHandle(handle) == 0) {
         if (!effect->isPinned() || unpiniflast) {
@@ -5909,7 +5913,7 @@
     int16_t *buffer = mMixBuffer;
     bool ownsBuffer = false;
 
-    LOGV("addEffectChain_l() %p on thread %p for session %d", chain.get(), this, session);
+    ALOGV("addEffectChain_l() %p on thread %p for session %d", chain.get(), this, session);
     if (session > 0) {
         // Only one effect chain can be present in direct output thread and it uses
         // the mix buffer as input
@@ -5917,7 +5921,7 @@
             size_t numSamples = mFrameCount * mChannelCount;
             buffer = new int16_t[numSamples];
             memset(buffer, 0, numSamples * sizeof(int16_t));
-            LOGV("addEffectChain_l() creating new input buffer %p session %d", buffer, session);
+            ALOGV("addEffectChain_l() creating new input buffer %p session %d", buffer, session);
             ownsBuffer = true;
         }
 
@@ -5925,7 +5929,7 @@
         for (size_t i = 0; i < mTracks.size(); ++i) {
             sp<Track> track = mTracks[i];
             if (session == track->sessionId()) {
-                LOGV("addEffectChain_l() track->setMainBuffer track %p buffer %p", track.get(), buffer);
+                ALOGV("addEffectChain_l() track->setMainBuffer track %p buffer %p", track.get(), buffer);
                 track->setMainBuffer(buffer);
                 chain->incTrackCnt();
             }
@@ -5936,7 +5940,7 @@
             sp<Track> track = mActiveTracks[i].promote();
             if (track == 0) continue;
             if (session == track->sessionId()) {
-                LOGV("addEffectChain_l() activating track %p on session %d", track.get(), session);
+                ALOGV("addEffectChain_l() activating track %p on session %d", track.get(), session);
                 chain->incActiveTrackCnt();
             }
         }
@@ -5969,7 +5973,7 @@
 {
     int session = chain->sessionId();
 
-    LOGV("removeEffectChain_l() %p from thread %p for session %d", chain.get(), this, session);
+    ALOGV("removeEffectChain_l() %p from thread %p for session %d", chain.get(), this, session);
 
     for (size_t i = 0; i < mEffectChains.size(); i++) {
         if (chain == mEffectChains[i]) {
@@ -5979,7 +5983,7 @@
                 sp<Track> track = mActiveTracks[i].promote();
                 if (track == 0) continue;
                 if (session == track->sessionId()) {
-                    LOGV("removeEffectChain_l(): stopping track on chain %p for session Id: %d",
+                    ALOGV("removeEffectChain_l(): stopping track on chain %p for session Id: %d",
                             chain.get(), session);
                     chain->decActiveTrackCnt();
                 }
@@ -6045,7 +6049,7 @@
     if (mEffectChains.size() != 0) {
         return INVALID_OPERATION;
     }
-    LOGV("addEffectChain_l() %p on thread %p", chain.get(), this);
+    ALOGV("addEffectChain_l() %p on thread %p", chain.get(), this);
 
     chain->setInBuffer(NULL);
     chain->setOutBuffer(NULL);
@@ -6059,8 +6063,8 @@
 
 size_t AudioFlinger::RecordThread::removeEffectChain_l(const sp<EffectChain>& chain)
 {
-    LOGV("removeEffectChain_l() %p from thread %p", chain.get(), this);
-    LOGW_IF(mEffectChains.size() != 1,
+    ALOGV("removeEffectChain_l() %p from thread %p", chain.get(), this);
+    ALOGW_IF(mEffectChains.size() != 1,
             "removeEffectChain_l() %p invalid chain size %d on thread %p",
             chain.get(), mEffectChains.size(), this);
     if (mEffectChains.size() == 1) {
@@ -6084,7 +6088,7 @@
     : mThread(wThread), mChain(chain), mId(id), mSessionId(sessionId), mEffectInterface(NULL),
       mStatus(NO_INIT), mState(IDLE), mSuspended(false)
 {
-    LOGV("Constructor %p", this);
+    ALOGV("Constructor %p", this);
     int lStatus;
     sp<ThreadBase> thread = mThread.promote();
     if (thread == 0) {
@@ -6108,17 +6112,17 @@
     if (mSessionId > AUDIO_SESSION_OUTPUT_MIX) {
         mPinned = true;
     }
-    LOGV("Constructor success name %s, Interface %p", mDescriptor.name, mEffectInterface);
+    ALOGV("Constructor success name %s, Interface %p", mDescriptor.name, mEffectInterface);
     return;
 Error:
     EffectRelease(mEffectInterface);
     mEffectInterface = NULL;
-    LOGV("Constructor Error %d", mStatus);
+    ALOGV("Constructor Error %d", mStatus);
 }
 
 AudioFlinger::EffectModule::~EffectModule()
 {
-    LOGV("Destructor %p", this);
+    ALOGV("Destructor %p", this);
     if (mEffectInterface != NULL) {
         if ((mDescriptor.flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_PRE_PROC ||
                 (mDescriptor.flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_POST_PROC) {
@@ -6162,7 +6166,7 @@
     } else {
         status = ALREADY_EXISTS;
     }
-    LOGV("addHandle() %p added handle %p in position %d", this, handle.get(), i);
+    ALOGV("addHandle() %p added handle %p in position %d", this, handle.get(), i);
     mHandles.insertAt(handle, i);
     return status;
 }
@@ -6178,12 +6182,12 @@
     if (i == size) {
         return size;
     }
-    LOGV("removeHandle() %p removed handle %p in position %d", this, handle.unsafe_get(), i);
+    ALOGV("removeHandle() %p removed handle %p in position %d", this, handle.unsafe_get(), i);
 
     bool enabled = false;
     EffectHandle *hdl = handle.unsafe_get();
     if (hdl) {
-        LOGV("removeHandle() unsafe_get OK");
+        ALOGV("removeHandle() unsafe_get OK");
         enabled = hdl->enabled();
     }
     mHandles.removeAt(i);
@@ -6218,7 +6222,7 @@
 
 void AudioFlinger::EffectModule::disconnect(const wp<EffectHandle>& handle, bool unpiniflast)
 {
-    LOGV("disconnect() %p handle %p ", this, handle.unsafe_get());
+    ALOGV("disconnect() %p handle %p ", this, handle.unsafe_get());
     // keep a strong reference on this EffectModule to avoid calling the
     // destructor before we exit
     sp<EffectModule> keep(this);
@@ -6279,7 +6283,7 @@
     if (isProcessEnabled()) {
         // do 32 bit to 16 bit conversion for auxiliary effect input buffer
         if ((mDescriptor.flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_AUXILIARY) {
-            AudioMixer::ditherAndClamp(mConfig.inputCfg.buffer.s32,
+            ditherAndClamp(mConfig.inputCfg.buffer.s32,
                                         mConfig.inputCfg.buffer.s32,
                                         mConfig.inputCfg.buffer.frameCount/2);
         }
@@ -6378,13 +6382,13 @@
     mConfig.inputCfg.buffer.frameCount = thread->frameCount();
     mConfig.outputCfg.buffer.frameCount = mConfig.inputCfg.buffer.frameCount;
 
-    LOGV("configure() %p thread %p buffer %p framecount %d",
+    ALOGV("configure() %p thread %p buffer %p framecount %d",
             this, thread.get(), mConfig.inputCfg.buffer.raw, mConfig.inputCfg.buffer.frameCount);
 
     status_t cmdStatus;
     uint32_t size = sizeof(int);
     status_t status = (*mEffectInterface)->command(mEffectInterface,
-                                                   EFFECT_CMD_CONFIGURE,
+                                                   EFFECT_CMD_SET_CONFIG,
                                                    sizeof(effect_config_t),
                                                    &mConfig,
                                                    &size,
@@ -6498,7 +6502,7 @@
                                              void *pReplyData)
 {
     Mutex::Autolock _l(mLock);
-//    LOGV("command(), cmdCode: %d, mEffectInterface: %p", cmdCode, mEffectInterface);
+//    ALOGV("command(), cmdCode: %d, mEffectInterface: %p", cmdCode, mEffectInterface);
 
     if (mState == DESTROYED || mEffectInterface == NULL) {
         return NO_INIT;
@@ -6525,7 +6529,7 @@
 {
 
     Mutex::Autolock _l(mLock);
-    LOGV("setEnabled %p enabled %d", this, enabled);
+    ALOGV("setEnabled %p enabled %d", this, enabled);
 
     if (enabled != isEnabled()) {
         status_t status = AudioSystem::setEffectEnabled(mId, enabled);
@@ -6702,7 +6706,8 @@
     Mutex::Autolock _l(mLock);
     mSuspended = suspended;
 }
-bool AudioFlinger::EffectModule::suspended()
+
+bool AudioFlinger::EffectModule::suspended() const
 {
     Mutex::Autolock _l(mLock);
     return mSuspended;
@@ -6807,7 +6812,7 @@
     mEffect(effect), mEffectClient(effectClient), mClient(client), mCblk(NULL),
     mPriority(priority), mHasControl(false), mEnabled(false)
 {
-    LOGV("constructor %p", this);
+    ALOGV("constructor %p", this);
 
     if (client == 0) {
         return;
@@ -6822,21 +6827,21 @@
             mBuffer = (uint8_t *)mCblk + bufOffset;
          }
     } else {
-        LOGE("not enough memory for Effect size=%u", EFFECT_PARAM_BUFFER_SIZE + sizeof(effect_param_cblk_t));
+        ALOGE("not enough memory for Effect size=%u", EFFECT_PARAM_BUFFER_SIZE + sizeof(effect_param_cblk_t));
         return;
     }
 }
 
 AudioFlinger::EffectHandle::~EffectHandle()
 {
-    LOGV("Destructor %p", this);
+    ALOGV("Destructor %p", this);
     disconnect(false);
-    LOGV("Destructor DONE %p", this);
+    ALOGV("Destructor DONE %p", this);
 }
 
 status_t AudioFlinger::EffectHandle::enable()
 {
-    LOGV("enable %p", this);
+    ALOGV("enable %p", this);
     if (!mHasControl) return INVALID_OPERATION;
     if (mEffect == 0) return DEAD_OBJECT;
 
@@ -6868,7 +6873,7 @@
 
 status_t AudioFlinger::EffectHandle::disable()
 {
-    LOGV("disable %p", this);
+    ALOGV("disable %p", this);
     if (!mHasControl) return INVALID_OPERATION;
     if (mEffect == 0) return DEAD_OBJECT;
 
@@ -6898,7 +6903,7 @@
 
 void AudioFlinger::EffectHandle::disconnect(bool unpiniflast)
 {
-    LOGV("disconnect(%s)", unpiniflast ? "true" : "false");
+    ALOGV("disconnect(%s)", unpiniflast ? "true" : "false");
     if (mEffect == 0) {
         return;
     }
@@ -6929,7 +6934,7 @@
                                              uint32_t *replySize,
                                              void *pReplyData)
 {
-//    LOGV("command(), cmdCode: %d, mHasControl: %d, mEffect: %p",
+//    ALOGV("command(), cmdCode: %d, mHasControl: %d, mEffect: %p",
 //              cmdCode, mHasControl, (mEffect == 0) ? 0 : mEffect.get());
 
     // only get parameter command is permitted for applications not controlling the effect
@@ -6957,12 +6962,12 @@
             int *p = (int *)(mBuffer + mCblk->serverIndex);
             int size = *p++;
             if (((uint8_t *)p + size) > mBuffer + mCblk->clientIndex) {
-                LOGW("command(): invalid parameter block size");
+                ALOGW("command(): invalid parameter block size");
                 break;
             }
             effect_param_t *param = (effect_param_t *)p;
             if (param->psize == 0 || param->vsize == 0) {
-                LOGW("command(): null parameter or value size");
+                ALOGW("command(): null parameter or value size");
                 mCblk->serverIndex += size;
                 continue;
             }
@@ -7005,7 +7010,7 @@
 
 void AudioFlinger::EffectHandle::setControl(bool hasControl, bool signal, bool enabled)
 {
-    LOGV("setControl %p control %d", this, hasControl);
+    ALOGV("setControl %p control %d", this, hasControl);
 
     mHasControl = hasControl;
     mEnabled = enabled;
@@ -7138,7 +7143,7 @@
 {
     sp<ThreadBase> thread = mThread.promote();
     if (thread == 0) {
-        LOGW("process_l(): cannot promote mixer thread");
+        ALOGW("process_l(): cannot promote mixer thread");
         return;
     }
     bool isGlobalSession = (mSessionId == AUDIO_SESSION_OUTPUT_MIX) ||
@@ -7234,7 +7239,7 @@
                 // check invalid effect chaining combinations
                 if (insertPref == EFFECT_FLAG_INSERT_EXCLUSIVE ||
                     iPref == EFFECT_FLAG_INSERT_EXCLUSIVE) {
-                    LOGW("addEffect_l() could not insert effect %s: exclusive conflict with %s", desc.name, d.name);
+                    ALOGW("addEffect_l() could not insert effect %s: exclusive conflict with %s", desc.name, d.name);
                     return INVALID_OPERATION;
                 }
                 // remember position of first insert effect and by default
@@ -7285,7 +7290,7 @@
         }
         mEffects.insertAt(effect, idx_insert);
 
-        LOGV("addEffect_l() effect %p, added in chain %p at rank %d", effect.get(), this, idx_insert);
+        ALOGV("addEffect_l() effect %p, added in chain %p at rank %d", effect.get(), this, idx_insert);
     }
     effect->configure();
     return NO_ERROR;
@@ -7317,7 +7322,7 @@
                 }
             }
             mEffects.removeAt(i);
-            LOGV("removeEffect_l() effect %p, removed from chain %p at rank %d", effect.get(), this, i);
+            ALOGV("removeEffect_l() effect %p, removed from chain %p at rank %d", effect.get(), this, i);
             break;
         }
     }
@@ -7454,7 +7459,7 @@
             desc = new SuspendedEffectDesc();
             memcpy(&desc->mType, type, sizeof(effect_uuid_t));
             mSuspendedEffects.add(type->timeLow, desc);
-            LOGV("setEffectSuspended_l() add entry for %08x", type->timeLow);
+            ALOGV("setEffectSuspended_l() add entry for %08x", type->timeLow);
         }
         if (desc->mRefCount++ == 0) {
             sp<EffectModule> effect = getEffectIfEnabled(type);
@@ -7470,11 +7475,11 @@
         }
         desc = mSuspendedEffects.valueAt(index);
         if (desc->mRefCount <= 0) {
-            LOGW("setEffectSuspended_l() restore refcount should not be 0 %d", desc->mRefCount);
+            ALOGW("setEffectSuspended_l() restore refcount should not be 0 %d", desc->mRefCount);
             desc->mRefCount = 1;
         }
         if (--desc->mRefCount == 0) {
-            LOGV("setEffectSuspended_l() remove entry for %08x", mSuspendedEffects.keyAt(index));
+            ALOGV("setEffectSuspended_l() remove entry for %08x", mSuspendedEffects.keyAt(index));
             if (desc->mEffect != 0) {
                 sp<EffectModule> effect = desc->mEffect.promote();
                 if (effect != 0) {
@@ -7503,7 +7508,7 @@
         } else {
             desc = new SuspendedEffectDesc();
             mSuspendedEffects.add((int)kKeyForSuspendAll, desc);
-            LOGV("setEffectSuspendedAll_l() add entry for 0");
+            ALOGV("setEffectSuspendedAll_l() add entry for 0");
         }
         if (desc->mRefCount++ == 0) {
             Vector< sp<EffectModule> > effects = getSuspendEligibleEffects();
@@ -7517,7 +7522,7 @@
         }
         desc = mSuspendedEffects.valueAt(index);
         if (desc->mRefCount <= 0) {
-            LOGW("setEffectSuspendedAll_l() restore refcount should not be 0 %d", desc->mRefCount);
+            ALOGW("setEffectSuspendedAll_l() restore refcount should not be 0 %d", desc->mRefCount);
             desc->mRefCount = 1;
         }
         if (--desc->mRefCount == 0) {
@@ -7531,7 +7536,7 @@
             for (size_t i = 0; i < types.size(); i++) {
                 setEffectSuspended_l(types[i], false);
             }
-            LOGV("setEffectSuspendedAll_l() remove entry for %08x", mSuspendedEffects.keyAt(index));
+            ALOGV("setEffectSuspendedAll_l() remove entry for %08x", mSuspendedEffects.keyAt(index));
             mSuspendedEffects.removeItem((int)kKeyForSuspendAll);
         }
     }
@@ -7597,11 +7602,11 @@
             setEffectSuspended_l(&effect->desc().type, enabled);
             index = mSuspendedEffects.indexOfKey(effect->desc().type.timeLow);
             if (index < 0) {
-                LOGW("checkSuspendOnEffectEnabled() Fx should be suspended here!");
+                ALOGW("checkSuspendOnEffectEnabled() Fx should be suspended here!");
                 return;
             }
         }
-        LOGV("checkSuspendOnEffectEnabled() enable suspending fx %08x",
+        ALOGV("checkSuspendOnEffectEnabled() enable suspending fx %08x",
              effect->desc().type.timeLow);
         sp<SuspendedEffectDesc> desc = mSuspendedEffects.valueAt(index);
         // if effect is requested to suspended but was not yet enabled, supend it now.
@@ -7614,7 +7619,7 @@
         if (index < 0) {
             return;
         }
-        LOGV("checkSuspendOnEffectEnabled() disable restoring fx %08x",
+        ALOGV("checkSuspendOnEffectEnabled() disable restoring fx %08x",
              effect->desc().type.timeLow);
         sp<SuspendedEffectDesc> desc = mSuspendedEffects.valueAt(index);
         desc->mEffect.clear();
diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h
index 6cafa7e..f99e764 100644
--- a/services/audioflinger/AudioFlinger.h
+++ b/services/audioflinger/AudioFlinger.h
@@ -55,12 +55,6 @@
 
 // ----------------------------------------------------------------------------
 
-#define LIKELY( exp )       (__builtin_expect( (exp) != 0, true  ))
-#define UNLIKELY( exp )     (__builtin_expect( (exp) != 0, false ))
-
-
-// ----------------------------------------------------------------------------
-
 static const nsecs_t kStandbyTimeInNsecs = seconds(3);
 
 class AudioFlinger :
@@ -69,7 +63,7 @@
 {
     friend class BinderService<AudioFlinger>;
 public:
-    static char const* getServiceName() { return "media.audio_flinger"; }
+    static const char* getServiceName() { return "media.audio_flinger"; }
 
     virtual     status_t    dump(int fd, const Vector<String16>& args);
 
@@ -547,7 +541,7 @@
                     Condition               mParamCond;
                     Vector<String8>         mNewParameters;
                     status_t                mParamStatus;
-                    Vector<ConfigEvent *>   mConfigEvents;
+                    Vector<ConfigEvent>     mConfigEvents;
                     bool                    mStandby;
                     int                     mId;
                     bool                    mExiting;
@@ -703,7 +697,7 @@
         virtual     status_t    readyToRun();
         virtual     void        onFirstRef();
 
-        virtual     status_t    initCheck() const { return (mOutput == 0) ? NO_INIT : NO_ERROR; }
+        virtual     status_t    initCheck() const { return (mOutput == NULL) ? NO_INIT : NO_ERROR; }
 
         virtual     uint32_t    latency() const;
 
@@ -736,7 +730,7 @@
 
                     void        suspend() { mSuspended++; }
                     void        restore() { if (mSuspended) mSuspended--; }
-                    bool        isSuspended() { return (mSuspended != 0); }
+                    bool        isSuspended() const { return (mSuspended != 0); }
         virtual     String8     getParameters(const String8& keys);
         virtual     void        audioConfigChanged_l(int event, int param = 0);
         virtual     status_t    getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames);
@@ -980,7 +974,7 @@
         virtual status_t    readyToRun();
         virtual void        onFirstRef();
 
-        virtual status_t    initCheck() const { return (mInput == 0) ? NO_INIT : NO_ERROR; }
+        virtual status_t    initCheck() const { return (mInput == NULL) ? NO_INIT : NO_ERROR; }
                 sp<AudioFlinger::RecordThread::RecordTrack>  createRecordTrack_l(
                         const sp<AudioFlinger::Client>& client,
                         uint32_t sampleRate,
@@ -1121,7 +1115,7 @@
         status_t         start();
         status_t         stop();
         void             setSuspended(bool suspended);
-        bool             suspended();
+        bool             suspended() const;
 
         sp<EffectHandle> controlHandle();
 
@@ -1144,7 +1138,7 @@
         status_t start_l();
         status_t stop_l();
 
-        Mutex               mLock;      // mutex for process, commands and handles list protection
+mutable Mutex               mLock;      // mutex for process, commands and handles list protection
         wp<ThreadBase>      mThread;    // parent thread
         wp<EffectChain>     mChain;     // parent effect chain
         int                 mId;        // this instance unique ID
@@ -1389,7 +1383,7 @@
                 mutable     Mutex                   mHardwareLock;
                 audio_hw_device_t*                  mPrimaryHardwareDev;
                 Vector<audio_hw_device_t*>          mAudioHwDevs;
-    mutable     int                                 mHardwareStatus;
+    mutable     hardware_call_state                 mHardwareStatus;    // for dump only
 
 
                 DefaultKeyedVector< int, sp<PlaybackThread> >  mPlaybackThreads;
diff --git a/services/audioflinger/AudioMixer.cpp b/services/audioflinger/AudioMixer.cpp
index 1200f75..a8102e5 100644
--- a/services/audioflinger/AudioMixer.cpp
+++ b/services/audioflinger/AudioMixer.cpp
@@ -18,6 +18,7 @@
 #define LOG_TAG "AudioMixer"
 //#define LOG_NDEBUG 0
 
+#include <assert.h>
 #include <stdint.h>
 #include <string.h>
 #include <stdlib.h>
@@ -27,242 +28,229 @@
 #include <utils/Log.h>
 
 #include <cutils/bitops.h>
+#include <cutils/compiler.h>
 
 #include <system/audio.h>
 
+#include <audio_utils/primitives.h>
+
 #include "AudioMixer.h"
 
 namespace android {
-// ----------------------------------------------------------------------------
-
-static inline int16_t clamp16(int32_t sample)
-{
-    if ((sample>>15) ^ (sample>>31))
-        sample = 0x7FFF ^ (sample>>31);
-    return sample;
-}
 
 // ----------------------------------------------------------------------------
 
 AudioMixer::AudioMixer(size_t frameCount, uint32_t sampleRate)
-    :   mActiveTrack(0), mTrackNames(0), mSampleRate(sampleRate)
+    :   mTrackNames(0), mSampleRate(sampleRate)
 {
+    // AudioMixer is not yet capable of multi-channel beyond stereo
+    assert(2 == MAX_NUM_CHANNELS);
     mState.enabledTracks= 0;
     mState.needsChanged = 0;
     mState.frameCount   = frameCount;
-    mState.outputTemp   = 0;
-    mState.resampleTemp = 0;
+    mState.outputTemp   = NULL;
+    mState.resampleTemp = NULL;
     mState.hook         = process__nop;
     track_t* t = mState.tracks;
-    for (int i=0 ; i<32 ; i++) {
+    for (unsigned i=0 ; i < MAX_NUM_TRACKS ; i++) {
         t->needs = 0;
         t->volume[0] = UNITY_GAIN;
         t->volume[1] = UNITY_GAIN;
+        // no initialization needed
+        // t->prevVolume[0]
+        // t->prevVolume[1]
         t->volumeInc[0] = 0;
         t->volumeInc[1] = 0;
         t->auxLevel = 0;
         t->auxInc = 0;
+        // no initialization needed
+        // t->prevAuxLevel
+        // t->frameCount
         t->channelCount = 2;
         t->enabled = 0;
         t->format = 16;
         t->channelMask = AUDIO_CHANNEL_OUT_STEREO;
         t->buffer.raw = 0;
-        t->bufferProvider = 0;
-        t->hook = 0;
-        t->resampler = 0;
+        t->bufferProvider = NULL;
+        t->hook = NULL;
+        t->resampler = NULL;
         t->sampleRate = mSampleRate;
-        t->in = 0;
+        t->in = NULL;
         t->mainBuffer = NULL;
         t->auxBuffer = NULL;
         t++;
     }
 }
 
- AudioMixer::~AudioMixer()
- {
-     track_t* t = mState.tracks;
-     for (int i=0 ; i<32 ; i++) {
-         delete t->resampler;
-         t++;
-     }
-     delete [] mState.outputTemp;
-     delete [] mState.resampleTemp;
- }
-
- int AudioMixer::getTrackName()
- {
-    uint32_t names = mTrackNames;
-    uint32_t mask = 1;
-    int n = 0;
-    while (names & mask) {
-        mask <<= 1;
-        n++;
+AudioMixer::~AudioMixer()
+{
+    track_t* t = mState.tracks;
+    for (unsigned i=0 ; i < MAX_NUM_TRACKS ; i++) {
+        delete t->resampler;
+        t++;
     }
-    if (mask) {
-        LOGV("add track (%d)", n);
-        mTrackNames |= mask;
+    delete [] mState.outputTemp;
+    delete [] mState.resampleTemp;
+}
+
+int AudioMixer::getTrackName()
+{
+    uint32_t names = ~mTrackNames;
+    if (names != 0) {
+        int n = __builtin_ctz(names);
+        ALOGV("add track (%d)", n);
+        mTrackNames |= 1 << n;
         return TRACK0 + n;
     }
     return -1;
- }
+}
 
- void AudioMixer::invalidateState(uint32_t mask)
- {
+void AudioMixer::invalidateState(uint32_t mask)
+{
     if (mask) {
         mState.needsChanged |= mask;
         mState.hook = process__validate;
     }
  }
 
- void AudioMixer::deleteTrackName(int name)
- {
+void AudioMixer::deleteTrackName(int name)
+{
     name -= TRACK0;
-    if (uint32_t(name) < MAX_NUM_TRACKS) {
-        LOGV("deleteTrackName(%d)", name);
-        track_t& track(mState.tracks[ name ]);
-        if (track.enabled != 0) {
-            track.enabled = 0;
-            invalidateState(1<<name);
-        }
-        if (track.resampler) {
-            // delete  the resampler
-            delete track.resampler;
-            track.resampler = 0;
-            track.sampleRate = mSampleRate;
-            invalidateState(1<<name);
-        }
-        track.volumeInc[0] = 0;
-        track.volumeInc[1] = 0;
-        mTrackNames &= ~(1<<name);
+    assert(uint32_t(name) < MAX_NUM_TRACKS);
+    ALOGV("deleteTrackName(%d)", name);
+    track_t& track(mState.tracks[ name ]);
+    if (track.enabled != 0) {
+        track.enabled = 0;
+        invalidateState(1<<name);
     }
- }
-
-status_t AudioMixer::enable(int name)
-{
-    switch (name) {
-        case MIXING: {
-            if (mState.tracks[ mActiveTrack ].enabled != 1) {
-                mState.tracks[ mActiveTrack ].enabled = 1;
-                LOGV("enable(%d)", mActiveTrack);
-                invalidateState(1<<mActiveTrack);
-            }
-        } break;
-        default:
-            return NAME_NOT_FOUND;
+    if (track.resampler) {
+        // delete  the resampler
+        delete track.resampler;
+        track.resampler = NULL;
+        track.sampleRate = mSampleRate;
+        invalidateState(1<<name);
     }
-    return NO_ERROR;
+    track.volumeInc[0] = 0;
+    track.volumeInc[1] = 0;
+    mTrackNames &= ~(1<<name);
 }
 
-status_t AudioMixer::disable(int name)
+void AudioMixer::enable(int name)
 {
-    switch (name) {
-        case MIXING: {
-            if (mState.tracks[ mActiveTrack ].enabled != 0) {
-                mState.tracks[ mActiveTrack ].enabled = 0;
-                LOGV("disable(%d)", mActiveTrack);
-                invalidateState(1<<mActiveTrack);
-            }
-        } break;
-        default:
-            return NAME_NOT_FOUND;
+    name -= TRACK0;
+    assert(uint32_t(name) < MAX_NUM_TRACKS);
+    track_t& track = mState.tracks[name];
+
+    if (track.enabled != 1) {
+        track.enabled = 1;
+        ALOGV("enable(%d)", name);
+        invalidateState(1 << name);
     }
-    return NO_ERROR;
 }
 
-status_t AudioMixer::setActiveTrack(int track)
+void AudioMixer::disable(int name)
 {
-    if (uint32_t(track-TRACK0) >= MAX_NUM_TRACKS) {
-        return BAD_VALUE;
+    name -= TRACK0;
+    assert(uint32_t(name) < MAX_NUM_TRACKS);
+    track_t& track = mState.tracks[name];
+
+    if (track.enabled != 0) {
+        track.enabled = 0;
+        ALOGV("disable(%d)", name);
+        invalidateState(1 << name);
     }
-    mActiveTrack = track - TRACK0;
-    return NO_ERROR;
 }
 
-status_t AudioMixer::setParameter(int target, int name, void *value)
+void AudioMixer::setParameter(int name, int target, int param, void *value)
 {
+    name -= TRACK0;
+    assert(uint32_t(name) < MAX_NUM_TRACKS);
+    track_t& track = mState.tracks[name];
+
     int valueInt = (int)value;
     int32_t *valueBuf = (int32_t *)value;
 
     switch (target) {
-    case TRACK:
-        if (name == CHANNEL_MASK) {
-            uint32_t mask = (uint32_t)value;
-            if (mState.tracks[ mActiveTrack ].channelMask != mask) {
-                uint8_t channelCount = popcount(mask);
-                if ((channelCount <= MAX_NUM_CHANNELS) && (channelCount)) {
-                    mState.tracks[ mActiveTrack ].channelMask = mask;
-                    mState.tracks[ mActiveTrack ].channelCount = channelCount;
-                    LOGV("setParameter(TRACK, CHANNEL_MASK, %x)", mask);
-                    invalidateState(1<<mActiveTrack);
-                    return NO_ERROR;
-                }
-            } else {
-                return NO_ERROR;
-            }
-        }
-        if (name == MAIN_BUFFER) {
-            if (mState.tracks[ mActiveTrack ].mainBuffer != valueBuf) {
-                mState.tracks[ mActiveTrack ].mainBuffer = valueBuf;
-                LOGV("setParameter(TRACK, MAIN_BUFFER, %p)", valueBuf);
-                invalidateState(1<<mActiveTrack);
-            }
-            return NO_ERROR;
-        }
-        if (name == AUX_BUFFER) {
-            if (mState.tracks[ mActiveTrack ].auxBuffer != valueBuf) {
-                mState.tracks[ mActiveTrack ].auxBuffer = valueBuf;
-                LOGV("setParameter(TRACK, AUX_BUFFER, %p)", valueBuf);
-                invalidateState(1<<mActiveTrack);
-            }
-            return NO_ERROR;
-        }
 
-        break;
-    case RESAMPLE:
-        if (name == SAMPLE_RATE) {
-            if (valueInt > 0) {
-                track_t& track = mState.tracks[ mActiveTrack ];
-                if (track.setResampler(uint32_t(valueInt), mSampleRate)) {
-                    LOGV("setParameter(RESAMPLE, SAMPLE_RATE, %u)",
-                            uint32_t(valueInt));
-                    invalidateState(1<<mActiveTrack);
-                }
-                return NO_ERROR;
+    case TRACK:
+        switch (param) {
+        case CHANNEL_MASK: {
+            uint32_t mask = (uint32_t)value;
+            if (track.channelMask != mask) {
+                uint8_t channelCount = popcount(mask);
+                assert((channelCount <= MAX_NUM_CHANNELS) && (channelCount));
+                track.channelMask = mask;
+                track.channelCount = channelCount;
+                ALOGV("setParameter(TRACK, CHANNEL_MASK, %x)", mask);
+                invalidateState(1 << name);
             }
-        }
-        if (name == RESET) {
-            track_t& track = mState.tracks[ mActiveTrack ];
-            track.resetResampler();
-            invalidateState(1<<mActiveTrack);
-            return NO_ERROR;
+            } break;
+        case MAIN_BUFFER:
+            if (track.mainBuffer != valueBuf) {
+                track.mainBuffer = valueBuf;
+                ALOGV("setParameter(TRACK, MAIN_BUFFER, %p)", valueBuf);
+                invalidateState(1 << name);
+            }
+            break;
+        case AUX_BUFFER:
+            if (track.auxBuffer != valueBuf) {
+                track.auxBuffer = valueBuf;
+                ALOGV("setParameter(TRACK, AUX_BUFFER, %p)", valueBuf);
+                invalidateState(1 << name);
+            }
+            break;
+        default:
+            // bad param
+            assert(false);
         }
         break;
+
+    case RESAMPLE:
+        switch (param) {
+        case SAMPLE_RATE:
+            assert(valueInt > 0);
+            if (track.setResampler(uint32_t(valueInt), mSampleRate)) {
+                ALOGV("setParameter(RESAMPLE, SAMPLE_RATE, %u)",
+                        uint32_t(valueInt));
+                invalidateState(1 << name);
+            }
+            break;
+        case RESET:
+            track.resetResampler();
+            invalidateState(1 << name);
+            break;
+        default:
+            // bad param
+            assert(false);
+        }
+        break;
+
     case RAMP_VOLUME:
     case VOLUME:
-        if ((uint32_t(name-VOLUME0) < MAX_NUM_CHANNELS)) {
-            track_t& track = mState.tracks[ mActiveTrack ];
-            if (track.volume[name-VOLUME0] != valueInt) {
-                LOGV("setParameter(VOLUME, VOLUME0/1: %04x)", valueInt);
-                track.prevVolume[name-VOLUME0] = track.volume[name-VOLUME0] << 16;
-                track.volume[name-VOLUME0] = valueInt;
+        switch (param) {
+        case VOLUME0:
+        case VOLUME1:
+            if (track.volume[param-VOLUME0] != valueInt) {
+                ALOGV("setParameter(VOLUME, VOLUME0/1: %04x)", valueInt);
+                track.prevVolume[param-VOLUME0] = track.volume[param-VOLUME0] << 16;
+                track.volume[param-VOLUME0] = valueInt;
                 if (target == VOLUME) {
-                    track.prevVolume[name-VOLUME0] = valueInt << 16;
-                    track.volumeInc[name-VOLUME0] = 0;
+                    track.prevVolume[param-VOLUME0] = valueInt << 16;
+                    track.volumeInc[param-VOLUME0] = 0;
                 } else {
-                    int32_t d = (valueInt<<16) - track.prevVolume[name-VOLUME0];
+                    int32_t d = (valueInt<<16) - track.prevVolume[param-VOLUME0];
                     int32_t volInc = d / int32_t(mState.frameCount);
-                    track.volumeInc[name-VOLUME0] = volInc;
+                    track.volumeInc[param-VOLUME0] = volInc;
                     if (volInc == 0) {
-                        track.prevVolume[name-VOLUME0] = valueInt << 16;
+                        track.prevVolume[param-VOLUME0] = valueInt << 16;
                     }
                 }
-                invalidateState(1<<mActiveTrack);
+                invalidateState(1 << name);
             }
-            return NO_ERROR;
-        } else if (name == AUXLEVEL) {
-            track_t& track = mState.tracks[ mActiveTrack ];
+            break;
+        case AUXLEVEL:
             if (track.auxLevel != valueInt) {
-                LOGV("setParameter(VOLUME, AUXLEVEL: %04x)", valueInt);
+                ALOGV("setParameter(VOLUME, AUXLEVEL: %04x)", valueInt);
                 track.prevAuxLevel = track.auxLevel << 16;
                 track.auxLevel = valueInt;
                 if (target == VOLUME) {
@@ -276,13 +264,19 @@
                         track.prevAuxLevel = valueInt << 16;
                     }
                 }
-                invalidateState(1<<mActiveTrack);
+                invalidateState(1 << name);
             }
-            return NO_ERROR;
+            break;
+        default:
+            // bad param
+            assert(false);
         }
         break;
+
+    default:
+        // bad target
+        assert(false);
     }
-    return BAD_VALUE;
 }
 
 bool AudioMixer::track_t::setResampler(uint32_t value, uint32_t devSampleRate)
@@ -290,7 +284,7 @@
     if (value!=devSampleRate || resampler) {
         if (sampleRate != value) {
             sampleRate = value;
-            if (resampler == 0) {
+            if (resampler == NULL) {
                 resampler = AudioResampler::create(
                         format, channelCount, devSampleRate);
             }
@@ -302,12 +296,12 @@
 
 bool AudioMixer::track_t::doesResample() const
 {
-    return resampler != 0;
+    return resampler != NULL;
 }
 
 void AudioMixer::track_t::resetResampler()
 {
-    if (resampler != 0) {
+    if (resampler != NULL) {
         resampler->reset();
     }
 }
@@ -315,7 +309,7 @@
 inline
 void AudioMixer::track_t::adjustVolumeRamp(bool aux)
 {
-    for (int i=0 ; i<2 ; i++) {
+    for (uint32_t i=0 ; i<MAX_NUM_CHANNELS ; i++) {
         if (((volumeInc[i]>0) && (((prevVolume[i]+volumeInc[i])>>16) >= volume[i])) ||
             ((volumeInc[i]<0) && (((prevVolume[i]+volumeInc[i])>>16) <= volume[i]))) {
             volumeInc[i] = 0;
@@ -349,10 +343,11 @@
     return 0;
 }
 
-status_t AudioMixer::setBufferProvider(AudioBufferProvider* buffer)
+void AudioMixer::setBufferProvider(int name, AudioBufferProvider* buffer)
 {
-    mState.tracks[ mActiveTrack ].bufferProvider = buffer;
-    return NO_ERROR;
+    name -= TRACK0;
+    assert(uint32_t(name) < MAX_NUM_TRACKS);
+    mState.tracks[name].bufferProvider = buffer;
 }
 
 
@@ -365,7 +360,7 @@
 
 void AudioMixer::process__validate(state_t* state)
 {
-    LOGW_IF(!state->needsChanged,
+    ALOGW_IF(!state->needsChanged,
         "in process__validate() but nothing's invalid");
 
     uint32_t changed = state->needsChanged;
@@ -447,11 +442,11 @@
         } else {
             if (state->outputTemp) {
                 delete [] state->outputTemp;
-                state->outputTemp = 0;
+                state->outputTemp = NULL;
             }
             if (state->resampleTemp) {
                 delete [] state->resampleTemp;
-                state->resampleTemp = 0;
+                state->resampleTemp = NULL;
             }
             state->hook = process__genericNoResampling;
             if (all16BitsStereoNoResample && !volumeRamp) {
@@ -462,120 +457,38 @@
         }
     }
 
-    LOGV("mixer configuration change: %d activeTracks (%08x) "
+    ALOGV("mixer configuration change: %d activeTracks (%08x) "
         "all16BitsStereoNoResample=%d, resampling=%d, volumeRamp=%d",
         countActiveTracks, state->enabledTracks,
         all16BitsStereoNoResample, resampling, volumeRamp);
 
-   state->hook(state);
+    state->hook(state);
 
-   // Now that the volume ramp has been done, set optimal state and
-   // track hooks for subsequent mixer process
-   if (countActiveTracks) {
-       int allMuted = 1;
-       uint32_t en = state->enabledTracks;
-       while (en) {
-           const int i = 31 - __builtin_clz(en);
-           en &= ~(1<<i);
-           track_t& t = state->tracks[i];
-           if (!t.doesResample() && t.volumeRL == 0)
-           {
-               t.needs |= NEEDS_MUTE_ENABLED;
-               t.hook = track__nop;
-           } else {
-               allMuted = 0;
-           }
-       }
-       if (allMuted) {
-           state->hook = process__nop;
-       } else if (all16BitsStereoNoResample) {
-           if (countActiveTracks == 1) {
-              state->hook = process__OneTrack16BitsStereoNoResampling;
-           }
-       }
-   }
-}
-
-static inline
-int32_t mulAdd(int16_t in, int16_t v, int32_t a)
-{
-#if defined(__arm__) && !defined(__thumb__)
-    int32_t out;
-    asm( "smlabb %[out], %[in], %[v], %[a] \n"
-         : [out]"=r"(out)
-         : [in]"%r"(in), [v]"r"(v), [a]"r"(a)
-         : );
-    return out;
-#else
-    return a + in * int32_t(v);
-#endif
-}
-
-static inline
-int32_t mul(int16_t in, int16_t v)
-{
-#if defined(__arm__) && !defined(__thumb__)
-    int32_t out;
-    asm( "smulbb %[out], %[in], %[v] \n"
-         : [out]"=r"(out)
-         : [in]"%r"(in), [v]"r"(v)
-         : );
-    return out;
-#else
-    return in * int32_t(v);
-#endif
-}
-
-static inline
-int32_t mulAddRL(int left, uint32_t inRL, uint32_t vRL, int32_t a)
-{
-#if defined(__arm__) && !defined(__thumb__)
-    int32_t out;
-    if (left) {
-        asm( "smlabb %[out], %[inRL], %[vRL], %[a] \n"
-             : [out]"=r"(out)
-             : [inRL]"%r"(inRL), [vRL]"r"(vRL), [a]"r"(a)
-             : );
-    } else {
-        asm( "smlatt %[out], %[inRL], %[vRL], %[a] \n"
-             : [out]"=r"(out)
-             : [inRL]"%r"(inRL), [vRL]"r"(vRL), [a]"r"(a)
-             : );
+    // Now that the volume ramp has been done, set optimal state and
+    // track hooks for subsequent mixer process
+    if (countActiveTracks) {
+        int allMuted = 1;
+        uint32_t en = state->enabledTracks;
+        while (en) {
+            const int i = 31 - __builtin_clz(en);
+            en &= ~(1<<i);
+            track_t& t = state->tracks[i];
+            if (!t.doesResample() && t.volumeRL == 0)
+            {
+                t.needs |= NEEDS_MUTE_ENABLED;
+                t.hook = track__nop;
+            } else {
+                allMuted = 0;
+            }
+        }
+        if (allMuted) {
+            state->hook = process__nop;
+        } else if (all16BitsStereoNoResample) {
+            if (countActiveTracks == 1) {
+                state->hook = process__OneTrack16BitsStereoNoResampling;
+            }
+        }
     }
-    return out;
-#else
-    if (left) {
-        return a + int16_t(inRL&0xFFFF) * int16_t(vRL&0xFFFF);
-    } else {
-        return a + int16_t(inRL>>16) * int16_t(vRL>>16);
-    }
-#endif
-}
-
-static inline
-int32_t mulRL(int left, uint32_t inRL, uint32_t vRL)
-{
-#if defined(__arm__) && !defined(__thumb__)
-    int32_t out;
-    if (left) {
-        asm( "smulbb %[out], %[inRL], %[vRL] \n"
-             : [out]"=r"(out)
-             : [inRL]"%r"(inRL), [vRL]"r"(vRL)
-             : );
-    } else {
-        asm( "smultt %[out], %[inRL], %[vRL] \n"
-             : [out]"=r"(out)
-             : [inRL]"%r"(inRL), [vRL]"r"(vRL)
-             : );
-    }
-    return out;
-#else
-    if (left) {
-        return int16_t(inRL&0xFFFF) * int16_t(vRL&0xFFFF);
-    } else {
-        return int16_t(inRL>>16) * int16_t(vRL>>16);
-    }
-#endif
 }
 
 
@@ -591,13 +504,13 @@
         t->resampler->setVolume(UNITY_GAIN, UNITY_GAIN);
         memset(temp, 0, outFrameCount * MAX_NUM_CHANNELS * sizeof(int32_t));
         t->resampler->resample(temp, outFrameCount, t->bufferProvider);
-        if UNLIKELY(t->volumeInc[0]|t->volumeInc[1]|t->auxInc) {
+        if (CC_UNLIKELY(t->volumeInc[0]|t->volumeInc[1]|t->auxInc)) {
             volumeRampStereo(t, out, outFrameCount, temp, aux);
         } else {
             volumeStereo(t, out, outFrameCount, temp, aux);
         }
     } else {
-        if UNLIKELY(t->volumeInc[0]|t->volumeInc[1]) {
+        if (CC_UNLIKELY(t->volumeInc[0]|t->volumeInc[1])) {
             t->resampler->setVolume(UNITY_GAIN, UNITY_GAIN);
             memset(temp, 0, outFrameCount * MAX_NUM_CHANNELS * sizeof(int32_t));
             t->resampler->resample(temp, outFrameCount, t->bufferProvider);
@@ -623,12 +536,12 @@
     const int32_t vlInc = t->volumeInc[0];
     const int32_t vrInc = t->volumeInc[1];
 
-    //LOGD("[0] %p: inc=%f, v0=%f, v1=%d, final=%f, count=%d",
+    //ALOGD("[0] %p: inc=%f, v0=%f, v1=%d, final=%f, count=%d",
     //        t, vlInc/65536.0f, vl/65536.0f, t->volume[0],
     //       (vl + vlInc*frameCount)/65536.0f, frameCount);
 
     // ramp volume
-    if UNLIKELY(aux != NULL) {
+    if (CC_UNLIKELY(aux != NULL)) {
         int32_t va = t->prevAuxLevel;
         const int32_t vaInc = t->auxInc;
         int32_t l;
@@ -663,7 +576,7 @@
     const int16_t vl = t->volume[0];
     const int16_t vr = t->volume[1];
 
-    if UNLIKELY(aux != NULL) {
+    if (CC_UNLIKELY(aux != NULL)) {
         const int16_t va = (int16_t)t->auxLevel;
         do {
             int16_t l = (int16_t)(*temp++ >> 12);
@@ -688,20 +601,20 @@
 
 void AudioMixer::track__16BitsStereo(track_t* t, int32_t* out, size_t frameCount, int32_t* temp, int32_t* aux)
 {
-    int16_t const *in = static_cast<int16_t const *>(t->in);
+    const int16_t *in = static_cast<const int16_t *>(t->in);
 
-    if UNLIKELY(aux != NULL) {
+    if (CC_UNLIKELY(aux != NULL)) {
         int32_t l;
         int32_t r;
         // ramp gain
-        if UNLIKELY(t->volumeInc[0]|t->volumeInc[1]|t->auxInc) {
+        if (CC_UNLIKELY(t->volumeInc[0]|t->volumeInc[1]|t->auxInc)) {
             int32_t vl = t->prevVolume[0];
             int32_t vr = t->prevVolume[1];
             int32_t va = t->prevAuxLevel;
             const int32_t vlInc = t->volumeInc[0];
             const int32_t vrInc = t->volumeInc[1];
             const int32_t vaInc = t->auxInc;
-            // LOGD("[1] %p: inc=%f, v0=%f, v1=%d, final=%f, count=%d",
+            // ALOGD("[1] %p: inc=%f, v0=%f, v1=%d, final=%f, count=%d",
             //        t, vlInc/65536.0f, vl/65536.0f, t->volume[0],
             //        (vl + vlInc*frameCount)/65536.0f, frameCount);
 
@@ -727,7 +640,7 @@
             const uint32_t vrl = t->volumeRL;
             const int16_t va = (int16_t)t->auxLevel;
             do {
-                uint32_t rl = *reinterpret_cast<uint32_t const *>(in);
+                uint32_t rl = *reinterpret_cast<const uint32_t *>(in);
                 int16_t a = (int16_t)(((int32_t)in[0] + in[1]) >> 1);
                 in += 2;
                 out[0] = mulAddRL(1, rl, vrl, out[0]);
@@ -739,13 +652,13 @@
         }
     } else {
         // ramp gain
-        if UNLIKELY(t->volumeInc[0]|t->volumeInc[1]) {
+        if (CC_UNLIKELY(t->volumeInc[0]|t->volumeInc[1])) {
             int32_t vl = t->prevVolume[0];
             int32_t vr = t->prevVolume[1];
             const int32_t vlInc = t->volumeInc[0];
             const int32_t vrInc = t->volumeInc[1];
 
-            // LOGD("[1] %p: inc=%f, v0=%f, v1=%d, final=%f, count=%d",
+            // ALOGD("[1] %p: inc=%f, v0=%f, v1=%d, final=%f, count=%d",
             //        t, vlInc/65536.0f, vl/65536.0f, t->volume[0],
             //        (vl + vlInc*frameCount)/65536.0f, frameCount);
 
@@ -765,7 +678,7 @@
         else {
             const uint32_t vrl = t->volumeRL;
             do {
-                uint32_t rl = *reinterpret_cast<uint32_t const *>(in);
+                uint32_t rl = *reinterpret_cast<const uint32_t *>(in);
                 in += 2;
                 out[0] = mulAddRL(1, rl, vrl, out[0]);
                 out[1] = mulAddRL(0, rl, vrl, out[1]);
@@ -778,11 +691,11 @@
 
 void AudioMixer::track__16BitsMono(track_t* t, int32_t* out, size_t frameCount, int32_t* temp, int32_t* aux)
 {
-    int16_t const *in = static_cast<int16_t const *>(t->in);
+    const int16_t *in = static_cast<int16_t const *>(t->in);
 
-    if UNLIKELY(aux != NULL) {
+    if (CC_UNLIKELY(aux != NULL)) {
         // ramp gain
-        if UNLIKELY(t->volumeInc[0]|t->volumeInc[1]|t->auxInc) {
+        if (CC_UNLIKELY(t->volumeInc[0]|t->volumeInc[1]|t->auxInc)) {
             int32_t vl = t->prevVolume[0];
             int32_t vr = t->prevVolume[1];
             int32_t va = t->prevAuxLevel;
@@ -790,7 +703,7 @@
             const int32_t vrInc = t->volumeInc[1];
             const int32_t vaInc = t->auxInc;
 
-            // LOGD("[2] %p: inc=%f, v0=%f, v1=%d, final=%f, count=%d",
+            // ALOGD("[2] %p: inc=%f, v0=%f, v1=%d, final=%f, count=%d",
             //         t, vlInc/65536.0f, vl/65536.0f, t->volume[0],
             //         (vl + vlInc*frameCount)/65536.0f, frameCount);
 
@@ -825,13 +738,13 @@
         }
     } else {
         // ramp gain
-        if UNLIKELY(t->volumeInc[0]|t->volumeInc[1]) {
+        if (CC_UNLIKELY(t->volumeInc[0]|t->volumeInc[1])) {
             int32_t vl = t->prevVolume[0];
             int32_t vr = t->prevVolume[1];
             const int32_t vlInc = t->volumeInc[0];
             const int32_t vrInc = t->volumeInc[1];
 
-            // LOGD("[2] %p: inc=%f, v0=%f, v1=%d, final=%f, count=%d",
+            // ALOGD("[2] %p: inc=%f, v0=%f, v1=%d, final=%f, count=%d",
             //         t, vlInc/65536.0f, vl/65536.0f, t->volume[0],
             //         (vl + vlInc*frameCount)/65536.0f, frameCount);
 
@@ -862,19 +775,6 @@
     t->in = in;
 }
 
-void AudioMixer::ditherAndClamp(int32_t* out, int32_t const *sums, size_t c)
-{
-    for (size_t i=0 ; i<c ; i++) {
-        int32_t l = *sums++;
-        int32_t r = *sums++;
-        int32_t nl = l >> 12;
-        int32_t nr = r >> 12;
-        l = clamp16(nl);
-        r = clamp16(nr);
-        *out++ = (r<<16) | (l & 0xFFFF);
-    }
-}
-
 // no-op case
 void AudioMixer::process__nop(state_t* state)
 {
@@ -891,7 +791,7 @@
             i = 31 - __builtin_clz(e2);
             e2 &= ~(1<<i);
             track_t& t2 = state->tracks[i];
-            if UNLIKELY(t2.mainBuffer != t1.mainBuffer) {
+            if (CC_UNLIKELY(t2.mainBuffer != t1.mainBuffer)) {
                 e1 &= ~(1<<i);
             }
         }
@@ -949,7 +849,7 @@
             j = 31 - __builtin_clz(e2);
             e2 &= ~(1<<j);
             track_t& t2 = state->tracks[j];
-            if UNLIKELY(t2.mainBuffer != t1.mainBuffer) {
+            if (CC_UNLIKELY(t2.mainBuffer != t1.mainBuffer)) {
                 e1 &= ~(1<<j);
             }
         }
@@ -966,7 +866,7 @@
                 track_t& t = state->tracks[i];
                 size_t outFrames = BLOCKSIZE;
                 int32_t *aux = NULL;
-                if UNLIKELY((t.needs & NEEDS_AUX__MASK) == NEEDS_AUX_ENABLED) {
+                if (CC_UNLIKELY((t.needs & NEEDS_AUX__MASK) == NEEDS_AUX_ENABLED)) {
                     aux = t.auxBuffer + numFrames;
                 }
                 while (outFrames) {
@@ -975,7 +875,7 @@
                         (t.hook)(&t, outTemp + (BLOCKSIZE-outFrames)*MAX_NUM_CHANNELS, inFrames, state->resampleTemp, aux);
                         t.frameCount -= inFrames;
                         outFrames -= inFrames;
-                        if UNLIKELY(aux != NULL) {
+                        if (CC_UNLIKELY(aux != NULL)) {
                             aux += inFrames;
                         }
                     }
@@ -1010,9 +910,10 @@
 }
 
 
-  // generic code with resampling
+// generic code with resampling
 void AudioMixer::process__genericResampling(state_t* state)
 {
+    // this const just means that local variable outTemp doesn't change
     int32_t* const outTemp = state->outputTemp;
     const size_t size = sizeof(int32_t) * MAX_NUM_CHANNELS * state->frameCount;
 
@@ -1030,7 +931,7 @@
             j = 31 - __builtin_clz(e2);
             e2 &= ~(1<<j);
             track_t& t2 = state->tracks[j];
-            if UNLIKELY(t2.mainBuffer != t1.mainBuffer) {
+            if (CC_UNLIKELY(t2.mainBuffer != t1.mainBuffer)) {
                 e1 &= ~(1<<j);
             }
         }
@@ -1042,7 +943,7 @@
             e1 &= ~(1<<i);
             track_t& t = state->tracks[i];
             int32_t *aux = NULL;
-            if UNLIKELY((t.needs & NEEDS_AUX__MASK) == NEEDS_AUX_ENABLED) {
+            if (CC_UNLIKELY((t.needs & NEEDS_AUX__MASK) == NEEDS_AUX_ENABLED)) {
                 aux = t.auxBuffer;
             }
 
@@ -1063,7 +964,7 @@
                     // been enabled for mixing.
                     if (t.in == NULL) break;
 
-                    if UNLIKELY(aux != NULL) {
+                    if (CC_UNLIKELY(aux != NULL)) {
                         aux += outFrames;
                     }
                     (t.hook)(&t, outTemp + outFrames*MAX_NUM_CHANNELS, t.buffer.frameCount, state->resampleTemp, aux);
@@ -1093,23 +994,23 @@
     while (numFrames) {
         b.frameCount = numFrames;
         t.bufferProvider->getNextBuffer(&b);
-        int16_t const *in = b.i16;
+        const int16_t *in = b.i16;
 
         // in == NULL can happen if the track was flushed just after having
         // been enabled for mixing.
         if (in == NULL || ((unsigned long)in & 3)) {
             memset(out, 0, numFrames*MAX_NUM_CHANNELS*sizeof(int16_t));
-            LOGE_IF(((unsigned long)in & 3), "process stereo track: input buffer alignment pb: buffer %p track %d, channels %d, needs %08x",
+            ALOGE_IF(((unsigned long)in & 3), "process stereo track: input buffer alignment pb: buffer %p track %d, channels %d, needs %08x",
                     in, i, t.channelCount, t.needs);
             return;
         }
         size_t outFrames = b.frameCount;
 
-        if (UNLIKELY(uint32_t(vl) > UNITY_GAIN || uint32_t(vr) > UNITY_GAIN)) {
+        if (CC_UNLIKELY(uint32_t(vl) > UNITY_GAIN || uint32_t(vr) > UNITY_GAIN)) {
             // volume is boosted, so we might need to clamp even though
             // we process only one track.
             do {
-                uint32_t rl = *reinterpret_cast<uint32_t const *>(in);
+                uint32_t rl = *reinterpret_cast<const uint32_t *>(in);
                 in += 2;
                 int32_t l = mulRL(1, rl, vrl) >> 12;
                 int32_t r = mulRL(0, rl, vrl) >> 12;
@@ -1120,7 +1021,7 @@
             } while (--outFrames);
         } else {
             do {
-                uint32_t rl = *reinterpret_cast<uint32_t const *>(in);
+                uint32_t rl = *reinterpret_cast<const uint32_t *>(in);
                 in += 2;
                 int32_t l = mulRL(1, rl, vrl) >> 12;
                 int32_t r = mulRL(0, rl, vrl) >> 12;
@@ -1132,6 +1033,7 @@
     }
 }
 
+#if 0
 // 2 tracks is also a common case
 // NEVER used in current implementation of process__validate()
 // only use if the 2 tracks have the same output buffer
@@ -1149,12 +1051,12 @@
     const track_t& t1 = state->tracks[i];
     AudioBufferProvider::Buffer& b1(t1.buffer);
 
-    int16_t const *in0;
+    const int16_t *in0;
     const int16_t vl0 = t0.volume[0];
     const int16_t vr0 = t0.volume[1];
     size_t frameCount0 = 0;
 
-    int16_t const *in1;
+    const int16_t *in1;
     const int16_t vl1 = t1.volume[0];
     const int16_t vr1 = t1.volume[1];
     size_t frameCount1 = 0;
@@ -1162,7 +1064,7 @@
     //FIXME: only works if two tracks use same buffer
     int32_t* out = t0.mainBuffer;
     size_t numFrames = state->frameCount;
-    int16_t const *buff = NULL;
+    const int16_t *buff = NULL;
 
 
     while (numFrames) {
@@ -1190,7 +1092,7 @@
                 }
                 in1 = buff;
                 b1.frameCount = numFrames;
-               } else {
+            } else {
                 in1 = b1.i16;
             }
             frameCount1 = b1.frameCount;
@@ -1229,7 +1131,7 @@
         delete [] buff;
     }
 }
+#endif
 
 // ----------------------------------------------------------------------------
 }; // namespace android
-
diff --git a/services/audioflinger/AudioMixer.h b/services/audioflinger/AudioMixer.h
index 0137185..84f6330 100644
--- a/services/audioflinger/AudioMixer.h
+++ b/services/audioflinger/AudioMixer.h
@@ -28,11 +28,6 @@
 
 // ----------------------------------------------------------------------------
 
-#define LIKELY( exp )       (__builtin_expect( (exp) != 0, true  ))
-#define UNLIKELY( exp )     (__builtin_expect( (exp) != 0, false ))
-
-// ----------------------------------------------------------------------------
-
 class AudioMixer
 {
 public:
@@ -47,11 +42,10 @@
 
     enum { // names
 
-        // track units (32 units)
+        // track names (MAX_NUM_TRACKS units)
         TRACK0          = 0x1000,
 
-        // enable/disable
-        MIXING          = 0x2000,
+        // 0x2000 is unused
 
         // setParameter targets
         TRACK           = 0x3000,
@@ -65,32 +59,30 @@
         FORMAT          = 0x4001,
         MAIN_BUFFER     = 0x4002,
         AUX_BUFFER      = 0x4003,
-        // for TARGET RESAMPLE
+        // for target RESAMPLE
         SAMPLE_RATE     = 0x4100,
         RESET           = 0x4101,
-        // for TARGET VOLUME (8 channels max)
+        // for target RAMP_VOLUME and VOLUME (8 channels max)
         VOLUME0         = 0x4200,
         VOLUME1         = 0x4201,
         AUXLEVEL        = 0x4210,
     };
 
 
+    // For all APIs with "name": TRACK0 <= name < TRACK0 + MAX_NUM_TRACKS
     int         getTrackName();
     void        deleteTrackName(int name);
 
-    status_t    enable(int name);
-    status_t    disable(int name);
+    void        enable(int name);
+    void        disable(int name);
 
-    status_t    setActiveTrack(int track);
-    status_t    setParameter(int target, int name, void *value);
+    void        setParameter(int name, int target, int param, void *value);
 
-    status_t    setBufferProvider(AudioBufferProvider* bufferProvider);
+    void        setBufferProvider(int name, AudioBufferProvider* bufferProvider);
     void        process();
 
     uint32_t    trackNames() const { return mTrackNames; }
 
-    static void ditherAndClamp(int32_t* out, int32_t const *sums, size_t c);
-
     size_t      getUnreleasedFrames(int name);
 
 private:
@@ -119,11 +111,6 @@
         NEEDS_AUX_ENABLED      = 0x00010000,
     };
 
-    static inline int32_t applyVolume(int32_t in, int32_t v) {
-        return in * v;
-    }
-
-
     struct state_t;
     struct track_t;
 
@@ -135,13 +122,13 @@
         uint32_t    needs;
 
         union {
-        int16_t     volume[2];      // [0]3.12 fixed point
+        int16_t     volume[MAX_NUM_CHANNELS]; // [0]3.12 fixed point
         int32_t     volumeRL;
         };
 
-        int32_t     prevVolume[2];
+        int32_t     prevVolume[MAX_NUM_CHANNELS];
 
-        int32_t     volumeInc[2];
+        int32_t     volumeInc[MAX_NUM_CHANNELS];
         int32_t     auxLevel;
         int32_t     auxInc;
         int32_t     prevAuxLevel;
@@ -158,7 +145,7 @@
         mutable AudioBufferProvider::Buffer buffer;
 
         hook_t      hook;
-        void const* in;             // current location in buffer
+        const void* in;             // current location in buffer
 
         AudioResampler*     resampler;
         uint32_t            sampleRate;
@@ -181,10 +168,10 @@
         int32_t         *outputTemp;
         int32_t         *resampleTemp;
         int32_t         reserved[2];
-        track_t         tracks[32]; __attribute__((aligned(32)));
+        track_t         tracks[MAX_NUM_TRACKS]; __attribute__((aligned(32)));
     };
 
-    int             mActiveTrack;
+    // bitmask of allocated track names, where bit 0 corresponds to TRACK0 etc.
     uint32_t        mTrackNames;
     const uint32_t  mSampleRate;
 
@@ -204,7 +191,9 @@
     static void process__genericNoResampling(state_t* state);
     static void process__genericResampling(state_t* state);
     static void process__OneTrack16BitsStereoNoResampling(state_t* state);
+#if 0
     static void process__TwoTracks16BitsStereoNoResampling(state_t* state);
+#endif
 };
 
 // ----------------------------------------------------------------------------
diff --git a/services/audioflinger/AudioPolicyService.cpp b/services/audioflinger/AudioPolicyService.cpp
index 8da5ca1..3f86d58 100644
--- a/services/audioflinger/AudioPolicyService.cpp
+++ b/services/audioflinger/AudioPolicyService.cpp
@@ -31,7 +31,6 @@
 #include <utils/threads.h>
 #include "AudioPolicyService.h"
 #include <cutils/properties.h>
-#include <dlfcn.h>
 #include <hardware_legacy/power.h>
 #include <media/AudioEffect.h>
 #include <media/EffectsFactoryApi.h>
@@ -53,7 +52,7 @@
 static bool checkPermission() {
     if (getpid() == IPCThreadState::self()->getCallingPid()) return true;
     bool ok = checkCallingPermission(String16("android.permission.MODIFY_AUDIO_SETTINGS"));
-    if (!ok) LOGE("Request requires android.permission.MODIFY_AUDIO_SETTINGS");
+    if (!ok) ALOGE("Request requires android.permission.MODIFY_AUDIO_SETTINGS");
     return ok;
 }
 
@@ -84,18 +83,18 @@
         return;
 
     rc = audio_policy_dev_open(module, &mpAudioPolicyDev);
-    LOGE_IF(rc, "couldn't open audio policy device (%s)", strerror(-rc));
+    ALOGE_IF(rc, "couldn't open audio policy device (%s)", strerror(-rc));
     if (rc)
         return;
 
     rc = mpAudioPolicyDev->create_audio_policy(mpAudioPolicyDev, &aps_ops, this,
                                                &mpAudioPolicy);
-    LOGE_IF(rc, "couldn't create audio policy (%s)", strerror(-rc));
+    ALOGE_IF(rc, "couldn't create audio policy (%s)", strerror(-rc));
     if (rc)
         return;
 
     rc = mpAudioPolicy->init_check(mpAudioPolicy);
-    LOGE_IF(rc, "couldn't init_check the audio policy (%s)", strerror(-rc));
+    ALOGE_IF(rc, "couldn't init_check the audio policy (%s)", strerror(-rc));
     if (rc)
         return;
 
@@ -103,7 +102,7 @@
     forced_val = strtol(value, NULL, 0);
     mpAudioPolicy->set_can_mute_enforced_audible(mpAudioPolicy, !forced_val);
 
-    LOGI("Loaded audio policy from %s (%s)", module->name, module->id);
+    ALOGI("Loaded audio policy from %s (%s)", module->name, module->id);
 
     // load audio pre processing modules
     if (access(AUDIO_EFFECT_VENDOR_CONFIG_FILE, R_OK) == 0) {
@@ -169,7 +168,7 @@
         return BAD_VALUE;
     }
 
-    LOGV("setDeviceConnectionState() tid %d", gettid());
+    ALOGV("setDeviceConnectionState() tid %d", gettid());
     Mutex::Autolock _l(mLock);
     return mpAudioPolicy->set_device_connection_state(mpAudioPolicy, device,
                                                       state, device_address);
@@ -194,11 +193,11 @@
     if (!checkPermission()) {
         return PERMISSION_DENIED;
     }
-    if (state < 0 || state >= AUDIO_MODE_CNT) {
+    if (uint32_t(state) >= AUDIO_MODE_CNT) {
         return BAD_VALUE;
     }
 
-    LOGV("setPhoneState() tid %d", gettid());
+    ALOGV("setPhoneState() tid %d", gettid());
 
     // TODO: check if it is more appropriate to do it in platform specific policy manager
     AudioSystem::setMode(state);
@@ -236,7 +235,7 @@
     if (config < 0 || config >= AUDIO_POLICY_FORCE_CFG_CNT) {
         return BAD_VALUE;
     }
-    LOGV("setForceUse() tid %d", gettid());
+    ALOGV("setForceUse() tid %d", gettid());
     Mutex::Autolock _l(mLock);
     mpAudioPolicy->set_force_use(mpAudioPolicy, usage, config);
     return NO_ERROR;
@@ -262,7 +261,7 @@
     if (mpAudioPolicy == NULL) {
         return 0;
     }
-    LOGV("getOutput() tid %d", gettid());
+    ALOGV("getOutput() tid %d", gettid());
     Mutex::Autolock _l(mLock);
     return mpAudioPolicy->get_output(mpAudioPolicy, stream, samplingRate, format, channels, flags);
 }
@@ -274,7 +273,7 @@
     if (mpAudioPolicy == NULL) {
         return NO_INIT;
     }
-    LOGV("startOutput() tid %d", gettid());
+    ALOGV("startOutput() tid %d", gettid());
     Mutex::Autolock _l(mLock);
     return mpAudioPolicy->start_output(mpAudioPolicy, output, stream, session);
 }
@@ -286,7 +285,7 @@
     if (mpAudioPolicy == NULL) {
         return NO_INIT;
     }
-    LOGV("stopOutput() tid %d", gettid());
+    ALOGV("stopOutput() tid %d", gettid());
     Mutex::Autolock _l(mLock);
     return mpAudioPolicy->stop_output(mpAudioPolicy, output, stream, session);
 }
@@ -296,7 +295,7 @@
     if (mpAudioPolicy == NULL) {
         return;
     }
-    LOGV("releaseOutput() tid %d", gettid());
+    ALOGV("releaseOutput() tid %d", gettid());
     Mutex::Autolock _l(mLock);
     mpAudioPolicy->release_output(mpAudioPolicy, output);
 }
@@ -339,7 +338,7 @@
         sp<AudioEffect> fx = new AudioEffect(NULL, &effect->mUuid, -1, 0, 0, audioSession, input);
         status_t status = fx->initCheck();
         if (status != NO_ERROR && status != ALREADY_EXISTS) {
-            LOGW("Failed to create Fx %s on input %d", effect->mName, input);
+            ALOGW("Failed to create Fx %s on input %d", effect->mName, input);
             // fx goes out of scope and strong ref on AudioEffect is released
             continue;
         }
@@ -534,7 +533,7 @@
 }
 
 void AudioPolicyService::binderDied(const wp<IBinder>& who) {
-    LOGW("binderDied() %p, tid %d, calling tid %d", who.unsafe_get(), gettid(),
+    ALOGW("binderDied() %p, tid %d, calling tid %d", who.unsafe_get(), gettid(),
             IPCThreadState::self()->getCallingPid());
 }
 
@@ -672,7 +671,7 @@
                 case START_TONE: {
                     mLock.unlock();
                     ToneData *data = (ToneData *)command->mParam;
-                    LOGV("AudioCommandThread() processing start tone %d on stream %d",
+                    ALOGV("AudioCommandThread() processing start tone %d on stream %d",
                             data->mType, data->mStream);
                     if (mpToneGenerator != NULL)
                         delete mpToneGenerator;
@@ -683,7 +682,7 @@
                     }break;
                 case STOP_TONE: {
                     mLock.unlock();
-                    LOGV("AudioCommandThread() processing stop tone");
+                    ALOGV("AudioCommandThread() processing stop tone");
                     if (mpToneGenerator != NULL) {
                         mpToneGenerator->stopTone();
                         delete mpToneGenerator;
@@ -693,7 +692,7 @@
                     }break;
                 case SET_VOLUME: {
                     VolumeData *data = (VolumeData *)command->mParam;
-                    LOGV("AudioCommandThread() processing set volume stream %d, \
+                    ALOGV("AudioCommandThread() processing set volume stream %d, \
                             volume %f, output %d", data->mStream, data->mVolume, data->mIO);
                     command->mStatus = AudioSystem::setStreamVolume(data->mStream,
                                                                     data->mVolume,
@@ -706,7 +705,7 @@
                     }break;
                 case SET_PARAMETERS: {
                      ParametersData *data = (ParametersData *)command->mParam;
-                     LOGV("AudioCommandThread() processing set parameters string %s, io %d",
+                     ALOGV("AudioCommandThread() processing set parameters string %s, io %d",
                              data->mKeyValuePairs.string(), data->mIO);
                      command->mStatus = AudioSystem::setParameters(data->mIO, data->mKeyValuePairs);
                      if (command->mWaitStatus) {
@@ -717,7 +716,7 @@
                      }break;
                 case SET_VOICE_VOLUME: {
                     VoiceVolumeData *data = (VoiceVolumeData *)command->mParam;
-                    LOGV("AudioCommandThread() processing set voice volume volume %f",
+                    ALOGV("AudioCommandThread() processing set voice volume volume %f",
                             data->mVolume);
                     command->mStatus = AudioSystem::setVoiceVolume(data->mVolume);
                     if (command->mWaitStatus) {
@@ -727,7 +726,7 @@
                     delete data;
                     }break;
                 default:
-                    LOGW("AudioCommandThread() unknown command %d", command->mCommand);
+                    ALOGW("AudioCommandThread() unknown command %d", command->mCommand);
                 }
                 delete command;
                 waitTime = INT64_MAX;
@@ -740,9 +739,9 @@
         if (mName != "" && mAudioCommands.isEmpty()) {
             release_wake_lock(mName.string());
         }
-        LOGV("AudioCommandThread() going to sleep");
+        ALOGV("AudioCommandThread() going to sleep");
         mWaitWorkCV.waitRelative(mLock, waitTime);
-        LOGV("AudioCommandThread() waking up");
+        ALOGV("AudioCommandThread() waking up");
     }
     mLock.unlock();
     return false;
@@ -793,7 +792,7 @@
     command->mWaitStatus = false;
     Mutex::Autolock _l(mLock);
     insertCommand_l(command);
-    LOGV("AudioCommandThread() adding tone start type %d, stream %d", type, stream);
+    ALOGV("AudioCommandThread() adding tone start type %d, stream %d", type, stream);
     mWaitWorkCV.signal();
 }
 
@@ -805,7 +804,7 @@
     command->mWaitStatus = false;
     Mutex::Autolock _l(mLock);
     insertCommand_l(command);
-    LOGV("AudioCommandThread() adding tone stop");
+    ALOGV("AudioCommandThread() adding tone stop");
     mWaitWorkCV.signal();
 }
 
@@ -830,7 +829,7 @@
     }
     Mutex::Autolock _l(mLock);
     insertCommand_l(command, delayMs);
-    LOGV("AudioCommandThread() adding set volume stream %d, volume %f, output %d",
+    ALOGV("AudioCommandThread() adding set volume stream %d, volume %f, output %d",
             stream, volume, output);
     mWaitWorkCV.signal();
     if (command->mWaitStatus) {
@@ -860,7 +859,7 @@
     }
     Mutex::Autolock _l(mLock);
     insertCommand_l(command, delayMs);
-    LOGV("AudioCommandThread() adding set parameter string %s, io %d ,delay %d",
+    ALOGV("AudioCommandThread() adding set parameter string %s, io %d ,delay %d",
             keyValuePairs, ioHandle, delayMs);
     mWaitWorkCV.signal();
     if (command->mWaitStatus) {
@@ -887,7 +886,7 @@
     }
     Mutex::Autolock _l(mLock);
     insertCommand_l(command, delayMs);
-    LOGV("AudioCommandThread() adding set voice volume volume %f", volume);
+    ALOGV("AudioCommandThread() adding set voice volume volume %f", volume);
     mWaitWorkCV.signal();
     if (command->mWaitStatus) {
         command->mCond.wait(mLock);
@@ -922,7 +921,7 @@
             ParametersData *data = (ParametersData *)command->mParam;
             ParametersData *data2 = (ParametersData *)command2->mParam;
             if (data->mIO != data2->mIO) break;
-            LOGV("Comparing parameter command %s to new command %s",
+            ALOGV("Comparing parameter command %s to new command %s",
                     data2->mKeyValuePairs.string(), data->mKeyValuePairs.string());
             AudioParameter param = AudioParameter(data->mKeyValuePairs);
             AudioParameter param2 = AudioParameter(data2->mKeyValuePairs);
@@ -936,7 +935,7 @@
                   param2.getAt(k, key2, value2);
                   if (key2 == key) {
                       param2.remove(key2);
-                      LOGV("Filtering out parameter %s", key2.string());
+                      ALOGV("Filtering out parameter %s", key2.string());
                       break;
                   }
                }
@@ -955,7 +954,7 @@
             VolumeData *data2 = (VolumeData *)command2->mParam;
             if (data->mIO != data2->mIO) break;
             if (data->mStream != data2->mStream) break;
-            LOGV("Filtering out volume command on output %d for stream %d",
+            ALOGV("Filtering out volume command on output %d for stream %d",
                     data->mIO, data->mStream);
             removedCommands.add(command2);
         } break;
@@ -971,7 +970,7 @@
         // removed commands always have time stamps greater than current command
         for (size_t k = i + 1; k < mAudioCommands.size(); k++) {
             if (mAudioCommands[k] == removedCommands[j]) {
-                LOGV("suppressing command: %d", mAudioCommands[k]->mCommand);
+                ALOGV("suppressing command: %d", mAudioCommands[k]->mCommand);
                 mAudioCommands.removeAt(k);
                 break;
             }
@@ -980,14 +979,14 @@
     removedCommands.clear();
 
     // insert command at the right place according to its time stamp
-    LOGV("inserting command: %d at index %d, num commands %d",
+    ALOGV("inserting command: %d at index %d, num commands %d",
             command->mCommand, (int)i+1, mAudioCommands.size());
     mAudioCommands.insertAt(command, i + 1);
 }
 
 void AudioPolicyService::AudioCommandThread::exit()
 {
-    LOGV("AudioCommandThread::exit");
+    ALOGV("AudioCommandThread::exit");
     {
         AutoMutex _l(mLock);
         requestExit();
@@ -1028,9 +1027,9 @@
                                   audio_stream_type_t stream)
 {
     if (tone != AUDIO_POLICY_TONE_IN_CALL_NOTIFICATION)
-        LOGE("startTone: illegal tone requested (%d)", tone);
+        ALOGE("startTone: illegal tone requested (%d)", tone);
     if (stream != AUDIO_STREAM_VOICE_CALL)
-        LOGE("startTone: illegal stream (%d) requested for tone %d", stream,
+        ALOGE("startTone: illegal stream (%d) requested for tone %d", stream,
              tone);
     mTonePlaybackThread->startToneCommand(ToneGenerator::TONE_SUP_CALL_WAITING,
                                           AUDIO_STREAM_VOICE_CALL);
@@ -1069,7 +1068,7 @@
     int i;
     for (i = AUDIO_SOURCE_MIC; i < AUDIO_SOURCE_CNT; i++) {
         if (strcmp(name, kInputSourceNames[i - AUDIO_SOURCE_MIC]) == 0) {
-            LOGV("inputSourceNameToEnum found source %s %d", name, i);
+            ALOGV("inputSourceNameToEnum found source %s %d", name, i);
             break;
         }
     }
@@ -1102,17 +1101,17 @@
     if (strncmp(node->name, SHORT_TAG, sizeof(SHORT_TAG) + 1) == 0) {
         size_t pos = growParamSize(param, sizeof(short), curSize, totSize);
         *(short *)((char *)param + pos) = (short)atoi(node->value);
-        LOGV("readParamValue() reading short %d", *(short *)((char *)param + pos));
+        ALOGV("readParamValue() reading short %d", *(short *)((char *)param + pos));
         return sizeof(short);
     } else if (strncmp(node->name, INT_TAG, sizeof(INT_TAG) + 1) == 0) {
         size_t pos = growParamSize(param, sizeof(int), curSize, totSize);
         *(int *)((char *)param + pos) = atoi(node->value);
-        LOGV("readParamValue() reading int %d", *(int *)((char *)param + pos));
+        ALOGV("readParamValue() reading int %d", *(int *)((char *)param + pos));
         return sizeof(int);
     } else if (strncmp(node->name, FLOAT_TAG, sizeof(FLOAT_TAG) + 1) == 0) {
         size_t pos = growParamSize(param, sizeof(float), curSize, totSize);
         *(float *)((char *)param + pos) = (float)atof(node->value);
-        LOGV("readParamValue() reading float %f",*(float *)((char *)param + pos));
+        ALOGV("readParamValue() reading float %f",*(float *)((char *)param + pos));
         return sizeof(float);
     } else if (strncmp(node->name, BOOL_TAG, sizeof(BOOL_TAG) + 1) == 0) {
         size_t pos = growParamSize(param, sizeof(bool), curSize, totSize);
@@ -1121,7 +1120,7 @@
         } else {
             *(bool *)((char *)param + pos) = true;
         }
-        LOGV("readParamValue() reading bool %s",*(bool *)((char *)param + pos) ? "true" : "false");
+        ALOGV("readParamValue() reading bool %s",*(bool *)((char *)param + pos) ? "true" : "false");
         return sizeof(bool);
     } else if (strncmp(node->name, STRING_TAG, sizeof(STRING_TAG) + 1) == 0) {
         size_t len = strnlen(node->value, EFFECT_STRING_LEN_MAX);
@@ -1132,10 +1131,10 @@
         strncpy(param + *curSize, node->value, len);
         *curSize += len;
         param[*curSize] = '\0';
-        LOGV("readParamValue() reading string %s", param + *curSize - len);
+        ALOGV("readParamValue() reading string %s", param + *curSize - len);
         return len;
     }
-    LOGW("readParamValue() unknown param type %s", node->name);
+    ALOGW("readParamValue() unknown param type %s", node->name);
     return 0;
 }
 
@@ -1156,7 +1155,7 @@
             // Note: that a pair of random strings is read as 0 0
             int *ptr = (int *)fx_param->data;
             int *ptr2 = (int *)((char *)param + sizeof(effect_param_t));
-            LOGW("loadEffectParameter() ptr %p ptr2 %p", ptr, ptr2);
+            ALOGW("loadEffectParameter() ptr %p ptr2 %p", ptr, ptr2);
             *ptr++ = atoi(param->name);
             *ptr = atoi(param->value);
             fx_param->psize = sizeof(int);
@@ -1165,14 +1164,14 @@
         }
     }
     if (param == NULL || value == NULL) {
-        LOGW("loadEffectParameter() invalid parameter description %s", root->name);
+        ALOGW("loadEffectParameter() invalid parameter description %s", root->name);
         goto error;
     }
 
     fx_param->psize = 0;
     param = param->first_child;
     while (param) {
-        LOGV("loadEffectParameter() reading param of type %s", param->name);
+        ALOGV("loadEffectParameter() reading param of type %s", param->name);
         size_t size = readParamValue(param, (char *)fx_param, &curSize, &totSize);
         if (size == 0) {
             goto error;
@@ -1187,7 +1186,7 @@
     fx_param->vsize = 0;
     value = value->first_child;
     while (value) {
-        LOGV("loadEffectParameter() reading value of type %s", value->name);
+        ALOGV("loadEffectParameter() reading value of type %s", value->name);
         size_t size = readParamValue(value, (char *)fx_param, &curSize, &totSize);
         if (size == 0) {
             goto error;
@@ -1207,7 +1206,7 @@
 {
     cnode *node = root->first_child;
     while (node) {
-        LOGV("loadEffectParameters() loading param %s", node->name);
+        ALOGV("loadEffectParameters() loading param %s", node->name);
         effect_param_t *param = loadEffectParameter(node);
         if (param == NULL) {
             node = node->next;
@@ -1224,7 +1223,7 @@
 {
     cnode *node = root->first_child;
     if (node == NULL) {
-        LOGW("loadInputSource() empty element %s", root->name);
+        ALOGW("loadInputSource() empty element %s", root->name);
         return NULL;
     }
     InputSourceDesc *source = new InputSourceDesc();
@@ -1232,23 +1231,23 @@
         size_t i;
         for (i = 0; i < effects.size(); i++) {
             if (strncmp(effects[i]->mName, node->name, EFFECT_STRING_LEN_MAX) == 0) {
-                LOGV("loadInputSource() found effect %s in list", node->name);
+                ALOGV("loadInputSource() found effect %s in list", node->name);
                 break;
             }
         }
         if (i == effects.size()) {
-            LOGV("loadInputSource() effect %s not in list", node->name);
+            ALOGV("loadInputSource() effect %s not in list", node->name);
             node = node->next;
             continue;
         }
         EffectDesc *effect = new EffectDesc(*effects[i]);
         loadEffectParameters(node, effect->mParams);
-        LOGV("loadInputSource() adding effect %s uuid %08x", effect->mName, effect->mUuid.timeLow);
+        ALOGV("loadInputSource() adding effect %s uuid %08x", effect->mName, effect->mUuid.timeLow);
         source->mEffects.add(effect);
         node = node->next;
     }
     if (source->mEffects.size() == 0) {
-        LOGW("loadInputSource() no valid effects found in source %s", root->name);
+        ALOGW("loadInputSource() no valid effects found in source %s", root->name);
         delete source;
         return NULL;
     }
@@ -1265,11 +1264,11 @@
     while (node) {
         audio_source_t source = inputSourceNameToEnum(node->name);
         if (source == AUDIO_SOURCE_CNT) {
-            LOGW("loadInputSources() invalid input source %s", node->name);
+            ALOGW("loadInputSources() invalid input source %s", node->name);
             node = node->next;
             continue;
         }
-        LOGV("loadInputSources() loading input source %s", node->name);
+        ALOGV("loadInputSources() loading input source %s", node->name);
         InputSourceDesc *desc = loadInputSource(node, effects);
         if (desc == NULL) {
             node = node->next;
@@ -1289,7 +1288,7 @@
     }
     effect_uuid_t uuid;
     if (AudioEffect::stringToGuid(node->value, &uuid) != NO_ERROR) {
-        LOGW("loadEffect() invalid uuid %s", node->value);
+        ALOGW("loadEffect() invalid uuid %s", node->value);
         return NULL;
     }
     EffectDesc *effect = new EffectDesc();
@@ -1307,7 +1306,7 @@
     }
     node = node->first_child;
     while (node) {
-        LOGV("loadEffects() loading effect %s", node->name);
+        ALOGV("loadEffects() loading effect %s", node->name);
         EffectDesc *effect = loadEffect(node);
         if (effect == NULL) {
             node = node->next;
@@ -1355,7 +1354,7 @@
 {
     sp<IAudioFlinger> af = AudioSystem::get_audio_flinger();
     if (af == NULL) {
-        LOGW("%s: could not get AudioFlinger", __func__);
+        ALOGW("%s: could not get AudioFlinger", __func__);
         return 0;
     }
 
@@ -1369,7 +1368,7 @@
 {
     sp<IAudioFlinger> af = AudioSystem::get_audio_flinger();
     if (af == NULL) {
-        LOGW("%s: could not get AudioFlinger", __func__);
+        ALOGW("%s: could not get AudioFlinger", __func__);
         return 0;
     }
     return af->openDuplicateOutput(output1, output2);
@@ -1388,7 +1387,7 @@
 {
     sp<IAudioFlinger> af = AudioSystem::get_audio_flinger();
     if (af == NULL) {
-        LOGW("%s: could not get AudioFlinger", __func__);
+        ALOGW("%s: could not get AudioFlinger", __func__);
         return PERMISSION_DENIED;
     }
 
@@ -1399,7 +1398,7 @@
 {
     sp<IAudioFlinger> af = AudioSystem::get_audio_flinger();
     if (af == NULL) {
-        LOGW("%s: could not get AudioFlinger", __func__);
+        ALOGW("%s: could not get AudioFlinger", __func__);
         return PERMISSION_DENIED;
     }
 
@@ -1415,7 +1414,7 @@
 {
     sp<IAudioFlinger> af = AudioSystem::get_audio_flinger();
     if (af == NULL) {
-        LOGW("%s: could not get AudioFlinger", __func__);
+        ALOGW("%s: could not get AudioFlinger", __func__);
         return 0;
     }
 
diff --git a/services/audioflinger/AudioPolicyService.h b/services/audioflinger/AudioPolicyService.h
index d898a53..88cb1e9 100644
--- a/services/audioflinger/AudioPolicyService.h
+++ b/services/audioflinger/AudioPolicyService.h
@@ -19,6 +19,7 @@
 
 #include <cutils/misc.h>
 #include <cutils/config_utils.h>
+#include <utils/String8.h>
 #include <utils/Vector.h>
 #include <utils/SortedVector.h>
 #include <binder/BinderService.h>
@@ -31,8 +32,6 @@
 
 namespace android {
 
-class String8;
-
 // ----------------------------------------------------------------------------
 
 class AudioPolicyService :
diff --git a/services/audioflinger/AudioResampler.cpp b/services/audioflinger/AudioResampler.cpp
index 9ee5a30..feacd96 100644
--- a/services/audioflinger/AudioResampler.cpp
+++ b/services/audioflinger/AudioResampler.cpp
@@ -87,7 +87,7 @@
     char value[PROPERTY_VALUE_MAX];
     if (property_get("af.resampler.quality", value, 0)) {
         quality = atoi(value);
-        LOGD("forcing AudioResampler quality to %d", quality);
+        ALOGD("forcing AudioResampler quality to %d", quality);
     }
 
     if (quality == DEFAULT)
@@ -96,15 +96,15 @@
     switch (quality) {
     default:
     case LOW_QUALITY:
-        LOGV("Create linear Resampler");
+        ALOGV("Create linear Resampler");
         resampler = new AudioResamplerOrder1(bitDepth, inChannelCount, sampleRate);
         break;
     case MED_QUALITY:
-        LOGV("Create cubic Resampler");
+        ALOGV("Create cubic Resampler");
         resampler = new AudioResamplerCubic(bitDepth, inChannelCount, sampleRate);
         break;
     case HIGH_QUALITY:
-        LOGV("Create sinc Resampler");
+        ALOGV("Create sinc Resampler");
         resampler = new AudioResamplerSinc(bitDepth, inChannelCount, sampleRate);
         break;
     }
@@ -121,9 +121,9 @@
             mPhaseFraction(0) {
     // sanity check on format
     if ((bitDepth != 16) ||(inChannelCount < 1) || (inChannelCount > 2)) {
-        LOGE("Unsupported sample format, %d bits, %d channels", bitDepth,
+        ALOGE("Unsupported sample format, %d bits, %d channels", bitDepth,
                 inChannelCount);
-        // LOG_ASSERT(0);
+        // ALOG_ASSERT(0);
     }
 
     // initialize common members
@@ -164,7 +164,7 @@
         AudioBufferProvider* provider) {
 
     // should never happen, but we overflow if it does
-    // LOG_ASSERT(outFrameCount < 32767);
+    // ALOG_ASSERT(outFrameCount < 32767);
 
     // select the appropriate resampler
     switch (mChannelCount) {
@@ -190,7 +190,7 @@
     size_t outputSampleCount = outFrameCount * 2;
     size_t inFrameCount = (outFrameCount*mInSampleRate)/mSampleRate;
 
-    // LOGE("starting resample %d frames, inputIndex=%d, phaseFraction=%d, phaseIncrement=%d\n",
+    // ALOGE("starting resample %d frames, inputIndex=%d, phaseFraction=%d, phaseIncrement=%d\n",
     //      outFrameCount, inputIndex, phaseFraction, phaseIncrement);
 
     while (outputIndex < outputSampleCount) {
@@ -203,7 +203,7 @@
                 goto resampleStereo16_exit;
             }
 
-            // LOGE("New buffer fetched: %d frames\n", mBuffer.frameCount);
+            // ALOGE("New buffer fetched: %d frames\n", mBuffer.frameCount);
             if (mBuffer.frameCount > inputIndex) break;
 
             inputIndex -= mBuffer.frameCount;
@@ -217,7 +217,7 @@
 
         // handle boundary case
         while (inputIndex == 0) {
-            // LOGE("boundary case\n");
+            // ALOGE("boundary case\n");
             out[outputIndex++] += vl * Interp(mX0L, in[0], phaseFraction);
             out[outputIndex++] += vr * Interp(mX0R, in[1], phaseFraction);
             Advance(&inputIndex, &phaseFraction, phaseIncrement);
@@ -226,7 +226,7 @@
         }
 
         // process input samples
-        // LOGE("general case\n");
+        // ALOGE("general case\n");
 
 #ifdef ASM_ARM_RESAMP1  // asm optimisation for ResamplerOrder1
         if (inputIndex + 2 < mBuffer.frameCount) {
@@ -248,24 +248,24 @@
             Advance(&inputIndex, &phaseFraction, phaseIncrement);
         }
 
-        // LOGE("loop done - outputIndex=%d, inputIndex=%d\n", outputIndex, inputIndex);
+        // ALOGE("loop done - outputIndex=%d, inputIndex=%d\n", outputIndex, inputIndex);
 
         // if done with buffer, save samples
         if (inputIndex >= mBuffer.frameCount) {
             inputIndex -= mBuffer.frameCount;
 
-            // LOGE("buffer done, new input index %d", inputIndex);
+            // ALOGE("buffer done, new input index %d", inputIndex);
 
             mX0L = mBuffer.i16[mBuffer.frameCount*2-2];
             mX0R = mBuffer.i16[mBuffer.frameCount*2-1];
             provider->releaseBuffer(&mBuffer);
 
             // verify that the releaseBuffer resets the buffer frameCount
-            // LOG_ASSERT(mBuffer.frameCount == 0);
+            // ALOG_ASSERT(mBuffer.frameCount == 0);
         }
     }
 
-    // LOGE("output buffer full - outputIndex=%d, inputIndex=%d\n", outputIndex, inputIndex);
+    // ALOGE("output buffer full - outputIndex=%d, inputIndex=%d\n", outputIndex, inputIndex);
 
 resampleStereo16_exit:
     // save state
@@ -286,7 +286,7 @@
     size_t outputSampleCount = outFrameCount * 2;
     size_t inFrameCount = (outFrameCount*mInSampleRate)/mSampleRate;
 
-    // LOGE("starting resample %d frames, inputIndex=%d, phaseFraction=%d, phaseIncrement=%d\n",
+    // ALOGE("starting resample %d frames, inputIndex=%d, phaseFraction=%d, phaseIncrement=%d\n",
     //      outFrameCount, inputIndex, phaseFraction, phaseIncrement);
     while (outputIndex < outputSampleCount) {
         // buffer is empty, fetch a new one
@@ -298,7 +298,7 @@
                 mPhaseFraction = phaseFraction;
                 goto resampleMono16_exit;
             }
-            // LOGE("New buffer fetched: %d frames\n", mBuffer.frameCount);
+            // ALOGE("New buffer fetched: %d frames\n", mBuffer.frameCount);
             if (mBuffer.frameCount >  inputIndex) break;
 
             inputIndex -= mBuffer.frameCount;
@@ -310,7 +310,7 @@
 
         // handle boundary case
         while (inputIndex == 0) {
-            // LOGE("boundary case\n");
+            // ALOGE("boundary case\n");
             int32_t sample = Interp(mX0L, in[0], phaseFraction);
             out[outputIndex++] += vl * sample;
             out[outputIndex++] += vr * sample;
@@ -320,7 +320,7 @@
         }
 
         // process input samples
-        // LOGE("general case\n");
+        // ALOGE("general case\n");
 
 #ifdef ASM_ARM_RESAMP1  // asm optimisation for ResamplerOrder1
         if (inputIndex + 2 < mBuffer.frameCount) {
@@ -343,23 +343,23 @@
         }
 
 
-        // LOGE("loop done - outputIndex=%d, inputIndex=%d\n", outputIndex, inputIndex);
+        // ALOGE("loop done - outputIndex=%d, inputIndex=%d\n", outputIndex, inputIndex);
 
         // if done with buffer, save samples
         if (inputIndex >= mBuffer.frameCount) {
             inputIndex -= mBuffer.frameCount;
 
-            // LOGE("buffer done, new input index %d", inputIndex);
+            // ALOGE("buffer done, new input index %d", inputIndex);
 
             mX0L = mBuffer.i16[mBuffer.frameCount-1];
             provider->releaseBuffer(&mBuffer);
 
             // verify that the releaseBuffer resets the buffer frameCount
-            // LOG_ASSERT(mBuffer.frameCount == 0);
+            // ALOG_ASSERT(mBuffer.frameCount == 0);
         }
     }
 
-    // LOGE("output buffer full - outputIndex=%d, inputIndex=%d\n", outputIndex, inputIndex);
+    // ALOGE("output buffer full - outputIndex=%d, inputIndex=%d\n", outputIndex, inputIndex);
 
 resampleMono16_exit:
     // save state
@@ -390,6 +390,7 @@
 *       phaseFraction : phase fraction for next interpolation
 *
 *******************************************************************/
+__attribute__((noinline))
 void AudioResamplerOrder1::AsmMono16Loop(int16_t *in, int32_t* maxOutPt, int32_t maxInIdx,
             size_t &outputIndex, int32_t* out, size_t &inputIndex, int32_t vl, int32_t vr,
             uint32_t &phaseFraction, uint32_t phaseIncrement)
@@ -500,6 +501,7 @@
 *       phaseFraction : phase fraction for next interpolation
 *
 *******************************************************************/
+__attribute__((noinline))
 void AudioResamplerOrder1::AsmStereo16Loop(int16_t *in, int32_t* maxOutPt, int32_t maxInIdx,
             size_t &outputIndex, int32_t* out, size_t &inputIndex, int32_t vl, int32_t vr,
             uint32_t &phaseFraction, uint32_t phaseIncrement)
@@ -600,6 +602,5 @@
 
 
 // ----------------------------------------------------------------------------
-}
-; // namespace android
 
+} // namespace android
diff --git a/services/audioflinger/AudioResamplerCubic.cpp b/services/audioflinger/AudioResamplerCubic.cpp
index 4d721f6..47205ba 100644
--- a/services/audioflinger/AudioResamplerCubic.cpp
+++ b/services/audioflinger/AudioResamplerCubic.cpp
@@ -36,7 +36,7 @@
         AudioBufferProvider* provider) {
 
     // should never happen, but we overflow if it does
-    // LOG_ASSERT(outFrameCount < 32767);
+    // ALOG_ASSERT(outFrameCount < 32767);
 
     // select the appropriate resampler
     switch (mChannelCount) {
@@ -68,7 +68,7 @@
         provider->getNextBuffer(&mBuffer);
         if (mBuffer.raw == NULL)
             return;
-        // LOGW("New buffer: offset=%p, frames=%dn", mBuffer.raw, mBuffer.frameCount);
+        // ALOGW("New buffer: offset=%p, frames=%dn", mBuffer.raw, mBuffer.frameCount);
     }
     int16_t *in = mBuffer.i16;
 
@@ -99,7 +99,7 @@
                 if (mBuffer.raw == NULL)
                     goto save_state;  // ugly, but efficient
                 in = mBuffer.i16;
-                // LOGW("New buffer: offset=%p, frames=%d\n", mBuffer.raw, mBuffer.frameCount);
+                // ALOGW("New buffer: offset=%p, frames=%d\n", mBuffer.raw, mBuffer.frameCount);
             }
 
             // advance sample state
@@ -109,7 +109,7 @@
     }
 
 save_state:
-    // LOGW("Done: index=%d, fraction=%u", inputIndex, phaseFraction);
+    // ALOGW("Done: index=%d, fraction=%u", inputIndex, phaseFraction);
     mInputIndex = inputIndex;
     mPhaseFraction = phaseFraction;
 }
@@ -133,7 +133,7 @@
         provider->getNextBuffer(&mBuffer);
         if (mBuffer.raw == NULL)
             return;
-        // LOGW("New buffer: offset=%p, frames=%d\n", mBuffer.raw, mBuffer.frameCount);
+        // ALOGW("New buffer: offset=%p, frames=%d\n", mBuffer.raw, mBuffer.frameCount);
     }
     int16_t *in = mBuffer.i16;
 
@@ -163,7 +163,7 @@
                 provider->getNextBuffer(&mBuffer);
                 if (mBuffer.raw == NULL)
                     goto save_state;  // ugly, but efficient
-                // LOGW("New buffer: offset=%p, frames=%dn", mBuffer.raw, mBuffer.frameCount);
+                // ALOGW("New buffer: offset=%p, frames=%dn", mBuffer.raw, mBuffer.frameCount);
                 in = mBuffer.i16;
             }
 
@@ -173,7 +173,7 @@
     }
 
 save_state:
-    // LOGW("Done: index=%d, fraction=%u", inputIndex, phaseFraction);
+    // ALOGW("Done: index=%d, fraction=%u", inputIndex, phaseFraction);
     mInputIndex = inputIndex;
     mPhaseFraction = phaseFraction;
 }
diff --git a/services/audioflinger/AudioResamplerSinc.cpp b/services/audioflinger/AudioResamplerSinc.cpp
index 9e5e254..d012433 100644
--- a/services/audioflinger/AudioResamplerSinc.cpp
+++ b/services/audioflinger/AudioResamplerSinc.cpp
@@ -284,7 +284,7 @@
 **/
 void AudioResamplerSinc::read(
         int16_t*& impulse, uint32_t& phaseFraction,
-        int16_t const* in, size_t inputIndex)
+        const int16_t* in, size_t inputIndex)
 {
     const uint32_t phaseIndex = phaseFraction >> kNumPhaseBits;
     impulse += CHANNELS;
@@ -302,7 +302,7 @@
 
 template<int CHANNELS>
 void AudioResamplerSinc::filterCoefficient(
-        int32_t& l, int32_t& r, uint32_t phase, int16_t const *samples)
+        int32_t& l, int32_t& r, uint32_t phase, const int16_t *samples)
 {
     // compute the index of the coefficient on the positive side and
     // negative side
@@ -317,9 +317,9 @@
 
     l = 0;
     r = 0;
-    int32_t const* coefs = mFirCoefs;
-    int16_t const *sP = samples;
-    int16_t const *sN = samples+CHANNELS;
+    const int32_t* coefs = mFirCoefs;
+    const int16_t *sP = samples;
+    const int16_t *sN = samples+CHANNELS;
     for (unsigned int i=0 ; i<halfNumCoefs/4 ; i++) {
         interpolate<CHANNELS>(l, r, coefs+indexP, lerpP, sP);
         interpolate<CHANNELS>(l, r, coefs+indexN, lerpN, sN);
@@ -339,13 +339,13 @@
 template<int CHANNELS>
 void AudioResamplerSinc::interpolate(
         int32_t& l, int32_t& r,
-        int32_t const* coefs, int16_t lerp, int16_t const* samples)
+        const int32_t* coefs, int16_t lerp, const int16_t* samples)
 {
     int32_t c0 = coefs[0];
     int32_t c1 = coefs[1];
     int32_t sinc = mulAdd(lerp, (c1-c0)<<1, c0);
     if (CHANNELS == 2) {
-        uint32_t rl = *reinterpret_cast<uint32_t const*>(samples);
+        uint32_t rl = *reinterpret_cast<const uint32_t*>(samples);
         l = mulAddRL(1, rl, sinc, l);
         r = mulAddRL(0, rl, sinc, r);
     } else {
diff --git a/services/audioflinger/AudioResamplerSinc.h b/services/audioflinger/AudioResamplerSinc.h
index e6cb90b..0e1bc44 100644
--- a/services/audioflinger/AudioResamplerSinc.h
+++ b/services/audioflinger/AudioResamplerSinc.h
@@ -44,22 +44,22 @@
 
     template<int CHANNELS>
     inline void filterCoefficient(
-            int32_t& l, int32_t& r, uint32_t phase, int16_t const *samples);
+            int32_t& l, int32_t& r, uint32_t phase, const int16_t *samples);
 
     template<int CHANNELS>
     inline void interpolate(
             int32_t& l, int32_t& r,
-            int32_t const* coefs, int16_t lerp, int16_t const* samples);
+            const int32_t* coefs, int16_t lerp, const int16_t* samples);
 
     template<int CHANNELS>
     inline void read(int16_t*& impulse, uint32_t& phaseFraction,
-            int16_t const* in, size_t inputIndex);
+            const int16_t* in, size_t inputIndex);
 
     int16_t *mState;
     int16_t *mImpulse;
     int16_t *mRingFull;
 
-    int32_t const * mFirCoefs;
+    const int32_t * mFirCoefs;
     static const int32_t mFirCoefsDown[];
     static const int32_t mFirCoefsUp[];
 
diff --git a/services/camera/libcameraservice/CameraHardwareInterface.h b/services/camera/libcameraservice/CameraHardwareInterface.h
index c3ced4c..34087b5 100644
--- a/services/camera/libcameraservice/CameraHardwareInterface.h
+++ b/services/camera/libcameraservice/CameraHardwareInterface.h
@@ -88,21 +88,21 @@
 
     ~CameraHardwareInterface()
     {
-        LOGI("Destroying camera %s", mName.string());
+        ALOGI("Destroying camera %s", mName.string());
         if(mDevice) {
             int rc = mDevice->common.close(&mDevice->common);
             if (rc != OK)
-                LOGE("Could not close camera %s: %d", mName.string(), rc);
+                ALOGE("Could not close camera %s: %d", mName.string(), rc);
         }
     }
 
     status_t initialize(hw_module_t *module)
     {
-        LOGI("Opening camera %s", mName.string());
+        ALOGI("Opening camera %s", mName.string());
         int rc = module->methods->open(module, mName.string(),
                                        (hw_device_t **)&mDevice);
         if (rc != OK) {
-            LOGE("Could not open camera %s: %d", mName.string(), rc);
+            ALOGE("Could not open camera %s: %d", mName.string(), rc);
             return rc;
         }
         initHalPreviewWindow();
@@ -112,12 +112,12 @@
     /** Set the ANativeWindow to which preview frames are sent */
     status_t setPreviewWindow(const sp<ANativeWindow>& buf)
     {
-        LOGV("%s(%s) buf %p", __FUNCTION__, mName.string(), buf.get());
+        ALOGV("%s(%s) buf %p", __FUNCTION__, mName.string(), buf.get());
 
         if (mDevice->ops->set_preview_window) {
             mPreviewWindow = buf;
             mHalPreviewWindow.user = this;
-            LOGV("%s &mHalPreviewWindow %p mHalPreviewWindow.user %p", __FUNCTION__,
+            ALOGV("%s &mHalPreviewWindow %p mHalPreviewWindow.user %p", __FUNCTION__,
                     &mHalPreviewWindow, mHalPreviewWindow.user);
             return mDevice->ops->set_preview_window(mDevice,
                     buf.get() ? &mHalPreviewWindow.nw : 0);
@@ -136,7 +136,7 @@
         mDataCbTimestamp = data_cb_timestamp;
         mCbUser = user;
 
-        LOGV("%s(%s)", __FUNCTION__, mName.string());
+        ALOGV("%s(%s)", __FUNCTION__, mName.string());
 
         if (mDevice->ops->set_callbacks) {
             mDevice->ops->set_callbacks(mDevice,
@@ -159,7 +159,7 @@
      */
     void enableMsgType(int32_t msgType)
     {
-        LOGV("%s(%s)", __FUNCTION__, mName.string());
+        ALOGV("%s(%s)", __FUNCTION__, mName.string());
         if (mDevice->ops->enable_msg_type)
             mDevice->ops->enable_msg_type(mDevice, msgType);
     }
@@ -176,7 +176,7 @@
      */
     void disableMsgType(int32_t msgType)
     {
-        LOGV("%s(%s)", __FUNCTION__, mName.string());
+        ALOGV("%s(%s)", __FUNCTION__, mName.string());
         if (mDevice->ops->disable_msg_type)
             mDevice->ops->disable_msg_type(mDevice, msgType);
     }
@@ -188,7 +188,7 @@
      */
     int msgTypeEnabled(int32_t msgType)
     {
-        LOGV("%s(%s)", __FUNCTION__, mName.string());
+        ALOGV("%s(%s)", __FUNCTION__, mName.string());
         if (mDevice->ops->msg_type_enabled)
             return mDevice->ops->msg_type_enabled(mDevice, msgType);
         return false;
@@ -199,7 +199,7 @@
      */
     status_t startPreview()
     {
-        LOGV("%s(%s)", __FUNCTION__, mName.string());
+        ALOGV("%s(%s)", __FUNCTION__, mName.string());
         if (mDevice->ops->start_preview)
             return mDevice->ops->start_preview(mDevice);
         return INVALID_OPERATION;
@@ -210,7 +210,7 @@
      */
     void stopPreview()
     {
-        LOGV("%s(%s)", __FUNCTION__, mName.string());
+        ALOGV("%s(%s)", __FUNCTION__, mName.string());
         if (mDevice->ops->stop_preview)
             mDevice->ops->stop_preview(mDevice);
     }
@@ -220,7 +220,7 @@
      */
     int previewEnabled()
     {
-        LOGV("%s(%s)", __FUNCTION__, mName.string());
+        ALOGV("%s(%s)", __FUNCTION__, mName.string());
         if (mDevice->ops->preview_enabled)
             return mDevice->ops->preview_enabled(mDevice);
         return false;
@@ -260,7 +260,7 @@
 
     status_t storeMetaDataInBuffers(int enable)
     {
-        LOGV("%s(%s)", __FUNCTION__, mName.string());
+        ALOGV("%s(%s)", __FUNCTION__, mName.string());
         if (mDevice->ops->store_meta_data_in_buffers)
             return mDevice->ops->store_meta_data_in_buffers(mDevice, enable);
         return enable ? INVALID_OPERATION: OK;
@@ -277,7 +277,7 @@
      */
     status_t startRecording()
     {
-        LOGV("%s(%s)", __FUNCTION__, mName.string());
+        ALOGV("%s(%s)", __FUNCTION__, mName.string());
         if (mDevice->ops->start_recording)
             return mDevice->ops->start_recording(mDevice);
         return INVALID_OPERATION;
@@ -288,7 +288,7 @@
      */
     void stopRecording()
     {
-        LOGV("%s(%s)", __FUNCTION__, mName.string());
+        ALOGV("%s(%s)", __FUNCTION__, mName.string());
         if (mDevice->ops->stop_recording)
             mDevice->ops->stop_recording(mDevice);
     }
@@ -298,7 +298,7 @@
      */
     int recordingEnabled()
     {
-        LOGV("%s(%s)", __FUNCTION__, mName.string());
+        ALOGV("%s(%s)", __FUNCTION__, mName.string());
         if (mDevice->ops->recording_enabled)
             return mDevice->ops->recording_enabled(mDevice);
         return false;
@@ -316,7 +316,7 @@
      */
     void releaseRecordingFrame(const sp<IMemory>& mem)
     {
-        LOGV("%s(%s)", __FUNCTION__, mName.string());
+        ALOGV("%s(%s)", __FUNCTION__, mName.string());
         if (mDevice->ops->release_recording_frame) {
             ssize_t offset;
             size_t size;
@@ -333,7 +333,7 @@
      */
     status_t autoFocus()
     {
-        LOGV("%s(%s)", __FUNCTION__, mName.string());
+        ALOGV("%s(%s)", __FUNCTION__, mName.string());
         if (mDevice->ops->auto_focus)
             return mDevice->ops->auto_focus(mDevice);
         return INVALID_OPERATION;
@@ -347,7 +347,7 @@
      */
     status_t cancelAutoFocus()
     {
-        LOGV("%s(%s)", __FUNCTION__, mName.string());
+        ALOGV("%s(%s)", __FUNCTION__, mName.string());
         if (mDevice->ops->cancel_auto_focus)
             return mDevice->ops->cancel_auto_focus(mDevice);
         return INVALID_OPERATION;
@@ -358,7 +358,7 @@
      */
     status_t takePicture()
     {
-        LOGV("%s(%s)", __FUNCTION__, mName.string());
+        ALOGV("%s(%s)", __FUNCTION__, mName.string());
         if (mDevice->ops->take_picture)
             return mDevice->ops->take_picture(mDevice);
         return INVALID_OPERATION;
@@ -370,7 +370,7 @@
      */
     status_t cancelPicture()
     {
-        LOGV("%s(%s)", __FUNCTION__, mName.string());
+        ALOGV("%s(%s)", __FUNCTION__, mName.string());
         if (mDevice->ops->cancel_picture)
             return mDevice->ops->cancel_picture(mDevice);
         return INVALID_OPERATION;
@@ -381,7 +381,7 @@
      * invalid or not supported. */
     status_t setParameters(const CameraParameters &params)
     {
-        LOGV("%s(%s)", __FUNCTION__, mName.string());
+        ALOGV("%s(%s)", __FUNCTION__, mName.string());
         if (mDevice->ops->set_parameters)
             return mDevice->ops->set_parameters(mDevice,
                                                params.flatten().string());
@@ -391,7 +391,7 @@
     /** Return the camera parameters. */
     CameraParameters getParameters() const
     {
-        LOGV("%s(%s)", __FUNCTION__, mName.string());
+        ALOGV("%s(%s)", __FUNCTION__, mName.string());
         CameraParameters parms;
         if (mDevice->ops->get_parameters) {
             char *temp = mDevice->ops->get_parameters(mDevice);
@@ -410,7 +410,7 @@
      */
     status_t sendCommand(int32_t cmd, int32_t arg1, int32_t arg2)
     {
-        LOGV("%s(%s)", __FUNCTION__, mName.string());
+        ALOGV("%s(%s)", __FUNCTION__, mName.string());
         if (mDevice->ops->send_command)
             return mDevice->ops->send_command(mDevice, cmd, arg1, arg2);
         return INVALID_OPERATION;
@@ -421,7 +421,7 @@
      * *not* done in the destructor.
      */
     void release() {
-        LOGV("%s(%s)", __FUNCTION__, mName.string());
+        ALOGV("%s(%s)", __FUNCTION__, mName.string());
         if (mDevice->ops->release)
             mDevice->ops->release(mDevice);
     }
@@ -431,7 +431,7 @@
      */
     status_t dump(int fd, const Vector<String16>& args) const
     {
-        LOGV("%s(%s)", __FUNCTION__, mName.string());
+        ALOGV("%s(%s)", __FUNCTION__, mName.string());
         if (mDevice->ops->dump)
             return mDevice->ops->dump(mDevice, fd);
         return OK; // It's fine if the HAL doesn't implement dump()
@@ -444,7 +444,7 @@
     static void __notify_cb(int32_t msg_type, int32_t ext1,
                             int32_t ext2, void *user)
     {
-        LOGV("%s", __FUNCTION__);
+        ALOGV("%s", __FUNCTION__);
         CameraHardwareInterface *__this =
                 static_cast<CameraHardwareInterface *>(user);
         __this->mNotifyCb(msg_type, ext1, ext2, __this->mCbUser);
@@ -455,12 +455,12 @@
                           camera_frame_metadata_t *metadata,
                           void *user)
     {
-        LOGV("%s", __FUNCTION__);
+        ALOGV("%s", __FUNCTION__);
         CameraHardwareInterface *__this =
                 static_cast<CameraHardwareInterface *>(user);
         sp<CameraHeapMemory> mem(static_cast<CameraHeapMemory *>(data->handle));
         if (index >= mem->mNumBufs) {
-            LOGE("%s: invalid buffer index %d, max allowed is %d", __FUNCTION__,
+            ALOGE("%s: invalid buffer index %d, max allowed is %d", __FUNCTION__,
                  index, mem->mNumBufs);
             return;
         }
@@ -471,7 +471,7 @@
                              const camera_memory_t *data, unsigned index,
                              void *user)
     {
-        LOGV("%s", __FUNCTION__);
+        ALOGV("%s", __FUNCTION__);
         CameraHardwareInterface *__this =
                 static_cast<CameraHardwareInterface *>(user);
         // Start refcounting the heap object from here on.  When the clients
@@ -479,7 +479,7 @@
         // MemoryHeapBase.
         sp<CameraHeapMemory> mem(static_cast<CameraHeapMemory *>(data->handle));
         if (index >= mem->mNumBufs) {
-            LOGE("%s: invalid buffer index %d, max allowed is %d", __FUNCTION__,
+            ALOGE("%s: invalid buffer index %d, max allowed is %d", __FUNCTION__,
                  index, mem->mNumBufs);
             return;
         }
diff --git a/services/camera/libcameraservice/CameraHardwareStub.cpp b/services/camera/libcameraservice/CameraHardwareStub.cpp
index 863f19e..cdfb2f5 100644
--- a/services/camera/libcameraservice/CameraHardwareStub.cpp
+++ b/services/camera/libcameraservice/CameraHardwareStub.cpp
@@ -57,7 +57,7 @@
     p.setPictureFormat(CameraParameters::PIXEL_FORMAT_JPEG);
 
     if (setParameters(p) != NO_ERROR) {
-        LOGE("Failed to set default parameters?!");
+        ALOGE("Failed to set default parameters?!");
     }
 }
 
@@ -70,7 +70,7 @@
 
     int preview_width, preview_height;
     mParameters.getPreviewSize(&preview_width, &preview_height);
-    LOGD("initHeapLocked: preview size=%dx%d", preview_width, preview_height);
+    ALOGD("initHeapLocked: preview size=%dx%d", preview_width, preview_height);
 
     // Note that we enforce yuv420sp in setParameters().
     int how_big = preview_width * preview_height * 3 / 2;
@@ -176,7 +176,7 @@
         uint8_t *frame = ((uint8_t *)base) + offset;
         fakeCamera->getNextFrameAsYuv420(frame);
 
-        //LOGV("previewThread: generated frame to buffer %d", mCurrentPreviewFrame);
+        //ALOGV("previewThread: generated frame to buffer %d", mCurrentPreviewFrame);
 
         // Notify the client of a new frame.
         if (mMsgEnabled & CAMERA_MSG_PREVIEW_FRAME)
@@ -340,20 +340,20 @@
 
     if (strcmp(params.getPreviewFormat(),
         CameraParameters::PIXEL_FORMAT_YUV420SP) != 0) {
-        LOGE("Only yuv420sp preview is supported");
+        ALOGE("Only yuv420sp preview is supported");
         return -1;
     }
 
     if (strcmp(params.getPictureFormat(),
         CameraParameters::PIXEL_FORMAT_JPEG) != 0) {
-        LOGE("Only jpeg still pictures are supported");
+        ALOGE("Only jpeg still pictures are supported");
         return -1;
     }
 
     int w, h;
     params.getPictureSize(&w, &h);
     if (w != kCannedJpegWidth && h != kCannedJpegHeight) {
-        LOGE("Still picture size must be size of canned JPEG (%dx%d)",
+        ALOGE("Still picture size must be size of canned JPEG (%dx%d)",
              kCannedJpegWidth, kCannedJpegHeight);
         return -1;
     }
diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp
index 52d9bf3..06fc708 100644
--- a/services/camera/libcameraservice/CameraService.cpp
+++ b/services/camera/libcameraservice/CameraService.cpp
@@ -47,8 +47,8 @@
 // Use "adb shell dumpsys media.camera -v 1" to change it.
 static volatile int32_t gLogLevel = 0;
 
-#define LOG1(...) LOGD_IF(gLogLevel >= 1, __VA_ARGS__);
-#define LOG2(...) LOGD_IF(gLogLevel >= 2, __VA_ARGS__);
+#define LOG1(...) ALOGD_IF(gLogLevel >= 1, __VA_ARGS__);
+#define LOG2(...) ALOGD_IF(gLogLevel >= 2, __VA_ARGS__);
 
 static void setLogLevel(int level) {
     android_atomic_write(level, &gLogLevel);
@@ -73,7 +73,7 @@
 CameraService::CameraService()
 :mSoundRef(0), mModule(0)
 {
-    LOGI("CameraService started (pid=%d)", getpid());
+    ALOGI("CameraService started (pid=%d)", getpid());
     gCameraService = this;
 }
 
@@ -83,13 +83,13 @@
 
     if (hw_get_module(CAMERA_HARDWARE_MODULE_ID,
                 (const hw_module_t **)&mModule) < 0) {
-        LOGE("Could not load camera HAL module");
+        ALOGE("Could not load camera HAL module");
         mNumberOfCameras = 0;
     }
     else {
         mNumberOfCameras = mModule->get_number_of_cameras();
         if (mNumberOfCameras > MAX_CAMERAS) {
-            LOGE("Number of cameras(%d) > MAX_CAMERAS(%d).",
+            ALOGE("Number of cameras(%d) > MAX_CAMERAS(%d).",
                     mNumberOfCameras, MAX_CAMERAS);
             mNumberOfCameras = MAX_CAMERAS;
         }
@@ -102,7 +102,7 @@
 CameraService::~CameraService() {
     for (int i = 0; i < mNumberOfCameras; i++) {
         if (mBusy[i]) {
-            LOGE("camera %d is still in use in destructor!", i);
+            ALOGE("camera %d is still in use in destructor!", i);
         }
     }
 
@@ -138,13 +138,13 @@
     LOG1("CameraService::connect E (pid %d, id %d)", callingPid, cameraId);
 
     if (!mModule) {
-        LOGE("Camera HAL module not loaded");
+        ALOGE("Camera HAL module not loaded");
         return NULL;
     }
 
     sp<Client> client;
     if (cameraId < 0 || cameraId >= mNumberOfCameras) {
-        LOGE("CameraService::connect X (pid %d) rejected (invalid cameraId %d).",
+        ALOGE("CameraService::connect X (pid %d) rejected (invalid cameraId %d).",
             callingPid, cameraId);
         return NULL;
     }
@@ -153,7 +153,7 @@
     property_get("sys.secpolicy.camera.disabled", value, "0");
     if (strcmp(value, "1") == 0) {
         // Camera is disabled by DevicePolicyManager.
-        LOGI("Camera is disabled. connect X (pid %d) rejected", callingPid);
+        ALOGI("Camera is disabled. connect X (pid %d) rejected", callingPid);
         return NULL;
     }
 
@@ -166,7 +166,7 @@
                     callingPid);
                 return client;
             } else {
-                LOGW("CameraService::connect X (pid %d) rejected (existing client).",
+                ALOGW("CameraService::connect X (pid %d) rejected (existing client).",
                     callingPid);
                 return NULL;
             }
@@ -175,14 +175,14 @@
     }
 
     if (mBusy[cameraId]) {
-        LOGW("CameraService::connect X (pid %d) rejected"
+        ALOGW("CameraService::connect X (pid %d) rejected"
              " (camera %d is still busy).", callingPid, cameraId);
         return NULL;
     }
 
     struct camera_info info;
     if (mModule->get_camera_info(cameraId, &info) != OK) {
-        LOGE("Invalid camera id %d", cameraId);
+        ALOGE("Invalid camera id %d", cameraId);
         return NULL;
     }
 
@@ -253,7 +253,7 @@
                 if (!checkCallingPermission(
                         String16("android.permission.CAMERA"))) {
                     const int uid = getCallingUid();
-                    LOGE("Permission Denial: "
+                    ALOGE("Permission Denial: "
                          "can't use the camera pid=%d, uid=%d", pid, uid);
                     return PERMISSION_DENIED;
                 }
@@ -288,7 +288,7 @@
         mp->setAudioStreamType(AUDIO_STREAM_ENFORCED_AUDIBLE);
         mp->prepare();
     } else {
-        LOGE("Failed to load CameraService sounds: %s", file);
+        ALOGE("Failed to load CameraService sounds: %s", file);
         return NULL;
     }
     return mp;
@@ -351,7 +351,7 @@
 
     // Enable zoom, error, focus, and metadata messages by default
     enableMsgType(CAMERA_MSG_ERROR | CAMERA_MSG_ZOOM | CAMERA_MSG_FOCUS |
-                  CAMERA_MSG_PREVIEW_METADATA);
+                  CAMERA_MSG_PREVIEW_METADATA | CAMERA_MSG_FOCUS_MOVE);
 
     // Callback is disabled by default
     mPreviewCallbackFlag = CAMERA_FRAME_CALLBACK_FLAG_NOOP;
@@ -380,7 +380,7 @@
     int callingPid = getCallingPid();
     if (callingPid == mClientPid) return NO_ERROR;
 
-    LOGW("attempt to use a locked camera from a different process"
+    ALOGW("attempt to use a locked camera from a different process"
          " (old pid %d, new pid %d)", mClientPid, callingPid);
     return EBUSY;
 }
@@ -389,7 +389,7 @@
     status_t result = checkPid();
     if (result != NO_ERROR) return result;
     if (mHardware == 0) {
-        LOGE("attempt to use a camera after disconnect() (pid %d)", getCallingPid());
+        ALOGE("attempt to use a camera after disconnect() (pid %d)", getCallingPid());
         return INVALID_OPERATION;
     }
     return NO_ERROR;
@@ -419,7 +419,7 @@
     status_t result = checkPid();
     if (result == NO_ERROR) {
         if (mHardware->recordingEnabled()) {
-            LOGE("Not allowed to unlock camera during recording.");
+            ALOGE("Not allowed to unlock camera during recording.");
             return INVALID_OPERATION;
         }
         mClientPid = 0;
@@ -438,7 +438,7 @@
     Mutex::Autolock lock(mLock);
 
     if (mClientPid != 0 && checkPid() != NO_ERROR) {
-        LOGW("Tried to connect to a locked camera (old pid %d, new pid %d)",
+        ALOGW("Tried to connect to a locked camera (old pid %d, new pid %d)",
                 mClientPid, callingPid);
         return EBUSY;
     }
@@ -461,7 +461,7 @@
         status_t result = native_window_api_disconnect(window.get(),
                 NATIVE_WINDOW_API_CAMERA);
         if (result != NO_ERROR) {
-            LOGW("native_window_api_disconnect failed: %s (%d)", strerror(-result),
+            ALOGW("native_window_api_disconnect failed: %s (%d)", strerror(-result),
                     result);
         }
     }
@@ -473,7 +473,7 @@
     Mutex::Autolock lock(mLock);
 
     if (checkPid() != NO_ERROR) {
-        LOGW("different client - don't disconnect");
+        ALOGW("different client - don't disconnect");
         return;
     }
 
@@ -526,7 +526,7 @@
     if (window != 0) {
         result = native_window_api_connect(window.get(), NATIVE_WINDOW_API_CAMERA);
         if (result != NO_ERROR) {
-            LOGE("native_window_api_connect failed: %s (%d)", strerror(-result),
+            ALOGE("native_window_api_connect failed: %s (%d)", strerror(-result),
                     result);
             return result;
         }
@@ -624,7 +624,7 @@
             return startPreviewMode();
         case CAMERA_RECORDING_MODE:
             if (mSurface == 0 && mPreviewWindow == 0) {
-                LOGE("mSurface or mPreviewWindow must be set before startRecordingMode.");
+                ALOGE("mSurface or mPreviewWindow must be set before startRecordingMode.");
                 return INVALID_OPERATION;
             }
             return startRecordingMode();
@@ -676,7 +676,7 @@
     mCameraService->playSound(SOUND_RECORDING);
     result = mHardware->startRecording();
     if (result != NO_ERROR) {
-        LOGE("mHardware->startRecording() failed with status %d", result);
+        ALOGE("mHardware->startRecording() failed with status %d", result);
     }
     return result;
 }
@@ -770,7 +770,7 @@
 
     if ((msgType & CAMERA_MSG_RAW_IMAGE) &&
         (msgType & CAMERA_MSG_RAW_IMAGE_NOTIFY)) {
-        LOGE("CAMERA_MSG_RAW_IMAGE and CAMERA_MSG_RAW_IMAGE_NOTIFY"
+        ALOGE("CAMERA_MSG_RAW_IMAGE and CAMERA_MSG_RAW_IMAGE_NOTIFY"
                 " cannot be both enabled");
         return BAD_VALUE;
     }
@@ -831,7 +831,7 @@
         // Disabling shutter sound is not allowed. Deny if the current
         // process is not mediaserver.
         if (getCallingPid() != getpid()) {
-            LOGE("Failed to disable shutter sound. Permission denied (pid %d)", getCallingPid());
+            ALOGE("Failed to disable shutter sound. Permission denied (pid %d)", getCallingPid());
             return PERMISSION_DENIED;
         }
     }
@@ -907,7 +907,7 @@
         }
         usleep(CHECK_MESSAGE_INTERVAL * 1000);
     }
-    LOGW("lockIfMessageWanted(%d): dropped unwanted message", msgType);
+    ALOGW("lockIfMessageWanted(%d): dropped unwanted message", msgType);
     return false;
 }
 
@@ -926,12 +926,12 @@
 
     // The checks below are not necessary and are for debugging only.
     if (client->mCameraService.get() != gCameraService) {
-        LOGE("mismatch service!");
+        ALOGE("mismatch service!");
         return NULL;
     }
 
     if (client->mHardware == 0) {
-        LOGE("mHardware == 0: callback after disconnect()?");
+        ALOGE("mHardware == 0: callback after disconnect()?");
         return NULL;
     }
 
@@ -989,7 +989,7 @@
     if (!client->lockIfMessageWanted(msgType)) return;
 
     if (dataPtr == 0 && metadata == NULL) {
-        LOGE("Null data returned in data callback");
+        ALOGE("Null data returned in data callback");
         client->handleGenericNotify(CAMERA_MSG_ERROR, UNKNOWN_ERROR, 0);
         return;
     }
@@ -1022,7 +1022,7 @@
     if (!client->lockIfMessageWanted(msgType)) return;
 
     if (dataPtr == 0) {
-        LOGE("Null data returned in data with timestamp callback");
+        ALOGE("Null data returned in data with timestamp callback");
         client->handleGenericNotify(CAMERA_MSG_ERROR, UNKNOWN_ERROR, 0);
         return;
     }
@@ -1177,7 +1177,7 @@
         mPreviewBuffer = new MemoryHeapBase(size, 0, NULL);
     }
     if (mPreviewBuffer == 0) {
-        LOGE("failed to allocate space for preview buffer");
+        ALOGE("failed to allocate space for preview buffer");
         mLock.unlock();
         return;
     }
@@ -1187,7 +1187,7 @@
 
     sp<MemoryBase> frame = new MemoryBase(previewBuffer, 0, size);
     if (frame == 0) {
-        LOGE("failed to allocate space for frame callback");
+        ALOGE("failed to allocate space for frame callback");
         mLock.unlock();
         return;
     }
@@ -1213,7 +1213,7 @@
             return HAL_TRANSFORM_FLIP_V | HAL_TRANSFORM_ROT_90;
         }
     }
-    LOGE("Invalid setDisplayOrientation degrees=%d", degrees);
+    ALOGE("Invalid setDisplayOrientation degrees=%d", degrees);
     return -1;
 }
 
diff --git a/services/camera/tests/CameraServiceTest/CameraServiceTest.cpp b/services/camera/tests/CameraServiceTest/CameraServiceTest.cpp
index e390ae2..1055538 100644
--- a/services/camera/tests/CameraServiceTest/CameraServiceTest.cpp
+++ b/services/camera/tests/CameraServiceTest/CameraServiceTest.cpp
@@ -46,7 +46,7 @@
     do { \
         printf(__VA_ARGS__); \
         printf("\n"); \
-        LOGD(__VA_ARGS__); \
+        ALOGD(__VA_ARGS__); \
     } while(0)
 
 void assert_fail(const char *file, int line, const char *func, const char *expr) {
@@ -217,7 +217,7 @@
 
 void MCameraClient::assertTest(OP op, int v1, int v2) {
     if (!test(op, v1, v2)) {
-        LOGE("assertTest failed: op=%d, v1=%d, v2=%d", op, v1, v2);
+        ALOGE("assertTest failed: op=%d, v1=%d, v2=%d", op, v1, v2);
         ASSERT(0);
     }
 }
@@ -797,7 +797,7 @@
         int w, h;
         const char *s = param.get(CameraParameters::KEY_SUPPORTED_PICTURE_SIZES);
         while (getNextSize(&s, &w, &h)) {
-            LOGD("checking picture size %dx%d", w, h);
+            ALOGD("checking picture size %dx%d", w, h);
             checkOnePicture(w, h);
         }
     }
@@ -811,7 +811,7 @@
 
         // Try all flag combinations.
         for (int v = 0; v < 8; v++) {
-            LOGD("TestPreviewCallbackFlag: flag=%d", v);
+            ALOGD("TestPreviewCallbackFlag: flag=%d", v);
             usleep(100000); // sleep a while to clear the in-flight callbacks.
             cc->clearStat();
             c->setPreviewCallbackFlag(v);
@@ -875,7 +875,7 @@
         int w, h;
         const char *s = param.get(CameraParameters::KEY_SUPPORTED_PREVIEW_SIZES);
         while (getNextSize(&s, &w, &h)) {
-            LOGD("checking preview size %dx%d", w, h);
+            ALOGD("checking preview size %dx%d", w, h);
             checkOnePicture(w, h);
         }
     }