public ulong TakeUnsignedLE(out ulong value, uint length) { if (CheckAvailable(length)) { value = BufferIO.BytesToUIntLE(_packetBuffer, _pos, length); _pos += length; return(value); } throw _bufferErr; }
public bool TakeBool(out bool value, byte length, Endian endian) { if (CheckAvailable(length)) { value = BufferIO.BytesToBool(_packetBuffer, _pos, length, endian); _pos += length; return(value); } throw _bufferErr; }
public long TakeSignedBE(out long value, uint length) { if (CheckAvailable(length)) { value = BufferIO.BytesToIntBE(_packetBuffer, _pos, length); _pos += length; return(value); } throw _bufferErr; }
public ulong TakeUnsigned(out ulong value, uint length, Endian endian = Endian.Big) { if (CheckAvailable(length)) { value = BufferIO.BytesToUInt(_packetBuffer, _pos, length, endian); _pos += length; return(value); } throw _bufferErr; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); Yse.Yse.System().init(); TimerCallback callback = new TimerCallback(Update); timer = new Timer(callback, null, 50, 50); FileManager = new BufferIO(true); byte[] fileBuffer = default(byte[]); using (StreamReader sr = new StreamReader(Assets.Open("countdown.ogg"))) { using (var memstream = new MemoryStream()) { sr.BaseStream.CopyTo(memstream); fileBuffer = memstream.ToArray(); } } FileManager.AddBuffer("file1", fileBuffer, fileBuffer.Length); FileManager.SetActive(true); sound = new sound(); sound.create("file1"); // Get our button from the layout resource, // and attach an event to it Button startbutton = FindViewById <Button>(Resource.Id.startButton); startbutton.Click += delegate { sound.play(); Yse.Yse.System().AudioTest(true); startbutton.Text = "" + sound.length(); }; Button pausebutton = FindViewById <Button>(Resource.Id.pauseButton); pausebutton.Click += delegate { sound.pause(); }; Button stopbutton = FindViewById <Button>(Resource.Id.stopButton); stopbutton.Click += delegate { sound.stop(); Yse.Yse.System().AudioTest(false); }; }
private void LoadBuffer(BufferIO IO, String fileName) { byte[] fileBuffer = default(byte[]); using (StreamReader sr = new StreamReader(Assets.Open(fileName + ".ogg"))) { using (var memstream = new MemoryStream()) { sr.BaseStream.CopyTo(memstream); fileBuffer = memstream.ToArray(); IO.AddBuffer(fileName, fileBuffer, fileBuffer.Length); } } }
public byte[] TakeBytes(out byte[] value, Prefix prefixFlag) { uint length; bool reduce = (prefixFlag & Prefix.WithPrefix) > 0; uint preLen = ((uint)prefixFlag) & 15; switch (preLen) { case 0: // Read to end. length = (uint)(_packetLength - _pos); break; case 1: case 2: case 4: if (CheckAvailable(preLen)) { length = (uint)BufferIO.BytesToUIntBE(_packetBuffer, _pos, preLen); _pos += preLen; if (reduce) { if (length < preLen) { throw new IOException("Data length is less than prefix length."); } length -= preLen; } break; } throw _bufferErr; default: throw new ArgumentOutOfRangeException("Invalid prefix flag."); } if (CheckAvailable(length)) { value = new byte[length]; Buffer.BlockCopy(_packetBuffer, (int)_pos, value, 0, (int)length); _pos += length; return(value); } throw _bufferErr; }
/// <summary> /// 以 Little Endian 字节序, 放入 short /// </summary> /// <param name="value">值</param> public void PutShortLE(short value) { WriteBytes(BufferIO.Int16ToBytesLE(value)); }
/// <summary> /// 放入 ulong /// </summary> /// <param name="value">值</param> /// <param name="endian">字节序</param> public void PutUlong(ulong value, Endian endian) { WriteBytes(BufferIO.UInt64ToBytes(value, endian)); }
/// <summary> /// 以 Little Endian 字节序, 放入 ulong /// </summary> /// <param name="value">值</param> public void PutUlongLE(ulong value) { WriteBytes(BufferIO.UInt64ToBytesLE(value)); }
/// <summary> /// 以 Little Endian 字节序, 放入 long /// </summary> /// <param name="value">值</param> public void PutLongLE(long value) { WriteBytes(BufferIO.Int64ToBytesLE(value)); }
/// <summary> /// 放入 uint /// </summary> /// <param name="value">值</param> /// <param name="endian">字节序</param> public void PutUint(uint value, Endian endian) { WriteBytes(BufferIO.UInt32ToBytes(value, endian)); }
/// <summary> /// 以 Little Endian 字节序, 放入 uint /// </summary> /// <param name="value">值</param> public void PutUintLE(uint value) { WriteBytes(BufferIO.UInt32ToBytesLE(value)); }
/// <summary> /// 以 Little Endian 字节序, 放入 int /// </summary> /// <param name="value">值</param> public void PutIntLE(int value) { WriteBytes(BufferIO.Int32ToBytesLE(value)); }
/// <summary> /// 以 Little Endian 字节序, 放入 ushort /// </summary> /// <param name="value">值</param> public void PutUshortLE(ushort value) { WriteBytes(BufferIO.UInt16ToBytesLE(value)); }
public void PutSbyte(sbyte value) { WriteBytes(BufferIO.Int8ToBytes(value)); }
public void PutByte(byte value) { WriteBytes(BufferIO.UInt8ToBytes(value)); }
/// <summary> /// 以 Little Endian 字节序, 放入 bool /// </summary> /// <param name="value">值</param> /// <param name="length">占用长度</param> public void PutBoolLE(bool value, byte length) { WriteBytes(BufferIO.BoolToBytesLE(value, length)); }
/// <summary> /// 放入 short /// </summary> /// <param name="value">值</param> /// <param name="endian">字节序</param> public void PutShort(short value, Endian endian) { WriteBytes(BufferIO.Int16ToBytes(value, endian)); }
public void PutBool(bool value, byte length, Endian endian) { WriteBytes(BufferIO.BoolToBytes(value, length, endian)); }