コード例 #1
0
 /// <summary>
 /// Disposes this stream
 /// </summary>
 /// <param name="disposing">true if the user called this</param>
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         // Release managed resources.
         if (conversionStream != null)
         {
             conversionStream.Dispose();
             conversionStream = null;
         }
         if (sourceStream != null)
         {
             sourceStream.Dispose();
             sourceStream = null;
         }
     }
     else
     {
         System.Diagnostics.Debug.Assert(false, "WaveFormatConversionStream was not disposed");
     }
     // Release unmanaged resources.
     // Set large fields to null.
     // Call Dispose on your base class.
     base.Dispose(disposing);
 }
コード例 #2
0
 /// <summary>
 /// Disposes this AudioFileReader
 /// </summary>
 /// <param name="disposing">True if called from Dispose</param>
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         readerStream.Dispose();
         readerStream = null;
     }
     base.Dispose(disposing);
 }
コード例 #3
0
 /// <summary>
 /// Disposes this WaveStream
 /// </summary>
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (sourceStream != null)
         {
             sourceStream.Dispose();
             sourceStream = null;
         }
     }
     base.Dispose(disposing);
 }
コード例 #4
0
 /// <summary>
 /// Disposes this WaveStream
 /// </summary>
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (sourceStream != null)
         {
             sourceStream.Dispose();
             sourceStream = null;
         }
     }
     else
     {
         System.Diagnostics.Debug.Assert(false, "BlockAlignReductionStream was not Disposed");
     }
     base.Dispose(disposing);
 }
コード例 #5
0
 /// <summary>
 /// Disposes this WaveStream
 /// </summary>
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (sourceStream != null)
         {
             sourceStream.Dispose();
             sourceStream = null;
         }
     }
     else
     {
         System.Diagnostics.Debug.Assert(false, "WaveChannel32 was not Disposed");
     }
     base.Dispose(disposing);
 }
コード例 #6
0
 /// <summary>
 /// Disposes this stream
 /// </summary>
 /// <param name="disposing">true if the user called this</param>
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         // Release managed resources.
         if (sourceStream != null)
         {
             sourceStream.Dispose();
             sourceStream = null;
         }
     }
     // Release unmanaged resources.
     // Set large fields to null.
     // Call Dispose on your base class.
     base.Dispose(disposing);
 }
コード例 #7
0
 /// <summary>
 /// Disposes this stream
 /// </summary>
 /// <param name="disposing">true if the user called this</param>
 protected override void Dispose(bool disposing)
 {
     if (!isDisposed)
     {
         isDisposed = true;
         if (disposing)
         {
             sourceStream.Dispose();
             conversionProvider.Dispose();
         }
         else
         {
             // we've been called by the finalizer
             Debug.Assert(false, "WaveFormatConversionStream was not disposed");
         }
     }
     // Release unmanaged resources.
     // Set large fields to null.
     // Call Dispose on your base class.
     base.Dispose(disposing);
 }
コード例 #8
0
ファイル: WSRSpeaker.cs プロジェクト: jdelhommeau/WSRMacro
    private void RunSession(WaveOut WaveOut, WaveStream stream, string match) {
      played.Add(match);
      WSRConfig.GetInstance().logInfo("PLAYER", "[" + device + "]" + "Start Player");
      Stopwatch timer = new Stopwatch(); timer.Start();

      using (WaveChannel32 volumeStream = new WaveChannel32(stream)) {
        volumeStream.Volume = match == "TTS" ? WSRConfig.GetInstance().SpkVolTTS / 100f : WSRConfig.GetInstance().SpkVolPlay / 100f;
        WaveOut.Init(volumeStream);
        WaveOut.Play();
        while (stream.CurrentTime < stream.TotalTime && played.Contains(match) && timer.ElapsedMilliseconds < 1000 * 60 * 8) {
          Thread.Sleep(100);
        }
        WaveOut.Stop();
        stream.Dispose();
      }

      WSRConfig.GetInstance().logInfo("PLAYER", "[" + device + "]" + "End Player");
      played.Remove(match);
    }
コード例 #9
0
        private void DisposeInternal(IWavePlayer player, WaveStream file)
        {
            new TaskFactory().StartNew(() => {
                if(player != null) {
                    player.Dispose();
                }

                if(file != null) {
                    // Given that the NAudio framework gives no access to inner systems the best way to
                    // assure the player has been disposed before disposing the file is to wait a while
                    Task.Delay(1000).Wait();
                    file.Dispose();
                }
            });
        }
コード例 #10
0
    private void Play(WaveStream stream, SpeakerState state) {
      
      // Stop all stream from playing for 1s
      if (DateTime.Now - StopTimeout < TimeSpan.FromMilliseconds(1000)) {
        Log("Stop next speech");
        state.playing = false;
        stream.Dispose();
        return;  
      }

      state.start = DateTime.Now;
      using (WaveChannel32 volume = new WaveChannel32(stream)) {
        volume.Volume = ConfigManager.GetInstance().Find("speaker.volume", 100) / 100f;
        waveOut.Init(volume);
        waveOut.Play();
        while (stream.CurrentTime < stream.TotalTime && (DateTime.Now - state.start) < state.timeout) { Thread.Sleep(500); }
        waveOut.Stop();
        state.playing = false;
      }
      stream.Dispose();
    }