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(); }
internal EsdStream(Esd esd) { this.esd = esd; id = -1; }
internal EsdSample(Esd esd) { this.esd = esd; cached = true; }
/// /// 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(); } }
/// /// 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; }