/// <summary> /// Gets the current position in bytes from the wave output device. /// (n.b. this is not the same thing as the position within your reader /// stream - it calls directly into waveOutGetPosition) /// </summary> /// <returns>Position in bytes</returns> public long GetPosition() { lock (WaveOutLock) { var time = new MmTime() { Type = MmTime.TIME_BYTES }; MmException.Try(WaveInterop.NativeMethods.waveOutGetPosition(DeviceHandle, out time, Marshal.SizeOf(time)), nameof(WaveInterop.NativeMethods.waveOutGetPosition)); if (time.Type != MmTime.TIME_BYTES) { throw new Exception(string.Format($"{nameof(WaveInterop.NativeMethods.waveOutGetPosition)}: wType -> Expected {0}, Received {1}", MmTime.TIME_BYTES, time.Type)); } return(time.CB); } }
public static extern MmResult waveOutGetPosition(IntPtr hWaveOut, out MmTime mmTime, int uSize);