Exemplo n.º 1
0
    public static void Main(string [] args)
    {
        FileStream fstream;
        EsdStream estream;
        Esd esd = new Esd();
        byte[] buffer = new byte[Esd.BufferSize];
        int len, leno, offs;

        if (args.Length != 1) {
            Console.WriteLine ("Usage: esd-play <wav-file>");
            return;
        }

        fstream = new FileStream(args[0], FileMode.Open);
        estream = esd.PlayStream(args[0], EsdChannels.Stereo,
                        Esd.DefaultRate, EsdBits.Sixteen);
        estream.AllocWriteBuffer(Esd.BufferSize);

        offs = 0;
        while ((len = fstream.Read(buffer, offs, buffer.Length - offs)) > 0) {
            leno = len + offs;
            offs = estream.Write(buffer, 0, leno);
            //Console.WriteLine("offs=" + offs + " len=" + len + " leno-offs=" + (leno - offs));
            if (offs < 0) break;
            if (offs < leno) Array.Copy(buffer, offs, buffer, 0, leno - offs);
            offs = leno - offs;
        }

        estream.FreeWriteBuffer();
        estream.Close();
        fstream.Close();
    }
Exemplo n.º 2
0
 internal EsdStream(Esd esd)
 {
     this.esd = esd;
     id = -1;
 }
Exemplo n.º 3
0
 internal EsdSample(Esd esd)
 {
     this.esd = esd;
     cached = true;
 }
Exemplo n.º 4
0
        ///
        /// Launch the mp3 reader thread if it is not running
        ///
        void _StartReaderThread( )
        {
            if (null == _esd)
            _esd = new Esd();

             _configMutex.WaitOne();
             try
             {
            if (null == _mp3ReaderThread
                || !_mp3ReaderThread.IsAlive)
            {
               _mp3ReaderThread =
                  new Thread( new ThreadStart( _Mp3ReaderThread ) );

               _mp3ReaderThread.Priority = ThreadPriority.AboveNormal;
               _mp3ReaderThread.Start();
            }
             }
             finally
             {
            // Mustn't forget!
            _configMutex.ReleaseMutex();
             }
        }
Exemplo n.º 5
0
 /// 
 /// Shuts down the playing engine and kills the reader and
 /// audio streamer threads. Call before program exit if you
 /// want the program to exit. :)
 ///
 public void ShutDown()
 {
     _KillReaderThread();
      _esd = null;
 }