diff options
author | Dima Zavin <dima@android.com> | 2012-04-24 00:21:59 -0700 |
---|---|---|
committer | Dima Zavin <dima@android.com> | 2012-04-24 12:55:06 -0700 |
commit | 739022f26a7127ba76a98dda65411496086114a7 (patch) | |
tree | 68bc69cfee8439880bb010f1d399de4175d5c9e2 | |
parent | 5ec145df7708564d385fd3fb764085321cf4c253 (diff) | |
download | hardware_libhardware_legacy-739022f26a7127ba76a98dda65411496086114a7.zip hardware_libhardware_legacy-739022f26a7127ba76a98dda65411496086114a7.tar.gz hardware_libhardware_legacy-739022f26a7127ba76a98dda65411496086114a7.tar.bz2 |
audio_policy: set some reasonable defaults if audio_policy.conf is not found
Change-Id: I25f7407c34b3032d4e77a27a4ac47b648098d9b0
Signed-off-by: Dima Zavin <dima@android.com>
-rw-r--r-- | audio/AudioPolicyManagerBase.cpp | 31 | ||||
-rw-r--r-- | include/hardware_legacy/AudioPolicyManagerBase.h | 1 |
2 files changed, 31 insertions, 1 deletions
diff --git a/audio/AudioPolicyManagerBase.cpp b/audio/AudioPolicyManagerBase.cpp index d5c0e6f..b0debef 100644 --- a/audio/AudioPolicyManagerBase.cpp +++ b/audio/AudioPolicyManagerBase.cpp @@ -1219,7 +1219,8 @@ AudioPolicyManagerBase::AudioPolicyManagerBase(AudioPolicyClientInterface *clien if (loadAudioPolicyConfig(AUDIO_POLICY_VENDOR_CONFIG_FILE) != NO_ERROR) { if (loadAudioPolicyConfig(AUDIO_POLICY_CONFIG_FILE) != NO_ERROR) { - ALOGE("could not load audio policy configuration file"); + ALOGE("could not load audio policy configuration file, setting defaults"); + defaultAudioPolicyConfig(); } } @@ -3406,5 +3407,33 @@ status_t AudioPolicyManagerBase::loadAudioPolicyConfig(const char *path) return NO_ERROR; } +void AudioPolicyManagerBase::defaultAudioPolicyConfig(void) +{ + HwModule *module; + IOProfile *profile; + + mDefaultOutputDevice = AUDIO_DEVICE_OUT_SPEAKER; + mAttachedOutputDevices = AUDIO_DEVICE_OUT_SPEAKER; + mAvailableInputDevices = AUDIO_DEVICE_IN_BUILTIN_MIC; + + module = new HwModule("primary"); + + profile = new IOProfile(module); + profile->mSamplingRates.add(44100); + profile->mFormats.add(AUDIO_FORMAT_PCM_16_BIT); + profile->mChannelMasks.add(AUDIO_CHANNEL_OUT_STEREO); + profile->mSupportedDevices = AUDIO_DEVICE_OUT_SPEAKER; + profile->mFlags = AUDIO_OUTPUT_FLAG_PRIMARY; + module->mOutputProfiles.add(profile); + + profile = new IOProfile(module); + profile->mSamplingRates.add(8000); + profile->mFormats.add(AUDIO_FORMAT_PCM_16_BIT); + profile->mChannelMasks.add(AUDIO_CHANNEL_IN_MONO); + profile->mSupportedDevices = AUDIO_DEVICE_IN_BUILTIN_MIC; + module->mInputProfiles.add(profile); + + mHwModules.add(module); +} }; // namespace android diff --git a/include/hardware_legacy/AudioPolicyManagerBase.h b/include/hardware_legacy/AudioPolicyManagerBase.h index 916c952..8d38bbd 100644 --- a/include/hardware_legacy/AudioPolicyManagerBase.h +++ b/include/hardware_legacy/AudioPolicyManagerBase.h @@ -479,6 +479,7 @@ protected: void loadHwModules(cnode *root); void loadGlobalConfig(cnode *root); status_t loadAudioPolicyConfig(const char *path); + void defaultAudioPolicyConfig(void); AudioPolicyClientInterface *mpClientInterface; // audio policy client interface |