Merge "Log fatal error when c2 sw codec fails to load" into qt-dev
diff --git a/camera/ndk/include/camera/NdkCameraMetadataTags.h b/camera/ndk/include/camera/NdkCameraMetadataTags.h
index 4563b41..7cd832a 100644
--- a/camera/ndk/include/camera/NdkCameraMetadataTags.h
+++ b/camera/ndk/include/camera/NdkCameraMetadataTags.h
@@ -7511,18 +7511,19 @@
 
     /**
      * <p>The camera device supports capturing high-resolution images at &gt;= 20 frames per
-     * second, in at least the uncompressed YUV format, when post-processing settings are set
-     * to FAST. Additionally, maximum-resolution images can be captured at &gt;= 10 frames
-     * per second.  Here, 'high resolution' means at least 8 megapixels, or the maximum
-     * resolution of the device, whichever is smaller.</p>
+     * second, in at least the uncompressed YUV format, when post-processing settings are
+     * set to FAST. Additionally, all image resolutions less than 24 megapixels can be
+     * captured at &gt;= 10 frames per second. Here, 'high resolution' means at least 8
+     * megapixels, or the maximum resolution of the device, whichever is smaller.</p>
      * <p>More specifically, this means that at least one output {@link AIMAGE_FORMAT_YUV_420_888 } size listed in
      * {@link ACAMERA_SCALER_AVAILABLE_STREAM_CONFIGURATIONS }
      * is larger or equal to the 'high resolution' defined above, and can be captured at at
      * least 20 fps.  For the largest {@link AIMAGE_FORMAT_YUV_420_888 } size listed in
      * {@link ACAMERA_SCALER_AVAILABLE_STREAM_CONFIGURATIONS },
-     * camera device can capture this size for at least 10 frames per second.  Also the
-     * ACAMERA_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES entry lists at least one FPS range where
-     * the minimum FPS is &gt;= 1 / minimumFrameDuration for the largest YUV_420_888 size.</p>
+     * camera device can capture this size for at least 10 frames per second if the size is
+     * less than 24 megapixels. Also the ACAMERA_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES entry
+     * lists at least one FPS range where the minimum FPS is &gt;= 1 / minimumFrameDuration
+     * for the largest YUV_420_888 size.</p>
      * <p>If the device supports the {@link AIMAGE_FORMAT_RAW10 }, {@link AIMAGE_FORMAT_RAW12 }, {@link AIMAGE_FORMAT_Y8 }, then those can also be
      * captured at the same rate as the maximum-size YUV_420_888 resolution is.</p>
      * <p>In addition, the ACAMERA_SYNC_MAX_LATENCY field is guaranted to have a value between 0
diff --git a/media/extractors/flac/FLACExtractor.cpp b/media/extractors/flac/FLACExtractor.cpp
index 8854631..5329bd1 100644
--- a/media/extractors/flac/FLACExtractor.cpp
+++ b/media/extractors/flac/FLACExtractor.cpp
@@ -531,23 +531,9 @@
             return NO_INIT;
         }
         // check sample rate
-        switch (getSampleRate()) {
-        case  8000:
-        case 11025:
-        case 12000:
-        case 16000:
-        case 22050:
-        case 24000:
-        case 32000:
-        case 44100:
-        case 48000:
-        case 88200:
-        case 96000:
-        case 176400:
-        case 192000:
-            break;
-        default:
-            // Note: internally we support arbitrary sample rates from 8kHz to 192kHz.
+        // Note: flac supports arbitrary sample rates up to 655350 Hz, but Android
+        // supports sample rates from 8kHz to 192kHz, so use that as the limit.
+        if (getSampleRate() < 8000 || getSampleRate() > 192000) {
             ALOGE("unsupported sample rate %u", getSampleRate());
             return NO_INIT;
         }
diff --git a/media/img_utils/src/DngUtils.cpp b/media/img_utils/src/DngUtils.cpp
index 9304f53..7914030 100644
--- a/media/img_utils/src/DngUtils.cpp
+++ b/media/img_utils/src/DngUtils.cpp
@@ -173,8 +173,8 @@
 
     status_t err = addGainMap(/*top*/redTop,
                               /*left*/redLeft,
-                              /*bottom*/activeAreaHeight - 1,
-                              /*right*/activeAreaWidth - 1,
+                              /*bottom*/activeAreaHeight,
+                              /*right*/activeAreaWidth,
                               /*plane*/0,
                               /*planes*/1,
                               /*rowPitch*/2,
