Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(293)

Side by Side Diff: media/base/android/media_codec_bridge.cc

Issue 215783002: Fix an issue that audio and video may run out of sync (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressing acolwell's comments Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/base/android/media_codec_bridge.h ('k') | media/base/android/media_decoder_job.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/base/android/media_codec_bridge.h" 5 #include "media/base/android/media_codec_bridge.h"
6 6
7 #include <jni.h> 7 #include <jni.h>
8 #include <string> 8 #include <string>
9 9
10 #include "base/android/build_info.h" 10 #include "base/android/build_info.h"
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 break; 586 break;
587 } 587 }
588 default: 588 default:
589 LOG(ERROR) << "Invalid header encountered for codec: " 589 LOG(ERROR) << "Invalid header encountered for codec: "
590 << AudioCodecToAndroidMimeType(codec); 590 << AudioCodecToAndroidMimeType(codec);
591 return false; 591 return false;
592 } 592 }
593 return true; 593 return true;
594 } 594 }
595 595
596 void AudioCodecBridge::PlayOutputBuffer(int index, size_t size) { 596 int64 AudioCodecBridge::PlayOutputBuffer(int index, size_t size) {
597 DCHECK_LE(0, index); 597 DCHECK_LE(0, index);
598 int numBytes = base::checked_cast<int>(size); 598 int numBytes = base::checked_cast<int>(size);
599 JNIEnv* env = AttachCurrentThread(); 599 JNIEnv* env = AttachCurrentThread();
600 ScopedJavaLocalRef<jobject> buf = 600 ScopedJavaLocalRef<jobject> buf =
601 Java_MediaCodecBridge_getOutputBuffer(env, media_codec(), index); 601 Java_MediaCodecBridge_getOutputBuffer(env, media_codec(), index);
602 uint8* buffer = static_cast<uint8*>(env->GetDirectBufferAddress(buf.obj())); 602 uint8* buffer = static_cast<uint8*>(env->GetDirectBufferAddress(buf.obj()));
603 603
604 ScopedJavaLocalRef<jbyteArray> byte_array = 604 ScopedJavaLocalRef<jbyteArray> byte_array =
605 base::android::ToJavaByteArray(env, buffer, numBytes); 605 base::android::ToJavaByteArray(env, buffer, numBytes);
606 Java_MediaCodecBridge_playOutputBuffer(env, media_codec(), byte_array.obj()); 606 return Java_MediaCodecBridge_playOutputBuffer(
607 env, media_codec(), byte_array.obj());
607 } 608 }
608 609
609 void AudioCodecBridge::SetVolume(double volume) { 610 void AudioCodecBridge::SetVolume(double volume) {
610 JNIEnv* env = AttachCurrentThread(); 611 JNIEnv* env = AttachCurrentThread();
611 Java_MediaCodecBridge_setVolume(env, media_codec(), volume); 612 Java_MediaCodecBridge_setVolume(env, media_codec(), volume);
612 } 613 }
613 614
614 // static 615 // static
615 AudioCodecBridge* AudioCodecBridge::Create(const AudioCodec& codec) { 616 AudioCodecBridge* AudioCodecBridge::Create(const AudioCodec& codec) {
616 if (!MediaCodecBridge::IsAvailable()) 617 if (!MediaCodecBridge::IsAvailable())
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 void VideoCodecBridge::RequestKeyFrameSoon() { 726 void VideoCodecBridge::RequestKeyFrameSoon() {
726 JNIEnv* env = AttachCurrentThread(); 727 JNIEnv* env = AttachCurrentThread();
727 Java_MediaCodecBridge_requestKeyFrameSoon(env, media_codec()); 728 Java_MediaCodecBridge_requestKeyFrameSoon(env, media_codec());
728 } 729 }
729 730
730 bool MediaCodecBridge::RegisterMediaCodecBridge(JNIEnv* env) { 731 bool MediaCodecBridge::RegisterMediaCodecBridge(JNIEnv* env) {
731 return RegisterNativesImpl(env); 732 return RegisterNativesImpl(env);
732 } 733 }
733 734
734 } // namespace media 735 } // namespace media
OLDNEW
« no previous file with comments | « media/base/android/media_codec_bridge.h ('k') | media/base/android/media_decoder_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698