Bass.net DOWNLOADPROC 只记录 5 秒

Bass.net DOWNLOADPROC only record 5 seconds

我正在尝试使用 bass.net 录制音频流,但使用文档示例我只能录制 5 秒。我怎样才能记录更多时间?

以下是我的代码:

class Program
{
    private static FileStream _fs = null;
    private static DOWNLOADPROC _myDownloadProc;
    private static byte[] _data;

    static void Main(string[] args)
    {
        Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero);
        _myDownloadProc = new DOWNLOADPROC(MyDownload);
        int stream = Bass.BASS_StreamCreateURL("http://m2.fabricahost.com.br:8704/;stream.mp3", 0,
                          BASSFlag.BASS_STREAM_BLOCK | BASSFlag.BASS_SAMPLE_MONO | BASSFlag.BASS_STREAM_STATUS, _myDownloadProc, IntPtr.Zero);
    }

    private static void MyDownload(IntPtr buffer, int length, IntPtr user)
    {
        if (_fs == null)
        {
            // create the file
            _fs = File.OpenWrite("output.mp3");
        }
        if (buffer == IntPtr.Zero)
        {
            // finished downloading
            _fs.Flush();
            _fs.Close();
        }
        else
        {
            // increase the data buffer as needed
            if (_data == null || _data.Length < length)
                _data = new byte[length];
            // copy from managed to unmanaged memory
            Marshal.Copy(buffer, _data, 0, length);
            // write to file
            _fs.Write(_data, 0, length);
        }
    }
}

谢谢

我发现了原因,bass.net 默认的网络缓冲区大小是 5000 毫秒(5 秒)。我只是使用更改了大小 Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_NET_BUFFER, 10000);想录多少就录多少。