Merge "AudioFlinger: Add datapath subproject"
diff --git a/cmds/stagefright/stagefright.cpp b/cmds/stagefright/stagefright.cpp
index 9783855..2edc0fe 100644
--- a/cmds/stagefright/stagefright.cpp
+++ b/cmds/stagefright/stagefright.cpp
@@ -749,7 +749,8 @@
mediaType.equalsIgnoreCase(MIMETYPE_VIDEO_VP8) ? asString_VP8Profile(pl.mProfile) :
mediaType.equalsIgnoreCase(MIMETYPE_VIDEO_HEVC) ? asString_HEVCProfile(pl.mProfile) :
mediaType.equalsIgnoreCase(MIMETYPE_VIDEO_VP9) ? asString_VP9Profile(pl.mProfile) :
- mediaType.equalsIgnoreCase(MIMETYPE_VIDEO_AV1) ? asString_AV1Profile(pl.mProfile) :"??";
+ mediaType.equalsIgnoreCase(MIMETYPE_VIDEO_AV1) ? asString_AV1Profile(pl.mProfile) :
+ mediaType.equalsIgnoreCase(MIMETYPE_VIDEO_DOLBY_VISION) ? asString_DolbyVisionProfile(pl.mProfile) :"??";
const char *niceLevel =
mediaType.equalsIgnoreCase(MIMETYPE_VIDEO_MPEG2) ? asString_MPEG2Level(pl.mLevel) :
mediaType.equalsIgnoreCase(MIMETYPE_VIDEO_H263) ? asString_H263Level(pl.mLevel) :
@@ -759,6 +760,7 @@
mediaType.equalsIgnoreCase(MIMETYPE_VIDEO_HEVC) ? asString_HEVCTierLevel(pl.mLevel) :
mediaType.equalsIgnoreCase(MIMETYPE_VIDEO_VP9) ? asString_VP9Level(pl.mLevel) :
mediaType.equalsIgnoreCase(MIMETYPE_VIDEO_AV1) ? asString_AV1Level(pl.mLevel) :
+ mediaType.equalsIgnoreCase(MIMETYPE_VIDEO_DOLBY_VISION) ? asString_DolbyVisionLevel(pl.mLevel) :
"??";
list.add(AStringPrintf("% 5u/% 5u (%s/%s)",
diff --git a/media/codec2/core/include/C2Buffer.h b/media/codec2/core/include/C2Buffer.h
index abe343b..7e1df91 100644
--- a/media/codec2/core/include/C2Buffer.h
+++ b/media/codec2/core/include/C2Buffer.h
@@ -101,6 +101,8 @@
/**
* Returns a file descriptor that can be used to wait for this fence in a select system call.
+ * \note If there are multiple file descriptors in fence then a file descriptor for merged fence
+ * would be returned
* \note The returned file descriptor, if valid, must be closed by the caller.
*
* This can be used in e.g. poll() system calls. This file becomes readable (POLLIN) when the
@@ -129,6 +131,7 @@
std::shared_ptr<Impl> mImpl;
C2Fence(std::shared_ptr<Impl> impl);
friend struct _C2FenceFactory;
+ friend std::vector<int> ExtractFdsFromCodec2SyncFence(const C2Fence& fence);
};
/**
diff --git a/media/codec2/vndk/C2Fence.cpp b/media/codec2/vndk/C2Fence.cpp
index aa908a8..0344fd3 100644
--- a/media/codec2/vndk/C2Fence.cpp
+++ b/media/codec2/vndk/C2Fence.cpp
@@ -190,7 +190,6 @@
if (timeoutMs > INT_MAX) {
timeoutMs = INT_MAX;
}
-
switch (mFence->wait((int)timeoutMs)) {
case NO_ERROR:
return C2_OK;
@@ -202,7 +201,7 @@
}
virtual bool valid() const {
- return mFence->getStatus() != Fence::Status::Invalid;
+ return (mFence && (mFence->getStatus() != Fence::Status::Invalid));
}
virtual bool ready() const {
@@ -213,6 +212,14 @@
return mFence->dup();
}
+ std::vector<int> fds() const {
+ std::vector<int> retFds;
+ for (int index = 0; index < mListFences.size(); index++) {
+ retFds.push_back(mListFences[index]->dup());
+ }
+ return retFds;
+ }
+
virtual bool isHW() const {
return true;
}
@@ -222,39 +229,95 @@
}
virtual native_handle_t *createNativeHandle() const {
- native_handle_t* nh = native_handle_create(1, 1);
+ std::vector<int> nativeFds = fds();
+ nativeFds.push_back(fd());
+ native_handle_t* nh = native_handle_create(nativeFds.size(), 1);
if (!nh) {
ALOGE("Failed to allocate native handle for sync fence");
+ for (int fd : nativeFds) {
+ close(fd);
+ }
return nullptr;
}
- nh->data[0] = fd();
- nh->data[1] = type();
+
+ for (int i = 0; i < nativeFds.size(); i++) {
+ nh->data[i] = nativeFds[i];
+ }
+ nh->data[nativeFds.size()] = type();
return nh;
}
virtual ~SyncFenceImpl() {};
SyncFenceImpl(int fenceFd) :
- mFence(sp<Fence>::make(fenceFd)) {}
+ mFence(sp<Fence>::make(fenceFd)) {
+ mListFences.clear();
+ if (mFence) {
+ mListFences.push_back(mFence);
+ }
+ }
+
+ SyncFenceImpl(const std::vector<int>& fenceFds, int mergedFd) {
+ mListFences.clear();
+
+ for (int fenceFd : fenceFds) {
+ if (fenceFd < 0) {
+ continue;
+ } else {
+ mListFences.push_back(sp<Fence>::make(fenceFd));
+ if (!mListFences.back()) {
+ mFence.clear();
+ break;
+ }
+ if (mergedFd == -1) {
+ mFence = (mFence == nullptr) ? (mListFences.back()) :
+ (Fence::merge("syncFence", mFence, mListFences.back()));
+ }
+ }
+ }
+ if (mergedFd != -1)
+ {
+ mFence = sp<Fence>::make(mergedFd);
+ }
+ if (!mFence) {
+ mListFences.clear();
+ }
+ }
static std::shared_ptr<SyncFenceImpl> CreateFromNativeHandle(const native_handle_t* nh) {
- if (!nh || nh->numFds != 1 || nh->numInts != 1) {
+ if (!nh || nh->numFds < 1 || nh->numInts < 1) {
ALOGE("Invalid handle for sync fence");
return nullptr;
}
- int fd = dup(nh->data[0]);
- std::shared_ptr<SyncFenceImpl> p = std::make_shared<SyncFenceImpl>(fd);
+ std::vector<int> fds;
+ for (int i = 0; i < nh->numFds-1; i++) {
+ fds.push_back(dup(nh->data[i]));
+ }
+ std::shared_ptr<SyncFenceImpl> p = (nh->numFds == 1)?
+ (std::make_shared<SyncFenceImpl>(fds.back())):
+ (std::make_shared<SyncFenceImpl>(fds, (dup(nh->data[nh->numFds-1]))));
if (!p) {
ALOGE("Failed to allocate sync fence impl");
- close(fd);
+ for (int fd : fds) {
+ close(fd);
+ }
}
return p;
}
private:
- const sp<Fence> mFence;
+ std::vector<sp<Fence>> mListFences;
+ sp<Fence> mFence; //merged fence in case mListFences size > 0
};
+std::vector<int> ExtractFdsFromCodec2SyncFence(const C2Fence& fence) {
+ std::vector<int> retFds;
+ if ((fence.mImpl) && (fence.mImpl->type() == C2Fence::Impl::SYNC_FENCE)) {
+ retFds = static_cast<_C2FenceFactory::SyncFenceImpl *>(fence.mImpl.get())->fds();
+ }
+ return retFds;
+}
+
C2Fence _C2FenceFactory::CreateSyncFence(int fenceFd) {
std::shared_ptr<C2Fence::Impl> p;
if (fenceFd >= 0) {
@@ -262,8 +325,7 @@
if (!p) {
ALOGE("Failed to allocate sync fence impl");
close(fenceFd);
- }
- if (!p->valid()) {
+ } else if (!p->valid()) {
p.reset();
}
} else {
@@ -272,6 +334,25 @@
return C2Fence(p);
}
+C2Fence _C2FenceFactory::CreateMultipleFdSyncFence(const std::vector<int>& fenceFds) {
+ std::shared_ptr<C2Fence::Impl> p;
+ if (fenceFds.size() > 0) {
+ p = std::make_shared<_C2FenceFactory::SyncFenceImpl>(fenceFds, -1);
+ if (!p) {
+ ALOGE("Failed to allocate sync fence impl closing FDs");
+ for (int fenceFd : fenceFds) {
+ close(fenceFd);
+ }
+ } else if (!p->valid()) {
+ ALOGE("Invalid sync fence created");
+ p.reset();
+ }
+ } else {
+ ALOGE("Create sync fence from invalid fd list of size 0");
+ }
+ return C2Fence(p);
+}
+
native_handle_t* _C2FenceFactory::CreateNativeHandle(const C2Fence& fence) {
return fence.mImpl? fence.mImpl->createNativeHandle() : nullptr;
}
diff --git a/media/codec2/vndk/include/C2FenceFactory.h b/media/codec2/vndk/include/C2FenceFactory.h
index 4944115..ef25c47 100644
--- a/media/codec2/vndk/include/C2FenceFactory.h
+++ b/media/codec2/vndk/include/C2FenceFactory.h
@@ -20,6 +20,16 @@
#include <C2Buffer.h>
+/*
+ * Create a list of fds from fence
+ *
+ * \param fence C2Fence object from which associated
+ * file descriptors need to be extracted
+ * \return a vector of fds otherwise return vector of size 0
+ */
+
+std::vector<int> ExtractFdsFromCodec2SyncFence(const C2Fence& fence);
+
class C2SurfaceSyncMemory;
/**
@@ -48,6 +58,14 @@
*/
static C2Fence CreateSyncFence(int fenceFd);
+ /*
+ * Create C2Fence from list of fence file fds.
+ *
+ * \param fenceFds Vector of file descriptor for fence.
+ * It will be owned and closed by the returned fence object.
+ */
+ static C2Fence CreateMultipleFdSyncFence(const std::vector<int>& fenceFds);
+
/**
* Create a native handle from fence for marshalling
*
diff --git a/media/libaudiohal/impl/DeviceHalAidl.cpp b/media/libaudiohal/impl/DeviceHalAidl.cpp
index b1b7e00..06c5f53 100644
--- a/media/libaudiohal/impl/DeviceHalAidl.cpp
+++ b/media/libaudiohal/impl/DeviceHalAidl.cpp
@@ -882,7 +882,7 @@
return OK;
}
-status_t DeviceHalAidl::addDeviceEffect(audio_port_handle_t device __unused,
+status_t DeviceHalAidl::addDeviceEffect(const struct audio_port_config *device __unused,
sp<EffectHalInterface> effect) {
if (!effect) {
return BAD_VALUE;
@@ -892,7 +892,7 @@
ALOGE("%s not implemented yet", __func__);
return OK;
}
-status_t DeviceHalAidl::removeDeviceEffect(audio_port_handle_t device __unused,
+status_t DeviceHalAidl::removeDeviceEffect(const struct audio_port_config *device __unused,
sp<EffectHalInterface> effect) {
if (!effect) {
return BAD_VALUE;
diff --git a/media/libaudiohal/impl/DeviceHalAidl.h b/media/libaudiohal/impl/DeviceHalAidl.h
index 03afbb7..74a8b51 100644
--- a/media/libaudiohal/impl/DeviceHalAidl.h
+++ b/media/libaudiohal/impl/DeviceHalAidl.h
@@ -149,9 +149,11 @@
// List microphones
status_t getMicrophones(std::vector<audio_microphone_characteristic_t>* microphones) override;
- status_t addDeviceEffect(audio_port_handle_t device, sp<EffectHalInterface> effect) override;
+ status_t addDeviceEffect(
+ const struct audio_port_config *device, sp<EffectHalInterface> effect) override;
- status_t removeDeviceEffect(audio_port_handle_t device, sp<EffectHalInterface> effect) override;
+ status_t removeDeviceEffect(
+ const struct audio_port_config *device, sp<EffectHalInterface> effect) override;
status_t getMmapPolicyInfos(media::audio::common::AudioMMapPolicyType policyType __unused,
std::vector<media::audio::common::AudioMMapPolicyInfo>* policyInfos
diff --git a/media/libaudiohal/impl/DeviceHalHidl.cpp b/media/libaudiohal/impl/DeviceHalHidl.cpp
index 826461f..f96d419 100644
--- a/media/libaudiohal/impl/DeviceHalHidl.cpp
+++ b/media/libaudiohal/impl/DeviceHalHidl.cpp
@@ -32,6 +32,7 @@
#include <util/CoreUtils.h>
#include "DeviceHalHidl.h"
+#include "EffectHalHidl.h"
#include "ParameterUtils.h"
#include "StreamHalHidl.h"
@@ -523,30 +524,32 @@
#if MAJOR_VERSION >= 6
status_t DeviceHalHidl::addDeviceEffect(
- audio_port_handle_t device, sp<EffectHalInterface> effect) {
+ const struct audio_port_config *device, sp<EffectHalInterface> effect) {
TIME_CHECK();
if (mDevice == 0) return NO_INIT;
+ auto hidlEffect = sp<effect::EffectHalHidl>::cast(effect);
return processReturn("addDeviceEffect", mDevice->addDeviceEffect(
- static_cast<AudioPortHandle>(device), effect->effectId()));
+ static_cast<AudioPortHandle>(device->id), hidlEffect->effectId()));
}
#else
status_t DeviceHalHidl::addDeviceEffect(
- audio_port_handle_t device __unused, sp<EffectHalInterface> effect __unused) {
+ const struct audio_port_config *device __unused, sp<EffectHalInterface> effect __unused) {
return INVALID_OPERATION;
}
#endif
#if MAJOR_VERSION >= 6
status_t DeviceHalHidl::removeDeviceEffect(
- audio_port_handle_t device, sp<EffectHalInterface> effect) {
+ const struct audio_port_config *device, sp<EffectHalInterface> effect) {
TIME_CHECK();
if (mDevice == 0) return NO_INIT;
+ auto hidlEffect = sp<effect::EffectHalHidl>::cast(effect);
return processReturn("removeDeviceEffect", mDevice->removeDeviceEffect(
- static_cast<AudioPortHandle>(device), effect->effectId()));
+ static_cast<AudioPortHandle>(device->id), hidlEffect->effectId()));
}
#else
status_t DeviceHalHidl::removeDeviceEffect(
- audio_port_handle_t device __unused, sp<EffectHalInterface> effect __unused) {
+ const struct audio_port_config *device __unused, sp<EffectHalInterface> effect __unused) {
return INVALID_OPERATION;
}
#endif
diff --git a/media/libaudiohal/impl/DeviceHalHidl.h b/media/libaudiohal/impl/DeviceHalHidl.h
index c5addde..989c1f5 100644
--- a/media/libaudiohal/impl/DeviceHalHidl.h
+++ b/media/libaudiohal/impl/DeviceHalHidl.h
@@ -105,8 +105,10 @@
// List microphones
status_t getMicrophones(std::vector<audio_microphone_characteristic_t>* microphones) override;
- status_t addDeviceEffect(audio_port_handle_t device, sp<EffectHalInterface> effect) override;
- status_t removeDeviceEffect(audio_port_handle_t device, sp<EffectHalInterface> effect) override;
+ status_t addDeviceEffect(
+ const struct audio_port_config *device, sp<EffectHalInterface> effect) override;
+ status_t removeDeviceEffect(
+ const struct audio_port_config *device, sp<EffectHalInterface> effect) override;
status_t getMmapPolicyInfos(
media::audio::common::AudioMMapPolicyType policyType __unused,
diff --git a/media/libaudiohal/impl/EffectConversionHelperHidl.h b/media/libaudiohal/impl/EffectConversionHelperHidl.h
index 4371d12..ed696bf 100644
--- a/media/libaudiohal/impl/EffectConversionHelperHidl.h
+++ b/media/libaudiohal/impl/EffectConversionHelperHidl.h
@@ -19,9 +19,9 @@
#include "ConversionHelperHidl.h"
-#include PATH(android/hardware/audio/effect/FILE_VERSION/types.h)
+#include PATH(android/hardware/audio/effect/COMMON_TYPES_FILE_VERSION/types.h)
-using EffectResult = ::android::hardware::audio::effect::CPP_VERSION::Result;
+using EffectResult = ::android::hardware::audio::effect::COMMON_TYPES_CPP_VERSION::Result;
namespace android {
diff --git a/media/libaudiohal/impl/EffectHalAidl.cpp b/media/libaudiohal/impl/EffectHalAidl.cpp
index 36abfa4..ae4a530 100644
--- a/media/libaudiohal/impl/EffectHalAidl.cpp
+++ b/media/libaudiohal/impl/EffectHalAidl.cpp
@@ -61,12 +61,11 @@
namespace effect {
EffectHalAidl::EffectHalAidl(const std::shared_ptr<IFactory>& factory,
- const std::shared_ptr<IEffect>& effect, uint64_t effectId,
+ const std::shared_ptr<IEffect>& effect,
int32_t sessionId, int32_t ioId, const Descriptor& desc,
bool isProxyEffect)
: mFactory(factory),
mEffect(effect),
- mEffectId(effectId),
mSessionId(sessionId),
mIoId(ioId),
mDesc(desc),
diff --git a/media/libaudiohal/impl/EffectHalAidl.h b/media/libaudiohal/impl/EffectHalAidl.h
index 47049d7..1b7a3d6 100644
--- a/media/libaudiohal/impl/EffectHalAidl.h
+++ b/media/libaudiohal/impl/EffectHalAidl.h
@@ -56,13 +56,8 @@
// Free resources on the remote side.
status_t close() override;
- // Whether it's a local implementation.
- bool isLocal() const override { return false; }
-
status_t dump(int fd) override;
- uint64_t effectId() const override { return mEffectId; }
-
const std::shared_ptr<::aidl::android::hardware::audio::effect::IEffect> getIEffect() const {
return mEffect;
}
@@ -75,7 +70,6 @@
const std::shared_ptr<::aidl::android::hardware::audio::effect::IFactory> mFactory;
const std::shared_ptr<::aidl::android::hardware::audio::effect::IEffect> mEffect;
- const uint64_t mEffectId;
const int32_t mSessionId;
const int32_t mIoId;
const ::aidl::android::hardware::audio::effect::Descriptor mDesc;
@@ -93,7 +87,7 @@
EffectHalAidl(
const std::shared_ptr<::aidl::android::hardware::audio::effect::IFactory>& factory,
const std::shared_ptr<::aidl::android::hardware::audio::effect::IEffect>& effect,
- uint64_t effectId, int32_t sessionId, int32_t ioId,
+ int32_t sessionId, int32_t ioId,
const ::aidl::android::hardware::audio::effect::Descriptor& desc,
bool isProxyEffect);
bool setEffectReverse(bool reverse);
diff --git a/media/libaudiohal/impl/EffectHalHidl.h b/media/libaudiohal/impl/EffectHalHidl.h
index 94dcd7e..dda21ed 100644
--- a/media/libaudiohal/impl/EffectHalHidl.h
+++ b/media/libaudiohal/impl/EffectHalHidl.h
@@ -17,7 +17,7 @@
#ifndef ANDROID_HARDWARE_EFFECT_HAL_HIDL_H
#define ANDROID_HARDWARE_EFFECT_HAL_HIDL_H
-#include PATH(android/hardware/audio/effect/FILE_VERSION/IEffect.h)
+#include PATH(android/hardware/audio/effect/COMMON_TYPES_FILE_VERSION/IEffect.h)
#include <media/audiohal/EffectHalInterface.h>
#include <fmq/EventFlag.h>
#include <fmq/MessageQueue.h>
@@ -31,7 +31,7 @@
namespace android {
namespace effect {
-using namespace ::android::hardware::audio::effect::CPP_VERSION;
+using namespace ::android::hardware::audio::effect::COMMON_TYPES_CPP_VERSION;
class EffectHalHidl : public EffectHalInterface, public EffectConversionHelperHidl
{
@@ -59,12 +59,9 @@
// Free resources on the remote side.
virtual status_t close();
- // Whether it's a local implementation.
- virtual bool isLocal() const { return false; }
-
virtual status_t dump(int fd);
- virtual uint64_t effectId() const { return mEffectId; }
+ uint64_t effectId() const { return mEffectId; }
private:
friend class EffectsFactoryHalHidl;
diff --git a/media/libaudiohal/impl/EffectsFactoryHalAidl.cpp b/media/libaudiohal/impl/EffectsFactoryHalAidl.cpp
index cf19dae..57395fa 100644
--- a/media/libaudiohal/impl/EffectsFactoryHalAidl.cpp
+++ b/media/libaudiohal/impl/EffectsFactoryHalAidl.cpp
@@ -201,20 +201,12 @@
Descriptor desc;
RETURN_STATUS_IF_ERROR(statusTFromBinderStatus(aidlEffect->getDescriptor(&desc)));
- uint64_t effectId;
- {
- std::lock_guard lg(mLock);
- effectId = ++mEffectIdCounter;
- }
-
- *effect =
- sp<EffectHalAidl>::make(mFactory, aidlEffect, effectId, sessionId, ioId, desc, isProxy);
+ *effect = sp<EffectHalAidl>::make(mFactory, aidlEffect, sessionId, ioId, desc, isProxy);
return OK;
}
status_t EffectsFactoryHalAidl::dumpEffects(int fd) {
status_t ret = OK;
- std::lock_guard lg(mLock);
// record the error ret and continue dump as many effects as possible
for (const auto& proxy : mProxyList) {
if (status_t temp = BAD_VALUE; proxy && (temp = proxy->dump(fd, nullptr, 0)) != OK) {
diff --git a/media/libaudiohal/impl/EffectsFactoryHalAidl.h b/media/libaudiohal/impl/EffectsFactoryHalAidl.h
index b900cb4..73089b0 100644
--- a/media/libaudiohal/impl/EffectsFactoryHalAidl.h
+++ b/media/libaudiohal/impl/EffectsFactoryHalAidl.h
@@ -19,7 +19,6 @@
#include <cstddef>
#include <list>
#include <memory>
-#include <mutex>
#include <aidl/android/hardware/audio/effect/IFactory.h>
#include <aidl/android/hardware/audio/effect/Processing.h>
@@ -88,9 +87,6 @@
// list of the EffectProxy instances
std::list<std::shared_ptr<EffectProxy>> mProxyList;
- std::mutex mLock;
- uint64_t mEffectIdCounter GUARDED_BY(mLock) = 0; // Align with HIDL (0 is INVALID_ID)
-
virtual ~EffectsFactoryHalAidl() = default;
status_t getHalDescriptorWithImplUuid(
const ::aidl::android::media::audio::common::AudioUuid& uuid,
diff --git a/media/libaudiohal/impl/StreamHalHidl.cpp b/media/libaudiohal/impl/StreamHalHidl.cpp
index 82062cc..72eadc6 100644
--- a/media/libaudiohal/impl/StreamHalHidl.cpp
+++ b/media/libaudiohal/impl/StreamHalHidl.cpp
@@ -33,6 +33,7 @@
#include <util/CoreUtils.h>
#include "DeviceHalHidl.h"
+#include "EffectHalHidl.h"
#include "ParameterUtils.h"
#include "StreamHalHidl.h"
@@ -144,13 +145,15 @@
status_t StreamHalHidl::addEffect(sp<EffectHalInterface> effect) {
TIME_CHECK();
if (!mStream) return NO_INIT;
- return processReturn("addEffect", mStream->addEffect(effect->effectId()));
+ auto hidlEffect = sp<effect::EffectHalHidl>::cast(effect);
+ return processReturn("addEffect", mStream->addEffect(hidlEffect->effectId()));
}
status_t StreamHalHidl::removeEffect(sp<EffectHalInterface> effect) {
TIME_CHECK();
if (!mStream) return NO_INIT;
- return processReturn("removeEffect", mStream->removeEffect(effect->effectId()));
+ auto hidlEffect = sp<effect::EffectHalHidl>::cast(effect);
+ return processReturn("removeEffect", mStream->removeEffect(hidlEffect->effectId()));
}
status_t StreamHalHidl::standby() {
diff --git a/media/libaudiohal/include/media/audiohal/DeviceHalInterface.h b/media/libaudiohal/include/media/audiohal/DeviceHalInterface.h
index 71e5e7a..a965709 100644
--- a/media/libaudiohal/include/media/audiohal/DeviceHalInterface.h
+++ b/media/libaudiohal/include/media/audiohal/DeviceHalInterface.h
@@ -132,9 +132,9 @@
std::vector<audio_microphone_characteristic_t>* microphones) = 0;
virtual status_t addDeviceEffect(
- audio_port_handle_t device, sp<EffectHalInterface> effect) = 0;
+ const struct audio_port_config *device, sp<EffectHalInterface> effect) = 0;
virtual status_t removeDeviceEffect(
- audio_port_handle_t device, sp<EffectHalInterface> effect) = 0;
+ const struct audio_port_config *device, sp<EffectHalInterface> effect) = 0;
virtual status_t getMmapPolicyInfos(
media::audio::common::AudioMMapPolicyType policyType,
diff --git a/media/libaudiohal/include/media/audiohal/EffectHalInterface.h b/media/libaudiohal/include/media/audiohal/EffectHalInterface.h
index 2969c92..cf8d7f0 100644
--- a/media/libaudiohal/include/media/audiohal/EffectHalInterface.h
+++ b/media/libaudiohal/include/media/audiohal/EffectHalInterface.h
@@ -52,20 +52,14 @@
// Free resources on the remote side.
virtual status_t close() = 0;
- // Whether it's a local implementation.
- virtual bool isLocal() const = 0;
-
virtual status_t dump(int fd) = 0;
- // Unique effect ID to use with the core HAL.
- virtual uint64_t effectId() const = 0;
-
protected:
// Subclasses can not be constructed directly by clients.
- EffectHalInterface() {}
+ EffectHalInterface() = default;
// The destructor automatically releases the effect.
- virtual ~EffectHalInterface() {}
+ virtual ~EffectHalInterface() = default;
};
} // namespace android
diff --git a/media/libmediaplayerservice/MediaPlayerService.cpp b/media/libmediaplayerservice/MediaPlayerService.cpp
index 9e9e9d8..3f08be5 100644
--- a/media/libmediaplayerservice/MediaPlayerService.cpp
+++ b/media/libmediaplayerservice/MediaPlayerService.cpp
@@ -388,7 +388,9 @@
mediaType.equalsIgnoreCase(MIMETYPE_VIDEO_VP9)
? asString_VP9Profile(pl.mProfile) :
mediaType.equalsIgnoreCase(MIMETYPE_VIDEO_AV1)
- ? asString_AV1Profile(pl.mProfile) : "??";
+ ? asString_AV1Profile(pl.mProfile) :
+ mediaType.equalsIgnoreCase(MIMETYPE_VIDEO_DOLBY_VISION)
+ ? asString_DolbyVisionProfile(pl.mProfile) : "??";
const char *niceLevel =
mediaType.equalsIgnoreCase(MIMETYPE_VIDEO_MPEG2)
? asString_MPEG2Level(pl.mLevel) :
@@ -405,7 +407,9 @@
mediaType.equalsIgnoreCase(MIMETYPE_VIDEO_VP9)
? asString_VP9Level(pl.mLevel) :
mediaType.equalsIgnoreCase(MIMETYPE_VIDEO_AV1)
- ? asString_AV1Level(pl.mLevel) : "??";
+ ? asString_AV1Level(pl.mLevel) :
+ mediaType.equalsIgnoreCase(MIMETYPE_VIDEO_DOLBY_VISION)
+ ? asString_DolbyVisionLevel(pl.mLevel) : "??";
list.add(AStringPrintf("% 5u/% 5u (%s/%s)",
pl.mProfile, pl.mLevel, niceProfile, niceLevel));
diff --git a/media/libstagefright/rtsp/fuzzer/sdploader_fuzzer.cpp b/media/libstagefright/rtsp/fuzzer/sdploader_fuzzer.cpp
index 9c37bfb..748e5b6 100644
--- a/media/libstagefright/rtsp/fuzzer/sdploader_fuzzer.cpp
+++ b/media/libstagefright/rtsp/fuzzer/sdploader_fuzzer.cpp
@@ -62,13 +62,11 @@
}
virtual void disconnect() { return; }
virtual ssize_t readAt(off64_t offset, void* data, size_t size) {
- if (size <= mSize - offset) {
- data = mData.data() + offset;
- return size;
- } else {
- data = nullptr;
- return 0;
+ if ((size + offset <= mData.size()) && (offset >= 0)) {
+ memcpy(data, mData.data() + offset, size);
+ return size;
}
+ return 0;
}
virtual off64_t getSize() { return mSize; }
virtual status_t getMIMEType(String8* /*mimeType*/) {return mFdp->ConsumeIntegral<status_t>();}
diff --git a/media/module/extractors/mkv/MatroskaExtractor.cpp b/media/module/extractors/mkv/MatroskaExtractor.cpp
index 2b72387..6900341 100644
--- a/media/module/extractors/mkv/MatroskaExtractor.cpp
+++ b/media/module/extractors/mkv/MatroskaExtractor.cpp
@@ -1800,7 +1800,6 @@
int32_t isotransfer = 2; // ISO unspecified
int32_t coeffs = 2; // ISO unspecified
bool fullRange = false; // default
- bool rangeSpecified = false;
if (isValidInt32ColourValue(color->primaries)) {
primaries = color->primaries;
@@ -1816,7 +1815,6 @@
// We only support MKV broadcast range (== limited) and full range.
// We treat all other value as the default limited range.
fullRange = color->range == 2 /* MKV fullRange */;
- rangeSpecified = true;
}
int32_t range = 0;
diff --git a/media/mtp/OWNERS b/media/mtp/OWNERS
index 54d3d4a..6b5336e 100644
--- a/media/mtp/OWNERS
+++ b/media/mtp/OWNERS
@@ -1,5 +1,9 @@
set noparent
+aprasath@google.com
+anothermark@google.com
+kumarashishg@google.com
+sarup@google.com
jsharkey@android.com
jameswei@google.com
rmojumder@google.com
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index 69a3f65..6406c6f 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -729,24 +729,24 @@
}
}
-status_t AudioFlinger::addEffectToHal(audio_port_handle_t deviceId,
- audio_module_handle_t hwModuleId, const sp<EffectHalInterface>& effect) {
+status_t AudioFlinger::addEffectToHal(
+ const struct audio_port_config *device, const sp<EffectHalInterface>& effect) {
AutoMutex lock(mHardwareLock);
- AudioHwDevice *audioHwDevice = mAudioHwDevs.valueFor(hwModuleId);
+ AudioHwDevice *audioHwDevice = mAudioHwDevs.valueFor(device->ext.device.hw_module);
if (audioHwDevice == nullptr) {
return NO_INIT;
}
- return audioHwDevice->hwDevice()->addDeviceEffect(deviceId, effect);
+ return audioHwDevice->hwDevice()->addDeviceEffect(device, effect);
}
-status_t AudioFlinger::removeEffectFromHal(audio_port_handle_t deviceId,
- audio_module_handle_t hwModuleId, const sp<EffectHalInterface>& effect) {
+status_t AudioFlinger::removeEffectFromHal(
+ const struct audio_port_config *device, const sp<EffectHalInterface>& effect) {
AutoMutex lock(mHardwareLock);
- AudioHwDevice *audioHwDevice = mAudioHwDevs.valueFor(hwModuleId);
+ AudioHwDevice *audioHwDevice = mAudioHwDevs.valueFor(device->ext.device.hw_module);
if (audioHwDevice == nullptr) {
return NO_INIT;
}
- return audioHwDevice->hwDevice()->removeDeviceEffect(deviceId, effect);
+ return audioHwDevice->hwDevice()->removeDeviceEffect(device, effect);
}
static const char * const audio_interfaces[] = {
diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h
index 9d429ae..320975e 100644
--- a/services/audioflinger/AudioFlinger.h
+++ b/services/audioflinger/AudioFlinger.h
@@ -348,10 +348,10 @@
const sp<os::ExternalVibration>& externalVibration);
static void onExternalVibrationStop(const sp<os::ExternalVibration>& externalVibration);
- status_t addEffectToHal(audio_port_handle_t deviceId,
- audio_module_handle_t hwModuleId, const sp<EffectHalInterface>& effect);
- status_t removeEffectFromHal(audio_port_handle_t deviceId,
- audio_module_handle_t hwModuleId, const sp<EffectHalInterface>& effect);
+ status_t addEffectToHal(
+ const struct audio_port_config *device, const sp<EffectHalInterface>& effect);
+ status_t removeEffectFromHal(
+ const struct audio_port_config *device, const sp<EffectHalInterface>& effect);
void updateDownStreamPatches_l(const struct audio_patch *patch,
const std::set<audio_io_handle_t>& streams);
diff --git a/services/audioflinger/DeviceEffectManager.h b/services/audioflinger/DeviceEffectManager.h
index 395781d..b87f830 100644
--- a/services/audioflinger/DeviceEffectManager.h
+++ b/services/audioflinger/DeviceEffectManager.h
@@ -44,13 +44,13 @@
status_t createEffectHal(const effect_uuid_t *pEffectUuid,
int32_t sessionId, int32_t deviceId,
sp<EffectHalInterface> *effect);
- status_t addEffectToHal(audio_port_handle_t deviceId, audio_module_handle_t hwModuleId,
+ status_t addEffectToHal(const struct audio_port_config *device,
const sp<EffectHalInterface>& effect) {
- return mAudioFlinger.addEffectToHal(deviceId, hwModuleId, effect);
+ return mAudioFlinger.addEffectToHal(device, effect);
};
- status_t removeEffectFromHal(audio_port_handle_t deviceId, audio_module_handle_t hwModuleId,
+ status_t removeEffectFromHal(const struct audio_port_config *device,
const sp<EffectHalInterface>& effect) {
- return mAudioFlinger.removeEffectFromHal(deviceId, hwModuleId, effect);
+ return mAudioFlinger.removeEffectFromHal(device, effect);
};
AudioFlinger& audioFlinger() const { return mAudioFlinger; }
@@ -132,13 +132,13 @@
int newEffectId() { return mManager.audioFlinger().nextUniqueId(AUDIO_UNIQUE_ID_USE_EFFECT); }
- status_t addEffectToHal(audio_port_handle_t deviceId,
- audio_module_handle_t hwModuleId, const sp<EffectHalInterface>& effect) {
- return mManager.addEffectToHal(deviceId, hwModuleId, effect);
+ status_t addEffectToHal(const struct audio_port_config *device,
+ const sp<EffectHalInterface>& effect) {
+ return mManager.addEffectToHal(device, effect);
}
- status_t removeEffectFromHal(audio_port_handle_t deviceId,
- audio_module_handle_t hwModuleId, const sp<EffectHalInterface>& effect) {
- return mManager.removeEffectFromHal(deviceId, hwModuleId, effect);
+ status_t removeEffectFromHal(const struct audio_port_config *device,
+ const sp<EffectHalInterface>& effect) {
+ return mManager.removeEffectFromHal(device, effect);
}
private:
DeviceEffectManager& mManager;
diff --git a/services/audioflinger/Effects.cpp b/services/audioflinger/Effects.cpp
index 071504a..822ea93 100644
--- a/services/audioflinger/Effects.cpp
+++ b/services/audioflinger/Effects.cpp
@@ -3407,8 +3407,7 @@
if (mHalEffect == nullptr) {
return NO_INIT;
}
- return mManagerCallback->addEffectToHal(
- mDevicePort.id, mDevicePort.ext.device.hw_module, effect);
+ return mManagerCallback->addEffectToHal(&mDevicePort, effect);
}
status_t AudioFlinger::DeviceEffectProxy::removeEffectFromHal(
@@ -3416,8 +3415,7 @@
if (mHalEffect == nullptr) {
return NO_INIT;
}
- return mManagerCallback->removeEffectFromHal(
- mDevicePort.id, mDevicePort.ext.device.hw_module, effect);
+ return mManagerCallback->removeEffectFromHal(&mDevicePort, effect);
}
bool AudioFlinger::DeviceEffectProxy::isOutput() const {
diff --git a/services/audiopolicy/engine/common/src/ProductStrategy.cpp b/services/audiopolicy/engine/common/src/ProductStrategy.cpp
index 1d3ad1c..0d25955 100644
--- a/services/audiopolicy/engine/common/src/ProductStrategy.cpp
+++ b/services/audiopolicy/engine/common/src/ProductStrategy.cpp
@@ -155,7 +155,7 @@
return iter.second->getId();
}
if (score > matchScore) {
- bestStrategyOrdefault = iter.second->getId();;
+ bestStrategyOrdefault = iter.second->getId();
matchScore = score;
}
}
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
index cd7221b..0e971b0 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
@@ -1325,10 +1325,15 @@
AudioProfileVector profiles;
status_t ret = getProfilesForDevices(outputDevices, profiles, *flags, false /*isInput*/);
if (ret == NO_ERROR && !profiles.empty()) {
- config->channel_mask = profiles[0]->getChannels().empty() ? config->channel_mask
- : *profiles[0]->getChannels().begin();
- config->sample_rate = profiles[0]->getSampleRates().empty() ? config->sample_rate
- : *profiles[0]->getSampleRates().begin();
+ const auto channels = profiles[0]->getChannels();
+ if (!channels.empty() && (channels.find(config->channel_mask) == channels.end())) {
+ config->channel_mask = *channels.begin();
+ }
+ const auto sampleRates = profiles[0]->getSampleRates();
+ if (!sampleRates.empty() &&
+ (sampleRates.find(config->sample_rate) == sampleRates.end())) {
+ config->sample_rate = *sampleRates.begin();
+ }
config->format = profiles[0]->getFormat();
}
return INVALID_OPERATION;
@@ -2153,6 +2158,26 @@
return DEAD_OBJECT;
}
info->increaseActiveClient();
+ if (info->getActiveClientCount() == 1 &&
+ (info->getFlags() & AUDIO_OUTPUT_FLAG_BIT_PERFECT) != AUDIO_OUTPUT_FLAG_NONE) {
+ // If it is first bit-perfect client, reroute all clients that will be routed to
+ // the bit-perfect sink so that it is guaranteed only bit-perfect stream is active.
+ PortHandleVector clientsToInvalidate;
+ for (size_t i = 0; i < mOutputs.size(); i++) {
+ if (mOutputs[i] == outputDesc ||
+ !mOutputs[i]->devices().filter(outputDesc->devices()).isEmpty()) {
+ continue;
+ }
+ for (const auto& c : mOutputs[i]->getClientIterable()) {
+ clientsToInvalidate.push_back(c->portId());
+ }
+ }
+ if (!clientsToInvalidate.empty()) {
+ ALOGD("%s Invalidate clients due to first bit-perfect client started",
+ __func__);
+ mpClientInterface->invalidateTracks(clientsToInvalidate);
+ }
+ }
}
}
@@ -2754,10 +2779,15 @@
status_t ret = getProfilesForDevices(
DeviceVector(device), profiles, flags, true /*isInput*/);
if (ret == NO_ERROR && !profiles.empty()) {
- config->channel_mask = profiles[0]->getChannels().empty() ? config->channel_mask
- : *profiles[0]->getChannels().begin();
- config->sample_rate = profiles[0]->getSampleRates().empty() ? config->sample_rate
- : *profiles[0]->getSampleRates().begin();
+ const auto channels = profiles[0]->getChannels();
+ if (!channels.empty() && (channels.find(config->channel_mask) == channels.end())) {
+ config->channel_mask = *channels.begin();
+ }
+ const auto sampleRates = profiles[0]->getSampleRates();
+ if (!sampleRates.empty() &&
+ (sampleRates.find(config->sample_rate) == sampleRates.end())) {
+ config->sample_rate = *sampleRates.begin();
+ }
config->format = profiles[0]->getFormat();
}
goto error;
diff --git a/services/audiopolicy/service/Spatializer.cpp b/services/audiopolicy/service/Spatializer.cpp
index ee2e0eb..1245b1e 100644
--- a/services/audiopolicy/service/Spatializer.cpp
+++ b/services/audiopolicy/service/Spatializer.cpp
@@ -236,18 +236,15 @@
sp<EffectHalInterface> effect;
status = effectsFactoryHal->createEffect(&descriptors[0].uuid, AUDIO_SESSION_OUTPUT_STAGE,
AUDIO_IO_HANDLE_NONE, AUDIO_PORT_HANDLE_NONE, &effect);
- ALOGI("%s FX create status %d effect ID %" PRId64, __func__, status,
- effect ? effect->effectId() : 0);
+ ALOGI("%s FX create status %d effect %p", __func__, status, effect.get());
if (status == NO_ERROR && effect != nullptr) {
spatializer = new Spatializer(descriptors[0], callback);
if (spatializer->loadEngineConfiguration(effect) != NO_ERROR) {
spatializer.clear();
- ALOGW("%s loadEngine error: %d effect Id %" PRId64,
- __func__, status, effect ? effect->effectId() : 0);
+ ALOGW("%s loadEngine error: %d effect %p", __func__, status, effect.get());
} else {
- spatializer->mLocalLog.log("%s with effect Id %" PRId64, __func__,
- effect ? effect->effectId() : 0);
+ spatializer->mLocalLog.log("%s with effect Id %p", __func__, effect.get());
}
}
diff --git a/services/camera/libcameraservice/api1/client2/CaptureSequencer.h b/services/camera/libcameraservice/api1/client2/CaptureSequencer.h
index 9475a39..f39599f 100644
--- a/services/camera/libcameraservice/api1/client2/CaptureSequencer.h
+++ b/services/camera/libcameraservice/api1/client2/CaptureSequencer.h
@@ -113,7 +113,7 @@
static const nsecs_t kWaitDuration = 100000000; // 100 ms
static const nsecs_t kIdleWaitDuration = 10000000; // 10 ms
static const int kMaxTimeoutsForPrecaptureStart = 10; // 1 sec
- static const int kMaxTimeoutsForPrecaptureEnd = 20; // 2 sec
+ static const int kMaxTimeoutsForPrecaptureEnd = 40; // 4 sec
static const int kMaxTimeoutsForCaptureEnd = 40; // 4 sec
static const int kMaxRetryCount = 3; // 3 retries in case of buffer drop
diff --git a/services/camera/libcameraservice/device3/Camera3Device.cpp b/services/camera/libcameraservice/device3/Camera3Device.cpp
index afcd29d..4487970 100644
--- a/services/camera/libcameraservice/device3/Camera3Device.cpp
+++ b/services/camera/libcameraservice/device3/Camera3Device.cpp
@@ -1645,6 +1645,10 @@
bool stateSeen = false;
nsecs_t startTime = systemTime();
do {
+ if (mStatus == STATUS_ERROR) {
+ // Device in error state. Return right away.
+ break;
+ }
if (active == (mStatus == STATUS_ACTIVE) &&
(requestThreadInvocation || !mStatusIsInternal)) {
// Desired state is current
@@ -1674,6 +1678,11 @@
// they are not paused. This avoids intermediate pause signals from reconfigureCamera as it
// changes the status to active right after.
for (size_t i = startIndex; i < mRecentStatusUpdates.size(); i++) {
+ if (mRecentStatusUpdates[i].status == STATUS_ERROR) {
+ // Device in error state. Return right away.
+ stateSeen = true;
+ break;
+ }
if (active == (mRecentStatusUpdates[i].status == STATUS_ACTIVE) &&
(requestThreadInvocation || !mRecentStatusUpdates[i].isInternal)) {
stateSeen = true;
@@ -2365,6 +2374,9 @@
//present streams end up with outstanding buffers that will
//not get drained.
internalUpdateStatusLocked(STATUS_ACTIVE);
+
+ mCameraServiceProxyWrapper->logStreamConfigured(mId, mOperatingMode,
+ true /*internalReconfig*/, ns2ms(systemTime() - startTime));
} else if (rc == DEAD_OBJECT) {
// DEAD_OBJECT can be returned if either the consumer surface is
// abandoned, or the HAL has died.
@@ -2380,9 +2392,6 @@
ALOGE("%s: Failed to pause streaming: %d", __FUNCTION__, rc);
}
- mCameraServiceProxyWrapper->logStreamConfigured(mId, mOperatingMode, true /*internalReconfig*/,
- ns2ms(systemTime() - startTime));
-
if (markClientActive) {
mStatusTracker->markComponentActive(clientStatusId);
}
diff --git a/services/camera/libcameraservice/utils/CameraServiceProxyWrapper.cpp b/services/camera/libcameraservice/utils/CameraServiceProxyWrapper.cpp
index 3aff2ac..b58975f 100644
--- a/services/camera/libcameraservice/utils/CameraServiceProxyWrapper.cpp
+++ b/services/camera/libcameraservice/utils/CameraServiceProxyWrapper.cpp
@@ -243,12 +243,12 @@
std::shared_ptr<CameraSessionStatsWrapper> sessionStats;
{
Mutex::Autolock l(mLock);
- sessionStats = mSessionStatsMap[id];
- if (sessionStats == nullptr) {
+ if (mSessionStatsMap.count(id) == 0) {
ALOGE("%s: SessionStatsMap should contain camera %s",
__FUNCTION__, id.c_str());
return;
}
+ sessionStats = mSessionStatsMap[id];
}
ALOGV("%s: id %s, operatingMode %d, internalConfig %d, latencyMs %d",
@@ -260,12 +260,12 @@
std::shared_ptr<CameraSessionStatsWrapper> sessionStats;
{
Mutex::Autolock l(mLock);
- sessionStats = mSessionStatsMap[id];
- if (sessionStats == nullptr) {
+ if (mSessionStatsMap.count(id) == 0) {
ALOGE("%s: SessionStatsMap should contain camera %s when logActive is called",
__FUNCTION__, id.c_str());
return;
}
+ sessionStats = mSessionStatsMap[id];
}
ALOGV("%s: id %s", __FUNCTION__, id.c_str());
@@ -280,13 +280,12 @@
std::shared_ptr<CameraSessionStatsWrapper> sessionStats;
{
Mutex::Autolock l(mLock);
- sessionStats = mSessionStatsMap[id];
- }
-
- if (sessionStats == nullptr) {
- ALOGE("%s: SessionStatsMap should contain camera %s when logIdle is called",
+ if (mSessionStatsMap.count(id) == 0) {
+ ALOGE("%s: SessionStatsMap should contain camera %s when logIdle is called",
__FUNCTION__, id.c_str());
- return;
+ return;
+ }
+ sessionStats = mSessionStatsMap[id];
}
ALOGV("%s: id %s, requestCount %" PRId64 ", resultErrorCount %" PRId64 ", deviceError %d"