diff options
-rw-r--r-- | include/media/stagefright/Utils.h | 3 | ||||
-rw-r--r-- | media/libstagefright/Android.mk | 4 | ||||
-rw-r--r-- | media/libstagefright/AudioPlayer.cpp | 12 | ||||
-rw-r--r-- | media/libstagefright/HTTPBase.cpp | 4 | ||||
-rw-r--r-- | media/libstagefright/Utils.cpp | 44 | ||||
-rw-r--r-- | services/audioflinger/AudioFlinger.cpp | 23 | ||||
-rwxr-xr-x | services/audiopolicy/AudioPolicyEffects.cpp | 2 | ||||
-rw-r--r-- | services/audiopolicy/AudioPolicyManager.cpp | 192 | ||||
-rw-r--r-- | services/audiopolicy/AudioPolicyManager.h | 21 | ||||
-rwxr-xr-x | services/audiopolicy/AudioPolicyService.cpp | 4 |
10 files changed, 259 insertions, 50 deletions
diff --git a/include/media/stagefright/Utils.h b/include/media/stagefright/Utils.h index c85368f..a795c80 100644 --- a/include/media/stagefright/Utils.h +++ b/include/media/stagefright/Utils.h @@ -53,6 +53,9 @@ AString MakeUserAgent(); // Convert a MIME type to a AudioSystem::audio_format status_t mapMimeToAudioFormat(audio_format_t& format, const char* mime); +// Convert a aac profile to a AudioSystem::audio_format +void mapAACProfileToAudioFormat(audio_format_t& format, uint64_t eAacProfile); + // Send information from MetaData to the HAL via AudioSink status_t sendMetaDataToHal(sp<MediaPlayerBase::AudioSink>& sink, const sp<MetaData>& meta); diff --git a/media/libstagefright/Android.mk b/media/libstagefright/Android.mk index 99c8e9f..be9af5e 100644 --- a/media/libstagefright/Android.mk +++ b/media/libstagefright/Android.mk @@ -65,16 +65,15 @@ LOCAL_C_INCLUDES:= \ $(TOP)/frameworks/av/include/media/stagefright/timedtext \ $(TOP)/frameworks/native/include/media/hardware \ $(TOP)/frameworks/native/include/media/openmax \ - $(TOP)/frameworks/native/services/connectivitymanager \ $(TOP)/external/flac/include \ $(TOP)/external/tremolo \ $(TOP)/external/openssl/include \ $(TOP)/external/libvpx/libwebm \ + $(TOP)/system/netd/include \ LOCAL_SHARED_LIBRARIES := \ libbinder \ libcamera_client \ - libconnectivitymanager \ libcutils \ libdl \ libdrmframework \ @@ -84,6 +83,7 @@ LOCAL_SHARED_LIBRARIES := \ libicuuc \ liblog \ libmedia \ + libnetd_client \ libopus \ libsonivox \ libssl \ diff --git a/media/libstagefright/AudioPlayer.cpp b/media/libstagefright/AudioPlayer.cpp index fdac8fc..e24824b 100644 --- a/media/libstagefright/AudioPlayer.cpp +++ b/media/libstagefright/AudioPlayer.cpp @@ -23,6 +23,7 @@ #include <binder/IPCThreadState.h> #include <media/AudioTrack.h> +#include <media/openmax/OMX_Audio.h> #include <media/stagefright/foundation/ADebug.h> #include <media/stagefright/foundation/ALooper.h> #include <media/stagefright/AudioPlayer.h> @@ -141,6 +142,12 @@ status_t AudioPlayer::start(bool sourceAlreadyStarted) { } else { ALOGV("Mime type \"%s\" mapped to audio_format 0x%x", mime, audioFormat); } + + int32_t aacaot = -1; + if ((audioFormat == AUDIO_FORMAT_AAC) && format->findInt32(kKeyAACAOT, &aacaot)) { + // Redefine AAC format corrosponding to aac profile + mapAACProfileToAudioFormat(audioFormat,(OMX_AUDIO_AACPROFILETYPE) aacaot); + } } int avgBitRate = -1; @@ -759,6 +766,11 @@ int64_t AudioPlayer::getMediaTimeUs() { if (mSeeking) { return mSeekTimeUs; } + if (mReachedEOS) { + int64_t durationUs; + mSource->getFormat()->findInt64(kKeyDuration, &durationUs); + return durationUs; + } mPositionTimeRealUs = getOutputPlayPositionUs_l(); ALOGV("getMediaTimeUs getOutputPlayPositionUs_l() mPositionTimeRealUs %" PRId64, mPositionTimeRealUs); diff --git a/media/libstagefright/HTTPBase.cpp b/media/libstagefright/HTTPBase.cpp index ca68c3d..32291c8 100644 --- a/media/libstagefright/HTTPBase.cpp +++ b/media/libstagefright/HTTPBase.cpp @@ -26,7 +26,7 @@ #include <cutils/properties.h> #include <cutils/qtaguid.h> -#include <ConnectivityManager.h> +#include <NetdClient.h> namespace android { @@ -122,7 +122,7 @@ void HTTPBase::UnRegisterSocketUserTag(int sockfd) { // static void HTTPBase::RegisterSocketUserMark(int sockfd, uid_t uid) { - ConnectivityManager::markSocketAsUser(sockfd, uid); + setNetworkForUser(uid, sockfd); } // static diff --git a/media/libstagefright/Utils.cpp b/media/libstagefright/Utils.cpp index 8c5deb3..750bff0 100644 --- a/media/libstagefright/Utils.cpp +++ b/media/libstagefright/Utils.cpp @@ -23,6 +23,7 @@ #include <arpa/inet.h> #include <cutils/properties.h> +#include <media/openmax/OMX_Audio.h> #include <media/stagefright/foundation/ABuffer.h> #include <media/stagefright/foundation/ADebug.h> #include <media/stagefright/foundation/AMessage.h> @@ -609,6 +610,39 @@ const struct mime_conv_t* p = &mimeLookup[0]; return BAD_VALUE; } +struct aac_format_conv_t { + OMX_AUDIO_AACPROFILETYPE eAacProfileType; + audio_format_t format; +}; + +static const struct aac_format_conv_t profileLookup[] = { + { OMX_AUDIO_AACObjectMain, AUDIO_FORMAT_AAC_MAIN}, + { OMX_AUDIO_AACObjectLC, AUDIO_FORMAT_AAC_LC}, + { OMX_AUDIO_AACObjectSSR, AUDIO_FORMAT_AAC_SSR}, + { OMX_AUDIO_AACObjectLTP, AUDIO_FORMAT_AAC_LTP}, + { OMX_AUDIO_AACObjectHE, AUDIO_FORMAT_AAC_HE_V1}, + { OMX_AUDIO_AACObjectScalable, AUDIO_FORMAT_AAC_SCALABLE}, + { OMX_AUDIO_AACObjectERLC, AUDIO_FORMAT_AAC_ERLC}, + { OMX_AUDIO_AACObjectLD, AUDIO_FORMAT_AAC_LD}, + { OMX_AUDIO_AACObjectHE_PS, AUDIO_FORMAT_AAC_HE_V2}, + { OMX_AUDIO_AACObjectELD, AUDIO_FORMAT_AAC_ELD}, + { OMX_AUDIO_AACObjectNull, AUDIO_FORMAT_AAC}, +}; + +void mapAACProfileToAudioFormat( audio_format_t& format, uint64_t eAacProfile) +{ +const struct aac_format_conv_t* p = &profileLookup[0]; + while (p->eAacProfileType != OMX_AUDIO_AACObjectNull) { + if (eAacProfile == p->eAacProfileType) { + format = p->format; + return; + } + ++p; + } + format = AUDIO_FORMAT_AAC; + return; +} + bool canOffloadStream(const sp<MetaData>& meta, bool hasVideo, bool isStreaming, audio_stream_type_t streamType) { @@ -634,15 +668,11 @@ bool canOffloadStream(const sp<MetaData>& meta, bool hasVideo, return false; } - // check whether it is ELD/LD content -> no offloading - // FIXME: this should depend on audio DSP capabilities. mapMimeToAudioFormat() should use the - // metadata to refine the AAC format and the audio HAL should only list supported profiles. + // Redefine aac format according to its profile + // Offloading depends on audio DSP capabilities. int32_t aacaot = -1; if (meta->findInt32(kKeyAACAOT, &aacaot)) { - if (aacaot == 23 || aacaot == 39 ) { - ALOGV("track of type '%s' is ELD/LD content", mime); - return false; - } + mapAACProfileToAudioFormat(info.format,(OMX_AUDIO_AACPROFILETYPE) aacaot); } int32_t srate = -1; diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp index 2124f85..5fed0c1 100644 --- a/services/audioflinger/AudioFlinger.cpp +++ b/services/audioflinger/AudioFlinger.cpp @@ -106,13 +106,19 @@ static const nsecs_t kMinGlobalEffectEnabletimeNs = seconds(7200); // ---------------------------------------------------------------------------- const char *formatToString(audio_format_t format) { - switch(format) { - case AUDIO_FORMAT_PCM_SUB_8_BIT: return "pcm8"; - case AUDIO_FORMAT_PCM_SUB_16_BIT: return "pcm16"; - case AUDIO_FORMAT_PCM_SUB_32_BIT: return "pcm32"; - case AUDIO_FORMAT_PCM_SUB_8_24_BIT: return "pcm8.24"; - case AUDIO_FORMAT_PCM_SUB_24_BIT_PACKED: return "pcm24"; - case AUDIO_FORMAT_PCM_SUB_FLOAT: return "pcmfloat"; + switch (format & AUDIO_FORMAT_MAIN_MASK) { + case AUDIO_FORMAT_PCM: + switch (format) { + case AUDIO_FORMAT_PCM_16_BIT: return "pcm16"; + case AUDIO_FORMAT_PCM_8_BIT: return "pcm8"; + case AUDIO_FORMAT_PCM_32_BIT: return "pcm32"; + case AUDIO_FORMAT_PCM_8_24_BIT: return "pcm8.24"; + case AUDIO_FORMAT_PCM_FLOAT: return "pcmfloat"; + case AUDIO_FORMAT_PCM_24_BIT_PACKED: return "pcm24"; + default: + break; + } + break; case AUDIO_FORMAT_MP3: return "mp3"; case AUDIO_FORMAT_AMR_NB: return "amr-nb"; case AUDIO_FORMAT_AMR_WB: return "amr-wb"; @@ -120,6 +126,9 @@ const char *formatToString(audio_format_t format) { case AUDIO_FORMAT_HE_AAC_V1: return "he-aac-v1"; case AUDIO_FORMAT_HE_AAC_V2: return "he-aac-v2"; case AUDIO_FORMAT_VORBIS: return "vorbis"; + case AUDIO_FORMAT_OPUS: return "opus"; + case AUDIO_FORMAT_AC3: return "ac-3"; + case AUDIO_FORMAT_E_AC3: return "e-ac-3"; default: break; } diff --git a/services/audiopolicy/AudioPolicyEffects.cpp b/services/audiopolicy/AudioPolicyEffects.cpp index 185e1cc..cc0e965 100755 --- a/services/audiopolicy/AudioPolicyEffects.cpp +++ b/services/audiopolicy/AudioPolicyEffects.cpp @@ -15,7 +15,7 @@ */ #define LOG_TAG "AudioPolicyEffects" -#define LOG_NDEBUG 0 +//#define LOG_NDEBUG 0 #include <stdlib.h> #include <stdio.h> diff --git a/services/audiopolicy/AudioPolicyManager.cpp b/services/audiopolicy/AudioPolicyManager.cpp index 73c9313..1b4796b 100644 --- a/services/audiopolicy/AudioPolicyManager.cpp +++ b/services/audiopolicy/AudioPolicyManager.cpp @@ -122,6 +122,16 @@ const StringToEnum sFormatNameToEnumTable[] = { STRING_TO_ENUM(AUDIO_FORMAT_PCM_24_BIT_PACKED), STRING_TO_ENUM(AUDIO_FORMAT_MP3), STRING_TO_ENUM(AUDIO_FORMAT_AAC), + STRING_TO_ENUM(AUDIO_FORMAT_AAC_MAIN), + STRING_TO_ENUM(AUDIO_FORMAT_AAC_LC), + STRING_TO_ENUM(AUDIO_FORMAT_AAC_SSR), + STRING_TO_ENUM(AUDIO_FORMAT_AAC_LTP), + STRING_TO_ENUM(AUDIO_FORMAT_AAC_HE_V1), + STRING_TO_ENUM(AUDIO_FORMAT_AAC_SCALABLE), + STRING_TO_ENUM(AUDIO_FORMAT_AAC_ERLC), + STRING_TO_ENUM(AUDIO_FORMAT_AAC_LD), + STRING_TO_ENUM(AUDIO_FORMAT_AAC_HE_V2), + STRING_TO_ENUM(AUDIO_FORMAT_AAC_ELD), STRING_TO_ENUM(AUDIO_FORMAT_VORBIS), STRING_TO_ENUM(AUDIO_FORMAT_HE_AAC_V1), STRING_TO_ENUM(AUDIO_FORMAT_HE_AAC_V2), @@ -2701,10 +2711,15 @@ status_t AudioPolicyManager::checkOutputsForDevice(audio_devices_t device, ALOGW("checkOutputsForDevice() direct output missing param"); mpClientInterface->closeOutput(output); output = 0; - } else if (profile->mSamplingRates[0] == 0) { + } else if (profile->mSamplingRates[0] == 0 || profile->mFormats[0] == 0 || + profile->mChannelMasks[0] == 0) { mpClientInterface->closeOutput(output); - desc->mSamplingRate = profile->mSamplingRates[1]; + desc->mSamplingRate = profile->pickSamplingRate(); + desc->mFormat = profile->pickFormat(); + desc->mChannelMask = profile->pickChannelMask(); offloadInfo.sample_rate = desc->mSamplingRate; + offloadInfo.format = desc->mFormat; + offloadInfo.channel_mask = desc->mChannelMask; output = mpClientInterface->openOutput( profile->mModule->mHandle, &desc->mDevice, @@ -4490,9 +4505,9 @@ AudioPolicyManager::AudioOutputDescriptor::AudioOutputDescriptor( } if (profile != NULL) { mAudioPort = profile; - mSamplingRate = profile->mSamplingRates[0]; - mFormat = profile->mFormats[0]; - mChannelMask = profile->mChannelMasks[0]; + mSamplingRate = profile->pickSamplingRate(); + mFormat = profile->pickFormat(); + mChannelMask = profile->pickChannelMask(); if (profile->mGains.size() > 0) { profile->mGains[0]->getDefaultConfig(&mGain); } @@ -4671,16 +4686,12 @@ AudioPolicyManager::AudioInputDescriptor::AudioInputDescriptor(const sp<IOProfil { if (profile != NULL) { mAudioPort = profile; - mSamplingRate = profile->mSamplingRates[0]; - mFormat = profile->mFormats[0]; - mChannelMask = profile->mChannelMasks[0]; + mSamplingRate = profile->pickSamplingRate(); + mFormat = profile->pickFormat(); + mChannelMask = profile->pickChannelMask(); if (profile->mGains.size() > 0) { profile->mGains[0]->getDefaultConfig(&mGain); } - } else { - mSamplingRate = 0; - mFormat = AUDIO_FORMAT_DEFAULT; - mChannelMask = 0; } } @@ -4996,7 +5007,7 @@ void AudioPolicyManager::HwModule::dump(int fd) AudioPolicyManager::AudioPort::AudioPort(const String8& name, audio_port_type_t type, audio_port_role_t role, const sp<HwModule>& module) : - mName(name), mType(type), mRole(role), mModule(module) + mName(name), mType(type), mRole(role), mModule(module), mFlags((audio_output_flags_t)0) { mUseInChannelMask = ((type == AUDIO_PORT_TYPE_DEVICE) && (role == AUDIO_PORT_ROLE_SOURCE)) || ((type == AUDIO_PORT_TYPE_MIX) && (role == AUDIO_PORT_ROLE_SINK)); @@ -5224,6 +5235,127 @@ status_t AudioPolicyManager::AudioPort::checkFormat(audio_format_t format) const return BAD_VALUE; } + +uint32_t AudioPolicyManager::AudioPort::pickSamplingRate() const +{ + // special case for uninitialized dynamic profile + if (mSamplingRates.size() == 1 && mSamplingRates[0] == 0) { + return 0; + } + + uint32_t samplingRate = 0; + uint32_t maxRate = MAX_MIXER_SAMPLING_RATE; + + // For mixed output and inputs, use max mixer sampling rates. Do not + // limit sampling rate otherwise + if ((mType != AUDIO_PORT_TYPE_MIX) || + ((mRole == AUDIO_PORT_ROLE_SOURCE) && + (mFlags & (AUDIO_OUTPUT_FLAG_DIRECT | AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD)))) { + maxRate = UINT_MAX; + } + for (size_t i = 0; i < mSamplingRates.size(); i ++) { + if ((mSamplingRates[i] > samplingRate) && (mSamplingRates[i] <= maxRate)) { + samplingRate = mSamplingRates[i]; + } + } + return samplingRate; +} + +audio_channel_mask_t AudioPolicyManager::AudioPort::pickChannelMask() const +{ + // special case for uninitialized dynamic profile + if (mChannelMasks.size() == 1 && mChannelMasks[0] == 0) { + return AUDIO_CHANNEL_NONE; + } + + audio_channel_mask_t channelMask = AUDIO_CHANNEL_NONE; + uint32_t channelCount = 0; + uint32_t maxCount = MAX_MIXER_CHANNEL_COUNT; + + // For mixed output and inputs, use max mixer channel count. Do not + // limit channel count otherwise + if ((mType != AUDIO_PORT_TYPE_MIX) || + ((mRole == AUDIO_PORT_ROLE_SOURCE) && + (mFlags & (AUDIO_OUTPUT_FLAG_DIRECT | AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD)))) { + maxCount = UINT_MAX; + } + for (size_t i = 0; i < mChannelMasks.size(); i ++) { + uint32_t cnlCount; + if (mUseInChannelMask) { + cnlCount = audio_channel_count_from_in_mask(mChannelMasks[i]); + } else { + cnlCount = audio_channel_count_from_out_mask(mChannelMasks[i]); + } + if ((cnlCount > channelCount) && (cnlCount <= maxCount)) { + channelMask = mChannelMasks[i]; + } + } + return channelMask; +} + +const audio_format_t AudioPolicyManager::AudioPort::sPcmFormatCompareTable[] = { + AUDIO_FORMAT_DEFAULT, + AUDIO_FORMAT_PCM_16_BIT, + AUDIO_FORMAT_PCM_24_BIT_PACKED, +}; + +int AudioPolicyManager::AudioPort::compareFormats(audio_format_t format1, + audio_format_t format2) +{ + // NOTE: AUDIO_FORMAT_INVALID is also considered not PCM and will be compared equal to any + // compressed format and better than any PCM format. This is by design of pickFormat() + if (!audio_is_linear_pcm(format1)) { + if (!audio_is_linear_pcm(format2)) { + return 0; + } + return 1; + } + if (!audio_is_linear_pcm(format2)) { + return -1; + } + + int index1 = -1, index2 = -1; + for (size_t i = 0; + (i < ARRAY_SIZE(sPcmFormatCompareTable)) && ((index1 == -1) || (index2 == -1)); + i ++) { + if (sPcmFormatCompareTable[i] == format1) { + index1 = i; + } + if (sPcmFormatCompareTable[i] == format2) { + index2 = i; + } + } + // format1 not found => index1 < 0 => format2 > format1 + // format2 not found => index2 < 0 => format2 < format1 + return index1 - index2; +} + +audio_format_t AudioPolicyManager::AudioPort::pickFormat() const +{ + // special case for uninitialized dynamic profile + if (mFormats.size() == 1 && mFormats[0] == 0) { + return AUDIO_FORMAT_DEFAULT; + } + + audio_format_t format = AUDIO_FORMAT_DEFAULT; + audio_format_t bestFormat = BEST_MIXER_FORMAT; + // For mixed output and inputs, use best mixer output format. Do not + // limit format otherwise + if ((mType != AUDIO_PORT_TYPE_MIX) || + ((mRole == AUDIO_PORT_ROLE_SOURCE) && + (((mFlags & (AUDIO_OUTPUT_FLAG_DIRECT | AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD)) == 0)))) { + bestFormat = AUDIO_FORMAT_INVALID; + } + + for (size_t i = 0; i < mFormats.size(); i ++) { + if ((compareFormats(mFormats[i], format) > 0) && + (compareFormats(mFormats[i], bestFormat) <= 0)) { + format = mFormats[i]; + } + } + return format; +} + status_t AudioPolicyManager::AudioPort::checkGain(const struct audio_gain_config *gainConfig, int index) const { @@ -5248,7 +5380,11 @@ void AudioPolicyManager::AudioPort::dump(int fd, int spaces) const snprintf(buffer, SIZE, "%*s- sampling rates: ", spaces, ""); result.append(buffer); for (size_t i = 0; i < mSamplingRates.size(); i++) { - snprintf(buffer, SIZE, "%d", mSamplingRates[i]); + if (i == 0 && mSamplingRates[i] == 0) { + snprintf(buffer, SIZE, "Dynamic"); + } else { + snprintf(buffer, SIZE, "%d", mSamplingRates[i]); + } result.append(buffer); result.append(i == (mSamplingRates.size() - 1) ? "" : ", "); } @@ -5259,7 +5395,13 @@ void AudioPolicyManager::AudioPort::dump(int fd, int spaces) const snprintf(buffer, SIZE, "%*s- channel masks: ", spaces, ""); result.append(buffer); for (size_t i = 0; i < mChannelMasks.size(); i++) { - snprintf(buffer, SIZE, "0x%04x", mChannelMasks[i]); + ALOGV("AudioPort::dump mChannelMasks %zu %08x", i, mChannelMasks[i]); + + if (i == 0 && mChannelMasks[i] == 0) { + snprintf(buffer, SIZE, "Dynamic"); + } else { + snprintf(buffer, SIZE, "0x%04x", mChannelMasks[i]); + } result.append(buffer); result.append(i == (mChannelMasks.size() - 1) ? "" : ", "); } @@ -5270,9 +5412,14 @@ void AudioPolicyManager::AudioPort::dump(int fd, int spaces) const snprintf(buffer, SIZE, "%*s- formats: ", spaces, ""); result.append(buffer); for (size_t i = 0; i < mFormats.size(); i++) { - snprintf(buffer, SIZE, "%-48s", enumToString(sFormatNameToEnumTable, - ARRAY_SIZE(sFormatNameToEnumTable), - mFormats[i])); + const char *formatStr = enumToString(sFormatNameToEnumTable, + ARRAY_SIZE(sFormatNameToEnumTable), + mFormats[i]); + if (i == 0 && strcmp(formatStr, "") == 0) { + snprintf(buffer, SIZE, "Dynamic"); + } else { + snprintf(buffer, SIZE, "%-48s", formatStr); + } result.append(buffer); result.append(i == (mFormats.size() - 1) ? "" : ", "); } @@ -5495,7 +5642,7 @@ void AudioPolicyManager::AudioPortConfig::toAudioPortConfig( AudioPolicyManager::IOProfile::IOProfile(const String8& name, audio_port_role_t role, const sp<HwModule>& module) - : AudioPort(name, AUDIO_PORT_TYPE_MIX, role, module), mFlags((audio_output_flags_t)0) + : AudioPort(name, AUDIO_PORT_TYPE_MIX, role, module) { } @@ -5586,8 +5733,7 @@ AudioPolicyManager::DeviceDescriptor::DeviceDescriptor(const String8& name, audi audio_is_output_device(type) ? AUDIO_PORT_ROLE_SINK : AUDIO_PORT_ROLE_SOURCE, NULL), - mDeviceType(type), mAddress(""), - mChannelMask(AUDIO_CHANNEL_NONE), mId(0) + mDeviceType(type), mAddress(""), mId(0) { mAudioPort = this; if (mGains.size() > 0) { @@ -5807,10 +5953,6 @@ status_t AudioPolicyManager::DeviceDescriptor::dump(int fd, int spaces, int inde snprintf(buffer, SIZE, "%*s- address: %-32s\n", spaces, "", mAddress.string()); result.append(buffer); } - if (mChannelMask != AUDIO_CHANNEL_NONE) { - snprintf(buffer, SIZE, "%*s- channel mask: %08x\n", spaces, "", mChannelMask); - result.append(buffer); - } write(fd, result.string(), result.size()); AudioPort::dump(fd, spaces); diff --git a/services/audiopolicy/AudioPolicyManager.h b/services/audiopolicy/AudioPolicyManager.h index c23d994..4caecca 100644 --- a/services/audiopolicy/AudioPolicyManager.h +++ b/services/audiopolicy/AudioPolicyManager.h @@ -52,6 +52,12 @@ namespace android { // Can be overridden by the audio.offload.min.duration.secs property #define OFFLOAD_DEFAULT_MIN_DURATION_SECS 60 +#define MAX_MIXER_SAMPLING_RATE 48000 +#define MAX_MIXER_CHANNEL_COUNT 2 +// See AudioPort::compareFormats() +#define WORST_MIXER_FORMAT AUDIO_FORMAT_PCM_16_BIT +#define BEST_MIXER_FORMAT AUDIO_FORMAT_PCM_24_BIT_PACKED + // ---------------------------------------------------------------------------- // AudioPolicyManager implements audio policy manager behavior common to all platforms. // ---------------------------------------------------------------------------- @@ -238,6 +244,13 @@ protected: status_t checkFormat(audio_format_t format) const; status_t checkGain(const struct audio_gain_config *gainConfig, int index) const; + uint32_t pickSamplingRate() const; + audio_channel_mask_t pickChannelMask() const; + audio_format_t pickFormat() const; + + static const audio_format_t sPcmFormatCompareTable[]; + static int compareFormats(audio_format_t format1, audio_format_t format2); + void dump(int fd, int spaces) const; String8 mName; @@ -252,6 +265,8 @@ protected: Vector <audio_format_t> mFormats; // supported audio formats Vector < sp<AudioGain> > mGains; // gain controllers sp<HwModule> mModule; // audio HW module exposing this I/O stream + audio_output_flags_t mFlags; // attribute flags (e.g primary output, + // direct output...). For outputs only. }; class AudioPortConfig: public virtual RefBase @@ -302,7 +317,6 @@ protected: audio_devices_t mDeviceType; String8 mAddress; - audio_channel_mask_t mChannelMask; audio_port_handle_t mId; }; @@ -352,11 +366,10 @@ protected: DeviceVector mSupportedDevices; // supported devices // (devices this output can be routed to) - audio_output_flags_t mFlags; // attribute flags (e.g primary output, - // direct output...). For outputs only. }; - class HwModule : public RefBase{ + class HwModule : public RefBase + { public: HwModule(const char *name); ~HwModule(); diff --git a/services/audiopolicy/AudioPolicyService.cpp b/services/audiopolicy/AudioPolicyService.cpp index 9435797..ae9cc35 100755 --- a/services/audiopolicy/AudioPolicyService.cpp +++ b/services/audiopolicy/AudioPolicyService.cpp @@ -841,8 +841,8 @@ void AudioPolicyService::AudioCommandThread::insertCommand_l(sp<AudioCommand>& c } // insert command at the right place according to its time stamp - ALOGV("inserting command: %d at index %d, num commands %d", - command->mCommand, (int)i+1, mAudioCommands.size()); + ALOGV("inserting command: %d at index %zd, num commands %zu", + command->mCommand, i+1, mAudioCommands.size()); mAudioCommands.insertAt(command, i + 1); } |