//public GCHandle this_gch; public WaveBuffer(int size, WaveBuffer prev) { this.header = new WaveNative.WaveHdr (); this.prev = prev; if (prev != null) prev.next = this; data = new byte[size]; data_gch = GCHandle.Alloc (data, GCHandleType.Pinned); //this_gch = GCHandle.Alloc(this, GCHandleType.Pinned); this.size = size; }
public void endWrite2(WaveBuffer buf) { lock (this) { buf.hasData = true; buf.playing = false; wh_read.Set(); } }
public void endWriteAsync() { lock (this) { //write.hasData = true; write = write.next; if (write.hasData) wh_write.Reset(); //wh_read.Set(); } }
public void endReadAsync() { lock (this) { read = read.next; if (!read.hasData) wh_read.Reset(); } }
public void endRead2(WaveBuffer buf) { lock (this) { buf.hasData = false; buf.playing = false; wh_write.Set(); } }
public void endRead() { lock (this) { read.hasData = false; read = read.next; if (!read.hasData) wh_read.Reset(); wh_write.Set(); } }
public void discard() { lock (this) { WaveBuffer tmp = write; do { if (tmp.prev.playing) { break; } tmp = tmp.prev; tmp.hasData = false; } while (tmp != read); write = tmp; } }
public WaveBufferList(int length, int size) { int i; wh_read = new System.Threading.EventWaitHandle(false, System.Threading.EventResetMode.ManualReset); wh_write = new System.Threading.EventWaitHandle(true, System.Threading.EventResetMode.ManualReset); WaveBuffer prev = null; array = new WaveBuffer[length]; for (i = 0; i < length; i++) { WaveBuffer tmp = new WaveBuffer(size, prev); prev = tmp; if (i == 0) { first = tmp; read = tmp; write = tmp; } if (i == length - 1) { last = tmp; last.next = first; first.prev = last; } tmp.index = i; array[i] = tmp; } }