/*internal void BufferFiller(IntPtr data, int size) * { * if (t.Count != 0) * { * byte[] b = t.Dequeue(); * //size = b.Length; * System.Runtime.InteropServices.Marshal.Copy(b, 0, data, b.Length); * //data = t.Dequeue(); * //size = t2.Dequeue(); * } * }*/ //WaveLib.WaveNative.WaveHdr h = new WaveLib.WaveNative.WaveHdr(); protected override void WndProc(ref Message m) { if (m.Msg == 0x113) { frame++; if (frame >= File.Header.NrFrames) { frame = 0; } IO.Misc.THP.THPFrame f = File.GetFrame(frame); //t.Dequeue(); if (audio) { byte[] a; f.ToPCM16(out a); //t.Enqueue(a); //w.Size = f.ToPCM16(out w.Data); //unsafe //{ //WaveLib.WaveNative.waveOutPrepareHeader(WaveOut, ref h, sizeof(WaveLib.WaveNative.WaveHdr)); //WaveLib.WaveNative.waveOutWrite(WaveOut, ref h, sizeof(WaveLib.WaveNative.WaveHdr)); //} //byte[] s = f.ToPCM16(); bb.AddSamples(a, 0, a.Length); } pictureBox1.Image = f.ToBitmap(); //backgroundWorker1.RunWorkerAsync(); } base.WndProc(ref m); }
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { int i = 0; //System.Diagnostics.Stopwatch w = new System.Diagnostics.Stopwatch(); while (!e.Cancel) { if (i > frame + 200) { continue; } //w.Reset(); //w.Start(); i++; if (i >= File.Header.NrFrames) { i = 0; } IO.Misc.THP.THPFrame f = File.GetFrame(i); byte[] a; f.ToPCM16(out a); bb.AddSamples(a, 0, a.Length); /*t.Enqueue(f); * if (audio) * { * //if (ww.PlaybackState != NAudio.Wave.PlaybackState.Playing) ww.Play(); * //byte[] s = f.ToPCM16(); * //bb.AddSamples(s, 0, s.Length); * } * * //frame++; * //if (frame >= File.Header.NrFrames) frame = 0; * //IO.Misc.THP.THPFrame f = t.Dequeue();//File.GetFrame(frame); * * pictureBox1.Image = f.ToBitmap(); * w.Stop(); * System.Threading.Thread.Sleep(new TimeSpan((long)(((1000f / File.Header.FPS) - 2f) * 10000f) - w.ElapsedTicks));/ * IO.Misc.THP.THPFrame f = File.GetFrame(i); * t.Enqueue(f); * if (audio) * { * h.dwBufferLength = f.ToPCM16(out h.lpData); * * unsafe * { * //WaveLib.WaveNative.waveOutPrepareHeader(WaveOut, ref h, sizeof(WaveLib.WaveNative.WaveHdr)); * WaveLib.WaveNative.waveOutWrite(WaveOut, ref h, sizeof(WaveLib.WaveNative.WaveHdr)); * } * //byte[] s = f.ToPCM16(); * //bb.AddSamples(s, 0, s.Length); * }*/ } }