コード例 #1
0
ファイル: CAudioPlay.cs プロジェクト: gchudov/WindowsMediaLib
        static public WaveOutCaps[] GetDevs()
        {
            int iCount = waveOut.GetNumDevs();

            WaveOutCaps[] pwocRet = new WaveOutCaps[iCount];

            for (int x = 0; x < iCount; x++)
            {
                pwocRet[x] = new WaveOutCaps();
                int mmr = waveOut.GetDevCaps(x, pwocRet[x], Marshal.SizeOf(pwocRet[x]));
                waveOut.ThrowExceptionForError(mmr);
            }

            return(pwocRet);
        }
コード例 #2
0
        public ArrayList getOutputDevices() //fill sound recording devices array
        {
            ArrayList arrLst = new ArrayList();
            int       waveOutDevicesCount = waveOutGetNumDevs(); //get total

            if (waveOutDevicesCount > 0)
            {
                for (int uDeviceID = 0; uDeviceID < waveOutDevicesCount; uDeviceID++)
                {
                    WaveOutCaps waveOutCaps = new WaveOutCaps();
                    waveOutGetDevCapsA(uDeviceID, ref waveOutCaps, Marshal.SizeOf(typeof(WaveOutCaps)));
                    arrLst.Add(new string(waveOutCaps.szPname).Remove(new string(waveOutCaps.szPname).IndexOf('\0')).Trim());
                }
            }
            return(arrLst);
        }
コード例 #3
0
ファイル: WaveOut.cs プロジェクト: mctr909/InstPlayer
        /// <summary>
        /// WAVE出力ポートのリストを取得します。
        /// </summary>
        public static List <DeviceItem> GetDeviceList()
        {
            var deviceList = new List <DeviceItem>();

            var waveOutCaps = new WaveOutCaps();

            var item = new DeviceItem();

            item.Name = "Wave Mapper";
            item.ID   = WaveMapper;
            deviceList.Add(item);

            for (uint id = 0; id < NumDevs; id++)
            {
                var ret     = waveOutGetDevCaps(id, ref waveOutCaps, Marshal.SizeOf(typeof(WaveOutCaps)));
                var tmpName = Encoding.Default.GetString(waveOutCaps.szPname);
                var remIdx  = tmpName.IndexOf("\0");
                if (0 <= remIdx)
                {
                    tmpName = tmpName.Remove(remIdx);
                }
                item      = new DeviceItem();
                item.Name = (ret == MMResult.MMSYSERR_NOERROR) ? tmpName : "No Name";
                item.ID   = id;
                deviceList.Add(item);
            }

            for (int i = 0; i < deviceList.Count; i++)
            {
                var dev = deviceList[i];
                if (dev.ID == mSelectedDevice.ID && dev.Name == mSelectedDevice.Name)
                {
                    deviceList[i].Selected = true;
                }
                else
                {
                    deviceList[i].Selected = false;
                }
            }

            return(deviceList);
        }
コード例 #4
0
        /// <summary>
        /// 現在、コンピューターに存在しているオーディオデバイスを取得します。
        /// </summary>
        /// <returns>オーディオデバイスの列挙子。存在しないときは0件の列挙子を返却します。</returns>
        /// <exception cref="IndexOutOfRangeException">オーディオデバイスのインデックス例外。</exception>
        /// <exception cref="InvalidOperationException">再生デバイスの提供または、不明な例外。</exception>
        /// <exception cref="OutOfMemoryException">メモリーの割当、ロックの例外。</exception>
        public static IEnumerable <AudioDevice> Find()
        {
            var devices     = new List <AudioDevice>();
            var waveOutCaps = new WaveOutCaps();
            var deviceCount = waveOutGetNumDevs();

            for (int id = 0; id < deviceCount; id++)
            {
                var codeValue = (MMRESULT)waveOutGetDevCaps(id, ref waveOutCaps, Marshal.SizeOf(typeof(WaveOutCaps)));
                var device    = new AudioDevice();

                if (codeValue == MMRESULT.MMSYSERR_NOERROR)
                {
                    device.Id   = id;
                    device.Name = waveOutCaps.szPname;
                    devices.Add(device);
                }
                else
                {
                    // エラー処理
                    switch (codeValue)
                    {
                    case MMRESULT.MMSYSERR_BADDEVICEID:
                        throw new IndexOutOfRangeException($"指定されたインデックス {id} は領域外の値です。");

                    case MMRESULT.MMSYSERR_NODRIVER:
                        throw new InvalidOperationException($"再生デバイスの提供がありませんでした。");

                    case MMRESULT.MMSYSERR_NOMEM:
                        throw new OutOfMemoryException("メモリーの割当またはロックができませんでした。");

                    default:
                        throw new InvalidOperationException($"インデックス {id} は、特定できないエラー ({codeValue}) が発生しました。");
                    }
                }
            }

            return(devices);
        }
