1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 21:43:22 +08:00

Merge pull request #28003 from peppy/fix-multi-spectator-music-pause

Fix audio being paused in a spectator session when all players finish playing
This commit is contained in:
Bartłomiej Dach 2024-04-26 11:39:57 +02:00 committed by GitHub
commit 3da5831075
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 24 additions and 5 deletions

View File

@ -94,7 +94,7 @@ namespace osu.Game
public const int SAMPLE_DEBOUNCE_TIME = 20; public const int SAMPLE_DEBOUNCE_TIME = 20;
/// <summary> /// <summary>
/// The maximum volume at which audio tracks should playback. This can be set lower than 1 to create some head-room for sound effects. /// The maximum volume at which audio tracks should play back at. This can be set lower than 1 to create some head-room for sound effects.
/// </summary> /// </summary>
private const double global_track_volume_adjust = 0.8; private const double global_track_volume_adjust = 0.8;

View File

@ -244,10 +244,19 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
playerArea.LoadScore(spectatorGameplayState.Score); playerArea.LoadScore(spectatorGameplayState.Score);
}); });
protected override void FailGameplay(int userId) protected override void FailGameplay(int userId) => Schedule(() =>
{ {
// We probably want to visualise this in the future. // We probably want to visualise this in the future.
}
var instance = instances.Single(i => i.UserId == userId);
syncManager.RemoveManagedClock(instance.SpectatorPlayerClock);
});
protected override void PassGameplay(int userId) => Schedule(() =>
{
var instance = instances.Single(i => i.UserId == userId);
syncManager.RemoveManagedClock(instance.SpectatorPlayerClock);
});
protected override void QuitGameplay(int userId) => Schedule(() => protected override void QuitGameplay(int userId) => Schedule(() =>
{ {

View File

@ -76,6 +76,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
public void RemoveManagedClock(SpectatorPlayerClock clock) public void RemoveManagedClock(SpectatorPlayerClock clock)
{ {
playerClocks.Remove(clock); playerClocks.Remove(clock);
Logger.Log($"Removing managed clock from {nameof(SpectatorSyncManager)} ({playerClocks.Count} remain)");
clock.IsRunning = false; clock.IsRunning = false;
} }
@ -130,7 +131,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
} }
/// <summary> /// <summary>
/// Updates the catchup states of all player clocks clocks. /// Updates the catchup states of all player clocks.
/// </summary> /// </summary>
private void updatePlayerCatchup() private void updatePlayerCatchup()
{ {
@ -176,7 +177,9 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
/// </summary> /// </summary>
private void updateMasterState() private void updateMasterState()
{ {
MasterClockState newState = playerClocks.Any(s => !s.IsCatchingUp) ? MasterClockState.Synchronised : MasterClockState.TooFarAhead; // Clocks are removed as players complete the beatmap.
// Once there are no clocks we want to make sure the track plays out to the end.
MasterClockState newState = playerClocks.Count == 0 || playerClocks.Any(s => !s.IsCatchingUp) ? MasterClockState.Synchronised : MasterClockState.TooFarAhead;
if (masterState == newState) if (masterState == newState)
return; return;

View File

@ -135,6 +135,7 @@ namespace osu.Game.Screens.Spectate
case SpectatedUserState.Passed: case SpectatedUserState.Passed:
markReceivedAllFrames(userId); markReceivedAllFrames(userId);
PassGameplay(userId);
break; break;
case SpectatedUserState.Failed: case SpectatedUserState.Failed:
@ -233,6 +234,12 @@ namespace osu.Game.Screens.Spectate
/// <param name="spectatorGameplayState">The gameplay state.</param> /// <param name="spectatorGameplayState">The gameplay state.</param>
protected abstract void StartGameplay(int userId, SpectatorGameplayState spectatorGameplayState); protected abstract void StartGameplay(int userId, SpectatorGameplayState spectatorGameplayState);
/// <summary>
/// Fired when a user passes gameplay.
/// </summary>
/// <param name="userId">The user which passed.</param>
protected virtual void PassGameplay(int userId) { }
/// <summary> /// <summary>
/// Quits gameplay for a user. /// Quits gameplay for a user.
/// Thread safety is not guaranteed should be scheduled as required. /// Thread safety is not guaranteed should be scheduled as required.