亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? waveout.cs

?? 用C#實現的取得CellID和LAC的程序源代碼!
?? CS
?? 第 1 頁 / 共 2 頁
字號:
using System;
using System.Runtime.InteropServices;
using System.IO;
using Microsoft.WindowsCE.Forms;
using System.Threading;
using System.Windows.Forms;
using System.Diagnostics;

namespace NiceTracker.Libraries
{
	/// <summary>
	/// Encapsulates Waveform Audio Interface playback functions and provides a simple
	/// interface for playing audio.
	/// </summary>
	public class WaveOut : IDisposable
	{
		/// <summary>
		/// Supplies an inteface for loading and playing a .wav file.
		/// </summary>
		public class WaveFile : IDisposable
		{
			/// <summary>
			/// Hardware interface instance for this wave file.
			/// </summary>
			protected IntPtr m_hwo = IntPtr.Zero;

			/// <summary>
			/// Instance of WAVEFORMATEX associated with this file.
			/// </summary>
			protected Wave.WAVEFORMATEX m_wfmt = null;

			/// <summary>
			/// Buffers used to read and play wave data.
			/// </summary>
			protected Wave.WAVEHDR[] m_whdr = null;

			/// <summary>
			/// Size of each buffer used for playback
			/// </summary>
			protected int m_bufferSize;

			/// <summary>
			/// Number of buffers needed for playback
			/// </summary>
			protected int m_numBlocks;

			/// <summary>
			/// Current buffer being read
			/// </summary>
			protected int m_curBlock;

			/// <summary>
			/// BinaryRead used to access the streaming audio file.
			/// </summary>
			protected BinaryReader m_rdr = null;

			/// <summary>
			/// Determines if file is done playing.
			/// </summary>
			public bool Done { get { return !m_playing; } }
			protected bool m_playing = false;

			/// <summary>
			/// Length, in milliseconds, of the audio file.
			/// </summary>
			public uint Milliseconds { get { return 1000 * m_dataLength / m_wfmt.nAvgBytesPerSec; } }
			protected uint m_dataLength;

			/// <summary>
			/// Create an instance of a wave file.  Allocate the two buffers that will
			/// be used for streaming audio.
			/// </summary>
			public WaveFile()
			{
				m_whdr = new Wave.WAVEHDR[2];
			}

			/// <summary>
			/// Play a wave file.
			/// </summary>
			/// <param name="curDevice">Hardware device to use for playback</param>
			/// <param name="fileName">Name of file to play</param>
			/// <param name="hwnd">Handle to a message window to use for messaging</param>
			/// <param name="bufferSize">Size of streaming buffers, a 0 value specifies
			/// that the buffer should be created big enough to fit the entire file</param>
			/// <param name="volLeft">Left channel volume level</param>
			/// <param name="volRight">Right channel volume level</param>
			/// <returns>MMSYSERR.NOERROR if successful</returns>
			public Wave.MMSYSERR Play(uint curDevice, String fileName, IntPtr hwnd, int bufferSize, ushort volLeft, ushort volRight)
			{
				if (m_playing)
					return Wave.MMSYSERR.NOERROR;

				if (!File.Exists(fileName))
					return Wave.MMSYSERR.ERROR;

				FileInfo fi = new FileInfo(fileName);
				if ((fi.Attributes & FileAttributes.ReadOnly) != 0)
					fi.Attributes -= FileAttributes.ReadOnly;

				FileStream strm = new FileStream(fileName, FileMode.Open);
				if (strm == null)
					return Wave.MMSYSERR.ERROR;

				m_rdr = new BinaryReader(strm);
				if (m_rdr == null)
					return Wave.MMSYSERR.ERROR;

				m_wfmt = new Wave.WAVEFORMATEX();
				m_wfmt.SeekTo(strm);

				// Read in the WAVEFORMATEX structure and attempt to open the
				// device for playback.
				m_wfmt.Read(m_rdr);

				Wave.MMSYSERR result = waveOutOpen(ref m_hwo, curDevice, m_wfmt, hwnd, 0, Wave.CALLBACK_WINDOW);
				if (result != Wave.MMSYSERR.NOERROR)
					return result;

				m_dataLength = (uint)(m_rdr.BaseStream.Length - Wave.WAVEFORMATEX.WF_OFFSET_DATA);

				if (bufferSize == 0)
					m_bufferSize = (int)m_dataLength;
				else
					m_bufferSize = bufferSize / 2;

				if (m_bufferSize % m_wfmt.nBlockAlign != 0)
					m_bufferSize += m_wfmt.nBlockAlign - (m_bufferSize % m_wfmt.nBlockAlign);

				// Determine the number of buffer reads required to play the entire
				// file
				m_numBlocks = (int)(m_dataLength / m_bufferSize);
				if ((m_numBlocks * m_bufferSize) < m_dataLength)
					m_numBlocks++;

				m_whdr[0] = new Wave.WAVEHDR();
				m_whdr[1] = new Wave.WAVEHDR();

				// Read in the first buffer
				result = ReadBuffer(0);
				if (result != Wave.MMSYSERR.NOERROR)
					return result;

				// If the entire file fits in the buffer then close the file
				if (m_numBlocks == 1)
				{
					m_rdr.BaseStream.Close();
					m_rdr.Close();
					m_rdr = null;
				}

				SetVolume(volLeft, volRight);

				// Start playback of the first buffer
				result = waveOutWrite(m_hwo, m_whdr[0], (uint)Marshal.SizeOf(m_whdr[0]));
				if (result != Wave.MMSYSERR.NOERROR)
					return result;

				m_curBlock = 0;

				// Create the second buffer.  If the audio is being streamed, this will
				// be the next audio block, otherwise it will be padding
				Thread loadThread = new Thread(new ThreadStart(LoadBuffer));
				loadThread.Start();

				m_playing = true;

				return Wave.MMSYSERR.NOERROR;
			}

