You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My laptop has an occasional issue where the sound device stops working completely, This affects various programs differently. Most browsers will still play video without the sound, Winamp won't start playback at all. I can fix that by disabling and re-enabling it in the Device Manager but it exposes a bug in my own software that I thought I'd mention here.
With HalfNES, with the sound disabled in Preferences things work normally. But if I turn on the sound everything freezes. The reason for this is that the SourceDataLine doesn't throw any exceptions when creating it with the system in this state but when I actually try to write to the buffer it blocks forever in a wait() loop.
Now I currently depend on the audio buffer blocking at least a little bit to maintain synchronization but I can't tell if its just going to block for a little bit or if no data is being drained from the buffer at all as far as I can tell.
Having an extra sentinel thread to interrupt the waiting if it's taking far too long doesn't work because of this lovely bit of code in the Swing mixer: https://community.oracle.com/thread/2381571
I think to fix this will require changing to a different audio system, or rewriting my code to never attempt to block on the audio buffer at all. That will require outputting much finer grained chunks of audio, maybe a line worth rather than a frame worth (a good idea anyway) and finding some other more accurate source of 60/ 50 hz timing. I can't get anything like a vblank interrupt from Swing but JavaFX does have an animation timer that might work.
The text was updated successfully, but these errors were encountered:
My laptop has an occasional issue where the sound device stops working completely, This affects various programs differently. Most browsers will still play video without the sound, Winamp won't start playback at all. I can fix that by disabling and re-enabling it in the Device Manager but it exposes a bug in my own software that I thought I'd mention here.
With HalfNES, with the sound disabled in Preferences things work normally. But if I turn on the sound everything freezes. The reason for this is that the SourceDataLine doesn't throw any exceptions when creating it with the system in this state but when I actually try to write to the buffer it blocks forever in a wait() loop.
Now I currently depend on the audio buffer blocking at least a little bit to maintain synchronization but I can't tell if its just going to block for a little bit or if no data is being drained from the buffer at all as far as I can tell.
Having an extra sentinel thread to interrupt the waiting if it's taking far too long doesn't work because of this lovely bit of code in the Swing mixer:
https://community.oracle.com/thread/2381571
I think to fix this will require changing to a different audio system, or rewriting my code to never attempt to block on the audio buffer at all. That will require outputting much finer grained chunks of audio, maybe a line worth rather than a frame worth (a good idea anyway) and finding some other more accurate source of 60/ 50 hz timing. I can't get anything like a vblank interrupt from Swing but JavaFX does have an animation timer that might work.
The text was updated successfully, but these errors were encountered: