From 93cbf64f884688b667c5403412cb8193dadb251c Mon Sep 17 00:00:00 2001 From: Ionut Andrei Oanca Date: Wed, 21 Oct 2020 15:46:50 +0200 Subject: [PATCH] End comments with a period --- .../SyncPlay/GroupController.cs | 28 ++-- .../GroupStates/AbstractGroupState.cs | 4 +- .../SyncPlay/GroupStates/IdleGroupState.cs | 12 +- .../SyncPlay/GroupStates/PausedGroupState.cs | 36 ++--- .../SyncPlay/GroupStates/PlayingGroupState.cs | 38 ++--- .../SyncPlay/GroupStates/WaitingGroupState.cs | 144 +++++++++--------- .../SyncPlay/SyncPlayManager.cs | 8 +- .../SyncPlay/ISyncPlayManager.cs | 4 +- .../SyncPlay/Queue/PlayQueueManager.cs | 10 +- 9 files changed, 142 insertions(+), 142 deletions(-) diff --git a/Emby.Server.Implementations/SyncPlay/GroupController.cs b/Emby.Server.Implementations/SyncPlay/GroupController.cs index ee2e9eb8f1..ff1340e46b 100644 --- a/Emby.Server.Implementations/SyncPlay/GroupController.cs +++ b/Emby.Server.Implementations/SyncPlay/GroupController.cs @@ -206,22 +206,22 @@ namespace Emby.Server.Implementations.SyncPlay var items = queue.ToList() .Select(item => _libraryManager.GetItemById(item)); - // Find the highest rating value, which becomes the required minimum for the user + // Find the highest rating value, which becomes the required minimum for the user. var MinParentalRatingAccessRequired = items .Select(item => item.InheritedParentalRatingValue) .Min(); - // Check ParentalRating access, user must have the minimum required access level + // Check ParentalRating access, user must have the minimum required access level. var hasParentalRatingAccess = !user.MaxParentalAgeRating.HasValue || MinParentalRatingAccessRequired <= user.MaxParentalAgeRating; - // Check that user has access to all required folders + // Check that user has access to all required folders. if (!user.HasPermission(PermissionKind.EnableAllFolders) && hasParentalRatingAccess) { - // Get list of items that are not accessible + // Get list of items that are not accessible. var blockedItems = items.Where(item => !HasAccessToItem(user, item)); - // We need the user to be able to access all items + // We need the user to be able to access all items. return !blockedItems.Any(); } @@ -235,14 +235,14 @@ namespace Emby.Server.Implementations.SyncPlay return true; } - // Get list of users + // Get list of users. var users = Participants.Values .Select(participant => _userManager.GetUserById(participant.Session.UserId)); - // Find problematic users + // Find problematic users. var usersWithNoAccess = users.Where(user => !HasAccessToQueue(user, queue)); - // All users must be able to access the queue + // All users must be able to access the queue. return !usersWithNoAccess.Any(); } @@ -268,7 +268,7 @@ namespace Emby.Server.Implementations.SyncPlay RunTimeTicks = session.FullNowPlayingItem.RunTimeTicks ?? 0; PositionTicks = session.PlayState.PositionTicks ?? 0; - // Mantain playstate + // Mantain playstate. var waitingState = new WaitingGroupState(_logger); waitingState.ResumePlaying = !session.PlayState.IsPaused; SetState(waitingState); @@ -503,13 +503,13 @@ namespace Emby.Server.Implementations.SyncPlay /// public bool SetPlayQueue(Guid[] playQueue, int playingItemPosition, long startPositionTicks) { - // Ignore on empty queue or invalid item position + // Ignore on empty queue or invalid item position. if (playQueue.Length < 1 || playingItemPosition >= playQueue.Length || playingItemPosition < 0) { return false; } - // Check is participants can access the new playing queue + // Check is participants can access the new playing queue. if (!AllUsersHaveAccessToQueue(playQueue)) { return false; @@ -577,13 +577,13 @@ namespace Emby.Server.Implementations.SyncPlay /// public bool AddToPlayQueue(Guid[] newItems, string mode) { - // Ignore on empty list + // Ignore on empty list. if (newItems.Length < 1) { return false; } - // Check is participants can access the new playing queue + // Check is participants can access the new playing queue. if (!AllUsersHaveAccessToQueue(newItems)) { return false; @@ -661,7 +661,7 @@ namespace Emby.Server.Implementations.SyncPlay { var currentTime = DateTime.UtcNow; var elapsedTime = currentTime - LastActivity; - // Event may happen during the delay added to account for latency + // Event may happen during the delay added to account for latency. startPositionTicks += elapsedTime.Ticks > 0 ? elapsedTime.Ticks : 0; } diff --git a/Emby.Server.Implementations/SyncPlay/GroupStates/AbstractGroupState.cs b/Emby.Server.Implementations/SyncPlay/GroupStates/AbstractGroupState.cs index 1f0cb42870..1eb1107721 100644 --- a/Emby.Server.Implementations/SyncPlay/GroupStates/AbstractGroupState.cs +++ b/Emby.Server.Implementations/SyncPlay/GroupStates/AbstractGroupState.cs @@ -35,7 +35,7 @@ namespace MediaBrowser.Controller.SyncPlay /// The cancellation token. protected void SendGroupStateUpdate(ISyncPlayStateContext context, IPlaybackGroupRequest reason, SessionInfo session, CancellationToken cancellationToken) { - // Notify relevant state change event + // Notify relevant state change event. var stateUpdate = new GroupStateUpdate() { State = GetGroupState(), @@ -200,7 +200,7 @@ namespace MediaBrowser.Controller.SyncPlay /// public virtual void HandleRequest(ISyncPlayStateContext context, GroupState prevState, PingGroupRequest request, SessionInfo session, CancellationToken cancellationToken) { - // Collected pings are used to account for network latency when unpausing playback + // Collected pings are used to account for network latency when unpausing playback. context.UpdatePing(session, request.Ping); } diff --git a/Emby.Server.Implementations/SyncPlay/GroupStates/IdleGroupState.cs b/Emby.Server.Implementations/SyncPlay/GroupStates/IdleGroupState.cs index d6b981c584..b8510715ac 100644 --- a/Emby.Server.Implementations/SyncPlay/GroupStates/IdleGroupState.cs +++ b/Emby.Server.Implementations/SyncPlay/GroupStates/IdleGroupState.cs @@ -18,7 +18,7 @@ namespace MediaBrowser.Controller.SyncPlay /// public IdleGroupState(ILogger logger) : base(logger) { - // Do nothing + // Do nothing. } /// @@ -36,13 +36,13 @@ namespace MediaBrowser.Controller.SyncPlay /// public override void SessionLeaving(ISyncPlayStateContext context, GroupState prevState, SessionInfo session, CancellationToken cancellationToken) { - // Do nothing + // Do nothing. } /// public override void HandleRequest(ISyncPlayStateContext context, GroupState prevState, PlayGroupRequest request, SessionInfo session, CancellationToken cancellationToken) { - // Change state + // Change state. var waitingState = new WaitingGroupState(_logger); context.SetState(waitingState); waitingState.HandleRequest(context, GetGroupState(), request, session, cancellationToken); @@ -51,7 +51,7 @@ namespace MediaBrowser.Controller.SyncPlay /// public override void HandleRequest(ISyncPlayStateContext context, GroupState prevState, UnpauseGroupRequest request, SessionInfo session, CancellationToken cancellationToken) { - // Change state + // Change state. var waitingState = new WaitingGroupState(_logger); context.SetState(waitingState); waitingState.HandleRequest(context, GetGroupState(), request, session, cancellationToken); @@ -90,7 +90,7 @@ namespace MediaBrowser.Controller.SyncPlay /// public override void HandleRequest(ISyncPlayStateContext context, GroupState prevState, NextTrackGroupRequest request, SessionInfo session, CancellationToken cancellationToken) { - // Change state + // Change state. var waitingState = new WaitingGroupState(_logger); context.SetState(waitingState); waitingState.HandleRequest(context, GetGroupState(), request, session, cancellationToken); @@ -99,7 +99,7 @@ namespace MediaBrowser.Controller.SyncPlay /// public override void HandleRequest(ISyncPlayStateContext context, GroupState prevState, PreviousTrackGroupRequest request, SessionInfo session, CancellationToken cancellationToken) { - // Change state + // Change state. var waitingState = new WaitingGroupState(_logger); context.SetState(waitingState); waitingState.HandleRequest(context, GetGroupState(), request, session, cancellationToken); diff --git a/Emby.Server.Implementations/SyncPlay/GroupStates/PausedGroupState.cs b/Emby.Server.Implementations/SyncPlay/GroupStates/PausedGroupState.cs index 39c0511d9f..f674ec7778 100644 --- a/Emby.Server.Implementations/SyncPlay/GroupStates/PausedGroupState.cs +++ b/Emby.Server.Implementations/SyncPlay/GroupStates/PausedGroupState.cs @@ -19,7 +19,7 @@ namespace MediaBrowser.Controller.SyncPlay /// public PausedGroupState(ILogger logger) : base(logger) { - // Do nothing + // Do nothing. } /// @@ -31,7 +31,7 @@ namespace MediaBrowser.Controller.SyncPlay /// public override void SessionJoined(ISyncPlayStateContext context, GroupState prevState, SessionInfo session, CancellationToken cancellationToken) { - // Wait for session to be ready + // Wait for session to be ready. var waitingState = new WaitingGroupState(_logger); context.SetState(waitingState); waitingState.SessionJoined(context, GetGroupState(), session, cancellationToken); @@ -40,13 +40,13 @@ namespace MediaBrowser.Controller.SyncPlay /// public override void SessionLeaving(ISyncPlayStateContext context, GroupState prevState, SessionInfo session, CancellationToken cancellationToken) { - // Do nothing + // Do nothing. } /// public override void HandleRequest(ISyncPlayStateContext context, GroupState prevState, PlayGroupRequest request, SessionInfo session, CancellationToken cancellationToken) { - // Change state + // Change state. var waitingState = new WaitingGroupState(_logger); context.SetState(waitingState); waitingState.HandleRequest(context, GetGroupState(), request, session, cancellationToken); @@ -55,7 +55,7 @@ namespace MediaBrowser.Controller.SyncPlay /// public override void HandleRequest(ISyncPlayStateContext context, GroupState prevState, UnpauseGroupRequest request, SessionInfo session, CancellationToken cancellationToken) { - // Change state + // Change state. var playingState = new PlayingGroupState(_logger); context.SetState(playingState); playingState.HandleRequest(context, GetGroupState(), request, session, cancellationToken); @@ -66,23 +66,23 @@ namespace MediaBrowser.Controller.SyncPlay { if (!prevState.Equals(GetGroupState())) { - // Pause group and compute the media playback position + // Pause group and compute the media playback position. var currentTime = DateTime.UtcNow; var elapsedTime = currentTime - context.LastActivity; context.LastActivity = currentTime; - // Seek only if playback actually started - // Pause request may be issued during the delay added to account for latency + // Seek only if playback actually started. + // Pause request may be issued during the delay added to account for latency. context.PositionTicks += elapsedTime.Ticks > 0 ? elapsedTime.Ticks : 0; var command = context.NewSyncPlayCommand(SendCommandType.Pause); context.SendCommand(session, SyncPlayBroadcastType.AllGroup, command, cancellationToken); - // Notify relevant state change event + // Notify relevant state change event. SendGroupStateUpdate(context, request, session, cancellationToken); } else { - // Client got lost, sending current state + // Client got lost, sending current state. var command = context.NewSyncPlayCommand(SendCommandType.Pause); context.SendCommand(session, SyncPlayBroadcastType.CurrentSession, command, cancellationToken); } @@ -91,7 +91,7 @@ namespace MediaBrowser.Controller.SyncPlay /// public override void HandleRequest(ISyncPlayStateContext context, GroupState prevState, StopGroupRequest request, SessionInfo session, CancellationToken cancellationToken) { - // Change state + // Change state. var idleState = new IdleGroupState(_logger); context.SetState(idleState); idleState.HandleRequest(context, GetGroupState(), request, session, cancellationToken); @@ -100,7 +100,7 @@ namespace MediaBrowser.Controller.SyncPlay /// public override void HandleRequest(ISyncPlayStateContext context, GroupState prevState, SeekGroupRequest request, SessionInfo session, CancellationToken cancellationToken) { - // Change state + // Change state. var waitingState = new WaitingGroupState(_logger); context.SetState(waitingState); waitingState.HandleRequest(context, GetGroupState(), request, session, cancellationToken); @@ -109,7 +109,7 @@ namespace MediaBrowser.Controller.SyncPlay /// public override void HandleRequest(ISyncPlayStateContext context, GroupState prevState, BufferGroupRequest request, SessionInfo session, CancellationToken cancellationToken) { - // Change state + // Change state. var waitingState = new WaitingGroupState(_logger); context.SetState(waitingState); waitingState.HandleRequest(context, GetGroupState(), request, session, cancellationToken); @@ -120,17 +120,17 @@ namespace MediaBrowser.Controller.SyncPlay { if (prevState.Equals(GetGroupState())) { - // Client got lost, sending current state + // Client got lost, sending current state. var command = context.NewSyncPlayCommand(SendCommandType.Pause); context.SendCommand(session, SyncPlayBroadcastType.CurrentSession, command, cancellationToken); } else if (prevState.Equals(GroupState.Waiting)) { - // Sending current state to all clients + // Sending current state to all clients. var command = context.NewSyncPlayCommand(SendCommandType.Pause); context.SendCommand(session, SyncPlayBroadcastType.AllGroup, command, cancellationToken); - // Notify relevant state change event + // Notify relevant state change event. SendGroupStateUpdate(context, request, session, cancellationToken); } } @@ -138,7 +138,7 @@ namespace MediaBrowser.Controller.SyncPlay /// public override void HandleRequest(ISyncPlayStateContext context, GroupState prevState, NextTrackGroupRequest request, SessionInfo session, CancellationToken cancellationToken) { - // Change state + // Change state. var waitingState = new WaitingGroupState(_logger); context.SetState(waitingState); waitingState.HandleRequest(context, GetGroupState(), request, session, cancellationToken); @@ -147,7 +147,7 @@ namespace MediaBrowser.Controller.SyncPlay /// public override void HandleRequest(ISyncPlayStateContext context, GroupState prevState, PreviousTrackGroupRequest request, SessionInfo session, CancellationToken cancellationToken) { - // Change state + // Change state. var waitingState = new WaitingGroupState(_logger); context.SetState(waitingState); waitingState.HandleRequest(context, GetGroupState(), request, session, cancellationToken); diff --git a/Emby.Server.Implementations/SyncPlay/GroupStates/PlayingGroupState.cs b/Emby.Server.Implementations/SyncPlay/GroupStates/PlayingGroupState.cs index e2909ff91c..a3b0baf963 100644 --- a/Emby.Server.Implementations/SyncPlay/GroupStates/PlayingGroupState.cs +++ b/Emby.Server.Implementations/SyncPlay/GroupStates/PlayingGroupState.cs @@ -24,7 +24,7 @@ namespace MediaBrowser.Controller.SyncPlay /// public PlayingGroupState(ILogger logger) : base(logger) { - // Do nothing + // Do nothing. } /// @@ -36,7 +36,7 @@ namespace MediaBrowser.Controller.SyncPlay /// public override void SessionJoined(ISyncPlayStateContext context, GroupState prevState, SessionInfo session, CancellationToken cancellationToken) { - // Wait for session to be ready + // Wait for session to be ready. var waitingState = new WaitingGroupState(_logger); context.SetState(waitingState); waitingState.SessionJoined(context, GetGroupState(), session, cancellationToken); @@ -45,13 +45,13 @@ namespace MediaBrowser.Controller.SyncPlay /// public override void SessionLeaving(ISyncPlayStateContext context, GroupState prevState, SessionInfo session, CancellationToken cancellationToken) { - // Do nothing + // Do nothing. } /// public override void HandleRequest(ISyncPlayStateContext context, GroupState prevState, PlayGroupRequest request, SessionInfo session, CancellationToken cancellationToken) { - // Change state + // Change state. var waitingState = new WaitingGroupState(_logger); context.SetState(waitingState); waitingState.HandleRequest(context, GetGroupState(), request, session, cancellationToken); @@ -62,13 +62,13 @@ namespace MediaBrowser.Controller.SyncPlay { if (!prevState.Equals(GetGroupState())) { - // Pick a suitable time that accounts for latency + // Pick a suitable time that accounts for latency. var delayMillis = Math.Max(context.GetHighestPing() * 2, context.DefaultPing); - // Unpause group and set starting point in future - // Clients will start playback at LastActivity (datetime) from PositionTicks (playback position) - // The added delay does not guarantee, of course, that the command will be received in time - // Playback synchronization will mainly happen client side + // Unpause group and set starting point in future. + // Clients will start playback at LastActivity (datetime) from PositionTicks (playback position). + // The added delay does not guarantee, of course, that the command will be received in time. + // Playback synchronization will mainly happen client side. context.LastActivity = DateTime.UtcNow.AddMilliseconds( delayMillis ); @@ -76,12 +76,12 @@ namespace MediaBrowser.Controller.SyncPlay var command = context.NewSyncPlayCommand(SendCommandType.Unpause); context.SendCommand(session, SyncPlayBroadcastType.AllGroup, command, cancellationToken); - // Notify relevant state change event + // Notify relevant state change event. SendGroupStateUpdate(context, request, session, cancellationToken); } else { - // Client got lost, sending current state + // Client got lost, sending current state. var command = context.NewSyncPlayCommand(SendCommandType.Unpause); context.SendCommand(session, SyncPlayBroadcastType.CurrentSession, command, cancellationToken); } @@ -90,7 +90,7 @@ namespace MediaBrowser.Controller.SyncPlay /// public override void HandleRequest(ISyncPlayStateContext context, GroupState prevState, PauseGroupRequest request, SessionInfo session, CancellationToken cancellationToken) { - // Change state + // Change state. var pausedState = new PausedGroupState(_logger); context.SetState(pausedState); pausedState.HandleRequest(context, GetGroupState(), request, session, cancellationToken); @@ -99,7 +99,7 @@ namespace MediaBrowser.Controller.SyncPlay /// public override void HandleRequest(ISyncPlayStateContext context, GroupState prevState, StopGroupRequest request, SessionInfo session, CancellationToken cancellationToken) { - // Change state + // Change state. var idleState = new IdleGroupState(_logger); context.SetState(idleState); idleState.HandleRequest(context, GetGroupState(), request, session, cancellationToken); @@ -108,7 +108,7 @@ namespace MediaBrowser.Controller.SyncPlay /// public override void HandleRequest(ISyncPlayStateContext context, GroupState prevState, SeekGroupRequest request, SessionInfo session, CancellationToken cancellationToken) { - // Change state + // Change state. var waitingState = new WaitingGroupState(_logger); context.SetState(waitingState); waitingState.HandleRequest(context, GetGroupState(), request, session, cancellationToken); @@ -122,7 +122,7 @@ namespace MediaBrowser.Controller.SyncPlay return; } - // Change state + // Change state. var waitingState = new WaitingGroupState(_logger); context.SetState(waitingState); waitingState.HandleRequest(context, GetGroupState(), request, session, cancellationToken); @@ -133,13 +133,13 @@ namespace MediaBrowser.Controller.SyncPlay { if (prevState.Equals(GetGroupState())) { - // Group was not waiting, make sure client has latest state + // Group was not waiting, make sure client has latest state. var command = context.NewSyncPlayCommand(SendCommandType.Unpause); context.SendCommand(session, SyncPlayBroadcastType.CurrentSession, command, cancellationToken); } else if (prevState.Equals(GroupState.Waiting)) { - // Notify relevant state change event + // Notify relevant state change event. SendGroupStateUpdate(context, request, session, cancellationToken); } } @@ -147,7 +147,7 @@ namespace MediaBrowser.Controller.SyncPlay /// public override void HandleRequest(ISyncPlayStateContext context, GroupState prevState, NextTrackGroupRequest request, SessionInfo session, CancellationToken cancellationToken) { - // Change state + // Change state. var waitingState = new WaitingGroupState(_logger); context.SetState(waitingState); waitingState.HandleRequest(context, GetGroupState(), request, session, cancellationToken); @@ -156,7 +156,7 @@ namespace MediaBrowser.Controller.SyncPlay /// public override void HandleRequest(ISyncPlayStateContext context, GroupState prevState, PreviousTrackGroupRequest request, SessionInfo session, CancellationToken cancellationToken) { - // Change state + // Change state. var waitingState = new WaitingGroupState(_logger); context.SetState(waitingState); waitingState.HandleRequest(context, GetGroupState(), request, session, cancellationToken); diff --git a/Emby.Server.Implementations/SyncPlay/GroupStates/WaitingGroupState.cs b/Emby.Server.Implementations/SyncPlay/GroupStates/WaitingGroupState.cs index 9d839b268b..acf0161b4e 100644 --- a/Emby.Server.Implementations/SyncPlay/GroupStates/WaitingGroupState.cs +++ b/Emby.Server.Implementations/SyncPlay/GroupStates/WaitingGroupState.cs @@ -34,7 +34,7 @@ namespace MediaBrowser.Controller.SyncPlay /// public WaitingGroupState(ILogger logger) : base(logger) { - // Do nothing + // Do nothing. } /// @@ -46,7 +46,7 @@ namespace MediaBrowser.Controller.SyncPlay /// public override void SessionJoined(ISyncPlayStateContext context, GroupState prevState, SessionInfo session, CancellationToken cancellationToken) { - // Save state if first event + // Save state if first event. if (!InitialStateSet) { InitialState = prevState; @@ -55,23 +55,23 @@ namespace MediaBrowser.Controller.SyncPlay if (prevState.Equals(GroupState.Playing)) { ResumePlaying = true; - // Pause group and compute the media playback position + // Pause group and compute the media playback position. var currentTime = DateTime.UtcNow; var elapsedTime = currentTime - context.LastActivity; context.LastActivity = currentTime; - // Seek only if playback actually started - // Event may happen during the delay added to account for latency + // Seek only if playback actually started. + // Event may happen during the delay added to account for latency. context.PositionTicks += elapsedTime.Ticks > 0 ? elapsedTime.Ticks : 0; } - // Prepare new session + // Prepare new session. var playQueueUpdate = context.GetPlayQueueUpdate(PlayQueueUpdateReason.NewPlaylist); var update = context.NewSyncPlayGroupUpdate(GroupUpdateType.PlayQueue, playQueueUpdate); context.SendGroupUpdate(session, SyncPlayBroadcastType.CurrentSession, update, cancellationToken); context.SetBuffering(session, true); - // Send pause command to all non-buffering sessions + // Send pause command to all non-buffering sessions. var command = context.NewSyncPlayCommand(SendCommandType.Pause); context.SendCommand(session, SyncPlayBroadcastType.AllReady, command, cancellationToken); } @@ -79,7 +79,7 @@ namespace MediaBrowser.Controller.SyncPlay /// public override void SessionLeaving(ISyncPlayStateContext context, GroupState prevState, SessionInfo session, CancellationToken cancellationToken) { - // Save state if first event + // Save state if first event. if (!InitialStateSet) { InitialState = prevState; @@ -92,7 +92,7 @@ namespace MediaBrowser.Controller.SyncPlay { if (ResumePlaying) { - // Client, that was buffering, left the group + // Client, that was buffering, left the group. var playingState = new PlayingGroupState(_logger); context.SetState(playingState); var unpauseRequest = new UnpauseGroupRequest(); @@ -102,7 +102,7 @@ namespace MediaBrowser.Controller.SyncPlay } else { - // Group is ready, returning to previous state + // Group is ready, returning to previous state. var pausedState = new PausedGroupState(_logger); context.SetState(pausedState); @@ -114,7 +114,7 @@ namespace MediaBrowser.Controller.SyncPlay /// public override void HandleRequest(ISyncPlayStateContext context, GroupState prevState, PlayGroupRequest request, SessionInfo session, CancellationToken cancellationToken) { - // Save state if first event + // Save state if first event. if (!InitialStateSet) { InitialState = prevState; @@ -128,7 +128,7 @@ namespace MediaBrowser.Controller.SyncPlay { _logger.LogError("HandleRequest: {0} in group {1}, unable to set playing queue.", request.GetRequestType(), context.GroupId.ToString()); - // Ignore request and return to previous state + // Ignore request and return to previous state. ISyncPlayState newState; switch (prevState) { @@ -151,7 +151,7 @@ namespace MediaBrowser.Controller.SyncPlay var update = context.NewSyncPlayGroupUpdate(GroupUpdateType.PlayQueue, playQueueUpdate); context.SendGroupUpdate(session, SyncPlayBroadcastType.AllGroup, update, cancellationToken); - // Reset status of sessions and await for all Ready events before sending Play command + // Reset status of sessions and await for all Ready events before sending Play command. context.SetAllBuffering(true); _logger.LogDebug("HandleRequest: {0} in group {1}, {2} set a new play queue.", request.GetRequestType(), context.GroupId.ToString(), session.Id.ToString()); @@ -160,7 +160,7 @@ namespace MediaBrowser.Controller.SyncPlay /// public override void HandleRequest(ISyncPlayStateContext context, GroupState prevState, SetPlaylistItemGroupRequest request, SessionInfo session, CancellationToken cancellationToken) { - // Save state if first event + // Save state if first event. if (!InitialStateSet) { InitialState = prevState; @@ -176,12 +176,12 @@ namespace MediaBrowser.Controller.SyncPlay var update = context.NewSyncPlayGroupUpdate(GroupUpdateType.PlayQueue, playQueueUpdate); context.SendGroupUpdate(session, SyncPlayBroadcastType.AllGroup, update, cancellationToken); - // Reset status of sessions and await for all Ready events before sending Play command + // Reset status of sessions and await for all Ready events before sending Play command. context.SetAllBuffering(true); } else { - // Return to old state + // Return to old state. ISyncPlayState newState; switch (prevState) { @@ -205,7 +205,7 @@ namespace MediaBrowser.Controller.SyncPlay /// public override void HandleRequest(ISyncPlayStateContext context, GroupState prevState, UnpauseGroupRequest request, SessionInfo session, CancellationToken cancellationToken) { - // Save state if first event + // Save state if first event. if (!InitialStateSet) { InitialState = prevState; @@ -221,7 +221,7 @@ namespace MediaBrowser.Controller.SyncPlay var update = context.NewSyncPlayGroupUpdate(GroupUpdateType.PlayQueue, playQueueUpdate); context.SendGroupUpdate(session, SyncPlayBroadcastType.AllGroup, update, cancellationToken); - // Reset status of sessions and await for all Ready events before sending Play command + // Reset status of sessions and await for all Ready events before sending Play command. context.SetAllBuffering(true); _logger.LogDebug("HandleRequest: {0} in group {1}, waiting for all ready events.", request.GetRequestType(), context.GroupId.ToString()); @@ -232,10 +232,10 @@ namespace MediaBrowser.Controller.SyncPlay { _logger.LogDebug("HandleRequest: {0} in group {1}, ignoring sessions that are not ready and forcing the playback to start.", request.GetRequestType(), context.GroupId.ToString()); - // An Unpause request is forcing the playback to start, ignoring sessions that are not ready + // An Unpause request is forcing the playback to start, ignoring sessions that are not ready. context.SetAllBuffering(false); - // Change state + // Change state. var playingState = new PlayingGroupState(_logger); playingState.IgnoreBuffering = true; context.SetState(playingState); @@ -243,10 +243,10 @@ namespace MediaBrowser.Controller.SyncPlay } else { - // Group would have gone to paused state, now will go to playing state when ready + // Group would have gone to paused state, now will go to playing state when ready. ResumePlaying = true; - // Notify relevant state change event + // Notify relevant state change event. SendGroupStateUpdate(context, request, session, cancellationToken); } } @@ -255,31 +255,31 @@ namespace MediaBrowser.Controller.SyncPlay /// public override void HandleRequest(ISyncPlayStateContext context, GroupState prevState, PauseGroupRequest request, SessionInfo session, CancellationToken cancellationToken) { - // Save state if first event + // Save state if first event. if (!InitialStateSet) { InitialState = prevState; InitialStateSet = true; } - // Wait for sessions to be ready, then switch to paused state + // Wait for sessions to be ready, then switch to paused state. ResumePlaying = false; - // Notify relevant state change event + // Notify relevant state change event. SendGroupStateUpdate(context, request, session, cancellationToken); } /// public override void HandleRequest(ISyncPlayStateContext context, GroupState prevState, StopGroupRequest request, SessionInfo session, CancellationToken cancellationToken) { - // Save state if first event + // Save state if first event. if (!InitialStateSet) { InitialState = prevState; InitialStateSet = true; } - // Change state + // Change state. var idleState = new IdleGroupState(_logger); context.SetState(idleState); idleState.HandleRequest(context, GetGroupState(), request, session, cancellationToken); @@ -288,7 +288,7 @@ namespace MediaBrowser.Controller.SyncPlay /// public override void HandleRequest(ISyncPlayStateContext context, GroupState prevState, SeekGroupRequest request, SessionInfo session, CancellationToken cancellationToken) { - // Save state if first event + // Save state if first event. if (!InitialStateSet) { InitialState = prevState; @@ -304,34 +304,34 @@ namespace MediaBrowser.Controller.SyncPlay ResumePlaying = false; } - // Sanitize PositionTicks + // Sanitize PositionTicks. var ticks = context.SanitizePositionTicks(request.PositionTicks); - // Seek + // Seek. context.PositionTicks = ticks; context.LastActivity = DateTime.UtcNow; var command = context.NewSyncPlayCommand(SendCommandType.Seek); context.SendCommand(session, SyncPlayBroadcastType.AllGroup, command, cancellationToken); - // Reset status of sessions and await for all Ready events before sending Play command + // Reset status of sessions and await for all Ready events before sending Play command. context.SetAllBuffering(true); - // Notify relevant state change event + // Notify relevant state change event. SendGroupStateUpdate(context, request, session, cancellationToken); } /// public override void HandleRequest(ISyncPlayStateContext context, GroupState prevState, BufferGroupRequest request, SessionInfo session, CancellationToken cancellationToken) { - // Save state if first event + // Save state if first event. if (!InitialStateSet) { InitialState = prevState; InitialStateSet = true; } - // Make sure the client is playing the correct item + // Make sure the client is playing the correct item. if (!request.PlaylistItemId.Equals(context.PlayQueue.GetPlayingItemPlaylistId())) { _logger.LogDebug("HandleRequest: {0} in group {1}, {2} has wrong playlist item.", request.GetRequestType(), context.GroupId.ToString(), session.Id.ToString()); @@ -346,60 +346,60 @@ namespace MediaBrowser.Controller.SyncPlay if (prevState.Equals(GroupState.Playing)) { - // Resume playback when all ready + // Resume playback when all ready. ResumePlaying = true; context.SetBuffering(session, true); - // Pause group and compute the media playback position + // Pause group and compute the media playback position. var currentTime = DateTime.UtcNow; var elapsedTime = currentTime - context.LastActivity; context.LastActivity = currentTime; context.PositionTicks += elapsedTime.Ticks > 0 ? elapsedTime.Ticks : 0; - // Send pause command to all non-buffering sessions + // Send pause command to all non-buffering sessions. var command = context.NewSyncPlayCommand(SendCommandType.Pause); context.SendCommand(session, SyncPlayBroadcastType.AllReady, command, cancellationToken); } else if (prevState.Equals(GroupState.Paused)) { - // Don't resume playback when all ready + // Don't resume playback when all ready. ResumePlaying = false; context.SetBuffering(session, true); - // Send pause command to buffering session + // Send pause command to buffering session. var command = context.NewSyncPlayCommand(SendCommandType.Pause); context.SendCommand(session, SyncPlayBroadcastType.CurrentSession, command, cancellationToken); } else if (prevState.Equals(GroupState.Waiting)) { - // Another session is now buffering + // Another session is now buffering. context.SetBuffering(session, true); if (!ResumePlaying) { - // Force update for this session that should be paused + // Force update for this session that should be paused. var command = context.NewSyncPlayCommand(SendCommandType.Pause); context.SendCommand(session, SyncPlayBroadcastType.CurrentSession, command, cancellationToken); } } - // Notify relevant state change event + // Notify relevant state change event. SendGroupStateUpdate(context, request, session, cancellationToken); } /// public override void HandleRequest(ISyncPlayStateContext context, GroupState prevState, ReadyGroupRequest request, SessionInfo session, CancellationToken cancellationToken) { - // Save state if first event + // Save state if first event. if (!InitialStateSet) { InitialState = prevState; InitialStateSet = true; } - // Make sure the client is playing the correct item + // Make sure the client is playing the correct item. if (!request.PlaylistItemId.Equals(context.PlayQueue.GetPlayingItemPlaylistId())) { _logger.LogDebug("HandleRequest: {0} in group {1}, {2} has wrong playlist item.", request.GetRequestType(), context.GroupId.ToString(), session.Id.ToString()); @@ -432,28 +432,28 @@ namespace MediaBrowser.Controller.SyncPlay if (ResumePlaying) { // Handle case where session reported as ready but in reality - // it has no clue of the real position nor the playback state + // it has no clue of the real position nor the playback state. if (!request.IsPlaying && Math.Abs(context.PositionTicks - requestTicks) > TimeSpan.FromSeconds(0.5).Ticks) { - // Session not ready at all + // Session not ready at all. context.SetBuffering(session, true); - // Correcting session's position + // Correcting session's position. var command = context.NewSyncPlayCommand(SendCommandType.Seek); context.SendCommand(session, SyncPlayBroadcastType.CurrentSession, command, cancellationToken); - // Notify relevant state change event + // Notify relevant state change event. SendGroupStateUpdate(context, request, session, cancellationToken); _logger.LogDebug("HandleRequest: {0} in group {1}, {2} got lost in time, correcting.", request.GetRequestType(), context.GroupId.ToString(), session.Id.ToString()); return; } - // Session is ready + // Session is ready. context.SetBuffering(session, false); if (context.IsBuffering()) { - // Others are still buffering, tell this client to pause when ready + // Others are still buffering, tell this client to pause when ready. var command = context.NewSyncPlayCommand(SendCommandType.Pause); var pauseAtTime = currentTime.AddTicks(delayTicks); command.When = context.DateToUTCString(pauseAtTime); @@ -463,11 +463,11 @@ namespace MediaBrowser.Controller.SyncPlay } else { - // If all ready, then start playback - // Let other clients resume as soon as the buffering client catches up + // If all ready, then start playback. + // Let other clients resume as soon as the buffering client catches up. if (delayTicks > context.GetHighestPing() * 2 * TimeSpan.TicksPerMillisecond) { - // Client that was buffering is recovering, notifying others to resume + // Client that was buffering is recovering, notifying others to resume. context.LastActivity = currentTime.AddTicks(delayTicks); var command = context.NewSyncPlayCommand(SendCommandType.Unpause); var filter = SyncPlayBroadcastType.AllExceptCurrentSession; @@ -482,7 +482,7 @@ namespace MediaBrowser.Controller.SyncPlay } else { - // Client, that was buffering, resumed playback but did not update others in time + // Client, that was buffering, resumed playback but did not update others in time. delayTicks = context.GetHighestPing() * 2 * TimeSpan.TicksPerMillisecond; delayTicks = delayTicks < context.DefaultPing ? context.DefaultPing : delayTicks; @@ -494,7 +494,7 @@ namespace MediaBrowser.Controller.SyncPlay _logger.LogDebug("HandleRequest: {0} in group {1}, {2} resumed playback but did not update others in time.", request.GetRequestType(), context.GroupId.ToString(), session.Id.ToString()); } - // Change state + // Change state. var playingState = new PlayingGroupState(_logger); context.SetState(playingState); playingState.HandleRequest(context, GetGroupState(), request, session, cancellationToken); @@ -502,35 +502,35 @@ namespace MediaBrowser.Controller.SyncPlay } else { - // Check that session is really ready, tollerate half second difference to account for player imperfections + // Check that session is really ready, tollerate half second difference to account for player imperfections. if (Math.Abs(context.PositionTicks - requestTicks) > TimeSpan.FromSeconds(0.5).Ticks) { - // Session still not ready + // Session still not ready. context.SetBuffering(session, true); - // Session is seeking to wrong position, correcting + // Session is seeking to wrong position, correcting. var command = context.NewSyncPlayCommand(SendCommandType.Seek); context.SendCommand(session, SyncPlayBroadcastType.CurrentSession, command, cancellationToken); - // Notify relevant state change event + // Notify relevant state change event. SendGroupStateUpdate(context, request, session, cancellationToken); _logger.LogDebug("HandleRequest: {0} in group {1}, {2} was seeking to wrong position, correcting.", request.GetRequestType(), context.GroupId.ToString(), session.Id.ToString()); return; } else { - // Session is ready + // Session is ready. context.SetBuffering(session, false); } if (!context.IsBuffering()) { - // Group is ready, returning to previous state + // Group is ready, returning to previous state. var pausedState = new PausedGroupState(_logger); context.SetState(pausedState); if (InitialState.Equals(GroupState.Playing)) { - // Group went from playing to waiting state and a pause request occured while waiting + // Group went from playing to waiting state and a pause request occured while waiting. var pauserequest = new PauseGroupRequest(); pausedState.HandleRequest(context, GetGroupState(), pauserequest, session, cancellationToken); } @@ -547,7 +547,7 @@ namespace MediaBrowser.Controller.SyncPlay /// public override void HandleRequest(ISyncPlayStateContext context, GroupState prevState, NextTrackGroupRequest request, SessionInfo session, CancellationToken cancellationToken) { - // Save state if first event + // Save state if first event. if (!InitialStateSet) { InitialState = prevState; @@ -556,7 +556,7 @@ namespace MediaBrowser.Controller.SyncPlay ResumePlaying = true; - // Make sure the client knows the playing item, to avoid duplicate requests + // Make sure the client knows the playing item, to avoid duplicate requests. if (!request.PlaylistItemId.Equals(context.PlayQueue.GetPlayingItemPlaylistId())) { _logger.LogDebug("HandleRequest: {0} in group {1}, client provided the wrong playlist id.", request.GetRequestType(), context.GroupId.ToString()); @@ -566,17 +566,17 @@ namespace MediaBrowser.Controller.SyncPlay var newItem = context.NextItemInQueue(); if (newItem) { - // Send playing-queue update + // Send playing-queue update. var playQueueUpdate = context.GetPlayQueueUpdate(PlayQueueUpdateReason.NextTrack); var update = context.NewSyncPlayGroupUpdate(GroupUpdateType.PlayQueue, playQueueUpdate); context.SendGroupUpdate(session, SyncPlayBroadcastType.AllGroup, update, cancellationToken); - // Reset status of sessions and await for all Ready events before sending Play command + // Reset status of sessions and await for all Ready events before sending Play command. context.SetAllBuffering(true); } else { - // Return to old state + // Return to old state. ISyncPlayState newState; switch (prevState) { @@ -600,7 +600,7 @@ namespace MediaBrowser.Controller.SyncPlay /// public override void HandleRequest(ISyncPlayStateContext context, GroupState prevState, PreviousTrackGroupRequest request, SessionInfo session, CancellationToken cancellationToken) { - // Save state if first event + // Save state if first event. if (!InitialStateSet) { InitialState = prevState; @@ -609,7 +609,7 @@ namespace MediaBrowser.Controller.SyncPlay ResumePlaying = true; - // Make sure the client knows the playing item, to avoid duplicate requests + // Make sure the client knows the playing item, to avoid duplicate requests. if (!request.PlaylistItemId.Equals(context.PlayQueue.GetPlayingItemPlaylistId())) { _logger.LogDebug("HandleRequest: {0} in group {1}, client provided the wrong playlist id.", request.GetRequestType(), context.GroupId.ToString()); @@ -619,17 +619,17 @@ namespace MediaBrowser.Controller.SyncPlay var newItem = context.PreviousItemInQueue(); if (newItem) { - // Send playing-queue update + // Send playing-queue update. var playQueueUpdate = context.GetPlayQueueUpdate(PlayQueueUpdateReason.PreviousTrack); var update = context.NewSyncPlayGroupUpdate(GroupUpdateType.PlayQueue, playQueueUpdate); context.SendGroupUpdate(session, SyncPlayBroadcastType.AllGroup, update, cancellationToken); - // Reset status of sessions and await for all Ready events before sending Play command + // Reset status of sessions and await for all Ready events before sending Play command. context.SetAllBuffering(true); } else { - // Return to old state + // Return to old state. ISyncPlayState newState; switch (prevState) { diff --git a/Emby.Server.Implementations/SyncPlay/SyncPlayManager.cs b/Emby.Server.Implementations/SyncPlay/SyncPlayManager.cs index a8e30a9eca..6e3b492498 100644 --- a/Emby.Server.Implementations/SyncPlay/SyncPlayManager.cs +++ b/Emby.Server.Implementations/SyncPlay/SyncPlayManager.cs @@ -135,7 +135,7 @@ namespace Emby.Server.Implementations.SyncPlay return; } - // TODO: probably remove this event, not used at the moment + // TODO: probably remove this event, not used at the moment. } private void OnSessionManagerPlaybackStart(object sender, PlaybackProgressEventArgs e) @@ -146,7 +146,7 @@ namespace Emby.Server.Implementations.SyncPlay return; } - // TODO: probably remove this event, not used at the moment + // TODO: probably remove this event, not used at the moment. } private void OnSessionManagerPlaybackStopped(object sender, PlaybackStopEventArgs e) @@ -157,7 +157,7 @@ namespace Emby.Server.Implementations.SyncPlay return; } - // TODO: probably remove this event, not used at the moment + // TODO: probably remove this event, not used at the moment. } private bool IsSessionInGroup(SessionInfo session) @@ -267,7 +267,7 @@ namespace Emby.Server.Implementations.SyncPlay /// public void LeaveGroup(SessionInfo session, CancellationToken cancellationToken) { - // TODO: determine what happens to users that are in a group and get their permissions revoked + // TODO: determine what happens to users that are in a group and get their permissions revoked. lock (_groupsLock) { _sessionToGroupMap.TryGetValue(session.Id, out var group); diff --git a/MediaBrowser.Controller/SyncPlay/ISyncPlayManager.cs b/MediaBrowser.Controller/SyncPlay/ISyncPlayManager.cs index 9bef3f5593..ae2b0fa50a 100644 --- a/MediaBrowser.Controller/SyncPlay/ISyncPlayManager.cs +++ b/MediaBrowser.Controller/SyncPlay/ISyncPlayManager.cs @@ -55,7 +55,7 @@ namespace MediaBrowser.Controller.SyncPlay /// /// The session. /// The group. - /// + /// Thrown when the user is in another group already. void AddSessionToGroup(SessionInfo session, ISyncPlayGroupController group); /// @@ -63,7 +63,7 @@ namespace MediaBrowser.Controller.SyncPlay /// /// The session. /// The group. - /// + /// Thrown when the user is not found in the specified group. void RemoveSessionFromGroup(SessionInfo session, ISyncPlayGroupController group); } } diff --git a/MediaBrowser.Controller/SyncPlay/Queue/PlayQueueManager.cs b/MediaBrowser.Controller/SyncPlay/Queue/PlayQueueManager.cs index 701982cc00..6b4f9401e2 100644 --- a/MediaBrowser.Controller/SyncPlay/Queue/PlayQueueManager.cs +++ b/MediaBrowser.Controller/SyncPlay/Queue/PlayQueueManager.cs @@ -261,9 +261,9 @@ namespace MediaBrowser.Controller.SyncPlay if (ShuffleMode.Equals(GroupShuffleMode.Shuffle)) { - // Append items to sorted playlist as they are + // Append items to sorted playlist as they are. SortedPlaylist.AddRange(newItems); - // Shuffle items before adding to shuffled playlist + // Shuffle items before adding to shuffled playlist. newItems.Shuffle(); ShuffledPlaylist.InsertRange(PlayingItemIndex + 1, newItems); } @@ -387,11 +387,11 @@ namespace MediaBrowser.Controller.SyncPlay { if (playlistItemIds.Contains(playingItem.PlaylistItemId)) { - // Playing item has been removed, picking previous item + // Playing item has been removed, picking previous item. PlayingItemIndex--; if (PlayingItemIndex < 0) { - // Was first element, picking next if available + // Was first element, picking next if available. PlayingItemIndex = SortedPlaylist.Count() > 0 ? 0 : -1; } @@ -399,7 +399,7 @@ namespace MediaBrowser.Controller.SyncPlay } else { - // Restoring playing item + // Restoring playing item. SetPlayingItemByPlaylistId(playingItem.PlaylistItemId); return false; }