Improved Texture update handling

This commit is contained in:
Flamefire committed 2013-05-10 13:37:55 +02:00
1 parent dd96b61cae
commit a2c1ee67ad
14 files changed
+157 -116

No files matched your search

+9 -7
View File
@@ -463,15 +463,17 @@ namespace Vocaluxe.Base
if (_Video != -1) if (_Video != -1)
{ {
float vtime; float vtime;
CVideo.GetFrame(_Video, ref _CurrentVideoTexture, CSound.GetPosition(_CurrentMusicStream), out vtime); if (CVideo.GetFrame(_Video, ref _CurrentVideoTexture, CSound.GetPosition(_CurrentMusicStream), out vtime))
if (_FadeTimer.ElapsedMilliseconds <= 3000L)
_CurrentVideoTexture.Color.A = _FadeTimer.ElapsedMilliseconds / 3000f;
else
{ {
_CurrentVideoTexture.Color.A = 1f; if (_FadeTimer.ElapsedMilliseconds <= 3000L)
_FadeTimer.Stop(); _CurrentVideoTexture.Color.A = _FadeTimer.ElapsedMilliseconds / 3000f;
else
{
_CurrentVideoTexture.Color.A = 1f;
_FadeTimer.Stop();
}
return _CurrentVideoTexture;
} }
return _CurrentVideoTexture;
} }
return null; return null;
} }
+7 -2
View File
@@ -160,9 +160,14 @@ namespace Vocaluxe.Base
return _Draw.EnqueueTexture(w, h, data); return _Draw.EnqueueTexture(w, h, data);
} }
public static bool UpdateTexture(CTexture texture, byte[] data) public static bool UpdateTexture(CTexture texture, int w, int h, byte[] data)
{ {
return _Draw.UpdateTexture(texture, data); return _Draw.UpdateTexture(texture, w, h, data);
}
public static bool UpdateOrAddTexture(ref CTexture texture, int w, int h, byte[] data)
{
return _Draw.UpdateOrAddTexture(ref texture, w, h, data);
} }
public static void RemoveTexture(ref CTexture texture) public static void RemoveTexture(ref CTexture texture)
+29 -23
View File
@@ -891,7 +891,7 @@ namespace Vocaluxe.Lib.Draw
bmp2.Dispose(); bmp2.Dispose();
} }
CTexture texture = new CTexture(bmp.Width, bmp.Height, w, h,true); CTexture texture = new CTexture(bmp.Width, bmp.Height, w, h, true);
return _AddTexture(texture, w, data); return _AddTexture(texture, w, data);
} }
@@ -924,12 +924,12 @@ namespace Vocaluxe.Lib.Draw
t = new Texture(_Device, texture.W2, texture.H2, 0, Usage.AutoGenerateMipMap, Format.A8R8G8B8, Pool.Managed); t = new Texture(_Device, texture.W2, texture.H2, 0, Usage.AutoGenerateMipMap, Format.A8R8G8B8, Pool.Managed);
//Lock the texture and fill it with the data //Lock the texture and fill it with the data
DataRectangle rect = t.LockRectangle(0, LockFlags.Discard); DataRectangle rect = t.LockRectangle(0, LockFlags.Discard);
int rowWidth = 4 * texture.W2; int rowWidth = 4 * w;
for (int i = 0; i + rowWidth <= data.Length; i += 4 * w) for (int i = 0; i + rowWidth <= data.Length; i += rowWidth)
{ {
rect.Data.Write(data, i, 4 * w); rect.Data.Write(data, i, rowWidth);
rect.Data.Position = rect.Data.Position - rowWidth; //Go to next row
rect.Data.Position += rect.Pitch; rect.Data.Position = rect.Data.Position - rowWidth + rect.Pitch;
} }
t.UnlockRectangle(0); t.UnlockRectangle(0);
} }
@@ -969,27 +969,39 @@ namespace Vocaluxe.Lib.Draw
/// Updates the data of a texture /// Updates the data of a texture
/// </summary> /// </summary>
/// <param name="texture">The texture to update</param> /// <param name="texture">The texture to update</param>
/// <param name="w"></param>
/// <param name="h"></param>
/// <param name="data">A byte array containing the new texture's data</param> /// <param name="data">A byte array containing the new texture's data</param>
/// <returns>True if succeeded</returns> /// <returns>True if succeeded</returns>
public bool UpdateTexture(CTexture texture, byte[] data) public bool UpdateTexture(CTexture texture, int w, int h, byte[] data)
{ {
if (!_TextureExists(texture)) //Check if texture exists and extend matches
if (!_TextureExists(texture) || texture.UsedWidth != w || texture.UsedHeight != h)
return false; return false;
lock (_MutexTexture) lock (_MutexTexture)
{ {
DataRectangle rect = _D3DTextures[texture.Index].LockRectangle(0, LockFlags.Discard); DataRectangle rect = _D3DTextures[texture.Index].LockRectangle(0, LockFlags.Discard);
int w = texture.OrigSize.Width; int rowWidth = 4 * w;
int rowWidth = 4 * texture.W2; for (int i = 0; i + rowWidth <= data.Length; i += rowWidth)
for (int i = 0; i + rowWidth <= data.Length; i += 4 * w)
{ {
rect.Data.Write(data, i, 4 * w); rect.Data.Write(data, i, rowWidth);
rect.Data.Position = rect.Data.Position - rowWidth; //Go to next row
rect.Data.Position += rect.Pitch; rect.Data.Position = rect.Data.Position - rowWidth + rect.Pitch;
} }
_D3DTextures[texture.Index].UnlockRectangle(0); _D3DTextures[texture.Index].UnlockRectangle(0);
} }
return true; return true;
} }
public bool UpdateOrAddTexture(ref CTexture texture, int w, int h, byte[] data)
{
if (!UpdateTexture(texture, w, h, data))
{
RemoveTexture(ref texture);
texture = AddTexture(w, h, data);
}
return true;
}
#endregion updating #endregion updating
/// <summary> /// <summary>
@@ -1288,15 +1300,9 @@ namespace Vocaluxe.Lib.Draw
CTexture texture; CTexture texture;
if (!_Textures.TryGetValue(q.Index, out texture)) if (!_Textures.TryGetValue(q.Index, out texture))
continue; continue;
if (q.Width == texture.OrigSize.Width && q.Height == texture.OrigSize.Height)
{ Texture t = _CreateTexture(texture, q.Width, q.Data);
texture.W2 = _CheckForNextPowerOf2(texture.OrigSize.Width); _D3DTextures[q.Index] = t;
texture.H2 = _CheckForNextPowerOf2(texture.OrigSize.Height);
Texture t = _CreateTexture(texture, q.Width, q.Data);
_D3DTextures[q.Index] = t;
}
else
CLog.LogError("Wrong texture size in queue!");
} }
} }
} }
+11 -1
View File
@@ -398,7 +398,7 @@ namespace Vocaluxe.Lib.Draw
} }
} }
public bool UpdateTexture(CTexture texture, byte[] data) public bool UpdateTexture(CTexture texture, int w, int h, byte[] data)
{ {
if (_TextureExists(texture)) if (_TextureExists(texture))
{ {
@@ -411,6 +411,16 @@ namespace Vocaluxe.Lib.Draw
return false; return false;
} }
public bool UpdateOrAddTexture(ref CTexture texture, int w, int h, byte[] data)
{
if (!UpdateTexture(texture, w, h, data))
{
RemoveTexture(ref texture);
texture = AddTexture(w, h, data);
}
return true;
}
public void DrawTexture(CTexture texture) public void DrawTexture(CTexture texture)
{ {
if (texture != null) if (texture != null)
+19 -11
View File
@@ -518,8 +518,8 @@ namespace Vocaluxe.Lib.Draw
public void CopyScreen(ref CTexture texture) public void CopyScreen(ref CTexture texture)
{ {
//Check for actual texture sizes! (W2/H2) as it may be up/downsized compared to OrigSize //Check for actual texture sizes as it may be downsized compared to OrigSize
if (!_TextureExists(texture) || texture.W2 != GetScreenWidth() || texture.H2 != GetScreenHeight()) if (!_TextureExists(texture) || texture.UsedWidth != GetScreenWidth() || texture.UsedHeight != GetScreenHeight())
{ {
RemoveTexture(ref texture); RemoveTexture(ref texture);
texture = CopyScreen(); texture = CopyScreen();
@@ -528,7 +528,7 @@ namespace Vocaluxe.Lib.Draw
{ {
GL.BindTexture(TextureTarget.Texture2D, texture.ID); GL.BindTexture(TextureTarget.Texture2D, texture.ID);
GL.CopyTexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, 0, 0, texture.OrigSize.Width, texture.OrigSize.Height); GL.CopyTexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, 0, 0, texture.UsedWidth, texture.UsedHeight);
GL.BindTexture(TextureTarget.Texture2D, 0); GL.BindTexture(TextureTarget.Texture2D, 0);
} }
@@ -831,9 +831,10 @@ namespace Vocaluxe.Lib.Draw
#endregion adding #endregion adding
#region updating #region updating
public bool UpdateTexture(CTexture texture, byte[] data) public bool UpdateTexture(CTexture texture, int w, int h, byte[] data)
{ {
if (!_TextureExists(texture)) //Check if texture exists and extend matches
if (!_TextureExists(texture) || texture.UsedWidth != w || texture.UsedHeight != h)
return false; return false;
if (_UsePBO) if (_UsePBO)
{ {
@@ -845,7 +846,7 @@ namespace Vocaluxe.Lib.Draw
GL.UnmapBuffer(BufferTarget.PixelUnpackBuffer); GL.UnmapBuffer(BufferTarget.PixelUnpackBuffer);
GL.BindTexture(TextureTarget.Texture2D, texture.ID); GL.BindTexture(TextureTarget.Texture2D, texture.ID);
GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, texture.OrigSize.Width, texture.OrigSize.Height, PixelFormat.Bgra, PixelType.UnsignedByte, IntPtr.Zero); GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, w, h, PixelFormat.Bgra, PixelType.UnsignedByte, IntPtr.Zero);
GL.BindTexture(TextureTarget.Texture2D, 0); GL.BindTexture(TextureTarget.Texture2D, 0);
GL.BindBuffer(BufferTarget.PixelUnpackBuffer, 0); GL.BindBuffer(BufferTarget.PixelUnpackBuffer, 0);
@@ -855,7 +856,7 @@ namespace Vocaluxe.Lib.Draw
GL.BindTexture(TextureTarget.Texture2D, texture.ID); GL.BindTexture(TextureTarget.Texture2D, texture.ID);
GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, texture.OrigSize.Width, texture.OrigSize.Height, PixelFormat.Bgra, PixelType.UnsignedByte, data); GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, w, h, PixelFormat.Bgra, PixelType.UnsignedByte, data);
//GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureParameterName.ClampToEdge); //GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureParameterName.ClampToEdge);
//GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureParameterName.ClampToEdge); //GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureParameterName.ClampToEdge);
@@ -869,6 +870,16 @@ namespace Vocaluxe.Lib.Draw
return true; return true;
} }
public bool UpdateOrAddTexture(ref CTexture texture, int w, int h, byte[] data)
{
if (!UpdateTexture(texture, w, h, data))
{
RemoveTexture(ref texture);
texture = AddTexture(w, h, data);
}
return true;
}
#endregion updating #endregion updating
public void RemoveTexture(ref CTexture texture) public void RemoveTexture(ref CTexture texture)
@@ -1172,10 +1183,7 @@ namespace Vocaluxe.Lib.Draw
if (!_Textures.TryGetValue(q.Index, out texture)) if (!_Textures.TryGetValue(q.Index, out texture))
continue; continue;
if (q.Width == texture.OrigSize.Width && q.Height == texture.OrigSize.Height) _CreateTexture(texture, q.Width, q.Height, q.Data);
_CreateTexture(texture, q.Width, q.Height, q.Data);
else
CLog.LogError("Wrong texture size in queue!");
} }
} }
} }
+2 -1
View File
@@ -43,7 +43,8 @@ namespace Vocaluxe.Lib.Draw
CTexture AddTexture(Bitmap bitmap); CTexture AddTexture(Bitmap bitmap);
CTexture AddTexture(int w, int h, byte[] data); CTexture AddTexture(int w, int h, byte[] data);
CTexture EnqueueTexture(int w, int h, byte[] data); CTexture EnqueueTexture(int w, int h, byte[] data);
bool UpdateTexture(CTexture texture, byte[] data); bool UpdateTexture(CTexture texture, int w, int h, byte[] data);
bool UpdateOrAddTexture(ref CTexture texture, int w, int h, byte[] data);
void RemoveTexture(ref CTexture texture); void RemoveTexture(ref CTexture texture);
// Basic Draw Methods // Basic Draw Methods
+3 -9
View File
@@ -323,7 +323,7 @@ namespace Vocaluxe.Lib.Video
_UploadNewFrame(ref frame); _UploadNewFrame(ref frame);
//EventDecode.Set(); //EventDecode.Set();
return true; return frame != null;
} }
if (Math.Abs(_SetTime - time) > float.Epsilon) if (Math.Abs(_SetTime - time) > float.Epsilon)
@@ -335,7 +335,7 @@ namespace Vocaluxe.Lib.Video
_UploadNewFrame(ref frame); _UploadNewFrame(ref frame);
videoTime = _CurrentVideoTime; videoTime = _CurrentVideoTime;
//EventDecode.Set(); //EventDecode.Set();
return true; return frame != null;
} }
return false; return false;
} }
@@ -661,13 +661,7 @@ namespace Vocaluxe.Lib.Video
if (num >= 0) if (num >= 0)
{ {
if (frame == null || _Width != frame.OrigSize.Width || _Height != frame.OrigSize.Height) CDraw.UpdateOrAddTexture(ref frame, _Width, _Height, _FrameBuffer[num].Data);
{
CDraw.RemoveTexture(ref frame);
frame = CDraw.AddTexture(_Width, _Height, _FrameBuffer[num].Data);
}
else
CDraw.UpdateTexture(frame, _FrameBuffer[num].Data);
lock (_MutexSyncSignals) lock (_MutexSyncSignals)
{ {
+2 -8
View File
@@ -84,7 +84,7 @@ namespace Vocaluxe.Lib.Video
videoTime = managedFrame.Videotime; videoTime = managedFrame.Videotime;
_UploadNewFrame(ref frame, ref managedFrame.Buffer, managedFrame.Width, managedFrame.Height); _UploadNewFrame(ref frame, ref managedFrame.Buffer, managedFrame.Width, managedFrame.Height);
return true; return frame != null;
} }
public bool Skip(int streamID, float start, float gap) public bool Skip(int streamID, float start, float gap)
@@ -121,13 +121,7 @@ namespace Vocaluxe.Lib.Video
{ {
if (data == null) if (data == null)
return; return;
if (frame == null || width != frame.OrigSize.Width || height != frame.OrigSize.Height || data.Length == 0) CDraw.UpdateOrAddTexture(ref frame, width, height, data);
{
CDraw.RemoveTexture(ref frame);
frame = CDraw.AddTexture(width, height, data);
}
else
CDraw.UpdateTexture(frame, data);
data = null; data = null;
} }
} }
+10
View File
@@ -41,7 +41,17 @@ namespace Vocaluxe.Lib.Video
int GetNumStreams(); int GetNumStreams();
float GetLength(int streamID); float GetLength(int streamID);
/// <summary>
///
/// </summary>
/// <param name="streamID"></param>
/// <param name="frame"></param>
/// <param name="time"></param>
/// <param name="videoTime"></param>
/// <returns>True if frame is valid</returns>
bool GetFrame(int streamID, ref CTexture frame, float time, out float videoTime); bool GetFrame(int streamID, ref CTexture frame, float time, out float videoTime);
bool Skip(int streamID, float start, float gap); bool Skip(int streamID, float start, float gap);
void SetLoop(int streamID, bool loop); void SetLoop(int streamID, bool loop);
void Pause(int streamID); void Pause(int streamID);
+26 -37
View File
@@ -41,29 +41,20 @@ namespace Vocaluxe.Lib.Webcam
public void Close() public void Close()
{ {
if (_Webcam != null) if (_Webcam == null)
{ return;
_Webcam.SignalToStop(); _Webcam.SignalToStop();
_Webcam.WaitForStop(); _Webcam.WaitForStop();
_Webcam.NewFrame -= _OnFrame; _Webcam.NewFrame -= _OnFrame;
_Data = new byte[1]; _Data = new byte[1];
}
} }
public bool GetFrame(ref CTexture frame) public bool GetFrame(ref CTexture frame)
{ {
if (_Webcam != null && _Width > 0 && _Height > 0 && _Data.Length == _Width * _Height * 4) lock (_MutexData)
{ {
lock (_MutexData) if (_Webcam != null && _Width > 0 && _Height > 0 && _Data.Length == _Width * _Height * 4)
{ CDraw.UpdateOrAddTexture(ref frame, _Width, _Height, _Data);
if (frame == null || _Width != frame.OrigSize.Width || _Height != frame.OrigSize.Height)
{
CDraw.RemoveTexture(ref frame);
frame = CDraw.AddTexture(_Width, _Height, _Data);
}
else
CDraw.UpdateTexture(frame, _Data);
}
} }
return false; return false;
} }
@@ -114,19 +105,18 @@ namespace Vocaluxe.Lib.Webcam
private void _OnFrame(object sender, NewFrameEventArgs e) private void _OnFrame(object sender, NewFrameEventArgs e)
{ {
if (!_Paused) if (_Paused)
return;
lock (_MutexData)
{ {
lock (_MutexData) if (_Width != e.Frame.Width || _Height != e.Frame.Height || _Data.Length != e.Frame.Width * e.Frame.Height * 4)
{ _Data = new byte[4 * e.Frame.Width * e.Frame.Height];
if (_Width != e.Frame.Width || _Height != e.Frame.Height || _Data.Length != e.Frame.Width * e.Frame.Height * 4)
_Data = new byte[4 * e.Frame.Width * e.Frame.Height];
_Width = e.Frame.Width; _Width = e.Frame.Width;
_Height = e.Frame.Height; _Height = e.Frame.Height;
BitmapData bitmapdata = e.Frame.LockBits(new Rectangle(0, 0, _Width, _Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb); BitmapData bitmapdata = e.Frame.LockBits(new Rectangle(0, 0, _Width, _Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
Marshal.Copy(bitmapdata.Scan0, _Data, 0, _Data.Length); Marshal.Copy(bitmapdata.Scan0, _Data, 0, _Data.Length);
e.Frame.UnlockBits(bitmapdata); e.Frame.UnlockBits(bitmapdata);
}
} }
} }
@@ -138,14 +128,13 @@ namespace Vocaluxe.Lib.Webcam
public void Start() public void Start()
{ {
if (_Webcam != null) if (_Webcam == null)
{ return;
_Webcam.NewFrame -= _OnFrame; _Webcam.NewFrame -= _OnFrame;
//Subscribe to NewFrame event //Subscribe to NewFrame event
_Webcam.NewFrame += _OnFrame; _Webcam.NewFrame += _OnFrame;
_Webcam.Start(); _Webcam.Start();
_Paused = false; _Paused = false;
}
} }
public void Stop() public void Stop()
+1 -1
View File
@@ -213,7 +213,7 @@ namespace Vocaluxe.Screens
if (paragraph[e] == null) if (paragraph[e] == null)
continue; continue;
string newLine = " " + paragraph[e]; string newLine = " " + paragraph[e];
CText text = GetNewText(75, lastY, -2, 30, -1, EAlignment.Left, EStyle.Bold, "Outline", new SColorF(1, 1, 1, 1), line); CText text = GetNewText(75, lastY, -2, 25, -1, EAlignment.Left, EStyle.Bold, "Outline", new SColorF(1, 1, 1, 1), line);
if (CFonts.GetTextBounds(text).Width < (CSettings.RenderW - 220)) if (CFonts.GetTextBounds(text).Width < (CSettings.RenderW - 220))
{ {
line += newLine; line += newLine;
+23 -3
View File
@@ -28,7 +28,7 @@ namespace VocaluxeLib.Draw
public SColorF Color = new SColorF(1f, 1f, 1f, 1f); public SColorF Color = new SColorF(1f, 1f, 1f, 1f);
private int _W2, _H2; private int _W2, _H2;
private bool _UseFullTexture; private readonly bool _UseFullTexture;
/// <summary> /// <summary>
/// Internal texture width (on device), a power of 2 if necessary /// Internal texture width (on device), a power of 2 if necessary
/// </summary> /// </summary>
@@ -38,7 +38,9 @@ namespace VocaluxeLib.Draw
set set
{ {
_W2 = value; _W2 = value;
if (!_UseFullTexture) if (_UseFullTexture)
WidthRatio = 1;
else
WidthRatio = (float)OrigSize.Width / _W2; WidthRatio = (float)OrigSize.Width / _W2;
} }
} }
@@ -51,7 +53,9 @@ namespace VocaluxeLib.Draw
set set
{ {
_H2 = value; _H2 = value;
if (!_UseFullTexture) if (_UseFullTexture)
HeightRatio = 1;
else
HeightRatio = (float)OrigSize.Height / _H2; HeightRatio = (float)OrigSize.Height / _H2;
} }
} }
@@ -65,6 +69,22 @@ namespace VocaluxeLib.Draw
/// </summary> /// </summary>
public float HeightRatio { get; private set; } public float HeightRatio { get; private set; }
/// <summary>
/// Actual texture space used in x direction
/// </summary>
public int UsedWidth
{
get { return (int)(_W2 * WidthRatio); }
}
/// <summary>
/// Actual texture space used in y direction
/// </summary>
public int UsedHeight
{
get { return (int)(_H2 * HeightRatio); }
}
/* /*
/// <summary> /// <summary>
/// Internal use. Specifies if full texture memory should be used /// Internal use. Specifies if full texture memory should be used
+3 -3
View File
@@ -204,7 +204,7 @@ namespace VocaluxeLib.Menu
private bool _DrawTexture() private bool _DrawTexture()
{ {
CTexture texture = CBase.Theme.GetSkinTexture(_Theme.TextureName, _PartyModeID); CTexture texture = CBase.Theme.GetSkinTexture(_Theme.TextureName, _PartyModeID);
if (texture.OrigSize.Height > 1) if (texture != null)
{ {
RectangleF bounds = new RectangleF(0f, 0f, CBase.Settings.GetRenderW(), CBase.Settings.GetRenderH()); RectangleF bounds = new RectangleF(0f, 0f, CBase.Settings.GetRenderW(), CBase.Settings.GetRenderH());
RectangleF rect; RectangleF rect;
@@ -219,7 +219,7 @@ namespace VocaluxeLib.Menu
private bool _DrawVideo() private bool _DrawVideo()
{ {
CTexture videoTexture = CBase.Theme.GetSkinVideoTexture(_Theme.VideoName, _PartyModeID); CTexture videoTexture = CBase.Theme.GetSkinVideoTexture(_Theme.VideoName, _PartyModeID);
if (videoTexture.OrigSize.Height > 1) if (videoTexture != null)
{ {
RectangleF bounds = new RectangleF(0f, 0f, CBase.Settings.GetRenderW(), CBase.Settings.GetRenderH()); RectangleF bounds = new RectangleF(0f, 0f, CBase.Settings.GetRenderW(), CBase.Settings.GetRenderH());
RectangleF rect; RectangleF rect;
@@ -234,7 +234,7 @@ namespace VocaluxeLib.Menu
private bool _DrawBackgroundMusicVideo() private bool _DrawBackgroundMusicVideo()
{ {
CTexture videoTexture = CBase.BackgroundMusic.GetVideoTexture(); CTexture videoTexture = CBase.BackgroundMusic.GetVideoTexture();
if (videoTexture.OrigSize.Height > 1) if (videoTexture != null)
{ {
RectangleF bounds = new RectangleF(0f, 0f, CBase.Settings.GetRenderW(), CBase.Settings.GetRenderH()); RectangleF bounds = new RectangleF(0f, 0f, CBase.Settings.GetRenderW(), CBase.Settings.GetRenderH());
RectangleF rect; RectangleF rect;
+12 -10
View File
@@ -438,19 +438,21 @@ namespace VocaluxeLib.Menu.SongMenu
if (_Actsong != _PreviewSelected) if (_Actsong != _PreviewSelected)
_SelectSong(_PreviewSelected); _SelectSong(_PreviewSelected);
if (_Streams.Count > 0 && _Video != -1) if (_Streams.Count <= 0 || _Video == -1)
return;
if (CBase.Video.IsFinished(_Video) || CBase.Sound.IsFinished(_Actsongstream))
{ {
if (CBase.Video.IsFinished(_Video) || CBase.Sound.IsFinished(_Actsongstream)) CBase.Video.Close(_Video);
{ _Video = -1;
CBase.Video.Close(_Video); return;
_Video = -1; }
return;
}
float time = CBase.Sound.GetPosition(_Actsongstream); float time = CBase.Sound.GetPosition(_Actsongstream);
float vtime; float vtime;
CBase.Video.GetFrame(_Video, ref _Vidtex, time, out vtime); if (CBase.Video.GetFrame(_Video, ref _Vidtex, time, out vtime))
{
if (_VideoFadeTimer.ElapsedMilliseconds <= 3000L) if (_VideoFadeTimer.ElapsedMilliseconds <= 3000L)
_Vidtex.Color.A = _VideoFadeTimer.ElapsedMilliseconds / 3000f; _Vidtex.Color.A = _VideoFadeTimer.ElapsedMilliseconds / 3000f;
else else