summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/codecs/aacdec/SoftAAC2.cpp
diff options
context:
space:
mode:
authorMarco Nelissen <marcone@google.com>2014-09-25 14:25:18 -0700
committerMarco Nelissen <marcone@google.com>2014-09-25 14:26:33 -0700
commit4edf384a512748b871f24e4c03afaa3c1151ca23 (patch)
tree2f2421c2a2cc19363ec4dc059dc88a8b6f8d3500 /media/libstagefright/codecs/aacdec/SoftAAC2.cpp
parentc0d17e349901c3ccf6d15b7dcdf7fa30139c9750 (diff)
downloadframeworks_av-4edf384a512748b871f24e4c03afaa3c1151ca23.zip
frameworks_av-4edf384a512748b871f24e4c03afaa3c1151ca23.tar.gz
frameworks_av-4edf384a512748b871f24e4c03afaa3c1151ca23.tar.bz2
Fix SoftAAC2 flush
If there were less than a full frame worth of samples in the ring buffer, then flush would loop forever trying to empty the ring buffer. Bug: 17646525 Change-Id: I68ec87352a91ce3a96d05e9b3f60a6e7975f9156
Diffstat (limited to 'media/libstagefright/codecs/aacdec/SoftAAC2.cpp')
-rw-r--r--media/libstagefright/codecs/aacdec/SoftAAC2.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/media/libstagefright/codecs/aacdec/SoftAAC2.cpp b/media/libstagefright/codecs/aacdec/SoftAAC2.cpp
index fb27dca..e701e9e 100644
--- a/media/libstagefright/codecs/aacdec/SoftAAC2.cpp
+++ b/media/libstagefright/codecs/aacdec/SoftAAC2.cpp
@@ -974,11 +974,15 @@ void SoftAAC2::onPortFlushCompleted(OMX_U32 portIndex) {
mDecodedSizes.clear();
mLastInHeader = NULL;
} else {
- while (outputDelayRingBufferSamplesAvailable() > 0) {
- int32_t ns = outputDelayRingBufferGetSamples(0,
- mStreamInfo->frameSize * mStreamInfo->numChannels);
- if (ns != mStreamInfo->frameSize * mStreamInfo->numChannels) {
+ int avail;
+ while ((avail = outputDelayRingBufferSamplesAvailable()) > 0) {
+ if (avail > mStreamInfo->frameSize * mStreamInfo->numChannels) {
+ avail = mStreamInfo->frameSize * mStreamInfo->numChannels;
+ }
+ int32_t ns = outputDelayRingBufferGetSamples(0, avail);
+ if (ns != avail) {
ALOGE("not a complete frame of samples available");
+ break;
}
mOutputBufferCount++;
}