Merge "DO NOT MERGE - Merge pie-platform-release (PPRL.190801.002) into master"

gugelfrei
Treehugger Robot 5 years ago committed by Gerrit Code Review
commit 04d0073dc7

@ -129,6 +129,7 @@ cc_library_static {
shared_libs: [ shared_libs: [
"libstagefright_enc_common", "libstagefright_enc_common",
"liblog",
], ],
cflags: ["-Werror"], cflags: ["-Werror"],

@ -14,6 +14,7 @@ cc_test {
shared_libs: [ shared_libs: [
"libdl", "libdl",
"liblog",
], ],
static_libs: [ static_libs: [

@ -47,6 +47,10 @@
#include "q_pulse.h" #include "q_pulse.h"
#undef LOG_TAG
#define LOG_TAG "amrwbenc"
#include "log/log.h"
static Word16 tipos[36] = { static Word16 tipos[36] = {
0, 1, 2, 3, /* starting point &ipos[0], 1st iter */ 0, 1, 2, 3, /* starting point &ipos[0], 1st iter */
1, 2, 3, 0, /* starting point &ipos[4], 2nd iter */ 1, 2, 3, 0, /* starting point &ipos[4], 2nd iter */
@ -745,11 +749,16 @@ void ACELP_4t64_fx(
i = (Word16)((vo_L_mult(track, NPMAXPT) >> 1)); i = (Word16)((vo_L_mult(track, NPMAXPT) >> 1));
while (ind[i] >= 0) while (i < NPMAXPT * NB_TRACK && ind[i] >= 0)
{ {
i += 1; i += 1;
} }
ind[i] = index; if (i < NPMAXPT * NB_TRACK) {
ind[i] = index;
} else {
ALOGE("b/132647222, OOB access in ind array track=%d i=%d", track, i);
android_errorWriteLog(0x534e4554, "132647222");
}
} }
k = 0; k = 0;

@ -157,6 +157,12 @@ ssize_t HTTPDownloader::fetchBlock(
buffer->size() + bufferRemaining); buffer->size() + bufferRemaining);
sp<ABuffer> copy = new ABuffer(buffer->size() + bufferRemaining); sp<ABuffer> copy = new ABuffer(buffer->size() + bufferRemaining);
if (copy->data() == NULL) {
android_errorWriteLog(0x534e4554, "68399439");
ALOGE("not enough memory to download: requesting %zu + %zu",
buffer->size(), bufferRemaining);
return NO_MEMORY;
}
memcpy(copy->data(), buffer->data(), buffer->size()); memcpy(copy->data(), buffer->data(), buffer->size());
copy->setRange(0, buffer->size()); copy->setRange(0, buffer->size());

@ -383,7 +383,7 @@ status_t TextDescriptions::extract3GPPGlobalDescriptions(
tmpData += 8; tmpData += 8;
size_t remaining = size - 8; size_t remaining = size - 8;
if (size < chunkSize) { if (chunkSize <= 8 || size < chunkSize) {
return OK; return OK;
} }
switch(chunkType) { switch(chunkType) {

@ -27,7 +27,7 @@
namespace android { namespace android {
class IOProfile; class IOProfile;
class AudioMix; class AudioPolicyMix;
// descriptor for audio inputs. Used to maintain current configuration of each opened audio input // descriptor for audio inputs. Used to maintain current configuration of each opened audio input
// and keep track of the usage of this input. // and keep track of the usage of this input.
@ -44,7 +44,7 @@ public:
audio_io_handle_t mIoHandle; // input handle audio_io_handle_t mIoHandle; // input handle
audio_devices_t mDevice; // current device this input is routed to audio_devices_t mDevice; // current device this input is routed to
AudioMix *mPolicyMix; // non NULL when used by a dynamic policy wp<AudioPolicyMix> mPolicyMix; // non NULL when used by a dynamic policy
const sp<IOProfile> mProfile; // I/O profile this output derives from const sp<IOProfile> mProfile; // I/O profile this output derives from
virtual void toAudioPortConfig(struct audio_port_config *dstConfig, virtual void toAudioPortConfig(struct audio_port_config *dstConfig,

@ -29,7 +29,7 @@
namespace android { namespace android {
class IOProfile; class IOProfile;
class AudioMix; class AudioPolicyMix;
class AudioPolicyClientInterface; class AudioPolicyClientInterface;
class DeviceDescriptor; class DeviceDescriptor;
@ -141,7 +141,7 @@ public:
audio_io_handle_t mIoHandle; // output handle audio_io_handle_t mIoHandle; // output handle
uint32_t mLatency; // uint32_t mLatency; //
audio_output_flags_t mFlags; // audio_output_flags_t mFlags; //
AudioMix *mPolicyMix; // non NULL when used by a dynamic policy wp<AudioPolicyMix> mPolicyMix; // non NULL when used by a dynamic policy
sp<SwAudioOutputDescriptor> mOutput1; // used by duplicated outputs: first output sp<SwAudioOutputDescriptor> mOutput1; // used by duplicated outputs: first output
sp<SwAudioOutputDescriptor> mOutput2; // used by duplicated outputs: second output sp<SwAudioOutputDescriptor> mOutput2; // used by duplicated outputs: second output
uint32_t mDirectOpenCount; // number of clients using this output (direct outputs only) uint32_t mDirectOpenCount; // number of clients using this output (direct outputs only)

@ -29,9 +29,11 @@ class SwAudioOutputDescriptor;
/** /**
* custom mix entry in mPolicyMixes * custom mix entry in mPolicyMixes
*/ */
class AudioPolicyMix : public RefBase { class AudioPolicyMix : public AudioMix, public RefBase {
public: public:
AudioPolicyMix() {} AudioPolicyMix(const AudioMix &mix);
AudioPolicyMix(const AudioPolicyMix&) = delete;
AudioPolicyMix& operator=(const AudioPolicyMix&) = delete;
const sp<SwAudioOutputDescriptor> &getOutput() const; const sp<SwAudioOutputDescriptor> &getOutput() const;
@ -39,14 +41,9 @@ public:
void clearOutput(); void clearOutput();
android::AudioMix *getMix();
void setMix(AudioMix &mix);
status_t dump(int fd, int spaces, int index) const; status_t dump(int fd, int spaces, int index) const;
private: private:
AudioMix mMix; // Audio policy mix descriptor
sp<SwAudioOutputDescriptor> mOutput; // Corresponding output stream sp<SwAudioOutputDescriptor> mOutput; // Corresponding output stream
}; };
@ -76,9 +73,9 @@ public:
audio_devices_t getDeviceAndMixForInputSource(audio_source_t inputSource, audio_devices_t getDeviceAndMixForInputSource(audio_source_t inputSource,
audio_devices_t availableDeviceTypes, audio_devices_t availableDeviceTypes,
AudioMix **policyMix); sp<AudioPolicyMix> *policyMix);
status_t getInputMixForAttr(audio_attributes_t attr, AudioMix **policyMix); status_t getInputMixForAttr(audio_attributes_t attr, sp<AudioPolicyMix> *policyMix);
status_t dump(int fd) const; status_t dump(int fd) const;
}; };

@ -28,6 +28,7 @@
namespace android { namespace android {
class AudioPolicyClientInterface; class AudioPolicyClientInterface;
class AudioPolicyMix;
class AudioSession : public RefBase, public AudioSessionInfoUpdateListener class AudioSession : public RefBase, public AudioSessionInfoUpdateListener
{ {
@ -40,7 +41,7 @@ public:
audio_input_flags_t flags, audio_input_flags_t flags,
uid_t uid, uid_t uid,
bool isSoundTrigger, bool isSoundTrigger,
AudioMix* policyMix, const sp<AudioPolicyMix> &policyMix,
AudioPolicyClientInterface *clientInterface); AudioPolicyClientInterface *clientInterface);
status_t dump(int fd, int spaces, int index) const; status_t dump(int fd, int spaces, int index) const;
@ -75,7 +76,7 @@ private:
bool mSilenced; bool mSilenced;
uint32_t mOpenCount; uint32_t mOpenCount;
uint32_t mActiveCount; uint32_t mActiveCount;
AudioMix* mPolicyMix; // non NULL when used by a dynamic policy wp<AudioPolicyMix> mPolicyMix; // non NULL when used by a dynamic policy
AudioPolicyClientInterface* mClientInterface; AudioPolicyClientInterface* mClientInterface;
const AudioSessionInfoProvider* mInfoProvider; const AudioSessionInfoProvider* mInfoProvider;
}; };

@ -21,6 +21,7 @@
#include "AudioInputDescriptor.h" #include "AudioInputDescriptor.h"
#include "IOProfile.h" #include "IOProfile.h"
#include "AudioGain.h" #include "AudioGain.h"
#include "AudioPolicyMix.h"
#include "HwModule.h" #include "HwModule.h"
#include <media/AudioPolicy.h> #include <media/AudioPolicy.h>
#include <policy.h> #include <policy.h>

@ -19,6 +19,7 @@
#include <AudioPolicyInterface.h> #include <AudioPolicyInterface.h>
#include "AudioOutputDescriptor.h" #include "AudioOutputDescriptor.h"
#include "AudioPolicyMix.h"
#include "IOProfile.h" #include "IOProfile.h"
#include "AudioGain.h" #include "AudioGain.h"
#include "Volume.h" #include "Volume.h"
@ -307,17 +308,18 @@ void SwAudioOutputDescriptor::changeRefCount(audio_stream_type_t stream,
} else { } else {
mGlobalRefCount += delta; mGlobalRefCount += delta;
} }
sp<AudioPolicyMix> policyMix = mPolicyMix.promote();
if ((oldGlobalRefCount == 0) && (mGlobalRefCount > 0)) { if ((oldGlobalRefCount == 0) && (mGlobalRefCount > 0)) {
if ((mPolicyMix != NULL) && ((mPolicyMix->mCbFlags & AudioMix::kCbFlagNotifyActivity) != 0)) if ((policyMix != NULL) && ((policyMix->mCbFlags & AudioMix::kCbFlagNotifyActivity) != 0))
{ {
mClientInterface->onDynamicPolicyMixStateUpdate(mPolicyMix->mDeviceAddress, mClientInterface->onDynamicPolicyMixStateUpdate(policyMix->mDeviceAddress,
MIX_STATE_MIXING); MIX_STATE_MIXING);
} }
} else if ((oldGlobalRefCount > 0) && (mGlobalRefCount == 0)) { } else if ((oldGlobalRefCount > 0) && (mGlobalRefCount == 0)) {
if ((mPolicyMix != NULL) && ((mPolicyMix->mCbFlags & AudioMix::kCbFlagNotifyActivity) != 0)) if ((policyMix != NULL) && ((policyMix->mCbFlags & AudioMix::kCbFlagNotifyActivity) != 0))
{ {
mClientInterface->onDynamicPolicyMixStateUpdate(mPolicyMix->mDeviceAddress, mClientInterface->onDynamicPolicyMixStateUpdate(policyMix->mDeviceAddress,
MIX_STATE_IDLE); MIX_STATE_IDLE);
} }
} }

@ -27,6 +27,10 @@
namespace android { namespace android {
AudioPolicyMix::AudioPolicyMix(const AudioMix &mix) : AudioMix(mix)
{
}
void AudioPolicyMix::setOutput(sp<SwAudioOutputDescriptor> &output) void AudioPolicyMix::setOutput(sp<SwAudioOutputDescriptor> &output)
{ {
mOutput = output; mOutput = output;
@ -42,16 +46,6 @@ void AudioPolicyMix::clearOutput()
mOutput.clear(); mOutput.clear();
} }
void AudioPolicyMix::setMix(AudioMix &mix)
{
mMix = mix;
}
android::AudioMix *AudioPolicyMix::getMix()
{
return &mMix;
}
status_t AudioPolicyMix::dump(int fd, int spaces, int index) const status_t AudioPolicyMix::dump(int fd, int spaces, int index) const
{ {
const size_t SIZE = 256; const size_t SIZE = 256;
@ -61,25 +55,25 @@ status_t AudioPolicyMix::dump(int fd, int spaces, int index) const
snprintf(buffer, SIZE, "%*sAudio Policy Mix %d:\n", spaces, "", index+1); snprintf(buffer, SIZE, "%*sAudio Policy Mix %d:\n", spaces, "", index+1);
result.append(buffer); result.append(buffer);
std::string mixTypeLiteral; std::string mixTypeLiteral;
if (!MixTypeConverter::toString(mMix.mMixType, mixTypeLiteral)) { if (!MixTypeConverter::toString(mMixType, mixTypeLiteral)) {
ALOGE("%s: failed to convert mix type %d", __FUNCTION__, mMix.mMixType); ALOGE("%s: failed to convert mix type %d", __FUNCTION__, mMixType);
return BAD_VALUE; return BAD_VALUE;
} }
snprintf(buffer, SIZE, "%*s- mix type: %s\n", spaces, "", mixTypeLiteral.c_str()); snprintf(buffer, SIZE, "%*s- mix type: %s\n", spaces, "", mixTypeLiteral.c_str());
result.append(buffer); result.append(buffer);
std::string routeFlagLiteral; std::string routeFlagLiteral;
RouteFlagTypeConverter::maskToString(mMix.mRouteFlags, routeFlagLiteral); RouteFlagTypeConverter::maskToString(mRouteFlags, routeFlagLiteral);
snprintf(buffer, SIZE, "%*s- Route Flags: %s\n", spaces, "", routeFlagLiteral.c_str()); snprintf(buffer, SIZE, "%*s- Route Flags: %s\n", spaces, "", routeFlagLiteral.c_str());
result.append(buffer); result.append(buffer);
std::string deviceLiteral; std::string deviceLiteral;
deviceToString(mMix.mDeviceType, deviceLiteral); deviceToString(mDeviceType, deviceLiteral);
snprintf(buffer, SIZE, "%*s- device type: %s\n", spaces, "", deviceLiteral.c_str()); snprintf(buffer, SIZE, "%*s- device type: %s\n", spaces, "", deviceLiteral.c_str());
result.append(buffer); result.append(buffer);
snprintf(buffer, SIZE, "%*s- device address: %s\n", spaces, "", mMix.mDeviceAddress.string()); snprintf(buffer, SIZE, "%*s- device address: %s\n", spaces, "", mDeviceAddress.string());
result.append(buffer); result.append(buffer);
int indexCriterion = 0; int indexCriterion = 0;
for (const auto &criterion : mMix.mCriteria) { for (const auto &criterion : mCriteria) {
snprintf(buffer, SIZE, "%*s- Criterion %d:\n", spaces + 2, "", indexCriterion++); snprintf(buffer, SIZE, "%*s- Criterion %d:\n", spaces + 2, "", indexCriterion++);
result.append(buffer); result.append(buffer);
std::string usageLiteral; std::string usageLiteral;
@ -89,7 +83,7 @@ status_t AudioPolicyMix::dump(int fd, int spaces, int index) const
} }
snprintf(buffer, SIZE, "%*s- Usage:%s\n", spaces + 4, "", usageLiteral.c_str()); snprintf(buffer, SIZE, "%*s- Usage:%s\n", spaces + 4, "", usageLiteral.c_str());
result.append(buffer); result.append(buffer);
if (mMix.mMixType == MIX_TYPE_RECORDERS) { if (mMixType == MIX_TYPE_RECORDERS) {
std::string sourceLiteral; std::string sourceLiteral;
if (!SourceTypeConverter::toString(criterion.mValue.mSource, sourceLiteral)) { if (!SourceTypeConverter::toString(criterion.mValue.mSource, sourceLiteral)) {
ALOGE("%s: failed to convert source %d", __FUNCTION__, criterion.mValue.mSource); ALOGE("%s: failed to convert source %d", __FUNCTION__, criterion.mValue.mSource);
@ -120,12 +114,11 @@ status_t AudioPolicyMixCollection::registerMix(const String8& address, AudioMix
ALOGE("registerPolicyMixes(): mix for address %s already registered", address.string()); ALOGE("registerPolicyMixes(): mix for address %s already registered", address.string());
return BAD_VALUE; return BAD_VALUE;
} }
sp<AudioPolicyMix> policyMix = new AudioPolicyMix(); sp<AudioPolicyMix> policyMix = new AudioPolicyMix(mix);
policyMix->setMix(mix);
add(address, policyMix); add(address, policyMix);
if (desc != 0) { if (desc != 0) {
desc->mPolicyMix = policyMix->getMix(); desc->mPolicyMix = policyMix;
policyMix->setOutput(desc); policyMix->setOutput(desc);
} }
return NO_ERROR; return NO_ERROR;
@ -171,8 +164,7 @@ status_t AudioPolicyMixCollection::getOutputForAttr(audio_attributes_t attribute
ALOGV("getOutputForAttr() querying %zu mixes:", size()); ALOGV("getOutputForAttr() querying %zu mixes:", size());
desc = 0; desc = 0;
for (size_t i = 0; i < size(); i++) { for (size_t i = 0; i < size(); i++) {
sp<AudioPolicyMix> policyMix = valueAt(i); sp<AudioPolicyMix> mix = valueAt(i);
AudioMix *mix = policyMix->getMix();
if (mix->mMixType == MIX_TYPE_PLAYERS) { if (mix->mMixType == MIX_TYPE_PLAYERS) {
// TODO if adding more player rules (currently only 2), make rule handling "generic" // TODO if adding more player rules (currently only 2), make rule handling "generic"
@ -269,7 +261,7 @@ status_t AudioPolicyMixCollection::getOutputForAttr(audio_attributes_t attribute
(hasUidExcludeRules && uidExclusionFound) || (hasUidExcludeRules && uidExclusionFound) ||
(hasUidMatchRules && !uidMatchFound))) { (hasUidMatchRules && !uidMatchFound))) {
ALOGV("\tgetOutputForAttr will use mix %zu", i); ALOGV("\tgetOutputForAttr will use mix %zu", i);
desc = policyMix->getOutput(); desc = mix->getOutput();
} }
} else if (mix->mMixType == MIX_TYPE_RECORDERS) { } else if (mix->mMixType == MIX_TYPE_RECORDERS) {
@ -278,7 +270,7 @@ status_t AudioPolicyMixCollection::getOutputForAttr(audio_attributes_t attribute
strncmp(attributes.tags + strlen("addr="), strncmp(attributes.tags + strlen("addr="),
mix->mDeviceAddress.string(), mix->mDeviceAddress.string(),
AUDIO_ATTRIBUTES_TAGS_MAX_SIZE - strlen("addr=") - 1) == 0) { AUDIO_ATTRIBUTES_TAGS_MAX_SIZE - strlen("addr=") - 1) == 0) {
desc = policyMix->getOutput(); desc = mix->getOutput();
} }
} }
if (desc != 0) { if (desc != 0) {
@ -289,12 +281,13 @@ status_t AudioPolicyMixCollection::getOutputForAttr(audio_attributes_t attribute
return BAD_VALUE; return BAD_VALUE;
} }
audio_devices_t AudioPolicyMixCollection::getDeviceAndMixForInputSource(audio_source_t inputSource, audio_devices_t AudioPolicyMixCollection::getDeviceAndMixForInputSource(
audio_devices_t availDevices, audio_source_t inputSource,
AudioMix **policyMix) audio_devices_t availDevices,
sp<AudioPolicyMix> *policyMix)
{ {
for (size_t i = 0; i < size(); i++) { for (size_t i = 0; i < size(); i++) {
AudioMix *mix = valueAt(i)->getMix(); AudioPolicyMix *mix = valueAt(i).get();
if (mix->mMixType != MIX_TYPE_RECORDERS) { if (mix->mMixType != MIX_TYPE_RECORDERS) {
continue; continue;
@ -317,7 +310,8 @@ audio_devices_t AudioPolicyMixCollection::getDeviceAndMixForInputSource(audio_so
return AUDIO_DEVICE_NONE; return AUDIO_DEVICE_NONE;
} }
status_t AudioPolicyMixCollection::getInputMixForAttr(audio_attributes_t attr, AudioMix **policyMix) status_t AudioPolicyMixCollection::getInputMixForAttr(
audio_attributes_t attr, sp<AudioPolicyMix> *policyMix)
{ {
if (strncmp(attr.tags, "addr=", strlen("addr=")) != 0) { if (strncmp(attr.tags, "addr=", strlen("addr=")) != 0) {
return BAD_VALUE; return BAD_VALUE;
@ -327,8 +321,7 @@ status_t AudioPolicyMixCollection::getInputMixForAttr(audio_attributes_t attr, A
#ifdef LOG_NDEBUG #ifdef LOG_NDEBUG
ALOGV("getInputMixForAttr looking for address %s\n mixes available:", address.string()); ALOGV("getInputMixForAttr looking for address %s\n mixes available:", address.string());
for (size_t i = 0; i < size(); i++) { for (size_t i = 0; i < size(); i++) {
sp<AudioPolicyMix> policyMix = valueAt(i); sp<AudioPolicyMix> mix = valueAt(i);
AudioMix *mix = policyMix->getMix();
ALOGV("\tmix %zu address=%s", i, mix->mDeviceAddress.string()); ALOGV("\tmix %zu address=%s", i, mix->mDeviceAddress.string());
} }
#endif #endif
@ -339,13 +332,14 @@ status_t AudioPolicyMixCollection::getInputMixForAttr(audio_attributes_t attr, A
return BAD_VALUE; return BAD_VALUE;
} }
sp<AudioPolicyMix> audioPolicyMix = valueAt(index); sp<AudioPolicyMix> audioPolicyMix = valueAt(index);
AudioMix *mix = audioPolicyMix->getMix();
if (mix->mMixType != MIX_TYPE_PLAYERS) { if (audioPolicyMix->mMixType != MIX_TYPE_PLAYERS) {
ALOGW("getInputMixForAttr() bad policy mix type for address %s", address.string()); ALOGW("getInputMixForAttr() bad policy mix type for address %s", address.string());
return BAD_VALUE; return BAD_VALUE;
} }
*policyMix = mix; if (policyMix != nullptr) {
*policyMix = audioPolicyMix;
}
return NO_ERROR; return NO_ERROR;
} }

@ -19,6 +19,7 @@
#include <AudioPolicyInterface.h> #include <AudioPolicyInterface.h>
#include "policy.h" #include "policy.h"
#include "AudioPolicyMix.h"
#include "AudioSession.h" #include "AudioSession.h"
#include "AudioGain.h" #include "AudioGain.h"
#include "TypeConverter.h" #include "TypeConverter.h"
@ -36,7 +37,7 @@ AudioSession::AudioSession(audio_session_t session,
audio_input_flags_t flags, audio_input_flags_t flags,
uid_t uid, uid_t uid,
bool isSoundTrigger, bool isSoundTrigger,
AudioMix* policyMix, const sp<AudioPolicyMix> &policyMix,
AudioPolicyClientInterface *clientInterface) : AudioPolicyClientInterface *clientInterface) :
mRecordClientInfo({ .uid = uid, .session = session, .source = inputSource}), mRecordClientInfo({ .uid = uid, .session = session, .source = inputSource}),
mConfig({ .format = format, .sample_rate = sampleRate, .channel_mask = channelMask}), mConfig({ .format = format, .sample_rate = sampleRate, .channel_mask = channelMask}),
@ -79,9 +80,10 @@ uint32_t AudioSession::changeActiveCount(int delta)
if (event != RECORD_CONFIG_EVENT_NONE) { if (event != RECORD_CONFIG_EVENT_NONE) {
// Dynamic policy callback: // Dynamic policy callback:
// if input maps to a dynamic policy with an activity listener, notify of state change // if input maps to a dynamic policy with an activity listener, notify of state change
if ((mPolicyMix != NULL) && ((mPolicyMix->mCbFlags & AudioMix::kCbFlagNotifyActivity) != 0)) sp<AudioPolicyMix> policyMix = mPolicyMix.promote();
if ((policyMix != NULL) && ((policyMix->mCbFlags & AudioMix::kCbFlagNotifyActivity) != 0))
{ {
mClientInterface->onDynamicPolicyMixStateUpdate(mPolicyMix->mDeviceAddress, mClientInterface->onDynamicPolicyMixStateUpdate(policyMix->mDeviceAddress,
(event == RECORD_CONFIG_EVENT_START) ? MIX_STATE_MIXING : MIX_STATE_IDLE); (event == RECORD_CONFIG_EVENT_START) ? MIX_STATE_MIXING : MIX_STATE_IDLE);
} }

@ -1161,10 +1161,9 @@ status_t AudioPolicyManager::startOutput(audio_io_handle_t output,
mOutputRoutes.incRouteActivity(session); mOutputRoutes.incRouteActivity(session);
audio_devices_t newDevice; audio_devices_t newDevice;
AudioMix *policyMix = NULL; sp<AudioPolicyMix> policyMix = outputDesc->mPolicyMix.promote();
const char *address = NULL; const char *address = NULL;
if (outputDesc->mPolicyMix != NULL) { if (policyMix != NULL) {
policyMix = outputDesc->mPolicyMix;
address = policyMix->mDeviceAddress.string(); address = policyMix->mDeviceAddress.string();
if ((policyMix->mRouteFlags & MIX_ROUTE_FLAG_RENDER) == MIX_ROUTE_FLAG_RENDER) { if ((policyMix->mRouteFlags & MIX_ROUTE_FLAG_RENDER) == MIX_ROUTE_FLAG_RENDER) {
newDevice = policyMix->mDeviceType; newDevice = policyMix->mDeviceType;
@ -1364,12 +1363,13 @@ status_t AudioPolicyManager::stopOutput(audio_io_handle_t output,
if (outputDesc->mRefCount[stream] == 1) { if (outputDesc->mRefCount[stream] == 1) {
// Automatically disable the remote submix input when output is stopped on a // Automatically disable the remote submix input when output is stopped on a
// re routing mix of type MIX_TYPE_RECORDERS // re routing mix of type MIX_TYPE_RECORDERS
sp<AudioPolicyMix> policyMix = outputDesc->mPolicyMix.promote();
if (audio_is_remote_submix_device(outputDesc->mDevice) && if (audio_is_remote_submix_device(outputDesc->mDevice) &&
outputDesc->mPolicyMix != NULL && policyMix != NULL &&
outputDesc->mPolicyMix->mMixType == MIX_TYPE_RECORDERS) { policyMix->mMixType == MIX_TYPE_RECORDERS) {
setDeviceConnectionStateInt(AUDIO_DEVICE_IN_REMOTE_SUBMIX, setDeviceConnectionStateInt(AUDIO_DEVICE_IN_REMOTE_SUBMIX,
AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE, AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE,
outputDesc->mPolicyMix->mDeviceAddress, policyMix->mDeviceAddress,
"remote-submix"); "remote-submix");
} }
} }
@ -1509,7 +1509,7 @@ status_t AudioPolicyManager::getInputForAttr(const audio_attributes_t *attr,
String8 address = String8(""); String8 address = String8("");
audio_source_t halInputSource; audio_source_t halInputSource;
audio_source_t inputSource = attr->source; audio_source_t inputSource = attr->source;
AudioMix *policyMix = NULL; sp<AudioPolicyMix> policyMix;
DeviceVector inputDevices; DeviceVector inputDevices;
if (inputSource == AUDIO_SOURCE_DEFAULT) { if (inputSource == AUDIO_SOURCE_DEFAULT) {
@ -1650,7 +1650,7 @@ audio_io_handle_t AudioPolicyManager::getInputForDevice(audio_devices_t device,
audio_source_t inputSource, audio_source_t inputSource,
const audio_config_base_t *config, const audio_config_base_t *config,
audio_input_flags_t flags, audio_input_flags_t flags,
AudioMix *policyMix) const sp<AudioPolicyMix> &policyMix)
{ {
audio_io_handle_t input = AUDIO_IO_HANDLE_NONE; audio_io_handle_t input = AUDIO_IO_HANDLE_NONE;
audio_source_t halInputSource = inputSource; audio_source_t halInputSource = inputSource;
@ -2062,10 +2062,11 @@ status_t AudioPolicyManager::startInput(audio_io_handle_t input,
} }
if (inputDesc->getAudioSessionCount(true/*activeOnly*/) == 1) { if (inputDesc->getAudioSessionCount(true/*activeOnly*/) == 1) {
sp<AudioPolicyMix> policyMix = inputDesc->mPolicyMix.promote();
// if input maps to a dynamic policy with an activity listener, notify of state change // if input maps to a dynamic policy with an activity listener, notify of state change
if ((inputDesc->mPolicyMix != NULL) if ((policyMix != NULL)
&& ((inputDesc->mPolicyMix->mCbFlags & AudioMix::kCbFlagNotifyActivity) != 0)) { && ((policyMix->mCbFlags & AudioMix::kCbFlagNotifyActivity) != 0)) {
mpClientInterface->onDynamicPolicyMixStateUpdate(inputDesc->mPolicyMix->mDeviceAddress, mpClientInterface->onDynamicPolicyMixStateUpdate(policyMix->mDeviceAddress,
MIX_STATE_MIXING); MIX_STATE_MIXING);
} }
@ -2080,10 +2081,10 @@ status_t AudioPolicyManager::startInput(audio_io_handle_t input,
// For remote submix (a virtual device), we open only one input per capture request. // For remote submix (a virtual device), we open only one input per capture request.
if (audio_is_remote_submix_device(inputDesc->mDevice)) { if (audio_is_remote_submix_device(inputDesc->mDevice)) {
String8 address = String8(""); String8 address = String8("");
if (inputDesc->mPolicyMix == NULL) { if (policyMix == NULL) {
address = String8("0"); address = String8("0");
} else if (inputDesc->mPolicyMix->mMixType == MIX_TYPE_PLAYERS) { } else if (policyMix->mMixType == MIX_TYPE_PLAYERS) {
address = inputDesc->mPolicyMix->mDeviceAddress; address = policyMix->mDeviceAddress;
} }
if (address != "") { if (address != "") {
setDeviceConnectionStateInt(AUDIO_DEVICE_OUT_REMOTE_SUBMIX, setDeviceConnectionStateInt(AUDIO_DEVICE_OUT_REMOTE_SUBMIX,
@ -2131,10 +2132,11 @@ status_t AudioPolicyManager::stopInput(audio_io_handle_t input,
if (inputDesc->isActive()) { if (inputDesc->isActive()) {
setInputDevice(input, getNewInputDevice(inputDesc), false /* force */); setInputDevice(input, getNewInputDevice(inputDesc), false /* force */);
} else { } else {
sp<AudioPolicyMix> policyMix = inputDesc->mPolicyMix.promote();
// if input maps to a dynamic policy with an activity listener, notify of state change // if input maps to a dynamic policy with an activity listener, notify of state change
if ((inputDesc->mPolicyMix != NULL) if ((policyMix != NULL)
&& ((inputDesc->mPolicyMix->mCbFlags & AudioMix::kCbFlagNotifyActivity) != 0)) { && ((policyMix->mCbFlags & AudioMix::kCbFlagNotifyActivity) != 0)) {
mpClientInterface->onDynamicPolicyMixStateUpdate(inputDesc->mPolicyMix->mDeviceAddress, mpClientInterface->onDynamicPolicyMixStateUpdate(policyMix->mDeviceAddress,
MIX_STATE_IDLE); MIX_STATE_IDLE);
} }
@ -2142,10 +2144,10 @@ status_t AudioPolicyManager::stopInput(audio_io_handle_t input,
// used by a policy mix of type MIX_TYPE_RECORDERS // used by a policy mix of type MIX_TYPE_RECORDERS
if (audio_is_remote_submix_device(inputDesc->mDevice)) { if (audio_is_remote_submix_device(inputDesc->mDevice)) {
String8 address = String8(""); String8 address = String8("");
if (inputDesc->mPolicyMix == NULL) { if (policyMix == NULL) {
address = String8("0"); address = String8("0");
} else if (inputDesc->mPolicyMix->mMixType == MIX_TYPE_PLAYERS) { } else if (policyMix->mMixType == MIX_TYPE_PLAYERS) {
address = inputDesc->mPolicyMix->mDeviceAddress; address = policyMix->mDeviceAddress;
} }
if (address != "") { if (address != "") {
setDeviceConnectionStateInt(AUDIO_DEVICE_OUT_REMOTE_SUBMIX, setDeviceConnectionStateInt(AUDIO_DEVICE_OUT_REMOTE_SUBMIX,
@ -4374,7 +4376,7 @@ status_t AudioPolicyManager::checkOutputsForDevice(const sp<DeviceDescriptor>& d
address.string()); address.string());
} }
policyMix->setOutput(desc); policyMix->setOutput(desc);
desc->mPolicyMix = policyMix->getMix(); desc->mPolicyMix = policyMix;
} else if (((desc->mFlags & AUDIO_OUTPUT_FLAG_DIRECT) == 0) && } else if (((desc->mFlags & AUDIO_OUTPUT_FLAG_DIRECT) == 0) &&
hasPrimaryOutput()) { hasPrimaryOutput()) {
@ -5515,7 +5517,7 @@ sp<IOProfile> AudioPolicyManager::getInputProfile(audio_devices_t device,
audio_devices_t AudioPolicyManager::getDeviceAndMixForInputSource(audio_source_t inputSource, audio_devices_t AudioPolicyManager::getDeviceAndMixForInputSource(audio_source_t inputSource,
AudioMix **policyMix) sp<AudioPolicyMix> *policyMix)
{ {
audio_devices_t availableDeviceTypes = mAvailableInputDevices.types() & ~AUDIO_DEVICE_BIT_IN; audio_devices_t availableDeviceTypes = mAvailableInputDevices.types() & ~AUDIO_DEVICE_BIT_IN;
audio_devices_t selectedDeviceFromMix = audio_devices_t selectedDeviceFromMix =

@ -658,7 +658,7 @@ private:
audio_source_t inputSource, audio_source_t inputSource,
const audio_config_base_t *config, const audio_config_base_t *config,
audio_input_flags_t flags, audio_input_flags_t flags,
AudioMix *policyMix); const sp<AudioPolicyMix> &policyMix);
// internal function to derive a stream type value from audio attributes // internal function to derive a stream type value from audio attributes
audio_stream_type_t streamTypefromAttributesInt(const audio_attributes_t *attr); audio_stream_type_t streamTypefromAttributesInt(const audio_attributes_t *attr);
@ -672,7 +672,7 @@ private:
// select input device corresponding to requested audio source and return associated policy // select input device corresponding to requested audio source and return associated policy
// mix if any. Calls getDeviceForInputSource(). // mix if any. Calls getDeviceForInputSource().
audio_devices_t getDeviceAndMixForInputSource(audio_source_t inputSource, audio_devices_t getDeviceAndMixForInputSource(audio_source_t inputSource,
AudioMix **policyMix = NULL); sp<AudioPolicyMix> *policyMix = NULL);
// Called by setDeviceConnectionState(). // Called by setDeviceConnectionState().
status_t setDeviceConnectionStateInt(audio_devices_t device, status_t setDeviceConnectionStateInt(audio_devices_t device,

Loading…
Cancel
Save