コード例 #5
0
ファイル: CAudioPlay.cs プロジェクト: gchudov/WindowsMediaLib
        /// <summary>
        /// Create the player
        /// </summary>
        /// <param name="iDevice">Zero based index of the playback device.  See GetDevs for a list of devices.</param>
        public CAudioPlay(int iDevice, Form fForm)
        {
            m_DeviceIndex = iDevice;
            m_fForm       = fForm;

            WaveOutCaps woc = new WaveOutCaps();
            int         mmr = waveOut.GetDevCaps(iDevice, woc, Marshal.SizeOf(woc));

            waveOut.ThrowExceptionForError(mmr);

            m_WaveCaps = woc.dwSupport;

            m_bIsSeekable      = false;
            m_bIsBroadcast     = false;
            m_dwAudioOutputNum = -1;
            m_hrAsync          = 0;
            m_hWaveOut         = IntPtr.Zero;
            m_hMixer           = IntPtr.Zero;
            m_pReader          = null;
            m_pHeaderInfo      = null;
            m_cnsFileDuration  = 0;
            m_pWfx             = null;
            m_MaxSampleSize    = -1;
            m_OldTime          = -1;
            m_UseNext          = 0;
            m_InsBuf           = new INSBuf[MAXBUFFERS];

            // Create an event for asynchronous calls.
            // When code in this class makes a call to an asynchronous
            //  method, it will wait for the event to be set to resume
            //  processing.
            m_hAsyncEvent = new AutoResetEvent(false);

            // Create a reader object, requesting only playback rights.
            WMUtils.WMCreateReader(IntPtr.Zero, Rights.Playback, out m_pReader);
        }
コード例 #6
0
ファイル: WinMM.cs プロジェクト: RoelofSol/DeOps
 public static extern int waveOutGetDevCaps(int uDeviceID, ref WaveOutCaps pwoc, int cbwoc);
コード例 #7
0
 public static extern MmResult waveOutGetDevCaps(IntPtr deviceID, out WaveOutCaps waveOutCaps, uint cbwaveOutCaps);
コード例 #8
0
 public static extern int waveOutGetDevCaps(uint uDeviceID, out WaveOutCaps pwoc, int cbwoc);
コード例 #9
0
        /// <summary>
        ///     Gets the wave out devices.
        /// </summary>
        /// <returns>A list of wave out devices</returns>
        public static List<string> GetWaveOutDevices()
        {
            var devices = new List<string>();
            var deviceCount = waveOutGetNumDevs();

            for (var i = -1; i < deviceCount; i++)
            {
                var waveOutCaps = new WaveOutCaps();
                waveOutGetDevCaps(i, ref waveOutCaps, Marshal.SizeOf(typeof (WaveOutCaps)));
                var deviceName = new string(waveOutCaps.szPname);

                if (deviceName.Contains('\0'))
                    deviceName = deviceName.Substring(0, deviceName.IndexOf('\0'));

                devices.Add(deviceName);
            }

            return devices;
        }
コード例 #10
0
 private static extern int waveOutGetDevCaps(int uDeviceId, ref WaveOutCaps lpCaps, int uSize);
コード例 #11
0
ファイル: WaveOut.cs プロジェクト: mctr909/InstPlayer
 private static extern MMResult waveOutGetDevCaps([MarshalAs(UnmanagedType.U4)] uint uDeviceID, ref WaveOutCaps pwoc, [MarshalAs(UnmanagedType.U4)] int cbwoc);
コード例 #12
0
ファイル: NativeMethods.cs プロジェクト: hoangduit/cscore
 public static extern MmResult waveOutGetDevCaps(IntPtr deviceID, out WaveOutCaps waveOutCaps, uint cbwaveOutCaps);
コード例 #13
0
 private static extern int waveOutGetDevCaps(int uDeviceID, ref WaveOutCaps pwoc, int cbwoc);
コード例 #14
0
 public static extern int waveOutGetDevCaps(int uDeviceID, ref WaveOutCaps lpCaps, int uSize);