diff options
Diffstat (limited to 'services')
4 files changed, 38 insertions, 16 deletions
diff --git a/services/audiopolicy/common/managerdefinitions/include/AudioPort.h b/services/audiopolicy/common/managerdefinitions/include/AudioPort.h index 1c2c27e..82e2c43 100644 --- a/services/audiopolicy/common/managerdefinitions/include/AudioPort.h +++ b/services/audiopolicy/common/managerdefinitions/include/AudioPort.h @@ -75,10 +75,8 @@ public: audio_format_t pickFormat() const; static const audio_format_t sPcmFormatCompareTable[]; - static int compareFormatsGoodToBad( - const audio_format_t *format1, const audio_format_t *format2) { - // compareFormats sorts from bad to good, we reverse it here - return compareFormats(*format2, *format1); + static int compareFormats(const audio_format_t *format1, const audio_format_t *format2) { + return compareFormats(*format1, *format2); } static int compareFormats(audio_format_t format1, audio_format_t format2); diff --git a/services/audiopolicy/common/managerdefinitions/src/AudioPort.cpp b/services/audiopolicy/common/managerdefinitions/src/AudioPort.cpp index 647550c..64f883a 100644 --- a/services/audiopolicy/common/managerdefinitions/src/AudioPort.cpp +++ b/services/audiopolicy/common/managerdefinitions/src/AudioPort.cpp @@ -146,7 +146,7 @@ void AudioPort::importAudioPort(const sp<AudioPort> port) { break; } } - if (!hasFormat) { // never import a channel mask twice + if (!hasFormat) { // never import a format twice mFormats.add(format); } } @@ -216,7 +216,12 @@ void AudioPort::loadFormats(char *name) } str = strtok(NULL, "|"); } - mFormats.sort(compareFormatsGoodToBad); + // we sort from worst to best, so that AUDIO_FORMAT_DEFAULT is always the first entry. + // TODO: compareFormats could be a lambda to convert between pointer-to-format to format: + // [](const audio_format_t *format1, const audio_format_t *format2) { + // return compareFormats(*format1, *format2); + // } + mFormats.sort(compareFormats); } void AudioPort::loadInChannels(char *name) @@ -558,11 +563,13 @@ status_t AudioPort::checkCompatibleFormat(audio_format_t format, audio_format_t mType == AUDIO_PORT_TYPE_MIX && mRole == AUDIO_PORT_ROLE_SINK && audio_is_linear_pcm(format); - for (size_t i = 0; i < mFormats.size(); ++i) { + // iterate from best format to worst format (reverse order) + for (ssize_t i = mFormats.size() - 1; i >= 0 ; --i) { if (mFormats[i] == format || - (checkInexact && audio_is_linear_pcm(mFormats[i]))) { - // for inexact checks we take the first linear pcm format since - // mFormats is sorted from best PCM format to worst PCM format. + (checkInexact + && mFormats[i] != AUDIO_FORMAT_DEFAULT + && audio_is_linear_pcm(mFormats[i]))) { + // for inexact checks we take the first linear pcm format due to sorting. if (updatedFormat != NULL) { *updatedFormat = mFormats[i]; } @@ -789,10 +796,15 @@ void AudioPort::dump(int fd, int spaces) const const char *formatStr = ConfigParsingUtils::enumToString(sFormatNameToEnumTable, ARRAY_SIZE(sFormatNameToEnumTable), mFormats[i]); - if (i == 0 && strcmp(formatStr, "") == 0) { + const bool isEmptyStr = formatStr[0] == 0; + if (i == 0 && isEmptyStr) { snprintf(buffer, SIZE, "Dynamic"); } else { - snprintf(buffer, SIZE, "%s", formatStr); + if (isEmptyStr) { + snprintf(buffer, SIZE, "%#x", mFormats[i]); + } else { + snprintf(buffer, SIZE, "%s", formatStr); + } } result.append(buffer); result.append(i == (mFormats.size() - 1) ? "" : ", "); diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp index 01f2b61..ba3fcaf 100644 --- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp +++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp @@ -1420,6 +1420,13 @@ status_t AudioPolicyManager::startInput(audio_io_handle_t input, } if (inputDesc->mRefCount == 0) { + // if input maps to a dynamic policy with an activity listener, notify of state change + if ((inputDesc->mPolicyMix != NULL) + && ((inputDesc->mPolicyMix->mFlags & MIX_FLAG_NOTIFY_ACTIVITY) != 0)) { + mpClientInterface->onDynamicPolicyMixStateUpdate(inputDesc->mPolicyMix->mRegistrationId, + MIX_STATE_MIXING); + } + if (mInputs.activeInputsCount() == 0) { SoundTrigger::setCaptureState(true); } @@ -1473,6 +1480,12 @@ status_t AudioPolicyManager::stopInput(audio_io_handle_t input, inputDesc->mRefCount--; if (inputDesc->mRefCount == 0) { + // if input maps to a dynamic policy with an activity listener, notify of state change + if ((inputDesc->mPolicyMix != NULL) + && ((inputDesc->mPolicyMix->mFlags & MIX_FLAG_NOTIFY_ACTIVITY) != 0)) { + mpClientInterface->onDynamicPolicyMixStateUpdate(inputDesc->mPolicyMix->mRegistrationId, + MIX_STATE_IDLE); + } // automatically disable the remote submix output when input is stopped if not // used by a policy mix of type MIX_TYPE_RECORDERS diff --git a/services/radio/RadioService.cpp b/services/radio/RadioService.cpp index a6c2bdf..cd0f5f3 100644 --- a/services/radio/RadioService.cpp +++ b/services/radio/RadioService.cpp @@ -146,7 +146,7 @@ status_t RadioService::attach(radio_handle_t handle, radio = module->addClient(client, config, withAudio); if (radio == 0) { - NO_INIT; + return NO_INIT; } return NO_ERROR; } @@ -500,13 +500,12 @@ sp<RadioService::ModuleClient> RadioService::Module::addClient(const sp<IRadioCl if (audio) { notifyDeviceConnection(true, ""); } + ALOGV("addClient() DONE moduleClient %p", moduleClient.get()); } else { + ALOGW("%s open_tuner failed with error %d", __FUNCTION__, ret); moduleClient.clear(); } - - ALOGV("addClient() DONE moduleClient %p", moduleClient.get()); - return moduleClient; } |