henkelmax / simple-voice-chat

A working voice chat in Minecraft!
https://modrepo.de/minecraft/voicechat/wiki
426 stars 106 forks source link

Fixing microphone not working at random times on MacOS #602

Closed Mrredstone5230 closed 11 months ago

Mrredstone5230 commented 1 year ago

Here's an issue I got with the mod running on macOS Ventura with PrismMC: Sometimes, at seemingly random intervals, the mic would just cut and not work. The only solution I found was to always disable the audio and put it back when the bug would occur, but I found that was a little stupid, so I decided to investigate.

To put it simply, I discovered that my bug occurred when mic.available() always returned 128. (Where normally it's a bunch of non-recurring numbers). (I tried using the ALMicrophone and the JavaxMicrophone implementations, but I had the same problem on both).

To solve the issue, I built this terrible code that would check if the mic.available() would continuously return 128, and if so, it would "restart" the microphone (similar of how I was able to "patch" the issue by disabling and re-enabling the audio).

I know my solution isn't very elegant, so don't be shy to completely change it. Maybe an OS check would be a good thing as I didn't test it on Windows.

Mrredstone5230 commented 1 year ago

Welp, today the number is different. Therefore, I changed the function a bit, but the concept's the same.

henkelmax commented 11 months ago

Welp, today the number is different. Therefore, I changed the function a bit, but the concept's the same.

This sounds like a very janky solution that might just work for your specific system. I will only accept proper fixes.