OSDN Git Service

audio policy: fix check in creaateAudioPatch()
authorEric Laurent <elaurent@google.com>
Fri, 12 Sep 2014 23:19:41 +0000 (16:19 -0700)
committerEric Laurent <elaurent@google.com>
Fri, 12 Sep 2014 23:22:00 +0000 (16:22 -0700)
Bug: 17488759.
Change-Id: I9dd2c3ca7f83de4b3573f4fb0e9934e1bc37c3bc

services/audiopolicy/AudioPolicyManager.cpp

index 22c4e04..abdbc5c 100644 (file)
@@ -2294,14 +2294,14 @@ status_t AudioPolicyManager::createAudioPatch(const struct audio_patch *patch,
             }
             sp<DeviceDescriptor> srcDeviceDesc =
                     mAvailableInputDevices.getDeviceFromId(patch->sources[0].id);
+            if (srcDeviceDesc == 0) {
+                return BAD_VALUE;
+            }
 
             //update source and sink with our own data as the data passed in the patch may
             // be incomplete.
             struct audio_patch newPatch = *patch;
             srcDeviceDesc->toAudioPortConfig(&newPatch.sources[0], &patch->sources[0]);
-            if (srcDeviceDesc == 0) {
-                return BAD_VALUE;
-            }
 
             for (size_t i = 0; i < patch->num_sinks; i++) {
                 if (patch->sinks[i].type != AUDIO_PORT_TYPE_DEVICE) {