public static extern MmResult waveOutOpenWindow(out IntPtr hWaveOut, IntPtr uDeviceID, WaveFormat lpFormat, IntPtr callbackWindowHandle, IntPtr dwInstance, WaveInOutOpenFlags dwFlags);
Esempio n. 2
0
 public static extern MmResult waveInOpenWindow(out IntPtr hWaveIn, IntPtr uDeviceID, WaveFormatProvider lpFormat, IntPtr callbackWindowHandle, IntPtr dwInstance, WaveInOutOpenFlags dwFlags);
 public static extern MmResult waveOutOpen(out IntPtr hWaveOut, IntPtr uDeviceID, WaveFormat lpFormat, WaveCallback dwCallback, IntPtr dwInstance, WaveInOutOpenFlags dwFlags);
Esempio n. 4
0
 public static extern MmResult waveInOpenWithWindow(out IntPtr hWaveIn, IntPtr device, WaveFormat pwfx, IntPtr window, IntPtr dwInstance, WaveInOutOpenFlags fdwOpen);
Esempio n. 5
0
 public static extern MmResult waveInOpen(out IntPtr hWaveIn, IntPtr uDeviceID, WaveFormatProvider lpFormat, WaveCallback dwCallback, IntPtr dwInstance, WaveInOutOpenFlags dwFlags);
Esempio n. 6
0
 public static extern MmResult waveOutOpenWithWindow(out IntPtr hWaveOut, IntPtr device, WaveFormat lpFormat, IntPtr window, IntPtr dwInstance, WaveInOutOpenFlags dwFlags);
Esempio n. 7
0
 public static extern MmResult waveInOpen(out IntPtr hWaveIn, IntPtr device, WaveFormat pwfx, WaveCallback dwCallback, IntPtr dwInstance, WaveInOutOpenFlags fdwOpen);
Esempio n. 8
0
        /// <summary>
        /// Opens the audio device.
        /// </summary>
        /// <param name="deviceId">The device identifier.</param>
        /// <param name="format">The format.</param>
        /// <param name="callbackHandle">The callback window handle.</param>
        /// <param name="instanceHandle">The instance handle.</param>
        /// <param name="openFlags">The open flags.</param>
        /// <returns>The audio device handle.</returns>
        /// <exception cref="TimeoutException">Occurs when the interop lock cannot be acquired.</exception>
        /// <exception cref="LegacyAudioException">Occurs when the MME interop call fails.</exception>
        public static IntPtr OpenAudioDevice(int deviceId, WaveFormat format, SafeWaitHandle callbackHandle, IntPtr instanceHandle, WaveInOutOpenFlags openFlags)
        {
            if (deviceId < -1)
            {
                throw new ArgumentException($"Invalid Device ID {deviceId}", nameof(deviceId));
            }
            if (!TryEnterDeviceOperation())
            {
                return(IntPtr.Zero);
            }

            try
            {
                LegacyAudioException.Try(
                    NativeMethods.OpenDeviceOnWindow(out var hWaveOut, deviceId, format, callbackHandle, instanceHandle, openFlags),
                    nameof(NativeMethods.OpenDeviceOnWindow));

                return(hWaveOut);
            }
            finally { Monitor.Exit(SyncLock); }
        }
Esempio n. 9
0
 public static extern MmResult waveOutOpen(out IntPtr hWaveOut, IntPtr device, WaveFormat lpFormat, WaveCallback dwCallback, IntPtr dwInstance, WaveInOutOpenFlags dwFlags);
Esempio n. 10
0
 public static extern MmResult waveInOpenWithWindow(out IntPtr hWaveIn, IntPtr device, WaveFormat pwfx, IntPtr window, IntPtr dwInstance, WaveInOutOpenFlags fdwOpen);
Esempio n. 11
0
 public static extern MmResult waveInOpen(out IntPtr hWaveIn, IntPtr device, WaveFormat pwfx, WaveCallback dwCallback, IntPtr dwInstance, WaveInOutOpenFlags fdwOpen);
Esempio n. 12
0
 public static extern MmResult waveOutOpenWithWindow(out IntPtr hWaveOut, IntPtr device, WaveFormat lpFormat, IntPtr window, IntPtr dwInstance, WaveInOutOpenFlags dwFlags);
Esempio n. 13
0
 public static extern MultimediaResult waveOutOpenWindow(out IntPtr hWaveOut,
                                                         IntPtr uDeviceID,
                                                         WaveFormat lpFormat,
                                                         IntPtr callbackWindowHandle,
                                                         IntPtr dwInstance,
                                                         WaveInOutOpenFlags dwFlags);
Esempio n. 14
0
        /// <summary>
        /// Opens the audio device.
        /// </summary>
        /// <param name="deviceId">The device identifier.</param>
        /// <param name="format">The format.</param>
        /// <param name="callbackWindowHandle">The callback window handle.</param>
        /// <param name="instanceHandle">The instance handle.</param>
        /// <param name="openFlags">The open flags.</param>
        /// <returns>The audio device handle</returns>
        /// <exception cref="TimeoutException">Occurs when the interop lock cannot be acquired.</exception>
        /// <exception cref="MmException">Occurs when the MME interop call fails</exception>
        public static IntPtr OpenAudioDevice(int deviceId, WaveFormat format, IntPtr callbackWindowHandle, IntPtr instanceHandle, WaveInOutOpenFlags openFlags)
        {
            if (deviceId < -1)
            {
                deviceId = -1;
            }
            var acquired = false;

            Monitor.TryEnter(SyncLock, LockTimeout, ref acquired);
            if (acquired == false)
            {
                throw new TimeoutException(TimeoutErrorMessage);
            }

            try
            {
                MmException.Try(
                    NativeMethods.waveOutOpenWindow(out IntPtr hWaveOut, deviceId, format, callbackWindowHandle, instanceHandle, openFlags),
                    nameof(NativeMethods.waveOutOpenWindow));

                return(hWaveOut);
            }
            catch { throw; }
            finally { Monitor.Exit(SyncLock); }
        }