diff options
author | Andy Hung <hunga@google.com> | 2014-08-08 15:52:38 -0700 |
---|---|---|
committer | Andy Hung <hunga@google.com> | 2014-08-08 15:52:38 -0700 |
commit | e3fdb6012905d593c9350958f4429d0d670adae4 (patch) | |
tree | dfa8326449c24b6c83c6935ff28a16f79daa8a7c /media/libstagefright/WAVExtractor.cpp | |
parent | 0912a5738d6baf2df7cd62e877240e3807b4b21f (diff) | |
download | frameworks_av-e3fdb6012905d593c9350958f4429d0d670adae4.zip frameworks_av-e3fdb6012905d593c9350958f4429d0d670adae4.tar.gz frameworks_av-e3fdb6012905d593c9350958f4429d0d670adae4.tar.bz2 |
Fix WAVExtractor to output full audio frames only
Fixes NuPlayer crash from MediaBuffers ending in partial audio frames.
Bug: 16881623
Change-Id: Ia80a9910f99245e645860c00ae85118cc85bef57
Diffstat (limited to 'media/libstagefright/WAVExtractor.cpp')
-rw-r--r-- | media/libstagefright/WAVExtractor.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/media/libstagefright/WAVExtractor.cpp b/media/libstagefright/WAVExtractor.cpp index 7124fd3..a4a651d 100644 --- a/media/libstagefright/WAVExtractor.cpp +++ b/media/libstagefright/WAVExtractor.cpp @@ -439,6 +439,10 @@ status_t WAVSource::read( maxBytesToRead = maxBytesAvailable; } + // read only integral amounts of audio unit frames. + const size_t inputUnitFrameSize = mNumChannels * mBitsPerSample / 8; + maxBytesToRead -= maxBytesToRead % inputUnitFrameSize; + if (mWaveFormat == WAVE_FORMAT_MSGSM) { // Microsoft packs 2 frames into 65 bytes, rather than using separate 33-byte frames, // so read multiples of 65, and use smaller buffers to account for ~10:1 expansion ratio |