Android MediaCodecVideoDecoder: Cleanup to prepare for texture liftime management

This CL should not change the behaviour of the decoder. The purpose is to prepare for lifetime management of textures received from the SurfaceTexture. The main change is to only use exceptions for error signaling in MediaCodecVideoDecoder.dequeueOutputBuffer() and MediaCodecVideoDecoder.releaseOutputBuffer(), not both exceptions and error return values.

BUG=webrtc:4993
R=perkj@webrtc.org

Review URL: https://codereview.webrtc.org/1383983003 .

Cr-Commit-Position: refs/heads/master@{#10148}
diff --git a/talk/app/webrtc/java/jni/androidmediadecoder_jni.cc b/talk/app/webrtc/java/jni/androidmediadecoder_jni.cc
index 4f7445e..a5a25f0 100644
--- a/talk/app/webrtc/java/jni/androidmediadecoder_jni.cc
+++ b/talk/app/webrtc/java/jni/androidmediadecoder_jni.cc
@@ -37,6 +37,7 @@
 #include "webrtc/base/logging.h"
 #include "webrtc/base/scoped_ref_ptr.h"
 #include "webrtc/base/thread.h"
+#include "webrtc/base/timeutils.h"
 #include "webrtc/common_video/interface/i420_buffer_pool.h"
 #include "webrtc/modules/video_coding/codecs/interface/video_codec_interface.h"
 #include "webrtc/system_wrappers/interface/logcat_trace_context.h"
@@ -198,7 +199,7 @@
       jni, *j_media_codec_video_decoder_class_, "dequeueOutputBuffer",
       "(I)Lorg/webrtc/MediaCodecVideoDecoder$DecoderOutputBufferInfo;");
   j_release_output_buffer_method_ = GetMethodID(
-      jni, *j_media_codec_video_decoder_class_, "releaseOutputBuffer", "(I)Z");
+      jni, *j_media_codec_video_decoder_class_, "releaseOutputBuffer", "(I)V");
 
   j_input_buffers_field_ = GetFieldID(
       jni, *j_media_codec_video_decoder_class_,
@@ -572,16 +573,13 @@
   // Extract output buffer info from Java DecoderOutputBufferInfo.
   int output_buffer_index =
       GetIntField(jni, j_decoder_output_buffer_info, j_info_index_field_);
-  if (output_buffer_index < 0) {
-    ALOGE("dequeueOutputBuffer error : %d", output_buffer_index);
-    return false;
-  }
+  RTC_CHECK_GE(output_buffer_index, 0);
   int output_buffer_offset =
       GetIntField(jni, j_decoder_output_buffer_info, j_info_offset_field_);
   int output_buffer_size =
       GetIntField(jni, j_decoder_output_buffer_info, j_info_size_field_);
   long output_timestamps_ms = GetLongField(jni, j_decoder_output_buffer_info,
-      j_info_presentation_timestamp_us_field_) / 1000;
+      j_info_presentation_timestamp_us_field_) / rtc::kNumMicrosecsPerMillisec;
   if (CheckException(jni)) {
     return false;
   }
@@ -677,11 +675,11 @@
       color_format, output_timestamps_ms, frame_decoding_time_ms);
 
   // Return output buffer back to codec.
-  bool success = jni->CallBooleanMethod(
+  jni->CallVoidMethod(
       *j_media_codec_video_decoder_,
       j_release_output_buffer_method_,
       output_buffer_index);
-  if (CheckException(jni) || !success) {
+  if (CheckException(jni)) {
     ALOGE("releaseOutputBuffer error");
     return false;
   }