diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java index fd71d79b13f11..a000cdd0f156b 100644 --- a/media/java/android/media/AudioService.java +++ b/media/java/android/media/AudioService.java @@ -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 */); } diff --git a/media/java/android/media/RemoteControlClient.java b/media/java/android/media/RemoteControlClient.java index e076ef0044d79..93bcf03bb4635 100644 --- a/media/java/android/media/RemoteControlClient.java +++ b/media/java/android/media/RemoteControlClient.java @@ -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);