Revert^3 "Reapply "AudioFlinger: Control volume using Port ID""
This reverts commit 98c44f36c95fd01ffc6f44b894e41c3140b9ed7e.
Reason for revert: Potential culprit for b/362363068- verifying through ABTD before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted.
Change-Id: Ic97eda49fbcccc6e47357d17a552d24960a1a393
diff --git a/services/audiopolicy/service/AudioPolicyClientImpl.cpp b/services/audiopolicy/service/AudioPolicyClientImpl.cpp
index 5008d68..f70dc52 100644
--- a/services/audiopolicy/service/AudioPolicyClientImpl.cpp
+++ b/services/audiopolicy/service/AudioPolicyClientImpl.cpp
@@ -188,16 +188,6 @@
delay_ms);
}
-status_t AudioPolicyService::AudioPolicyClient::setPortsVolume(
- const std::vector<audio_port_handle_t> &ports, float volume, audio_io_handle_t output,
- int delayMs)
-{
- if (ports.empty()) {
- return NO_ERROR;
- }
- return mAudioPolicyService->setPortsVolume(ports, volume, output, delayMs);
-}
-
void AudioPolicyService::AudioPolicyClient::setParameters(audio_io_handle_t io_handle,
const String8& keyValuePairs,
int delay_ms)
diff --git a/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp b/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp
index 6194002..f414862 100644
--- a/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp
+++ b/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp
@@ -423,7 +423,6 @@
AudioPolicyInterface::output_type_t outputType;
bool isSpatialized = false;
bool isBitPerfect = false;
- float volume;
status_t result = mAudioPolicyManager->getOutputForAttr(&attr, &output, session,
&stream,
attributionSource,
@@ -432,8 +431,7 @@
&secondaryOutputs,
&outputType,
&isSpatialized,
- &isBitPerfect,
- &volume);
+ &isBitPerfect);
// FIXME: Introduce a way to check for the the telephony device before opening the output
if (result == NO_ERROR) {
@@ -497,7 +495,6 @@
_aidl_return->isBitPerfect = isBitPerfect;
_aidl_return->attr = VALUE_OR_RETURN_BINDER_STATUS(
legacy2aidl_audio_attributes_t_AudioAttributes(attr));
- _aidl_return->volume = volume;
} else {
_aidl_return->configBase.format = VALUE_OR_RETURN_BINDER_STATUS(
legacy2aidl_audio_format_t_AudioFormatDescription(config.format));
diff --git a/services/audiopolicy/service/AudioPolicyService.cpp b/services/audiopolicy/service/AudioPolicyService.cpp
index a8b7954..cc67481 100644
--- a/services/audiopolicy/service/AudioPolicyService.cpp
+++ b/services/audiopolicy/service/AudioPolicyService.cpp
@@ -1815,16 +1815,6 @@
data->mIO);
ul.lock();
}break;
- case SET_PORTS_VOLUME: {
- VolumePortsData *data = (VolumePortsData *)command->mParam.get();
- ALOGV("AudioCommandThread() processing set volume Ports %s volume %f, \
- output %d", data->dumpPorts().c_str(), data->mVolume, data->mIO);
- ul.unlock();
- command->mStatus = AudioSystem::setPortsVolume(data->mPorts,
- data->mVolume,
- data->mIO);
- ul.lock();
- } break;
case SET_PARAMETERS: {
ParametersData *data = (ParametersData *)command->mParam.get();
ALOGV("AudioCommandThread() processing set parameters string %s, io %d",
@@ -2137,23 +2127,6 @@
return sendCommand(command, delayMs);
}
-status_t AudioPolicyService::AudioCommandThread::volumePortsCommand(
- const std::vector<audio_port_handle_t> &ports, float volume, audio_io_handle_t output,
- int delayMs)
-{
- sp<AudioCommand> command = new AudioCommand();
- command->mCommand = SET_PORTS_VOLUME;
- sp<VolumePortsData> data = new VolumePortsData();
- data->mPorts = ports;
- data->mVolume = volume;
- data->mIO = output;
- command->mParam = data;
- command->mWaitStatus = true;
- ALOGV("AudioCommandThread() adding set volume ports %s, volume %f, output %d",
- data->dumpPorts().c_str(), volume, output);
- return sendCommand(command, delayMs);
-}
-
status_t AudioPolicyService::AudioCommandThread::parametersCommand(audio_io_handle_t ioHandle,
const char *keyValuePairs,
int delayMs)
@@ -2484,31 +2457,6 @@
delayMs = 1;
} break;
- case SET_PORTS_VOLUME: {
- VolumePortsData *data = (VolumePortsData *)command->mParam.get();
- VolumePortsData *data2 = (VolumePortsData *)command2->mParam.get();
- if (data->mIO != data2->mIO) break;
- // Can remove command only if port ids list is the same, otherwise, remove from
- // command 2 all port whose volume will be replaced with command 1 volume.
- std::vector<audio_port_handle_t> portsOnlyInCommand2{};
- std::copy_if(data2->mPorts.begin(), data2->mPorts.end(),
- std::back_inserter(portsOnlyInCommand2), [&](const auto &portId) {
- return std::find(data->mPorts.begin(), data->mPorts.end(), portId) ==
- data->mPorts.end();
- });
- if (!portsOnlyInCommand2.empty()) {
- data2->mPorts = portsOnlyInCommand2;
- break;
- }
- ALOGV("Filtering out volume command on output %d for ports %s",
- data->mIO, data->dumpPorts().c_str());
- removedCommands.add(command2);
- command->mTime = command2->mTime;
- // force delayMs to non 0 so that code below does not request to wait for
- // command status as the command is now delayed
- delayMs = 1;
- } break;
-
case SET_VOICE_VOLUME: {
VoiceVolumeData *data = (VoiceVolumeData *)command->mParam.get();
VoiceVolumeData *data2 = (VoiceVolumeData *)command2->mParam.get();
@@ -2655,12 +2603,6 @@
output, delayMs);
}
-int AudioPolicyService::setPortsVolume(const std::vector<audio_port_handle_t> &ports, float volume,
- audio_io_handle_t output, int delayMs)
-{
- return (int)mAudioCommandThread->volumePortsCommand(ports, volume, output, delayMs);
-}
-
int AudioPolicyService::setVoiceVolume(float volume, int delayMs)
{
return (int)mAudioCommandThread->voiceVolumeCommand(volume, delayMs);
diff --git a/services/audiopolicy/service/AudioPolicyService.h b/services/audiopolicy/service/AudioPolicyService.h
index 0492cd3..720ba84 100644
--- a/services/audiopolicy/service/AudioPolicyService.h
+++ b/services/audiopolicy/service/AudioPolicyService.h
@@ -47,7 +47,6 @@
#include <android/hardware/BnSensorPrivacyListener.h>
#include <android/content/AttributionSourceState.h>
-#include <numeric>
#include <unordered_map>
namespace android {
@@ -355,21 +354,6 @@
float volume,
audio_io_handle_t output,
int delayMs = 0);
-
- /**
- * Set a volume on AudioTrack port id(s) for a particular output.
- * For the same user setting, a volume group (and associated given port of the
- * client's track) can have different volumes for each output destination device
- * it is attached to.
- *
- * @param ports to consider
- * @param volume to set
- * @param output to consider
- * @param delayMs to use
- * @return NO_ERROR if successful
- */
- virtual status_t setPortsVolume(const std::vector<audio_port_handle_t> &ports, float volume,
- audio_io_handle_t output, int delayMs = 0);
virtual status_t setVoiceVolume(float volume, int delayMs = 0);
void doOnNewAudioModulesAvailable();
@@ -593,7 +577,6 @@
// commands for tone AudioCommand
enum {
SET_VOLUME,
- SET_PORTS_VOLUME,
SET_PARAMETERS,
SET_VOICE_VOLUME,
STOP_OUTPUT,
@@ -627,8 +610,6 @@
void exit();
status_t volumeCommand(audio_stream_type_t stream, float volume,
audio_io_handle_t output, int delayMs = 0);
- status_t volumePortsCommand(const std::vector<audio_port_handle_t> &ports,
- float volume, audio_io_handle_t output, int delayMs = 0);
status_t parametersCommand(audio_io_handle_t ioHandle,
const char *keyValuePairs, int delayMs = 0);
status_t voiceVolumeCommand(float volume, int delayMs = 0);
@@ -703,20 +684,6 @@
audio_io_handle_t mIO;
};
- class VolumePortsData : public AudioCommandData {
- public:
- std::vector<audio_port_handle_t> mPorts;
- float mVolume;
- audio_io_handle_t mIO;
- std::string dumpPorts() {
- return std::string("volume ") + std::to_string(mVolume) + " on IO " +
- std::to_string(mIO) + " and ports " +
- std::accumulate(std::begin(mPorts), std::end(mPorts), std::string{},
- [] (const std::string& ls, int rs) {
- return ls + std::to_string(rs) + " "; });
- }
- };
-
class ParametersData : public AudioCommandData {
public:
audio_io_handle_t mIO;
@@ -856,19 +823,6 @@
// set a stream volume for a particular output. For the same user setting, a given stream type can have different volumes
// for each output (destination device) it is attached to.
virtual status_t setStreamVolume(audio_stream_type_t stream, float volume, audio_io_handle_t output, int delayMs = 0);
- /**
- * Set a volume on port(s) for a particular output. For the same user setting, a volume
- * group (and associated given port of the client's track) can have different volumes for
- * each output (destination device) it is attached to.
- *
- * @param ports to consider
- * @param volume to set
- * @param output to consider
- * @param delayMs to use
- * @return NO_ERROR if successful
- */
- status_t setPortsVolume(const std::vector<audio_port_handle_t> &ports, float volume,
- audio_io_handle_t output, int delayMs = 0) override;
// function enabling to send proprietary informations directly from audio policy manager to audio hardware interface.
virtual void setParameters(audio_io_handle_t ioHandle, const String8& keyValuePairs, int delayMs = 0);