Merge "Camera: Allow vendor stream use case unconditionally." into tm-dev
diff --git a/media/codec2/components/base/SimpleC2Interface.cpp b/media/codec2/components/base/SimpleC2Interface.cpp
index 29740d1..993e602 100644
--- a/media/codec2/components/base/SimpleC2Interface.cpp
+++ b/media/codec2/components/base/SimpleC2Interface.cpp
@@ -28,6 +28,14 @@
/* SimpleInterface */
+static C2R SubscribedParamIndicesSetter(
+ bool mayBlock, C2InterfaceHelper::C2P<C2SubscribedParamIndicesTuning> &me) {
+ (void)mayBlock;
+ (void)me;
+
+ return C2R::Ok();
+}
+
SimpleInterface<void>::BaseParams::BaseParams(
const std::shared_ptr<C2ReflectorHelper> &reflector,
C2String name,
@@ -186,7 +194,7 @@
.withDefault(C2SubscribedParamIndicesTuning::AllocShared(0u))
.withFields({ C2F(mSubscribedParamIndices, m.values[0]).any(),
C2F(mSubscribedParamIndices, m.values).any() })
- .withSetter(Setter<C2SubscribedParamIndicesTuning>::NonStrictValuesWithNoDeps)
+ .withSetter(SubscribedParamIndicesSetter)
.build());
/* TODO
diff --git a/media/codec2/components/base/include/SimpleC2Interface.h b/media/codec2/components/base/include/SimpleC2Interface.h
index 2051d3d..916f392 100644
--- a/media/codec2/components/base/include/SimpleC2Interface.h
+++ b/media/codec2/components/base/include/SimpleC2Interface.h
@@ -209,6 +209,7 @@
return me.F(me.v.value).validatePossible(me.v.value);
}
+ // TODO(b/230146771): fix crash
static C2R NonStrictValuesWithNoDeps(
bool mayBlock, C2InterfaceHelper::C2P<type> &me) {
(void)mayBlock;
diff --git a/media/codec2/sfplugin/CCodec.cpp b/media/codec2/sfplugin/CCodec.cpp
index 88fe1f3..fffd60a 100644
--- a/media/codec2/sfplugin/CCodec.cpp
+++ b/media/codec2/sfplugin/CCodec.cpp
@@ -30,6 +30,7 @@
#include <android/hardware/media/c2/1.0/IInputSurface.h>
#include <android/hardware/media/omx/1.0/IGraphicBufferSource.h>
#include <android/hardware/media/omx/1.0/IOmx.h>
+#include <android-base/properties.h>
#include <android-base/stringprintf.h>
#include <cutils/properties.h>
#include <gui/IGraphicBufferProducer.h>
@@ -1011,7 +1012,9 @@
// Query vendor format for Flexible YUV
std::vector<std::unique_ptr<C2Param>> heapParams;
C2StoreFlexiblePixelFormatDescriptorsInfo *pixelFormatInfo = nullptr;
- if (mClient->query(
+ int vendorSdkVersion = base::GetIntProperty(
+ "ro.vendor.build.version.sdk", android_get_device_api_level());
+ if (vendorSdkVersion >= __ANDROID_API_S__ && mClient->query(
{},
{C2StoreFlexiblePixelFormatDescriptorsInfo::PARAM_TYPE},
C2_MAY_BLOCK,
diff --git a/media/codec2/sfplugin/CCodecConfig.cpp b/media/codec2/sfplugin/CCodecConfig.cpp
index 132902b..836d2a7 100644
--- a/media/codec2/sfplugin/CCodecConfig.cpp
+++ b/media/codec2/sfplugin/CCodecConfig.cpp
@@ -20,6 +20,8 @@
#include <log/log.h>
#include <utils/NativeHandle.h>
+#include <android-base/properties.h>
+
#include <C2Component.h>
#include <C2Param.h>
#include <util/C2InterfaceHelper.h>
@@ -1111,15 +1113,21 @@
const std::shared_ptr<Codec2Client::Configurable> &configurable,
const std::vector<C2Param::Index> &indices,
c2_blocking_t blocking) {
+ static const int32_t kProductFirstApiLevel =
+ base::GetIntProperty<int32_t>("ro.product.first_api_level", 0);
+ static const int32_t kBoardApiLevel =
+ base::GetIntProperty<int32_t>("ro.board.first_api_level", 0);
+ static const int32_t kFirstApiLevel =
+ (kBoardApiLevel != 0) ? kBoardApiLevel : kProductFirstApiLevel;
mSubscribedIndices.insert(indices.begin(), indices.end());
- // TODO: enable this when components no longer crash on this config
- if (mSubscribedIndices.size() != mSubscribedIndicesSize && false) {
- std::vector<uint32_t> indices;
+ if (mSubscribedIndices.size() != mSubscribedIndicesSize
+ && kFirstApiLevel >= __ANDROID_API_T__) {
+ std::vector<uint32_t> indicesVector;
for (C2Param::Index ix : mSubscribedIndices) {
- indices.push_back(ix);
+ indicesVector.push_back(ix);
}
std::unique_ptr<C2SubscribedParamIndicesTuning> subscribeTuning =
- C2SubscribedParamIndicesTuning::AllocUnique(indices);
+ C2SubscribedParamIndicesTuning::AllocUnique(indicesVector);
std::vector<std::unique_ptr<C2SettingResult>> results;
c2_status_t c2Err = configurable->config({ subscribeTuning.get() }, blocking, &results);
if (c2Err != C2_OK && c2Err != C2_BAD_INDEX) {
diff --git a/media/libaudioclient/AudioSystem.cpp b/media/libaudioclient/AudioSystem.cpp
index 9a7b9c1..02e7114 100644
--- a/media/libaudioclient/AudioSystem.cpp
+++ b/media/libaudioclient/AudioSystem.cpp
@@ -70,6 +70,7 @@
dynamic_policy_callback AudioSystem::gDynPolicyCallback = NULL;
record_config_callback AudioSystem::gRecordConfigCallback = NULL;
routing_callback AudioSystem::gRoutingCallback = NULL;
+vol_range_init_req_callback AudioSystem::gVolRangeInitReqCallback = NULL;
// Required to be held while calling into gSoundTriggerCaptureStateListener.
class CaptureStateListenerImpl;
@@ -781,6 +782,11 @@
gRoutingCallback = cb;
}
+/*static*/ void AudioSystem::setVolInitReqCallback(vol_range_init_req_callback cb) {
+ Mutex::Autolock _l(gLock);
+ gVolRangeInitReqCallback = cb;
+}
+
// client singleton for AudioPolicyService binder interface
// protected by gLockAPS
sp<IAudioPolicyService> AudioSystem::gAudioPolicyService;
@@ -2574,6 +2580,19 @@
return Status::ok();
}
+Status AudioSystem::AudioPolicyServiceClient::onVolumeRangeInitRequest() {
+ vol_range_init_req_callback cb = NULL;
+ {
+ Mutex::Autolock _l(AudioSystem::gLock);
+ cb = gVolRangeInitReqCallback;
+ }
+
+ if (cb != NULL) {
+ cb();
+ }
+ return Status::ok();
+}
+
void AudioSystem::AudioPolicyServiceClient::binderDied(const wp<IBinder>& who __unused) {
{
Mutex::Autolock _l(mLock);
diff --git a/media/libaudioclient/aidl/android/media/IAudioPolicyServiceClient.aidl b/media/libaudioclient/aidl/android/media/IAudioPolicyServiceClient.aidl
index d93a59d..c0cdd96 100644
--- a/media/libaudioclient/aidl/android/media/IAudioPolicyServiceClient.aidl
+++ b/media/libaudioclient/aidl/android/media/IAudioPolicyServiceClient.aidl
@@ -46,4 +46,7 @@
AudioSource source);
/** Notifies a change of audio routing */
void onRoutingUpdated();
+ /** Notifies a request for volume index ranges to be reset after they were observed as invalid
+ */
+ void onVolumeRangeInitRequest();
}
diff --git a/media/libaudioclient/include/media/AudioSystem.h b/media/libaudioclient/include/media/AudioSystem.h
index 1cc22a0..b5b9277 100644
--- a/media/libaudioclient/include/media/AudioSystem.h
+++ b/media/libaudioclient/include/media/AudioSystem.h
@@ -77,6 +77,7 @@
audio_patch_handle_t patchHandle,
audio_source_t source);
typedef void (*routing_callback)();
+typedef void (*vol_range_init_req_callback)();
class IAudioFlinger;
class String8;
@@ -154,6 +155,7 @@
static void setDynPolicyCallback(dynamic_policy_callback cb);
static void setRecordConfigCallback(record_config_callback);
static void setRoutingCallback(routing_callback cb);
+ static void setVolInitReqCallback(vol_range_init_req_callback cb);
// Sets the binder to use for accessing the AudioFlinger service. This enables the system server
// to grant specific isolated processes access to the audio system. Currently used only for the
@@ -736,6 +738,7 @@
int32_t patchHandle,
media::audio::common::AudioSource source) override;
binder::Status onRoutingUpdated();
+ binder::Status onVolumeRangeInitRequest();
private:
Mutex mLock;
@@ -763,6 +766,7 @@
static dynamic_policy_callback gDynPolicyCallback;
static record_config_callback gRecordConfigCallback;
static routing_callback gRoutingCallback;
+ static vol_range_init_req_callback gVolRangeInitReqCallback;
static size_t gInBuffSize;
// previous parameters for recording buffer size queries
diff --git a/media/libstagefright/omx/OMXStore.cpp b/media/libstagefright/omx/OMXStore.cpp
index e8fee42..7e33f09 100644
--- a/media/libstagefright/omx/OMXStore.cpp
+++ b/media/libstagefright/omx/OMXStore.cpp
@@ -99,6 +99,15 @@
}
}
+static int getFirstApiLevel() {
+ int boardApiLevel = android::base::GetIntProperty("ro.board.first_api_level", 0);
+ if (boardApiLevel != 0) {
+ return boardApiLevel;
+ }
+
+ return android::base::GetIntProperty("ro.product.first_api_level", __ANDROID_API_T__);
+}
+
void OMXStore::addPlugin(OMXPluginBase *plugin) {
Mutex::Autolock autoLock(mLock);
@@ -110,6 +119,29 @@
name, sizeof(name), index++)) == OMX_ErrorNone) {
String8 name8(name);
+ Vector<String8> roles;
+ OMX_ERRORTYPE err = plugin->getRolesOfComponent(name, &roles);
+ if (err == OMX_ErrorNone) {
+ bool skip = false;
+ for (String8 role : roles) {
+ if (role.find("video_decoder") != -1 || role.find("video_encoder") != -1) {
+ if (getFirstApiLevel() >= __ANDROID_API_S__) {
+ skip = true;
+ break;
+ }
+ }
+ if (role.find("audio_decoder") != -1 || role.find("audio_encoder") != -1) {
+ if (getFirstApiLevel() >= __ANDROID_API_T__) {
+ skip = true;
+ break;
+ }
+ }
+ }
+ if (skip) {
+ continue;
+ }
+ }
+
if (mPluginByComponentName.indexOfKey(name8) >= 0) {
ALOGE("A component of name '%s' already exists, ignoring this one.",
name8.string());
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index 9344e20..49f6bfc 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -978,7 +978,8 @@
|| mType == MIXER
|| mType == DUPLICATING
|| mType == DIRECT
- || mType == OFFLOAD) {
+ || mType == OFFLOAD
+ || mType == SPATIALIZER) {
dprintf(fd, " Timestamp stats: %s\n", mTimestampVerifier.toString().c_str());
dprintf(fd, " Timestamp corrected: %s\n", isTimestampCorrectionEnabled() ? "yes" : "no");
}
@@ -3007,6 +3008,7 @@
// Calculate size of normal sink buffer relative to the HAL output buffer size
double multiplier = 1.0;
+ // Note: mType == SPATIALIZER does not support FastMixer.
if (mType == MIXER && (kUseFastMixer == FastMixer_Static ||
kUseFastMixer == FastMixer_Dynamic)) {
size_t minNormalFrameCount = (kMinNormalSinkBufferSizeMs * mSampleRate) / 1000;
@@ -3468,7 +3470,7 @@
sp<EffectBufferHalInterface> halInBuffer, halOutBuffer;
effect_buffer_t *buffer = nullptr; // only used for non global sessions
- if (mType == SPATIALIZER ) {
+ if (mType == SPATIALIZER) {
if (!audio_is_global_session(session)) {
// player sessions on a spatializer output will use a dedicated input buffer and
// will either output multi channel to mEffectBuffer if the track is spatilaized
@@ -3694,7 +3696,7 @@
cacheParameters_l();
mSleepTimeUs = mIdleSleepTimeUs;
- if (mType == MIXER) {
+ if (mType == MIXER || mType == SPATIALIZER) {
sleepTimeShift = 0;
}
@@ -3872,7 +3874,7 @@
mStandbyTimeNs = systemTime() + mStandbyDelayNs;
mSleepTimeUs = mIdleSleepTimeUs;
- if (mType == MIXER) {
+ if (mType == MIXER || mType == SPATIALIZER) {
sleepTimeShift = 0;
}
@@ -4149,7 +4151,8 @@
// write blocked detection
const int64_t deltaWriteNs = lastIoEndNs - lastIoBeginNs;
- if (mType == MIXER && deltaWriteNs > maxPeriod) {
+ if ((mType == MIXER || mType == SPATIALIZER)
+ && deltaWriteNs > maxPeriod) {
mNumDelayedWrites++;
if ((lastIoEndNs - lastWarning) > kWarningThrottleNs) {
ATRACE_NAME("underrun");
@@ -4170,7 +4173,7 @@
(mMixerStatus == MIXER_DRAIN_ALL)) {
threadLoop_drain();
}
- if (mType == MIXER && !mStandby) {
+ if ((mType == MIXER || mType == SPATIALIZER) && !mStandby) {
if (mThreadThrottle
&& mMixerStatus == MIXER_TRACKS_READY // we are mixing (active tracks)
@@ -4295,13 +4298,6 @@
void AudioFlinger::PlaybackThread::collectTimestamps_l()
{
- // Collect timestamp statistics for the Playback Thread types that support it.
- if (mType != MIXER
- && mType != DUPLICATING
- && mType != DIRECT
- && mType != OFFLOAD) {
- return;
- }
if (mStandby) {
mTimestampVerifier.discontinuity(discontinuityForStandbyOrFlush());
return;
diff --git a/services/audiopolicy/AudioPolicyInterface.h b/services/audiopolicy/AudioPolicyInterface.h
index 20d0523..496591a 100644
--- a/services/audiopolicy/AudioPolicyInterface.h
+++ b/services/audiopolicy/AudioPolicyInterface.h
@@ -533,6 +533,10 @@
virtual void onRoutingUpdated() = 0;
+ // Used to notify AudioService that an error was encountering when reading
+ // the volume ranges, and that they should be re-initialized
+ virtual void onVolumeRangeInitRequest() = 0;
+
// Used to notify the sound trigger module that an audio capture is about to
// take place. This should typically result in any active recognition
// sessions to be preempted on modules that do not support sound trigger
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
index 49a0dde..ddc72f6 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
@@ -2118,11 +2118,15 @@
// apply volume rules for current stream and device if necessary
auto &curves = getVolumeCurves(client->attributes());
- checkAndSetVolume(curves, client->volumeSource(),
+ if (NO_ERROR != checkAndSetVolume(curves, client->volumeSource(),
curves.getVolumeIndex(outputDesc->devices().types()),
outputDesc,
outputDesc->devices().types(), 0 /*delay*/,
- outputDesc->useHwGain() /*force*/);
+ outputDesc->useHwGain() /*force*/)) {
+ // request AudioService to reinitialize the volume curves asynchronously
+ ALOGE("checkAndSetVolume failed, requesting volume range init");
+ mpClientInterface->onVolumeRangeInitRequest();
+ };
// update the outputs if starting an output with a stream that can affect notification
// routing
@@ -7290,6 +7294,11 @@
deviceTypes = outputDesc->devices().types();
}
+ if (curves.getVolumeIndexMin() < 0 || curves.getVolumeIndexMax() < 0) {
+ ALOGE("invalid volume index range");
+ return BAD_VALUE;
+ }
+
float volumeDb = computeVolume(curves, volumeSource, index, deviceTypes);
if (outputDesc->isFixedVolume(deviceTypes) ||
// Force VoIP volume to max for bluetooth SCO device except if muted
diff --git a/services/audiopolicy/service/AudioPolicyClientImpl.cpp b/services/audiopolicy/service/AudioPolicyClientImpl.cpp
index 63a1e71..c766a15 100644
--- a/services/audiopolicy/service/AudioPolicyClientImpl.cpp
+++ b/services/audiopolicy/service/AudioPolicyClientImpl.cpp
@@ -277,6 +277,11 @@
mAudioPolicyService->onRoutingUpdated();
}
+void AudioPolicyService::AudioPolicyClient::onVolumeRangeInitRequest()
+{
+ mAudioPolicyService->onVolumeRangeInitRequest();
+}
+
audio_unique_id_t AudioPolicyService::AudioPolicyClient::newAudioUniqueId(audio_unique_id_use_t use)
{
return AudioSystem::newAudioUniqueId(use);
diff --git a/services/audiopolicy/service/AudioPolicyService.cpp b/services/audiopolicy/service/AudioPolicyService.cpp
index 18339b0..e7d945f 100644
--- a/services/audiopolicy/service/AudioPolicyService.cpp
+++ b/services/audiopolicy/service/AudioPolicyService.cpp
@@ -488,6 +488,19 @@
}
}
+void AudioPolicyService::onVolumeRangeInitRequest()
+{
+ mOutputCommandThread->volRangeInitReqCommand();
+}
+
+void AudioPolicyService::doOnVolumeRangeInitRequest()
+{
+ Mutex::Autolock _l(mNotificationClientsLock);
+ for (size_t i = 0; i < mNotificationClients.size(); i++) {
+ mNotificationClients.valueAt(i)->onVolumeRangeInitRequest();
+ }
+}
+
void AudioPolicyService::onCheckSpatializer()
{
Mutex::Autolock _l(mLock);
@@ -721,6 +734,13 @@
}
}
+void AudioPolicyService::NotificationClient::onVolumeRangeInitRequest()
+{
+ if (mAudioPolicyServiceClient != 0 && isServiceUid(mUid)) {
+ mAudioPolicyServiceClient->onVolumeRangeInitRequest();
+ }
+}
+
void AudioPolicyService::binderDied(const wp<IBinder>& who) {
ALOGW("binderDied() %p, calling pid %d", who.unsafe_get(),
IPCThreadState::self()->getCallingPid());
@@ -2161,6 +2181,17 @@
mLock.lock();
} break;
+ case VOL_RANGE_INIT_REQUEST: {
+ ALOGV("AudioCommandThread() processing volume range init request");
+ svc = mService.promote();
+ if (svc == 0) {
+ break;
+ }
+ mLock.unlock();
+ svc->doOnVolumeRangeInitRequest();
+ mLock.lock();
+ } break;
+
default:
ALOGW("AudioCommandThread() unknown command %d", command->mCommand);
}
@@ -2485,6 +2516,14 @@
sendCommand(command);
}
+void AudioPolicyService::AudioCommandThread::volRangeInitReqCommand()
+{
+ sp<AudioCommand>command = new AudioCommand();
+ command->mCommand = VOL_RANGE_INIT_REQUEST;
+ ALOGV("AudioCommandThread() adding volume range init request");
+ sendCommand(command);
+}
+
status_t AudioPolicyService::AudioCommandThread::sendCommand(sp<AudioCommand>& command, int delayMs)
{
{
@@ -2652,6 +2691,10 @@
} break;
+ case VOL_RANGE_INIT_REQUEST: {
+ // command may come from different requests, do not filter
+ } break;
+
default:
break;
}
diff --git a/services/audiopolicy/service/AudioPolicyService.h b/services/audiopolicy/service/AudioPolicyService.h
index d863ff1..3a08cf8 100644
--- a/services/audiopolicy/service/AudioPolicyService.h
+++ b/services/audiopolicy/service/AudioPolicyService.h
@@ -343,6 +343,9 @@
void onRoutingUpdated();
void doOnRoutingUpdated();
+ void onVolumeRangeInitRequest();
+ void doOnVolumeRangeInitRequest();
+
/**
* Spatializer SpatializerPolicyCallback implementation.
* onCheckSpatializer() sends an event on mOutputCommandThread which executes
@@ -530,7 +533,8 @@
ROUTING_UPDATED,
UPDATE_UID_STATES,
CHECK_SPATIALIZER_OUTPUT, // verify if spatializer effect should be created or moved
- UPDATE_ACTIVE_SPATIALIZER_TRACKS // Update active track counts on spalializer output
+ UPDATE_ACTIVE_SPATIALIZER_TRACKS, // Update active track counts on spalializer output
+ VOL_RANGE_INIT_REQUEST, // request to reset the volume range indices
};
AudioCommandThread (String8 name, const wp<AudioPolicyService>& service);
@@ -581,6 +585,7 @@
void updateUidStatesCommand();
void checkSpatializerCommand();
void updateActiveSpatializerTracksCommand();
+ void volRangeInitReqCommand();
void insertCommand_l(AudioCommand *command, int delayMs = 0);
private:
@@ -803,6 +808,8 @@
virtual void onRoutingUpdated();
+ virtual void onVolumeRangeInitRequest();
+
virtual audio_unique_id_t newAudioUniqueId(audio_unique_id_use_t use);
void setSoundTriggerCaptureState(bool active) override;
@@ -842,6 +849,7 @@
audio_patch_handle_t patchHandle,
audio_source_t source);
void onRoutingUpdated();
+ void onVolumeRangeInitRequest();
void setAudioPortCallbacksEnabled(bool enabled);
void setAudioVolumeGroupCallbacksEnabled(bool enabled);
diff --git a/services/audiopolicy/tests/AudioPolicyManagerTestClient.h b/services/audiopolicy/tests/AudioPolicyManagerTestClient.h
index adef8f1..057fa58 100644
--- a/services/audiopolicy/tests/AudioPolicyManagerTestClient.h
+++ b/services/audiopolicy/tests/AudioPolicyManagerTestClient.h
@@ -138,7 +138,12 @@
}
size_t getRoutingUpdatedCounter() const {
- return mRoutingUpdatedUpdateCount; }
+ return mRoutingUpdatedUpdateCount;
+ }
+
+ void onVolumeRangeInitRequest() override {
+
+ }
status_t updateSecondaryOutputs(
const TrackSecondaryOutputsMap& trackSecondaryOutputs __unused) override {
diff --git a/services/audiopolicy/tests/AudioPolicyTestClient.h b/services/audiopolicy/tests/AudioPolicyTestClient.h
index da85658..8a85fee 100644
--- a/services/audiopolicy/tests/AudioPolicyTestClient.h
+++ b/services/audiopolicy/tests/AudioPolicyTestClient.h
@@ -85,6 +85,7 @@
audio_patch_handle_t patchHandle __unused,
audio_source_t source __unused) override { }
void onRoutingUpdated() override { }
+ void onVolumeRangeInitRequest() override { }
void setEffectSuspended(int effectId __unused,
audio_session_t sessionId __unused,
bool suspended __unused) {}
diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp
index a965080..c8c6b1c 100644
--- a/services/camera/libcameraservice/CameraService.cpp
+++ b/services/camera/libcameraservice/CameraService.cpp
@@ -3717,21 +3717,10 @@
void CameraService::UidPolicy::onUidStateChanged(uid_t uid, int32_t procState,
int64_t procStateSeq __unused, int32_t capability __unused) {
- bool procStateChange = false;
- {
- Mutex::Autolock _l(mUidLock);
- if (mMonitoredUids.find(uid) != mMonitoredUids.end() &&
- mMonitoredUids[uid].procState != procState) {
- mMonitoredUids[uid].procState = procState;
- procStateChange = true;
- }
- }
-
- if (procStateChange) {
- sp<CameraService> service = mService.promote();
- if (service != nullptr) {
- service->notifyMonitoredUids();
- }
+ Mutex::Autolock _l(mUidLock);
+ if (mMonitoredUids.find(uid) != mMonitoredUids.end() &&
+ mMonitoredUids[uid].procState != procState) {
+ mMonitoredUids[uid].procState = procState;
}
}