Index: content/common/gpu/media/android_video_decode_accelerator.cc |
diff --git a/content/common/gpu/media/android_video_decode_accelerator.cc b/content/common/gpu/media/android_video_decode_accelerator.cc |
index 37ea2c771c0a6bb73f016a010a540b9a1a6a015a..1960dce32f7a99d6bc257d9fe34e67766a316bf8 100644 |
--- a/content/common/gpu/media/android_video_decode_accelerator.cc |
+++ b/content/common/gpu/media/android_video_decode_accelerator.cc |
@@ -618,6 +618,21 @@ void AndroidVideoDecodeAccelerator::SendDecodedFrameToClient( |
void AndroidVideoDecodeAccelerator::Decode( |
const media::BitstreamBuffer& bitstream_buffer) { |
+ // We use id = -1 as a special bitstream_buffer internally, which indicating |
Pawel Osciak
2016/02/19 07:48:44
This feels like an opportunity to remove the check
Owen Lin
2016/02/23 09:06:38
Done.
|
+ // flush the decoder. The client should not passing any id < 0 when call |
+ // Decode(). |
+ if (bitstream_buffer.id() < 0) { |
+ POST_ERROR(INVALID_ARGUMENT, |
+ "Invalid bistream_buffer, id: " << bitstream_buffer.id()); |
+ if (base::SharedMemory::IsHandleValid(bitstream_buffer.handle())) |
+ base::SharedMemory::CloseHandle(bitstream_buffer.handle()); |
+ return; |
+ } |
+ DecodeInternal(bitstream_buffer); |
+} |
+ |
+void AndroidVideoDecodeAccelerator::DecodeInternal( |
+ const media::BitstreamBuffer& bitstream_buffer) { |
DCHECK(thread_checker_.CalledOnValidThread()); |
if (bitstream_buffer.id() != -1 && bitstream_buffer.size() == 0) { |
base::MessageLoop::current()->PostTask( |
@@ -704,7 +719,7 @@ void AndroidVideoDecodeAccelerator::ReusePictureBuffer( |
void AndroidVideoDecodeAccelerator::Flush() { |
DCHECK(thread_checker_.CalledOnValidThread()); |
- Decode(media::BitstreamBuffer(-1, base::SharedMemoryHandle(), 0)); |
+ DecodeInternal(media::BitstreamBuffer(-1, base::SharedMemoryHandle(), 0)); |
} |
bool AndroidVideoDecodeAccelerator::ConfigureMediaCodec() { |