Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Master issue: Missing sessions when audio device, session enumerator, etc. are invalidated #1305

Open
riverar opened this issue Jan 26, 2023 · 10 comments
Labels
type: bug A bug in EarTrumpet

Comments

@riverar
Copy link
Contributor

riverar commented Jan 26, 2023

Tracking issues related to our mishandling of scenarios where the audio device, session enumerator, etc. become invalidated. The "turn everything off/on again" procedure we need to implement is documented at https://learn.microsoft.com/windows/win32/coreaudio/recovering-from-an-invalid-device-error.

#483
#529
#574 (contains workaround)
#587
#814
#846
#848
#902
#940
#977
#1049
#1072
#1131
#1252
#1281
#1314
#1329
#1339
#1384
#1407
#1487
#1533

@lockcole
Copy link

#846 is also describing the same issue.

@riverar
Copy link
Contributor Author

riverar commented Jan 27, 2023

@lockcole Perfect, thanks!

@HydrantHunter
Copy link

Is issue #574 also related to this?

@riverar
Copy link
Contributor Author

riverar commented May 26, 2023

Yup, good eye @HydrantHunter!

@riverar
Copy link
Contributor Author

riverar commented May 26, 2023

I made sure to mark that one with (workaround) so folks see your post.

@HydrantHunter
Copy link

Thank you, @riverar - hopefully the workaround is of use to others, even if it is just to avoid the relatively minor effort of restarting EarTrumpet. Apologies for the ping, but it looks like you linked to this issue (1305) rather than 574 on the list above.

@riverar
Copy link
Contributor Author

riverar commented May 26, 2023

Fixed, thanks again.

@403CTRLer
Copy link

Thanks for linking this issue here, and also I've forgot to mention that the spatial audio software keeps switching to off on all devices connected while using after restarting.
The work around you've mentioned, I've tried that already and it remains the same if I change the spatial audio again. Can you add a refresh button that restarts the EarTrumpet's internal values to avoid restarting the application, if possible?

@lockcole
Copy link

Hi,
Following is the debug output captured when I tried to reproduce the problem.
Grateful if advise could be provided for the next part I should look into. (I am not familiar with the MMDeviceAPI anyway...)


// started and stopped youtube video playback on firefox
20:27:39.911 13   AudioDeviceSession OnStateChanged Active firefox {0.0.0.00000000}.{ffa6b945-177b-4c08-bdbd-32ff188a16a3}|\Device\HarddiskVolume3\Users\(username)\AppData\Local\Mozilla Firefox\firefox.exe%b{00000000-0000-0000-0000-000000000000}|2%b28692
20:27:42.171 13   AudioDeviceSession OnStateChanged Inactive firefox {0.0.0.00000000}.{ffa6b945-177b-4c08-bdbd-32ff188a16a3}|\Device\HarddiskVolume3\Users\(username)\AppData\Local\Mozilla Firefox\firefox.exe%b{00000000-0000-0000-0000-000000000000}|2%b28692
20:27:43.110 13   AudioDeviceSession OnStateChanged Active firefox {0.0.0.00000000}.{ffa6b945-177b-4c08-bdbd-32ff188a16a3}|\Device\HarddiskVolume3\Users\(username)\AppData\Local\Mozilla Firefox\firefox.exe%b{00000000-0000-0000-0000-000000000000}|2%b28692
20:29:00.492 13   AudioDeviceSession OnStateChanged Inactive firefox {0.0.0.00000000}.{ffa6b945-177b-4c08-bdbd-32ff188a16a3}|\Device\HarddiskVolume3\Users\(username)\AppData\Local\Mozilla Firefox\firefox.exe%b{00000000-0000-0000-0000-000000000000}|2%b28692
The thread '[Thread Destroyed]' (3732) has exited with code 0 (0x0).
The thread '[Thread Destroyed]' (41324) has exited with code 0 (0x0).
20:32:48.842 18   AudioDeviceSession OnStateChanged Active firefox {0.0.0.00000000}.{ffa6b945-177b-4c08-bdbd-32ff188a16a3}|\Device\HarddiskVolume3\Users\(username)\AppData\Local\Mozilla Firefox\firefox.exe%b{00000000-0000-0000-0000-000000000000}|2%b28692
20:32:51.136 18   AudioDeviceSession OnStateChanged Inactive firefox {0.0.0.00000000}.{ffa6b945-177b-4c08-bdbd-32ff188a16a3}|\Device\HarddiskVolume3\Users\(username)\AppData\Local\Mozilla Firefox\firefox.exe%b{00000000-0000-0000-0000-000000000000}|2%b28692

