diff options
28 files changed, 137 insertions, 67 deletions
diff --git a/include/media/AudioEffect.h b/include/media/AudioEffect.h index 61da4f2..5af6c10 100644 --- a/include/media/AudioEffect.h +++ b/include/media/AudioEffect.h @@ -429,7 +429,8 @@ protected: private: // Implements the IEffectClient interface - class EffectClient : public android::BnEffectClient, public android::IBinder::DeathRecipient + class EffectClient : + public android::BnEffectClient, public android::IBinder::DeathRecipient { public: @@ -437,24 +438,39 @@ private: // IEffectClient virtual void controlStatusChanged(bool controlGranted) { - mEffect->controlStatusChanged(controlGranted); + sp<AudioEffect> effect = mEffect.promote(); + if (effect != 0) { + effect->controlStatusChanged(controlGranted); + } } virtual void enableStatusChanged(bool enabled) { - mEffect->enableStatusChanged(enabled); + sp<AudioEffect> effect = mEffect.promote(); + if (effect != 0) { + effect->enableStatusChanged(enabled); + } } virtual void commandExecuted(uint32_t cmdCode, uint32_t cmdSize, void *pCmdData, uint32_t replySize, void *pReplyData) { - mEffect->commandExecuted(cmdCode, cmdSize, pCmdData, replySize, pReplyData); + sp<AudioEffect> effect = mEffect.promote(); + if (effect != 0) { + effect->commandExecuted( + cmdCode, cmdSize, pCmdData, replySize, pReplyData); + } } // IBinder::DeathRecipient - virtual void binderDied(const wp<IBinder>& who) {mEffect->binderDied();} + virtual void binderDied(const wp<IBinder>& who) { + sp<AudioEffect> effect = mEffect.promote(); + if (effect != 0) { + effect->binderDied(); + } + } private: - AudioEffect *mEffect; + wp<AudioEffect> mEffect; }; void binderDied(); diff --git a/media/libmedia/AudioEffect.cpp b/media/libmedia/AudioEffect.cpp index bbeb854..ff82544 100644 --- a/media/libmedia/AudioEffect.cpp +++ b/media/libmedia/AudioEffect.cpp @@ -134,12 +134,14 @@ status_t AudioEffect::set(const effect_uuid_t *type, if (iEffect == 0 || (mStatus != NO_ERROR && mStatus != ALREADY_EXISTS)) { ALOGE("set(): AudioFlinger could not create effect, status: %d", mStatus); + if (iEffect == 0) { + mStatus = NO_INIT; + } return mStatus; } mEnabled = (volatile int32_t)enabled; - mIEffect = iEffect; cblk = iEffect->getCblk(); if (cblk == 0) { mStatus = NO_INIT; @@ -147,6 +149,7 @@ status_t AudioEffect::set(const effect_uuid_t *type, return mStatus; } + mIEffect = iEffect; mCblkMemory = cblk; mCblk = static_cast<effect_param_cblk_t*>(cblk->pointer()); int bufOffset = ((sizeof(effect_param_cblk_t) - 1) / sizeof(int) + 1) * sizeof(int); @@ -177,11 +180,11 @@ AudioEffect::~AudioEffect() mIEffect->disconnect(); IInterface::asBinder(mIEffect)->unlinkToDeath(mIEffectClient); } + mIEffect.clear(); + mCblkMemory.clear(); + mIEffectClient.clear(); IPCThreadState::self()->flushCommands(); } - mIEffect.clear(); - mIEffectClient.clear(); - mCblkMemory.clear(); } diff --git a/media/libmediaplayerservice/MediaPlayerService.cpp b/media/libmediaplayerservice/MediaPlayerService.cpp index c0b35e8..ae869d6 100644 --- a/media/libmediaplayerservice/MediaPlayerService.cpp +++ b/media/libmediaplayerservice/MediaPlayerService.cpp @@ -1679,7 +1679,7 @@ status_t MediaPlayerService::AudioOutput::open( t->setVolume(mLeftVolume, mRightVolume); mSampleRateHz = sampleRate; - mFlags = flags; + mFlags = t->getFlags(); // we suggest the flags above, but new AudioTrack() may not grant it. mMsecsPerFrame = 1E3f / (mPlaybackRate.mSpeed * sampleRate); uint32_t pos; if (t->getPosition(&pos) == OK) { @@ -1688,7 +1688,9 @@ status_t MediaPlayerService::AudioOutput::open( mTrack = t; status_t res = NO_ERROR; - if ((flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) == 0) { + // Note some output devices may give us a direct track even though we don't specify it. + // Example: Line application b/17459982. + if ((mFlags & (AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD | AUDIO_OUTPUT_FLAG_DIRECT)) == 0) { res = t->setPlaybackRate(mPlaybackRate); if (res == NO_ERROR) { t->setAuxEffectSendLevel(mSendLevel); diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp index f7e3117..eb4e67d 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp +++ b/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp @@ -841,7 +841,7 @@ bool NuPlayer::Renderer::onDrainAudioQueue() { if (written < 0) { // An error in AudioSink write. Perhaps the AudioSink was not properly opened. if (written == WOULD_BLOCK) { - ALOGW("AudioSink write would block when writing %zu bytes", copy); + ALOGV("AudioSink write would block when writing %zu bytes", copy); } else { ALOGE("AudioSink write error(%zd) when writing %zu bytes", written, copy); notifyAudioTearDown(); diff --git a/media/libstagefright/OggExtractor.cpp b/media/libstagefright/OggExtractor.cpp index 2451641..1c663a3 100644 --- a/media/libstagefright/OggExtractor.cpp +++ b/media/libstagefright/OggExtractor.cpp @@ -191,7 +191,8 @@ struct MyOpusExtractor : public MyOggExtractor { MyOpusExtractor(const sp<DataSource> &source) : MyOggExtractor(source, MEDIA_MIMETYPE_AUDIO_OPUS, /*numHeaders*/ 2, kOpusSeekPreRollUs), mChannelCount(0), - mCodecDelay(0) { + mCodecDelay(0), + mStartGranulePosition(-1) { } virtual uint64_t approxBitrate() const { @@ -211,6 +212,7 @@ private: uint8_t mChannelCount; uint16_t mCodecDelay; + int64_t mStartGranulePosition; }; static void extractAlbumArt( @@ -557,6 +559,37 @@ ssize_t MyOggExtractor::readPage(off64_t offset, Page *page) { } status_t MyOpusExtractor::readNextPacket(MediaBuffer **out) { + if (mOffset <= mFirstDataOffset && mStartGranulePosition < 0) { + // The first sample might not start at time 0; find out where by subtracting + // the number of samples on the first page from the granule position + // (position of last complete sample) of the first page. This happens + // the first time before we attempt to read a packet from the first page. + MediaBuffer *mBuf; + uint32_t numSamples = 0; + uint64_t curGranulePosition = 0; + while (true) { + status_t err = _readNextPacket(&mBuf, /* calcVorbisTimestamp = */false); + if (err != OK && err != ERROR_END_OF_STREAM) { + return err; + } + // First two pages are header pages. + if (err == ERROR_END_OF_STREAM || mCurrentPage.mPageNo > 2) { + break; + } + curGranulePosition = mCurrentPage.mGranulePosition; + numSamples += getNumSamplesInPacket(mBuf); + mBuf->release(); + mBuf = NULL; + } + + if (curGranulePosition > numSamples) { + mStartGranulePosition = curGranulePosition - numSamples; + } else { + mStartGranulePosition = 0; + } + seekToOffset(0); + } + status_t err = _readNextPacket(out, /* calcVorbisTimestamp = */false); if (err != OK) { return err; @@ -567,6 +600,10 @@ status_t MyOpusExtractor::readNextPacket(MediaBuffer **out) { // We assume that we only seek to page boundaries. if ((*out)->meta_data()->findInt32(kKeyValidSamples, ¤tPageSamples)) { // first packet in page + if (mOffset == mFirstDataOffset) { + currentPageSamples -= mStartGranulePosition; + (*out)->meta_data()->setInt32(kKeyValidSamples, currentPageSamples); + } mCurGranulePosition = mCurrentPage.mGranulePosition - currentPageSamples; } diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp index dc6710f..ad445a5 100644 --- a/services/audioflinger/Threads.cpp +++ b/services/audioflinger/Threads.cpp @@ -743,7 +743,8 @@ void AudioFlinger::ThreadBase::processConfigEvents_l() String8 channelMaskToString(audio_channel_mask_t mask, bool output) { String8 s; - const audio_channel_representation_t representation = audio_channel_mask_get_representation(mask); + const audio_channel_representation_t representation = + audio_channel_mask_get_representation(mask); switch (representation) { case AUDIO_CHANNEL_REPRESENTATION_POSITION: { @@ -6709,11 +6710,8 @@ bool AudioFlinger::RecordThread::checkForNewParameter_l(const String8& keyValueP audio_format_t reqFormat = mFormat; uint32_t samplingRate = mSampleRate; + // TODO this may change if we want to support capture from HDMI PCM multi channel (e.g on TVs). audio_channel_mask_t channelMask = audio_channel_in_mask_from_count(mChannelCount); - // possible that we are > 2 channels, use channel index mask - if (channelMask == AUDIO_CHANNEL_INVALID && mChannelCount <= FCC_8) { - audio_channel_mask_for_index_assignment_from_count(mChannelCount); - } AudioParameter param = AudioParameter(keyValuePair); int value; diff --git a/services/audiopolicy/enginedefault/src/Engine.cpp b/services/audiopolicy/enginedefault/src/Engine.cpp index 50f1609..7a785eb 100755 --- a/services/audiopolicy/enginedefault/src/Engine.cpp +++ b/services/audiopolicy/enginedefault/src/Engine.cpp @@ -498,6 +498,10 @@ audio_devices_t Engine::getDeviceForStrategy(routing_strategy strategy) const device2 = availableOutputDevices.types() & AUDIO_DEVICE_OUT_REMOTE_SUBMIX; } } + if (isInCall() && (strategy == STRATEGY_MEDIA)) { + device = getDeviceForStrategy(STRATEGY_PHONE); + break; + } if ((device2 == AUDIO_DEVICE_NONE) && (mForceUse[AUDIO_POLICY_FORCE_FOR_MEDIA] != AUDIO_POLICY_FORCE_NO_BT_A2DP) && (outputs.getA2dpOutput() != 0)) { diff --git a/services/camera/libcameraservice/CameraFlashlight.cpp b/services/camera/libcameraservice/CameraFlashlight.cpp index 8613ac6..280bb9d 100644 --- a/services/camera/libcameraservice/CameraFlashlight.cpp +++ b/services/camera/libcameraservice/CameraFlashlight.cpp @@ -359,7 +359,7 @@ CameraDeviceClientFlashControl::~CameraDeviceClientFlashControl() { delete mMetadata; } - mAnw.clear(); + mSurface.clear(); mSurfaceTexture.clear(); mProducer.clear(); mConsumer.clear(); @@ -395,11 +395,11 @@ status_t CameraDeviceClientFlashControl::initializeSurface( return res; } - mAnw = new Surface(mProducer, /*useAsync*/ true); - if (mAnw == NULL) { + mSurface = new Surface(mProducer, /*useAsync*/ true); + if (mSurface == NULL) { return NO_MEMORY; } - res = device->createStream(mAnw, width, height, format, + res = device->createStream(mSurface, width, height, format, HAL_DATASPACE_UNKNOWN, CAMERA3_STREAM_ROTATION_0, &mStreamId); if (res) { return res; @@ -653,7 +653,7 @@ CameraHardwareInterfaceFlashControl::CameraHardwareInterfaceFlashControl( CameraHardwareInterfaceFlashControl::~CameraHardwareInterfaceFlashControl() { disconnectCameraDevice(); - mAnw.clear(); + mSurface.clear(); mSurfaceTexture.clear(); mProducer.clear(); mConsumer.clear(); @@ -810,18 +810,18 @@ status_t CameraHardwareInterfaceFlashControl::initializePreviewWindow( return res; } - mAnw = new Surface(mProducer, /*useAsync*/ true); - if (mAnw == NULL) { + mSurface = new Surface(mProducer, /*useAsync*/ true); + if (mSurface == NULL) { return NO_MEMORY; } - res = native_window_api_connect(mAnw.get(), NATIVE_WINDOW_API_CAMERA); + res = native_window_api_connect(mSurface.get(), NATIVE_WINDOW_API_CAMERA); if (res) { ALOGE("%s: Unable to connect to native window", __FUNCTION__); return res; } - return device->setPreviewWindow(mAnw); + return device->setPreviewWindow(mSurface); } status_t CameraHardwareInterfaceFlashControl::connectCameraDevice( @@ -870,7 +870,7 @@ status_t CameraHardwareInterfaceFlashControl::disconnectCameraDevice() { CameraParameters::FLASH_MODE_OFF); mDevice->setParameters(mParameters); mDevice->stopPreview(); - status_t res = native_window_api_disconnect(mAnw.get(), + status_t res = native_window_api_disconnect(mSurface.get(), NATIVE_WINDOW_API_CAMERA); if (res) { ALOGW("%s: native_window_api_disconnect failed: %s (%d)", diff --git a/services/camera/libcameraservice/CameraFlashlight.h b/services/camera/libcameraservice/CameraFlashlight.h index 30f01f0..4d5fe8d 100644 --- a/services/camera/libcameraservice/CameraFlashlight.h +++ b/services/camera/libcameraservice/CameraFlashlight.h @@ -166,7 +166,7 @@ class CameraDeviceClientFlashControl : public FlashControlBase { sp<IGraphicBufferProducer> mProducer; sp<IGraphicBufferConsumer> mConsumer; sp<GLConsumer> mSurfaceTexture; - sp<ANativeWindow> mAnw; + sp<Surface> mSurface; int32_t mStreamId; Mutex mLock; @@ -215,7 +215,7 @@ class CameraHardwareInterfaceFlashControl : public FlashControlBase { sp<IGraphicBufferProducer> mProducer; sp<IGraphicBufferConsumer> mConsumer; sp<GLConsumer> mSurfaceTexture; - sp<ANativeWindow> mAnw; + sp<Surface> mSurface; Mutex mLock; }; diff --git a/services/camera/libcameraservice/api1/Camera2Client.cpp b/services/camera/libcameraservice/api1/Camera2Client.cpp index ca14cdb..e109595 100644 --- a/services/camera/libcameraservice/api1/Camera2Client.cpp +++ b/services/camera/libcameraservice/api1/Camera2Client.cpp @@ -529,7 +529,7 @@ status_t Camera2Client::setPreviewTarget( if ( (res = checkPid(__FUNCTION__) ) != OK) return res; sp<IBinder> binder; - sp<ANativeWindow> window; + sp<Surface> window; if (bufferProducer != 0) { binder = IInterface::asBinder(bufferProducer); // Using controlledByApp flag to ensure that the buffer queue remains in @@ -541,7 +541,7 @@ status_t Camera2Client::setPreviewTarget( } status_t Camera2Client::setPreviewWindowL(const sp<IBinder>& binder, - sp<ANativeWindow> window) { + sp<Surface> window) { ATRACE_CALL(); status_t res; @@ -666,7 +666,7 @@ status_t Camera2Client::setPreviewCallbackTarget( status_t res; if ( (res = checkPid(__FUNCTION__) ) != OK) return res; - sp<ANativeWindow> window; + sp<Surface> window; if (callbackProducer != 0) { window = new Surface(callbackProducer); } diff --git a/services/camera/libcameraservice/api1/Camera2Client.h b/services/camera/libcameraservice/api1/Camera2Client.h index c6df228..c288313 100644 --- a/services/camera/libcameraservice/api1/Camera2Client.h +++ b/services/camera/libcameraservice/api1/Camera2Client.h @@ -150,7 +150,7 @@ private: typedef camera2::Parameters Parameters; status_t setPreviewWindowL(const sp<IBinder>& binder, - sp<ANativeWindow> window); + sp<Surface> window); status_t startPreviewL(Parameters ¶ms, bool restart); void stopPreviewL(); status_t startRecordingL(Parameters ¶ms, bool restart); diff --git a/services/camera/libcameraservice/api1/client2/CallbackProcessor.cpp b/services/camera/libcameraservice/api1/client2/CallbackProcessor.cpp index 143cc61..5f4fb22 100644 --- a/services/camera/libcameraservice/api1/client2/CallbackProcessor.cpp +++ b/services/camera/libcameraservice/api1/client2/CallbackProcessor.cpp @@ -55,7 +55,7 @@ void CallbackProcessor::onFrameAvailable(const BufferItem& /*item*/) { } status_t CallbackProcessor::setCallbackWindow( - sp<ANativeWindow> callbackWindow) { + sp<Surface> callbackWindow) { ATRACE_CALL(); status_t res; @@ -115,7 +115,7 @@ status_t CallbackProcessor::updateStream(const Parameters ¶ms) { BufferQueue::createBufferQueue(&producer, &consumer); mCallbackConsumer = new CpuConsumer(consumer, kCallbackHeapCount); mCallbackConsumer->setFrameAvailableListener(this); - mCallbackConsumer->setName(String8("Camera2Client::CallbackConsumer")); + mCallbackConsumer->setName(String8("Camera2-CallbackConsumer")); mCallbackWindow = new Surface(producer); } diff --git a/services/camera/libcameraservice/api1/client2/CallbackProcessor.h b/services/camera/libcameraservice/api1/client2/CallbackProcessor.h index 7fdc329..a290536 100644 --- a/services/camera/libcameraservice/api1/client2/CallbackProcessor.h +++ b/services/camera/libcameraservice/api1/client2/CallbackProcessor.h @@ -47,7 +47,7 @@ class CallbackProcessor: void onFrameAvailable(const BufferItem& item); // Set to NULL to disable the direct-to-app callback window - status_t setCallbackWindow(sp<ANativeWindow> callbackWindow); + status_t setCallbackWindow(sp<Surface> callbackWindow); status_t updateStream(const Parameters ¶ms); status_t deleteStream(); int getStreamId() const; @@ -73,7 +73,7 @@ class CallbackProcessor: int mCallbackStreamId; static const size_t kCallbackHeapCount = 6; sp<CpuConsumer> mCallbackConsumer; - sp<ANativeWindow> mCallbackWindow; + sp<Surface> mCallbackWindow; sp<Camera2Heap> mCallbackHeap; int mCallbackHeapId; size_t mCallbackHeapHead, mCallbackHeapFree; diff --git a/services/camera/libcameraservice/api1/client2/JpegProcessor.cpp b/services/camera/libcameraservice/api1/client2/JpegProcessor.cpp index 88987f9..bd9786f 100644 --- a/services/camera/libcameraservice/api1/client2/JpegProcessor.cpp +++ b/services/camera/libcameraservice/api1/client2/JpegProcessor.cpp @@ -87,7 +87,7 @@ status_t JpegProcessor::updateStream(const Parameters ¶ms) { BufferQueue::createBufferQueue(&producer, &consumer); mCaptureConsumer = new CpuConsumer(consumer, 1); mCaptureConsumer->setFrameAvailableListener(this); - mCaptureConsumer->setName(String8("Camera2Client::CaptureConsumer")); + mCaptureConsumer->setName(String8("Camera2-JpegConsumer")); mCaptureWindow = new Surface(producer); } diff --git a/services/camera/libcameraservice/api1/client2/JpegProcessor.h b/services/camera/libcameraservice/api1/client2/JpegProcessor.h index 2040b30..fbdae11 100644 --- a/services/camera/libcameraservice/api1/client2/JpegProcessor.h +++ b/services/camera/libcameraservice/api1/client2/JpegProcessor.h @@ -70,8 +70,8 @@ class JpegProcessor: int mCaptureStreamId; sp<CpuConsumer> mCaptureConsumer; - sp<ANativeWindow> mCaptureWindow; - sp<MemoryHeapBase> mCaptureHeap; + sp<Surface> mCaptureWindow; + sp<MemoryHeapBase> mCaptureHeap; virtual bool threadLoop(); diff --git a/services/camera/libcameraservice/api1/client2/StreamingProcessor.cpp b/services/camera/libcameraservice/api1/client2/StreamingProcessor.cpp index 36d143b..66d7b00 100644 --- a/services/camera/libcameraservice/api1/client2/StreamingProcessor.cpp +++ b/services/camera/libcameraservice/api1/client2/StreamingProcessor.cpp @@ -64,7 +64,7 @@ StreamingProcessor::~StreamingProcessor() { deleteRecordingStream(); } -status_t StreamingProcessor::setPreviewWindow(sp<ANativeWindow> window) { +status_t StreamingProcessor::setPreviewWindow(sp<Surface> window) { ATRACE_CALL(); status_t res; diff --git a/services/camera/libcameraservice/api1/client2/StreamingProcessor.h b/services/camera/libcameraservice/api1/client2/StreamingProcessor.h index 42e9e7a..e0cad3a 100644 --- a/services/camera/libcameraservice/api1/client2/StreamingProcessor.h +++ b/services/camera/libcameraservice/api1/client2/StreamingProcessor.h @@ -43,7 +43,7 @@ class StreamingProcessor: StreamingProcessor(sp<Camera2Client> client); ~StreamingProcessor(); - status_t setPreviewWindow(sp<ANativeWindow> window); + status_t setPreviewWindow(sp<Surface> window); bool haveValidPreviewWindow() const; @@ -108,7 +108,7 @@ class StreamingProcessor: int32_t mPreviewRequestId; int mPreviewStreamId; CameraMetadata mPreviewRequest; - sp<ANativeWindow> mPreviewWindow; + sp<Surface> mPreviewWindow; // Recording-related members static const nsecs_t kWaitDuration = 50000000; // 50 ms @@ -117,7 +117,7 @@ class StreamingProcessor: int mRecordingStreamId; int mRecordingFrameCount; sp<BufferItemConsumer> mRecordingConsumer; - sp<ANativeWindow> mRecordingWindow; + sp<Surface> mRecordingWindow; CameraMetadata mRecordingRequest; sp<camera2::Camera2Heap> mRecordingHeap; diff --git a/services/camera/libcameraservice/api1/client2/ZslProcessor.cpp b/services/camera/libcameraservice/api1/client2/ZslProcessor.cpp index d8500df..0b79b31 100644 --- a/services/camera/libcameraservice/api1/client2/ZslProcessor.cpp +++ b/services/camera/libcameraservice/api1/client2/ZslProcessor.cpp @@ -139,7 +139,7 @@ status_t ZslProcessor::updateStream(const Parameters ¶ms) { GRALLOC_USAGE_HW_CAMERA_ZSL, kZslBufferDepth); mZslConsumer->setFrameAvailableListener(this); - mZslConsumer->setName(String8("Camera2Client::ZslConsumer")); + mZslConsumer->setName(String8("Camera2-ZslConsumer")); mZslWindow = new Surface(producer); } diff --git a/services/camera/libcameraservice/api1/client2/ZslProcessor.h b/services/camera/libcameraservice/api1/client2/ZslProcessor.h index 5f50d7b..5870bd3 100644 --- a/services/camera/libcameraservice/api1/client2/ZslProcessor.h +++ b/services/camera/libcameraservice/api1/client2/ZslProcessor.h @@ -101,7 +101,7 @@ class ZslProcessor: int mZslStreamId; int mZslReprocessStreamId; sp<BufferItemConsumer> mZslConsumer; - sp<ANativeWindow> mZslWindow; + sp<Surface> mZslWindow; struct ZslPair { BufferItem buffer; diff --git a/services/camera/libcameraservice/api2/CameraDeviceClient.cpp b/services/camera/libcameraservice/api2/CameraDeviceClient.cpp index 4d276be..3b83f63 100644 --- a/services/camera/libcameraservice/api2/CameraDeviceClient.cpp +++ b/services/camera/libcameraservice/api2/CameraDeviceClient.cpp @@ -411,27 +411,28 @@ status_t CameraDeviceClient::createStream(const OutputConfiguration &outputConfi (consumerUsage & allowedFlags) != 0; sp<IBinder> binder = IInterface::asBinder(bufferProducer); - sp<ANativeWindow> anw = new Surface(bufferProducer, useAsync); + sp<Surface> surface = new Surface(bufferProducer, useAsync); + ANativeWindow *anw = surface.get(); int width, height, format; android_dataspace dataSpace; - if ((res = anw->query(anw.get(), NATIVE_WINDOW_WIDTH, &width)) != OK) { + if ((res = anw->query(anw, NATIVE_WINDOW_WIDTH, &width)) != OK) { ALOGE("%s: Camera %d: Failed to query Surface width", __FUNCTION__, mCameraId); return res; } - if ((res = anw->query(anw.get(), NATIVE_WINDOW_HEIGHT, &height)) != OK) { + if ((res = anw->query(anw, NATIVE_WINDOW_HEIGHT, &height)) != OK) { ALOGE("%s: Camera %d: Failed to query Surface height", __FUNCTION__, mCameraId); return res; } - if ((res = anw->query(anw.get(), NATIVE_WINDOW_FORMAT, &format)) != OK) { + if ((res = anw->query(anw, NATIVE_WINDOW_FORMAT, &format)) != OK) { ALOGE("%s: Camera %d: Failed to query Surface format", __FUNCTION__, mCameraId); return res; } - if ((res = anw->query(anw.get(), NATIVE_WINDOW_DEFAULT_DATASPACE, + if ((res = anw->query(anw, NATIVE_WINDOW_DEFAULT_DATASPACE, reinterpret_cast<int*>(&dataSpace))) != OK) { ALOGE("%s: Camera %d: Failed to query Surface dataSpace", __FUNCTION__, mCameraId); @@ -456,7 +457,7 @@ status_t CameraDeviceClient::createStream(const OutputConfiguration &outputConfi } int streamId = -1; - res = mDevice->createStream(anw, width, height, format, dataSpace, + res = mDevice->createStream(surface, width, height, format, dataSpace, static_cast<camera3_stream_rotation_t> (outputConfiguration.getRotation()), &streamId); diff --git a/services/camera/libcameraservice/common/CameraDeviceBase.h b/services/camera/libcameraservice/common/CameraDeviceBase.h index 27c33a3..06177e3 100644 --- a/services/camera/libcameraservice/common/CameraDeviceBase.h +++ b/services/camera/libcameraservice/common/CameraDeviceBase.h @@ -106,7 +106,7 @@ class CameraDeviceBase : public virtual RefBase { * For HAL_PIXEL_FORMAT_BLOB formats, the width and height should be the * logical dimensions of the buffer, not the number of bytes. */ - virtual status_t createStream(sp<ANativeWindow> consumer, + virtual status_t createStream(sp<Surface> consumer, uint32_t width, uint32_t height, int format, android_dataspace dataSpace, camera3_stream_rotation_t rotation, int *id) = 0; diff --git a/services/camera/libcameraservice/device2/Camera2Device.cpp b/services/camera/libcameraservice/device2/Camera2Device.cpp index 88f555b..dfe5565 100644 --- a/services/camera/libcameraservice/device2/Camera2Device.cpp +++ b/services/camera/libcameraservice/device2/Camera2Device.cpp @@ -240,7 +240,7 @@ status_t Camera2Device::waitUntilRequestReceived(int32_t requestId, nsecs_t time return mRequestQueue.waitForDequeue(requestId, timeout); } -status_t Camera2Device::createStream(sp<ANativeWindow> consumer, +status_t Camera2Device::createStream(sp<Surface> consumer, uint32_t width, uint32_t height, int format, android_dataspace /*dataSpace*/, camera3_stream_rotation_t rotation, int *id) { ATRACE_CALL(); diff --git a/services/camera/libcameraservice/device2/Camera2Device.h b/services/camera/libcameraservice/device2/Camera2Device.h index a001a91..c9f3a2c 100644 --- a/services/camera/libcameraservice/device2/Camera2Device.h +++ b/services/camera/libcameraservice/device2/Camera2Device.h @@ -56,7 +56,7 @@ class Camera2Device: public CameraDeviceBase { int64_t *lastFrameNumber = NULL); virtual status_t clearStreamingRequest(int64_t *lastFrameNumber = NULL); virtual status_t waitUntilRequestReceived(int32_t requestId, nsecs_t timeout); - virtual status_t createStream(sp<ANativeWindow> consumer, + virtual status_t createStream(sp<Surface> consumer, uint32_t width, uint32_t height, int format, android_dataspace dataSpace, camera3_stream_rotation_t rotation, int *id); virtual status_t createInputStream( diff --git a/services/camera/libcameraservice/device3/Camera3Device.cpp b/services/camera/libcameraservice/device3/Camera3Device.cpp index 852751c..c28a57e 100644 --- a/services/camera/libcameraservice/device3/Camera3Device.cpp +++ b/services/camera/libcameraservice/device3/Camera3Device.cpp @@ -57,6 +57,7 @@ namespace android { Camera3Device::Camera3Device(int id): mId(id), + mIsConstrainedHighSpeedConfiguration(false), mHal3Device(NULL), mStatus(STATUS_UNINITIALIZED), mUsePartialResult(false), @@ -420,7 +421,7 @@ status_t Camera3Device::dump(int fd, const Vector<String16> &args) { } lines.appendFormat(" Stream configuration:\n"); lines.appendFormat(" Operation mode: %s \n", mIsConstrainedHighSpeedConfiguration ? - "CONSTAINED HIGH SPEED VIDEO" : "NORMAL"); + "CONSTRAINED HIGH SPEED VIDEO" : "NORMAL"); if (mInputStream != NULL) { write(fd, lines.string(), lines.size()); @@ -816,7 +817,7 @@ status_t Camera3Device::createZslStream( return OK; } -status_t Camera3Device::createStream(sp<ANativeWindow> consumer, +status_t Camera3Device::createStream(sp<Surface> consumer, uint32_t width, uint32_t height, int format, android_dataspace dataSpace, camera3_stream_rotation_t rotation, int *id) { ATRACE_CALL(); diff --git a/services/camera/libcameraservice/device3/Camera3Device.h b/services/camera/libcameraservice/device3/Camera3Device.h index 180b1f8..e2fd8d4 100644 --- a/services/camera/libcameraservice/device3/Camera3Device.h +++ b/services/camera/libcameraservice/device3/Camera3Device.h @@ -94,7 +94,7 @@ class Camera3Device : // Actual stream creation/deletion is delayed until first request is submitted // If adding streams while actively capturing, will pause device before adding // stream, reconfiguring device, and unpausing. - virtual status_t createStream(sp<ANativeWindow> consumer, + virtual status_t createStream(sp<Surface> consumer, uint32_t width, uint32_t height, int format, android_dataspace dataSpace, camera3_stream_rotation_t rotation, int *id); virtual status_t createInputStream( diff --git a/services/camera/libcameraservice/device3/Camera3OutputStream.cpp b/services/camera/libcameraservice/device3/Camera3OutputStream.cpp index 7a0331b..8c611d5 100644 --- a/services/camera/libcameraservice/device3/Camera3OutputStream.cpp +++ b/services/camera/libcameraservice/device3/Camera3OutputStream.cpp @@ -32,7 +32,7 @@ namespace android { namespace camera3 { Camera3OutputStream::Camera3OutputStream(int id, - sp<ANativeWindow> consumer, + sp<Surface> consumer, uint32_t width, uint32_t height, int format, android_dataspace dataSpace, camera3_stream_rotation_t rotation) : Camera3IOStreamBase(id, CAMERA3_STREAM_OUTPUT, width, height, @@ -48,7 +48,7 @@ Camera3OutputStream::Camera3OutputStream(int id, } Camera3OutputStream::Camera3OutputStream(int id, - sp<ANativeWindow> consumer, + sp<Surface> consumer, uint32_t width, uint32_t height, size_t maxSize, int format, android_dataspace dataSpace, camera3_stream_rotation_t rotation) : Camera3IOStreamBase(id, CAMERA3_STREAM_OUTPUT, width, height, maxSize, @@ -229,6 +229,7 @@ void Camera3OutputStream::dump(int fd, const Vector<String16> &args) const { (void) args; String8 lines; lines.appendFormat(" Stream[%d]: Output\n", mId); + lines.appendFormat(" Consumer name: %s\n", mConsumerName.string()); write(fd, lines.string(), lines.size()); Camera3IOStreamBase::dump(fd, args); @@ -278,6 +279,8 @@ status_t Camera3OutputStream::configureQueueLocked() { return res; } + mConsumerName = mConsumer->getConsumerName(); + res = native_window_set_usage(mConsumer.get(), camera3_stream::usage); if (res != OK) { ALOGE("%s: Unable to configure usage %08x for stream %d", @@ -326,7 +329,8 @@ status_t Camera3OutputStream::configureQueueLocked() { } int maxConsumerBuffers; - res = mConsumer->query(mConsumer.get(), + res = static_cast<ANativeWindow*>(mConsumer.get())->query( + mConsumer.get(), NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS, &maxConsumerBuffers); if (res != OK) { ALOGE("%s: Unable to query consumer undequeued" @@ -401,7 +405,7 @@ status_t Camera3OutputStream::getEndpointUsage(uint32_t *usage) const { status_t res; int32_t u = 0; - res = mConsumer->query(mConsumer.get(), + res = static_cast<ANativeWindow*>(mConsumer.get())->query(mConsumer.get(), NATIVE_WINDOW_CONSUMER_USAGE_BITS, &u); // If an opaque output stream's endpoint is ImageReader, add diff --git a/services/camera/libcameraservice/device3/Camera3OutputStream.h b/services/camera/libcameraservice/device3/Camera3OutputStream.h index 513b695..941d693 100644 --- a/services/camera/libcameraservice/device3/Camera3OutputStream.h +++ b/services/camera/libcameraservice/device3/Camera3OutputStream.h @@ -38,7 +38,7 @@ class Camera3OutputStream : /** * Set up a stream for formats that have 2 dimensions, such as RAW and YUV. */ - Camera3OutputStream(int id, sp<ANativeWindow> consumer, + Camera3OutputStream(int id, sp<Surface> consumer, uint32_t width, uint32_t height, int format, android_dataspace dataSpace, camera3_stream_rotation_t rotation); @@ -46,7 +46,7 @@ class Camera3OutputStream : * Set up a stream for formats that have a variable buffer size for the same * dimensions, such as compressed JPEG. */ - Camera3OutputStream(int id, sp<ANativeWindow> consumer, + Camera3OutputStream(int id, sp<Surface> consumer, uint32_t width, uint32_t height, size_t maxSize, int format, android_dataspace dataSpace, camera3_stream_rotation_t rotation); @@ -81,7 +81,7 @@ class Camera3OutputStream : virtual status_t disconnectLocked(); - sp<ANativeWindow> mConsumer; + sp<Surface> mConsumer; private: int mTransform; @@ -89,6 +89,9 @@ class Camera3OutputStream : bool mTraceFirstBuffer; + // Name of Surface consumer + String8 mConsumerName; + /** * Internal Camera3Stream interface */ diff --git a/services/camera/libcameraservice/device3/Camera3ZslStream.cpp b/services/camera/libcameraservice/device3/Camera3ZslStream.cpp index 10d7f2e..eefcb44 100644 --- a/services/camera/libcameraservice/device3/Camera3ZslStream.cpp +++ b/services/camera/libcameraservice/device3/Camera3ZslStream.cpp @@ -122,6 +122,7 @@ Camera3ZslStream::Camera3ZslStream(int id, uint32_t width, uint32_t height, sp<IGraphicBufferConsumer> consumer; BufferQueue::createBufferQueue(&producer, &consumer); mProducer = new RingBufferConsumer(consumer, GRALLOC_USAGE_HW_CAMERA_ZSL, bufferCount); + mProducer->setName(String8("Camera2-ZslRingBufferConsumer")); mConsumer = new Surface(producer); } |