Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cd7f0d7f authored by Gloria Wang's avatar Gloria Wang Committed by Android (Google) Code Review
Browse files

Merge "To support for switching from a non-null surface/ surface texture to a...

Merge "To support for switching from a non-null surface/ surface texture to a null one, and vice versa. Fix for bug 5137445."
parents cbeb69eb 91784c99
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -607,13 +607,13 @@ public class MediaPlayer

    /**
     * Sets the {@link SurfaceHolder} to use for displaying the video
     * portion of the media.  A surface must be set if a display is
     * needed.  Not calling this method when playing back a video will
     * result in only the audio track being played.
     * portion of the media.
     *
     * Either a surface holder or surface must be set if a display or video sink
     * is needed.  Not calling this method or {@link #setTexture(SurfaceTexture)}
     * when playing back a video will result in only the audio track being played.
     * A null surface holder or surface will result in only the audio track being
     * played.
     *
     * @param sh the SurfaceHolder to use for video display
     */
@@ -634,6 +634,7 @@ public class MediaPlayer
     * the media. This is similar to {@link #setDisplay(SurfaceHolder)}, but does not
     * support {@link #setScreenOnWhilePlaying(boolean)} or {@link #updateSurfaceScreenOn()}.
     * Setting a Surface will un-set any Surface or SurfaceHolder that was previously set.
     * A null surface will result in only the audio track being played.
     *
     * @param surface The {@link Surface} to be used for the video portion of the media.
     *
+4 −3
Original line number Diff line number Diff line
@@ -247,9 +247,8 @@ android_media_MediaPlayer_setDataSourceFD(JNIEnv *env, jobject thiz, jobject fil
static void setVideoSurfaceOrSurfaceTexture(
        const sp<MediaPlayer>& mp, JNIEnv *env, jobject thiz, const char *prefix)
{
    // The Java MediaPlayer class makes sure that at most one of mSurface and
    // mParcelSurfaceTexture is non-null.  But just in case, we give priority to
    // mSurface over mParcelSurfaceTexture.
    // Both mSurface and mParcelSurfaceTexture could be null.
    // We give priority to mSurface over mParcelSurfaceTexture.
    jobject surface = env->GetObjectField(thiz, fields.surface);
    if (surface != NULL) {
        sp<Surface> native_surface(get_surface(env, surface));
@@ -263,6 +262,8 @@ static void setVideoSurfaceOrSurfaceTexture(
                    ParcelSurfaceTexture_getISurfaceTexture(env, parcelSurfaceTexture));
            LOGV("%s: texture=%p", prefix, native_surfaceTexture.get());
            mp->setVideoSurfaceTexture(native_surfaceTexture);
        } else {
            mp->setVideoSurfaceTexture(NULL);
        }
    }
}
+4 −1
Original line number Diff line number Diff line
@@ -1157,6 +1157,8 @@ void AwesomePlayer::setSurfaceTexture(const sp<ISurfaceTexture> &surfaceTexture)
    mSurface.clear();
    if (surfaceTexture != NULL) {
        setNativeWindow_l(new SurfaceTextureClient(surfaceTexture));
    } else {
        setNativeWindow_l(NULL);
    }
}

@@ -1769,7 +1771,8 @@ void AwesomePlayer::onVideoEvent() {
        }
    }

    if (mVideoRendererIsPreview || mVideoRenderer == NULL) {
    if ((mNativeWindow != NULL)
            && (mVideoRendererIsPreview || mVideoRenderer == NULL)) {
        mVideoRendererIsPreview = false;

        initRenderer_l();