Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deadlock on linux hosts when exiting the game #845

Merged
merged 3 commits into from
Jun 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions osu.Framework/Audio/AudioManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class AudioManager : AudioCollectionManager<AdjustableAudioComponent>
/// <summary>
/// The thread audio operations (mainly Bass calls) are ran on.
/// </summary>
internal GameThread Thread;
internal AudioThread Thread;

private List<DeviceInfo> audioDevices = new List<DeviceInfo>();
private List<string> audioDeviceNames = new List<string>();
Expand Down Expand Up @@ -99,7 +99,7 @@ public AudioManager(ResourceStore<byte[]> trackStore, ResourceStore<byte[]> samp
sampleStore.AddExtension(@"wav");
sampleStore.AddExtension(@"mp3");

Thread = new GameThread(Update, @"Audio");
Thread = new AudioThread(Update, @"Audio");
Thread.Start();

scheduler.Add(() =>
Expand Down
22 changes: 22 additions & 0 deletions osu.Framework/Threading/AudioThread.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE

using System;

namespace osu.Framework.Threading
{
public class AudioThread : GameThread
{
public AudioThread(Action onNewFrame, string threadName)
: base(onNewFrame, threadName)
{
}

public override void Exit()
{
base.Exit();

ManagedBass.Bass.Free();
}
}
}
2 changes: 1 addition & 1 deletion osu.Framework/Threading/GameThread.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public double InactiveHz

public bool Running => Thread.IsAlive;

public void Exit() => exitRequested = true;
public virtual void Exit() => exitRequested = true;

private volatile bool exitRequested;

Expand Down
1 change: 1 addition & 0 deletions osu.Framework/osu.Framework.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@
<Compile Include="Graphics\UserInterface\CircularProgressDrawNode.cs" />
<Compile Include="Graphics\Containers\TextFlowContainer.cs" />
<Compile Include="Graphics\UserInterface\CircularProgress.cs" />
<Compile Include="Threading\AudioThread.cs" />
</ItemGroup>
<ItemGroup>
<None Include="..\osu-framework.licenseheader">
Expand Down