Ejemplo n.º 1
0
        public void Register(FifoStream audiostream, int channels, bool paused)
        {
            GetLock(out LockCookie cookie, out WriteLock wl);

            this.streams.Add(audiostream);
            this.streaminfo.Add(new streaminf(channels)
            {
                running = !paused
            });
            ReleaseLock(cookie, wl);
        }
Ejemplo n.º 2
0
        public void Pause(FifoStream audiostream)
        {
            GetLock(out LockCookie cookie, out WriteLock wl);
            int ind = streams.IndexOf(audiostream);

            if (ind != -1)
            {
                this.streaminfo[ind].running = false;
            }
            ReleaseLock(cookie, wl);
        }
Ejemplo n.º 3
0
 public void SetSetAudio(FifoStream audiostream, bool muted, float volume)
 {
     using (var rl = new ReadLock(this.StreamsLock))
     {
         int ind = streams.IndexOf(audiostream);
         if (ind != -1)
         {
             this.streaminfo[ind].Set(muted, volume);
         }
     }
 }
Ejemplo n.º 4
0
        public void StartAt(FifoStream audiostream, long time)
        {
            GetLock(out LockCookie cookie, out WriteLock wl);

            int ind = streams.IndexOf(audiostream);

            if (ind != -1)
            {
                this.streaminfo[ind].starttime = time;
            }
            ReleaseLock(cookie, wl);
        }
Ejemplo n.º 5
0
 public float[] GetAudioLevels(FifoStream audiostream)
 {
     using (var wl = new ReadLock(this.StreamsLock))
     {
         int ind = streams.IndexOf(audiostream);
         if (ind == -1)
         {
             return(new float[0]);
         }
         return(this.streaminfo[ind].audiolevel);
     }
 }
Ejemplo n.º 6
0
 public AudioViewer()
 {
     if (WaveNative.waveInGetNumDevs() == 0)
     {
         throw new Exception(DateTime.Now.ToString() + " : There are no audio devices available\r\n");
     }
     else
     {
         if (_isPlayer == true)
         {
             _stream = new FifoStream();
         }
         _audioFrame = new AudioFrame();
     }
 }
