summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2015-06-09 17:19:44 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-06-09 17:22:26 +0000
commit26f9a1c4c14b0f7da8b0d60ffcecbf5e221d15c5 (patch)
tree1f1070dfe6e084d48abd77b01e3685ae8503cf08 /src
parent3a0f65a96a56f18954088bcb43a7b0a57efe2bc0 (diff)
parentaa08cb01d58f1da2d0a2b208aed3bf1730f8f63d (diff)
downloadandroid_frameworks_wilhelm-26f9a1c4c14b0f7da8b0d60ffcecbf5e221d15c5.tar.gz
android_frameworks_wilhelm-26f9a1c4c14b0f7da8b0d60ffcecbf5e221d15c5.tar.bz2
android_frameworks_wilhelm-26f9a1c4c14b0f7da8b0d60ffcecbf5e221d15c5.zip
Merge "Use only strong references to AudioEffect" into mnc-dev
Diffstat (limited to 'src')
-rw-r--r--src/android/AudioPlayer_to_android.cpp3
-rw-r--r--src/android/android_Effect.cpp16
-rw-r--r--src/itf/IAndroidEffect.cpp6
-rw-r--r--src/itfstruct.h2
4 files changed, 12 insertions, 15 deletions
diff --git a/src/android/AudioPlayer_to_android.cpp b/src/android/AudioPlayer_to_android.cpp
index 5e3b94f..1771b5f 100644
--- a/src/android/AudioPlayer_to_android.cpp
+++ b/src/android/AudioPlayer_to_android.cpp
@@ -27,7 +27,8 @@
#include <system/audio.h>
-template class android::KeyedVector<SLuint32, android::AudioEffect* > ;
+template class android::KeyedVector<SLuint32,
+ android::sp<android::AudioEffect> > ;
#define KEY_STREAM_TYPE_PARAMSIZE sizeof(SLint32)
diff --git a/src/android/android_Effect.cpp b/src/android/android_Effect.cpp
index ab3bbe3..090a211 100644
--- a/src/android/android_Effect.cpp
+++ b/src/android/android_Effect.cpp
@@ -528,8 +528,9 @@ SLresult android_fxSend_attachToAux(CAudioPlayer* ap, SLInterfaceID pUuid, SLboo
return SL_RESULT_PARAMETER_INVALID;
}
- android::AudioEffect* pFx = outputMix->mAndroidEffect.mEffects->valueAt(index);
- if (NULL == pFx) {
+ android::sp<android::AudioEffect> pFx =
+ outputMix->mAndroidEffect.mEffects->valueAt(index);
+ if (pFx == 0) {
return SL_RESULT_RESOURCE_ERROR;
}
if (android::NO_ERROR == android_fxSend_attach( ap, (bool) attach, pFx, sendLevel) ) {
@@ -766,7 +767,7 @@ SLresult android_genericFx_createEffect(IAndroidEffect* iae, SLInterfaceID pUuid
}
// create new effect
- android::AudioEffect* pFx = new android::AudioEffect(
+ android::sp<android::AudioEffect> pFx = new android::AudioEffect(
NULL, // not using type to create effect
android::String16(),
(const effect_uuid_t*)pUuid,
@@ -780,7 +781,6 @@ SLresult android_genericFx_createEffect(IAndroidEffect* iae, SLInterfaceID pUuid
android::status_t status = pFx->initCheck();
if (android::NO_ERROR != status) {
SL_LOGE("AudioEffect initCheck() returned %d, effect will not be stored", status);
- delete pFx;
result = SL_RESULT_RESOURCE_ERROR;
} else {
SL_LOGV("AudioEffect successfully created on session %d", sessionId);
@@ -799,8 +799,6 @@ SLresult android_genericFx_releaseEffect(IAndroidEffect* iae, SLInterfaceID pUui
if (0 > index) {
return SL_RESULT_PARAMETER_INVALID;
} else {
- android::AudioEffect* pFx = iae->mEffects->valueAt(index);
- delete pFx;
iae->mEffects->removeItem(index);
return SL_RESULT_SUCCESS;
}
@@ -815,7 +813,7 @@ SLresult android_genericFx_setEnabled(IAndroidEffect* iae, SLInterfaceID pUuid,
if (0 > index) {
return SL_RESULT_PARAMETER_INVALID;
} else {
- android::AudioEffect* pFx = iae->mEffects->valueAt(index);
+ android::sp<android::AudioEffect> pFx = iae->mEffects->valueAt(index);
android::status_t status = pFx->setEnabled(SL_BOOLEAN_TRUE == enabled);
return android_fx_statusToResult(status);
}
@@ -830,7 +828,7 @@ SLresult android_genericFx_isEnabled(IAndroidEffect* iae, SLInterfaceID pUuid, S
if (0 > index) {
return SL_RESULT_PARAMETER_INVALID;
} else {
- android::AudioEffect* pFx = iae->mEffects->valueAt(index);
+ android::sp<android::AudioEffect> pFx = iae->mEffects->valueAt(index);
*pEnabled = (SLboolean) pFx->getEnabled();
return SL_RESULT_SUCCESS;
}
@@ -847,7 +845,7 @@ SLresult android_genericFx_sendCommand(IAndroidEffect* iae, SLInterfaceID pUuid,
if (0 > index) {
return SL_RESULT_PARAMETER_INVALID;
} else {
- android::AudioEffect* pFx = iae->mEffects->valueAt(index);
+ android::sp<android::AudioEffect> pFx = iae->mEffects->valueAt(index);
android::status_t status = pFx->command(
(uint32_t) command,
(uint32_t) commandSize,
diff --git a/src/itf/IAndroidEffect.cpp b/src/itf/IAndroidEffect.cpp
index f34cabd..8e5ab7c 100644
--- a/src/itf/IAndroidEffect.cpp
+++ b/src/itf/IAndroidEffect.cpp
@@ -108,7 +108,8 @@ void IAndroidEffect_init(void *self)
{
IAndroidEffect *thiz = (IAndroidEffect *) self;
thiz->mItf = &IAndroidEffect_Itf;
- thiz->mEffects = new android::KeyedVector<SLuint32, android::AudioEffect* >();
+ thiz->mEffects =
+ new android::KeyedVector<SLuint32, android::sp<android::AudioEffect> >();
}
void IAndroidEffect_deinit(void *self)
@@ -116,9 +117,6 @@ void IAndroidEffect_deinit(void *self)
IAndroidEffect *thiz = (IAndroidEffect *) self;
if (NULL != thiz->mEffects) {
if (!thiz->mEffects->isEmpty()) {
- for (size_t i = 0 ; i < thiz->mEffects->size() ; i++) {
- delete thiz->mEffects->valueAt(i);
- }
thiz->mEffects->clear();
}
delete thiz->mEffects;
diff --git a/src/itfstruct.h b/src/itfstruct.h
index 65223b1..825e894 100644
--- a/src/itfstruct.h
+++ b/src/itfstruct.h
@@ -640,7 +640,7 @@ typedef struct {
typedef struct {
const struct SLAndroidEffectItf_ *mItf;
IObject *mThis;
- android::KeyedVector<SLuint32, android::AudioEffect* > *mEffects;
+ android::KeyedVector<SLuint32, android::sp<android::AudioEffect> > *mEffects;
} IAndroidEffect;
typedef struct {