			/// <summary>
			/// Read in the specified buffer.
			/// </summary>
			/// <param name="bufIndex">Index of buffer to use for the read</param>
			/// <returns>MMSYSERR.NOERROR if successful</returns>
			protected Wave.MMSYSERR ReadBuffer(int bufIndex)
			{
				uint readLength = (uint)m_bufferSize;
				if (bufIndex < m_numBlocks)
				{
					uint remainingDataLength = (uint)(m_rdr.BaseStream.Length - m_rdr.BaseStream.Position);
					if (m_bufferSize > remainingDataLength)
						readLength = remainingDataLength;
				}

				// Read in the next block of data
				Wave.MMSYSERR result = m_whdr[bufIndex].Read(m_rdr, readLength, m_wfmt.nBlockAlign);
				if (result != Wave.MMSYSERR.NOERROR)
					return result;

				// If the header is not prepared then prepare it
				if ((m_whdr[bufIndex].dwFlags & Wave.WAVEHDR.WHDR_PREPARED) == 0)
				{
					return waveOutPrepareHeader(m_hwo, m_whdr[bufIndex], (uint)Marshal.SizeOf(m_whdr[bufIndex]));
				}

				return Wave.MMSYSERR.NOERROR;
			}

			/// <summary>
			/// Create an empty buffer to append to the end of the sound.  This protects
			/// the playback because the system will sometimes continue reading after the
			/// BlockDone method is called.
			/// </summary>
			/// <param name="bufIndex">Index of buffer to be created</param>
			/// <returns>MMSYSERR.NOERROR is successful</returns>
			protected Wave.MMSYSERR CreateBuffer(int bufIndex)
			{
				Wave.MMSYSERR result = m_whdr[bufIndex].Init((uint)m_bufferSize, true);
				if (result != Wave.MMSYSERR.NOERROR)
					return result;

				if ((m_whdr[bufIndex].dwFlags & Wave.WAVEHDR.WHDR_PREPARED) == 0)
				{
					return waveOutPrepareHeader(m_hwo, m_whdr[bufIndex], (uint)Marshal.SizeOf(m_whdr[bufIndex]));
				}

				return Wave.MMSYSERR.NOERROR;
			}

			/// <summary>
			/// Load a buffer.  If there are blocks left to be read, then data will
			/// be read into the buffer that is not being played.  Otherwise, the buffer
			/// will be filled with 0's for padding to detect the end of playback.
			/// </summary>
			public void LoadBuffer()
			{
				int readBuffer = (m_curBlock + 3) % 2;

				lock(m_whdr[readBuffer])
				{
					if (m_curBlock == m_numBlocks - 1)
						CreateBuffer(readBuffer);
					else
						ReadBuffer(readBuffer);

					waveOutWrite(m_hwo, m_whdr[readBuffer], (uint)Marshal.SizeOf(m_whdr[readBuffer]));
				}
			}

