Change: Only touch the preview player if necessary

Complete change of LoadPreview() to prevent touching the preview player, if we don't want to change anything.
Maybe this change break something, but after 2 hours of testing with different settings, everything seems to work here.
This commit is contained in:
Stefan authored and GitHub committed 2020-01-25 08:33:11 +01:00
1 parent 46351eb207
commit 1ddcf765f3
1 file changed
+3 -26
+3 -26
View File
@@ -316,14 +316,13 @@ namespace Vocaluxe.Base
CSound.SetGlobalVolume(CConfig.PreviewMusicVolume); CSound.SetGlobalVolume(CConfig.PreviewMusicVolume);
} }
//Change song position only if song is changed or near to end
bool songChanged = _CurPlayer.SongID != song.ID; bool songChanged = _CurPlayer.SongID != song.ID;
if (!songChanged && _CurPlayer.Position + 30 < _CurPlayer.Length)
return;
_PreviewPlayer.Load(song); _PreviewPlayer.Load(song);
//Change song position only if song is changed or near to end
if (songChanged || _CurPlayer.Position + 30 < _CurPlayer.Length || _PreviewStartHelperTask == null)
{
lock (_PreviewStartHelperTaskLock) lock (_PreviewStartHelperTaskLock)
{ {
_PreviewStartHelperTask = new Task(() => _PreviewStartHelperTask = new Task(() =>
@@ -344,28 +343,6 @@ namespace Vocaluxe.Base
}); });
} }
_CurPlayer = _PreviewPlayer; _CurPlayer = _PreviewPlayer;
}
else
{
if (_PreviewStartHelperTask != null)
{
lock (_PreviewStartHelperTaskLock)
{
// Recheck the condition as it cloud have change before we got the lock
if (_PreviewStartHelperTask != null)
{
_PreviewStartHelperTask = null;
}
}
}
_PreviewPlayer.Position = _CurPlayer.Position;
_CurPlayer = _PreviewPlayer;
Play();
}
} }
public static void StopPreview() public static void StopPreview()