예제 #1
0
        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);
        }
예제 #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);
            }
예제 #3
0
 private void Unlock(LockFlag flag)
 {
     _backingStore &= (~flag);
 }
예제 #4
0
 private void Lock(LockFlag flag)
 {
     _backingStore |= flag;
 }
예제 #5
0
 public bool IsLocked(LockFlag flag)
 {
     return((_backingStore & flag) != 0);
 }
예제 #6
0
 private void Unlock(LockFlag flag)
 {
     _backingStore &= ( ~flag );
 } 
예제 #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); 
            }
예제 #8
0
 private void Lock(LockFlag flag)
 { 
     _backingStore |= flag; 
 }
예제 #9
0
 public bool IsLocked(LockFlag flag) 
 {
     return ( _backingStore & flag ) != 0;
 }
예제 #10
0
 public void Write(int bufferStartingLocation, Stream data, int numberBytesToWrite, LockFlag flag)
 {
     throw new NotImplementedException();
 }
예제 #11
0
 public void Write(int bufferStartingLocation, Array data, LockFlag flag)
 {
     throw new NotImplementedException();
 }
예제 #12
0
 public Array Read(int bufferStartingLocation, Type returnedDataType, LockFlag flag, params int[] ranks)
 {
     throw new NotImplementedException();
 }