コード例 #1
0
        private void DeviceNotification_DefaultDeviceChanged(object sender, DefaultDeviceChangedEventArgs e)
        {
            try
            {
                _defaultDeviceChanged = true;
                Trace.TraceInformation("Default device changed. New device: {0}, {1}", e.DataFlow.ToString(), e.Role.ToString());
                switch (e.DataFlow)
                {
                case DataFlow.Capture:
                    GetCapture(_isControllerMode, e.DeviceId);
                    break;

                case DataFlow.Render:
                    GetNewSoundOut();
                    break;
                }
            }
            catch (Exception exp)
            {
                Trace.TraceError(exp.Message);
            }
            finally
            {
                _defaultDeviceChanged = false;
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: mikepelley/cscore
 private static void OnDefaultDeviceChanged(object sender, DefaultDeviceChangedEventArgs e)
 {
     using (var enumerator = new MMDeviceEnumerator())
         using (var mmDevice = enumerator.GetDevice(e.DeviceId))
         {
             Console.WriteLine($"{mmDevice.FriendlyName} became default {e.Role} {e.DataFlow} device");
         }
 }
コード例 #3
0
ファイル: AudioEngine.cs プロジェクト: mshish/micser
        private async void DefaultDeviceChanged(object sender, DefaultDeviceChangedEventArgs e)
        {
            if (!IsRunning)
            {
                return;
            }

            await Task.Run(SetupDefaultEndpoint).ConfigureAwait(false);
        }
コード例 #4
0
        private void DefaultDeviceChanged(object sender, DefaultDeviceChangedEventArgs e)
        {
            MMDevice device = MyMMDeviceEnumerator.GetDevice(e.DeviceId);

            if (device != null && e.Role == Role.Multimedia && e.DataFlow == DataFlow.Render)
            {
                Log.D($"Default Audio Device Changed to {device.FriendlyName}, Flow: {device.DataFlow}");
                DefaultMmDevice = device;
            }
        }
コード例 #5
0
 private void HandleDefaultChanged(DefaultDeviceChangedEventArgs defaultChangedEvent)
 {
     if (defaultChangedEvent.IsDefaultEvent)
     {
         OnPropertyChanged("IsDefaultDevice");
     }
     else if (defaultChangedEvent.IsDefaultCommunicationsEvent)
     {
         OnPropertyChanged("IsDefaultCommunicationsDevice");
     }
 }
コード例 #6
0
 private void MMNotificationClient_DefaultDeviceChanged(object sender, DefaultDeviceChangedEventArgs e)
 {
     if (e.DeviceId.Equals(DispositivoAtual) == false)
     {
         //Console.Write("Default Device changed to: ");
         //Console.WriteLine(e.DeviceId);
         DispositivoAtual = e.DeviceId;
         Listen(false);
         UpdateFromDefaultDevice();
         Listen(true);
     }
 }
コード例 #7
0
 private void OnDefaultDeviceChanged(object sender, DefaultDeviceChangedEventArgs e)
 {
     // For some reason this event triggers twice.
     // We keep track of the previous state, and only raise the event if
     // we are now the default device and were not before.
     if (IsDefault && !_wasDefault)
     {
         _wasDefault = true;
         DeviceDefaultChanged?.Invoke(this);
     }
     else
     {
         _wasDefault = false;
     }
 }
コード例 #8
0
        private void MMNotificationClient_DefaultDeviceChanged(object sender, DefaultDeviceChangedEventArgs e)
        {
            if (e.DeviceId == _lastDefaultDeviceChanged)
            {
                return;
            }

            _lastDefaultDeviceChanged = e.DeviceId;
            if (CurrentSoundOutDevice?.Id == WindowsDefaultId)
            {
                Application.Current.Dispatcher.BeginInvoke(new Action(OnInvalidateSoundOut));
            }

            Application.Current.Dispatcher.BeginInvoke(new Action(UpdateDefaultAudioDevice));
        }
コード例 #9
0
        private void OnDefaultDeviceChanged(object sender, DefaultDeviceChangedEventArgs e)
        {
            if (e.DataFlow != Flow.ToDataFlow())
            {
                return;
            }

            bool newDefault = e.DeviceId == DeviceId;

            if (IsDefault != newDefault)
            {
                AppLogging.DebugLog(nameof(OnDefaultDeviceChanged), DeviceId, newDefault.ToString());
                IsDefault = newDefault;
                DeviceDefaultChanged?.Invoke(this);
            }
        }
コード例 #10
0
ファイル: CSCoreEngine.cs プロジェクト: xiaohszx/Hurricane
 void client_DefaultDeviceChanged(object sender, DefaultDeviceChangedEventArgs e)
 {
     if (Settings.SoundOutDeviceID == "-0" && e.DeviceID != _currentDeviceId)
     {
         _currentDeviceId = e.DeviceID;
         Thread t = new Thread(() =>
         {
             Thread.Sleep(100);
             Application.Current.Dispatcher.Invoke(UpdateSoundOut);
         })
         {
             IsBackground = true
         };
         t.Start();
     }
     _client.Dispose();
 }
コード例 #11
0
ファイル: CSCorePlayer.cs プロジェクト: kbalint/Dopamine
        private void MMNotificationClient_DefaultDeviceChanged(object sender, DefaultDeviceChangedEventArgs e)
        {
            // Only try to resume on new default device if not stopped
            if (this.canStop)
            {
                this.defaultDeviceChangedTimer.Stop();

                this.pauseAfterSwitchingDefaultDevice = !this.canPause;

                if (this.currentTime == null)
                {
                    this.currentTime = this.GetCurrentTime();
                    this.SuspendSoundOut();
                }

                this.defaultDeviceChangedTimer.Start();
            }
        }
コード例 #12
0
ファイル: SoundOutManager.cs プロジェクト: timyuheng/AMP
        private void _mmNotificationClient_DefaultDeviceChanged(object sender, DefaultDeviceChangedEventArgs e)
        {
            if (e.DeviceId == _lastDefaultDeviceChanged)
            {
                return;
            }
            _lastDefaultDeviceChanged = e.DeviceId;
            if (AnyListenSettings.Instance.Config.SoundOutDeviceID == DefaultDevicePlaceholder &&
                e.DeviceId != _currentDeviceId)
            {
                if (RefreshSoundOut != null)
                {
                    Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal,
                                                               new Action(OnRefreshSoundOut));
                }
            }

            Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(UpdateDefaultAudioDevice));
        }
