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

Commit 3fbf67e2 authored by Jean-Michel Trivi's avatar Jean-Michel Trivi
Browse files

Handle seek requests in AudioService

AudioService handles seek requests to RemoteControlClients.
Discard old or unprocessed seek requests when handling a new one.
Update javadoc for OnPlaybackPositionUpdateListener interface.

bug 8120740

Change-Id: Id17c2852b24d4b8af85e472a177484b98cfeba05
parent 5a78b1b2
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -3535,6 +3535,9 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
                    onNewPlaybackStateForRcc(msg.arg1 /* rccId */, msg.arg2 /* state */,
                            (RccPlaybackState)msg.obj /* newState */);
                    break;
                case MSG_RCC_SEEK_REQUEST:
                    onSetRemoteControlClientPlaybackPosition(msg.arg1 /* generationId */,
                            ((Long)msg.obj).longValue() /* timeMs */);

                case MSG_SET_RSX_CONNECTION_STATE:
                    onSetRsxConnectionState(msg.arg1/*available*/, msg.arg2/*address*/);
@@ -5820,7 +5823,16 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
    }

    public void setRemoteControlClientPlaybackPosition(int generationId, long timeMs) {
        sendMsg(mAudioHandler, MSG_RCC_SEEK_REQUEST, SENDMSG_QUEUE, generationId /* arg1 */,
        // ignore position change requests if invalid generation ID
        synchronized(mRCStack) {
            synchronized(mCurrentRcLock) {
                if (mCurrentRcClientGen != generationId) {
                    return;
                }
            }
        }
        // discard any unprocessed seek request in the message queue, and replace with latest
        sendMsg(mAudioHandler, MSG_RCC_SEEK_REQUEST, SENDMSG_REPLACE, generationId /* arg1 */,
                0 /* arg2 ignored*/, new Long(timeMs) /* obj */, 0 /* delay */);
    }

+4 −1
Original line number Diff line number Diff line
@@ -683,9 +683,12 @@ public class RemoteControlClient
        /**
         * Called on the implementer to notify it that the playback head should be set at the given
         * position. If the position can be changed from its current value, the implementor of
         * the interface should also update the playback position using
         * the interface must also update the playback position using
         * {@link RemoteControlClient#setPlaybackState(int, long, int)} to reflect the actual new
         * position being used, regardless of whether it differs from the requested position.
         * Failure to do so would cause the system to not know the new actual playback position,
         * and user interface components would fail to show the user where playback resumed after
         * the position was updated.
         * @param newPositionMs the new requested position in the current media, expressed in ms.
         */
        void onPlaybackPositionUpdate(long newPositionMs);