summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--media/libstagefright/AudioSource.cpp4
-rw-r--r--media/libstagefright/DRMExtractor.cpp3
-rw-r--r--media/libstagefright/codecs/amrwbenc/src/util.c19
-rw-r--r--media/libstagefright/id3/ID3.cpp7
-rw-r--r--services/audiopolicy/AudioPolicyInterface.h1
-rw-r--r--services/audiopolicy/managerdefault/AudioPolicyManager.cpp2
-rw-r--r--services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp2
-rw-r--r--services/camera/libcameraservice/device3/Camera3Device.cpp43
-rw-r--r--services/camera/libcameraservice/device3/Camera3Device.h5
9 files changed, 66 insertions, 20 deletions
diff --git a/media/libstagefright/AudioSource.cpp b/media/libstagefright/AudioSource.cpp
index 3505844..6e4a1dd 100644
--- a/media/libstagefright/AudioSource.cpp
+++ b/media/libstagefright/AudioSource.cpp
@@ -290,6 +290,10 @@ void AudioSource::signalBufferReturned(MediaBuffer *buffer) {
status_t AudioSource::dataCallback(const AudioRecord::Buffer& audioBuffer) {
int64_t timeUs = systemTime() / 1000ll;
+ // Estimate the real sampling time of the 1st sample in this buffer
+ // from AudioRecord's latency. (Apply this adjustment first so that
+ // the start time logic is not affected.)
+ timeUs -= mRecord->latency() * 1000LL;
ALOGV("dataCallbackTimestamp: %" PRId64 " us", timeUs);
Mutex::Autolock autoLock(mLock);
diff --git a/media/libstagefright/DRMExtractor.cpp b/media/libstagefright/DRMExtractor.cpp
index 63cb430..9cb6e86 100644
--- a/media/libstagefright/DRMExtractor.cpp
+++ b/media/libstagefright/DRMExtractor.cpp
@@ -186,7 +186,8 @@ status_t DRMSource::read(MediaBuffer **buffer, const ReadOptions *options) {
srcOffset += mNALLengthSize;
- if (srcOffset + nalLength > len) {
+ size_t end = srcOffset + nalLength;
+ if (end > len || end < srcOffset) {
if (decryptedDrmBuffer.data) {
delete [] decryptedDrmBuffer.data;
decryptedDrmBuffer.data = NULL;
diff --git a/media/libstagefright/codecs/amrwbenc/src/util.c b/media/libstagefright/codecs/amrwbenc/src/util.c
index 76ab1b1..333140d 100644
--- a/media/libstagefright/codecs/amrwbenc/src/util.c
+++ b/media/libstagefright/codecs/amrwbenc/src/util.c
@@ -35,9 +35,10 @@ void Set_zero(
)
{
Word32 num = (Word32)L;
- do{
+ while (num > 0) {
*x++ = 0;
- }while(--num !=0);
+ --num;
+ }
}
@@ -54,20 +55,22 @@ void Copy(
)
{
Word32 temp1,temp2,num;
+ if (L <= 0) {
+ return;
+ }
if(L&1)
{
temp1 = *x++;
*y++ = temp1;
}
num = (Word32)(L>>1);
- temp1 = *x++;
- temp2 = *x++;
- do{
- *y++ = temp1;
- *y++ = temp2;
+ while (num > 0) {
temp1 = *x++;
temp2 = *x++;
- }while(--num!=0);
+ *y++ = temp1;
+ *y++ = temp2;
+ --num;
+ }
}
diff --git a/media/libstagefright/id3/ID3.cpp b/media/libstagefright/id3/ID3.cpp
index 38ba844..a90d958 100644
--- a/media/libstagefright/id3/ID3.cpp
+++ b/media/libstagefright/id3/ID3.cpp
@@ -327,7 +327,7 @@ bool ID3::removeUnsynchronizationV2_4(bool iTunesHack) {
size_t oldSize = mSize;
size_t offset = 0;
- while (offset + 10 <= mSize) {
+ while (mSize >= 10 && offset <= mSize - 10) {
if (!memcmp(&mData[offset], "\0\0\0\0", 4)) {
break;
}
@@ -339,7 +339,7 @@ bool ID3::removeUnsynchronizationV2_4(bool iTunesHack) {
return false;
}
- if (offset + dataSize + 10 > mSize) {
+ if (dataSize > mSize - 10 - offset) {
return false;
}
@@ -349,6 +349,9 @@ bool ID3::removeUnsynchronizationV2_4(bool iTunesHack) {
if (flags & 1) {
// Strip data length indicator
+ if (mSize < 14 || mSize - 14 < offset) {
+ return false;
+ }
memmove(&mData[offset + 10], &mData[offset + 14], mSize - offset - 14);
mSize -= 4;
dataSize -= 4;
diff --git a/services/audiopolicy/AudioPolicyInterface.h b/services/audiopolicy/AudioPolicyInterface.h
index 8523fc5..c1e7bc0 100644
--- a/services/audiopolicy/AudioPolicyInterface.h
+++ b/services/audiopolicy/AudioPolicyInterface.h
@@ -64,6 +64,7 @@ public:
API_INPUT_MIX_EXT_POLICY_REROUTE,// used for platform audio rerouting, where mixes are
// handled by external and dynamically installed
// policies which reroute audio mixes
+ API_INPUT_TELEPHONY_RX, // used for capture from telephony RX path
} input_type_t;
public:
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
index 3e6df38..b1d7b13 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
@@ -1351,6 +1351,8 @@ status_t AudioPolicyManager::getInputForAttr(const audio_attributes_t *attr,
} else if (audio_is_remote_submix_device(device)) {
address = String8("0");
*inputType = API_INPUT_MIX_CAPTURE;
+ } else if (device == AUDIO_DEVICE_IN_TELEPHONY_RX) {
+ *inputType = API_INPUT_TELEPHONY_RX;
} else {
*inputType = API_INPUT_LEGACY;
}
diff --git a/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp b/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp
index 65639c3..793c26a 100644
--- a/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp
+++ b/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp
@@ -303,6 +303,8 @@ status_t AudioPolicyService::getInputForAttr(const audio_attributes_t *attr,
switch (inputType) {
case AudioPolicyInterface::API_INPUT_LEGACY:
break;
+ case AudioPolicyInterface::API_INPUT_TELEPHONY_RX:
+ // FIXME: use the same permission as for remote submix for now.
case AudioPolicyInterface::API_INPUT_MIX_CAPTURE:
if (!captureAudioOutputAllowed()) {
ALOGE("getInputForAttr() permission denied: capture not allowed");
diff --git a/services/camera/libcameraservice/device3/Camera3Device.cpp b/services/camera/libcameraservice/device3/Camera3Device.cpp
index 3afbd89..0a4440f 100644
--- a/services/camera/libcameraservice/device3/Camera3Device.cpp
+++ b/services/camera/libcameraservice/device3/Camera3Device.cpp
@@ -370,7 +370,7 @@ ssize_t Camera3Device::getJpegBufferSize(uint32_t width, uint32_t height) const
// Get max jpeg size (area-wise).
Size maxJpegResolution = getMaxJpegResolution();
if (maxJpegResolution.width == 0) {
- ALOGE("%s: Camera %d: Can't find find valid available jpeg sizes in static metadata!",
+ ALOGE("%s: Camera %d: Can't find valid available jpeg sizes in static metadata!",
__FUNCTION__, mId);
return BAD_VALUE;
}
@@ -397,6 +397,21 @@ ssize_t Camera3Device::getJpegBufferSize(uint32_t width, uint32_t height) const
return jpegBufferSize;
}
+ssize_t Camera3Device::getPointCloudBufferSize() const {
+ const int FLOATS_PER_POINT=4;
+ camera_metadata_ro_entry maxPointCount = mDeviceInfo.find(ANDROID_DEPTH_MAX_DEPTH_SAMPLES);
+ if (maxPointCount.count == 0) {
+ ALOGE("%s: Camera %d: Can't find maximum depth point cloud size in static metadata!",
+ __FUNCTION__, mId);
+ return BAD_VALUE;
+ }
+ ssize_t maxBytesForPointCloud = sizeof(android_depth_points) +
+ maxPointCount.data.i32[0] * sizeof(float) * FLOATS_PER_POINT;
+ return maxBytesForPointCloud;
+}
+
+
+
status_t Camera3Device::dump(int fd, const Vector<String16> &args) {
ATRACE_CALL();
(void)args;
@@ -865,14 +880,22 @@ status_t Camera3Device::createStream(sp<Surface> consumer,
sp<Camera3OutputStream> newStream;
if (format == HAL_PIXEL_FORMAT_BLOB) {
- ssize_t jpegBufferSize = getJpegBufferSize(width, height);
- if (jpegBufferSize <= 0) {
- SET_ERR_L("Invalid jpeg buffer size %zd", jpegBufferSize);
- return BAD_VALUE;
+ ssize_t blobBufferSize;
+ if (dataSpace != HAL_DATASPACE_DEPTH) {
+ blobBufferSize = getJpegBufferSize(width, height);
+ if (blobBufferSize <= 0) {
+ SET_ERR_L("Invalid jpeg buffer size %zd", blobBufferSize);
+ return BAD_VALUE;
+ }
+ } else {
+ blobBufferSize = getPointCloudBufferSize();
+ if (blobBufferSize <= 0) {
+ SET_ERR_L("Invalid point cloud buffer size %zd", blobBufferSize);
+ return BAD_VALUE;
+ }
}
-
newStream = new Camera3OutputStream(mNextStreamId, consumer,
- width, height, jpegBufferSize, format, dataSpace, rotation);
+ width, height, blobBufferSize, format, dataSpace, rotation);
} else {
newStream = new Camera3OutputStream(mNextStreamId, consumer,
width, height, format, dataSpace, rotation);
@@ -2067,8 +2090,12 @@ void Camera3Device::removeInFlightRequestIfReadyLocked(int idx) {
// Sanity check - if we have too many in-flight frames, something has
// likely gone wrong
- if (mInFlightMap.size() > kInFlightWarnLimit) {
+ if (!mIsConstrainedHighSpeedConfiguration && mInFlightMap.size() > kInFlightWarnLimit) {
CLOGE("In-flight list too large: %zu", mInFlightMap.size());
+ } else if (mIsConstrainedHighSpeedConfiguration && mInFlightMap.size() >
+ kInFlightWarnLimitHighSpeed) {
+ CLOGE("In-flight list too large for high speed configuration: %zu",
+ mInFlightMap.size());
}
}
diff --git a/services/camera/libcameraservice/device3/Camera3Device.h b/services/camera/libcameraservice/device3/Camera3Device.h
index 140da98..8bd0f8e 100644
--- a/services/camera/libcameraservice/device3/Camera3Device.h
+++ b/services/camera/libcameraservice/device3/Camera3Device.h
@@ -146,6 +146,7 @@ class Camera3Device :
virtual uint32_t getDeviceVersion();
virtual ssize_t getJpegBufferSize(uint32_t width, uint32_t height) const;
+ ssize_t getPointCloudBufferSize() const;
// Methods called by subclasses
void notifyStatus(bool idle); // updates from StatusTracker
@@ -153,9 +154,11 @@ class Camera3Device :
private:
static const size_t kDumpLockAttempts = 10;
static const size_t kDumpSleepDuration = 100000; // 0.10 sec
- static const size_t kInFlightWarnLimit = 20;
static const nsecs_t kShutdownTimeout = 5000000000; // 5 sec
static const nsecs_t kActiveTimeout = 500000000; // 500 ms
+ static const size_t kInFlightWarnLimit = 20;
+ static const size_t kInFlightWarnLimitHighSpeed = 256; // batch size 32 * pipe depth 8
+
struct RequestTrigger;
// minimal jpeg buffer size: 256KB + blob header
static const ssize_t kMinJpegBufferSize = 256 * 1024 + sizeof(camera3_jpeg_blob);