From 44dceaed60791d1fa480bc56c236e481ae9356de Mon Sep 17 00:00:00 2001 From: Flamefire Date: Tue, 11 Mar 2014 20:30:07 +0100 Subject: [PATCH] Add names to all threads --- ClientServerLib/ClientServerLib/CDiscover.cs | 2 +- Vocaluxe/Lib/Sound/CDirectSoundRecord.cs | 2 +- Vocaluxe/Lib/Sound/CGstreamerSharpAudio.cs | 31 ++++++++++++++++---- Vocaluxe/Lib/Sound/COpenALPlay.cs | 2 +- Vocaluxe/Lib/Sound/CPortAudioPlay.cs | 2 +- 5 files changed, 29 insertions(+), 10 deletions(-) diff --git a/ClientServerLib/ClientServerLib/CDiscover.cs b/ClientServerLib/ClientServerLib/CDiscover.cs index 9dd5aa3d..ecff0173 100644 --- a/ClientServerLib/ClientServerLib/CDiscover.cs +++ b/ClientServerLib/ClientServerLib/CDiscover.cs @@ -73,7 +73,7 @@ namespace ServerLib return; _DiscoverRunning = true; - _DiscoverThread = new Thread(() => _Discover(Timeout)); + _DiscoverThread = new Thread(() => _Discover(Timeout)) {Name = "Client discover"}; _OnDiscovered = OnDiscovered; _DiscoverThread.Start(); } diff --git a/Vocaluxe/Lib/Sound/CDirectSoundRecord.cs b/Vocaluxe/Lib/Sound/CDirectSoundRecord.cs index 15fcc291..a769fb5e 100644 --- a/Vocaluxe/Lib/Sound/CDirectSoundRecord.cs +++ b/Vocaluxe/Lib/Sound/CDirectSoundRecord.cs @@ -326,7 +326,7 @@ namespace Vocaluxe.Lib.Sound for (int i = 0; i < _Notifications.Count; i++) _WaitHandles[i] = _Notifications[i].Event; - _CaptureThread = new Thread(_DoCapture) {IsBackground = true}; + _CaptureThread = new Thread(_DoCapture) {Name="DirectSoundCapture",IsBackground = true}; _Running = true; _CaptureThread.Start(); diff --git a/Vocaluxe/Lib/Sound/CGstreamerSharpAudio.cs b/Vocaluxe/Lib/Sound/CGstreamerSharpAudio.cs index b8270b32..84e2226c 100644 --- a/Vocaluxe/Lib/Sound/CGstreamerSharpAudio.cs +++ b/Vocaluxe/Lib/Sound/CGstreamerSharpAudio.cs @@ -37,10 +37,10 @@ namespace Vocaluxe.Lib.Sound public bool Init() { #if ARCH_X86 - string path = ".\\x86\\gstreamer"; + const string path = ".\\x86\\gstreamer"; #endif #if ARCH_X64 - string path = ".\\x64\\gstreamer"; + const string path = ".\\x64\\gstreamer"; #endif SetDllDirectory(path); Application.Init(); @@ -213,9 +213,9 @@ namespace Vocaluxe.Lib.Sound private class CGstreamerSharpAudioStream { - private readonly Element _Element; + private Element _Element; private bool _Loop; - public volatile bool Closed; + public volatile bool Closed = true; public volatile bool Finished; private bool _Fading; @@ -240,7 +240,10 @@ namespace Vocaluxe.Lib.Sound var audioSinkBin = new Bin("Audiosink"); if (convert == null || audiosink == null) + { CLog.LogError("Could not create pipeline"); + return; + } audioSinkBin.Add(convert); audioSinkBin.Add(audiosink); @@ -249,21 +252,35 @@ namespace Vocaluxe.Lib.Sound GhostPad ghostpad = new GhostPad("sink", pad); if (pad == null) + { CLog.LogError("Could not create pads"); + return; + } if (!ghostpad.SetActive(true)) + { CLog.LogError("Could not link pads"); + return; + } if (!audioSinkBin.AddPad(ghostpad)) + { CLog.LogError("Could not add pad"); + return; + } _Element = ElementFactory.Make("playbin", "playbin"); if (_Element == null) + { CLog.LogError("Could not create playbin"); + return; + } _Element["audio-sink"] = audioSinkBin; _Element["flags"] = 1 << 1; _Element["uri"] = new Uri(media).AbsoluteUri; _Element.SetState(State.Paused); + Closed = false; //Enable stream + // Passing CLOCK_TIME_NONE here causes the pipeline to block for a long time so with // prescan enabled the pipeline will wait 500ms for stream to initialize and then continue // if it takes more than 500ms, duration queries will be performed asynchronously @@ -307,7 +324,7 @@ namespace Vocaluxe.Lib.Sound { Closed = true; Finished = true; - var t = new Thread(_TerminateStream); + var t = new Thread(_TerminateStream) {Name = "GSt Terminate"}; t.Start(); } } @@ -318,6 +335,7 @@ namespace Vocaluxe.Lib.Sound { _Element.SetState(State.Null); _Element.Dispose(); + _Element = null; } } @@ -388,7 +406,8 @@ namespace Vocaluxe.Lib.Sound { if (_Duration < 0 && !_QueryingDuration) { - var t = new Thread(_UpdateDuration); + _QueryingDuration = true; // Set this to avoid race conditions + var t = new Thread(_UpdateDuration) {Name = "GSt Update Duration"}; t.Start(); } return _Duration > 0 ? _Duration : -1; diff --git a/Vocaluxe/Lib/Sound/COpenALPlay.cs b/Vocaluxe/Lib/Sound/COpenALPlay.cs index caecc663..67891ffb 100644 --- a/Vocaluxe/Lib/Sound/COpenALPlay.cs +++ b/Vocaluxe/Lib/Sound/COpenALPlay.cs @@ -416,7 +416,7 @@ namespace Vocaluxe.Lib.Sound public COpenAlStream() { _Initialized = false; - _DecoderThread = new Thread(_Execute); + _DecoderThread = new Thread(_Execute) {Name = "OpenAL Decode"}; } public void Free(Closeproc closeProc, int streamID, Object closeMutex) diff --git a/Vocaluxe/Lib/Sound/CPortAudioPlay.cs b/Vocaluxe/Lib/Sound/CPortAudioPlay.cs index 6cbf218b..985d936e 100644 --- a/Vocaluxe/Lib/Sound/CPortAudioPlay.cs +++ b/Vocaluxe/Lib/Sound/CPortAudioPlay.cs @@ -401,7 +401,7 @@ namespace Vocaluxe.Lib.Sound public CPortAudioStream() { _SyncTimer = new CSyncTimer(0f, 1f, 0.02f); - _DecoderThread = new Thread(_Execute); + _DecoderThread = new Thread(_Execute) {Name = "PortAudio Decode"}; } ~CPortAudioStream()