Fix problems added by Pause (#2645)

* Disable Pause/Resume menu instead of trying to hide them

* Fix Resume menu being active before renderer starts

* Fix emulator not being able to close properly
This commit is contained in:
mpnico 2021-09-18 14:31:44 +02:00 committed by GitHub
parent d327e809c9
commit fe9d5a1981
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 42 additions and 15 deletions

View file

@ -395,6 +395,14 @@ namespace Ryujinx.Audio.Renderer.Server
Logger.Info?.Print(LogClass.AudioRenderer, $"Stopped renderer id {_sessionId}");
}
public void Disable()
{
lock (_lock)
{
_isActive = false;
}
}
public ResultCode Update(Memory<byte> output, Memory<byte> performanceOutput, ReadOnlyMemory<byte> input)
{
lock (_lock)

View file

@ -219,7 +219,21 @@ namespace Ryujinx.Audio.Renderer.Server
/// </summary>
public void StopSendingCommands()
{
_isRunning = false;
lock (_sessionLock)
{
foreach (AudioRenderSystem renderer in _sessions)
{
renderer?.Disable();
}
}
lock (_audioProcessorLock)
{
if (_isRunning)
{
StopLocked();
}
}
}
/// <summary>
@ -234,7 +248,7 @@ namespace Ryujinx.Audio.Renderer.Server
{
lock (_sessionLock)
{
foreach(AudioRenderSystem renderer in _sessions)
foreach (AudioRenderSystem renderer in _sessions)
{
renderer?.SendCommands();
}

View file

@ -386,11 +386,15 @@ namespace Ryujinx.HLE.HOS
_isDisposed = true;
// "Soft" stops AudioRenderer and AudioManager to avoid some sound between resume and stop.
AudioRendererManager.StopSendingCommands();
if (IsPaused)
{
AudioManager.StopUpdates();
TogglePauseEmulation(false);
AudioRendererManager.StopSendingCommands();
}
KProcess terminationProcess = new KProcess(KernelContext);
KThread terminationThread = new KThread(KernelContext);

View file

@ -214,6 +214,7 @@ namespace Ryujinx.Ui
_actionMenu.Sensitive = false;
_pauseEmulation.Sensitive = false;
_resumeEmulation.Sensitive = false;
if (ConfigurationState.Instance.Ui.GuiColumns.FavColumn) _favToggle.Active = true;
if (ConfigurationState.Instance.Ui.GuiColumns.IconColumn) _iconToggle.Active = true;
@ -1289,36 +1290,36 @@ namespace Ryujinx.Ui
UpdateGameMetadata(_emulationContext.Application.TitleIdText);
}
_pauseEmulation.Visible = true;
_pauseEmulation.Sensitive = false;
_resumeEmulation.Visible = false;
_resumeEmulation.Sensitive = false;
RendererWidget?.Exit();
}
private void PauseEmulation_Pressed(object sender, EventArgs args)
{
_pauseEmulation.Visible = false;
_resumeEmulation.Visible = true;
_pauseEmulation.Sensitive = false;
_resumeEmulation.Sensitive = true;
_emulationContext.System.TogglePauseEmulation(true);
}
private void ResumeEmulation_Pressed(object sender, EventArgs args)
{
_pauseEmulation.Visible = true;
_resumeEmulation.Visible = false;
_pauseEmulation.Sensitive = true;
_resumeEmulation.Sensitive = false;
_emulationContext.System.TogglePauseEmulation(false);
}
public void ActivatePauseMenu()
{
_pauseEmulation.Sensitive = true;
_resumeEmulation.Sensitive = false;
}
public void TogglePause()
{
_pauseEmulation.Visible ^= true;
_resumeEmulation.Visible ^= true;
_emulationContext.System.TogglePauseEmulation(_resumeEmulation.Visible);
_pauseEmulation.Sensitive ^= true;
_resumeEmulation.Sensitive ^= true;
_emulationContext.System.TogglePauseEmulation(_resumeEmulation.Sensitive);
}
private void Installer_File_Pressed(object o, EventArgs args)

View file

@ -305,7 +305,7 @@
</child>
<child>
<object class="GtkMenuItem" id="_resumeEmulation">
<property name="visible">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">Resume emulation</property>
<property name="label" translatable="yes">Resume Emulation</property>