コード例 #1
0
        private int lame_decode_fromfile(FileStream fd, short[] pcm_l, short[] pcm_r, MP3Data mp3data)
        {
            var ret = 0;
            var len = 0;
            var buf = new byte[1024];

            ret = -1;
            ret = mpg.hip_decode1_headers(hip, buf, len, pcm_l, pcm_r, mp3data);
            if (ret != 0)
            {
                return(ret);
            }

            while (true)
            {
                try
                {
                    len = fd.Read(buf, 0, buf.Length);
                }
                catch (IOException e)
                {
                    Console.WriteLine(e.ToString());
                    Console.Write(e.StackTrace);
                    return(-1);
                }

                if (len <= 0)
                {
                    ret = mpg.hip_decode1_headers(hip, buf, 0, pcm_l, pcm_r, mp3data);
                    if (ret <= 0)
                    {
                        mpg.hip_decode_exit(hip);
                        hip = null;
                        return(-1);
                    }

                    break;
                }

                ret = mpg.hip_decode1_headers(hip, buf, len, pcm_l, pcm_r, mp3data);
                if (ret == -1)
                {
                    mpg.hip_decode_exit(hip);
                    hip = null;
                    return(-1);
                }

                if (ret > 0)
                {
                    break;
                }
            }

            return(ret);
        }
コード例 #2
0
ファイル: GetAudio.cs プロジェクト: starburst997/GroovyCodecs
        private int lame_decode_fromfile(Stream fd, short[] pcm_l, short[] pcm_r, MP3Data mp3data, bool seek)
        {
            var ret = 0;
            var len = 0;
            var buf = new byte[1024];

            ret = -1;
            ret = mpg.hip_decode1_headers(hip, buf, len, pcm_l, pcm_r, mp3data, seek);
            if (ret != 0)
            {
                return(ret);
            }

            while (true)
            {
                try
                {
                    len = fd.Read(buf, 0, buf.Length);
                }
                catch (IOException e)
                {
                    return(-1);
                }

                if (len <= 0)
                {
                    ret = mpg.hip_decode1_headers(hip, buf, 0, pcm_l, pcm_r, mp3data, seek);
                    if (ret <= 0)
                    {
                        mpg.hip_decode_exit(hip);
                        hip = null;
                        return(-1);
                    }

                    break;
                }

                ret = mpg.hip_decode1_headers(hip, buf, len, pcm_l, pcm_r, mp3data, seek);
                if (ret == -1)
                {
                    mpg.hip_decode_exit(hip);
                    hip = null;
                    return(-1);
                }

                if (ret > 0)
                {
                    break;
                }
            }

            return(ret);
        }