diff options
author | Marco Nelissen <marcone@google.com> | 2014-08-25 15:58:39 -0700 |
---|---|---|
committer | The Android Automerger <android-build@google.com> | 2014-08-27 11:48:52 -0700 |
commit | 4789dea53f9e4404762cbeceafa7b54cf67dc77a (patch) | |
tree | 1c041f7543d800c3a378f19ee0ebaf490ad4ef54 | |
parent | 7bf083ed328d33499782215877c6c962706ca764 (diff) | |
download | frameworks_av-4789dea53f9e4404762cbeceafa7b54cf67dc77a.zip frameworks_av-4789dea53f9e4404762cbeceafa7b54cf67dc77a.tar.gz frameworks_av-4789dea53f9e4404762cbeceafa7b54cf67dc77a.tar.bz2 |
Fix memory leak in getConnectionState
Turns out having an sp<> point at the containing object doesn't really
work so well.
Bug: 17210991
Change-Id: I4bcb0c38adffc574d661f0772583357868f6c5b4
-rw-r--r-- | services/audiopolicy/AudioPolicyManager.cpp | 16 | ||||
-rw-r--r-- | services/audiopolicy/AudioPolicyManager.h | 5 |
2 files changed, 11 insertions, 10 deletions
diff --git a/services/audiopolicy/AudioPolicyManager.cpp b/services/audiopolicy/AudioPolicyManager.cpp index 14fdec5..b643eac 100644 --- a/services/audiopolicy/AudioPolicyManager.cpp +++ b/services/audiopolicy/AudioPolicyManager.cpp @@ -3874,7 +3874,7 @@ audio_devices_t AudioPolicyManager::getDeviceForStrategy(routing_strategy strate if (((mAvailableInputDevices.types() & AUDIO_DEVICE_IN_TELEPHONY_RX & ~AUDIO_DEVICE_BIT_IN) == 0) || (((txDevice & availablePrimaryInputDevices() & ~AUDIO_DEVICE_BIT_IN) != 0) && - (hwOutputDesc->mAudioPort->mModule->mHalVersion < + (hwOutputDesc->getAudioPort()->mModule->mHalVersion < AUDIO_DEVICE_API_VERSION_3_0))) { availableOutputDeviceTypes = availablePrimaryOutputDevices(); } @@ -5070,7 +5070,6 @@ AudioPolicyManager::AudioOutputDescriptor::AudioOutputDescriptor( mStrategyMutedByDevice[i] = false; } if (profile != NULL) { - mAudioPort = profile; mFlags = profile->mFlags; mSamplingRate = profile->pickSamplingRate(); mFormat = profile->pickFormat(); @@ -5253,7 +5252,6 @@ AudioPolicyManager::AudioInputDescriptor::AudioInputDescriptor(const sp<IOProfil mInputSource(AUDIO_SOURCE_DEFAULT), mProfile(profile), mIsSoundTrigger(false) { if (profile != NULL) { - mAudioPort = profile; mSamplingRate = profile->pickSamplingRate(); mFormat = profile->pickFormat(); mChannelMask = profile->pickChannelMask(); @@ -6273,33 +6271,34 @@ status_t AudioPolicyManager::AudioPortConfig::applyAudioPortConfig( localBackupConfig.config_mask = config->config_mask; toAudioPortConfig(&localBackupConfig); - if (mAudioPort == 0) { + sp<AudioPort> audioport = getAudioPort(); + if (audioport == 0) { status = NO_INIT; goto exit; } if (config->config_mask & AUDIO_PORT_CONFIG_SAMPLE_RATE) { - status = mAudioPort->checkExactSamplingRate(config->sample_rate); + status = audioport->checkExactSamplingRate(config->sample_rate); if (status != NO_ERROR) { goto exit; } mSamplingRate = config->sample_rate; } if (config->config_mask & AUDIO_PORT_CONFIG_CHANNEL_MASK) { - status = mAudioPort->checkExactChannelMask(config->channel_mask); + status = audioport->checkExactChannelMask(config->channel_mask); if (status != NO_ERROR) { goto exit; } mChannelMask = config->channel_mask; } if (config->config_mask & AUDIO_PORT_CONFIG_FORMAT) { - status = mAudioPort->checkFormat(config->format); + status = audioport->checkFormat(config->format); if (status != NO_ERROR) { goto exit; } mFormat = config->format; } if (config->config_mask & AUDIO_PORT_CONFIG_GAIN) { - status = mAudioPort->checkGain(&config->gain, config->gain.index); + status = audioport->checkGain(&config->gain, config->gain.index); if (status != NO_ERROR) { goto exit; } @@ -6486,7 +6485,6 @@ AudioPolicyManager::DeviceDescriptor::DeviceDescriptor(const String8& name, audi NULL), mDeviceType(type), mAddress(""), mId(0) { - mAudioPort = this; if (mGains.size() > 0) { mGains[0]->getDefaultConfig(&mGain); } diff --git a/services/audiopolicy/AudioPolicyManager.h b/services/audiopolicy/AudioPolicyManager.h index e3e3172..6712eb7 100644 --- a/services/audiopolicy/AudioPolicyManager.h +++ b/services/audiopolicy/AudioPolicyManager.h @@ -297,7 +297,7 @@ protected: struct audio_port_config *backupConfig = NULL); virtual void toAudioPortConfig(struct audio_port_config *dstConfig, const struct audio_port_config *srcConfig = NULL) const = 0; - sp<AudioPort> mAudioPort; + virtual sp<AudioPort> getAudioPort() const = 0; uint32_t mSamplingRate; audio_format_t mFormat; audio_channel_mask_t mChannelMask; @@ -330,6 +330,7 @@ protected: bool equals(const sp<DeviceDescriptor>& other) const; virtual void toAudioPortConfig(struct audio_port_config *dstConfig, const struct audio_port_config *srcConfig = NULL) const; + virtual sp<AudioPort> getAudioPort() const { return (AudioPort*) this; } virtual void toAudioPort(struct audio_port *port) const; @@ -462,6 +463,7 @@ protected: virtual void toAudioPortConfig(struct audio_port_config *dstConfig, const struct audio_port_config *srcConfig = NULL) const; + virtual sp<AudioPort> getAudioPort() const { return mProfile; } void toAudioPort(struct audio_port *port) const; audio_port_handle_t mId; @@ -506,6 +508,7 @@ protected: virtual void toAudioPortConfig(struct audio_port_config *dstConfig, const struct audio_port_config *srcConfig = NULL) const; + virtual sp<AudioPort> getAudioPort() const { return mProfile; } void toAudioPort(struct audio_port *port) const; }; |