diff options
author | Gloria Wang <gwang@google.com> | 2011-08-09 15:29:34 -0700 |
---|---|---|
committer | Gloria Wang <gwang@google.com> | 2011-08-09 15:31:30 -0700 |
commit | 91784c996f95483e3041169215c0d6635e27ffcc (patch) | |
tree | 4ae8badfa2529f83e8747e687b971bdc79012b32 /media | |
parent | 1467ec343309821b215cb3e049a6746d07030c07 (diff) | |
download | frameworks_base-91784c996f95483e3041169215c0d6635e27ffcc.zip frameworks_base-91784c996f95483e3041169215c0d6635e27ffcc.tar.gz frameworks_base-91784c996f95483e3041169215c0d6635e27ffcc.tar.bz2 |
To support for switching from a non-null surface/ surface texture to
a null one, and vice versa.
Fix for bug 5137445.
Change-Id: Ifca2997f8ad27a843abbdaa7e89a56329bc40fde
Diffstat (limited to 'media')
-rw-r--r-- | media/java/android/media/MediaPlayer.java | 7 | ||||
-rw-r--r-- | media/jni/android_media_MediaPlayer.cpp | 7 | ||||
-rw-r--r-- | media/libstagefright/AwesomePlayer.cpp | 5 |
3 files changed, 12 insertions, 7 deletions
diff --git a/media/java/android/media/MediaPlayer.java b/media/java/android/media/MediaPlayer.java index 1bacdbb..434ef14 100644 --- a/media/java/android/media/MediaPlayer.java +++ b/media/java/android/media/MediaPlayer.java @@ -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. * diff --git a/media/jni/android_media_MediaPlayer.cpp b/media/jni/android_media_MediaPlayer.cpp index 5663683..9090daa 100644 --- a/media/jni/android_media_MediaPlayer.cpp +++ b/media/jni/android_media_MediaPlayer.cpp @@ -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); } } } diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp index 67f6c79..9c9bc2d 100644 --- a/media/libstagefright/AwesomePlayer.cpp +++ b/media/libstagefright/AwesomePlayer.cpp @@ -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(); |