예제 #1
0
        public override void Play(AudioDevice dev)
        {
            int fragment_played   = 0;
            int total_data_played = 0;
            int chunk_size        = (int)dev.ChunkSize;
            int count             = data_len;

            byte[] buffer        = new byte [data_len];
            byte[] chunk_to_play = new byte [chunk_size];

            // Read only Au data, don't care about file header here !
            stream.Position = 0;             //(long)data_offset;
            stream.Read(buffer, 0, data_len);

            while (!IsStopped && count >= 0)
            {
                // Copy one chunk from buffer
                Buffer.BlockCopy(buffer, total_data_played, chunk_to_play, 0, chunk_size);
                // play that chunk, !!! the size pass to alsa the number of fragment, a fragment is a sample per channel !!!
                fragment_played = dev.PlaySample(chunk_to_play, chunk_size / (frame_divider * channels));

                // If alsa played something, inc the total data played and dec the data to be played
                if (fragment_played > 0)
                {
                    total_data_played += (fragment_played * frame_divider * channels);
                    count             -= (fragment_played * frame_divider * channels);
                }
            }
        }
예제 #2
0
        public override void Play(AudioDevice dev)
        {
            int read;
            int count = data_len;

            byte[] buffer = new byte [buffer_size];
            stream.Position = 0;
            while (!IsStopped && count >= 0 && (read = stream.Read(buffer, 0, System.Math.Min(buffer.Length, count))) > 0)
            {
                // FIXME: account for leftover bytes
                dev.PlaySample(buffer, read / frame_divider);
                count -= read;
            }
        }
예제 #3
0
파일: AudioData.cs 프로젝트: nlhepler/mono
		public override void Play (AudioDevice dev) {
						int    fragment_played = 0;
			int    total_data_played = 0;
			int    chunk_size        = (int)dev.ChunkSize;
			int    count             = data_len;
			byte[] buffer            = new byte [data_len];
			byte[] chunk_to_play     = new byte [chunk_size];
			
			// Read only Au data, don't care about file header here !
			stream.Position = 0; //(long)data_offset;
			stream.Read (buffer, 0, data_len); 
			
			while (!IsStopped && count >= 0){
				// Copy one chunk from buffer
				Buffer.BlockCopy(buffer, total_data_played, chunk_to_play, 0, chunk_size);
				// play that chunk, !!! the size pass to alsa the number of fragment, a fragment is a sample per channel !!!
				fragment_played = dev.PlaySample (chunk_to_play, chunk_size / (frame_divider * channels));
				
				// If alsa played something, inc the total data played and dec the data to be played
				if (fragment_played > 0) {
					total_data_played  += (fragment_played * frame_divider * channels);
					count              -= (fragment_played * frame_divider * channels);
				}
			}
		}
예제 #4
0
		public override void Play(AudioDevice dev) {
			int fragment_played = 0;
			int total_data_played = 0;
			int chunk_size = (int)dev.ChunkSize;
			int count = data_len;
			byte[] buffer = new byte[data_len];
			byte[] chunk_to_play = new byte[chunk_size];

			// Read only wave data, don't care about file header here !
			stream.Position = data_offset;
			stream.Read(buffer, 0, data_len);

			while (!IsStopped && count >= 0) {
				//Console.WriteLine(stream.Position + " - " + DateTime.Now.ToString());
				// Copy one chunk from buffer
				var readSize = buffer.Length - total_data_played < chunk_size ? buffer.Length - total_data_played : chunk_size;
				if (readSize == 0) return;
				Buffer.BlockCopy(buffer, total_data_played, chunk_to_play, 0, readSize);
				// play that chunk, !!! the size pass to alsa the number of fragment, a fragment is a sample per channel !!!
				fragment_played = dev.PlaySample(chunk_to_play, readSize / (frame_divider * channels));

				// If alsa played something, inc the total data played and dec the data to be played
				if (fragment_played > 0) {
					total_data_played += (fragment_played * frame_divider * channels);
					count -= (fragment_played * frame_divider * channels);
				}
			}
		}
예제 #5
0
파일: AudioData.cs 프로젝트: carrie901/mono
		public override void Play (AudioDevice dev) {
			int read;
			int count = data_len;
			byte[] buffer = new byte [buffer_size];
			stream.Position = 0;
			while (!IsStopped && count >= 0 && (read = stream.Read (buffer, 0, System.Math.Min (buffer.Length, count))) > 0) {
				// FIXME: account for leftover bytes
				dev.PlaySample (buffer, read/frame_divider);
				count -= read;
			}
		}