internal AudioCaptureClient(AudioClient parent, IAudioCaptureClient realClient)
 {
     _Parent = parent;
     _RealClient = realClient;
 }
示例#2
0
 /* added -> */
 private void GetAudioClient()
 {
     object result;
     Marshal.ThrowExceptionForHR(_RealDevice.Activate(ref IID_IAudioClient, CLSCTX.ALL, IntPtr.Zero, out result));
     _AudioClient = new AudioClient(result as IAudioClient);
 }
 internal AudioCaptureClient(AudioClient parent, IAudioCaptureClient realClient)
 {
     _Parent     = parent;
     _RealClient = realClient;
 }
示例#4
0
        private void selectDeviceImpl(string devId)
        {
            releaseDevice();

            _capDevice = _devices.GetDevice(devId.Trim());
            int idx = _deviceInfos.FindIndex((di) => { return di.DeviceId == devId; });
            if (_capDevice == null)
            {
#warning 例外
            }
            _capDeviceId = _capDevice.Id;

            // デバイスに適した初期化方法を決定
            AudioClientStreamFlags streamFlags = AudioClientStreamFlags.NoPersist;
            if (_capDevice.DataFlow == EDataFlow.eRender)
                streamFlags = AudioClientStreamFlags.Loopback |
                    AudioClientStreamFlags.EventCallback; // 実際は発生してくれない
          
            // フォーマット
            if(_audioClient != null) _capDevice.ReleaseAudioClient();

            try
            {
                _audioClient = _capDevice.AudioClient;
                _capFormat = _audioClient.MixFormat;
                _pitchAnalyzer.SampleFrequency = (double)(_capFormat.nSamplesPerSec);

                // 初期化
                _audioClient.Initialize(AudioClientShareMode.Shared,
                    streamFlags, 300 /*ms*/ * 10000, 0, _capFormat, Guid.Empty);
                _capClient = _audioClient.AudioCaptureClient;

                // イベント発火
                DeviceSelectedEventHandler del = DeviceSelected;
                if (del != null)
                {
                    del.Invoke(this, new DeviceSelectedEventArgs(_capDevice, idx));
                }
            }
            catch (System.Runtime.InteropServices.COMException ex)
            {
#warning エラー処理
                _audioClient = null;
                _capClient = null;
            }
        }