-
-
Notifications
You must be signed in to change notification settings - Fork 90
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
[FR] Fixing audio rate correction on video freq adjust #1404
Comments
That's probably not a good idea. There is no guarantee the new refresh rate will be supported by the monitor, it may end up just showing an "out of sync" screen, with no easy way to go back. |
Ah yes, I know what you mean. But for example I have several monitors around that can do near-60Hz modes with no problems at all. Also, the MiSTer does it all the time with the low-latency video sync option, and nobody seems to complain: if it doesn't work ("out of sync!") simply don't use it. |
Usually most monitors will handle 60Hz, but going down to 50Hz is not supported on all of them. I think it would be best to fix the resampling aspect instead, which can't cause any such issues. Don't you agree? |
@midwan Ah, yes, people would use a PAL Amiga as default, and would most certainly go into black-screen land automatically. You are right. I am so used to having monitors supporting everything... Yes, fixing the resampling would be the desired solution. Let's work on that. Do you have an idea on what the problem is? |
SDL2 handles audio in two ways:
Both are supported in Amiberry, with the options Push/Pull. The audio buffer used is also configurable, and it works best if you use a small buffer with Push, but a setting of around 6 with Pull. The SDL2 wiki has a lot of details, starting with this: https://wiki.libsdl.org/SDL2/SDL_OpenAudioDevice All of the code in Amiberry is here: https://github.com/BlitterStudio/amiberry/blob/master/src/sounddep/sound.cpp |
Ok, I can see that the SDL2 audio callback function is only used when in "pull mode", right? How often is the audio callback function called? |
@vanfanel Yes, that's correct. In the other cases, there are places in the code where it will "push" audio chunks accordingly. The handling all happens inside this file, in any case. The distinction is Push or Pull, which is also saved as a setting in the config file. I only implemented the call to the resampling calculations when using the Push (no callback) option, which works best with a small buffer size. I did a test with setting it to "1" for example, and it seemed to work for me. |
@midwan Ah! I tried the PUSH mode with latency set to "1", and indeed there are no audio defects, but audio is terribly lagged behind video. |
@midwan Also tried PUSH with latency set to "minimum", and audio latency is still very noticeable. |
I've also been trying to decrease |
The smaller the buffer, the faster the device needs to be in order to keep up. I've had no trouble with a Pi5, for instance. |
@midwan Increasing What I need to know is: What determines how often |
@vanfanel you don't have to increase it in the code, that's what the slider does... Trying with a setting of 2 or 3 for instance, will use a larger buffer. It depends on how fast your device is, but like I said, something along the lines of a Pi4 or Pi5 should be enough to handle most cases with a setting of 1. The code pushes audio as part of each frame drawn, in |
@midwan We are not understanding each other :P A smaller audio buffer should provide less audio delay. But, using PUSH, it does not. |
@vanfanel |
Here's my config: I use 60Hz (NTSC Amiga), low-latency Vsync enabled. Also, you said this: |
@vanfanel Both Push and Pull functions will get new audio chunks through the same mechanism in custom.cpp, the difference is how they do that: With Push, we call |
@midwan I recently implemented low-latency video on SDL2+Wayland: |
I can recreate the issue, only seems to happen with Push mode. Testing on a previous release which didn't have the |
I've just reverted that commit, at least until we have a proper implementation that doesn't break things. |
Is your feature request related to a problem? Please describe.
Since "FPS Adjust" causes audio problems because of the lack of proper audio samplerate adaptation, I am trying the other way around: when the emulated Amiga changes to a different video mode (as in
amiberry/src/custom.cpp
Line 7176 in efebb3f
I already have wlroots-based code ready that changes the videomode on wlroots-based Wayland compositors, but now, what's a good place to detect internal emulated Amiga video mode changes in https://github.com/BlitterStudio/amiberry/blob/preview/src/osdep/amiberry_gfx.cpp? (Specially refresh rate changes)
Or maybe no function in https://github.com/BlitterStudio/amiberry/blob/preview/src/osdep/amiberry_gfx.cpp is run when internal Amiga videomode changes are made?
The text was updated successfully, but these errors were encountered: