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

Commit 69b8d69a authored by Andreas Huber's avatar Andreas Huber
Browse files

Squashed commit of the following:

commit 0d5694ba2d399dd0869532a4d6256448185a1be0
Author: Andreas Huber <andih@google.com>
Date:   Fri Oct 29 11:59:23 2010 -0700

    suspend() and resume() methods on VideoView are back but don't do anything.

    They need to be back because they were public before.

    Change-Id: Iddfd1021ffcf341f26e8d55ba761fd33701e2425

commit 16192891ed7d349ee97e47d1729d20a2d0d247b8
Author: Andreas Huber <andih@google.com>
Date:   Fri Oct 29 11:47:05 2010 -0700

    Revert "New API on VideoView widget to suspend/resume a session. Do not release the MediaPlayer client for video suspending/resuming."

    This reverts commit 2e1818a4.

    Conflicts:

    	api/current.xml

    Change-Id: I68dd1d05871044faf3f832d0838aa40bc7f890e5

commit 8f934dc1a3ae4e60f0790fcf97671e063fa20fad
Author: Andreas Huber <andih@google.com>
Date:   Fri Oct 29 11:44:16 2010 -0700

    Revert "Release mediaplayer if the current state is not suspending. Fix for bug 2480093."

    This reverts commit efb882cf.

commit f2ed03550887986f39d36b5dabcd9e919949c7cf
Author: Andreas Huber <andih@google.com>
Date:   Fri Oct 29 11:44:08 2010 -0700

    Revert "Release MediaPlayer if suspend() returns false."

    This reverts commit 047212fd.

commit 441ecce678bd24e9660a72c8627b5bd94433ff8b
Author: Andreas Huber <andih@google.com>
Date:   Fri Oct 29 11:40:46 2010 -0700

    manually.

    Change-Id: I4fdd43c9f7c8b3eedddb31a196da4984e1c58e87

Change-Id: I60d4b10e7a9e4ed8d9a796f1711618f557eb6e89
parent 7b9652b6
Loading
Loading
Loading
Loading
+5 −43
Original line number Diff line number Diff line
@@ -62,9 +62,6 @@ public class VideoView extends SurfaceView implements MediaPlayerControl {
    private static final int STATE_PLAYING            = 3;
    private static final int STATE_PAUSED             = 4;
    private static final int STATE_PLAYBACK_COMPLETED = 5;
    private static final int STATE_SUSPEND            = 6;
    private static final int STATE_RESUME             = 7;
    private static final int STATE_SUSPEND_UNSUPPORTED = 8;

    // mCurrentState is a VideoView object's current state.
    // mTargetState is the state that a method caller intends to reach.
@@ -90,7 +87,6 @@ public class VideoView extends SurfaceView implements MediaPlayerControl {
    private boolean     mCanPause;
    private boolean     mCanSeekBack;
    private boolean     mCanSeekForward;
    private int         mStateWhenSuspended;  //state before calling suspend()

    public VideoView(Context context) {
        super(context);
@@ -470,25 +466,16 @@ public class VideoView extends SurfaceView implements MediaPlayerControl {
        public void surfaceCreated(SurfaceHolder holder)
        {
            mSurfaceHolder = holder;
            //resume() was called before surfaceCreated()
            if (mMediaPlayer != null && mCurrentState == STATE_SUSPEND
                   && mTargetState == STATE_RESUME) {
                mMediaPlayer.setDisplay(mSurfaceHolder);
                resume();
            } else {
            openVideo();
        }
        }

        public void surfaceDestroyed(SurfaceHolder holder)
        {
            // after we return from this we can't use the surface any more
            mSurfaceHolder = null;
            if (mMediaController != null) mMediaController.hide();
            if (mCurrentState != STATE_SUSPEND) {
            release(true);
        }
        }
    };

    /*
@@ -581,37 +568,12 @@ public class VideoView extends SurfaceView implements MediaPlayerControl {
    }

    public void suspend() {
        if (isInPlaybackState()) {
            if (mMediaPlayer.suspend()) {
                mStateWhenSuspended = mCurrentState;
                mCurrentState = STATE_SUSPEND;
                mTargetState = STATE_SUSPEND;
            } else {
        release(false);
                mCurrentState = STATE_SUSPEND_UNSUPPORTED;
                Log.w(TAG, "Unable to suspend video. Release MediaPlayer.");
            }
        }
    }

    public void resume() {
        if (mSurfaceHolder == null && mCurrentState == STATE_SUSPEND){
            mTargetState = STATE_RESUME;
            return;
        }
        if (mMediaPlayer != null && mCurrentState == STATE_SUSPEND) {
            if (mMediaPlayer.resume()) {
                mCurrentState = mStateWhenSuspended;
                mTargetState = mStateWhenSuspended;
            } else {
                Log.w(TAG, "Unable to resume video");
            }
            return;
        }
        if (mCurrentState == STATE_SUSPEND_UNSUPPORTED) {
        openVideo();
    }
    }

    // cache duration as mDuration for faster access
    public int getDuration() {
+0 −2
Original line number Diff line number Diff line
@@ -48,8 +48,6 @@ public:
    virtual status_t        setAudioStreamType(int type) = 0;
    virtual status_t        setLooping(int loop) = 0;
    virtual status_t        setVolume(float leftVolume, float rightVolume) = 0;
    virtual status_t        suspend() = 0;
    virtual status_t        resume() = 0;
    virtual status_t        setAuxEffectSendLevel(float level) = 0;
    virtual status_t        attachAuxEffect(int effectId) = 0;

+0 −2
Original line number Diff line number Diff line
@@ -120,8 +120,6 @@ public:
    virtual status_t    reset() = 0;
    virtual status_t    setLooping(int loop) = 0;
    virtual player_type playerType() = 0;
    virtual status_t    suspend() { return INVALID_OPERATION; }
    virtual status_t    resume() { return INVALID_OPERATION; }

    virtual void        setNotifyCallback(void* cookie, notify_callback_f notifyFunc) {
                            mCookie = cookie; mNotify = notifyFunc; }
+0 −2
Original line number Diff line number Diff line
@@ -169,8 +169,6 @@ public:
            status_t        invoke(const Parcel& request, Parcel *reply);
            status_t        setMetadataFilter(const Parcel& filter);
            status_t        getMetadata(bool update_only, bool apply_filter, Parcel *metadata);
            status_t        suspend();
            status_t        resume();
            status_t        setAudioSessionId(int sessionId);
            int             getAudioSessionId();
            status_t        setAuxEffectSendLevel(float level);
+0 −47
Original line number Diff line number Diff line
@@ -1086,53 +1086,6 @@ public class MediaPlayer

    private native void _reset();

    /**
     * Suspends the MediaPlayer. The only methods that may be called while
     * suspended are {@link #reset()}, {@link #release()} and {@link #resume()}.
     * MediaPlayer will release its hardware resources as far as
     * possible and reasonable. A successfully suspended MediaPlayer will
     * cease sending events.
     * If suspension is successful, this method returns true, otherwise
     * false is returned and the player's state is not affected.
     * @hide
     */
    public boolean suspend() {
        if (native_suspend_resume(true) < 0) {
            return false;
        }

        stayAwake(false);

        // make sure none of the listeners get called anymore
        mEventHandler.removeCallbacksAndMessages(null);

        return true;
    }

    /**
     * Resumes the MediaPlayer. Only to be called after a previous (successful)
     * call to {@link #suspend()}.
     * MediaPlayer will return to a state close to what it was in before
     * suspension.
     * @hide
     */
    public boolean resume() {
        if (native_suspend_resume(false) < 0) {
            return false;
        }

        if (isPlaying()) {
            stayAwake(true);
        }

        return true;
    }

    /**
     * @hide
     */
    private native int native_suspend_resume(boolean isSuspend);

    /**
     * Sets the audio stream type for this MediaPlayer. See {@link AudioManager}
     * for a list of stream types. Must call this method before prepare() or
Loading