diff --git a/Output/x64/acinerella.dll b/Output/x64/acinerella.dll index 4fa95785..e851fd01 100644 Binary files a/Output/x64/acinerella.dll and b/Output/x64/acinerella.dll differ diff --git a/Output/x64/avcodec-54.dll b/Output/x64/avcodec-54.dll index 37ff648d..ca074e7c 100644 Binary files a/Output/x64/avcodec-54.dll and b/Output/x64/avcodec-54.dll differ diff --git a/Output/x64/avformat-54.dll b/Output/x64/avformat-54.dll index 406d4c1f..40521b17 100644 Binary files a/Output/x64/avformat-54.dll and b/Output/x64/avformat-54.dll differ diff --git a/Output/x64/avutil-51.dll b/Output/x64/avutil-51.dll index 638b40c5..5f8cdf7d 100644 Binary files a/Output/x64/avutil-51.dll and b/Output/x64/avutil-51.dll differ diff --git a/Output/x64/swscale-2.dll b/Output/x64/swscale-2.dll index 2649979b..dcc41fd3 100644 Binary files a/Output/x64/swscale-2.dll and b/Output/x64/swscale-2.dll differ diff --git a/Output/x86/acinerella.dll b/Output/x86/acinerella.dll index 29a05b55..a39e3501 100644 Binary files a/Output/x86/acinerella.dll and b/Output/x86/acinerella.dll differ diff --git a/Output/x86/avcodec-54.dll b/Output/x86/avcodec-54.dll index 1d56751b..97d7f850 100644 Binary files a/Output/x86/avcodec-54.dll and b/Output/x86/avcodec-54.dll differ diff --git a/Output/x86/avformat-54.dll b/Output/x86/avformat-54.dll index 76385c1e..7328c561 100644 Binary files a/Output/x86/avformat-54.dll and b/Output/x86/avformat-54.dll differ diff --git a/Output/x86/avutil-51.dll b/Output/x86/avutil-51.dll index 6117ea73..5ab61687 100644 Binary files a/Output/x86/avutil-51.dll and b/Output/x86/avutil-51.dll differ diff --git a/Output/x86/swscale-2.dll b/Output/x86/swscale-2.dll index 50d699f1..afa902a0 100644 Binary files a/Output/x86/swscale-2.dll and b/Output/x86/swscale-2.dll differ diff --git a/Vocaluxe/Base/CBackgroundMusic.cs b/Vocaluxe/Base/CBackgroundMusic.cs index 6b49ec98..31acd203 100644 --- a/Vocaluxe/Base/CBackgroundMusic.cs +++ b/Vocaluxe/Base/CBackgroundMusic.cs @@ -156,6 +156,9 @@ namespace Vocaluxe.Base public static void Play() { + if (_Playing) + return; + if (CConfig.BackgroundMusic == EOffOn.TR_CONFIG_ON) { if (_AllFileNames.Count > 0) @@ -181,6 +184,9 @@ namespace Vocaluxe.Base public static void Stop() { + if (!_Playing) + return; + if (_VideoEnabled && _Video != -1) { CVideo.VdClose(_Video); @@ -195,6 +201,9 @@ namespace Vocaluxe.Base public static void Pause() { + if (!_Playing) + return; + if (_VideoEnabled && _Video != -1) { CVideo.VdPause(_Video); diff --git a/Vocaluxe/Base/CDataBase.cs b/Vocaluxe/Base/CDataBase.cs index e1040bf8..53ef0cc8 100644 --- a/Vocaluxe/Base/CDataBase.cs +++ b/Vocaluxe/Base/CDataBase.cs @@ -797,10 +797,16 @@ namespace Vocaluxe.Base data.id = Sqlite3.sqlite3_column_int(Stmt, 0); byte[] bytes = Sqlite3.sqlite3_column_rawbytes(Stmt, 1); - data.str1 = UTF8.GetString(Encoding.Convert(CP1252, UTF8, bytes)); + if (bytes != null) + data.str1 = UTF8.GetString(Encoding.Convert(CP1252, UTF8, bytes)); + else + data.str1 = "Someone"; bytes = Sqlite3.sqlite3_column_rawbytes(Stmt, 2); - data.str2 = UTF8.GetString(Encoding.Convert(CP1252, UTF8, bytes)); + if (bytes != null) + data.str2 = UTF8.GetString(Encoding.Convert(CP1252, UTF8, bytes)); + else + data.str2 = "Someone"; songs.Add(data); } @@ -832,7 +838,10 @@ namespace Vocaluxe.Base data.id = Sqlite3.sqlite3_column_int(Stmt, 0); byte[] bytes = Sqlite3.sqlite3_column_rawbytes(Stmt, 1); - data.str1 = UTF8.GetString(Encoding.Convert(CP1252, UTF8, bytes)); + if (bytes != null) + data.str1 = UTF8.GetString(Encoding.Convert(CP1252, UTF8, bytes)); + else + data.str1 = "Someone"; if (dateExists) data.ticks = UnixTimeToTicks(Sqlite3.sqlite3_column_int(Stmt, 2)); diff --git a/Vocaluxe/Base/CSettings.cs b/Vocaluxe/Base/CSettings.cs index 67359b9b..6fd9414e 100644 --- a/Vocaluxe/Base/CSettings.cs +++ b/Vocaluxe/Base/CSettings.cs @@ -47,7 +47,7 @@ namespace Vocaluxe.Base public const int iVersionSub = 0; // patches public const ERevision VersionRevision = ERevision.Alpha; - public const int iBuild = 63; // Increase on every published version! Never Reset! + public const int iBuild = 65; // Increase on every published version! Never Reset! public const int iDatabaseHighscoreVersion = 1; public const int iDatabaseCoverVersion = 1; diff --git a/Vocaluxe/Base/CVideo.cs b/Vocaluxe/Base/CVideo.cs index 496e76b1..718222b4 100644 --- a/Vocaluxe/Base/CVideo.cs +++ b/Vocaluxe/Base/CVideo.cs @@ -1,5 +1,7 @@ using System; using System.Collections.Generic; +using System.Diagnostics; +using System.Drawing; using System.Text; using Vocaluxe.Lib.Draw; @@ -95,4 +97,100 @@ namespace Vocaluxe.Base #endregion VideoDecoder } + + class VideoPlayer + { + private STexture _VideoTexture; + private int _VideoStream; + private Stopwatch _VideoTimer; + private bool _Finished; + private bool _Loaded; + + public bool IsFinished + { + get { return _Finished || !_Loaded; } + } + + public bool Loop + { + set { CVideo.VdSetLoop(_VideoStream, value); } + } + + public VideoPlayer() + { + _VideoTimer = new Stopwatch(); + _VideoTexture = new STexture(-1); + _Finished = false; + _Loaded = false; + } + + public void Load(string VideoName) + { + _VideoStream = CVideo.VdLoad(CTheme.GetVideoFilePath(VideoName)); + _Loaded = true; + } + + public void Start() + { + _VideoTimer.Reset(); + _Finished = false; + //CVideo.VdSkip(_VideoStream, 0f, 0f); + _VideoTimer.Start(); + } + + public void Pause() + { + _VideoTimer.Stop(); + } + + public void Resume() + { + _VideoTimer.Start(); + } + + public void Draw() + { + if (!_Finished) + { + + float VideoTime = _VideoTimer.ElapsedMilliseconds / 1000f; + _Finished = CVideo.VdFinished(_VideoStream); + + STexture tex = new STexture(-1); + tex.height = 0f; + CVideo.VdGetFrame(_VideoStream, ref tex, VideoTime, ref VideoTime); + + if (tex.height > 0) + { + CDraw.RemoveTexture(ref _VideoTexture); + _VideoTexture = tex; + } + } + RectangleF bounds = new RectangleF(0f, 0f, CSettings.iRenderW, CSettings.iRenderH); + RectangleF rect = new RectangleF(0f, 0f, _VideoTexture.width, _VideoTexture.height); + CHelper.SetRect(bounds, ref rect, rect.Width / rect.Height, EAspect.Crop); + + CDraw.DrawTexture(_VideoTexture, new SRectF(rect.X, rect.Y, rect.Width, rect.Height, CSettings.zFar / 4)); + } + + public void PreLoad() + { + float VideoTime = 0f; + while (_VideoTexture.index == -1 && VideoTime < 1f) + { + float dummy = 0f; + CVideo.VdGetFrame(_VideoStream, ref _VideoTexture, 0, ref dummy); + VideoTime += 0.05f; + } + } + + public void Close() + { + CVideo.VdClose(_VideoStream); + CDraw.RemoveTexture(ref _VideoTexture); + _Loaded = false; + _Finished = false; + _VideoTimer.Reset(); + } + } } diff --git a/Vocaluxe/Lib/Song/CSong.cs b/Vocaluxe/Lib/Song/CSong.cs index dce672c1..03d69a0f 100644 --- a/Vocaluxe/Lib/Song/CSong.cs +++ b/Vocaluxe/Lib/Song/CSong.cs @@ -389,9 +389,9 @@ namespace Vocaluxe.Lib.Song TempC = (char)sr.Read(); } while ((TempC.CompareTo(':') != 0) && (TempC.CompareTo('F') != 0) && (TempC.CompareTo('*') != 0) && (TempC.CompareTo('P') != 0)); - FileLineNo++; while (!sr.EndOfStream && (TempC.CompareTo('E') != 0)) { + FileLineNo++; if (TempC.CompareTo('P') == 0) { char chr = (char)sr.Read(); @@ -466,7 +466,7 @@ namespace Vocaluxe.Lib.Song { c = sr.Read(); TempC = (char)c; - } while ((TempC.CompareTo('E') != 0) && !sr.EndOfStream && (c == 19 || c == 16 || c == 13)); + } while ((TempC.CompareTo('E') != 0) && !sr.EndOfStream && (c == 19 || c == 16 || c == 13 || c==10)); } foreach(CLines lines in this.Notes.Lines) { diff --git a/Vocaluxe/Lib/Sound/CPortAudioPlay.cs b/Vocaluxe/Lib/Sound/CPortAudioPlay.cs index ad2122f0..6c7ebc7c 100644 --- a/Vocaluxe/Lib/Sound/CPortAudioPlay.cs +++ b/Vocaluxe/Lib/Sound/CPortAudioPlay.cs @@ -422,10 +422,10 @@ namespace Vocaluxe.Lib.Sound private Thread _DecoderThread; - AutoResetEvent EventDecode = new AutoResetEvent(false); + private AutoResetEvent EventDecode = new AutoResetEvent(false); - Object MutexData = new Object(); - Object MutexSyncSignals = new Object(); + private Object _LockData = new Object(); + private Object _LockSyncSignals = new Object(); public PortAudioStream() { @@ -456,7 +456,7 @@ namespace Vocaluxe.Lib.Sound { get { - lock (MutexData) + lock (_LockData) { return _NoMoreData && _data.BytesNotRead == 0L; } @@ -468,7 +468,7 @@ namespace Vocaluxe.Lib.Sound get { return _Volume * 100f; } set { - lock (MutexData) + lock (_LockData) { _Volume = value / 100f; if (_Volume < 0f) @@ -484,7 +484,7 @@ namespace Vocaluxe.Lib.Sound { get { - lock (MutexData) + lock (_LockData) { if (Finished) _SyncTimer.Pause(); @@ -500,7 +500,7 @@ namespace Vocaluxe.Lib.Sound set { _Paused = value; - lock (MutexSyncSignals) + lock (_LockData) { if (_Paused) _SyncTimer.Pause(); @@ -615,12 +615,13 @@ namespace Vocaluxe.Lib.Sound outputParams.sampleFormat = PortAudio.PaSampleFormat.paInt16; outputParams.suggestedLatency = _outputDeviceInfo.defaultLowOutputLatency; + uint bufsize = (uint)CConfig.AudioBufferSize; errorCheck("OpenDefaultStream", PortAudio.Pa_OpenStream( out _Ptr, IntPtr.Zero, ref outputParams, format.SamplesPerSecond, - (uint)CConfig.AudioBufferSize, + bufsize, PortAudio.PaStreamFlags.paNoFlag, _paStreamCallback, data)); @@ -645,7 +646,7 @@ namespace Vocaluxe.Lib.Sound public bool Skip(float Time) { - lock (MutexSyncSignals) + lock (_LockSyncSignals) { _SetStart = Time; _SetSkip = true; @@ -658,7 +659,7 @@ namespace Vocaluxe.Lib.Sound #region Threading private void DoSkip() { - lock (MutexData) + lock (_LockData) { _Decoder.SetPosition(_Start); _CurrentTime = _Start; @@ -677,7 +678,7 @@ namespace Vocaluxe.Lib.Sound { if (EventDecode.WaitOne(10)) { - lock (MutexSyncSignals) + lock (_LockSyncSignals) { if (_SetSkip) { @@ -724,7 +725,7 @@ namespace Vocaluxe.Lib.Sound byte[] Buffer; bool DoIt = false; - lock (MutexData) + lock (_LockData) { if (!_skip && BUFSIZE - 10000L > _data.BytesNotRead) DoIt = true; @@ -739,7 +740,7 @@ namespace Vocaluxe.Lib.Sound { if (_Loop) { - lock (MutexSyncSignals) + lock (_LockSyncSignals) { _CurrentTime = 0f; _Start = 0f; @@ -754,7 +755,7 @@ namespace Vocaluxe.Lib.Sound return; } - lock (MutexData) + lock (_LockData) { _data.Write(Buffer); _TimeCode = Timecode; @@ -804,7 +805,7 @@ namespace Vocaluxe.Lib.Sound return PortAudio.PaStreamCallbackResult.paContinue; } - lock (MutexData) + lock (_LockData) { if (_NoMoreData || _data.BytesNotRead >= buf.Length) { diff --git a/Vocaluxe/Lib/Video/Acinerella/acinerella.c b/Vocaluxe/Lib/Video/Acinerella/acinerella.c index c5b23ef7..3550bc07 100644 --- a/Vocaluxe/Lib/Video/Acinerella/acinerella.c +++ b/Vocaluxe/Lib/Video/Acinerella/acinerella.c @@ -167,21 +167,6 @@ static int64_t io_seek(void *opaque, int64_t pos, int whence) return -1; } -//uint64_t global_video_pkt_pts = AV_NOPTS_VALUE; - -int ac_get_buffer(struct AVCodecContext *c, AVFrame *pic) { - int ret = avcodec_default_get_buffer(c, pic); - uint64_t *pts = av_malloc(sizeof(uint64_t)); - *pts = AV_NOPTS_VALUE; - pic->opaque = pts; - return ret; -} - -void ac_release_buffer(struct AVCodecContext *c, AVFrame *pic){ - if (pic) av_freep(&pic->opaque); - avcodec_default_release_buffer(c, pic); -} - lp_ac_proberesult CALL_CONVT ac_probe_input_buffer( void* buf, int bufsize, @@ -533,7 +518,10 @@ void* ac_create_video_decoder(lp_ac_instance pacInstance, lp_ac_stream_info info if (!(pDecoder->pCodec = avcodec_find_decoder(pDecoder->pCodecCtx->codec_id))) { return NULL; //Codec could not have been found } - + + pDecoder->pCodecCtx->thread_count = 1; //this is for HT CPUs, it should be + // tested if there is a better solution + //Open codec if (avcodec_open2(pDecoder->pCodecCtx, pDecoder->pCodec, NULL) < 0) { return NULL; //Codec could not have been opened @@ -635,36 +623,34 @@ double ac_sync_video(lp_ac_package pPackage, lp_ac_decoder pDec, AVFrame *src_fr return pts; } -int ac_decode_video_package(lp_ac_package pPackage, lp_ac_video_decoder pDecoder, lp_ac_decoder pDec) { - if (((lp_ac_package_data)pPackage)->ffpackage.size <= 0) - return 0; - +int ac_decode_video_package(lp_ac_package pPackage, lp_ac_video_decoder pDecoder, lp_ac_decoder pDec) +{ int finished = 0; double pts = 0; + int len = 0; + + AVPacket pkt_tmp = ((lp_ac_package_data)pPackage)->ffpackage; + + while (pkt_tmp.size > 0) { + len = avcodec_decode_video2( + pDecoder->pCodecCtx, pDecoder->pFrame, + &finished, &pkt_tmp); + + if (len < 0) { + return 0; + } + pkt_tmp.size -= len; + pkt_tmp.data += len; + } + + /* avcodec_decode_video2( pDecoder->pCodecCtx, pDecoder->pFrame, &finished, &(((lp_ac_package_data)pPackage)->ffpackage)); + */ - if (finished) { - if(((lp_ac_package_data)pPackage)->ffpackage.dts == AV_NOPTS_VALUE && - *(uint64_t*)pDecoder->pFrame->opaque != AV_NOPTS_VALUE ){ - pts = *(uint64_t*)pDecoder->pFrame->opaque; - } else if(((lp_ac_package_data)pPackage)->ffpackage.dts != AV_NOPTS_VALUE){ - pts = ((lp_ac_package_data)pPackage)->ffpackage.dts; - } else { - pts = 0; - } - - if(((lp_ac_data)pDec->pacInstance)->pFormatCtx->streams[pPackage->stream_index]->start_time != AV_NOPTS_VALUE){ - pts -= ((lp_ac_data)pDec->pacInstance)->pFormatCtx->streams[pPackage->stream_index]->start_time; - } - - pts *= av_q2d(((lp_ac_data)pDec->pacInstance)->pFormatCtx->streams[pPackage->stream_index]->time_base); - - pts = ac_sync_video(pPackage, pDec, pDecoder->pFrame, pts); - pDec->timecode = pts; - + if (finished != 0) { pDecoder->pSwsCtx = sws_getCachedContext(pDecoder->pSwsCtx, pDecoder->pCodecCtx->width, pDecoder->pCodecCtx->height, pDecoder->pCodecCtx->pix_fmt, pDecoder->pCodecCtx->width, pDecoder->pCodecCtx->height, convert_pix_format(pDecoder->decoder.pacInstance->output_format), @@ -678,6 +664,24 @@ int ac_decode_video_package(lp_ac_package pPackage, lp_ac_video_decoder pDecoder pDecoder->pCodecCtx->height, pDecoder->pFrameRGB->data, pDecoder->pFrameRGB->linesize); + + + if(pkt_tmp.dts == AV_NOPTS_VALUE && + *(uint64_t*)pDecoder->pFrame->opaque != AV_NOPTS_VALUE ){ + pts = *(uint64_t*)pDecoder->pFrame->opaque; + } else if(pkt_tmp.dts != AV_NOPTS_VALUE){ + pts = pkt_tmp.dts; + } + + if(((lp_ac_data)pDec->pacInstance)->pFormatCtx->streams[pPackage->stream_index]->start_time != AV_NOPTS_VALUE){ + pts -= ((lp_ac_data)pDec->pacInstance)->pFormatCtx->streams[pPackage->stream_index]->start_time; + } + + pts *= av_q2d(((lp_ac_data)pDec->pacInstance)->pFormatCtx->streams[pPackage->stream_index]->time_base); + + pts = ac_sync_video(pPackage, pDec, pDecoder->pFrame, pts); + pDec->timecode = pts; + return 1; } return 0; @@ -795,11 +799,23 @@ int CALL_CONVT ac_drop_decode_package(lp_ac_package pPackage, lp_ac_decoder pDec int ac_drop_decode_video_package(lp_ac_package pPackage, lp_ac_video_decoder pDecoder, lp_ac_decoder pDec) { int finished; double pts; + int len = 0; - avcodec_decode_video2( - pDecoder->pCodecCtx, pDecoder->pFrame, &finished, - &(((lp_ac_package_data)pPackage)->ffpackage)); + AVPacket pkt_tmp = ((lp_ac_package_data)pPackage)->ffpackage; + + while (pkt_tmp.size > 0) { + len = avcodec_decode_video2( + pDecoder->pCodecCtx, pDecoder->pFrame, + &finished, &pkt_tmp); + + if (len < 0) { + return 0; + } + pkt_tmp.size -= len; + pkt_tmp.data += len; + } + if (finished) { pts=0; //global_video_pkt_pts = ((lp_ac_package_data)pPackage)->ffpackage.pts; @@ -860,11 +876,12 @@ int CALL_CONVT ac_get_frame(lp_ac_instance pacInstance, lp_ac_decoder pDecoder) lp_ac_package pPackage = ac_read_package(pacInstance); int done = 0; + int pcount = 0; while(done == 0 && pPackage != NULL){ if (((lp_ac_package_data)pPackage)->package.stream_index == pDecoder->stream_index){ done = ac_decode_package(pPackage, pDecoder); ac_free_package(pPackage); - + pcount++; if (done == 0) pPackage = ac_read_package(pacInstance); } else { @@ -876,7 +893,7 @@ int CALL_CONVT ac_get_frame(lp_ac_instance pacInstance, lp_ac_decoder pDecoder) if (done == 0) return 0; else - return 1; + return pcount; } int CALL_CONVT ac_skip_frames(lp_ac_instance pacInstance, lp_ac_decoder pDecoder, int num) { diff --git a/Vocaluxe/Lib/Video/CVideoDecoderFFmpeg.cs b/Vocaluxe/Lib/Video/CVideoDecoderFFmpeg.cs index 4756ae06..a9cacb6d 100644 --- a/Vocaluxe/Lib/Video/CVideoDecoderFFmpeg.cs +++ b/Vocaluxe/Lib/Video/CVideoDecoderFFmpeg.cs @@ -258,8 +258,9 @@ namespace Vocaluxe.Lib.Video private bool _terminated = false; private Thread _thread; - AutoResetEvent EventDecode = new AutoResetEvent(false); + //AutoResetEvent EventDecode = new AutoResetEvent(false); SFrameBuffer[] _FrameBuffer = new SFrameBuffer[5]; + private bool _NewFrame = false; Object MutexFramebuffer = new Object(); Object MutexSyncSignals = new Object(); @@ -359,7 +360,7 @@ namespace Vocaluxe.Lib.Video UploadNewFrame(ref frame); - EventDecode.Set(); + //EventDecode.Set(); return true; } @@ -367,11 +368,11 @@ namespace Vocaluxe.Lib.Video { lock (MutexSyncSignals) { - _SetTime = Time; - VideoTime = _CurrentVideoTime; + _SetTime = Time; } UploadNewFrame(ref frame); - EventDecode.Set(); + VideoTime = _CurrentVideoTime; + //EventDecode.Set(); return true; } return false; @@ -387,7 +388,7 @@ namespace Vocaluxe.Lib.Video _NoMoreFrames = false; _Finished = false; } - EventDecode.Set(); + //EventDecode.Set(); return true; } @@ -441,17 +442,18 @@ namespace Vocaluxe.Lib.Video _BufferFull = false; _skip = false; - EventDecode.Set(); + _NewFrame = false; + //EventDecode.Set(); } private void Execute() { DoOpen(); - EventDecode.Set(); + //EventDecode.Set(); while (!_terminated) { - if (EventDecode.WaitOne(10)) + //if (EventDecode.WaitOne(10)) { lock (MutexSyncSignals) { @@ -468,11 +470,12 @@ namespace Vocaluxe.Lib.Video if (_skip) DoSkip(); - if (!_BufferFull) + if (!_NewFrame) DoDecode(); - if (_BufferFull) - Copy(); + if (_NewFrame) + Copy(); + Thread.Sleep(1); } } @@ -555,7 +558,7 @@ namespace Vocaluxe.Lib.Video { const int FRAMEDROPCOUNT = 4; - if (!_FileOpened) + if (!_FileOpened || _NewFrame) return; if (_Paused || _NoMoreFrames || _BufferFull) @@ -641,12 +644,18 @@ namespace Vocaluxe.Lib.Video } return; } - - Copy(); + else + { + _NewFrame = true; + Copy(); + } } private void Copy() { + if (!_NewFrame) + return; + int num = -1; lock (MutexFramebuffer) @@ -687,11 +696,13 @@ namespace Vocaluxe.Lib.Video if (numfull < _FrameBuffer.Length) _BufferFull = false; + + _NewFrame = false; } } - if (!_BufferFull) - EventDecode.Set(); + //if (!_BufferFull) + // EventDecode.Set(); } private void UploadNewFrame(ref STexture frame) @@ -720,7 +731,7 @@ namespace Vocaluxe.Lib.Video _CurrentVideoTime = _FrameBuffer[num].time; } _Finished = false; - EventDecode.Set(); + //EventDecode.Set(); } else { @@ -739,7 +750,7 @@ namespace Vocaluxe.Lib.Video { float td = _SetTime + _VideoSkipTime - _FrameBuffer[i].time; - if (td > _VideoTimeBase * 2) + if (td > _VideoTimeBase * 2f) { _FrameBuffer[i].displayed = true; } @@ -754,6 +765,7 @@ namespace Vocaluxe.Lib.Video if (Result != -1) { _FrameBuffer[Result].displayed = true; + _BufferFull = false; } return Result; diff --git a/Vocaluxe/Screens/CScreenLoad.cs b/Vocaluxe/Screens/CScreenLoad.cs index 5e74e834..d20c7490 100644 --- a/Vocaluxe/Screens/CScreenLoad.cs +++ b/Vocaluxe/Screens/CScreenLoad.cs @@ -30,6 +30,8 @@ namespace Vocaluxe.Screens private int _CurrentIntroVideoNr; private bool _IntroOutPlayed; private VideoPlayer[] _Intros; + + private bool _BGMusicStartet; public CScreenLoad() @@ -121,8 +123,7 @@ namespace Vocaluxe.Screens } } - if (!CBackgroundMusic.Playing) - CBackgroundMusic.Next(); + _BGMusicStartet = false; } public override void OnShowFinish() @@ -142,8 +143,18 @@ namespace Vocaluxe.Screens _SongLoaderThread.Start(); _timer.Start(); - if (!CBackgroundMusic.Playing) - CBackgroundMusic.Next(); + if (CConfig.BackgroundMusic == EOffOn.TR_CONFIG_ON && + CConfig.BackgroundMusicSource == EBackgroundMusicSource.TR_CONFIG_NO_OWN_MUSIC && !_BGMusicStartet) + { + CBackgroundMusic.AddOwnMusic(); + + if (!CBackgroundMusic.Playing) + CBackgroundMusic.Next(); + + _BGMusicStartet = true; + } + + CBackgroundMusic.CanSing = false; } public override bool UpdateGame() @@ -172,15 +183,16 @@ namespace Vocaluxe.Screens CLanguage.Translate("TR_SCREENLOAD_LOADED") + ")"; if (CSongs.SongsLoaded && CConfig.BackgroundMusic == EOffOn.TR_CONFIG_ON && - CConfig.BackgroundMusicSource != EBackgroundMusicSource.TR_CONFIG_NO_OWN_MUSIC) + CConfig.BackgroundMusicSource != EBackgroundMusicSource.TR_CONFIG_NO_OWN_MUSIC && !_BGMusicStartet) { CBackgroundMusic.AddOwnMusic(); - //if (!CBackgroundMusic.Playing) - // CBackgroundMusic.Next(); - } - CBackgroundMusic.CanSing = false; + if (!CBackgroundMusic.Playing) + CBackgroundMusic.Next(); + _BGMusicStartet = true; + } + return true; } @@ -248,100 +260,4 @@ namespace Vocaluxe.Screens _IntroOutPlayed = true; } } - - class VideoPlayer - { - private STexture _VideoTexture; - private int _VideoStream; - private Stopwatch _VideoTimer; - private bool _Finished; - private bool _Loaded; - - public bool IsFinished - { - get { return _Finished || !_Loaded; } - } - - public bool Loop - { - set { CVideo.VdSetLoop(_VideoStream, value); } - } - - public VideoPlayer() - { - _VideoTimer = new Stopwatch(); - _VideoTexture = new STexture(-1); - _Finished = false; - _Loaded = false; - } - - public void Load(string VideoName) - { - _VideoStream = CVideo.VdLoad(CTheme.GetVideoFilePath(VideoName)); - _Loaded = true; - } - - public void Start() - { - _VideoTimer.Reset(); - _Finished = false; - //CVideo.VdSkip(_VideoStream, 0f, 0f); - _VideoTimer.Start(); - } - - public void Pause() - { - _VideoTimer.Stop(); - } - - public void Resume() - { - _VideoTimer.Start(); - } - - public void Draw() - { - if (!_Finished) - { - - float VideoTime = _VideoTimer.ElapsedMilliseconds / 1000f; - _Finished = CVideo.VdFinished(_VideoStream); - - STexture tex = new STexture(-1); - tex.height = 0f; - CVideo.VdGetFrame(_VideoStream, ref tex, VideoTime, ref VideoTime); - - if (tex.height > 0) - { - CDraw.RemoveTexture(ref _VideoTexture); - _VideoTexture = tex; - } - } - RectangleF bounds = new RectangleF(0f, 0f, CSettings.iRenderW, CSettings.iRenderH); - RectangleF rect = new RectangleF(0f, 0f, _VideoTexture.width, _VideoTexture.height); - CHelper.SetRect(bounds, ref rect, rect.Width / rect.Height, EAspect.Crop); - - CDraw.DrawTexture(_VideoTexture, new SRectF(rect.X, rect.Y, rect.Width, rect.Height, CSettings.zFar / 4)); - } - - public void PreLoad() - { - float VideoTime = 0f; - while (_VideoTexture.index == -1 && VideoTime < 1f) - { - float dummy = 0f; - CVideo.VdGetFrame(_VideoStream, ref _VideoTexture, 0, ref dummy); - VideoTime += 0.05f; - } - } - - public void Close() - { - CVideo.VdClose(_VideoStream); - CDraw.RemoveTexture(ref _VideoTexture); - _Loaded = false; - _Finished = false; - _VideoTimer.Reset(); - } - } } diff --git a/Vocaluxe/Screens/CScreenSong.cs b/Vocaluxe/Screens/CScreenSong.cs index df176860..92a4ee3f 100644 --- a/Vocaluxe/Screens/CScreenSong.cs +++ b/Vocaluxe/Screens/CScreenSong.cs @@ -183,16 +183,19 @@ namespace Vocaluxe.Screens SongMenus[htSongMenus(SongMenu)].Update(); Texts[htTexts(TextCategory)].Text = CSongs.GetActualCategoryName(); + if (CSongs.Category > -1 || CConfig.Tabs == EOffOn.TR_CONFIG_OFF) + CBackgroundMusic.Disabled = true; + else + CBackgroundMusic.Disabled = false; + int song = SongMenus[htSongMenus(SongMenu)].GetActualSelection(); if ((CSongs.Category >= 0 || CConfig.Tabs == EOffOn.TR_CONFIG_OFF) && song >= 0 && song < CSongs.VisibleSongs.Length) { - Texts[htTexts(TextSelection)].Text = CSongs.VisibleSongs[song].Artist + " - " + CSongs.VisibleSongs[song].Title; - CBackgroundMusic.Disabled = true; + Texts[htTexts(TextSelection)].Text = CSongs.VisibleSongs[song].Artist + " - " + CSongs.VisibleSongs[song].Title; } else if (CSongs.Category == -1 && song >= 0 && song < CSongs.Categories.Length) { - Texts[htTexts(TextSelection)].Text = CSongs.Categories[song].Name; - CBackgroundMusic.Disabled = false; + Texts[htTexts(TextSelection)].Text = CSongs.Categories[song].Name; } else Texts[htTexts(TextSelection)].Text = String.Empty;