am dd4e72b4: am 2295ce2c: Increase bitrate now that other issues have been resolved.

* commit 'dd4e72b44ddb7a1591bd2f81c46d20bb0939e9eb':
  Increase bitrate now that other issues have been resolved.
diff --git a/camera/CameraParameters.cpp b/camera/CameraParameters.cpp
index fd91bf2..d10f2e5 100644
--- a/camera/CameraParameters.cpp
+++ b/camera/CameraParameters.cpp
@@ -90,6 +90,7 @@
 const char CameraParameters::KEY_VIDEO_SNAPSHOT_SUPPORTED[] = "video-snapshot-supported";
 const char CameraParameters::KEY_VIDEO_STABILIZATION[] = "video-stabilization";
 const char CameraParameters::KEY_VIDEO_STABILIZATION_SUPPORTED[] = "video-stabilization-supported";
+const char CameraParameters::KEY_LIGHTFX[] = "light-fx";
 
 const char CameraParameters::TRUE[] = "true";
 const char CameraParameters::FALSE[] = "false";
@@ -167,6 +168,10 @@
 const char CameraParameters::FOCUS_MODE_CONTINUOUS_VIDEO[] = "continuous-video";
 const char CameraParameters::FOCUS_MODE_CONTINUOUS_PICTURE[] = "continuous-picture";
 
+// Values for light fx settings
+const char CameraParameters::LIGHTFX_LOWLIGHT[] = "low-light";
+const char CameraParameters::LIGHTFX_HDR[] = "high-dynamic-range";
+
 CameraParameters::CameraParameters()
                 : mMap()
 {
diff --git a/include/camera/CameraParameters.h b/include/camera/CameraParameters.h
index 5540d32..d521543 100644
--- a/include/camera/CameraParameters.h
+++ b/include/camera/CameraParameters.h
@@ -525,6 +525,10 @@
     // stream and record stabilized videos.
     static const char KEY_VIDEO_STABILIZATION_SUPPORTED[];
 
+    // Supported modes for special effects with light.
+    // Example values: "lowlight,hdr".
+    static const char KEY_LIGHTFX[];
+
     // Value for KEY_ZOOM_SUPPORTED or KEY_SMOOTH_ZOOM_SUPPORTED.
     static const char TRUE[];
     static const char FALSE[];
@@ -664,6 +668,12 @@
     // other modes.
     static const char FOCUS_MODE_CONTINUOUS_PICTURE[];
 
+    // Values for light special effects
+    // Low-light enhancement mode
+    static const char LIGHTFX_LOWLIGHT[];
+    // High-dynamic range mode
+    static const char LIGHTFX_HDR[];
+
 private:
     DefaultKeyedVector<String8,String8>    mMap;
 };
diff --git a/media/libeffects/downmix/Android.mk b/media/libeffects/downmix/Android.mk
index 95ca6fd..3052ad9 100644
--- a/media/libeffects/downmix/Android.mk
+++ b/media/libeffects/downmix/Android.mk
@@ -25,4 +25,6 @@
 
 LOCAL_PRELINK_MODULE := false
 
+LOCAL_CFLAGS += -fvisibility=hidden
+
 include $(BUILD_SHARED_LIBRARY)
diff --git a/media/libeffects/downmix/EffectDownmix.c b/media/libeffects/downmix/EffectDownmix.c
index 5bf052a..f17a6e8 100644
--- a/media/libeffects/downmix/EffectDownmix.c
+++ b/media/libeffects/downmix/EffectDownmix.c
@@ -58,13 +58,13 @@
         NULL /* no process_reverse function, no reference stream needed */
 };
 
