Example #1
0
        public void TestFeed()
        {
            Mpg123 mpg123 = new Mpg123();

            mpg123.OpenFeed();

            byte[] buffer = new byte[8];

            Assert.That(() => mpg123.Feed(buffer), Throws.Nothing);
        }
Example #2
0
        public void TestFeedReadNeedMore()
        {
            Mpg123 mpg123 = new Mpg123();

            mpg123.OpenFeed();

            byte[] inBuffer  = new byte[8];
            byte[] outBuffer = new byte[8];
            uint   done      = 0;

            mpg123.Feed(inBuffer);
            Assert.That(mpg123.Read(outBuffer, ref done), Is.EqualTo(Mpg123.Errors.NEED_MORE));
        }
Example #3
0
        public void TestFeedReadNoNeedMore()
        {
            Mpg123 mpg123 = new Mpg123();

            mpg123.OpenFeed();

            string dirName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            string path    = Path.Combine(dirName, "bensound-epic.mp3");

            byte[] inBuffer  = File.ReadAllBytes(path);
            byte[] outBuffer = new byte[inBuffer.Length];
            uint   done      = 0;

            mpg123.Feed(inBuffer);

            long a = 0;
            int  b = 0, c = 0;

            mpg123.GetFormat(ref a, ref b, ref c);

            Assert.That(mpg123.Read(outBuffer, ref done), Is.EqualTo(Mpg123.Errors.OK));
            Assert.That(done, Is.EqualTo(inBuffer.Length));
        }