summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
Diffstat (limited to 'services')
-rw-r--r--services/audioflinger/Threads.cpp8
-rw-r--r--services/camera/libcameraservice/api1/client2/JpegProcessor.cpp15
2 files changed, 19 insertions, 4 deletions
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index faca7ab..12e09ab 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -2803,6 +2803,7 @@ AudioFlinger::MixerThread::MixerThread(const sp<AudioFlinger>& audioFlinger, Aud
// create a MonoPipe to connect our submix to FastMixer
NBAIO_Format format = mOutputSink->format();
+ NBAIO_Format origformat = format;
// adjust format to match that of the Fast Mixer
format.mFormat = fastMixerFormat;
format.mFrameSize = audio_bytes_per_sample(format.mFormat) * format.mChannelCount;
@@ -2822,14 +2823,15 @@ AudioFlinger::MixerThread::MixerThread(const sp<AudioFlinger>& audioFlinger, Aud
#ifdef TEE_SINK
if (mTeeSinkOutputEnabled) {
// create a Pipe to archive a copy of FastMixer's output for dumpsys
- Pipe *teeSink = new Pipe(mTeeSinkOutputFrames, format);
+ Pipe *teeSink = new Pipe(mTeeSinkOutputFrames, origformat);
+ const NBAIO_Format offers2[1] = {origformat};
numCounterOffers = 0;
- index = teeSink->negotiate(offers, 1, NULL, numCounterOffers);
+ index = teeSink->negotiate(offers2, 1, NULL, numCounterOffers);
ALOG_ASSERT(index == 0);
mTeeSink = teeSink;
PipeReader *teeSource = new PipeReader(*teeSink);
numCounterOffers = 0;
- index = teeSource->negotiate(offers, 1, NULL, numCounterOffers);
+ index = teeSource->negotiate(offers2, 1, NULL, numCounterOffers);
ALOG_ASSERT(index == 0);
mTeeSource = teeSource;
}
diff --git a/services/camera/libcameraservice/api1/client2/JpegProcessor.cpp b/services/camera/libcameraservice/api1/client2/JpegProcessor.cpp
index cda98be..b433781 100644
--- a/services/camera/libcameraservice/api1/client2/JpegProcessor.cpp
+++ b/services/camera/libcameraservice/api1/client2/JpegProcessor.cpp
@@ -89,14 +89,27 @@ status_t JpegProcessor::updateStream(const Parameters &params) {
mCaptureConsumer->setFrameAvailableListener(this);
mCaptureConsumer->setName(String8("Camera2Client::CaptureConsumer"));
mCaptureWindow = new Surface(producer);
+ }
+
+ // Since ashmem heaps are rounded up to page size, don't reallocate if
+ // the capture heap isn't exactly the same size as the required JPEG buffer
+ const size_t HEAP_SLACK_FACTOR = 2;
+ if (mCaptureHeap == 0 ||
+ (mCaptureHeap->getSize() < static_cast<size_t>(maxJpegSize)) ||
+ (mCaptureHeap->getSize() >
+ static_cast<size_t>(maxJpegSize) * HEAP_SLACK_FACTOR) ) {
// Create memory for API consumption
- mCaptureHeap = new MemoryHeapBase(maxJpegSize, 0, "Camera2Client::CaptureHeap");
+ mCaptureHeap.clear();
+ mCaptureHeap =
+ new MemoryHeapBase(maxJpegSize, 0, "Camera2Client::CaptureHeap");
if (mCaptureHeap->getSize() == 0) {
ALOGE("%s: Camera %d: Unable to allocate memory for capture",
__FUNCTION__, mId);
return NO_MEMORY;
}
}
+ ALOGV("%s: Camera %d: JPEG capture heap now %d bytes; requested %d bytes",
+ __FUNCTION__, mId, mCaptureHeap->getSize(), maxJpegSize);
if (mCaptureStreamId != NO_STREAM) {
// Check if stream parameters have to change