Merge "fix AmrInputStream.read() hang"

am: 5b6a02eb8b

Change-Id: I7aff9043ec95d2f41e5d3301b01707f5dff4bef2
This commit is contained in:
Wonsik Kim
2017-10-03 21:18:10 +00:00
committed by android-build-merger

View File

@@ -30,7 +30,7 @@ import android.util.Log;
*/
public final class AmrInputStream extends InputStream {
private final static String TAG = "AmrInputStream";
// frame is 20 msec at 8.000 khz
private final static int SAMPLES_PER_FRAME = 8000 * 20 / 1000;
@@ -140,19 +140,15 @@ public final class AmrInputStream extends InputStream {
}
}
// now read encoded data from the encoder (blocking, since we just filled up the
// encoder's input with data it should be able to output at least one buffer)
while (true) {
int index = mCodec.dequeueOutputBuffer(mInfo, -1);
if (index >= 0) {
mBufIn = mInfo.size;
ByteBuffer out = mCodec.getOutputBuffer(index);
out.get(mBuf, 0 /* offset */, mBufIn /* length */);
mCodec.releaseOutputBuffer(index, false /* render */);
if ((mInfo.flags & MediaCodec.BUFFER_FLAG_END_OF_STREAM) != 0) {
mSawOutputEOS = true;
}
break;
// now read encoded data from the encoder
int index = mCodec.dequeueOutputBuffer(mInfo, 0);
if (index >= 0) {
mBufIn = mInfo.size;
ByteBuffer out = mCodec.getOutputBuffer(index);
out.get(mBuf, 0 /* offset */, mBufIn /* length */);
mCodec.releaseOutputBuffer(index, false /* render */);
if ((mInfo.flags & MediaCodec.BUFFER_FLAG_END_OF_STREAM) != 0) {
mSawOutputEOS = true;
}
}
}