@@ -191,8 +191,8 @@
 
     err = addGainMap(/*top*/greenEvenTop,
                      /*left*/greenEvenLeft,
-                     /*bottom*/activeAreaHeight - 1,
-                     /*right*/activeAreaWidth - 1,
+                     /*bottom*/activeAreaHeight,
+                     /*right*/activeAreaWidth,
                      /*plane*/0,
                      /*planes*/1,
                      /*rowPitch*/2,
@@ -209,8 +209,8 @@
 
     err = addGainMap(/*top*/greenOddTop,
                      /*left*/greenOddLeft,
-                     /*bottom*/activeAreaHeight - 1,
-                     /*right*/activeAreaWidth - 1,
+                     /*bottom*/activeAreaHeight,
+                     /*right*/activeAreaWidth,
                      /*plane*/0,
                      /*planes*/1,
                      /*rowPitch*/2,
@@ -227,8 +227,8 @@
 
     err = addGainMap(/*top*/blueTop,
                      /*left*/blueLeft,
-                     /*bottom*/activeAreaHeight - 1,
-                     /*right*/activeAreaWidth - 1,
+                     /*bottom*/activeAreaHeight,
+                     /*right*/activeAreaWidth,
                      /*plane*/0,
                      /*planes*/1,
                      /*rowPitch*/2,
@@ -265,8 +265,8 @@
 
     status_t err = addGainMap(/*top*/0,
                               /*left*/0,
-                              /*bottom*/activeAreaHeight - 1,
-                              /*right*/activeAreaWidth - 1,
+                              /*bottom*/activeAreaHeight,
+                              /*right*/activeAreaWidth,
                               /*plane*/0,
                               /*planes*/1,
                               /*rowPitch*/1,
@@ -364,8 +364,8 @@
         return BAD_VALUE;
     }
 
-    double normalizedOCX = opticalCenterX / static_cast<double>(activeArrayWidth - 1);
-    double normalizedOCY = opticalCenterY / static_cast<double>(activeArrayHeight - 1);
+    double normalizedOCX = opticalCenterX / static_cast<double>(activeArrayWidth);
+    double normalizedOCY = opticalCenterY / static_cast<double>(activeArrayHeight);
 
     normalizedOCX = CLAMP(normalizedOCX, 0, 1);
     normalizedOCY = CLAMP(normalizedOCY, 0, 1);
diff --git a/media/libaaudio/src/client/AudioStreamInternal.cpp b/media/libaaudio/src/client/AudioStreamInternal.cpp
index db98d58..c7e8088 100644
--- a/media/libaaudio/src/client/AudioStreamInternal.cpp
+++ b/media/libaaudio/src/client/AudioStreamInternal.cpp
@@ -76,6 +76,7 @@
     aaudio_result_t result = AAUDIO_OK;
     int32_t capacity;
     int32_t framesPerBurst;
+    int32_t framesPerHardwareBurst;
     AAudioStreamRequest request;
     AAudioStreamConfiguration configurationOutput;
 
@@ -90,6 +91,9 @@
         return result;
     }
 
+    const int32_t burstMinMicros = AAudioProperty_getHardwareBurstMinMicros();
+    int32_t burstMicros = 0;
+
     // We have to do volume scaling. So we prefer FLOAT format.
     if (getFormat() == AUDIO_FORMAT_DEFAULT) {
         setFormat(AUDIO_FORMAT_PCM_FLOAT);
@@ -173,8 +177,22 @@
         goto error;
     }
 
-    // Validate result from server.
-    framesPerBurst = mEndpointDescriptor.dataQueueDescriptor.framesPerBurst;
+    framesPerHardwareBurst = mEndpointDescriptor.dataQueueDescriptor.framesPerBurst;
+
+    // Scale up the burst size to meet the minimum equivalent in microseconds.
+    // This is to avoid waking the CPU too often when the HW burst is very small
+    // or at high sample rates.
+    framesPerBurst = framesPerHardwareBurst;
+    do {
+        if (burstMicros > 0) {  // skip first loop
+            framesPerBurst *= 2;
+        }
+        burstMicros = framesPerBurst * static_cast<int64_t>(1000000) / getSampleRate();
+    } while (burstMicros < burstMinMicros);
+    ALOGD("%s() original HW burst = %d, minMicros = %d => SW burst = %d\n",
+          __func__, framesPerHardwareBurst, burstMinMicros, framesPerBurst);
+
+    // Validate final burst size.
     if (framesPerBurst < MIN_FRAMES_PER_BURST || framesPerBurst > MAX_FRAMES_PER_BURST) {
         ALOGE("%s - framesPerBurst out of range = %d", __func__, framesPerBurst);
         result = AAUDIO_ERROR_OUT_OF_RANGE;
@@ -190,7 +208,7 @@
     }
 
     mClockModel.setSampleRate(getSampleRate());
-    mClockModel.setFramesPerBurst(mFramesPerBurst);
+    mClockModel.setFramesPerBurst(framesPerHardwareBurst);
 
     if (isDataCallbackSet()) {
         mCallbackFrames = builder.getFramesPerDataCallback();
diff --git a/services/audiopolicy/engineconfigurable/parameter-framework/examples/common/Structure/PolicySubsystem-CommonTypes.xml b/services/audiopolicy/engineconfigurable/parameter-framework/examples/common/Structure/PolicySubsystem-CommonTypes.xml
index 56c5ed3..d17c021 100644
--- a/services/audiopolicy/engineconfigurable/parameter-framework/examples/common/Structure/PolicySubsystem-CommonTypes.xml
+++ b/services/audiopolicy/engineconfigurable/parameter-framework/examples/common/Structure/PolicySubsystem-CommonTypes.xml
@@ -74,6 +74,8 @@
             <BitParameter Name="proxy" Size="1" Pos="21"/>
             <BitParameter Name="usb_headset" Size="1" Pos="22"/>
             <BitParameter Name="bluetooth_ble" Size="1" Pos="23"/>
+            <BitParameter Name="hdmi_arc" Size="1" Pos="24"/>
+            <BitParameter Name="echo_reference" Size="1" Pos="25"/>
             <BitParameter Name="stub" Size="1" Pos="30"/>
         </BitParameterBlock>
     </ComponentType>
@@ -128,8 +130,10 @@
             <BitParameter Name="voice_communication" Size="1" Pos="7"/>
             <BitParameter Name="remote_submix" Size="1" Pos="8"/>
             <BitParameter Name="unprocessed" Size="1" Pos="9"/>
-            <BitParameter Name="fm_tuner" Size="1" Pos="10"/>
-            <BitParameter Name="hotword" Size="1" Pos="11"/>
+            <BitParameter Name="voice_performance" Size="1" Pos="10"/>
+            <BitParameter Name="echo_reference" Size="1" Pos="11"/>
+            <BitParameter Name="fm_tuner" Size="1" Pos="12"/>
+            <BitParameter Name="hotword" Size="1" Pos="13"/>
         </BitParameterBlock>
     </ComponentType>
 
diff --git a/services/camera/libcameraservice/utils/LatencyHistogram.cpp b/services/camera/libcameraservice/utils/LatencyHistogram.cpp
index 538bb6e..e2bdc43 100644
--- a/services/camera/libcameraservice/utils/LatencyHistogram.cpp
+++ b/services/camera/libcameraservice/utils/LatencyHistogram.cpp
@@ -46,7 +46,7 @@
 }
 
 void CameraLatencyHistogram::reset() {
-    mBins.clear();
+    memset(mBins.data(), 0, mBins.size() * sizeof(int64_t));
     mTotalCount = 0;
 }
 
diff --git a/services/oboeservice/AAudioServiceEndpointMMAP.cpp b/services/oboeservice/AAudioServiceEndpointMMAP.cpp
index 447f32c..b05baa4 100644
--- a/services/oboeservice/AAudioServiceEndpointMMAP.cpp
+++ b/services/oboeservice/AAudioServiceEndpointMMAP.cpp
@@ -77,9 +77,6 @@
     audio_config_base_t config;
     audio_port_handle_t deviceId;
 
-    int32_t burstMinMicros = AAudioProperty_getHardwareBurstMinMicros();
-    int32_t burstMicros = 0;
-
     copyFrom(request.getConstantConfiguration());
 
     aaudio_direction_t direction = getDirection();
@@ -235,24 +232,12 @@
     setFormat(config.format);
     setSampleRate(config.sample_rate);
 
-    // Scale up the burst size to meet the minimum equivalent in microseconds.
-    // This is to avoid waking the CPU too often when the HW burst is very small
-    // or at high sample rates.
-    do {
-        if (burstMicros > 0) {  // skip first loop
-            mFramesPerBurst *= 2;
-        }
-        burstMicros = mFramesPerBurst * static_cast<int64_t>(1000000) / getSampleRate();
-    } while (burstMicros < burstMinMicros);
+    ALOGD("%s() actual rate = %d, channels = %d"
+          ", deviceId = %d, capacity = %d\n",
+          __func__, getSampleRate(), getSamplesPerFrame(), deviceId, getBufferCapacity());
 
-    ALOGD("%s() original burst = %d, minMicros = %d => burst = %d\n",
-          __func__, mMmapBufferinfo.burst_size_frames, burstMinMicros, mFramesPerBurst);
-
-    ALOGD("%s() actual rate = %d, channels = %d, deviceId = %d\n",
-          __func__, getSampleRate(), getSamplesPerFrame(), deviceId);
-
-    ALOGD("%s() format = 0x%08x, frame size = %d",
-          __func__, getFormat(), calculateBytesPerFrame());
+    ALOGD("%s() format = 0x%08x, frame size = %d, burst size = %d",
+          __func__, getFormat(), calculateBytesPerFrame(), mFramesPerBurst);
 
     return result;