Try to fix exceptions while closing Vocaluxe (during closing bg video) (may fixes #320)
This commit is contained in:
1 parent
3e0eec8294
commit
a92353c9a2
3 files changed
+110
-6
No files matched your search
+24
-3
@@ -822,7 +822,14 @@ namespace Vocaluxe.Base
|
||||
|
||||
public void Close(ref CVideoStream stream)
|
||||
{
|
||||
CVideo.Close(ref stream);
|
||||
try
|
||||
{
|
||||
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)
|
||||
@@ -832,12 +839,26 @@ namespace Vocaluxe.Base
|
||||
|
||||
public void Pause(CVideoStream stream)
|
||||
{
|
||||
CVideo.Pause(stream);
|
||||
try
|
||||
{
|
||||
CVideo.Pause(stream);
|
||||
}
|
||||
catch (NotSupportedException e)
|
||||
{
|
||||
CLog.LogError($"Clould not pause the background video: {e.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
public void Resume(CVideoStream stream)
|
||||
{
|
||||
CVideo.Resume(stream);
|
||||
try
|
||||
{
|
||||
CVideo.Resume(stream);
|
||||
}
|
||||
catch (NotSupportedException e)
|
||||
{
|
||||
CLog.LogError($"Clould not resume the background video: {e.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using Vocaluxe.Lib.Video;
|
||||
using VocaluxeLib;
|
||||
|
||||
@@ -61,6 +62,10 @@ namespace Vocaluxe.Base
|
||||
|
||||
public static CVideoStream Load(string videoFileName)
|
||||
{
|
||||
if (_VideoDecoder == null)
|
||||
{
|
||||
throw new NotSupportedException("_VideoDecoder is null (already closed?)");
|
||||
}
|
||||
return _VideoDecoder.Load(videoFileName);
|
||||
}
|
||||
|
||||
@@ -73,41 +78,109 @@ namespace Vocaluxe.Base
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public static void Update()
|
||||
{
|
||||
if (_VideoDecoder == null)
|
||||
{
|
||||
throw new NotSupportedException("_VideoDecoder is null (already closed?)");
|
||||
}
|
||||
|
||||
_VideoDecoder.Update();
|
||||
}
|
||||
#endregion Interface
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using Vocaluxe.Base;
|
||||
@@ -142,9 +144,13 @@ namespace Vocaluxe.Lib.Sound.Record.PortAudio
|
||||
|
||||
foreach (IntPtr handle in _RecHandle)
|
||||
{
|
||||
PortAudioSharp.PortAudio.Pa_StopStream(handle);
|
||||
PortAudioSharp.PortAudio.Pa_CloseStream(handle);
|
||||
if (handle != IntPtr.Zero)
|
||||
{
|
||||
PortAudioSharp.PortAudio.Pa_StopStream(handle);
|
||||
PortAudioSharp.PortAudio.Pa_CloseStream(handle);
|
||||
}
|
||||
}
|
||||
_RecHandle = new IntPtr[_Devices.Count];
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -153,13 +159,17 @@ namespace Vocaluxe.Lib.Sound.Record.PortAudio
|
||||
/// </summary>
|
||||
public override void Close()
|
||||
{
|
||||
if (_RecHandle != null)
|
||||
if (_RecHandle != null && _RecHandle.Length > 0)
|
||||
{
|
||||
foreach (IntPtr handle in _RecHandle)
|
||||
{
|
||||
if (handle != IntPtr.Zero)
|
||||
{
|
||||
_PaHandle.CloseStream(handle);
|
||||
}
|
||||
}
|
||||
|
||||
_RecHandle = new IntPtr[_Devices.Count];
|
||||
}
|
||||
if (_PaHandle != null)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user