OSDN Git Service

audiopolicy: fix output audio format selection
authorEric Laurent <elaurent@google.com>
Sun, 27 Jul 2014 20:47:31 +0000 (13:47 -0700)
committerJean-Michel Trivi <jmtrivi@google.com>
Sun, 27 Jul 2014 20:52:03 +0000 (20:52 +0000)
Fix two problems in output stream audio format selection
added by commit 1e693b55:
- flags must be set before picking the format.
- fix logic error in best format selection.

Change-Id: I6458b32725f771da5a08108932d64e71964ae9f1

services/audiopolicy/AudioPolicyManager.cpp

index aa6a389..f1d65f0 100644 (file)
@@ -4627,13 +4627,13 @@ AudioPolicyManager::AudioOutputDescriptor::AudioOutputDescriptor(
     }
     if (profile != NULL) {
         mAudioPort = profile;
+        mFlags = profile->mFlags;
         mSamplingRate = profile->pickSamplingRate();
         mFormat = profile->pickFormat();
         mChannelMask = profile->pickChannelMask();
         if (profile->mGains.size() > 0) {
             profile->mGains[0]->getDefaultConfig(&mGain);
         }
-        mFlags = profile->mFlags;
     }
 }
 
@@ -5470,7 +5470,7 @@ audio_format_t AudioPolicyManager::AudioPort::pickFormat() const
     // 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)))) {
+             (((mFlags & (AUDIO_OUTPUT_FLAG_DIRECT | AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD)) != 0)))) {
         bestFormat = AUDIO_FORMAT_INVALID;
     }