+// This is the only symbol that needs to be exported
+__attribute__ ((visibility ("default")))
 audio_effect_library_t AUDIO_EFFECT_LIBRARY_INFO_SYM = {
     tag : AUDIO_EFFECT_LIBRARY_TAG,
     version : EFFECT_LIBRARY_API_VERSION,
     name : "Downmix Library",
     implementor : "The Android Open Source Project",
-    query_num_effects : DownmixLib_QueryNumberEffects,
-    query_effect : DownmixLib_QueryEffect,
     create_effect : DownmixLib_Create,
     release_effect : DownmixLib_Release,
     get_descriptor : DownmixLib_GetDescriptor,
@@ -159,25 +159,6 @@
 
 /*--- Effect Library Interface Implementation ---*/
 
-int32_t DownmixLib_QueryNumberEffects(uint32_t *pNumEffects) {
-    ALOGV("DownmixLib_QueryNumberEffects()");
-    *pNumEffects = kNbEffects;
-    return 0;
-}
-
-int32_t DownmixLib_QueryEffect(uint32_t index, effect_descriptor_t *pDescriptor) {
-    ALOGV("DownmixLib_QueryEffect() index=%d", index);
-    if (pDescriptor == NULL) {
-        return -EINVAL;
-    }
-    if (index >= (uint32_t)kNbEffects) {
-        return -EINVAL;
-    }
-    memcpy(pDescriptor, gDescriptors[index], sizeof(effect_descriptor_t));
-    return 0;
-}
-
-
 int32_t DownmixLib_Create(const effect_uuid_t *uuid,
         int32_t sessionId,
         int32_t ioId,
diff --git a/media/libeffects/downmix/EffectDownmix.h b/media/libeffects/downmix/EffectDownmix.h
index be3ca3f..cb6b957 100644
--- a/media/libeffects/downmix/EffectDownmix.h
+++ b/media/libeffects/downmix/EffectDownmix.h
@@ -65,9 +65,6 @@
  * Effect API
  *------------------------------------
 */
-int32_t DownmixLib_QueryNumberEffects(uint32_t *pNumEffects);
-int32_t DownmixLib_QueryEffect(uint32_t index,
-        effect_descriptor_t *pDescriptor);
 int32_t DownmixLib_Create(const effect_uuid_t *uuid,
         int32_t sessionId,
         int32_t ioId,
diff --git a/media/libeffects/lvm/lib/Android.mk b/media/libeffects/lvm/lib/Android.mk
index f49267e..bb56c75 100644
--- a/media/libeffects/lvm/lib/Android.mk
+++ b/media/libeffects/lvm/lib/Android.mk
@@ -105,8 +105,6 @@
 
 LOCAL_MODULE:= libmusicbundle
 
-
-
 LOCAL_C_INCLUDES += \
     $(LOCAL_PATH)/Eq/lib \
     $(LOCAL_PATH)/Eq/src \
@@ -121,8 +119,12 @@
     $(LOCAL_PATH)/StereoWidening/src \
     $(LOCAL_PATH)/StereoWidening/lib
 
+LOCAL_CFLAGS += -fvisibility=hidden
+
 include $(BUILD_STATIC_LIBRARY)
 
+
+
 # Reverb library
 include $(CLEAR_VARS)
 
@@ -168,12 +170,11 @@
 
 LOCAL_MODULE:= libreverb
 
-
-
 LOCAL_C_INCLUDES += \
     $(LOCAL_PATH)/Reverb/lib \
     $(LOCAL_PATH)/Reverb/src \
     $(LOCAL_PATH)/Common/lib \
     $(LOCAL_PATH)/Common/src
 
+LOCAL_CFLAGS += -fvisibility=hidden
 include $(BUILD_STATIC_LIBRARY)
diff --git a/media/libeffects/lvm/wrapper/Android.mk b/media/libeffects/lvm/wrapper/Android.mk
index 4313424..f1af389 100644
--- a/media/libeffects/lvm/wrapper/Android.mk
+++ b/media/libeffects/lvm/wrapper/Android.mk
@@ -9,28 +9,27 @@
 LOCAL_SRC_FILES:= \
 	Bundle/EffectBundle.cpp
 
+LOCAL_CFLAGS += -fvisibility=hidden
+
 LOCAL_MODULE:= libbundlewrapper
 
 LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/soundfx
 
-
-
 LOCAL_STATIC_LIBRARIES += libmusicbundle
 
 LOCAL_SHARED_LIBRARIES := \
      libcutils \
      libdl
 
-
 LOCAL_C_INCLUDES += \
 	$(LOCAL_PATH)/Bundle \
 	$(LOCAL_PATH)/../lib/Common/lib/ \
 	$(LOCAL_PATH)/../lib/Bundle/lib/ \
 	$(call include-path-for, audio-effects)
 
-
 include $(BUILD_SHARED_LIBRARY)
 
+
 # reverb wrapper
 include $(CLEAR_VARS)
 
@@ -39,12 +38,12 @@
 LOCAL_SRC_FILES:= \
     Reverb/EffectReverb.cpp
 
+LOCAL_CFLAGS += -fvisibility=hidden
+
 LOCAL_MODULE:= libreverbwrapper
 
 LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/soundfx
 
-
-
 LOCAL_STATIC_LIBRARIES += libreverb
 
 LOCAL_SHARED_LIBRARIES := \
diff --git a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
index d706c2d..94b9acf 100644
--- a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
+++ b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
@@ -158,42 +158,6 @@
 int Effect_setEnabled(EffectContext *pContext, bool enabled);
 
 /* Effect Library Interface Implementation */
-extern "C" int EffectQueryNumberEffects(uint32_t *pNumEffects){
-    ALOGV("\n\tEffectQueryNumberEffects start");
-    *pNumEffects = 4;
-    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){
-    ALOGV("\n\tEffectQueryEffect start");
-    ALOGV("\tEffectQueryEffect processing index %d", index);
-
-    if (pDescriptor == NULL){
-        ALOGV("\tLVM_ERROR : EffectQueryEffect was passed NULL pointer");
-        return -EINVAL;
-    }
-    if (index > 3){
-        ALOGV("\tLVM_ERROR : EffectQueryEffect index out of range %d", index);
-        return -ENOENT;
-    }
-    if(index == LVM_BASS_BOOST){
-        ALOGV("\tEffectQueryEffect processing LVM_BASS_BOOST");
-        *pDescriptor = gBassBoostDescriptor;
-    }else if(index == LVM_VIRTUALIZER){
-        ALOGV("\tEffectQueryEffect processing LVM_VIRTUALIZER");
-        *pDescriptor = gVirtualizerDescriptor;
-    } else if(index == LVM_EQUALIZER){
-        ALOGV("\tEffectQueryEffect processing LVM_EQUALIZER");
-        *pDescriptor = gEqualizerDescriptor;
-    } else if(index == LVM_VOLUME){
-        ALOGV("\tEffectQueryEffect processing LVM_VOLUME");
-        *pDescriptor = gVolumeDescriptor;
-    }
-    ALOGV("\tEffectQueryEffect end\n");
-    return 0;
-}     /* end EffectQueryEffect */
 
 extern "C" int EffectCreate(const effect_uuid_t *uuid,
                             int32_t             sessionId,
@@ -3299,13 +3263,13 @@
     NULL,
 };    /* end gLvmEffectInterface */
 
+// This is the only symbol that needs to be exported
+__attribute__ ((visibility ("default")))
 audio_effect_library_t AUDIO_EFFECT_LIBRARY_INFO_SYM = {
     tag : AUDIO_EFFECT_LIBRARY_TAG,
     version : EFFECT_LIBRARY_API_VERSION,
     name : "Effect Bundle Library",
     implementor : "NXP Software Ltd.",
-    query_num_effects : android::EffectQueryNumberEffects,
-    query_effect : android::EffectQueryEffect,
     create_effect : android::EffectCreate,
     release_effect : android::EffectRelease,
     get_descriptor : android::EffectGetDescriptor,
diff --git a/media/libeffects/lvm/wrapper/Reverb/EffectReverb.cpp b/media/libeffects/lvm/wrapper/Reverb/EffectReverb.cpp
index 941d651..87e2c85 100755
--- a/media/libeffects/lvm/wrapper/Reverb/EffectReverb.cpp
+++ b/media/libeffects/lvm/wrapper/Reverb/EffectReverb.cpp
@@ -186,30 +186,6 @@
 int Reverb_LoadPreset       (ReverbContext   *pContext);
 
 /* Effect Library Interface Implementation */
-extern "C" int EffectQueryNumberEffects(uint32_t *pNumEffects){
-    ALOGV("\n\tEffectQueryNumberEffects start");
-    *pNumEffects = sizeof(gDescriptors) / sizeof(const effect_descriptor_t *);
-    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){
-    ALOGV("\n\tEffectQueryEffect start");
-    ALOGV("\tEffectQueryEffect processing index %d", index);
-    if (pDescriptor == NULL){
-        ALOGV("\tLVM_ERROR : EffectQueryEffect was passed NULL pointer");
-        return -EINVAL;
-    }
-    if (index >= sizeof(gDescriptors) / sizeof(const effect_descriptor_t *)) {
-        ALOGV("\tLVM_ERROR : EffectQueryEffect index out of range %d", index);
-        return -ENOENT;
-    }
-    *pDescriptor = *gDescriptors[index];
-    ALOGV("\tEffectQueryEffect end\n");
-    return 0;
-}     /* end EffectQueryEffect */
 
 extern "C" int EffectCreate(const effect_uuid_t *uuid,
                             int32_t             sessionId,
@@ -2170,13 +2146,13 @@
     NULL,
 };    /* end gReverbInterface */
 
+// This is the only symbol that needs to be exported
+__attribute__ ((visibility ("default")))
 audio_effect_library_t AUDIO_EFFECT_LIBRARY_INFO_SYM = {
     tag : AUDIO_EFFECT_LIBRARY_TAG,
     version : EFFECT_LIBRARY_API_VERSION,
     name : "Reverb Library",
     implementor : "NXP Software Ltd.",
-    query_num_effects : android::EffectQueryNumberEffects,
-    query_effect : android::EffectQueryEffect,
     create_effect : android::EffectCreate,
     release_effect : android::EffectRelease,
     get_descriptor : android::EffectGetDescriptor,
diff --git a/media/libeffects/preprocessing/Android.mk b/media/libeffects/preprocessing/Android.mk
index c13b9d4..dfa1711 100755
--- a/media/libeffects/preprocessing/Android.mk
+++ b/media/libeffects/preprocessing/Android.mk
@@ -29,4 +29,6 @@
 LOCAL_SHARED_LIBRARIES += libdl
 endif
 
+LOCAL_CFLAGS += -fvisibility=hidden
+
 include $(BUILD_SHARED_LIBRARY)
diff --git a/media/libeffects/preprocessing/PreProcessing.cpp b/media/libeffects/preprocessing/PreProcessing.cpp
index 597866a..25586e8 100755
--- a/media/libeffects/preprocessing/PreProcessing.cpp
+++ b/media/libeffects/preprocessing/PreProcessing.cpp
@@ -1818,30 +1818,6 @@
 // Effect Library Interface Implementation
 //------------------------------------------------------------------------------
 
-int PreProcessingLib_QueryNumberEffects(uint32_t *pNumEffects)
-{
-    if (PreProc_Init() != 0) {
-        return sInitStatus;
-    }
-    if (pNumEffects == NULL) {
-        return -EINVAL;
-    }
-    *pNumEffects = PREPROC_NUM_EFFECTS;
-    return sInitStatus;
-}
-
-int PreProcessingLib_QueryEffect(uint32_t index, effect_descriptor_t *pDescriptor)
-{
-    if (PreProc_Init() != 0) {
-        return sInitStatus;
-    }
-    if (index >= PREPROC_NUM_EFFECTS) {
-        return -EINVAL;
-    }
-    *pDescriptor = *sDescriptors[index];
-    return 0;
-}
-
 int PreProcessingLib_Create(const effect_uuid_t *uuid,
                             int32_t             sessionId,
                             int32_t             ioId,
@@ -1913,13 +1889,13 @@
     return 0;
 }
 
+// This is the only symbol that needs to be exported
+__attribute__ ((visibility ("default")))
 audio_effect_library_t AUDIO_EFFECT_LIBRARY_INFO_SYM = {
     tag : AUDIO_EFFECT_LIBRARY_TAG,
     version : EFFECT_LIBRARY_API_VERSION,
     name : "Audio Preprocessing Library",
     implementor : "The Android Open Source Project",
-    query_num_effects : PreProcessingLib_QueryNumberEffects,
-    query_effect : PreProcessingLib_QueryEffect,
     create_effect : PreProcessingLib_Create,
     release_effect : PreProcessingLib_Release,
     get_descriptor : PreProcessingLib_GetDescriptor
diff --git a/media/libeffects/testlibs/EffectEqualizer.cpp b/media/libeffects/testlibs/EffectEqualizer.cpp
index 90ebe1f..c35453b 100644
--- a/media/libeffects/testlibs/EffectEqualizer.cpp
+++ b/media/libeffects/testlibs/EffectEqualizer.cpp
@@ -123,23 +123,6 @@
 //--- Effect Library Interface Implementation
 //
 
-extern "C" int EffectQueryNumberEffects(uint32_t *pNumEffects) {
-    *pNumEffects = 1;
-    return 0;
-} /* end EffectQueryNumberEffects */
-
-extern "C" int EffectQueryEffect(uint32_t index,
-                                 effect_descriptor_t *pDescriptor) {
-    if (pDescriptor == NULL) {
-        return -EINVAL;
-    }
-    if (index > 0) {
-        return -EINVAL;
-    }
-    *pDescriptor = gEqualizerDescriptor;
-    return 0;
-} /* end EffectQueryNext */
-
 extern "C" int EffectCreate(const effect_uuid_t *uuid,
                             int32_t sessionId,
                             int32_t ioId,
@@ -771,8 +754,6 @@
     version : EFFECT_LIBRARY_API_VERSION,
     name : "Test Equalizer Library",
     implementor : "The Android Open Source Project",
-    query_num_effects : android::EffectQueryNumberEffects,
-    query_effect : android::EffectQueryEffect,
     create_effect : android::EffectCreate,
     release_effect : android::EffectRelease,
     get_descriptor : android::EffectGetDescriptor,
diff --git a/media/libeffects/testlibs/EffectReverb.c b/media/libeffects/testlibs/EffectReverb.c
index a87a834..c37f392 100644
--- a/media/libeffects/testlibs/EffectReverb.c
+++ b/media/libeffects/testlibs/EffectReverb.c
@@ -94,23 +94,6 @@
 
 /*--- Effect Library Interface Implementation ---*/
 
-int EffectQueryNumberEffects(uint32_t *pNumEffects) {
-    *pNumEffects = sizeof(gDescriptors) / sizeof(const effect_descriptor_t *);
-    return 0;
-}
-
-int EffectQueryEffect(uint32_t index, effect_descriptor_t *pDescriptor) {
-    if (pDescriptor == NULL) {
-        return -EINVAL;
-    }
-    if (index >= sizeof(gDescriptors) / sizeof(const effect_descriptor_t *)) {
-        return -EINVAL;
-    }
-    memcpy(pDescriptor, gDescriptors[index],
-            sizeof(effect_descriptor_t));
-    return 0;
-}
-
 int EffectCreate(const effect_uuid_t *uuid,
         int32_t sessionId,
         int32_t ioId,
@@ -2222,8 +2205,6 @@
     .version = EFFECT_LIBRARY_API_VERSION,
     .name = "Test Equalizer Library",
     .implementor = "The Android Open Source Project",
-    .query_num_effects = EffectQueryNumberEffects,
-    .query_effect = EffectQueryEffect,
     .create_effect = EffectCreate,
     .release_effect = EffectRelease,
     .get_descriptor = EffectGetDescriptor,
diff --git a/media/libeffects/testlibs/EffectReverb.h b/media/libeffects/testlibs/EffectReverb.h
index 1fb14a7..e5248fe 100644
--- a/media/libeffects/testlibs/EffectReverb.h
+++ b/media/libeffects/testlibs/EffectReverb.h
@@ -300,9 +300,6 @@
  * Effect API
  *------------------------------------
 */
-int EffectQueryNumberEffects(uint32_t *pNumEffects);
-int EffectQueryEffect(uint32_t index,
-                      effect_descriptor_t *pDescriptor);
 int EffectCreate(const effect_uuid_t *effectUID,
                  int32_t sessionId,
                  int32_t ioId,
diff --git a/media/libeffects/visualizer/Android.mk b/media/libeffects/visualizer/Android.mk
index 76b5110..49cf4fa 100644
--- a/media/libeffects/visualizer/Android.mk
+++ b/media/libeffects/visualizer/Android.mk
@@ -6,7 +6,7 @@
 LOCAL_SRC_FILES:= \
 	EffectVisualizer.cpp
 
-LOCAL_CFLAGS+= -O2
+LOCAL_CFLAGS+= -O2 -fvisibility=hidden
 
 LOCAL_SHARED_LIBRARIES := \
 	libcutils \
diff --git a/media/libeffects/visualizer/EffectVisualizer.cpp b/media/libeffects/visualizer/EffectVisualizer.cpp
index 44baf93..e7eccf1 100644
--- a/media/libeffects/visualizer/EffectVisualizer.cpp
+++ b/media/libeffects/visualizer/EffectVisualizer.cpp
@@ -177,23 +177,6 @@
 //--- Effect Library Interface Implementation
 //
 
-int VisualizerLib_QueryNumberEffects(uint32_t *pNumEffects) {
-    *pNumEffects = 1;
-    return 0;
-}
-
-int VisualizerLib_QueryEffect(uint32_t index,
-                              effect_descriptor_t *pDescriptor) {
-    if (pDescriptor == NULL) {
-        return -EINVAL;
-    }
-    if (index > 0) {
-        return -EINVAL;
-    }
-    *pDescriptor = gVisualizerDescriptor;
-    return 0;
-}
-
 int VisualizerLib_Create(const effect_uuid_t *uuid,
                          int32_t sessionId,
                          int32_t ioId,
@@ -574,14 +557,13 @@
         NULL,
 };
 
-
+// This is the only symbol that needs to be exported
+__attribute__ ((visibility ("default")))
 audio_effect_library_t AUDIO_EFFECT_LIBRARY_INFO_SYM = {
     tag : AUDIO_EFFECT_LIBRARY_TAG,
     version : EFFECT_LIBRARY_API_VERSION,
     name : "Visualizer Library",
     implementor : "The Android Open Source Project",
-    query_num_effects : VisualizerLib_QueryNumberEffects,
-    query_effect : VisualizerLib_QueryEffect,
     create_effect : VisualizerLib_Create,
     release_effect : VisualizerLib_Release,
     get_descriptor : VisualizerLib_GetDescriptor,
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
index 1ddf775..756e76a 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
+++ b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
@@ -513,8 +513,6 @@
                     }
                 }
             } else if (what == Renderer::kWhatFlushComplete) {
-                CHECK_EQ(what, (int32_t)Renderer::kWhatFlushComplete);
-
                 int32_t audio;
                 CHECK(msg->findInt32("audio", &audio));
 
diff --git a/media/libstagefright/ThrottledSource.cpp b/media/libstagefright/ThrottledSource.cpp
index 348a9d3..7496752 100644
--- a/media/libstagefright/ThrottledSource.cpp
+++ b/media/libstagefright/ThrottledSource.cpp
@@ -31,10 +31,6 @@
     CHECK(mBandwidthLimitBytesPerSecond > 0);
 }
 
-status_t ThrottledSource::initCheck() const {
-    return mSource->initCheck();
-}
-
 ssize_t ThrottledSource::readAt(off64_t offset, void *data, size_t size) {
     Mutex::Autolock autoLock(mLock);
 
@@ -62,17 +58,9 @@
     if (whenUs > nowUs) {
         usleep(whenUs - nowUs);
     }
-
     return n;
 }
 
-status_t ThrottledSource::getSize(off64_t *size) {
-    return mSource->getSize(size);
-}
-
-uint32_t ThrottledSource::flags() {
-    return mSource->flags();
-}
 
 }  // namespace android
 
diff --git a/media/libstagefright/include/ThrottledSource.h b/media/libstagefright/include/ThrottledSource.h
index 7fe7c06..673268b 100644
--- a/media/libstagefright/include/ThrottledSource.h
+++ b/media/libstagefright/include/ThrottledSource.h
@@ -28,18 +28,44 @@
             const sp<DataSource> &source,
             int32_t bandwidthLimitBytesPerSecond);
 
-    virtual status_t initCheck() const;
-
+    // implementation of readAt() that sleeps to achieve the desired max throughput
     virtual ssize_t readAt(off64_t offset, void *data, size_t size);
 
-    virtual status_t getSize(off64_t *size);
-    virtual uint32_t flags();
+    // returns an empty string to prevent callers from using the Uri to construct a new datasource
+    virtual String8 getUri() {
+        return String8();
+    }
+
+    // following methods all call through to the wrapped DataSource's methods
+
+    status_t initCheck() const {
+        return mSource->initCheck();
+    }
+
+    virtual status_t getSize(off64_t *size) {
+        return mSource->getSize(size);
+    }
+
+    virtual uint32_t flags() {
+        return mSource->flags();
+    }
+
+    virtual status_t reconnectAtOffset(off64_t offset) {
+        return mSource->reconnectAtOffset(offset);
+    }
+
+    virtual sp<DecryptHandle> DrmInitialization(const char *mime = NULL) {
+        return mSource->DrmInitialization(mime);
+    }
+
+    virtual void getDrmInfo(sp<DecryptHandle> &handle, DrmManagerClient **client) {
+        mSource->getDrmInfo(handle, client);
+    };
 
     virtual String8 getMIMEType() const {
         return mSource->getMIMEType();
     }
 
-
 private:
     Mutex mLock;
 
diff --git a/media/mediaserver/main_mediaserver.cpp b/media/mediaserver/main_mediaserver.cpp
index 6b1abb1..ddd5b84 100644
--- a/media/mediaserver/main_mediaserver.cpp
+++ b/media/mediaserver/main_mediaserver.cpp
@@ -33,6 +33,7 @@
 
 int main(int argc, char** argv)
 {
+    signal(SIGPIPE, SIG_IGN);
     sp<ProcessState> proc(ProcessState::self());
     sp<IServiceManager> sm = defaultServiceManager();
     ALOGI("ServiceManager: %p", sm.get());
diff --git a/services/audioflinger/Android.mk b/services/audioflinger/Android.mk
index bd9421c..2899953 100644
--- a/services/audioflinger/Android.mk
+++ b/services/audioflinger/Android.mk
@@ -19,11 +19,9 @@
     AudioResampler.cpp.arm      \
     AudioPolicyService.cpp      \
     ServiceUtilities.cpp        \
+	AudioResamplerCubic.cpp.arm \
     AudioResamplerSinc.cpp.arm
 
-# uncomment to enable AudioResampler::MED_QUALITY
-# LOCAL_SRC_FILES += AudioResamplerCubic.cpp.arm
-
 LOCAL_SRC_FILES += StateQueue.cpp
 
 # uncomment for debugging timing problems related to StateQueue::push()
@@ -80,4 +78,27 @@
 
 include $(BUILD_SHARED_LIBRARY)
 
+#
+# build audio resampler test tool
+#
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES:=               \
+	test-resample.cpp 			\
+    AudioResampler.cpp.arm      \
+	AudioResamplerCubic.cpp.arm \
+    AudioResamplerSinc.cpp.arm
+
+LOCAL_SHARED_LIBRARIES := \
+	libdl \
+    libcutils \
+    libutils
+
+LOCAL_MODULE:= test-resample
+
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_EXECUTABLE)
+
+
 include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/services/audioflinger/AudioMixer.cpp b/services/audioflinger/AudioMixer.cpp
index af169d5..e652d14 100644
--- a/services/audioflinger/AudioMixer.cpp
+++ b/services/audioflinger/AudioMixer.cpp
@@ -108,6 +108,8 @@
 
     LocalClock lc;
 
+    pthread_once(&sOnceControl, &sInitRoutine);
+
     mState.enabledTracks= 0;
     mState.needsChanged = 0;
     mState.frameCount   = frameCount;
@@ -121,8 +123,6 @@
     // and mTrackNames is initially 0.  However, leave it here until that's verified.
     track_t* t = mState.tracks;
     for (unsigned i=0 ; i < MAX_NUM_TRACKS ; i++) {
-        // FIXME redundant per track
-        t->localTimeFreq = lc.getLocalFreq();
         t->resampler = NULL;
         t->downmixerBufferProvider = NULL;
         t++;
@@ -192,7 +192,6 @@
         t->sessionId = sessionId;
         // setBufferProvider(name, AudioBufferProvider *) is required before enable(name)
         t->bufferProvider = NULL;
-        t->downmixerBufferProvider = NULL;
         t->buffer.raw = NULL;
         // no initialization needed
         // t->buffer.frameCount
@@ -203,7 +202,7 @@
         // setParameter(name, TRACK, MAIN_BUFFER, mixBuffer) is required before enable(name)
         t->mainBuffer = NULL;
         t->auxBuffer = NULL;
-        // see t->localTimeFreq in constructor above
+        t->downmixerBufferProvider = NULL;
 
         status_t status = initTrackDownmix(&mState.tracks[n], n, channelMask);
         if (status == OK) {
@@ -556,7 +555,7 @@
                         // the resampler sees the number of channels after the downmixer, if any
                         downmixerBufferProvider != NULL ? MAX_NUM_CHANNELS : channelCount,
                         devSampleRate, quality);
-                resampler->setLocalTimeFreq(localTimeFreq);
+                resampler->setLocalTimeFreq(sLocalTimeFreq);
             }
             return true;
         }
@@ -1423,7 +1422,16 @@
     if (AudioBufferProvider::kInvalidPTS == basePTS)
         return AudioBufferProvider::kInvalidPTS;
 
-    return basePTS + ((outputFrameIndex * t.localTimeFreq) / t.sampleRate);
+    return basePTS + ((outputFrameIndex * sLocalTimeFreq) / t.sampleRate);
+}
+
+/*static*/ uint64_t AudioMixer::sLocalTimeFreq;
+/*static*/ pthread_once_t AudioMixer::sOnceControl = PTHREAD_ONCE_INIT;
+
+/*static*/ void AudioMixer::sInitRoutine()
+{
+    LocalClock lc;
+    sLocalTimeFreq = lc.getLocalFreq();
 }
 
 // ----------------------------------------------------------------------------
diff --git a/services/audioflinger/AudioMixer.h b/services/audioflinger/AudioMixer.h
index 6333357..dc468ff 100644
--- a/services/audioflinger/AudioMixer.h
+++ b/services/audioflinger/AudioMixer.h
@@ -188,12 +188,12 @@
 
         // 16-byte boundary
 
-        uint64_t    localTimeFreq;
-
         DownmixerBufferProvider* downmixerBufferProvider; // 4 bytes
 
         int32_t     sessionId;
 
+        int32_t     padding[2];
+
         // 16-byte boundary
 
         bool        setResampler(uint32_t sampleRate, uint32_t devSampleRate);
@@ -274,6 +274,10 @@
 
     static int64_t calculateOutputPTS(const track_t& t, int64_t basePTS,
                                       int outputFrameIndex);
+
+    static uint64_t         sLocalTimeFreq;
+    static pthread_once_t   sOnceControl;
+    static void             sInitRoutine();
 };
 
 // ----------------------------------------------------------------------------
diff --git a/services/audioflinger/AudioResampler.cpp b/services/audioflinger/AudioResampler.cpp
index ffea9b9..2c3c719 100644
--- a/services/audioflinger/AudioResampler.cpp
+++ b/services/audioflinger/AudioResampler.cpp
@@ -82,10 +82,8 @@
     switch (quality) {
     case DEFAULT_QUALITY:
     case LOW_QUALITY:
-#if 0   // these have not been qualified recently so are not supported unless explicitly requested
     case MED_QUALITY:
     case HIGH_QUALITY:
-#endif
     case VERY_HIGH_QUALITY:
         return true;
     default:
@@ -190,12 +188,10 @@
         ALOGV("Create linear Resampler");
         resampler = new AudioResamplerOrder1(bitDepth, inChannelCount, sampleRate);
         break;
-#if 0   // disabled because it has not been qualified recently, if requested will use default:
     case MED_QUALITY:
         ALOGV("Create cubic Resampler");
         resampler = new AudioResamplerCubic(bitDepth, inChannelCount, sampleRate);
         break;
-#endif
     case HIGH_QUALITY:
         ALOGV("Create HIGH_QUALITY sinc Resampler");
         resampler = new AudioResamplerSinc(bitDepth, inChannelCount, sampleRate);
diff --git a/services/audioflinger/AudioResamplerSinc.cpp b/services/audioflinger/AudioResamplerSinc.cpp
index 9e8447a..8dad250 100644
--- a/services/audioflinger/AudioResamplerSinc.cpp
+++ b/services/audioflinger/AudioResamplerSinc.cpp
@@ -31,36 +31,33 @@
 /*
  * These coeficients are computed with the "fir" utility found in
  * tools/resampler_tools
- * TODO: A good optimization would be to transpose this matrix, to take
- * better advantage of the data-cache.
+ * cmd-line: fir -v 0.3 -l 7 -s 48000 -c 20478
  */
 const int32_t AudioResamplerSinc::mFirCoefsUp[] = {
-        0x7fffffff, 0x7f15d078, 0x7c5e0da6, 0x77ecd867, 0x71e2e251, 0x6a6c304a, 0x61be7269, 0x58170412, 0x4db8ab05, 0x42e92ea6, 0x37eee214, 0x2d0e3bb1, 0x22879366, 0x18951e95, 0x0f693d0d, 0x072d2621,
-        0x00000000, 0xf9f66655, 0xf51a5fd7, 0xf16bbd84, 0xeee0d9ac, 0xed67a922, 0xece70de6, 0xed405897, 0xee50e505, 0xeff3be30, 0xf203370f, 0xf45a6741, 0xf6d67d53, 0xf957db66, 0xfbc2f647, 0xfe00f2b9,
-        0x00000000, 0x01b37218, 0x0313a0c6, 0x041d930d, 0x04d28057, 0x053731b0, 0x05534dff, 0x05309bfd, 0x04da440d, 0x045c1aee, 0x03c1fcdd, 0x03173ef5, 0x02663ae8, 0x01b7f736, 0x0113ec79, 0x007fe6a9,
-        0x00000000, 0xff96b229, 0xff44f99f, 0xff0a86be, 0xfee5f803, 0xfed518fd, 0xfed521fd, 0xfee2f4fd, 0xfefb54f8, 0xff1b159b, 0xff3f4203, 0xff6539e0, 0xff8ac502, 0xffae1ddd, 0xffcdf3f9, 0xffe96798,
-        0x00000000, 0x00119de6, 0x001e6b7e, 0x0026cb7a, 0x002b4830, 0x002c83d6, 0x002b2a82, 0x0027e67a, 0x002356f9, 0x001e098e, 0x001875e4, 0x0012fbbe, 0x000de2d1, 0x00095c10, 0x00058414, 0x00026636,
-        0x00000000, 0xfffe44a9, 0xfffd206d, 0xfffc7b7f, 0xfffc3c8f, 0xfffc4ac2, 0xfffc8f2b, 0xfffcf5c4, 0xfffd6df3, 0xfffdeab2, 0xfffe6275, 0xfffececf, 0xffff2c07, 0xffff788c, 0xffffb471, 0xffffe0f2,
-        0x00000000, 0x000013e6, 0x00001f03, 0x00002396, 0x00002399, 0x000020b6, 0x00001c3c, 0x00001722, 0x00001216, 0x00000d81, 0x0000099c, 0x0000067c, 0x00000419, 0x0000025f, 0x00000131, 0x00000070,
-        0x00000000, 0xffffffc7, 0xffffffb3, 0xffffffb3, 0xffffffbe, 0xffffffcd, 0xffffffdb, 0xffffffe7, 0xfffffff0, 0xfffffff7, 0xfffffffb, 0xfffffffe, 0xffffffff, 0x00000000, 0x00000000, 0x00000000,
+        0x7ba78e22, 0x7ba44428, 0x7b9a668f, 0x7b89f654, 0x7b72f51b, 0x7b556530, 0x7b314988, 0x7b06a5be, 0x7ad57e15, 0x7a9dd776, 0x7a5fb76f, 0x7a1b2433, 0x79d0249b, 0x797ec022, 0x7926fee5, 0x78c8e9a4, 0x786489be, 0x77f9e933, 0x7789129f, 0x7712113b, 0x7694f0de, 0x7611bdf6, 0x7588858a, 0x74f95538, 0x74643b33, 0x73c94642, 0x732885bc, 0x72820989, 0x71d5e21d, 0x7124207a, 0x706cd62a, 0x6fb0153e, 0x6eedf04d, 0x6e267a71, 0x6d59c744, 0x6c87eade, 0x6bb0f9d4, 0x6ad50932, 0x69f42e7d, 0x690e7fac, 0x68241328, 0x6734ffca, 0x66415cd4, 0x654941f4, 0x644cc73b, 0x634c051f, 0x62471477, 0x613e0e75, 0x60310ca7, 0x5f2028f0, 0x5e0b7d8a, 0x5cf324fd, 0x5bd73a21, 0x5ab7d815, 0x59951a42, 0x586f1c54, 0x5745fa37, 0x5619d015, 0x54eaba51, 0x53b8d585, 0x52843e7f, 0x514d1239, 0x50136ddd, 0x4ed76ebc, 0x4d99324c, 0x4c58d626, 0x4b167800, 0x49d235ab, 0x488c2d10, 0x47447c2b, 0x45fb410a, 0x44b099c4, 0x4364a47d, 0x42177f5c, 0x40c9488e, 0x3f7a1e3b, 0x3e2a1e87, 0x3cd96790, 0x3b881766, 0x3a364c0b, 0x38e4236f, 0x3791bb6b, 0x363f31c0, 0x34eca410, 0x339a2fe1, 0x3247f291, 0x30f6095c, 0x2fa49150, 0x2e53a752, 0x2d036813, 0x2bb3f012, 0x2a655b9a, 0x2917c6b7, 0x27cb4d3e, 0x26800abf, 0x25361a8c, 0x23ed97ae, 0x22a69ce7, 0x216144ad, 0x201da929, 0x1edbe431, 0x1d9c0f49, 0x1c5e439e, 0x1b229a04, 0x19e92af4, 0x18b20e89, 0x177d5c7e, 0x164b2c2a, 0x151b947f, 0x13eeac09, 0x12c488ea, 0x119d40d7, 0x1078e918, 0x0f579686, 0x0e395d87, 0x0d1e520d, 0x0c068797, 0x0af21128, 0x09e10150, 0x08d36a1f, 0x07c95d2c, 0x06c2eb8e, 0x05c025df, 0x04c11c38, 0x03c5de2f, 0x02ce7ad8, 0x01db00c3, 0x00eb7df9,
+        0x00000000, 0xff1893d3, 0xfe3545e8, 0xfd56222b, 0xfc7b33fd, 0xfba48638, 0xfad22328, 0xfa04148f, 0xf93a63a3, 0xf8751910, 0xf7b43cf2, 0xf6f7d6db, 0xf63fedcf, 0xf58c8845, 0xf4ddac29, 0xf4335ed9, 0xf38da525, 0xf2ec8353, 0xf24ffd1c, 0xf1b815ad, 0xf124cfa8, 0xf0962d24, 0xf00c2fad, 0xef86d846, 0xef06276a, 0xee8a1d0b, 0xee12b892, 0xed9ff8e4, 0xed31dc5f, 0xecc860de, 0xec6383b6, 0xec0341bc, 0xeba79744, 0xeb50801f, 0xeafdf7a4, 0xeaaff8aa, 0xea667d8d, 0xea21802e, 0xe9e0f9f7, 0xe9a4e3da, 0xe96d3654, 0xe939e96d, 0xe90af4be, 0xe8e04f6d, 0xe8b9f032, 0xe897cd5b, 0xe879dcc9, 0xe86013f5, 0xe84a67f4, 0xe838cd74, 0xe82b38c1, 0xe8219dc9, 0xe81bf01a, 0xe81a22e7, 0xe81c290b, 0xe821f507, 0xe82b790b, 0xe838a6f1, 0xe8497046, 0xe85dc648, 0xe87599e9, 0xe890dbd5, 0xe8af7c6e, 0xe8d16bd7, 0xe8f699ee, 0xe91ef654, 0xe94a706f, 0xe978f769, 0xe9aa7a37, 0xe9dee79a, 0xea162e21, 0xea503c2b, 0xea8cffec, 0xeacc676e, 0xeb0e6095, 0xeb52d91e, 0xeb99bea7, 0xebe2fead, 0xec2e8693, 0xec7c439f, 0xeccc2303, 0xed1e11db, 0xed71fd31, 0xedc7d201, 0xee1f7d3a, 0xee78ebc1, 0xeed40a74, 0xef30c62b, 0xef8f0bbd, 0xefeec803, 0xf04fe7d5, 0xf0b25814, 0xf11605a8, 0xf17add82, 0xf1e0cca2, 0xf247c017, 0xf2afa4ff, 0xf3186891, 0xf381f816, 0xf3ec40f2, 0xf45730a4, 0xf4c2b4c9, 0xf52ebb1b, 0xf59b3178, 0xf60805e2, 0xf6752681, 0xf6e281a4, 0xf75005c5, 0xf7bda18b, 0xf82b43c9, 0xf898db86, 0xf90657f7, 0xf973a887, 0xf9e0bcd7, 0xfa4d84bf, 0xfab9f050, 0xfb25efd6, 0xfb9173db, 0xfbfc6d24, 0xfc66ccb9, 0xfcd083e2, 0xfd398428, 0xfda1bf5c, 0xfe092790, 0xfe6faf21, 0xfed548af, 0xff39e729, 0xff9d7dc3,
+        0x00000000, 0x006161ae, 0x00c196e9, 0x0120941c, 0x017e4e00, 0x01dab9a0, 0x0235cc56, 0x028f7bcf, 0x02e7be0b, 0x033e895c, 0x0393d469, 0x03e7962c, 0x0439c5f4, 0x048a5b66, 0x04d94e7c, 0x05269785, 0x05722f29, 0x05bc0e63, 0x06042e86, 0x064a893e, 0x068f1889, 0x06d1d6c1, 0x0712be93, 0x0751cb05, 0x078ef772, 0x07ca3f8d, 0x08039f5e, 0x083b1344, 0x087097f3, 0x08a42a74, 0x08d5c827, 0x09056ebd, 0x09331c3e, 0x095ecf04, 0x098885bc, 0x09b03f66, 0x09d5fb52, 0x09f9b923, 0x0a1b78cb, 0x0a3b3a8a, 0x0a58fef1, 0x0a74c6dd, 0x0a8e9378, 0x0aa66638, 0x0abc40dd, 0x0ad02573, 0x0ae2164c, 0x0af21603, 0x0b00277a, 0x0b0c4dd8, 0x0b168c87, 0x0b1ee736, 0x0b2561d5, 0x0b2a0093, 0x0b2cc7e1, 0x0b2dbc6d, 0x0b2ce320, 0x0b2a411f, 0x0b25dbcb, 0x0b1fb8ba, 0x0b17ddbc, 0x0b0e50d4, 0x0b03183b, 0x0af63a5b, 0x0ae7bdd1, 0x0ad7a969, 0x0ac6041a, 0x0ab2d50d, 0x0a9e2391, 0x0a87f721, 0x0a70575f, 0x0a574c14, 0x0a3cdd2c, 0x0a2112b7, 0x0a03f4e7, 0x09e58c0d, 0x09c5e097, 0x09a4fb12, 0x0982e424, 0x095fa48c, 0x093b4523, 0x0915ced5, 0x08ef4aa5, 0x08c7c1a7, 0x089f3d00, 0x0875c5e5, 0x084b659a, 0x0820256e, 0x07f40ebb, 0x07c72ae4, 0x07998354, 0x076b217a, 0x073c0ecd, 0x070c54c3, 0x06dbfcd7, 0x06ab1080, 0x06799936, 0x0647a06e, 0x06152f96, 0x05e25018, 0x05af0b56, 0x057b6aa7, 0x0547775b, 0x05133ab3, 0x04debde6, 0x04aa0a19, 0x04752865, 0x044021d0, 0x040aff4c, 0x03d5c9ba, 0x03a089e5, 0x036b4882, 0x03360e30, 0x0300e373, 0x02cbd0b8, 0x0296de51, 0x02621472, 0x022d7b36, 0x01f91a98, 0x01c4fa74, 0x01912288, 0x015d9a6f, 0x012a69a6, 0x00f79784, 0x00c52b40, 0x00932be9, 0x0061a06e, 0x00308f96,
+        0x00000000, 0xffcff828, 0xffa07e5f, 0xff7198d0, 0xff434d7c, 0xff15a23b, 0xfee89cbb, 0xfebc4281, 0xfe9098e4, 0xfe65a513, 0xfe3b6c10, 0xfe11f2b0, 0xfde93d9e, 0xfdc15155, 0xfd9a3226, 0xfd73e434, 0xfd4e6b74, 0xfd29cbad, 0xfd06087a, 0xfce32547, 0xfcc12551, 0xfca00ba9, 0xfc7fdb31, 0xfc60969d, 0xfc424073, 0xfc24db0b, 0xfc086890, 0xfbeceafd, 0xfbd26423, 0xfbb8d5a2, 0xfba040ee, 0xfb88a750, 0xfb7209e1, 0xfb5c6990, 0xfb47c71f, 0xfb342324, 0xfb217e0a, 0xfb0fd810, 0xfaff314c, 0xfaef89a9, 0xfae0e0e7, 0xfad3369e, 0xfac68a3e, 0xfabadb0d, 0xfab0282a, 0xfaa6708d, 0xfa9db307, 0xfa95ee44, 0xfa8f20c9, 0xfa8948f7, 0xfa84650c, 0xfa807321, 0xfa7d712d, 0xfa7b5d05, 0xfa7a345d, 0xfa79f4c8, 0xfa7a9bb9, 0xfa7c2684, 0xfa7e925f, 0xfa81dc63, 0xfa86018b, 0xfa8afeb7, 0xfa90d0ac, 0xfa977415, 0xfa9ee582, 0xfaa7216d, 0xfab02435, 0xfab9ea25, 0xfac46f71, 0xfacfb037, 0xfadba883, 0xfae8544b, 0xfaf5af73, 0xfb03b5d1, 0xfb126324, 0xfb21b321, 0xfb31a16a, 0xfb422996, 0xfb53472c, 0xfb64f5a9, 0xfb77307e, 0xfb89f311, 0xfb9d38bf, 0xfbb0fcdb, 0xfbc53ab3, 0xfbd9ed8a, 0xfbef10a2, 0xfc049f32, 0xfc1a9472, 0xfc30eb93, 0xfc479fc5, 0xfc5eac35, 0xfc760c11, 0xfc8dba84, 0xfca5b2bc, 0xfcbdefe8, 0xfcd66d38, 0xfcef25e2, 0xfd08151d, 0xfd213624, 0xfd3a843c, 0xfd53faab, 0xfd6d94c0, 0xfd874dd3, 0xfda12141, 0xfdbb0a73, 0xfdd504da, 0xfdef0bf1, 0xfe091b41, 0xfe232e5a, 0xfe3d40dc, 0xfe574e72, 0xfe7152d5, 0xfe8b49cc, 0xfea52f2d, 0xfebefedd, 0xfed8b4cf, 0xfef24d09, 0xff0bc3a0, 0xff2514ba, 0xff3e3c8f, 0xff57376b, 0xff7001a9, 0xff8897b9, 0xffa0f61e, 0xffb91970, 0xffd0fe58, 0xffe8a197,
+        0x00000000, 0x0017167d, 0x002de20b, 0x00445fc0, 0x005a8cc4, 0x00706659, 0x0085e9d5, 0x009b14a4, 0x00afe44b, 0x00c45665, 0x00d868a3, 0x00ec18cd, 0x00ff64c6, 0x01124a84, 0x0124c816, 0x0136dba4, 0x0148836b, 0x0159bdc2, 0x016a8918, 0x017ae3f0, 0x018acce9, 0x019a42b6, 0x01a94425, 0x01b7d01a, 0x01c5e58e, 0x01d38396, 0x01e0a95a, 0x01ed561d, 0x01f98935, 0x02054211, 0x02108037, 0x021b4343, 0x02258ae6, 0x022f56e9, 0x0238a72b, 0x02417b9e, 0x0249d44b, 0x0251b151, 0x025912e4, 0x025ff949, 0x026664de, 0x026c5612, 0x0271cd69, 0x0276cb79, 0x027b50ed, 0x027f5e80, 0x0282f503, 0x02861556, 0x0288c06b, 0x028af746, 0x028cbafc, 0x028e0cb1, 0x028eed9b, 0x028f5eff, 0x028f6231, 0x028ef893, 0x028e2396, 0x028ce4bb, 0x028b3d8e, 0x02892fa9, 0x0286bcb2, 0x0283e65d, 0x0280ae68, 0x027d169e, 0x027920d3, 0x0274cee6, 0x027022c2, 0x026b1e58, 0x0265c3a6, 0x026014b0, 0x025a1382, 0x0253c232, 0x024d22da, 0x0246379d, 0x023f02a5, 0x0237861f, 0x022fc441, 0x0227bf42, 0x021f7961, 0x0216f4de, 0x020e3400, 0x0205390e, 0x01fc0653, 0x01f29e1c, 0x01e902b9, 0x01df367a, 0x01d53bb1, 0x01cb14ae, 0x01c0c3c5, 0x01b64b47, 0x01abad84, 0x01a0ecce, 0x01960b72, 0x018b0bbd, 0x017feffa, 0x0174ba6f, 0x01696d61, 0x015e0b11, 0x015295be, 0x01470f9f, 0x013b7aea, 0x012fd9cf, 0x01242e78, 0x01187b0c, 0x010cc1a9, 0x01010469, 0x00f54560, 0x00e9869a, 0x00ddca1c, 0x00d211e5, 0x00c65fec, 0x00bab620, 0x00af1668, 0x00a382a2, 0x0097fca6, 0x008c8641, 0x00812137, 0x0075cf45, 0x006a921e, 0x005f6b69, 0x00545cc6, 0x004967cc, 0x003e8e04, 0x0033d0f1, 0x0029320a, 0x001eb2bb, 0x00145466, 0x000a1864,
+        0x00000000, 0xfff60c7d, 0xffec3f11, 0xffe298e9, 0xffd91b25, 0xffcfc6dc, 0xffc69d18, 0xffbd9ed7, 0xffb4cd10, 0xffac28a9, 0xffa3b281, 0xff9b6b6a, 0xff93542b, 0xff8b6d80, 0xff83b819, 0xff7c349b, 0xff74e3a0, 0xff6dc5b6, 0xff66db62, 0xff60251c, 0xff59a351, 0xff535664, 0xff4d3ead, 0xff475c78, 0xff41b008, 0xff3c3995, 0xff36f94b, 0xff31ef4d, 0xff2d1bb4, 0xff287e8e, 0xff2417e0, 0xff1fe7a4, 0xff1bedca, 0xff182a3b, 0xff149cd2, 0xff114566, 0xff0e23c0, 0xff0b37a4, 0xff0880cb, 0xff05fee6, 0xff03b19d, 0xff01988f, 0xfeffb356, 0xfefe0182, 0xfefc829a, 0xfefb3620, 0xfefa1b8d, 0xfef93254, 0xfef879e0, 0xfef7f196, 0xfef798d4, 0xfef76ef3, 0xfef77344, 0xfef7a513, 0xfef803a8, 0xfef88e42, 0xfef9441d, 0xfefa2471, 0xfefb2e6f, 0xfefc6144, 0xfefdbc19, 0xfeff3e14, 0xff00e655, 0xff02b3f9, 0xff04a61b, 0xff06bbd0, 0xff08f42c, 0xff0b4e40, 0xff0dc91a, 0xff1063c5, 0xff131d4a, 0xff15f4b2, 0xff18e902, 0xff1bf93e, 0xff1f2469, 0xff226984, 0xff25c791, 0xff293d8f, 0xff2cca7e, 0xff306d5d, 0xff34252b, 0xff37f0e7, 0xff3bcf91, 0xff3fc028, 0xff43c1ad, 0xff47d321, 0xff4bf386, 0xff5021df, 0xff545d32, 0xff58a483, 0xff5cf6dc, 0xff615345, 0xff65b8ca, 0xff6a267a, 0xff6e9b62, 0xff731697, 0xff77972d, 0xff7c1c3b, 0xff80a4dd, 0xff85302f, 0xff89bd52, 0xff8e4b69, 0xff92d99c, 0xff976715, 0xff9bf301, 0xffa07c94, 0xffa50301, 0xffa98582, 0xffae0354, 0xffb27bb9, 0xffb6edf5, 0xffbb5953, 0xffbfbd1e, 0xffc418ab, 0xffc86b4e, 0xffccb463, 0xffd0f349, 0xffd52763, 0xffd9501b, 0xffdd6cde, 0xffe17d1d, 0xffe5804e, 0xffe975ed, 0xffed5d7b, 0xfff1367b, 0xfff50077, 0xfff8baff, 0xfffc65a4,
+        0x00000000, 0x000389af, 0x00070254, 0x000a6994, 0x000dbf1c, 0x0011029c, 0x001433c8, 0x0017525c, 0x001a5e15, 0x001d56b7, 0x00203c0a, 0x00230ddc, 0x0025cbfd, 0x00287644, 0x002b0c8b, 0x002d8eb2, 0x002ffc9c, 0x00325631, 0x00349b5d, 0x0036cc12, 0x0038e844, 0x003aefed, 0x003ce309, 0x003ec19a, 0x00408ba5, 0x00424134, 0x0043e254, 0x00456f15, 0x0046e78c, 0x00484bd1, 0x00499c00, 0x004ad839, 0x004c009d, 0x004d1552, 0x004e1683, 0x004f045a, 0x004fdf07, 0x0050a6bc, 0x00515bae, 0x0051fe16, 0x00528e2d, 0x00530c30, 0x00537860, 0x0053d2fd, 0x00541c4d, 0x00545496, 0x00547c20, 0x00549337, 0x00549a25, 0x0054913b, 0x005478c8, 0x0054511d, 0x00541a8f, 0x0053d572, 0x0053821b, 0x005320e4, 0x0052b223, 0x00523633, 0x0051ad6f, 0x00511831, 0x005076d8, 0x004fc9bf, 0x004f1144, 0x004e4dc6, 0x004d7fa4, 0x004ca73d, 0x004bc4ef, 0x004ad91c, 0x0049e423, 0x0048e663, 0x0047e03c, 0x0046d20f, 0x0045bc3b, 0x00449f1f, 0x00437b19, 0x0042508a, 0x00411fce, 0x003fe943, 0x003ead47, 0x003d6c34, 0x003c2668, 0x003adc3d, 0x00398e0c, 0x00383c2f, 0x0036e6fd, 0x00358ece, 0x003433f7, 0x0032d6cd, 0x003177a3, 0x003016cc, 0x002eb499, 0x002d5159, 0x002bed5b, 0x002a88ec, 0x00292456, 0x0027bfe5, 0x00265be0, 0x0024f88e, 0x00239636, 0x00223519, 0x0020d57b, 0x001f779c, 0x001e1bbb, 0x001cc214, 0x001b6ae3, 0x001a1661, 0x0018c4c7, 0x0017764a, 0x00162b1e, 0x0014e376, 0x00139f83, 0x00125f73, 0x00112373, 0x000febaf, 0x000eb84f, 0x000d897c, 0x000c5f5b, 0x000b3a10, 0x000a19bc, 0x0008fe81, 0x0007e87c, 0x0006d7cb, 0x0005cc88, 0x0004c6cc, 0x0003c6ae, 0x0002cc45, 0x0001d7a4, 0x0000e8dd,
+        0x00000000, 0xffff1d1d, 0xfffe4040, 0xfffd6975, 0xfffc98c6, 0xfffbce3b, 0xfffb09db, 0xfffa4bab, 0xfff993af, 0xfff8e1e9, 0xfff83659, 0xfff790ff, 0xfff6f1d9, 0xfff658e3, 0xfff5c619, 0xfff53974, 0xfff4b2ed, 0xfff4327c, 0xfff3b816, 0xfff343b1, 0xfff2d541, 0xfff26cb7, 0xfff20a07, 0xfff1ad20, 0xfff155f3, 0xfff1046d, 0xfff0b87e, 0xfff07211, 0xfff03112, 0xffeff56d, 0xffefbf0d, 0xffef8ddb, 0xffef61c0, 0xffef3aa3, 0xffef186e, 0xffeefb07, 0xffeee254, 0xffeece3c, 0xffeebea4, 0xffeeb371, 0xffeeac88, 0xffeea9cc, 0xffeeab22, 0xffeeb06e, 0xffeeb992, 0xffeec671, 0xffeed6ef, 0xffeeeaef, 0xffef0251, 0xffef1cfa, 0xffef3acb, 0xffef5ba6, 0xffef7f6e, 0xffefa605, 0xffefcf4d, 0xffeffb28, 0xfff02979, 0xfff05a22, 0xfff08d05, 0xfff0c207, 0xfff0f909, 0xfff131ef, 0xfff16c9c, 0xfff1a8f3, 0xfff1e6da, 0xfff22634, 0xfff266e6, 0xfff2a8d5, 0xfff2ebe6, 0xfff32fff, 0xfff37506, 0xfff3bae1, 0xfff40178, 0xfff448b2, 0xfff49077, 0xfff4d8b0, 0xfff52144, 0xfff56a1e, 0xfff5b328, 0xfff5fc4b, 0xfff64574, 0xfff68e8c, 0xfff6d782, 0xfff72040, 0xfff768b5, 0xfff7b0ce, 0xfff7f879, 0xfff83fa6, 0xfff88644, 0xfff8cc43, 0xfff91195, 0xfff95629, 0xfff999f3, 0xfff9dce5, 0xfffa1ef2, 0xfffa600e, 0xfffaa02d, 0xfffadf44, 0xfffb1d49, 0xfffb5a32, 0xfffb95f6, 0xfffbd08c, 0xfffc09ec, 0xfffc420e, 0xfffc78ed, 0xfffcae80, 0xfffce2c3, 0xfffd15b1, 0xfffd4744, 0xfffd7779, 0xfffda64c, 0xfffdd3ba, 0xfffdffc0, 0xfffe2a5c, 0xfffe538d, 0xfffe7b51, 0xfffea1a9, 0xfffec693, 0xfffeea11, 0xffff0c22, 0xffff2cc8, 0xffff4c05, 0xffff69db, 0xffff864b, 0xffffa15a, 0xffffbb09, 0xffffd35c, 0xffffea58,
         0x00000000 // this one is needed for lerping the last coefficient
 };
 
 /*
- * These coefficients are optimized for 48KHz -> 44.1KHz (stop-band at 22.050KHz)
- * It's possible to use the above coefficient for any down-sampling
- * at the expense of a slower processing loop (we can interpolate
- * these coefficient from the above by "Stretching" them in time).
+ * These coefficients are optimized for 48KHz -> 44.1KHz
+ * cmd-line: fir -v 0.3 -l 7 -s 48000 -c 16600
  */
 const int32_t AudioResamplerSinc::mFirCoefsDown[] = {
-        0x7fffffff, 0x7f55e46d, 0x7d5b4c60, 0x7a1b4b98, 0x75a7fb14, 0x7019f0bd, 0x698f875a, 0x622bfd59, 0x5a167256, 0x5178cc54, 0x487e8e6c, 0x3f53aae8, 0x36235ad4, 0x2d17047b, 0x245539ab, 0x1c00d540,
-        0x14383e57, 0x0d14d5ca, 0x06aa910b, 0x0107c38b, 0xfc351654, 0xf835abae, 0xf5076b45, 0xf2a37202, 0xf0fe9faa, 0xf00a3bbd, 0xefb4aa81, 0xefea2b05, 0xf0959716, 0xf1a11e83, 0xf2f6f7a0, 0xf481fff4,
-        0xf62e48ce, 0xf7e98ca5, 0xf9a38b4c, 0xfb4e4bfa, 0xfcde456f, 0xfe4a6d30, 0xff8c2fdf, 0x009f5555, 0x0181d393, 0x0233940f, 0x02b62f06, 0x030ca07d, 0x033afa62, 0x03461725, 0x03334f83, 0x030835fa,
-        0x02ca59cc, 0x027f12d1, 0x022b570d, 0x01d39a49, 0x017bb78f, 0x0126e414, 0x00d7aaaf, 0x008feec7, 0x0050f584, 0x001b73e3, 0xffefa063, 0xffcd46ed, 0xffb3ddcd, 0xffa29aaa, 0xff988691, 0xff949066,
-        0xff959d24, 0xff9a959e, 0xffa27195, 0xffac4011, 0xffb72d2b, 0xffc28569, 0xffcdb706, 0xffd85171, 0xffe20364, 0xffea97e9, 0xfff1f2b2, 0xfff80c06, 0xfffcec92, 0x0000a955, 0x00035fd8, 0x000532cf,
-        0x00064735, 0x0006c1f9, 0x0006c62d, 0x000673ba, 0x0005e68f, 0x00053630, 0x000475a3, 0x0003b397, 0x0002fac1, 0x00025257, 0x0001be9e, 0x0001417a, 0x0000dafd, 0x000089eb, 0x00004c28, 0x00001f1d,
-        0x00000000, 0xffffec10, 0xffffe0be, 0xffffdbc5, 0xffffdb39, 0xffffdd8b, 0xffffe182, 0xffffe638, 0xffffeb0a, 0xffffef8f, 0xfffff38b, 0xfffff6e3, 0xfffff993, 0xfffffba6, 0xfffffd30, 0xfffffe4a,
-        0xffffff09, 0xffffff85, 0xffffffd1, 0xfffffffb, 0x0000000f, 0x00000016, 0x00000015, 0x00000012, 0x0000000d, 0x00000009, 0x00000006, 0x00000003, 0x00000002, 0x00000001, 0x00000000, 0x00000000,
+        0x7ba78e22, 0x7ba5ec84, 0x7ba107c0, 0x7b98e016, 0x7b8d75f3, 0x7b7ec9ed, 0x7b6cdcc5, 0x7b57af69, 0x7b3f42f0, 0x7b23989d, 0x7b04b1dc, 0x7ae29047, 0x7abd359f, 0x7a94a3d0, 0x7a68dcf4, 0x7a39e349, 0x7a07b93d, 0x79d26164, 0x7999de7d, 0x795e3370, 0x791f6350, 0x78dd7157, 0x789860e9, 0x78503592, 0x7804f307, 0x77b69d25, 0x776537f2, 0x7710c799, 0x76b95070, 0x765ed6f1, 0x76015fbf, 0x75a0efa2, 0x753d8b88, 0x74d73888, 0x746dfbda, 0x7401dade, 0x7392db19, 0x73210234, 0x72ac55fc, 0x7234dc61, 0x71ba9b77, 0x713d9976, 0x70bddcb7, 0x703b6bb6, 0x6fb64d11, 0x6f2e8786, 0x6ea421f5, 0x6e17235e, 0x6d8792e2, 0x6cf577bf, 0x6c60d954, 0x6bc9bf1f, 0x6b3030bb, 0x6a9435e0, 0x69f5d664, 0x69551a39, 0x68b2096e, 0x680cac2d, 0x67650abb, 0x66bb2d77, 0x660f1cda, 0x6560e178, 0x64b083fb, 0x63fe0d27, 0x634985d8, 0x6292f701, 0x61da69ab, 0x611fe6f5, 0x60637814, 0x5fa52650, 0x5ee4fb09, 0x5e22ffae, 0x5d5f3dc5, 0x5c99bee4, 0x5bd28cb4, 0x5b09b0ee, 0x5a3f355e, 0x597323dc, 0x58a58654, 0x57d666bd, 0x5705cf1d, 0x5633c98a, 0x55606024, 0x548b9d17, 0x53b58a9c, 0x52de32f7, 0x5205a075, 0x512bdd6f, 0x5050f443, 0x4f74ef5c, 0x4e97d929, 0x4db9bc22, 0x4cdaa2c5, 0x4bfa9795, 0x4b19a51b, 0x4a37d5e5, 0x49553484, 0x4871cb8b, 0x478da592, 0x46a8cd31, 0x45c34d02, 0x44dd2f9f, 0x43f67fa3, 0x430f47a7, 0x42279244, 0x413f6a10, 0x4056d99f, 0x3f6deb81, 0x3e84aa43, 0x3d9b206d, 0x3cb15882, 0x3bc75d00, 0x3add385c, 0x39f2f507, 0x39089d69, 0x381e3be1, 0x3733dac8, 0x3649846b, 0x355f430d, 0x347520e7, 0x338b2828, 0x32a162f0, 0x31b7db56, 0x30ce9b63, 0x2fe5ad11, 0x2efd1a4d, 0x2e14ecf6, 0x2d2d2eda,
+        0x2c45e9b9, 0x2b5f2742, 0x2a78f112, 0x299350b7, 0x28ae4fab, 0x27c9f756, 0x26e6510d, 0x26036613, 0x25213f95, 0x243fe6ac, 0x235f645c, 0x227fc196, 0x21a10731, 0x20c33def, 0x1fe66e7e, 0x1f0aa171, 0x1e2fdf44, 0x1d56305d, 0x1c7d9d06, 0x1ba62d74, 0x1acfe9be, 0x19fad9e5, 0x192705ce, 0x18547543, 0x17832ff3, 0x16b33d74, 0x15e4a53c, 0x15176ea9, 0x144ba0f9, 0x13814350, 0x12b85cb4, 0x11f0f40c, 0x112b1024, 0x1066b7a7, 0x0fa3f123, 0x0ee2c308, 0x0e2333a7, 0x0d654930, 0x0ca909b5, 0x0bee7b28, 0x0b35a35b, 0x0a7e8800, 0x09c92ea8, 0x09159cc5, 0x0863d7a5, 0x07b3e479, 0x0705c84e, 0x06598811, 0x05af288c, 0x0506ae68, 0x04601e2e, 0x03bb7c42, 0x0318cce7, 0x02781440, 0x01d9564b, 0x013c96e3, 0x00a1d9c5, 0x00092285, 0xff72749a, 0xfeddd356, 0xfe4b41e8, 0xfdbac35c, 0xfd2c5a9c, 0xfca00a6f, 0xfc15d57a, 0xfb8dbe3c, 0xfb07c716, 0xfa83f243, 0xfa0241db, 0xf982b7d4, 0xf9055602, 0xf88a1e16, 0xf811119e, 0xf79a3206, 0xf7258096, 0xf6b2fe76, 0xf642acab, 0xf5d48c16, 0xf5689d79, 0xf4fee173, 0xf4975880, 0xf43202fb, 0xf3cee11f, 0xf36df305, 0xf30f38a2, 0xf2b2b1d0, 0xf2585e42, 0xf2003d8f, 0xf1aa4f2b, 0xf156926c, 0xf1050685, 0xf0b5aa8d, 0xf0687d78, 0xf01d7e1e, 0xefd4ab35, 0xef8e0357, 0xef4984fd, 0xef072e84, 0xeec6fe2b, 0xee88f210, 0xee4d0839, 0xee133e8a, 0xeddb92ce, 0xeda602b0, 0xed728bc3, 0xed412b7b, 0xed11df32, 0xece4a425, 0xecb97779, 0xec905638, 0xec693d4f, 0xec442995, 0xec2117c5, 0xec000482, 0xebe0ec58, 0xebc3cbb7, 0xeba89efa, 0xeb8f6264, 0xeb781221, 0xeb62aa45, 0xeb4f26ce, 0xeb3d83a7, 0xeb2dbca1, 0xeb1fcd7b, 0xeb13b1df, 0xeb096562, 0xeb00e385, 0xeafa27b6,
+        0xeaf52d50, 0xeaf1ef9d, 0xeaf069d1, 0xeaf09712, 0xeaf27274, 0xeaf5f6fa, 0xeafb1f95, 0xeb01e728, 0xeb0a4886, 0xeb143e74, 0xeb1fc3a7, 0xeb2cd2c7, 0xeb3b666c, 0xeb4b7925, 0xeb5d0571, 0xeb7005c4, 0xeb847485, 0xeb9a4c11, 0xebb186ba, 0xebca1ec8, 0xebe40e77, 0xebff4ffb, 0xec1bdd80, 0xec39b127, 0xec58c50a, 0xec79133d, 0xec9a95ca, 0xecbd46b7, 0xece12000, 0xed061ba0, 0xed2c3388, 0xed5361a8, 0xed7b9fe8, 0xeda4e830, 0xedcf3461, 0xedfa7e5a, 0xee26bff8, 0xee53f315, 0xee82118a, 0xeeb1152e, 0xeee0f7d8, 0xef11b35d, 0xef434193, 0xef759c51, 0xefa8bd6e, 0xefdc9ec2, 0xf0113a28, 0xf046897c, 0xf07c869d, 0xf0b32b6c, 0xf0ea71cf, 0xf12253af, 0xf15acaf8, 0xf193d19c, 0xf1cd6192, 0xf20774d5, 0xf2420568, 0xf27d0d52, 0xf2b886a1, 0xf2f46b6a, 0xf330b5ca, 0xf36d5fe4, 0xf3aa63e4, 0xf3e7bbfe, 0xf4256270, 0xf463517e, 0xf4a18378, 0xf4dff2b7, 0xf51e999d, 0xf55d7297, 0xf59c781d, 0xf5dba4b2, 0xf61af2e4, 0xf65a5d4c, 0xf699de8f, 0xf6d97160, 0xf719107b, 0xf758b6ab, 0xf7985ec9, 0xf7d803b9, 0xf817a06d, 0xf8572fe6, 0xf896ad32, 0xf8d6136d, 0xf9155dc3, 0xf954876c, 0xf9938bb3, 0xf9d265ef, 0xfa111187, 0xfa4f89f3, 0xfa8dcab9, 0xfacbcf70, 0xfb0993bf, 0xfb47135d, 0xfb844a13, 0xfbc133ba, 0xfbfdcc3b, 0xfc3a0f90, 0xfc75f9c7, 0xfcb186fb, 0xfcecb35d, 0xfd277b2d, 0xfd61dabc, 0xfd9bce6f, 0xfdd552bd, 0xfe0e642d, 0xfe46ff5a, 0xfe7f20f1, 0xfeb6c5b1, 0xfeedea6c, 0xff248c06, 0xff5aa776, 0xff9039c5, 0xffc54010, 0xfff9b786, 0x002d9d69, 0x0060ef0e, 0x0093a9dd, 0x00c5cb50, 0x00f750f6, 0x0128386e, 0x01587f6d, 0x018823b9, 0x01b7232d, 0x01e57bb4, 0x02132b4f, 0x02403010, 0x026c881c,
+        0x029831ad, 0x02c32b0d, 0x02ed729c, 0x031706c9, 0x033fe618, 0x03680f20, 0x038f8089, 0x03b63910, 0x03dc3782, 0x04017abf, 0x042601ba, 0x0449cb78, 0x046cd70f, 0x048f23a9, 0x04b0b080, 0x04d17ce2, 0x04f1882b, 0x0510d1cc, 0x052f5947, 0x054d1e2e, 0x056a2024, 0x05865edf, 0x05a1da25, 0x05bc91cb, 0x05d685b9, 0x05efb5e6, 0x0608225b, 0x061fcb2f, 0x0636b08a, 0x064cd2a4, 0x066231c4, 0x0676ce42, 0x068aa883, 0x069dc0fd, 0x06b01833, 0x06c1aeba, 0x06d28532, 0x06e29c4a, 0x06f1f4c2, 0x07008f64, 0x070e6d0a, 0x071b8e9c, 0x0727f50e, 0x0733a162, 0x073e94a5, 0x0748cff4, 0x07525475, 0x075b235d, 0x07633dec, 0x076aa56d, 0x07715b37, 0x077760ae, 0x077cb73f, 0x07816063, 0x07855d9c, 0x0788b07a, 0x078b5a93, 0x078d5d89, 0x078ebb09, 0x078f74c8, 0x078f8c82, 0x078f0401, 0x078ddd14, 0x078c1993, 0x0789bb60, 0x0786c464, 0x0783368e, 0x077f13d8, 0x077a5e41, 0x077517d0, 0x076f4291, 0x0768e09a, 0x0761f403, 0x075a7eef, 0x07528382, 0x074a03e9, 0x07410255, 0x073780fc, 0x072d8219, 0x072307ec, 0x071814ba, 0x070caaca, 0x0700cc69, 0x06f47be7, 0x06e7bb97, 0x06da8dcf, 0x06ccf4e9, 0x06bef340, 0x06b08b35, 0x06a1bf28, 0x0692917b, 0x06830493, 0x06731ad7, 0x0662d6af, 0x06523a82, 0x064148bc, 0x063003c6, 0x061e6e0c, 0x060c89f8, 0x05fa59f5, 0x05e7e06f, 0x05d51fd0, 0x05c21a83, 0x05aed2ef, 0x059b4b7f, 0x05878698, 0x057386a1, 0x055f4dfc, 0x054adf0e, 0x05363c35, 0x052167d0, 0x050c643b, 0x04f733cf, 0x04e1d8e2, 0x04cc55c8, 0x04b6acd2, 0x04a0e04c, 0x048af281, 0x0474e5b7, 0x045ebc2f, 0x0448782a, 0x04321be1, 0x041ba98b, 0x0405235a, 0x03ee8b7b, 0x03d7e417, 0x03c12f51, 0x03aa6f4a,
+        0x0393a61a, 0x037cd5d6, 0x0366008e, 0x034f284c, 0x03384f14, 0x032176e3, 0x030aa1b4, 0x02f3d179, 0x02dd081e, 0x02c64789, 0x02af919c, 0x0298e830, 0x02824d17, 0x026bc220, 0x02554910, 0x023ee3a6, 0x0228939b, 0x02125aa0, 0x01fc3a61, 0x01e63480, 0x01d04a9a, 0x01ba7e44, 0x01a4d10c, 0x018f4478, 0x0179da08, 0x01649334, 0x014f716a, 0x013a7615, 0x0125a295, 0x0110f844, 0x00fc7872, 0x00e8246b, 0x00d3fd70, 0x00c004bc, 0x00ac3b81, 0x0098a2eb, 0x00853c1b, 0x0072082e, 0x005f0837, 0x004c3d40, 0x0039a84d, 0x00274a5a, 0x0015245a, 0x00033739, 0xfff183db, 0xffe00b1b, 0xffcecdcd, 0xffbdccbe, 0xffad08b2, 0xff9c8265, 0xff8c3a8b, 0xff7c31d2, 0xff6c68de, 0xff5ce04c, 0xff4d98b2, 0xff3e929e, 0xff2fce96, 0xff214d18, 0xff130e9b, 0xff05138f, 0xfef75c5b, 0xfee9e960, 0xfedcbaf7, 0xfecfd172, 0xfec32d1a, 0xfeb6ce34, 0xfeaab4fb, 0xfe9ee1a5, 0xfe93545e, 0xfe880d4e, 0xfe7d0c95, 0xfe72524c, 0xfe67de84, 0xfe5db14b, 0xfe53caa3, 0xfe4a2a8d, 0xfe40d0ff, 0xfe37bdec, 0xfe2ef13e, 0xfe266ada, 0xfe1e2a9e, 0xfe163064, 0xfe0e7bfe, 0xfe070d39, 0xfdffe3db, 0xfdf8ffa6, 0xfdf26054, 0xfdec059d, 0xfde5ef30, 0xfde01cb8, 0xfdda8ddc, 0xfdd5423b, 0xfdd03971, 0xfdcb7316, 0xfdc6eeb9, 0xfdc2abe9, 0xfdbeaa2d, 0xfdbae90a, 0xfdb767fd, 0xfdb42681, 0xfdb1240e, 0xfdae6015, 0xfdabda05, 0xfda99147, 0xfda78541, 0xfda5b557, 0xfda420e6, 0xfda2c74b, 0xfda1a7dd, 0xfda0c1f0, 0xfda014d5, 0xfd9f9fdc, 0xfd9f624e, 0xfd9f5b73, 0xfd9f8a91, 0xfd9feeeb, 0xfda087c0, 0xfda1544d, 0xfda253ce, 0xfda3857b, 0xfda4e88a, 0xfda67c31, 0xfda83fa0, 0xfdaa3209, 0xfdac529a, 0xfdaea081, 0xfdb11ae7, 0xfdb3c0f9,
+        0xfdb691dc, 0xfdb98cba, 0xfdbcb0b8, 0xfdbffcfa, 0xfdc370a5, 0xfdc70adc, 0xfdcacac1, 0xfdceaf74, 0xfdd2b818, 0xfdd6e3cc, 0xfddb31b0, 0xfddfa0e4, 0xfde43087, 0xfde8dfb8, 0xfdedad97, 0xfdf29942, 0xfdf7a1d8, 0xfdfcc679, 0xfe020645, 0xfe07605b, 0xfe0cd3dc, 0xfe125fe8, 0xfe1803a3, 0xfe1dbe2d, 0xfe238ea9, 0xfe29743c, 0xfe2f6e0a, 0xfe357b39, 0xfe3b9af0, 0xfe41cc56, 0xfe480e94, 0xfe4e60d6, 0xfe54c246, 0xfe5b3212, 0xfe61af68, 0xfe683978, 0xfe6ecf74, 0xfe75708f, 0xfe7c1bff, 0xfe82d0f9, 0xfe898eb7, 0xfe905473, 0xfe972169, 0xfe9df4d8, 0xfea4ce00, 0xfeabac24, 0xfeb28e88, 0xfeb97473, 0xfec05d2d, 0xfec74803, 0xfece3442, 0xfed5213a, 0xfedc0e3c, 0xfee2fa9f, 0xfee9e5b8, 0xfef0cee2, 0xfef7b579, 0xfefe98db, 0xff05786b, 0xff0c538b, 0xff1329a3, 0xff19fa1b, 0xff20c461, 0xff2787e2, 0xff2e4410, 0xff34f85f, 0xff3ba447, 0xff424740, 0xff48e0c9, 0xff4f705f, 0xff55f586, 0xff5c6fc2, 0xff62de9c, 0xff69419f, 0xff6f9858, 0xff75e258, 0xff7c1f32, 0xff824e7e, 0xff886fd4, 0xff8e82d1, 0xff948714, 0xff9a7c40, 0xffa061f8, 0xffa637e6, 0xffabfdb4, 0xffb1b310, 0xffb757ab, 0xffbceb37, 0xffc26d6c, 0xffc7de03, 0xffcd3cb8, 0xffd28949, 0xffd7c379, 0xffdceb0d, 0xffe1ffcc, 0xffe7017f, 0xffebeff5, 0xfff0cafc, 0xfff59268, 0xfffa460d, 0xfffee5c4, 0x00037166, 0x0007e8d2, 0x000c4be7, 0x00109a87, 0x0014d499, 0x0018fa02, 0x001d0aad, 0x00210688, 0x0024ed80, 0x0028bf89, 0x002c7c95, 0x0030249a, 0x0033b793, 0x00373579, 0x003a9e4b, 0x003df207, 0x004130b0, 0x00445a4a, 0x00476eda, 0x004a6e6a, 0x004d5903, 0x00502eb3, 0x0052ef87, 0x00559b91, 0x005832e3, 0x005ab591, 0x005d23b1,
+        0x005f7d5c, 0x0061c2ac, 0x0063f3bc, 0x006610aa, 0x00681995, 0x006a0e9e, 0x006befe8, 0x006dbd95, 0x006f77cd, 0x00711eb5, 0x0072b277, 0x0074333d, 0x0075a131, 0x0076fc81, 0x0078455a, 0x00797bed, 0x007aa068, 0x007bb2fe, 0x007cb3e3, 0x007da349, 0x007e8166, 0x007f4e6f, 0x00800a9d, 0x0080b626, 0x00815144, 0x0081dc31, 0x00825727, 0x0082c261, 0x00831e1c, 0x00836a95, 0x0083a80a, 0x0083d6b7, 0x0083f6dd, 0x008408bb, 0x00840c91, 0x0084029f, 0x0083eb26, 0x0083c667, 0x008394a4, 0x00835620, 0x00830b1d, 0x0082b3dc, 0x008250a3, 0x0081e1b2, 0x0081674f, 0x0080e1bc, 0x0080513c, 0x007fb615, 0x007f1089, 0x007e60dc, 0x007da752, 0x007ce42f, 0x007c17b7, 0x007b422c, 0x007a63d3, 0x00797cef, 0x00788dc2, 0x00779690, 0x0076979c, 0x00759127, 0x00748375, 0x00736ec6, 0x0072535c, 0x00713179, 0x0070095c, 0x006edb47, 0x006da779, 0x006c6e31, 0x006b2faf, 0x0069ec30, 0x0068a3f3, 0x00675735, 0x00660633, 0x0064b129, 0x00635852, 0x0061fbea, 0x00609c2a, 0x005f394d, 0x005dd38c, 0x005c6b1e, 0x005b003c, 0x0059931c, 0x005823f5, 0x0056b2fc, 0x00554066, 0x0053cc66, 0x00525730, 0x0050e0f6, 0x004f69ea, 0x004df23c, 0x004c7a1d, 0x004b01bb, 0x00498945, 0x004810e8, 0x004698d0, 0x0045212a, 0x0043aa20, 0x004233dd, 0x0040be88, 0x003f4a4b, 0x003dd74c, 0x003c65b3, 0x003af5a4, 0x00398744, 0x00381ab7, 0x0036b020, 0x003547a0, 0x0033e15a, 0x00327d6b, 0x00311bf5, 0x002fbd15, 0x002e60e9, 0x002d078c, 0x002bb11b, 0x002a5db0, 0x00290d66, 0x0027c054, 0x00267693, 0x0025303b, 0x0023ed60, 0x0022ae19, 0x0021727a, 0x00203a97, 0x001f0682, 0x001dd64d, 0x001caa0a, 0x001b81c7, 0x001a5d96,
+        0x00193d84, 0x0018219f, 0x001709f3, 0x0015f68d, 0x0014e779, 0x0013dcc0, 0x0012d66c, 0x0011d487, 0x0010d717, 0x000fde26, 0x000ee9b8, 0x000df9d5, 0x000d0e82, 0x000c27c2, 0x000b459a, 0x000a680d, 0x00098f1d, 0x0008bacc, 0x0007eb1a, 0x00072009, 0x00065999, 0x000597c7, 0x0004da94, 0x000421fc, 0x00036dfd, 0x0002be95, 0x000213be, 0x00016d76, 0x0000cbb6, 0x00002e7a, 0xffff95bc, 0xffff0175, 0xfffe719f, 0xfffde632, 0xfffd5f26, 0xfffcdc72, 0xfffc5e10, 0xfffbe3f4, 0xfffb6e16, 0xfffafc6b, 0xfffa8eea, 0xfffa2588, 0xfff9c039, 0xfff95ef2, 0xfff901a8, 0xfff8a84e, 0xfff852d8, 0xfff8013a, 0xfff7b366, 0xfff7694f, 0xfff722e9, 0xfff6e024, 0xfff6a0f4, 0xfff66549, 0xfff62d17, 0xfff5f84d, 0xfff5c6de, 0xfff598bb, 0xfff56dd4, 0xfff5461a, 0xfff5217e, 0xfff4fff1, 0xfff4e162, 0xfff4c5c3, 0xfff4ad03, 0xfff49712, 0xfff483e1, 0xfff47360, 0xfff4657e, 0xfff45a2c, 0xfff45159, 0xfff44af5, 0xfff446f1, 0xfff4453b, 0xfff445c5, 0xfff4487d, 0xfff44d54, 0xfff4543a, 0xfff45d1e, 0xfff467f1, 0xfff474a4, 0xfff48325, 0xfff49366, 0xfff4a556, 0xfff4b8e7, 0xfff4ce09, 0xfff4e4ad, 0xfff4fcc2, 0xfff5163b, 0xfff53109, 0xfff54d1b, 0xfff56a65, 0xfff588d7, 0xfff5a863, 0xfff5c8fb, 0xfff5ea91, 0xfff60d16, 0xfff6307e, 0xfff654bb, 0xfff679bf, 0xfff69f7d, 0xfff6c5e9, 0xfff6ecf5, 0xfff71495, 0xfff73cbe, 0xfff76562, 0xfff78e75, 0xfff7b7ed, 0xfff7e1be, 0xfff80bdc, 0xfff8363c, 0xfff860d4, 0xfff88b99, 0xfff8b681, 0xfff8e182, 0xfff90c92, 0xfff937a6, 0xfff962b7, 0xfff98dba, 0xfff9b8a7, 0xfff9e376, 0xfffa0e1d, 0xfffa3895, 0xfffa62d5, 0xfffa8cd6, 0xfffab691, 0xfffadfff, 0xfffb0917,
         0x00000000 // this one is needed for lerping the last coefficient
 };
 
diff --git a/services/audioflinger/AudioResamplerSinc.h b/services/audioflinger/AudioResamplerSinc.h
index 25fc025..48bc747 100644
--- a/services/audioflinger/AudioResamplerSinc.h
+++ b/services/audioflinger/AudioResamplerSinc.h
@@ -71,7 +71,7 @@
 
     // ----------------------------------------------------------------------------
     static const int32_t RESAMPLE_FIR_NUM_COEF       = 8;
-    static const int32_t RESAMPLE_FIR_LERP_INT_BITS  = 4;
+    static const int32_t RESAMPLE_FIR_LERP_INT_BITS  = 7;
 
     struct Constants {
         // we have 16 coefs samples per zero-crossing
diff --git a/services/audioflinger/test-resample.cpp b/services/audioflinger/test-resample.cpp
new file mode 100644
index 0000000..a55a32b
--- /dev/null
+++ b/services/audioflinger/test-resample.cpp
@@ -0,0 +1,229 @@
+/*
+ * Copyright (C) 2012 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 "AudioResampler.h"
+#include <media/AudioBufferProvider.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <time.h>
+
+using namespace android;
+
+struct HeaderWav {
+    HeaderWav(size_t size, int nc, int sr, int bits) {
+        strncpy(RIFF, "RIFF", 4);
+        chunkSize = size + sizeof(HeaderWav);
+        strncpy(WAVE, "WAVE", 4);
+        strncpy(fmt,  "fmt ", 4);
+        fmtSize = 16;
+        audioFormat = 1;
+        numChannels = nc;
+        samplesRate = sr;
+        byteRate = sr * numChannels * (bits/8);
+        align = nc*(bits/8);
+        bitsPerSample = bits;
+        strncpy(data, "data", 4);
+        dataSize = size;
+    }
+
+    char RIFF[4];           // RIFF
+    uint32_t chunkSize;     // File size
+    char WAVE[4];        // WAVE
+    char fmt[4];            // fmt\0
+    uint32_t fmtSize;       // fmt size
+    uint16_t audioFormat;   // 1=PCM
+    uint16_t numChannels;   // num channels
+    uint32_t samplesRate;   // sample rate in hz
+    uint32_t byteRate;      // Bps
+    uint16_t align;         // 2=16-bit mono, 4=16-bit stereo
+    uint16_t bitsPerSample; // bits per sample
+    char data[4];           // "data"
+    uint32_t dataSize;      // size
+};
+
+static int usage(const char* name) {
+    fprintf(stderr,"Usage: %s [-p] [-h] [-q <dq|lq|mq|hq|vhq>] [-i <input-sample-rate>] [-o <output-sample-rate>] <input-file> <output-file>\n", name);
+    fprintf(stderr,"-p              - enable profiling\n");
+    fprintf(stderr,"-h              - create wav file\n");
+    fprintf(stderr,"-q              - resampler quality\n");
+    fprintf(stderr,"                  dq  : default quality\n");
+    fprintf(stderr,"                  lq  : low quality\n");
+    fprintf(stderr,"                  mq  : medium quality\n");
+    fprintf(stderr,"                  hq  : high quality\n");
+    fprintf(stderr,"                  vhq : very high quality\n");
+    fprintf(stderr,"-i              - input file sample rate\n");
+    fprintf(stderr,"-o              - output file sample rate\n");
+    return -1;
+}
+
+int main(int argc, char* argv[]) {
+
+    bool profiling = false;
+    bool writeHeader = false;
+    int input_freq = 0;
+    int output_freq = 0;
+    AudioResampler::src_quality quality = AudioResampler::DEFAULT_QUALITY;
+
+    int ch;
+    while ((ch = getopt(argc, argv, "phq:i:o:")) != -1) {
+        switch (ch) {
+        case 'p':
+            profiling = true;
+            break;
+        case 'h':
+            writeHeader = true;
+            break;
+        case 'q':
+            if (!strcmp(optarg, "dq"))
+                quality = AudioResampler::DEFAULT_QUALITY;
+            else if (!strcmp(optarg, "lq"))
+                quality = AudioResampler::LOW_QUALITY;
+            else if (!strcmp(optarg, "mq"))
+                quality = AudioResampler::MED_QUALITY;
+            else if (!strcmp(optarg, "hq"))
+                quality = AudioResampler::HIGH_QUALITY;
+            else if (!strcmp(optarg, "vhq"))
+                quality = AudioResampler::VERY_HIGH_QUALITY;
+            else {
+                usage(argv[0]);
+                return -1;
+            }
+            break;
+        case 'i':
+            input_freq = atoi(optarg);
+            break;
+        case 'o':
+            output_freq = atoi(optarg);
+            break;
+        case '?':
+        default:
+            usage(argv[0]);
+            return -1;
+        }
+    }
+    argc -= optind;
+
+    if (argc != 2) {
+        usage(argv[0]);
+        return -1;
+    }
+
+    argv += optind;
+
+    // ----------------------------------------------------------
+
+    struct stat st;
+    if (stat(argv[0], &st) < 0) {
+        fprintf(stderr, "stat: %s\n", strerror(errno));
+        return -1;
+    }
+
+    int input_fd = open(argv[0], O_RDONLY);
+    if (input_fd < 0) {
+        fprintf(stderr, "open: %s\n", strerror(errno));
+        return -1;
+    }
+
+    size_t input_size = st.st_size;
+    void* input_vaddr = mmap(0, input_size, PROT_READ, MAP_PRIVATE, input_fd,
+            0);
+    if (input_vaddr == MAP_FAILED ) {
+        fprintf(stderr, "mmap: %s\n", strerror(errno));
+        return -1;
+    }
+
+//    printf("input  sample rate: %d Hz\n", input_freq);
+//    printf("output sample rate: %d Hz\n", output_freq);
+//    printf("input mmap: %p, size=%u\n", input_vaddr, input_size);
+
+    // ----------------------------------------------------------
+
+    class Provider: public AudioBufferProvider {
+        int16_t* mAddr;
+        size_t mNumFrames;
+    public:
+        Provider(const void* addr, size_t size) {
+            mAddr = (int16_t*) addr;
+            mNumFrames = size / sizeof(int16_t);
+        }
+        virtual status_t getNextBuffer(Buffer* buffer,
+                int64_t pts = kInvalidPTS) {
+            buffer->frameCount = mNumFrames;
+            buffer->i16 = mAddr;
+            return NO_ERROR;
+        }
+        virtual void releaseBuffer(Buffer* buffer) {
+        }
+    } provider(input_vaddr, input_size);
+
+    size_t output_size = 2 * 2 * ((int64_t) input_size * output_freq)
+            / input_freq;
+    output_size &= ~7; // always stereo, 32-bits
+
+    void* output_vaddr = malloc(output_size);
+    memset(output_vaddr, 0, output_size);
+
+    AudioResampler* resampler = AudioResampler::create(16, 1, output_freq,
+            quality);
+
+    size_t out_frames = output_size/8;
+    resampler->setSampleRate(input_freq);
+    resampler->setVolume(0x1000, 0x1000);
+    resampler->resample((int*) output_vaddr, out_frames, &provider);
+
+    if (profiling) {
+        memset(output_vaddr, 0, output_size);
+        timespec start, end;
+        clock_gettime(CLOCK_MONOTONIC_HR, &start);
+        resampler->resample((int*) output_vaddr, out_frames, &provider);
+        clock_gettime(CLOCK_MONOTONIC_HR, &end);
+        int64_t start_ns = start.tv_sec * 1000000000LL + start.tv_nsec;
+        int64_t end_ns = end.tv_sec * 1000000000LL + end.tv_nsec;
+        int64_t time = end_ns - start_ns;
+        printf("%f Mspl/s\n", out_frames/(time/1e9)/1e6);
+    }
+
+    // down-mix (we just truncate and keep the left channel)
+    int32_t* out = (int32_t*) output_vaddr;
+    int16_t* convert = (int16_t*) malloc(out_frames * sizeof(int16_t));
+    for (size_t i = 0; i < out_frames; i++) {
+        convert[i] = out[i * 2] >> 12;
+    }
+
+    // write output to disk
+    int output_fd = open(argv[1], O_WRONLY | O_CREAT | O_TRUNC,
+            S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+    if (output_fd < 0) {
+        fprintf(stderr, "open: %s\n", strerror(errno));
+        return -1;
+    }
+
+    if (writeHeader) {
+        HeaderWav wav(out_frames*sizeof(int16_t), 1, output_freq, 16);
+        write(output_fd, &wav, sizeof(wav));
+    }
+
+    write(output_fd, convert, out_frames * sizeof(int16_t));
+    close(output_fd);
+
+    return 0;
+}
diff --git a/services/camera/libcameraservice/Android.mk b/services/camera/libcameraservice/Android.mk
index eff47c8..801afe9 100644
--- a/services/camera/libcameraservice/Android.mk
+++ b/services/camera/libcameraservice/Android.mk
@@ -40,6 +40,9 @@
     system/media/camera/include \
     external/jpeg
 
+
+LOCAL_CFLAGS += -Wall -Wextra
+
 LOCAL_MODULE:= libcameraservice
 
 include $(BUILD_SHARED_LIBRARY)
diff --git a/services/camera/libcameraservice/Camera2Client.cpp b/services/camera/libcameraservice/Camera2Client.cpp
index e59a240..9627416 100644
--- a/services/camera/libcameraservice/Camera2Client.cpp
+++ b/services/camera/libcameraservice/Camera2Client.cpp
@@ -37,10 +37,6 @@
     return IPCThreadState::self()->getCallingPid();
 }
 
-static int getCallingUid() {
-    return IPCThreadState::self()->getCallingUid();
-}
-
 // Interface used by CameraService
 
 Camera2Client::Camera2Client(const sp<CameraService>& cameraService,
@@ -370,7 +366,6 @@
 void Camera2Client::disconnect() {
     ATRACE_CALL();
     Mutex::Autolock icl(mICameraLock);
-    status_t res;
 
     // Allow both client and the media server to disconnect at all times
     int callingPid = getCallingPid();
@@ -575,7 +570,7 @@
     ATRACE_CALL();
     ALOGV("%s: Camera %d: Flag 0x%x", __FUNCTION__, mCameraId, flag);
     Mutex::Autolock icl(mICameraLock);
-    status_t res;
+
     if ( checkPid(__FUNCTION__) != OK) return;
 
     SharedParameters::Lock l(mParameters);
@@ -1062,7 +1057,7 @@
     return OK;
 }
 
-status_t Camera2Client::takePicture(int msgType) {
+status_t Camera2Client::takePicture(int /*msgType*/) {
     ATRACE_CALL();
     Mutex::Autolock icl(mICameraLock);
     status_t res;
@@ -1244,7 +1239,7 @@
     return OK;
 }
 
-status_t Camera2Client::commandStartFaceDetectionL(int type) {
+status_t Camera2Client::commandStartFaceDetectionL(int /*type*/) {
     ALOGV("%s: Camera %d: Starting face detection",
           __FUNCTION__, mCameraId);
     status_t res;
@@ -1331,6 +1326,8 @@
 }
 
 void Camera2Client::notifyShutter(int frameNumber, nsecs_t timestamp) {
+    (void)frameNumber;
+    (void)timestamp;
     ALOGV("%s: Shutter notification for frame %d at time %lld", __FUNCTION__,
             frameNumber, timestamp);
 }
@@ -1452,6 +1449,8 @@
 }
 
 void Camera2Client::notifyAutoWhitebalance(uint8_t newState, int triggerId) {
+    (void)newState;
+    (void)triggerId;
     ALOGV("%s: Auto-whitebalance state now %d, last trigger %d",
             __FUNCTION__, newState, triggerId);
 }
diff --git a/services/camera/libcameraservice/Camera2Device.cpp b/services/camera/libcameraservice/Camera2Device.cpp
index d6445c1..5bfa085 100644
--- a/services/camera/libcameraservice/Camera2Device.cpp
+++ b/services/camera/libcameraservice/Camera2Device.cpp
@@ -765,7 +765,6 @@
     ATRACE_CALL();
     ALOGV("%s: E", __FUNCTION__);
     Mutex::Autolock l(mMutex);
-    status_t res;
 
     if (mStreamSlotCount > 0) {
         freeBuffers(mStreamSlot.begin(), mStreamSlot.end());
@@ -785,7 +784,7 @@
 }
 
 status_t Camera2Device::MetadataQueue::dump(int fd,
-        const Vector<String16>& args) {
+        const Vector<String16>& /*args*/) {
     ATRACE_CALL();
     String8 result;
     status_t notLocked;
@@ -894,12 +893,13 @@
 {
     ATRACE_CALL();
     MetadataQueue *queue = getInstance(q);
+    (void)queue;
     free_camera_metadata(old_buffer);
     return OK;
 }
 
 int Camera2Device::MetadataQueue::producer_dequeue(
-        const camera2_frame_queue_dst_ops_t *q,
+        const camera2_frame_queue_dst_ops_t * /*q*/,
         size_t entries, size_t bytes,
         camera_metadata_t **buffer)
 {
@@ -912,7 +912,7 @@
 }
 
 int Camera2Device::MetadataQueue::producer_cancel(
-        const camera2_frame_queue_dst_ops_t *q,
+        const camera2_frame_queue_dst_ops_t * /*q*/,
         camera_metadata_t *old_buffer)
 {
     ATRACE_CALL();
@@ -1184,7 +1184,7 @@
 }
 
 status_t Camera2Device::StreamAdapter::dump(int fd,
-        const Vector<String16>& args) {
+        const Vector<String16>& /*args*/) {
     ATRACE_CALL();
     String8 result = String8::format("      Stream %d: %d x %d, format 0x%x\n",
             mId, mWidth, mHeight, mFormat);
@@ -1423,7 +1423,7 @@
 }
 
 status_t Camera2Device::ReprocessStreamAdapter::dump(int fd,
-        const Vector<String16>& args) {
+        const Vector<String16>& /*args*/) {
     ATRACE_CALL();
     String8 result =
             String8::format("      Reprocess stream %d: %d x %d, fmt 0x%x\n",
@@ -1444,7 +1444,7 @@
     const camera2_stream_in_ops_t *w,
         buffer_handle_t** buffer) {
     ATRACE_CALL();
-    int res;
+
     ReprocessStreamAdapter* stream =
             const_cast<ReprocessStreamAdapter*>(
                 static_cast<const ReprocessStreamAdapter*>(w));
diff --git a/services/camera/libcameraservice/CameraClient.cpp b/services/camera/libcameraservice/CameraClient.cpp
index b930c02..006a9c9 100644
--- a/services/camera/libcameraservice/CameraClient.cpp
+++ b/services/camera/libcameraservice/CameraClient.cpp
@@ -34,10 +34,6 @@
     return IPCThreadState::self()->getCallingPid();
 }
 
-static int getCallingUid() {
-    return IPCThreadState::self()->getCallingUid();
-}
-
 CameraClient::CameraClient(const sp<CameraService>& cameraService,
         const sp<ICameraClient>& cameraClient,
         int cameraId, int cameraFacing, int clientPid, int servicePid):
diff --git a/services/camera/libcameraservice/CameraHardwareInterface.h b/services/camera/libcameraservice/CameraHardwareInterface.h
index 05ac9fa..167b37c 100644
--- a/services/camera/libcameraservice/CameraHardwareInterface.h
+++ b/services/camera/libcameraservice/CameraHardwareInterface.h
@@ -427,7 +427,7 @@
     /**
      * Dump state of the camera hardware
      */
-    status_t dump(int fd, const Vector<String16>& args) const
+    status_t dump(int fd, const Vector<String16>& /*args*/) const
     {
         ALOGV("%s(%s)", __FUNCTION__, mName.string());
         if (mDevice->ops->dump)
@@ -584,9 +584,10 @@
 #endif
 
     static int __lock_buffer(struct preview_stream_ops* w,
-                      buffer_handle_t* buffer)
+                      buffer_handle_t* /*buffer*/)
     {
         ANativeWindow *a = anw(w);
+        (void)a;
         return 0;
     }
 
diff --git a/services/camera/libcameraservice/camera2/BurstCapture.cpp b/services/camera/libcameraservice/camera2/BurstCapture.cpp
index f56c50c..192d419 100644
--- a/services/camera/libcameraservice/camera2/BurstCapture.cpp
+++ b/services/camera/libcameraservice/camera2/BurstCapture.cpp
@@ -38,7 +38,8 @@
 BurstCapture::~BurstCapture() {
 }
 
-status_t BurstCapture::start(Vector<CameraMetadata> &metadatas, int32_t firstCaptureId) {
+status_t BurstCapture::start(Vector<CameraMetadata> &/*metadatas*/,
+                             int32_t /*firstCaptureId*/) {
     ALOGE("Not completely implemented");
     return INVALID_OPERATION;
 }
@@ -75,7 +76,7 @@
 
 CpuConsumer::LockedBuffer* BurstCapture::jpegEncode(
     CpuConsumer::LockedBuffer *imgBuffer,
-    int quality)
+    int /*quality*/)
 {
     ALOGV("%s", __FUNCTION__);
 
@@ -91,7 +92,7 @@
     buffers.push_back(imgEncoded);
 
     sp<JpegCompressor> jpeg = new JpegCompressor();
-    status_t res = jpeg->start(buffers, 1);
+    jpeg->start(buffers, 1);
 
     bool success = jpeg->waitForDone(10 * 1e9);
     if(success) {
@@ -103,7 +104,7 @@
     }
 }
 
-status_t BurstCapture::processFrameAvailable(sp<Camera2Client> &client) {
+status_t BurstCapture::processFrameAvailable(sp<Camera2Client> &/*client*/) {
     ALOGE("Not implemented");
     return INVALID_OPERATION;
 }
diff --git a/services/camera/libcameraservice/camera2/CallbackProcessor.cpp b/services/camera/libcameraservice/camera2/CallbackProcessor.cpp
index 3e9c255..307cfab 100644
--- a/services/camera/libcameraservice/camera2/CallbackProcessor.cpp
+++ b/services/camera/libcameraservice/camera2/CallbackProcessor.cpp
@@ -119,7 +119,6 @@
 
 status_t CallbackProcessor::deleteStream() {
     ATRACE_CALL();
-    status_t res;
 
     Mutex::Autolock l(mInputMutex);
 
@@ -144,7 +143,7 @@
     return mCallbackStreamId;
 }
 
-void CallbackProcessor::dump(int fd, const Vector<String16>& args) const {
+void CallbackProcessor::dump(int /*fd*/, const Vector<String16>& /*args*/) const {
 }
 
 bool CallbackProcessor::threadLoop() {
@@ -173,7 +172,6 @@
     ATRACE_CALL();
     status_t res;
 
-    int callbackHeapId;
     sp<Camera2Heap> callbackHeap;
     size_t heapIdx;
 
diff --git a/services/camera/libcameraservice/camera2/CaptureSequencer.cpp b/services/camera/libcameraservice/camera2/CaptureSequencer.cpp
index fe4abc0..b228faf 100644
--- a/services/camera/libcameraservice/camera2/CaptureSequencer.cpp
+++ b/services/camera/libcameraservice/camera2/CaptureSequencer.cpp
@@ -128,7 +128,7 @@
 }
 
 
-void CaptureSequencer::dump(int fd, const Vector<String16>& args) {
+void CaptureSequencer::dump(int fd, const Vector<String16>& /*args*/) {
     String8 result;
     if (mCaptureRequest.entryCount() != 0) {
         result = "    Capture request:\n";
@@ -182,7 +182,6 @@
 };
 
 bool CaptureSequencer::threadLoop() {
-    status_t res;
 
     sp<Camera2Client> client = mClient.promote();
     if (client == 0) return false;
@@ -213,7 +212,8 @@
     return true;
 }
 
-CaptureSequencer::CaptureState CaptureSequencer::manageIdle(sp<Camera2Client> &client) {
+CaptureSequencer::CaptureState CaptureSequencer::manageIdle(
+        sp<Camera2Client> &/*client*/) {
     status_t res;
     Mutex::Autolock l(mInputMutex);
     while (!mStartCapture) {
@@ -350,13 +350,13 @@
 }
 
 CaptureSequencer::CaptureState CaptureSequencer::manageZslWaiting(
-        sp<Camera2Client> &client) {
+        sp<Camera2Client> &/*client*/) {
     ALOGV("%s", __FUNCTION__);
     return DONE;
 }
 
 CaptureSequencer::CaptureState CaptureSequencer::manageZslReprocessing(
-        sp<Camera2Client> &client) {
+        sp<Camera2Client> &/*client*/) {
     ALOGV("%s", __FUNCTION__);
     return START;
 }
@@ -378,7 +378,7 @@
 }
 
 CaptureSequencer::CaptureState CaptureSequencer::manageStandardPrecaptureWait(
-        sp<Camera2Client> &client) {
+        sp<Camera2Client> &/*client*/) {
     status_t res;
     ATRACE_CALL();
     Mutex::Autolock l(mInputMutex);
@@ -578,7 +578,7 @@
 }
 
 CaptureSequencer::CaptureState CaptureSequencer::manageBurstCaptureWait(
-        sp<Camera2Client> &client) {
+        sp<Camera2Client> &/*client*/) {
     status_t res;
     ATRACE_CALL();
 
diff --git a/services/camera/libcameraservice/camera2/FrameProcessor.cpp b/services/camera/libcameraservice/camera2/FrameProcessor.cpp
index 064607c..e032522 100644
--- a/services/camera/libcameraservice/camera2/FrameProcessor.cpp
+++ b/services/camera/libcameraservice/camera2/FrameProcessor.cpp
@@ -62,7 +62,7 @@
     return OK;
 }
 
-void FrameProcessor::dump(int fd, const Vector<String16>& args) {
+void FrameProcessor::dump(int fd, const Vector<String16>& /*args*/) {
     String8 result("    Latest received frame:\n");
     write(fd, result.string(), result.size());
     mLastFrame.dump(fd, 2, 6);
@@ -128,7 +128,6 @@
 
 status_t FrameProcessor::processListeners(const CameraMetadata &frame,
         sp<Camera2Client> &client) {
-    status_t res;
     ATRACE_CALL();
     camera_metadata_ro_entry_t entry;
 
@@ -173,7 +172,7 @@
     ATRACE_CALL();
     camera_metadata_ro_entry_t entry;
     bool enableFaceDetect;
-    int maxFaces;
+
     {
         SharedParameters::Lock l(client->getParameters());
         enableFaceDetect = l.mParameters.enableFaceDetect;
diff --git a/services/camera/libcameraservice/camera2/JpegCompressor.cpp b/services/camera/libcameraservice/camera2/JpegCompressor.cpp
index 702ef58..c9af71e 100644
--- a/services/camera/libcameraservice/camera2/JpegCompressor.cpp
+++ b/services/camera/libcameraservice/camera2/JpegCompressor.cpp
@@ -144,7 +144,7 @@
 }
 
 // old function -- TODO: update for new buffer type
-bool JpegCompressor::isStreamInUse(uint32_t id) {
+bool JpegCompressor::isStreamInUse(uint32_t /*id*/) {
     ALOGV("%s", __FUNCTION__);
     Mutex::Autolock lock(mBusyMutex);
 
@@ -203,14 +203,14 @@
     dest->free_in_buffer = kMaxJpegSize;
 }
 
-boolean JpegCompressor::jpegEmptyOutputBuffer(j_compress_ptr cinfo) {
+boolean JpegCompressor::jpegEmptyOutputBuffer(j_compress_ptr /*cinfo*/) {
     ALOGV("%s", __FUNCTION__);
     ALOGE("%s: JPEG destination buffer overflow!",
             __FUNCTION__);
     return true;
 }
 
-void JpegCompressor::jpegTermDestination(j_compress_ptr cinfo) {
+void JpegCompressor::jpegTermDestination(j_compress_ptr /*cinfo*/) {
     ALOGV("%s", __FUNCTION__);
     ALOGV("%s: Done writing JPEG data. %d bytes left in buffer",
             __FUNCTION__, cinfo->dest->free_in_buffer);
diff --git a/services/camera/libcameraservice/camera2/JpegProcessor.cpp b/services/camera/libcameraservice/camera2/JpegProcessor.cpp
index ffc072b..6280f83 100644
--- a/services/camera/libcameraservice/camera2/JpegProcessor.cpp
+++ b/services/camera/libcameraservice/camera2/JpegProcessor.cpp
@@ -139,7 +139,6 @@
 
 status_t JpegProcessor::deleteStream() {
     ATRACE_CALL();
-    status_t res;
 
     Mutex::Autolock l(mInputMutex);
 
@@ -164,7 +163,7 @@
     return mCaptureStreamId;
 }
 
-void JpegProcessor::dump(int fd, const Vector<String16>& args) const {
+void JpegProcessor::dump(int /*fd*/, const Vector<String16>& /*args*/) const {
 }
 
 bool JpegProcessor::threadLoop() {
@@ -356,7 +355,7 @@
     // Find End of Image
     // Scan JPEG buffer until End of Image (EOI)
     bool foundEnd = false;
-    for (size; size <= maxSize - MARKER_LENGTH; size++) {
+    for ( ; size <= maxSize - MARKER_LENGTH; size++) {
         if ( checkJpegEnd(jpegBuffer + size) ) {
             foundEnd = true;
             size += MARKER_LENGTH;
diff --git a/services/camera/libcameraservice/camera2/Parameters.cpp b/services/camera/libcameraservice/camera2/Parameters.cpp
index 9a0083a..93927e6 100644
--- a/services/camera/libcameraservice/camera2/Parameters.cpp
+++ b/services/camera/libcameraservice/camera2/Parameters.cpp
@@ -951,7 +951,6 @@
 
 camera_metadata_ro_entry_t Parameters::staticInfo(uint32_t tag,
         size_t minCount, size_t maxCount) const {
-    status_t res;
     camera_metadata_ro_entry_t entry = info->find(tag);
 
     if (CC_UNLIKELY( entry.count == 0 )) {
@@ -1567,6 +1566,10 @@
         ALOGE("%s: Video stabilization not supported", __FUNCTION__);
     }
 
+    // LIGHTFX
+    validatedParams.lightFx = lightFxStringToEnum(
+        newParams.get(CameraParameters::KEY_LIGHTFX));
+
     /** Update internal parameters */
 
     *this = validatedParams;
@@ -2094,6 +2097,18 @@
     }
 }
 
+Parameters::Parameters::lightFxMode_t Parameters::lightFxStringToEnum(
+        const char *lightFxMode) {
+    return
+        !lightFxMode ?
+            Parameters::LIGHTFX_NONE :
+        !strcmp(lightFxMode, CameraParameters::LIGHTFX_LOWLIGHT) ?
+            Parameters::LIGHTFX_LOWLIGHT :
+        !strcmp(lightFxMode, CameraParameters::LIGHTFX_HDR) ?
+            Parameters::LIGHTFX_HDR :
+        Parameters::LIGHTFX_NONE;
+}
+
 status_t Parameters::parseAreas(const char *areasCStr,
         Vector<Parameters::Area> *areas) {
     static const size_t NUM_FIELDS = 5;
@@ -2414,7 +2429,7 @@
     return crop;
 }
 
-int32_t Parameters::fpsFromRange(int32_t min, int32_t max) const {
+int32_t Parameters::fpsFromRange(int32_t /*min*/, int32_t max) const {
     return max;
 }
 
diff --git a/services/camera/libcameraservice/camera2/Parameters.h b/services/camera/libcameraservice/camera2/Parameters.h
index 54b1e8c..6d32bf6 100644
--- a/services/camera/libcameraservice/camera2/Parameters.h
+++ b/services/camera/libcameraservice/camera2/Parameters.h
@@ -261,6 +261,8 @@
     static const char* flashModeEnumToString(flashMode_t flashMode);
     static focusMode_t focusModeStringToEnum(const char *focusMode);
     static const char* focusModeEnumToString(focusMode_t focusMode);
+    static lightFxMode_t lightFxStringToEnum(const char *lightFxMode);
+
     static status_t parseAreas(const char *areasCStr,
             Vector<Area> *areas);
 
diff --git a/services/camera/libcameraservice/camera2/StreamingProcessor.cpp b/services/camera/libcameraservice/camera2/StreamingProcessor.cpp
index 207f780..6ea27b2 100644
--- a/services/camera/libcameraservice/camera2/StreamingProcessor.cpp
+++ b/services/camera/libcameraservice/camera2/StreamingProcessor.cpp
@@ -447,7 +447,6 @@
     ATRACE_CALL();
     Mutex::Autolock m(mMutex);
 
-    status_t res;
     mPreviewRequestId++;
     if (mPreviewRequestId >= Camera2Client::kPreviewRequestIdEnd) {
         mPreviewRequestId = Camera2Client::kPreviewRequestIdStart;
@@ -628,7 +627,7 @@
 }
 
 
-status_t StreamingProcessor::dump(int fd, const Vector<String16>& args) {
+status_t StreamingProcessor::dump(int fd, const Vector<String16>& /*args*/) {
     String8 result;
 
     result.append("  Current requests:\n");
diff --git a/services/camera/libcameraservice/camera2/ZslProcessor.cpp b/services/camera/libcameraservice/camera2/ZslProcessor.cpp
index 1937955..9584028 100644
--- a/services/camera/libcameraservice/camera2/ZslProcessor.cpp
+++ b/services/camera/libcameraservice/camera2/ZslProcessor.cpp
@@ -69,11 +69,12 @@
     }
 }
 
-void ZslProcessor::onFrameAvailable(int32_t frameId, const CameraMetadata &frame) {
+void ZslProcessor::onFrameAvailable(int32_t /*frameId*/, const CameraMetadata &frame) {
     Mutex::Autolock l(mInputMutex);
     camera_metadata_ro_entry_t entry;
     entry = frame.find(ANDROID_SENSOR_TIMESTAMP);
     nsecs_t timestamp = entry.data.i64[0];
+    (void)timestamp;
     ALOGVV("Got preview frame for timestamp %lld", timestamp);
 
     if (mState != RUNNING) return;
@@ -367,7 +368,7 @@
     return OK;
 }
 
-void ZslProcessor::dump(int fd, const Vector<String16>& args) const {
+void ZslProcessor::dump(int fd, const Vector<String16>& /*args*/) const {
     Mutex::Autolock l(mInputMutex);
     if (!mLatestCapturedRequest.isEmpty()) {
         String8 result("    Latest ZSL capture request:\n");
diff --git a/tools/resampler_tools/fir.cpp b/tools/resampler_tools/fir.cpp
index 377814f..14707d1 100644
--- a/tools/resampler_tools/fir.cpp
+++ b/tools/resampler_tools/fir.cpp
@@ -16,6 +16,9 @@
 
 #include <math.h>
 #include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
 
 static double sinc(double x) {
     if (fabs(x) == 0.0f) return 1.0f;
@@ -34,44 +37,82 @@
         y=x/3.75;
         y*=y;
         ans=1.0+y*(3.5156229+y*(3.0899424+y*(1.2067492
-            +y*(0.2659732+y*(0.360768e-1+y*0.45813e-2)))));
+                +y*(0.2659732+y*(0.360768e-1+y*0.45813e-2)))));
     } else {
         y=3.75/ax;
         ans=(exp(ax)/sqrt(ax))*(0.39894228+y*(0.1328592e-1
-            +y*(0.225319e-2+y*(-0.157565e-2+y*(0.916281e-2
-            +y*(-0.2057706e-1+y*(0.2635537e-1+y*(-0.1647633e-1
-            +y*0.392377e-2))))))));
+                +y*(0.225319e-2+y*(-0.157565e-2+y*(0.916281e-2
+                        +y*(-0.2057706e-1+y*(0.2635537e-1+y*(-0.1647633e-1
+                                +y*0.392377e-2))))))));
     }
     return ans;
 }
 
-static double kaiser(int k, int N, double alpha) {
+static double kaiser(int k, int N, double beta) {
     if (k < 0 || k > N)
         return 0;
-    return I0(M_PI*alpha * sqrt(1.0 - sqr((2.0*k)/N - 1.0))) / I0(M_PI*alpha);
+    return I0(beta * sqrt(1.0 - sqr((2.0*k)/N - 1.0))) / I0(beta);
+}
+
+
+static void usage(char* name) {
+    fprintf(stderr,
+            "usage: %s [-h] [-d] [-s sample_rate] [-c cut-off_frequency] [-n half_zero_crossings] [-f {float|fixed}] [-b beta] [-v dBFS] [-l lerp]\n"
+            "       %s [-h] [-d] [-s sample_rate] [-c cut-off_frequency] [-n half_zero_crossings] [-f {float|fixed}] [-b beta] [-v dBFS] -p M/N\n"
+            "    -h    this help message\n"
+            "    -d    debug, print comma-separated coefficient table\n"
+            "    -p    generate poly-phase filter coefficients, with sample increment M/N\n"
+            "    -s    sample rate (48000)\n"
+            "    -c    cut-off frequency (20478)\n"
+            "    -n    number of zero-crossings on one side (8)\n"
+            "    -l    number of lerping bits (4)\n"
+            "    -f    output format, can be fixed-point or floating-point (fixed)\n"
+            "    -b    kaiser window parameter beta (7.865 [-80dB])\n"
+            "    -v    attenuation in dBFS (0)\n",
+            name, name
+    );
+    exit(0);
 }
 
 int main(int argc, char** argv)
 {
     // nc is the number of bits to store the coefficients
-    int nc = 32;
+    const int nc = 32;
 
-    // ni is the minimum number of bits needed for interpolation
-    // (not used for generating the coefficients)
-    const int ni = nc / 2;
+    bool polyphase = false;
+    unsigned int polyM = 160;
+    unsigned int polyN = 147;
+    bool debug = false;
+    double Fs = 48000;
+    double Fc = 24000;
+    double atten = 1;
+    int format = 0;
 
-    // cut off frequency ratio Fc/Fs
-    // The bigger the stop-band, the less coefficients we'll need.
-    double Fcr = 20000.0 / 48000.0;
 
-    // nzc is the number of zero-crossing on one half of the filter
-    int nzc = 8;
-    
-    // alpha parameter of the kaiser window
-    // Larger numbers reduce ripples in the rejection band but increase
-    // the width of the transition band. 
-    // the table below gives some value of alpha for a given
-    // stop-band attenuation.
+    // in order to keep the errors associated with the linear
+    // interpolation of the coefficients below the quantization error
+    // we must satisfy:
+    //   2^nz >= 2^(nc/2)
+    //
+    // for 16 bit coefficients that would be 256
+    //
+    // note that increasing nz only increases memory requirements,
+    // but doesn't increase the amount of computation to do.
+    //
+    //
+    // see:
+    // Smith, J.O. Digital Audio Resampling Home Page
+    // https://ccrma.stanford.edu/~jos/resample/, 2011-03-29
+    //
+    int nz = 4;
+
+    //         | 0.1102*(A - 8.7)                         A > 50
+    //  beta = | 0.5842*(A - 21)^0.4 + 0.07886*(A - 21)   21 <= A <= 50
+    //         | 0                                        A < 21
+    //   with A is the desired stop-band attenuation in dBFS
+    //
+    // for eg:
+    //
     //    30 dB    2.210
     //    40 dB    3.384
     //    50 dB    4.538
@@ -80,42 +121,162 @@
     //    80 dB    7.865
     //    90 dB    8.960
     //   100 dB   10.056
-    double alpha = 7.865;	// -80dB stop-band attenuation
-    
-    // 2^nz is the number coefficients per zero-crossing
-    // (int theory this should be 1<<(nc/2))
-    const int nz = 4;
+    double beta = 7.865;
 
-    // total number of coefficients
+
+    // 2*nzc = (A - 8) / (2.285 * dw)
+    //      with dw the transition width = 2*pi*dF/Fs
+    //
+    int nzc = 8;
+
+    //
+    // Example:
+    // 44.1 KHz to 48 KHz resampling
+    // 100 dB rejection above 28 KHz
+    //   (the spectrum will fold around 24 KHz and we want 100 dB rejection
+    //    at the point where the folding reaches 20 KHz)
+    //  ...___|_____
+    //        |     \|
+    //        | ____/|\____
+    //        |/alias|     \
+    //  ------/------+------\---------> KHz
+    //       20     24     28
+
+    // Transition band 8 KHz, or dw = 1.0472
+    //
+    // beta = 10.056
+    // nzc  = 20
+    //
+
+    int ch;
+    while ((ch = getopt(argc, argv, ":hds:c:n:f:l:b:p:v:")) != -1) {
+        switch (ch) {
+            case 'd':
+                debug = true;
+                break;
+            case 'p':
+                if (sscanf(optarg, "%u/%u", &polyM, &polyN) != 2) {
+                    usage(argv[0]);
+                }
+                polyphase = true;
+                break;
+            case 's':
+                Fs = atof(optarg);
+                break;
+            case 'c':
+                Fc = atof(optarg);
+                break;
+            case 'n':
+                nzc = atoi(optarg);
+                break;
+            case 'l':
+                nz = atoi(optarg);
+                break;
+            case 'f':
+                if (!strcmp(optarg,"fixed")) format = 0;
+                else if (!strcmp(optarg,"float")) format = 1;
+                else usage(argv[0]);
+                break;
+            case 'b':
+                beta = atof(optarg);
+                break;
+            case 'v':
+                atten = pow(10, -fabs(atof(optarg))*0.05 );
+                break;
+            case 'h':
+            default:
+                usage(argv[0]);
+                break;
+        }
+    }
+
+    // cut off frequency ratio Fc/Fs
+    double Fcr = Fc / Fs;
+
+
+    // total number of coefficients (one side)
     const int N = (1 << nz) * nzc;
 
     // generate the right half of the filter
-    printf("const int32_t RESAMPLE_FIR_SIZE           = %d;\n", N);
-    printf("const int32_t RESAMPLE_FIR_NUM_COEF       = %d;\n", nzc);
-    printf("const int32_t RESAMPLE_FIR_COEF_BITS      = %d;\n", nc);
-    printf("const int32_t RESAMPLE_FIR_LERP_FRAC_BITS = %d;\n", ni);
-    printf("const int32_t RESAMPLE_FIR_LERP_INT_BITS  = %d;\n", nz);
-    printf("\n");
-    printf("static int16_t resampleFIR[%d] = {", N);
-    for (int i=0 ; i<N ; i++)
-    {
-        double x = (2.0 * M_PI * i * Fcr) / (1 << nz);
-        double y = kaiser(i+N, 2*N, alpha) * sinc(x);
-
-        long yi = floor(y * ((1ULL<<(nc-1))) + 0.5);
-        if (yi >= (1LL<<(nc-1))) yi = (1LL<<(nc-1))-1;        
-
-        if ((i % (1 << 4)) == 0) printf("\n    ");
-        if (nc > 16)
-        	printf("0x%08x, ", int(yi));
-        else 
-        	printf("0x%04x, ", int(yi)&0xFFFF);
+    if (!debug) {
+        printf("// cmd-line: ");
+        for (int i=1 ; i<argc ; i++) {
+            printf("%s ", argv[i]);
+        }
+        printf("\n");
+        if (!polyphase) {
+            printf("const int32_t RESAMPLE_FIR_SIZE           = %d;\n", N);
+            printf("const int32_t RESAMPLE_FIR_LERP_INT_BITS  = %d;\n", nz);
+            printf("const int32_t RESAMPLE_FIR_NUM_COEF       = %d;\n", nzc);
+        } else {
+            printf("const int32_t RESAMPLE_FIR_SIZE           = %d;\n", 2*nzc*polyN);
+            printf("const int32_t RESAMPLE_FIR_NUM_COEF       = %d;\n", 2*nzc);
+        }
+        if (!format) {
+            printf("const int32_t RESAMPLE_FIR_COEF_BITS      = %d;\n", nc);
+        }
+        printf("\n");
+        printf("static %s resampleFIR[] = {", !format ? "int32_t" : "float");
     }
-    printf("\n};\n");
-    return 0;
- }
 
-// http://www.dsptutor.freeuk.com/KaiserFilterDesign/KaiserFilterDesign.html
+    if (!polyphase) {
+        for (int i=0 ; i<N ; i++) {
+            double x = (2.0 * M_PI * i * Fcr) / (1 << nz);
+            double y = kaiser(i+N, 2*N, beta) * sinc(x);
+            y *= atten;
+
+            if (!debug) {
+                if ((i % (1<<nz)) == 0)
+                    printf("\n    ");
+            }
+
+            if (!format) {
+                int64_t yi = floor(y * ((1ULL<<(nc-1))) + 0.5);
+                if (yi >= (1LL<<(nc-1))) yi = (1LL<<(nc-1))-1;
+                printf("0x%08x, ", int32_t(yi));
+            } else {
+                printf("%.9g%s ", y, debug ? "," : "f,");
+            }
+        }
+    } else {
+        for (int j=0 ; j<polyN ; j++) {
+            // calculate the phase
+            double p = ((polyM*j) % polyN) / double(polyN);
+            if (!debug) printf("\n    ");
+            else        printf("\n");
+            // generate a FIR per phase
+            for (int i=-nzc ; i<nzc ; i++) {
+                double x = 2.0 * M_PI * Fcr * (i + p);
+                double y = kaiser(i+N, 2*N, beta) * sinc(x);
+                y *= atten;
+                if (!format) {
+                    int64_t yi = floor(y * ((1ULL<<(nc-1))) + 0.5);
+                    if (yi >= (1LL<<(nc-1))) yi = (1LL<<(nc-1))-1;
+                    printf("0x%08x", int32_t(yi));
+                } else {
+                    printf("%.9g%s", y, debug ? "" : "f");
+                }
+
+                if (debug && (i==nzc-1)) {
+                } else {
+                    printf(", ");
+                }
+            }
+        }
+    }
+
+    if (!debug) {
+        if (!format) {
+            printf("\n    0x%08x ", 0);
+        } else {
+            printf("\n    %.9g ", 0.0f);
+        }
+        printf("\n};");
+    }
+    printf("\n");
+    return 0;
+}
+
 // http://www.csee.umbc.edu/help/sound/AFsp-V2R1/html/audio/ResampAudio.html
 
- 
+