コード例 #13
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="aEvent"></param>
        public void OnDefaultMultiMediaDeviceChanged(object sender, DefaultDeviceChangedEventArgs aEvent)
        {
            if (aEvent != null && (aEvent.DataFlow == DataFlow.Render && (aEvent.Role == Role.Multimedia || aEvent.Role == Role.Console)))
            {
                if (_mMdevice != null)
                {
                    _mMdevice.Dispose();
                    _mMdevice = null;
                }

                if (_mMdeviceEnumerator != null)
                {
                    _mMdeviceEnumerator.Dispose();
                    _mMdeviceEnumerator = null;
                }
                Stop();
                CreateDevice(OnDefaultMultiMediaDeviceChanged, OnVolumeNotification);
                //ResetAudioManagerThreadSafe();
            }
        }
コード例 #14
0
 private void HandleDefaultChanged(DefaultDeviceChangedEventArgs defaultChangedEvent)
 {
     if (defaultChangedEvent.IsDefaultEvent)
         OnPropertyChanged("IsDefaultDevice");
     else if (defaultChangedEvent.IsDefaultCommunicationsEvent)
         OnPropertyChanged("IsDefaultCommunicationsDevice");
 }
コード例 #15
0
 private void MmNotificationClient_DefaultDeviceChanged(object sender, DefaultDeviceChangedEventArgs e)
 {
     this.audioDevicesChangedTimer.Stop();
     this.audioDevicesChangedTimer.Start();
 }
コード例 #16
0
 private void AudioEndpointDevice_OnVolumeNotification(object sender, DefaultDeviceChangedEventArgs e)
 {
     // Not used
     // here
 }
コード例 #17
0
ファイル: Core.cs プロジェクト: catright/Wale
 /// <summary>
 /// Get new default device
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void MMN_DefaultDeviceChanged(object sender, DefaultDeviceChangedEventArgs e) => GetMMD();
コード例 #18
0
ファイル: Core.cs プロジェクト: SWThinker/Wale
 private void CoreTestMainWindow_DefaultDeviceChanged(object sender, DefaultDeviceChangedEventArgs e) => GetMMD();