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:
1 parent
46351eb207
commit
1ddcf765f3
1 file changed
+19
-42
@@ -316,56 +316,33 @@ namespace Vocaluxe.Base
|
||||
CSound.SetGlobalVolume(CConfig.PreviewMusicVolume);
|
||||
}
|
||||
|
||||
//Change song position only if song is changed or near to end
|
||||
bool songChanged = _CurPlayer.SongID != song.ID;
|
||||
if (!songChanged && _CurPlayer.Position + 30 < _CurPlayer.Length)
|
||||
return;
|
||||
|
||||
_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(() =>
|
||||
{
|
||||
float length = _PreviewPlayer.Length;
|
||||
if (length < 1)
|
||||
length = 30; // If length is unknow or invalid assume a length of 30s
|
||||
float length = _PreviewPlayer.Length;
|
||||
if (length < 1)
|
||||
length = 30; // If length is unknow or invalid assume a length of 30s
|
||||
|
||||
if (start < 0)
|
||||
start = (song.Preview.Source == EDataSource.None) ? length / 4f : song.Preview.StartTime;
|
||||
if (start > length - 5f)
|
||||
start = Math.Max(0f, Math.Min(length / 4f, length - 5f));
|
||||
if (start >= 0.5f)
|
||||
start -= 0.5f;
|
||||
if (start < 0)
|
||||
start = (song.Preview.Source == EDataSource.None) ? length / 4f : song.Preview.StartTime;
|
||||
if (start > length - 5f)
|
||||
start = Math.Max(0f, Math.Min(length / 4f, length - 5f));
|
||||
if (start >= 0.5f)
|
||||
start -= 0.5f;
|
||||
|
||||
_PreviewPlayer.Position = start;
|
||||
Play();
|
||||
});
|
||||
}
|
||||
_CurPlayer = _PreviewPlayer;
|
||||
_PreviewPlayer.Position = start;
|
||||
Play();
|
||||
});
|
||||
}
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
_CurPlayer = _PreviewPlayer;
|
||||
}
|
||||
|
||||
public static void StopPreview()
|
||||
@@ -460,4 +437,4 @@ namespace Vocaluxe.Base
|
||||
return _BGMusicFiles.Contains(element);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user