Exemplo n.º 1
0
 //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;
 }
Exemplo n.º 2
0
 public void endWrite2(WaveBuffer buf)
 {
     lock (this)
     {
         buf.hasData = true;
         buf.playing = false;
         wh_read.Set();
     }
 }
Exemplo n.º 3
0
 public void endWriteAsync()
 {
     lock (this)
     {
         //write.hasData = true;
         write = write.next;
         if (write.hasData)
             wh_write.Reset();
         //wh_read.Set();
     }
 }
Exemplo n.º 4
0
 public void endReadAsync()
 {
     lock (this)
     {
         read = read.next;
         if (!read.hasData)
             wh_read.Reset();
     }
 }
Exemplo n.º 5
0
 public void endRead2(WaveBuffer buf)
 {
     lock (this)
     {
         buf.hasData = false;
         buf.playing = false;
         wh_write.Set();
     }
 }
Exemplo n.º 6
0
 public void endRead()
 {
     lock (this)
     {
         read.hasData = false;
         read = read.next;
         if (!read.hasData)
             wh_read.Reset();
         wh_write.Set();
     }
 }
Exemplo n.º 7
0
 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;
     }
 }
Exemplo n.º 8
0
 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;
     }
 }