// switched to another windows user
// lines with "===>" are Trace.WriteLine I added
20:32:56.143 18   AudioDeviceSession DisconnectSession firefox {0.0.0.00000000}.{ffa6b945-177b-4c08-bdbd-32ff188a16a3}|\Device\HarddiskVolume3\Users\(username)\AppData\Local\Mozilla Firefox\firefox.exe%b{00000000-0000-0000-0000-000000000000}|2%b28692
20:32:56.153 18   AudioDeviceSession DisconnectSession steam {0.0.0.00000000}.{ffa6b945-177b-4c08-bdbd-32ff188a16a3}|\Device\HarddiskVolume3\Program Files (x86)\Steam\steam.exe%b{00000000-0000-0000-0000-000000000000}|2%b46068
20:32:56.188 UI AudioDeviceSessionCollection RemoveSession firefox {0.0.0.00000000}.{ffa6b945-177b-4c08-bdbd-32ff188a16a3}|\Device\HarddiskVolume3\Users\(username)\AppData\Local\Mozilla Firefox\firefox.exe%b{00000000-0000-0000-0000-000000000000}|2%b28692
20:32:56.194 18   AudioDeviceSession DisconnectSession *SystemSounds {0.0.0.00000000}.{ffa6b945-177b-4c08-bdbd-32ff188a16a3}|#%b{A9EF3FD9-4240-455E-A4D5-F2B3301887B2}|2%b#
20:32:56.205 18   AudioDeviceSession DisconnectSession *SystemSounds {0.0.0.00000000}.{f0864fb6-b270-4326-b28c-84c546e38657}|#%b{A9EF3FD9-4240-455E-A4D5-F2B3301887B2}|2%b#
20:32:56.214 18   AudioDeviceSession DisconnectSession *SystemSounds {0.0.0.00000000}.{73ba86ca-3340-46f0-b212-53e773568b21}|#%b{A9EF3FD9-4240-455E-A4D5-F2B3301887B2}|2%b#
20:32:56.224 18   AudioDeviceSession DisconnectSession *SystemSounds {0.0.0.00000000}.{44f7fb3d-2f3e-43be-b016-6dbe66c302a3}|#%b{A9EF3FD9-4240-455E-A4D5-F2B3301887B2}|2%b#
20:32:56.775 UI ===> Speakers (Hidizs S9Pro) Removed existing session from Apps: 
20:32:56.812 UI AudioDeviceSessionCollection RemoveSession steam {0.0.0.00000000}.{ffa6b945-177b-4c08-bdbd-32ff188a16a3}|\Device\HarddiskVolume3\Program Files (x86)\Steam\steam.exe%b{00000000-0000-0000-0000-000000000000}|2%b46068
20:32:56.816 UI ===> Speakers (Hidizs S9Pro) Removed existing session from Apps: 
20:32:56.838 UI AudioDeviceSessionCollection RemoveSession *SystemSounds {0.0.0.00000000}.{ffa6b945-177b-4c08-bdbd-32ff188a16a3}|#%b{A9EF3FD9-4240-455E-A4D5-F2B3301887B2}|2%b#
20:32:56.864 UI ===> Speakers (Hidizs S9Pro) Removed existing session from Apps: 
20:32:56.867 UI AudioDeviceSessionCollection RemoveSession *SystemSounds {0.0.0.00000000}.{f0864fb6-b270-4326-b28c-84c546e38657}|#%b{A9EF3FD9-4240-455E-A4D5-F2B3301887B2}|2%b#
20:32:56.868 UI ===> Speakers (Steam Streaming Speakers) Removed existing session from Apps: 
20:32:56.870 UI AudioDeviceSessionCollection RemoveSession *SystemSounds {0.0.0.00000000}.{73ba86ca-3340-46f0-b212-53e773568b21}|#%b{A9EF3FD9-4240-455E-A4D5-F2B3301887B2}|2%b#
20:32:56.871 UI ===> Speakers (Steam Streaming Microphone) Removed existing session from Apps: 
20:32:56.874 UI AudioDeviceSessionCollection RemoveSession *SystemSounds {0.0.0.00000000}.{44f7fb3d-2f3e-43be-b016-6dbe66c302a3}|#%b{A9EF3FD9-4240-455E-A4D5-F2B3301887B2}|2%b#
20:32:56.879 UI ===> Realtek Digital Output (Realtek(R) Audio) Removed existing session from Apps: 
20:32:56.907 19   AudioDeviceSession DisconnectSession firefox {0.0.0.00000000}.{ffa6b945-177b-4c08-bdbd-32ff188a16a3}|\Device\HarddiskVolume3\Users\(username)\AppData\Local\Mozilla Firefox\firefox.exe%b{00000000-0000-0000-0000-000000000000}|2%b28692
20:32:56.916 19   AudioDeviceSession DisconnectSession steam {0.0.0.00000000}.{ffa6b945-177b-4c08-bdbd-32ff188a16a3}|\Device\HarddiskVolume3\Program Files (x86)\Steam\steam.exe%b{00000000-0000-0000-0000-000000000000}|2%b46068
20:32:56.937 19   AudioDeviceSession DisconnectSession *SystemSounds {0.0.0.00000000}.{ffa6b945-177b-4c08-bdbd-32ff188a16a3}|#%b{A9EF3FD9-4240-455E-A4D5-F2B3301887B2}|2%b#
20:32:56.949 19   AudioDeviceSession DisconnectSession *SystemSounds {0.0.0.00000000}.{f0864fb6-b270-4326-b28c-84c546e38657}|#%b{A9EF3FD9-4240-455E-A4D5-F2B3301887B2}|2%b#
20:32:56.953 19   AudioDeviceSession DisconnectSession *SystemSounds {0.0.0.00000000}.{73ba86ca-3340-46f0-b212-53e773568b21}|#%b{A9EF3FD9-4240-455E-A4D5-F2B3301887B2}|2%b#
20:32:56.962 19   AudioDeviceSession DisconnectSession *SystemSounds {0.0.0.00000000}.{44f7fb3d-2f3e-43be-b016-6dbe66c302a3}|#%b{A9EF3FD9-4240-455E-A4D5-F2B3301887B2}|2%b#
20:32:57.075 UI WindowsTaskbar Current: Location=Bottom, AutoHide=False, Taskbar=919576, Size=[Left=0,Top=1552,Right=2560,Bottom=1600], Monitor=Screen[Bounds={X=0,Y=0,Width=2560,Height=1600} WorkingArea={X=0,Y=0,Width=2560,Height=1552} Primary=True DeviceName=WinDisc
20:32:57.846 UI TaskbarIconSource Changed: kind=SpeakerTwoBars dpi=96 isSysLight=False isLegacy=False
20:32:57.851 UI IconHelper LoadIconForTaskbar C:\Windows\System32\SndVolSSO.dll,123 16x16

// switched back to the first user
20:33:15.677 UI TaskbarIconSource Changed: kind=SpeakerTwoBars dpi=120 isSysLight=False isLegacy=False
20:33:15.678 UI IconHelper LoadIconForTaskbar C:\Windows\System32\SndVolSSO.dll,123 20x20
20:33:15.843 UI WindowsTaskbar Current: Location=Bottom, AutoHide=False, Taskbar=919576, Size=[Left=0,Top=1380,Right=2560,Bottom=1440], Monitor=Screen[Bounds={X=0,Y=0,Width=2560,Height=1440} WorkingArea={X=0,Y=0,Width=2560,Height=1440} Primary=True DeviceName=\\.\DISPLAY1
The thread '[Thread Destroyed]' (16404) has exited with code 0 (0x0).
The thread '[Thread Destroyed]' (43296) has exited with code 0 (0x0).

// started (and stopped) youtube video playback on firefox again
20:33:55.868 19   AudioDeviceSessionCollection OnSessionCreated
20:33:55.890 13   AudioDeviceSession OnStateChanged Active firefox {0.0.0.00000000}.{ffa6b945-177b-4c08-bdbd-32ff188a16a3}|\Device\HarddiskVolume3\Users\(username)\AppData\Local\Mozilla Firefox\firefox.exe%b{00000000-0000-0000-0000-000000000000}|2%b28692
Exception thrown: 'System.Runtime.InteropServices.COMException' in EarTrumpet.exe
20:33:55.902 19   AudioDeviceSessionCollection CreateAndAddSession System.Runtime.InteropServices.COMException (0x88890004): Exception from HRESULT: 0x88890004
   at EarTrumpet.Interop.MMDeviceAPI.IChannelAudioVolume.GetChannelCount()
   at EarTrumpet.DataModel.WindowsAudio.Internal.AudioDeviceSessionChannelCollection..ctor(IChannelAudioVolume session, Dispatcher dispatcher) in G:\proj\EarTrumpet\EarTrumpet\EarTrumpet\DataModel\WindowsAudio\Internal\AudioDeviceSessionChannelCollection.cs:line 14
   at EarTrumpet.DataModel.WindowsAudio.Internal.AudioDeviceSession..ctor(IAudioDevice parent, IAudioSessionControl session, Dispatcher foregroundDispatcher) in G:\proj\EarTrumpet\EarTrumpet\EarTrumpet\DataModel\WindowsAudio\Internal\AudioDeviceSession.cs:line 151
   at EarTrumpet.DataModel.WindowsAudio.Internal.AudioDeviceSessionCollection.CreateAndAddSession(IAudioSessionControl session) in G:\proj\EarTrumpet\EarTrumpet\EarTrumpet\DataModel\WindowsAudio\Internal\AudioDeviceSessionCollection.cs:line 68
20:33:57.001 19   AudioDeviceSession OnStateChanged Inactive firefox {0.0.0.00000000}.{ffa6b945-177b-4c08-bdbd-32ff188a16a3}|\Device\HarddiskVolume3\Users\(username)\AppData\Local\Mozilla Firefox\firefox.exe%b{00000000-0000-0000-0000-000000000000}|2%b28692
20:34:17.581 UI FlyoutViewModel ChangeState Opening
20:34:17.582 UI WindowsTaskbar Current: Location=Bottom, AutoHide=False, Taskbar=919576, Size=[Left=0,Top=1380,Right=2560,Bottom=1440], Monitor=Screen[Bounds={X=0,Y=0,Width=2560,Height=1440} WorkingArea={X=0,Y=0,Width=2560,Height=1380} Primary=True DeviceName=\\.\DISPLAY1
20:34:17.712 UI FlyoutViewModel ChangeState Open
20:34:18.245 UI FlyoutViewModel ChangeState Closing_Stage1
20:34:18.262 UI FlyoutViewModel ChangeState Closing_Stage2
20:34:18.570 UI FlyoutViewModel ChangeState Hidden

@Lemon-ja
Copy link

This bug is still a thing, also the workaround in #574 may not work anymore, it was working for while but suddenly wont work now. I think due to permissions in the WindowsApps folder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A bug in EarTrumpet
Projects
None yet
Development

No branches or pull requests

5 participants