summaryrefslogtreecommitdiffstats
path: root/media/libmedia/mediaplayer.cpp
diff options
context:
space:
mode:
authorJamie Gennis <jgennis@google.com>2011-10-28 02:53:20 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2011-10-28 02:53:20 +0000
commit4b8bb4ee7d1d64dc1cd5478a3772f97e4a4a00d7 (patch)
tree1c9e328d23cb6328d2a2531c7215599d2ad3d78b /media/libmedia/mediaplayer.cpp
parentc1aa1e96d1310e8b8f9962f924247aa35a61e3c3 (diff)
parent262620399c228b3b201c2c4b39c87508d3047d74 (diff)
downloadframeworks_av-4b8bb4ee7d1d64dc1cd5478a3772f97e4a4a00d7.zip
frameworks_av-4b8bb4ee7d1d64dc1cd5478a3772f97e4a4a00d7.tar.gz
frameworks_av-4b8bb4ee7d1d64dc1cd5478a3772f97e4a4a00d7.tar.bz2
am fc9592f8: am 08479cee: Merge "Stagefright: ANW::connect in MediaPlayerService" into ics-mr0
* commit 'fc9592f8a5f2f75207e5e532655ac294eb2b334b': Stagefright: ANW::connect in MediaPlayerService
Diffstat (limited to 'media/libmedia/mediaplayer.cpp')
-rw-r--r--media/libmedia/mediaplayer.cpp98
1 files changed, 2 insertions, 96 deletions
diff --git a/media/libmedia/mediaplayer.cpp b/media/libmedia/mediaplayer.cpp
index e4010be..e365ca1 100644
--- a/media/libmedia/mediaplayer.cpp
+++ b/media/libmedia/mediaplayer.cpp
@@ -86,8 +86,6 @@ void MediaPlayer::disconnect()
if (p != 0) {
p->disconnect();
}
-
- disconnectNativeWindow();
}
// always call with lock held
@@ -221,63 +219,12 @@ status_t MediaPlayer::getMetadata(bool update_only, bool apply_filter, Parcel *m
return mPlayer->getMetadata(update_only, apply_filter, metadata);
}
-void MediaPlayer::disconnectNativeWindow() {
- if (mConnectedWindow != NULL) {
- status_t err = native_window_api_disconnect(mConnectedWindow.get(),
- NATIVE_WINDOW_API_MEDIA);
-
- if (err != OK) {
- LOGW("native_window_api_disconnect returned an error: %s (%d)",
- strerror(-err), err);
- }
- }
- mConnectedWindow.clear();
-}
-
status_t MediaPlayer::setVideoSurface(const sp<Surface>& surface)
{
ALOGV("setVideoSurface");
Mutex::Autolock _l(mLock);
if (mPlayer == 0) return NO_INIT;
-
- sp<IBinder> binder(surface == NULL ? NULL : surface->asBinder());
- if (mConnectedWindowBinder == binder) {
- return OK;
- }
-
- if (surface != NULL) {
- status_t err = native_window_api_connect(surface.get(),
- NATIVE_WINDOW_API_MEDIA);
-
- if (err != OK) {
- LOGE("setVideoSurface failed: %d", err);
- // Note that we must do the reset before disconnecting from the ANW.
- // Otherwise queue/dequeue calls could be made on the disconnected
- // ANW, which may result in errors.
- reset_l();
-
- disconnectNativeWindow();
-
- return err;
- }
- }
-
- // Note that we must set the player's new surface before disconnecting the
- // old one. Otherwise queue/dequeue calls could be made on the disconnected
- // ANW, which may result in errors.
- status_t err = mPlayer->setVideoSurface(surface);
-
- disconnectNativeWindow();
-
- mConnectedWindow = surface;
-
- if (err == OK) {
- mConnectedWindowBinder = binder;
- } else {
- disconnectNativeWindow();
- }
-
- return err;
+ return mPlayer->setVideoSurface(surface);
}
status_t MediaPlayer::setVideoSurfaceTexture(
@@ -286,48 +233,7 @@ status_t MediaPlayer::setVideoSurfaceTexture(
ALOGV("setVideoSurfaceTexture");
Mutex::Autolock _l(mLock);
if (mPlayer == 0) return NO_INIT;
-
- sp<IBinder> binder(surfaceTexture == NULL ? NULL :
- surfaceTexture->asBinder());
- if (mConnectedWindowBinder == binder) {
- return OK;
- }
-
- sp<ANativeWindow> anw;
- if (surfaceTexture != NULL) {
- anw = new SurfaceTextureClient(surfaceTexture);
- status_t err = native_window_api_connect(anw.get(),
- NATIVE_WINDOW_API_MEDIA);
-
- if (err != OK) {
- LOGE("setVideoSurfaceTexture failed: %d", err);
- // Note that we must do the reset before disconnecting from the ANW.
- // Otherwise queue/dequeue calls could be made on the disconnected
- // ANW, which may result in errors.
- reset_l();
-
- disconnectNativeWindow();
-
- return err;
- }
- }
-
- // Note that we must set the player's new SurfaceTexture before
- // disconnecting the old one. Otherwise queue/dequeue calls could be made
- // on the disconnected ANW, which may result in errors.
- status_t err = mPlayer->setVideoSurfaceTexture(surfaceTexture);
-
- disconnectNativeWindow();
-
- mConnectedWindow = anw;
-
- if (err == OK) {
- mConnectedWindowBinder = binder;
- } else {
- disconnectNativeWindow();
- }
-
- return err;
+ return mPlayer->setVideoSurfaceTexture(surfaceTexture);
}
// must call with lock held