			/// <summary>
			/// Called by the MessageWindow when the buffer currently being played has
			/// finished.  This method starts the loading of the next block on a
			/// separate thread.  If the current block is the last one then playback is
			/// stopped.
			/// </summary>
			public void BlockDone()
			{
				m_curBlock++;

				if (m_curBlock < m_numBlocks)
				{
					Debug.Assert((m_whdr[(m_curBlock + 2) % 2].dwFlags & Wave.WAVEHDR.WHDR_INQUEUE) != 0,
						"ERROR: A sound block finished before the subsequent block was written.");

					Thread loadThread = new Thread(new ThreadStart(LoadBuffer));
					loadThread.Start();
				}
				else if (m_curBlock == m_numBlocks)
				{
					Stop();
				}
			}

			/// <summary>
			/// Stop playing the current file and clean up all resources.
			/// </summary>
			public void Stop()
			{
				waveOutReset(m_hwo);

				m_playing = false;

				if (m_rdr != null)
				{
					m_rdr.BaseStream.Close();
					m_rdr.Close();
					m_rdr = null;
				}

				for (int i = 0; i < 2; i++)
				{
					if (m_whdr[i] != null)
					{
						lock(m_whdr[i])
						{
							if (m_hwo != IntPtr.Zero)
								waveOutUnprepareHeader(m_hwo, m_whdr[i], (uint)Marshal.SizeOf(m_whdr[i]));

							m_whdr[i].Dispose();
							m_whdr[i] = null;
						}
					}
				}

				if (m_hwo != IntPtr.Zero)
					waveOutClose(m_hwo);

				m_hwo = IntPtr.Zero;
				m_wfmt = null;

			}

			/// <summary>
			/// Resume the playback of a paused sound.
			/// </summary>
			/// <returns>MMSYSERR.NOERROR if successful</returns>
			public Wave.MMSYSERR Resume()
			{
				return waveOutRestart(m_hwo);
			}

			/// <summary>
			/// Pause the playback of a sound.
			/// </summary>
			/// <returns>MMSYSERR.NOERROR if successful</returns>
			public Wave.MMSYSERR Pause()
			{
				return waveOutPause(m_hwo);
			}

			/// <summary>
			/// Get the volume of this sound.
			/// </summary>
			/// <param name="volLeft">Left channel volume level</param>
			/// <param name="volRight">Right channel volume level</param>
			/// <returns>MMSYSERR.NOERROR if successful</returns>
			public Wave.MMSYSERR GetVolume(ref ushort volLeft, ref ushort volRight)
			{
				uint vol = 0;

				Wave.MMSYSERR result = waveOutGetVolume(m_hwo, ref vol);
				if (result != Wave.MMSYSERR.NOERROR)
					return result;

				volLeft = (ushort)(vol & 0x0000ffff);
				volRight = (ushort)(vol >> 16);

				return Wave.MMSYSERR.NOERROR;
			}

			/// <summary>
			/// Sets the volume of this sound.
			/// </summary>
			/// <param name="volLeft">Left channel volume level</param>
			/// <param name="volRight">Right channel volume level</param>
			/// <returns>MMSYSERR.NOERROR if successful</returns>
			public Wave.MMSYSERR SetVolume(ushort volLeft, ushort volRight)
			{
				uint vol = ((uint)volLeft & 0x0000ffff) | ((uint)volRight << 16);
				return waveOutSetVolume(m_hwo, vol);
			}

			/// <summary>
			/// Clean up all resources.
			/// </summary>
			public void Dispose()
			{
				Stop();
			}
		}

		/// <summary>
		/// Defines the MessageWindow used to receive messages from the audio
		/// system.
		/// </summary>
		public class SoundMessageWindow : MessageWindow
		{
			public const int MM_WOM_OPEN  = 0x03BB;
			public const int MM_WOM_CLOSE = 0x03BC;
			public const int MM_WOM_DONE  = 0x03BD;

			// Instance of a playback interface
			protected WaveOut m_wo = null;

			public SoundMessageWindow(WaveOut wo)
			{
				m_wo = wo;
			}

