Exemplo n.º 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);
        }
Exemplo n.º 2
0
 public void Dispose()
 {
     lock (this)
     {
         Inst.Dispose();
         Stream.Dispose();
         DecoderThread.Abort();
         EndOfStream = true;
     }
 }
Exemplo n.º 3
0
 public void Dispose()
 {
     lock (ControlLock)
     {
         Disposed = true;
         Inst?.Dispose();
         Stream?.Dispose();
         DecoderThread?.Abort();
         EndOfStream = true;
     }
 }
Exemplo n.º 4
0
        public void Dispose()
        {
            lock (ControlLock)
            {
                Disposed = true;
                Inst?.Dispose();
                Stream?.Dispose();

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

                EndOfStream = true;
            }
        }
Exemplo n.º 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();
 }
Exemplo n.º 6
0
 public void Stop()
 {
     if (mp3Stream == null)
     {
         return;
     }
     if (secondaryBuffer == null)
     {
         return;
     }
     Playing = false;
     bufferDescription.Dispose();
     secondaryBuffer.Dispose();
     mp3Stream.Dispose();
     mp3Stream = null;
 }
Exemplo n.º 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;
        }