Merge branch 'release-0.4.1' of github.com:Vocaluxe/Vocaluxe into develop

This commit is contained in:
Florian Küpper committed 2017-11-05 22:47:52 +01:00
commit 073158558e
6 files changed
+241 -3

No files matched your search

+26
View File
@@ -51,6 +51,7 @@ namespace Vocaluxe.Base
private static Task _PreviewStartHelperTask; private static Task _PreviewStartHelperTask;
private static int _PreviewStartWaitCounter; private static int _PreviewStartWaitCounter;
private const int _PreviewStartWaitMaxTries = 10; private const int _PreviewStartWaitMaxTries = 10;
private static readonly object _PreviewStartHelperTaskLock = new Object();
public static bool VideoEnabled public static bool VideoEnabled
{ {
@@ -255,12 +256,19 @@ namespace Vocaluxe.Base
public static void Update() public static void Update()
{ {
if (_PreviewStartHelperTask != null && ( _PreviewPlayer.Length > 0 || _PreviewStartWaitCounter++ >= _PreviewStartWaitMaxTries)) if (_PreviewStartHelperTask != null && ( _PreviewPlayer.Length > 0 || _PreviewStartWaitCounter++ >= _PreviewStartWaitMaxTries))
{
lock (_PreviewStartHelperTaskLock)
{
// Recheck the condition as it cloud have change before we got the lock
if (_PreviewStartHelperTask != null && (_PreviewPlayer.Length > 0 || _PreviewStartWaitCounter++ >= _PreviewStartWaitMaxTries))
{ {
_PreviewStartHelperTask.RunSynchronously(TaskScheduler.FromCurrentSynchronizationContext()); _PreviewStartHelperTask.RunSynchronously(TaskScheduler.FromCurrentSynchronizationContext());
_PreviewStartHelperTask.Dispose(); _PreviewStartHelperTask.Dispose();
_PreviewStartHelperTask = null; _PreviewStartHelperTask = null;
_PreviewStartWaitCounter = 0; _PreviewStartWaitCounter = 0;
} }
}
}
if (!IsPlaying) if (!IsPlaying)
return; return;
@@ -317,6 +325,13 @@ namespace Vocaluxe.Base
//Change song position only if song is changed or near to end //Change song position only if song is changed or near to end
if (songChanged || _CurPlayer.Position + 30 < _CurPlayer.Length) if (songChanged || _CurPlayer.Position + 30 < _CurPlayer.Length)
{ {
lock (_PreviewStartHelperTaskLock)
{
// Check if the old _PreviewStartHelperTask needs to disposed
if (_PreviewStartHelperTask != null)
{
_PreviewStartHelperTask.Dispose();
}
_PreviewStartHelperTask = new Task(() => _PreviewStartHelperTask = new Task(() =>
{ {
float length = _PreviewPlayer.Length; float length = _PreviewPlayer.Length;
@@ -333,12 +348,23 @@ namespace Vocaluxe.Base
_PreviewPlayer.Position = start; _PreviewPlayer.Position = start;
Play(); Play();
}); });
}
_CurPlayer = _PreviewPlayer; _CurPlayer = _PreviewPlayer;
} }
else else
{
if (_PreviewStartHelperTask != null)
{
lock (_PreviewStartHelperTaskLock)
{
// Recheck the condition as it cloud have change before we got the lock
if (_PreviewStartHelperTask != null)
{ {
_PreviewStartHelperTask.Dispose(); _PreviewStartHelperTask.Dispose();
_PreviewStartHelperTask = null; _PreviewStartHelperTask = null;
}
}
}
_PreviewPlayer.Position = _CurPlayer.Position; _PreviewPlayer.Position = _CurPlayer.Position;
_CurPlayer = _PreviewPlayer; _CurPlayer = _PreviewPlayer;
Play(); Play();
+21
View File
@@ -826,9 +826,16 @@ namespace Vocaluxe.Base
} }
public void Close(ref CVideoStream stream) public void Close(ref CVideoStream stream)
{
try
{ {
CVideo.Close(ref stream); CVideo.Close(ref stream);
} }
catch (NotSupportedException e)
{
CLog.LogError($"Clould not close the background video: {e.Message}");
}
}
public void SetLoop(CVideoStream stream, bool loop = true) public void SetLoop(CVideoStream stream, bool loop = true)
{ {
@@ -836,14 +843,28 @@ namespace Vocaluxe.Base
} }
public void Pause(CVideoStream stream) public void Pause(CVideoStream stream)
{
try
{ {
CVideo.Pause(stream); CVideo.Pause(stream);
} }
catch (NotSupportedException e)
{
CLog.LogError($"Clould not pause the background video: {e.Message}");
}
}
public void Resume(CVideoStream stream) public void Resume(CVideoStream stream)
{
try
{ {
CVideo.Resume(stream); CVideo.Resume(stream);
} }
catch (NotSupportedException e)
{
CLog.LogError($"Clould not resume the background video: {e.Message}");
}
}
} }
class CBsound : ISound class CBsound : ISound
+73
View File
@@ -15,6 +15,7 @@
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>. // along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
#endregion #endregion
using System;
using Vocaluxe.Lib.Video; using Vocaluxe.Lib.Video;
using VocaluxeLib; using VocaluxeLib;
@@ -61,6 +62,10 @@ namespace Vocaluxe.Base
public static CVideoStream Load(string videoFileName) public static CVideoStream Load(string videoFileName)
{ {
if (_VideoDecoder == null)
{
throw new NotSupportedException("_VideoDecoder is null (already closed?)");
}
return _VideoDecoder.Load(videoFileName); return _VideoDecoder.Load(videoFileName);
} }
@@ -73,41 +78,109 @@ namespace Vocaluxe.Base
public static float GetLength(CVideoStream stream) public static float GetLength(CVideoStream stream)
{ {
if (stream == null)
{
throw new ArgumentException("stream is null");
}
if (_VideoDecoder == null)
{
throw new NotSupportedException("_VideoDecoder is null (already closed?)");
}
return _VideoDecoder.GetLength(stream); return _VideoDecoder.GetLength(stream);
} }
public static bool GetFrame(CVideoStream stream, float time) public static bool GetFrame(CVideoStream stream, float time)
{ {
if (stream == null)
{
throw new ArgumentException("stream is null");
}
if (_VideoDecoder == null)
{
throw new NotSupportedException("_VideoDecoder is null (already closed?)");
}
return _VideoDecoder.GetFrame(stream, time); return _VideoDecoder.GetFrame(stream, time);
} }
public static bool Skip(CVideoStream stream, float start, float gap) public static bool Skip(CVideoStream stream, float start, float gap)
{ {
if (stream == null)
{
throw new ArgumentException("stream is null");
}
if (_VideoDecoder == null)
{
throw new NotSupportedException("_VideoDecoder is null (already closed?)");
}
return _VideoDecoder.Skip(stream, start, gap); return _VideoDecoder.Skip(stream, start, gap);
} }
public static void SetLoop(CVideoStream stream, bool loop) public static void SetLoop(CVideoStream stream, bool loop)
{ {
if (stream == null)
{
throw new ArgumentException("stream is null");
}
if (_VideoDecoder == null)
{
throw new NotSupportedException("_VideoDecoder is null (already closed?)");
}
_VideoDecoder.SetLoop(stream, loop); _VideoDecoder.SetLoop(stream, loop);
} }
public static void Pause(CVideoStream stream) public static void Pause(CVideoStream stream)
{ {
if (stream == null)
{
throw new ArgumentException("stream is null");
}
if (_VideoDecoder == null)
{
throw new NotSupportedException("_VideoDecoder is null (already closed?)");
}
_VideoDecoder.Pause(stream); _VideoDecoder.Pause(stream);
} }
public static void Resume(CVideoStream stream) public static void Resume(CVideoStream stream)
{ {
if (stream == null)
{
throw new ArgumentException("stream is null");
}
if (_VideoDecoder == null)
{
throw new NotSupportedException("_VideoDecoder is null (already closed?)");
}
_VideoDecoder.Resume(stream); _VideoDecoder.Resume(stream);
} }
public static bool Finished(CVideoStream stream) public static bool Finished(CVideoStream stream)
{ {
if (stream == null)
{
throw new ArgumentException("stream is null");
}
if (_VideoDecoder == null)
{
throw new NotSupportedException("_VideoDecoder is null (already closed?)");
}
return _VideoDecoder.Finished(stream); return _VideoDecoder.Finished(stream);
} }
public static void Update() public static void Update()
{ {
if (_VideoDecoder == null)
{
throw new NotSupportedException("_VideoDecoder is null (already closed?)");
}
_VideoDecoder.Update(); _VideoDecoder.Update();
} }
#endregion Interface #endregion Interface
@@ -16,6 +16,8 @@
#endregion #endregion
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Threading; using System.Threading;
using Vocaluxe.Base; using Vocaluxe.Base;
@@ -141,10 +143,14 @@ namespace Vocaluxe.Lib.Sound.Record.PortAudio
return false; return false;
foreach (IntPtr handle in _RecHandle) foreach (IntPtr handle in _RecHandle)
{
if (handle != IntPtr.Zero)
{ {
PortAudioSharp.PortAudio.Pa_StopStream(handle); PortAudioSharp.PortAudio.Pa_StopStream(handle);
PortAudioSharp.PortAudio.Pa_CloseStream(handle); PortAudioSharp.PortAudio.Pa_CloseStream(handle);
} }
}
_RecHandle = new IntPtr[_Devices.Count];
return true; return true;
} }
@@ -153,14 +159,18 @@ namespace Vocaluxe.Lib.Sound.Record.PortAudio
/// </summary> /// </summary>
public override void Close() public override void Close()
{ {
if (_RecHandle != null) if (_RecHandle != null && _RecHandle.Length > 0)
{ {
foreach (IntPtr handle in _RecHandle) foreach (IntPtr handle in _RecHandle)
{ {
if (handle != IntPtr.Zero) if (handle != IntPtr.Zero)
{
_PaHandle.CloseStream(handle); _PaHandle.CloseStream(handle);
} }
} }
_RecHandle = new IntPtr[_Devices.Count];
}
if (_PaHandle != null) if (_PaHandle != null)
{ {
_PaHandle.Close(); _PaHandle.Close();
@@ -429,7 +429,18 @@ namespace Vocaluxe.Lib.Video.Acinerella
private bool _CopyDecodedFrameToBuffer() private bool _CopyDecodedFrameToBuffer()
{ {
bool result; bool result;
var decoder = (SACDecoder)Marshal.PtrToStructure(_Videodecoder, typeof(SACDecoder)); SACDecoder decoder;
try
{
decoder = (SACDecoder)Marshal.PtrToStructure(_Videodecoder, typeof(SACDecoder));
}
catch (Exception e)
{
CLog.LogError("Couldn't copy the frame to the managed environment.", false, false, e);
return false;
}
if (decoder.Buffer != IntPtr.Zero) if (decoder.Buffer != IntPtr.Zero)
{ {
_LastDecodedTime = (float)decoder.Timecode; _LastDecodedTime = (float)decoder.Timecode;
+98 -1
View File
@@ -285,23 +285,120 @@ namespace Vocaluxe
try try
{ {
CController.Close(); CController.Close();
}
catch (Exception e)
{
CLog.LogError("Error during shutdown! (CController)", false, false, e);
}
try
{
CVocaluxeServer.Close(); CVocaluxeServer.Close();
}
catch (Exception e)
{
CLog.LogError("Error during shutdown! (CVocaluxeServer)", false, false, e);
}
try
{
CGraphics.Close(); CGraphics.Close();
}
catch (Exception e)
{
CLog.LogError("Error during shutdown! (CGraphics)", false, false, e);
}
try
{
CThemes.Close(); CThemes.Close();
}
catch (Exception e)
{
CLog.LogError("Error during shutdown! (CThemes)", false, false, e);
}
try
{
CCover.Close(); CCover.Close();
}
catch (Exception e)
{
CLog.LogError("Error during shutdown! (CCover)", false, false, e);
}
try
{
CFonts.Close(); CFonts.Close();
}
catch (Exception e)
{
CLog.LogError("Error during shutdown! (CFonts)", false, false, e);
}
try
{
CBackgroundMusic.Close(); CBackgroundMusic.Close();
}
catch (Exception e)
{
CLog.LogError("Error during shutdown! (CBackgroundMusic)", false, false, e);
}
try
{
CWebcam.Close(); CWebcam.Close();
}
catch (Exception e)
{
CLog.LogError("Error during shutdown! (CWebcam)", false, false, e);
}
try
{
CDataBase.Close(); CDataBase.Close();
}
catch (Exception e)
{
CLog.LogError("Error during shutdown! (CDataBase)", false, false, e);
}
try
{
CVideo.Close(); CVideo.Close();
}
catch (Exception e)
{
CLog.LogError("Error during shutdown! (CVideo)", false, false, e);
}
try
{
CRecord.Close(); CRecord.Close();
}
catch (Exception e)
{
CLog.LogError("Error during shutdown! (CRecord)", false, false, e);
}
try
{
CSound.Close(); CSound.Close();
}
catch (Exception e)
{
CLog.LogError("Error during shutdown! (CSound)", false, false, e);
}
try
{
CDraw.Close(); CDraw.Close();
} }
catch (Exception e) catch (Exception e)
{ {
CLog.LogError("Error during shutdown!", false, false, e); CLog.LogError("Error during shutdown! (CDraw)", false, false, e);
} }
GC.Collect(); // Do a GC run here before we close logs to have finalizers run GC.Collect(); // Do a GC run here before we close logs to have finalizers run
try try
{ {