1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-13 16:13:34 +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;
/// <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>
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);
});
protected override void FailGameplay(int userId)
protected override void FailGameplay(int userId) => Schedule(() =>
{
// 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(() =>
{

View File

@ -76,6 +76,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
public void RemoveManagedClock(SpectatorPlayerClock clock)
{
playerClocks.Remove(clock);
Logger.Log($"Removing managed clock from {nameof(SpectatorSyncManager)} ({playerClocks.Count} remain)");
clock.IsRunning = false;
}
@ -130,7 +131,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
}
/// <summary>
/// Updates the catchup states of all player clocks clocks.
/// Updates the catchup states of all player clocks.
/// </summary>
private void updatePlayerCatchup()
{
@ -176,7 +177,9 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
/// </summary>
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)
return;

View File

@ -135,6 +135,7 @@ namespace osu.Game.Screens.Spectate
case SpectatedUserState.Passed:
markReceivedAllFrames(userId);
PassGameplay(userId);
break;
case SpectatedUserState.Failed:
@ -233,6 +234,12 @@ namespace osu.Game.Screens.Spectate
/// <param name="spectatorGameplayState">The gameplay state.</param>
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>
/// Quits gameplay for a user.
/// Thread safety is not guaranteed should be scheduled as required.