private NextNotificationTask HandleNewBytesInControlThread(int nextPlaceForBytes, int byteWindowSize, BufferNotificationEventArgs ea)
        {
            LockFlag lockFlag      = LockFlag.None;
            int      bytesObtained = ea.NewSoundByte.Length;

            if (bytesObtained > byteWindowSize)
            {
                SB.Stop();
                throw new ApplicationException("An event handler provided the streaming buffer with " + bytesObtained + " bytes of sound, but it only requested " + byteWindowSize + " bytes.");
            }
            else if (bytesObtained == byteWindowSize)
            {
                SB.Write(nextPlaceForBytes, ea.NewSoundByte, lockFlag);
            }
            else
            {
                // Fill the remainder of the segment with silence.
                if (ea.NewSoundByte.Length > 0)
                {
                    SB.Write(nextPlaceForBytes, ea.NewSoundByte, lockFlag);
                }
                SB.Write(nextPlaceForBytes + ea.NewSoundByte.Length, new byte[byteWindowSize - ea.NewSoundByte.Length], lockFlag);

                if (ea.SoundFinished)
                {
                    return(NextNotificationTask.FillSectionWithSilence);
                }
            }
            return(NextNotificationTask.FillSectionWithNewSound);
        }
Example #2
0
            public AutoLocker(LockHelper helper, LockFlag flag)
            {
                if (helper == null)
                {
                    throw new ArgumentNullException("helper");
                }

                Debug.Assert(!helper.IsLocked(flag));
                _helper = helper;
                _flag   = flag;

                // Lock the locker at the object's creation time.
                _helper.Lock(_flag);
            }
Example #3
0
 private void Unlock(LockFlag flag)
 {
     _backingStore &= (~flag);
 }
Example #4
0
 private void Lock(LockFlag flag)
 {
     _backingStore |= flag;
 }
Example #5
0
 public bool IsLocked(LockFlag flag)
 {
     return((_backingStore & flag) != 0);
 }
Example #6
0
 private void Unlock(LockFlag flag)
 {
     _backingStore &= ( ~flag );
 } 
Example #7
0
            public AutoLocker(LockHelper helper, LockFlag flag) 
            { 
                if(helper == null)
                { 
                    throw new ArgumentNullException("helper");
                }

                Debug.Assert(!helper.IsLocked(flag)); 
                _helper = helper;
                _flag = flag; 
 
                // Lock the locker at the object's creation time.
                _helper.Lock(_flag); 
            }
Example #8
0
 private void Lock(LockFlag flag)
 { 
     _backingStore |= flag; 
 }
Example #9
0
 public bool IsLocked(LockFlag flag) 
 {
     return ( _backingStore & flag ) != 0;
 }
Example #10
0
 public void Write(int bufferStartingLocation, Stream data, int numberBytesToWrite, LockFlag flag)
 {
     throw new NotImplementedException();
 }
Example #11
0
 public void Write(int bufferStartingLocation, Array data, LockFlag flag)
 {
     throw new NotImplementedException();
 }
Example #12
0
 public Array Read(int bufferStartingLocation, Type returnedDataType, LockFlag flag, params int[] ranks)
 {
     throw new NotImplementedException();
 }