Ejemplo n.º 7
0
        void ReadLogFile(ProcessHandler process)
        {
            using var stream = File.Open(Config.LogFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
            using var buffer = new FifoStream();
            var reader = new DataReader(buffer);

            while (process.IsRunning)
            {
                buffer.AppendStream(stream);
                while (buffer.Contains(10))
                {
                    var line = reader.ReadLine().TrimEnd('\r', ' ');
                    log.LogInfo($"StdOut: <green>{line}");
                }
            }
        }
Ejemplo n.º 8
0
 private void AskSoundForm_Load(object sender, EventArgs e)
 {
     if (WaveNative.waveInGetNumDevs() == 0)
     {
         consoletext += DateTime.Now.ToString() + " : No audio input devices detected\r\n";
     }
     else
     {
         consoletext += DateTime.Now.ToString() + " : Audio input device detected\r\n";
         if (_isPlayer == true)
         {
             _streamOut = new FifoStream();
         }
         _audioFrame = new AudioFrame(_isTest);
         //_audioFrame.IsDetectingEvents = TVSender.Properties.Settings.Default.SettingIsDetectingEvents;
         //_audioFrame.AmplitudeThreshold = TVSender.Properties.Settings.Default.SettingAmplitudeThreshold;
         _streamMemory = new MemoryStream();
         Start();
     }
 }
Ejemplo n.º 9
0
 public void ListenEnd(FifoStream audiostream, Action function)
 {
     using (var rl = new ReadLock(this.StreamsLock))
     {
         //GetLock(out LockCookie cookie, out WriteLock wl);
         int ind = streams.IndexOf(audiostream);
         if (ind != -1)
         {
             lock (this.streaminfo[ind])
             {
                 if (!this.streaminfo[ind].running)
                 {
                     function();
                 }
                 else
                 {
                     this.streaminfo[ind].Done = function;
                 }
             }
         }
         //   ReleaseLock(cookie, wl);
     }
 }
Ejemplo n.º 10
0
        public void Unregister(FifoStream audiostream)
        {
            if (audiostream != null)
            {
                audiostream.Close();

                GetLock(out LockCookie cookie, out WriteLock wl);

                int ind = this.streams.IndexOf(audiostream);

                if (ind >= 0)
                {
                    this.streaminfo.RemoveAt(ind);
                    this.streams.RemoveAt(ind);
                }
                else
                {
                    Debug.Assert(false);
                }
                ReleaseLock(cookie, wl);
                audiostream.Clear();
            }
        }
Ejemplo n.º 11
0
        public Player(MainWindow mainwindow, string filename, long timebase)
        {
            try
            {
                this.timebase = timebase;
                this.renderer = mainwindow.Renderer;
                this.audioout = mainwindow.Audio;
                this.mixer    = mainwindow.Mixer;
                this.player   = BaseLib.Media.MoviePlayer.Open(() => { }, filename);

                try
                {
                    if (player.VideoStreams.Length > 0)
                    {
                        this.video = player.open_video(0, frameready);
                    }
                    if (player.AudioStreams.Length > 0)
                    {
                        this.audio       = player.open_audio(0, mainwindow.Mixer, audioready);
                        this.audiobuffer = new FifoStream(mainwindow.Audio.SampleSize * mainwindow.Audio.SampleRate * 3);
                        this.mixer.Register(this.audiobuffer, this.audioout.Channels, false);
                    }
                    this.player.start(0, timebase);
                }
                catch
                {
                    Dispose(true);
                    GC.SuppressFinalize(this);
                    throw;
                }
            }
            catch
            {
                GC.SuppressFinalize(this);
                throw;
            }
        }
Ejemplo n.º 12
0
        public static ImapAnswer Parse(string id, Stream stream)
        {
            var answer = new ImapAnswer
            {
                ID = id
            };

            var buffer  = new FifoStream();
            var current = new List <byte>(80);

            while (true)
            {
                var b = stream.ReadByte();
                if (b < 0)
                {
                    throw new EndOfStreamException();
                }

                current.Add((byte)b);
                if (b == '\n')
                {
                    var line = current.ToArray();
                    var str  = ASCII.GetString(line);
                    if (str.StartsWith(answer.ID + " "))
                    {
                        answer.Result = str;
                        break;
                    }
                    buffer.AppendBuffer(line, 0, line.Length);
                    current.Clear();
                }
            }

            answer.Data = buffer.ToArray();
            return(answer);
        }
Ejemplo n.º 13
0
 public void Flush(FifoStream audiostream)
 {
     audiostream.WaitAllReadDone();
 }
Ejemplo n.º 14
0
 private void AskForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     Stop();
     if (_isSaving == true)
     {
         byte[] waveBuffer = new byte[16];
         _streamWave = WaveStream.CreateStream(_streamMemory, _waveFormat);
         waveBuffer  = new byte[_streamWave.Length - _streamWave.Position];
         _streamWave.Read(waveBuffer, 0, waveBuffer.Length);
         //if ("" != "")
         //    _streamFile = new FileStream("" + "\\" + _sampleFilename, FileMode.Create);
         //else
         _streamFile = new FileStream(_sampleFilename, FileMode.Create);
         _streamFile.Write(waveBuffer, 0, waveBuffer.Length);
         _isSaving = false;
     }
     if (_streamOut != null)
     {
         try
         {
             _streamOut.Close();
         }
         catch { }
         finally
         {
             _streamOut = null;
         }
     }
     if (_streamWave != null)
     {
         try
         {
             _streamWave.Close();
         }
         catch { }
         finally
         {
             _streamWave = null;
         }
     }
     if (_streamFile != null)
     {
         try
         {
             _streamFile.Close();
         }
         catch { }
         finally
         {
             _streamFile = null;
         }
     }
     if (_streamMemory != null)
     {
         try
         {
             _streamMemory.Close();
         }
         catch { }
         finally
         {
             _streamMemory = null;
         }
     }
 }
Ejemplo n.º 15
0
 private void Init()
 {
     SetBtn(0);
     m_Fifo = new FifoStream();
     //데이터 통신을 위한 udpclient 생성
     udpData = new UdpClient(3000);
     //데이터 비동기 수신 대기
     OnReceiveData();
 }