예제 #1
0
        /// <summary>
        /// Disposes this WaveStream
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                while (this.TableCreater.IsAlive)
                {
                    this.tableCreated = true;
                    Thread.Sleep(1);
                }

                if (Mp3Stream != null)
                {
                    if (ownInputStream)
                    {
                        Mp3Stream.Dispose();
                    }
                    Mp3Stream = null;
                }
                if (decompressor != null)
                {
                    decompressor.Dispose();
                    decompressor = null;
                }
            }
            base.Dispose(disposing);
        }
예제 #2
0
 public void Dispose()
 {
     lock (this)
     {
         Inst.Dispose();
         Stream.Dispose();
         DecoderThread.Abort();
         EndOfStream = true;
     }
 }
예제 #3
0
파일: MP3Player.cs 프로젝트: jwofles/ForkSO
 public void Dispose()
 {
     lock (ControlLock)
     {
         Disposed = true;
         Inst?.Dispose();
         Stream?.Dispose();
         DecoderThread?.Abort();
         EndOfStream = true;
     }
 }
예제 #4
0
        public void Dispose()
        {
            lock (ControlLock)
            {
                Disposed = true;
                Inst?.Dispose();
                Stream?.Dispose();

                Active = false;
                DecodeNext.Set(); //end the mp3 thread immediately

                EndOfStream = true;
            }
        }
예제 #5
0
 /// <summary>
 /// Dispose.
 /// </summary>
 protected virtual void Dispose(bool disposing)
 {
     devices?.Dispose();
     streamingRequestListener?.StopListening();
     streamingRequestListener?.Dispose();
     Mp3Stream?.Dispose();
     NativeMethods.StopSetWindowsHooks();
     if (notifyIcon != null)
     {
         notifyIcon.Visible = false;
     }
     notifyIcon?.Dispose();
     mainForm?.Dispose();
     taskList?.Dispose();
 }
예제 #6
0
 public void Stop()
 {
     if (mp3Stream == null)
     {
         return;
     }
     if (secondaryBuffer == null)
     {
         return;
     }
     Playing = false;
     bufferDescription.Dispose();
     secondaryBuffer.Dispose();
     mp3Stream.Dispose();
     mp3Stream = null;
 }
예제 #7
0
        void DoLoading(object obj)
        {
            Wavefile  wave   = m_Wavefile;
            Mp3Stream stream = (Mp3Stream)obj;

            BlockArray <Sample> array = wave.m_Samples;

            //SafeStream safeStream = new SafeStream(stream);

            Sample[] sample = new Sample[10000];
            byte[]   buffer = new byte[sample.Length * 4];

            Thread.Sleep(1000);

            while (true)             //safeStream.Position < safeStream.Length)
            {
                //int count;
                //int countMax = (int)Math.Min(1024, (safeStream.Length - safeStream.Position)/4);
                //for (count=0; count <countMax; count ++)
                //{
                //    //sample[count] = new Sample(ReadI2(safeStream), ReadI2(safeStream));
                //    sample[count] = ReadSI2(safeStream);
                //}

                int byteCount = stream.Read(buffer, 0, buffer.Length);
                if (byteCount == 0)
                {
                    break;
                }

                int sampleCount = byteCount / 4;

                for (int i = 0, j = 0; i < sampleCount; i++, j += 4)
                {
                    sample[i] = new Sample((short)(buffer[j] | buffer[j + 1] << 8),
                                           (short)(buffer[j + 2] | buffer[j + 3] << 8));
                }

                array.Write(sample, 0, sampleCount);
                Thread.Sleep(0);
            }

            stream.Dispose();
            wave.FinishedLoading = true;
        }