From df4723ef3c43b3a0b2548908a4461db29b5649d2 Mon Sep 17 00:00:00 2001 From: Santosh Madhava Date: Wed, 16 Feb 2011 22:32:02 -0800 Subject: [PATCH] Fix for issue 3439595 : Java/JNI - Movide studio playback picks previous frames Change-Id: I0f9257a1bfb96c00acfdffa0f4f7f8188646c713 --- .../media/videoeditor/MediaArtistNativeHelper.java | 5 ++--- media/jni/mediaeditor/VideoEditorMain.cpp | 14 +++++++++----- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/media/java/android/media/videoeditor/MediaArtistNativeHelper.java b/media/java/android/media/videoeditor/MediaArtistNativeHelper.java index 8c78d6044d4af..ad2bf954543e5 100644 --- a/media/java/android/media/videoeditor/MediaArtistNativeHelper.java +++ b/media/java/android/media/videoeditor/MediaArtistNativeHelper.java @@ -3065,8 +3065,7 @@ class MediaArtistNativeHelper { * This function is responsible for stopping the preview */ long stopPreview() { - nativeStopPreview(); - return mPreviewProgress; + return nativeStopPreview(); } /** @@ -3999,7 +3998,7 @@ class MediaArtistNativeHelper { int framewidth, int frameheight, int surfacewidth, int surfaceheight, long timeMs) throws IllegalArgumentException, IllegalStateException, RuntimeException; - private native void nativeStopPreview(); + private native int nativeStopPreview(); private native int nativeGenerateAudioGraph(String pcmFilePath, String outGraphPath, int frameDuration, int channels, int sampleCount); diff --git a/media/jni/mediaeditor/VideoEditorMain.cpp b/media/jni/mediaeditor/VideoEditorMain.cpp index 1ba5beb348438..23081f868fcba 100755 --- a/media/jni/mediaeditor/VideoEditorMain.cpp +++ b/media/jni/mediaeditor/VideoEditorMain.cpp @@ -208,7 +208,7 @@ videoEditor_populateSettings( jobject object, jobject audioSettingObject); -static void videoEditor_stopPreview(JNIEnv* pEnv, +static int videoEditor_stopPreview(JNIEnv* pEnv, jobject thiz); static jobject @@ -283,8 +283,8 @@ static JNINativeMethod gManualEditMethods[] = { {"nativeRenderMediaItemPreviewFrame", "(Landroid/view/Surface;Ljava/lang/String;IIIIJ)I", (int *)videoEditor_renderMediaItemPreviewFrame }, - {"nativeStopPreview", "()V", - (void *)videoEditor_stopPreview }, + {"nativeStopPreview", "()I", + (int *)videoEditor_stopPreview }, {"stopEncoding", "()V", (void *)videoEditor_stopEncoding }, {"release", "()V", @@ -482,11 +482,13 @@ static void jniPreviewProgressCallback (void* cookie, M4OSA_UInt32 msgType, pContext->pVM->DetachCurrentThread(); } -static void videoEditor_stopPreview(JNIEnv* pEnv, +static int videoEditor_stopPreview(JNIEnv* pEnv, jobject thiz) { ManualEditContext* pContext = M4OSA_NULL; bool needToBeLoaded = true; + M4OSA_UInt32 lastProgressTimeMs = 0; + // Get the context. pContext = (ManualEditContext*)videoEditClasses_getContext(&needToBeLoaded, pEnv, thiz); @@ -495,12 +497,14 @@ static void videoEditor_stopPreview(JNIEnv* pEnv, videoEditJava_checkAndThrowIllegalStateException(&needToBeLoaded, pEnv, (M4OSA_NULL == pContext), "not initialized"); - pContext->mPreviewController->stopPreview(); + lastProgressTimeMs = pContext->mPreviewController->stopPreview(); if (pContext->mOverlayFileName != NULL) { M4OSA_free((M4OSA_MemAddr32)pContext->mOverlayFileName); pContext->mOverlayFileName = NULL; } + + return lastProgressTimeMs; } static void videoEditor_clearSurface(JNIEnv* pEnv,