internal void FireStateChanged(AudioSessionState NewState) { if (OnStateChanged != null) { OnStateChanged(this, NewState); } }
// Fires on @out.Play() and @out.Stop() public void OnStateChanged(AudioSessionState state) { if (state == AudioSessionState.AudioSessionStateActive) { OnVolumeChanged(appVolume.SimpleAudioVolume.Volume, appVolume.SimpleAudioVolume.Mute); } }
/// <summary> /// Retrieves the current state of the audio session. /// <seealso cref="SessionState"/> /// </summary> /// <param name="state">A variable into which the method writes the current session state.</param> /// <returns>HRESULT</returns> public unsafe int GetStateNative(out AudioSessionState state) { fixed(void *p = &state) { return(InteropCalls.CallI(UnsafeBasePtr, p, ((void **)(*(void **)UnsafeBasePtr))[3])); } }
/// <summary> /// Notifies the client that the stream-activity state of the session has changed. /// </summary> /// <param name="state">The new session state.</param> /// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns> public int OnStateChanged( [In] AudioSessionState state) { audioSessionEventsHandler.OnStateChanged(state); return(0); }
/// <summary> /// Notifies the client that the stream-activity state of the session has changed. /// </summary> /// <param name="newState">The new session state.</param> /// <returns>HRESULT</returns> int IAudioSessionEvents.OnStateChanged(AudioSessionState newState) { if (StateChanged != null) { StateChanged(this, new AudioSessionStateChangedEventArgs(newState)); } return((int)Win32.HResult.S_OK); }
private void SessionStateChanged(object sender, AudioSessionState newState) { if (newState == AudioSessionState.AudioSessionStateExpired) { session.Dispose(); Dispatcher.Invoke(() => { MainWindow.instance.sessionControlStackPanel.Children.Remove(this); }); } }
void IAudioSessionEventsHandler.OnStateChanged(AudioSessionState state) { if (state != AudioSessionState.AudioSessionStateExpired) { return; } SessionEnded?.Invoke(this); }
public int OnStateChanged(AudioSessionState newState) { if (newState == AudioSessionState.Expired) { this.SessionEnded?.Invoke(); } return(0); }
/// <summary> /// Notifies the client that the stream-activity state of the session has changed. /// </summary> /// <param name="newState">The new session state.</param> /// <returns>HRESULT</returns> void IAudioSessionEvents.OnStateChanged(AudioSessionState newState) { EventHandler <AudioSessionStateChangedEventArgs> handler = StateChanged; if (handler != null) { handler(this, new AudioSessionStateChangedEventArgs(newState)); } }
public int OnStateChanged(AudioSessionState NewState) { if (_sessionControl != null) { SessionStateChangedEventArgs e = new SessionStateChangedEventArgs(NewState); _sessionControl.FireStateChanged(e); } return(0); }
private void SessionStateChanged(object sender, AudioSessionState newState) { if (newState == AudioSessionState.AudioSessionStateExpired) { session.Dispose(); AudioMixerWindow.instance.SessionVolumeChanged(session, 0f, true); Dispatcher.Invoke(() => { AudioMixerWindow.instance.sessionStackPanel.Children.Remove(this); }); } }
public void OnStateChanged(AudioSessionState NewState) { // System.Diagnostics.Debug.WriteLine("STATE CHANGED. EVENT CLIENT"); if (StateChanged != null) { StateChangedEventArgs oDisConnectSessionEventArgs = new StateChangedEventArgs(NewState); StateChanged(this, oDisConnectSessionEventArgs); } }
/// <summary> /// Notifies the client that the stream-activity state of the session has changed. /// </summary> /// <param name="newState">The new session state.</param> /// <returns>HRESULT</returns> int IAudioSessionEvents.OnStateChanged(AudioSessionState newState) { EventHandler <AudioSessionStateChangedEventArgs> handler = this.StateChanged; if (handler != null) { handler(this, new AudioSessionStateChangedEventArgs(newState)); } return((int)Win32.HResult.S_OK); }
// Lists all devices, and for each device all processes that are currently playing sound using that device public static List <SoundInfoDevice> getSoundInfo() { List <SoundInfoDevice> soundInfoDevices = new List <SoundInfoDevice>(); DeviceEnumerator enumerator = new DeviceEnumerator(); IMMDeviceEnumerator deviceEnumerator = (IMMDeviceEnumerator)enumerator; IMMDeviceCollection deviceCollection = deviceEnumerator.EnumAudioEndpoints(EDataFlow.eRender, DeviceStatemask.DEVICE_STATE_ACTIVE); uint deviceCount = deviceCollection.GetCount(); for (uint i = 0; i < deviceCount; i++) { SoundInfoDevice soundInfoDevice = new SoundInfoDevice(); soundInfoDevices.Add(soundInfoDevice); IMMDevice device = deviceCollection.Item(i); string deviceId = device.GetId(); soundInfoDevice.ID = deviceId; IMMPropertyStore propertyStore = device.OpenPropertyStore(ProperyStoreMode.STGM_READ); PropertyKey propertyKeyDeviceDesc = new PropertyKey(); propertyKeyDeviceDesc.fmtid = new Guid(0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0); propertyKeyDeviceDesc.pid = 2; PropVariant deviceNamePtr = propertyStore.GetValue(ref propertyKeyDeviceDesc); string deviceName = Marshal.PtrToStringUni(deviceNamePtr.pszVal); soundInfoDevice.name = deviceName; Guid guidAudioSessionManager2 = new Guid("77AA99A0-1BD6-484F-8BC7-2C654C9A9B6F"); IAudioSessionManager2 audioSessionManager = (IAudioSessionManager2)device.Activate(ref guidAudioSessionManager2, (int)ClsCtx.CLSCTX_ALL, IntPtr.Zero); IAudioSessionEnumerator sessionEnumerator = audioSessionManager.GetSessionEnumerator(); int sessionCount = sessionEnumerator.GetCount(); for (int j = 0; j < sessionCount; j++) { IAudioSessionControl audioSessionControl = sessionEnumerator.GetSession(j); IAudioSessionControl2 audioSessionControl2 = (IAudioSessionControl2)audioSessionControl; AudioSessionState state = audioSessionControl.GetState(); if (state == AudioSessionState.AudioSessionStateActive) { SoundInfoSession soundInfoSession = new SoundInfoSession(); soundInfoDevice.sessions.Add(soundInfoSession); string displayName = audioSessionControl.GetDisplayName(); string iconPath = audioSessionControl.GetIconPath(); int processId = audioSessionControl2.GetProcessId(); string processName = Process.GetProcessById(processId).MainWindowTitle; soundInfoSession.pid = processId; soundInfoSession.windowName = processName; } } } return(soundInfoDevices); }
internal OSAudioApp(MMDevice device) { try { aev = device.AudioEndpointVolume; } catch (InvalidCastException) { Console.WriteLine("AudioEndpointVolume Error"); } State = AudioSessionState.AudioSessionStateActive; }
public void SessionStateChangedArgs_Sets_Session_State_Expired() { var mockAudioSession = new Mock <IAudioSession>(); const AudioSessionState state = AudioSessionState.Expired; var args = new SessionStateChangedArgs(mockAudioSession.Object, state); Assert.NotNull(args); Assert.NotNull(args.Session); Assert.Equal(mockAudioSession.Object, args.Session); Assert.Equal(state, args.State); }
internal static EAudioSessionState AsEAudioSessionState(this AudioSessionState state) { switch (state) { case AudioSessionState.Inactive: return(EAudioSessionState.AudioSessionStateInactive); case AudioSessionState.Active: return(EAudioSessionState.AudioSessionStateActive); case AudioSessionState.Expired: return(EAudioSessionState.AudioSessionStateExpired); default: throw new ArgumentOutOfRangeException(nameof(state), state, null); } }
public static string GetStringAudioState(AudioSessionState state) { switch (state) { case AudioSessionState.AudioSessionStateExpired: return("Expired"); case AudioSessionState.AudioSessionStateActive: return("Active"); case AudioSessionState.AudioSessionStateInactive: return("Inactive"); default: return(string.Empty); } }
public void MaybeRefreshSessions() { if (_shouldRefreshSessions) { _shouldRefreshSessions = false; _sessManager.RefreshSessions(); int count = _sessManager.Sessions.Count; for (int i = 0; i < count; i++) { AudioSessionControl session = _sessManager.Sessions[i]; if (session.GetProcessID == 0) { continue; } AudioSessionState state = session.State; String fn = ""; try { Process p = Process.GetProcessById((int)(session.GetProcessID)); fn = p.ProcessName + ".exe"; } catch (Exception e) { _logger.Error($"Could not get process name. {e.Message}", e); } if (state != AudioSessionState.AudioSessionStateExpired) { newSessionEvent(session, fn); var stateStr = (state == AudioSessionState.AudioSessionStateActive) ? " (ACTIVE)" : ""; _logger.Info($"'{fn}' {session.GetProcessID} -- {session.AudioMeterInformation.MasterPeakValue + stateStr}"); } } } }
private bool sessionIsActive(IAudioSessionEnumerator sessionEnumerator, int sessionIndex) { IAudioSessionControl sessionControl = null; try { sessionEnumerator.GetSession(sessionIndex, out sessionControl); AudioSessionState sessionState = AudioSessionState.AudioSessionStateInactive; sessionControl.GetState(out sessionState); return(sessionState == AudioSessionState.AudioSessionStateActive); } finally { if (sessionControl != null) { Marshal.ReleaseComObject(sessionControl); } } }
private void RefreshProperties() { if (_isDisposed) { return; } ComThread.Invoke(() => { _isSystemSession = AudioSessionControl.IsSystemSoundsSession() == 0; AudioSessionControl.GetDisplayName(out _displayName); AudioSessionControl.GetIconPath(out _iconPath); EAudioSessionState state; AudioSessionControl.GetState(out state); _state = state.AsAudioSessionState(); uint processId; AudioSessionControl.GetProcessId(out processId); _processId = (int)processId; AudioSessionControl.GetSessionIdentifier(out _id); try { if (ProcessId > 0) { var proc = Process.GetProcessById(ProcessId); _executablePath = proc.MainModule.FileName; _fileDescription = proc.MainModule.FileVersionInfo.FileDescription; } } catch { _fileDescription = ""; } }); }
private void Session_OnStateChanged(object sender, AudioSessionState newState) { AudioSessionControl2 senderSession = (AudioSessionControl2)sender; AudioSession changedSession = getAudioSessionObject(senderSession); if (Main.LOG_EVENTS) { Console.WriteLine(changedSession.ToString() + "\nState=" + newState.ToString()); } if (newState == AudioSessionState.AudioSessionStateExpired) { expiredSessions.Add(changedSession.id); } else { if (expiredSessions.Contains(changedSession.id)) { expiredSessions.Remove(changedSession.id); } } }
int IAudioSessionEvents.OnStateChanged(AudioSessionState newState) { return 0; }
public int OnStateChanged(AudioSessionState NewState) { _Parent.FireStateChanged(NewState); return(0); }
public int OnStateChanged(AudioSessionState NewState) { _Parent.FireStateChanged(NewState); return 0; }
public AudioSessionStateChangedEventArgs(AudioSessionState newState) { NewState = newState; }
/// <summary> /// Notifies the client that the stream-activity state of the session has changed. /// </summary> /// <param name="newState">The new session state.</param> /// <returns>HRESULT</returns> int IAudioSessionEvents.OnStateChanged(AudioSessionState newState) { if (StateChanged != null) StateChanged(this, new AudioSessionStateChangedEventArgs(newState)); return (int) Win32.HResult.S_OK; }
public HRESULT OnStateChanged(AudioSessionState NewState) { return(((delegate * unmanaged <IAudioSessionEvents *, AudioSessionState, int>)(lpVtbl[8]))((IAudioSessionEvents *)Unsafe.AsPointer(ref this), NewState)); }
public void FireStateChanged(AudioSessionState NewState) { OnStateChanged?.Invoke(this, NewState); }
public SessionStateChangedEventArgs(AudioSessionState state) { State = state; }
int IAudioSessionEvents.OnStateChanged(AudioSessionState state) { Debug.WriteLine(nameof(IAudioSessionEvents.OnStateChanged)); return(0); }
public void OnStateChanged(AudioSessionState state) { }
internal void FireStateChanged(AudioSessionState NewState) { if (OnStateChanged != null) OnStateChanged(this, NewState); }
/// <summary> /// Notifies the client that the stream-activity state of the session has changed. /// </summary> /// <param name="newState">The new session state.</param> /// <returns>HRESULT</returns> int IAudioSessionEvents.OnStateChanged(AudioSessionState newState) { EventHandler<AudioSessionStateChangedEventArgs> handler = this.StateChanged; if (handler != null) handler(this, new AudioSessionStateChangedEventArgs(newState)); return (int) Win32.HResult.S_OK; }
public int OnStateChanged(AudioSessionState NewState) { if (_sessionControl != null) { SessionStateChangedEventArgs e = new SessionStateChangedEventArgs(NewState); _sessionControl.FireStateChanged(e); } return 0; }
public int OnStateChanged(AudioSessionState NewState) { return 0; }
int IAudioSessionEvents.OnStateChanged(AudioSessionState newState) { return(0); }
/// <summary> /// The GetState method retrieves the current state of the audio session. /// </summary> /// <returns>HRESULT</returns> public unsafe int GetStateNative(out AudioSessionState state) { fixed (void* p = &state) { return InteropCalls.CallI(_basePtr, p, ((void**)(*(void**)_basePtr))[3]); } }
/// <summary> /// Notifies the client that the stream-activity state of the session has changed. /// </summary> /// <param name="newState">The new session state.</param> /// <returns>HRESULT</returns> int IAudioSessionEvents.OnStateChanged(AudioSessionState newState) { StateChanged?.Invoke(this, new AudioSessionStateChangedEventArgs(newState)); return(0); }