			protected override void WndProc(ref Message msg)
			{
				switch (msg.Msg)
				{
					// When this message is encountered, a block is
					// done playing, so notify the WaveOut instance.
					case MM_WOM_DONE:
						m_wo.BlockDone(msg.WParam);
						break;

				}
				base.WndProc(ref msg);
			}
		}

		/// <summary>
		/// Maintain an instance of a MessageWindow that handles audio messages.
		/// </summary>
		protected SoundMessageWindow m_msgWindow = null;

		/// <summary>
		/// An instance of WaveFile used as the source for playing audio.
		/// </summary>
		protected WaveFile m_file = null;

		/// <summary>
		/// Create an instance of WaveOut.
		/// </summary>
		public WaveOut()
		{
			m_msgWindow = new SoundMessageWindow(this);
			m_file = new WaveFile();
		}

		/// <summary>
		///  Determine the number of available playback devices.
		/// </summary>
		/// <returns>Number of output devices</returns>
		public uint NumDevices()
		{
			return (uint)waveOutGetNumDevs();
		}

		/// <summary>
		/// Get the name of the specified playback device.
		/// </summary>
		/// <param name="deviceId">ID of the device</param>
		/// <param name="prodName">Destination string assigned the name</param>
		/// <returns>MMSYSERR.NOERROR if successful</returns>
		public Wave.MMSYSERR GetDeviceName(uint deviceId, ref string prodName)
		{
			WAVEOUTCAPS caps = new WAVEOUTCAPS();
			Wave.MMSYSERR result = waveOutGetDevCaps(deviceId, caps, caps.Size);
			if (result != Wave.MMSYSERR.NOERROR)
				return result;

			prodName = caps.szPname;

			return Wave.MMSYSERR.NOERROR;
		}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
麻豆久久久久久| 亚洲最色的网站| 一本高清dvd不卡在线观看 | 欧美成人猛片aaaaaaa| 岛国一区二区三区| 亚洲成人在线观看视频| 国产日韩欧美综合一区| 欧美美女直播网站| www.亚洲色图.com| 精品一区二区三区久久久| 亚洲精品精品亚洲| 久久久久国色av免费看影院| 欧美日韩亚洲另类| 色综合久久综合| 国内精品视频666| 亚洲高清免费观看高清完整版在线观看| 精品国产三级电影在线观看| 在线观看日韩av先锋影音电影院| 国产精品亚洲人在线观看| 日本欧美大码aⅴ在线播放| 亚洲精品欧美二区三区中文字幕| 亚洲精品一区二区三区四区高清| 欧美午夜精品久久久久久孕妇| 国产黄人亚洲片| 久久av资源站| 日韩高清在线观看| 亚洲一区二区三区四区五区中文| 国产精品欧美久久久久一区二区| 日韩欧美成人午夜| 欧美一区欧美二区| 欧美乱妇23p| 精品视频全国免费看| 在线观看视频欧美| 色婷婷久久久久swag精品| 成人毛片在线观看| 成人av资源站| 成人做爰69片免费看网站| 国产成人亚洲综合a∨婷婷| 久久er精品视频| 激情欧美一区二区| 国产麻豆午夜三级精品| 久久99国产精品久久| 青青草伊人久久| 日本不卡一二三区黄网| 无码av免费一区二区三区试看| 亚洲一区在线观看网站| 亚洲黄色免费网站| 亚洲免费av高清| 亚洲精品国产无套在线观| 亚洲欧美另类久久久精品| 亚洲毛片av在线| 亚洲小说欧美激情另类| 亚洲国产aⅴ天堂久久| 亚洲第一在线综合网站| 五月天一区二区| 青青草国产精品亚洲专区无| 久久疯狂做爰流白浆xx| 国产成人亚洲综合a∨婷婷图片| 高清视频一区二区| av亚洲精华国产精华精| 成人18精品视频| 欧美性欧美巨大黑白大战| 91精品国产综合久久久久久久久久| 欧美剧情电影在线观看完整版免费励志电影| 91黄色激情网站| 91精品国产欧美一区二区成人| 日韩天堂在线观看| 国产色一区二区| 亚洲欧美另类在线| 奇米精品一区二区三区在线观看一| 久久国产精品第一页| 国产精品99久久久久久宅男| 国产福利精品导航| 在线中文字幕不卡| 8x8x8国产精品| 久久久久99精品一区| 亚洲视频一二区| 亚洲444eee在线观看| 激情欧美一区二区| 色婷婷精品大在线视频| 欧美一区二区视频在线观看2020| 久久伊人中文字幕| 亚洲精品免费一二三区| 久久aⅴ国产欧美74aaa| 99久久婷婷国产精品综合| 欧美理论在线播放| 久久久综合精品| 一区二区三区毛片| 国产主播一区二区三区| 91麻豆福利精品推荐| 日韩视频免费观看高清完整版 | 久久久亚洲精品一区二区三区| 中文字幕在线视频一区| 日本中文字幕一区二区视频 | 久久超碰97中文字幕| 91网站在线播放| av电影天堂一区二区在线观看| 一区二区三区丝袜| 欧美人与禽zozo性伦| 色噜噜夜夜夜综合网| 日韩一区二区精品葵司在线| 国产精品久久国产精麻豆99网站 | 久久久久久久av麻豆果冻| 一区二区不卡在线播放 | 亚洲国产电影在线观看| 亚洲国产三级在线| 国产成人精品影院| 欧美一卡二卡三卡四卡| 亚洲精品国产精华液| 国产成人啪免费观看软件| 7777精品伊人久久久大香线蕉的| 国产精品动漫网站| 国产在线播放一区三区四| 欧美三级日韩三级| 中文字幕综合网| 国产剧情在线观看一区二区| 91麻豆精品国产91久久久使用方法 | 亚洲欧美色综合| 国产一区不卡视频| 337p亚洲精品色噜噜| 亚洲精品美腿丝袜| 99国产精品久久久久| 久久无码av三级| 久久精品国产99| 欧美一区二区三区喷汁尤物| 精品久久久久久久久久久院品网| 欧美一级片在线看| 欧美www视频| 亚洲第一成人在线| 91麻豆精东视频| 亚洲欧洲av在线| 粉嫩av亚洲一区二区图片| 久久亚洲欧美国产精品乐播| 久久精品国产一区二区三区免费看| 欧美日韩国产综合草草| 亚洲一区二区三区在线播放 | 欧美久久久久久久久久| 一区二区三区日韩精品| 99久久夜色精品国产网站| 欧美激情综合五月色丁香| 懂色av中文一区二区三区 | 亚洲午夜免费视频| 欧美色视频在线观看| 亚洲一区二区三区四区在线观看| 91国模大尺度私拍在线视频| 一区二区三区免费网站| 欧美色电影在线| 日韩制服丝袜av| 欧美一区二区三区播放老司机| 琪琪久久久久日韩精品| 欧美成人欧美edvon| 国产成人精品免费网站| 国产欧美一区二区三区沐欲| 国产成人久久精品77777最新版本| 国产三级欧美三级| 懂色中文一区二区在线播放| 中文字幕在线不卡| 欧美视频在线不卡| 日韩 欧美一区二区三区| 久久这里只精品最新地址| 成人高清视频在线观看| 亚洲精品大片www| 欧美精品一二三| 美国十次了思思久久精品导航| 欧美va亚洲va香蕉在线| 丁香婷婷深情五月亚洲| 亚洲免费伊人电影| 欧美一级二级三级蜜桃| 国产精品资源在线| 亚洲欧美欧美一区二区三区| 欧美人与禽zozo性伦| 国产资源精品在线观看| 中文字幕一区二区在线播放| 在线观看av不卡| 久久99精品久久只有精品| 亚洲国产高清aⅴ视频| 欧美日韩另类一区| 国产一区二区三区| 亚洲综合色成人| 日韩欧美一区二区久久婷婷| 成人av网站大全| 日韩专区欧美专区| 国产精品久久久久久亚洲毛片| 欧美色中文字幕| 国产精品亚洲一区二区三区在线| 亚洲精品视频自拍| 精品久久久久一区| 在线观看区一区二| 国产二区国产一区在线观看| 香蕉乱码成人久久天堂爱免费| 久久亚洲二区三区| 欧美丝袜自拍制服另类| 国产美女精品人人做人人爽| 亚洲综合在线五月| 久久精品欧美日韩| 91精品一区二区三区久久久久久| 成人av网站在线| 韩国女主播一区| 亚洲主播在线观看| 国产日韩高清在线|