diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index c4b8c8fe..00000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,39 +0,0 @@ ---- -name: Bug report -about: Create a report to help us improve - ---- - -## NOTE -Bug reports without clear information or scenario to reproduce and logs from ``%AppData%\GHelper`` will be closed without answer. Please respect the time of the developer. Thanks. - -**Describe the bug** -A clear and concise description of what the bug is. - -**Clear scenario to Reproduce** -Steps to reproduce the behavior: -1. Go to '...' -2. Click on '....' -3. Scroll down to '....' -4. Explanation of an error or a bug - -**Expected behavior** -A clear and concise description of what you expected to happen. - -**App Logs** -Please include and attach log.txt from ``%AppData%\GHelper`` - -**Screenshots or screencasts** -If applicable, add screenshots to help explain your problem. - -**Desktop (please complete the following information):** - - OS: [e.g. Windows 11] - - Laptop model - -**Asus software** -- Armoury Crate (or it's services installed) -- MyASUS installed -- Other Asus services running in background - -**Additional context** -Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 00000000..37d95fcd --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,82 @@ +name: Bug Report +description: Something isn't working correctly +labels: ["bug"] +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to fill out this bug report. The more information you provide, the easier it will be for me to fix it! + - type: checkboxes + id: rules + attributes: + label: Rules + options: + - label: I made myself familiar with the Readme, FAQ and Troubleshooting. + required: true + - label: I understand that, if insufficient information was provided, my issue will be closed without an answer. + required: true + validations: + required: true + - type: textarea + id: description + attributes: + label: What's wrong? + description: Provide detailed description of what is wrong or does not work as expected. + placeholder: Provide detailed description of what is wrong or does not work as expected. + validations: + required: true + - type: textarea + id: reproduce + attributes: + label: How to reproduce the bug? + description: Describe how to reproduce the behavior. Be as specific as possible and provide as many details as possible. + placeholder: | + 1. Go to '...' + 2. Click on '....' + 3. Scroll down to '....' + 4. See error + validations: + required: true + - type: textarea + id: logs + attributes: + label: Logs + placeholder: Please drag and drop complete log file from ``%APPDATA%\GHelper\log.txt`` + description: Please drag and drop complete log file from ``%APPDATA%\GHelper\log.txt`` + validations: + required: true + - type: input + id: device + attributes: + label: Device and Model + description: Which laptop do you use? + placeholder: e.g. Asus Zephyrus G14 GA404RK + validations: + required: true + - type: textarea + id: additional + attributes: + label: Additional information. + description: If applicable, add screenshots or other relevant information to help explain your problem. + - type: checkboxes + id: asus + attributes: + label: Asus Software + description: Please check what Asus/Armoury Services do you have installed and running + options: + - label: Armoury Crate + - label: MyAsus + - label: Other Asus Services + - type: input + id: version + attributes: + label: Version + description: G-Helper version? + placeholder: e.g. 0.146 + - type: input + id: os + attributes: + label: OS + description: Which operating system do you use? + placeholder: e.g. Windows 11 21H2 + diff --git a/app/AnimeMatrix/AniMatrixControl.cs b/app/AnimeMatrix/AniMatrixControl.cs index 025f0f53..d5d4b1b9 100644 --- a/app/AnimeMatrix/AniMatrixControl.cs +++ b/app/AnimeMatrix/AniMatrixControl.cs @@ -10,7 +10,7 @@ using System.Timers; namespace GHelper.AnimeMatrix { - public class AniMatrixControl + public class AniMatrixControl : NAudio.CoreAudioApi.Interfaces.IMMNotificationClient { SettingsForm settings; @@ -20,6 +20,8 @@ namespace GHelper.AnimeMatrix double[]? AudioValues; WasapiCapture? AudioDevice; + string? AudioDeviceId; + private MMDeviceEnumerator? AudioDeviceEnum; public bool IsValid => device != null; @@ -167,6 +169,9 @@ namespace GHelper.AnimeMatrix Logger.WriteLine(ex.ToString()); } } + + AudioDeviceId = null; + AudioDeviceEnum?.Dispose(); } void SetMatrixAudio() @@ -179,10 +184,13 @@ namespace GHelper.AnimeMatrix try { - using (var enumerator = new MMDeviceEnumerator()) - using (MMDevice device = enumerator.GetDefaultAudioEndpoint(DataFlow.Render, Role.Console)) + AudioDeviceEnum = new MMDeviceEnumerator(); + AudioDeviceEnum.RegisterEndpointNotificationCallback(this); + + using (MMDevice device = AudioDeviceEnum.GetDefaultAudioEndpoint(DataFlow.Render, Role.Console)) { AudioDevice = new WasapiLoopbackCapture(device); + AudioDeviceId = device.ID; WaveFormat fmt = AudioDevice.WaveFormat; AudioValues = new double[fmt.SampleRate / 1000]; @@ -397,6 +405,48 @@ namespace GHelper.AnimeMatrix } + public void OnDeviceStateChanged(string deviceId, DeviceState newState) + { + } + + public void OnDeviceAdded(string pwstrDeviceId) + { + + } + + public void OnDeviceRemoved(string deviceId) + { + + } + + public void OnDefaultDeviceChanged(DataFlow flow, Role role, string defaultDeviceId) + { + if (AudioDeviceId == defaultDeviceId) + { + //We already caputre this device. No need to re-initialize + return; + } + + int running = AppConfig.Get("matrix_running"); + if (flow != DataFlow.Render || role != Role.Console || running != 4) + { + return; + } + + //Restart audio if default audio changed + Logger.WriteLine("Matrix Audio: Default Output changed to " + defaultDeviceId); + + //Already set the device here. Otherwise this will be called multiple times in a short succession and causes a crash due to dispose during initalization. + AudioDeviceId = defaultDeviceId; + + //Delay is required or it will deadlock on dispose. + Task.Delay(50).ContinueWith(t => SetMatrixAudio()); + } + + public void OnPropertyValueChanged(string pwstrDeviceId, PropertyKey key) + { + + } } } diff --git a/app/Properties/Strings.pt-PT.resx b/app/Properties/Strings.pt-PT.resx index df0af47c..bdf98858 100644 --- a/app/Properties/Strings.pt-PT.resx +++ b/app/Properties/Strings.pt-PT.resx @@ -124,10 +124,10 @@ Não foi possível conectar ao ASUS ACPI. O programa não funciona sem esse serviço. Tente instalar Asus System Control Interface - Restart your device to apply changes + Reinicie o dispositivo para aplicar as alterações - Restart now? + Reiniciar agora? Parece que o GPU está em uso pesado, desativá-lo? @@ -169,7 +169,7 @@ Ajuste automático dos modos de energia do Windows - Memory Assigned to GPU + Memória Alocada à GPU Serviços da Asus em execução @@ -250,10 +250,10 @@ Tempo limite ligado à corrente / na bateria (0 - ON) - Backlight Timeout when on battery + Desligar o ecrã após (em Bateria) - Backlight Timeout when plugged + Desligar o ecrã após (ligado à corrente) Equilibrado