diff options
author | Eric Laurent <elaurent@google.com> | 2010-09-24 11:52:04 -0700 |
---|---|---|
committer | Eric Laurent <elaurent@google.com> | 2010-09-24 15:24:54 -0700 |
commit | 0fa449cc475580d995e9d56756c3da5507d2b6f6 (patch) | |
tree | 1e344eefa5847ad1e8ea3fc508e0d63ba5334c13 /media/libmedia | |
parent | 76e2c7be04aeff55f3e6a473ff1cd6d9ec2d620c (diff) | |
download | frameworks_av-0fa449cc475580d995e9d56756c3da5507d2b6f6.zip frameworks_av-0fa449cc475580d995e9d56756c3da5507d2b6f6.tar.gz frameworks_av-0fa449cc475580d995e9d56756c3da5507d2b6f6.tar.bz2 |
Fix error in AudioEffect command status reporting.
AudioEffect::command() should not interpret the status
returned in pReplyData unless the command is ENABLE or
DISABLE.
Also fixed:
- bug in Visualizer::getWAveForm() status reporting.
- wrong initialization value for capture buffer in visualizer engine.
Change-Id: I60fb0011f9dba96ee74661dec1e8ef441edcaf35
Diffstat (limited to 'media/libmedia')
-rw-r--r-- | media/libmedia/AudioEffect.cpp | 26 | ||||
-rw-r--r-- | media/libmedia/Visualizer.cpp | 6 |
2 files changed, 21 insertions, 11 deletions
diff --git a/media/libmedia/AudioEffect.cpp b/media/libmedia/AudioEffect.cpp index 0f3e245..88b8c86 100644 --- a/media/libmedia/AudioEffect.cpp +++ b/media/libmedia/AudioEffect.cpp @@ -228,24 +228,32 @@ status_t AudioEffect::command(uint32_t cmdCode, void *replyData) { if (mStatus != NO_ERROR && mStatus != ALREADY_EXISTS) { + LOGV("command() bad status %d", mStatus); return INVALID_OPERATION; } - status_t status = mIEffect->command(cmdCode, cmdSize, cmdData, replySize, replyData); - if (status != NO_ERROR) { - return status; + if ((cmdCode == EFFECT_CMD_ENABLE || cmdCode == EFFECT_CMD_DISABLE) && + (replySize == NULL || *replySize != sizeof(status_t) || replyData == NULL)) { + return BAD_VALUE; } - status = *(status_t *)replyData; + + status_t status = mIEffect->command(cmdCode, cmdSize, cmdData, replySize, replyData); if (status != NO_ERROR) { return status; } - if (cmdCode == EFFECT_CMD_ENABLE) { - android_atomic_or(1, &mEnabled); - } - if (cmdCode == EFFECT_CMD_DISABLE) { - android_atomic_and(~1, &mEnabled); + if (cmdCode == EFFECT_CMD_ENABLE || cmdCode == EFFECT_CMD_DISABLE) { + status = *(status_t *)replyData; + if (status != NO_ERROR) { + return status; + } + if (cmdCode == EFFECT_CMD_ENABLE) { + android_atomic_or(1, &mEnabled); + } else { + android_atomic_and(~1, &mEnabled); + } } + return status; } diff --git a/media/libmedia/Visualizer.cpp b/media/libmedia/Visualizer.cpp index 39552b6..68f2e9b 100644 --- a/media/libmedia/Visualizer.cpp +++ b/media/libmedia/Visualizer.cpp @@ -169,11 +169,13 @@ status_t Visualizer::getWaveForm(uint8_t *waveform) status_t status = NO_ERROR; if (mEnabled) { uint32_t replySize = mCaptureSize; - status_t status = command(VISU_CMD_CAPTURE, 0, NULL, &replySize, waveform); + status = command(VISU_CMD_CAPTURE, 0, NULL, &replySize, waveform); + LOGV("getWaveForm() command returned %d", status); if (replySize == 0) { status = NOT_ENOUGH_DATA; } } else { + LOGV("getWaveForm() disabled"); memset(waveform, 0x80, mCaptureSize); } return status; @@ -191,7 +193,7 @@ status_t Visualizer::getFft(uint8_t *fft) status_t status = NO_ERROR; if (mEnabled) { uint8_t buf[mCaptureSize]; - status_t status = getWaveForm(buf); + status = getWaveForm(buf); if (status == NO_ERROR) { status = doFft(fft, buf); } |