MediaCodecSource: Fix buffer allocation
am: 01d1e52558
Change-Id: I03f6976b6615672bfa52f0dc5c60abd7b3f2b3bc
diff --git a/camera/CameraBase.cpp b/camera/CameraBase.cpp
index 15d7715..194e1d3 100644
--- a/camera/CameraBase.cpp
+++ b/camera/CameraBase.cpp
@@ -20,6 +20,7 @@
#include <utils/Log.h>
#include <utils/threads.h>
#include <utils/Mutex.h>
+#include <cutils/properties.h>
#include <android/hardware/ICameraService.h>
@@ -90,6 +91,12 @@
{
Mutex::Autolock _l(gLock);
if (gCameraService.get() == 0) {
+ char value[PROPERTY_VALUE_MAX];
+ property_get("config.disable_cameraservice", value, "0");
+ if (strncmp(value, "0", 2) != 0 && strncasecmp(value, "false", 6) != 0) {
+ return gCameraService;
+ }
+
sp<IServiceManager> sm = defaultServiceManager();
sp<IBinder> binder;
do {
diff --git a/camera/ndk/impl/ACameraManager.cpp b/camera/ndk/impl/ACameraManager.cpp
index 26d6679..35555ff 100644
--- a/camera/ndk/impl/ACameraManager.cpp
+++ b/camera/ndk/impl/ACameraManager.cpp
@@ -22,6 +22,7 @@
#include "ACameraMetadata.h"
#include "ACameraDevice.h"
#include <utils/Vector.h>
+#include <cutils/properties.h>
#include <stdlib.h>
#include <camera/VendorTagDescriptor.h>
@@ -71,9 +72,19 @@
mCameraService.clear();
}
+static bool isCameraServiceDisabled() {
+ char value[PROPERTY_VALUE_MAX];
+ property_get("config.disable_cameraservice", value, "0");
+ return (strncmp(value, "0", 2) != 0 && strncasecmp(value, "false", 6) != 0);
+}
+
sp<hardware::ICameraService> CameraManagerGlobal::getCameraService() {
Mutex::Autolock _l(mLock);
if (mCameraService.get() == nullptr) {
+ if (isCameraServiceDisabled()) {
+ return mCameraService;
+ }
+
sp<IServiceManager> sm = defaultServiceManager();
sp<IBinder> binder;
do {
@@ -302,6 +313,13 @@
camera_status_t
ACameraManager::getOrCreateCameraIdListLocked(ACameraIdList** cameraIdList) {
if (mCachedCameraIdList.numCameras == kCameraIdListNotInit) {
+ if (isCameraServiceDisabled()) {
+ mCachedCameraIdList.numCameras = 0;
+ mCachedCameraIdList.cameraIds = new const char*[0];
+ *cameraIdList = &mCachedCameraIdList;
+ return ACAMERA_OK;
+ }
+
int numCameras = 0;
Vector<char *> cameraIds;
sp<hardware::ICameraService> cs = CameraManagerGlobal::getInstance().getCameraService();
diff --git a/include/media/ToneGenerator.h b/include/media/ToneGenerator.h
index a419e17..9fd5f61 100644
--- a/include/media/ToneGenerator.h
+++ b/include/media/ToneGenerator.h
@@ -193,8 +193,8 @@
TONE_JAPAN_DIAL, // Dial tone: 400Hz, continuous
TONE_JAPAN_BUSY, // Busy tone: 400Hz, 500ms ON, 500ms OFF...
TONE_JAPAN_RADIO_ACK, // Radio path acknowlegment: 400Hz, 1s ON, 2s OFF...
- // UK Supervisory tones
- TONE_UK_RINGTONE, // Ring Tone: A 400Hz + 450Hz tone repeated in a 0.4s on, 0.2s off, 0.4s on, 2.0s off pattern.
+ // GB Supervisory tones
+ TONE_GB_RINGTONE, // Ring Tone: A 400Hz + 450Hz tone repeated in a 0.4s on, 0.2s off, 0.4s on, 2.0s off pattern.
// AUSTRALIA Supervisory tones
TONE_AUSTRALIA_RINGTONE, // Ring tone: A 400Hz + 450Hz tone repeated in a 0.4s on, 0.2s off, 0.4s on, 2.0s off pattern.
TONE_AUSTRALIA_BUSY, // Busy tone: 425 Hz repeated in a 0.375s on, 0.375s off pattern.
@@ -206,7 +206,7 @@
enum region {
ANSI,
JAPAN,
- UK,
+ GB,
AUSTRALIA,
CEPT,
NUM_REGIONS
diff --git a/media/libmedia/ToneGenerator.cpp b/media/libmedia/ToneGenerator.cpp
index 9a087ff..7a72237 100644
--- a/media/libmedia/ToneGenerator.cpp
+++ b/media/libmedia/ToneGenerator.cpp
@@ -746,7 +746,7 @@
{ .duration = 2000, .waveFreq = { 0 }, 0, 0},
{ .duration = 0, .waveFreq = { 0 }, 0, 0}},
.repeatCnt = ToneGenerator::TONEGEN_INF,
- .repeatSegment = 0 }, // TONE_UK_RINGTONE
+ .repeatSegment = 0 }, // TONE_GB_RINGTONE
{ .segments = { { .duration = 400, .waveFreq = { 400, 450, 0 }, 0, 0 },
{ .duration = 200, .waveFreq = { 0 }, 0, 0 },
{ .duration = 400, .waveFreq = { 400, 450, 0 }, 0, 0 },
@@ -796,7 +796,7 @@
TONE_SUP_CALL_WAITING, // TONE_SUP_CALL_WAITING
TONE_SUP_RINGTONE // TONE_SUP_RINGTONE
},
- { // UK
+ { // GB
TONE_SUP_DIAL, // TONE_SUP_DIAL
TONE_SUP_BUSY, // TONE_SUP_BUSY
TONE_SUP_CONGESTION, // TONE_SUP_CONGESTION
@@ -804,7 +804,7 @@
TONE_SUP_RADIO_NOTAVAIL, // TONE_SUP_RADIO_NOTAVAIL
TONE_SUP_ERROR, // TONE_SUP_ERROR
TONE_SUP_CALL_WAITING, // TONE_SUP_CALL_WAITING
- TONE_UK_RINGTONE // TONE_SUP_RINGTONE
+ TONE_GB_RINGTONE // TONE_SUP_RINGTONE
},
{ // AUSTRALIA
TONE_ANSI_DIAL, // TONE_SUP_DIAL
@@ -869,8 +869,8 @@
mRegion = ANSI;
} else if (strstr(value, "jp") != NULL) {
mRegion = JAPAN;
- } else if (strstr(value, "uk") != NULL) {
- mRegion = UK;
+ } else if (strstr(value, "gb") != NULL) {
+ mRegion = GB;
} else if (strstr(value, "au") != NULL) {
mRegion = AUSTRALIA;
} else {
diff --git a/media/libstagefright/mpeg2ts/ATSParser.cpp b/media/libstagefright/mpeg2ts/ATSParser.cpp
index b863d67..844479e 100644
--- a/media/libstagefright/mpeg2ts/ATSParser.cpp
+++ b/media/libstagefright/mpeg2ts/ATSParser.cpp
@@ -701,6 +701,10 @@
}
mPayloadStarted = true;
+ // There should be at most 2 elements in |mPesStartOffsets|.
+ while (mPesStartOffsets.size() >= 2) {
+ mPesStartOffsets.erase(mPesStartOffsets.begin());
+ }
mPesStartOffsets.push_back(offset);
}
@@ -1104,15 +1108,20 @@
mSource->queueAccessUnit(accessUnit);
}
- if ((event != NULL) && !found && mQueue->getFormat() != NULL) {
+ // Every access unit has a pesStartOffset queued in |mPesStartOffsets|.
+ off64_t pesStartOffset = -1;
+ if (!mPesStartOffsets.empty()) {
+ pesStartOffset = *mPesStartOffsets.begin();
+ mPesStartOffsets.erase(mPesStartOffsets.begin());
+ }
+
+ if (pesStartOffset >= 0 && (event != NULL) && !found && mQueue->getFormat() != NULL) {
int32_t sync = 0;
if (accessUnit->meta()->findInt32("isSync", &sync) && sync) {
int64_t timeUs;
if (accessUnit->meta()->findInt64("timeUs", &timeUs)) {
found = true;
- off64_t pesStartOffset = *mPesStartOffsets.begin();
event->init(pesStartOffset, mSource, timeUs);
- mPesStartOffsets.erase(mPesStartOffsets.begin());
}
}
}