-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Refactor PortAudio backend #7444
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
base: master
Are you sure you want to change the base?
Conversation
|
How does one test this? Should I play two demo tracks and look at the latency? |
|
Here's my config, @sakertooth, with recent files and directory paths obscured: <?xml version="1.0"?>
<!DOCTYPE lmms-config-file>
<lmms version="1.3.0-alpha.1.740+g303215f8b" configversion="3">
<MidiJack device="lmms"/>
<app loopmarkermode="dual" nanhandler="1" openlastproject="0" nommpz="0" sololegacybehavior="0" configured="1" displaydbfs="1" disablebackup="0" language="sr"/>
<audioengine mididev="WinMM MIDI" framesperaudiobuffer="256" audiodev="SDL (Simple DirectMedia Layer)"/>
<audiojack clientname="lmms" channels="2"/>
<audioportaudio backend="" device=""/>
<audiosdl inputdevice="" device=""/>
<midi midiautoassign="none" autoquantize="0"/>
<paths ladspadir="..." workingdir="..." stkdir="data:/stk/rawwaves/" defaultsf2="..." sf2dir="..." vstdir="..." theme="data:/themes/default/" backgroundtheme="" gigdir="..."/>
<tooltips disabled="0"/>
<ui saveinterval="2" enablerunningautosave="0" displaywaveform="1" vstembedmethod="none" animateafp="1" smoothscroll="0" sidebaronright="0" trackdeletionwarning="0" printnotelabels="1" mixerchanneldeletionwarning="1" compacttrackbuttons="0" disableautoquit="0" vstalwaysontop="0" oneinstrumenttrackwindow="0" enableautosave="0" letpreviewsfinish="0"/>
<recentfiles>
...
</recentfiles>
</lmms> |
|
Saker claims this is merge-ready, as there is little to be done left. MSYS compilation yields four backend, with the following results, after some crude testing:
Additionally, with WDM-KS, with certain outputs selected, LMMS won't report the above message, but will instead hang and result in the following output: |
|
That should be it, really. Let me know if anything more is needed! |
|
Checked again!
Still true, all of it, including the hanging. However, 2/4 backends now work well, which I think is great! Please merge ASAP. 🚀 |
GitHub demands your blessing with an explicit approval before I can merge (in general though it needs one approver before merge, at least for this repository in particular currently). I mentioned one last test if you want to take that on though, which is just checking if MSVC builds work for WASAPI and WDM-KS. Here's a link to them for this PR. |
|
Tested with MSVC. Pretty much the same as MSYS2:
Gonna test using MinGW again as well. |
This is truly incredible |
|
Corrected #7444 (comment). MinGW features only two backends:
|
|
After trying both, it seems neither of them generate the hanging behaviour, LOL! In any case, I'd say that PortAudio is fixed, for the most part. It doesn't chop like it used to, and the ability to specify the channel count has been added. I would investigate this further outside of this PR and we can make future improvements to PortAudio. |
bratpeki
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved from a tester standpoint; I haven't looked at the code.
|
Yup, I can't reproduce the hanging now, somehow! Must be something to do with running MinGW before/after MSVC, that's my best guess. |
|
@bratpeki asked me on Discord to test macOS support.
|
|
Pushed the last few fixes I had in mind. Will merge soon if there are no objections. Any other potential issues might have to be looked at later. |
|
There is definitely the issue stated by @tresf. |
They aren't potential issues, they're actually issues because the behavior regresses from master. Here's what the terminal says: I wasn't able to get this message to reproduce reliably, but it's the closest thing to a usable error I was able to obtain. No matter of configuration will allow the AirPods to work on this PR. |
Dont want to make a lie out of what device is being used
Should the user choose the correct working sample rate instead? I don't want to make a lie out of the config. This would probably require showing a dialog box to the user though, instead of just printing to console. |
When you say "instead" do what condition do you describe? For example, do you mean a condition such as where the "first working" sample rate can't be determined? |
I mean on the condition when the sample rate chosen in the config doesn't work. |
Oh, good question. Messaging would certainly be nice. |
Great. I'll try to implement this, but the error handling situation is a bit messy. I need to report some dialog back to the GUI when trying to initialize the playback devices, but throwing an error would skip the rest of the initialization. Might need a bit of refactoring. |
…evice for playback
Hey. Its been awhile but I came back to this PR and added a popup message when an audio device fails to be setup for playback, which also advises the user to try adjusting their settings. This is nice because the application never reaches in and changes the config under the user's nose (e.g., to change to a working sample rate), which might be unexpected/unusual. I also made some general changes/bug-fixes. Would appreciate any Windows testing as usual. |
I managed to resurrect a Windows laptop since our last testing, so I'd happily retest. |
|
Testing HP Spectre 360 Laptop Windows 11, integrated Realtek Audio, 48000 sample rate (default) Summary: The only observable regression -- consistent with previous tests -- is the need to manually change the samplerate to fix WASAPI. Since we had discussed the possibility of the back-end automatically determining this samplerate for us, I feel like there may still be a bug with the implementation. I deleted the Note that these tests were performed on a different physical machine than previous tests.
|
Yeah I don't think its in our control at this point. |
If there was a popup that said there was a failure to load the PortAudio device when you used the 44100 sample rate and they should try adjusting their settings, then I think this is fine IMO. My reasoning for this was stated in my messages a few months ago. If there was no popup, that's a problem. Still a bummer that the other Windows APIs didn't work though.. I feel like maybe this PR isn't even useful at that point. My initial hope was that I could maybe fix those APIs not working :( |
Backends don't pop-up invalid settings until after a restart, sadly (and even then, unless you're reading the logs, it's only implied when the dailog shows). Not the fault of this PR of course, it's been this way. I see code for a new pop-up, I don't see that at all. Furthemore -- and this is an unrelated issue -- we really need a way to allow the settings screen to change the backend without a restart. This is out of scope for this PR, but (as an example) it's very confusing to start LMMS with it working on SDL, open the settings screen to change to PortAudio, only to have to restart for it to use PortAudio, and then only know if PortAudio is broken when the Settings screen re-appears. This is a pretty big usability issue.
Well, the code cleanup is always welcome. These backends are horribly broken on Windows anyways, I won't stop a merge because of those test results. Cleaner code is easier to troubleshoot. Somewhat related, the project has the $$$ to send you a Windows laptop if you wanted to debug this in -- say msys2 locally. We'd be happy to send you something to work on this more, even after it's merged. |
So having the popup of invalid settings showing only after a restart is because that's the only time in the code we actually open the device and check if we can load the device from it. As you discovered, we don't currently change the device immediately after the settings are applied. Though I do agree how this can be an issue. It is more reasonable and efficient for the application to check if the settings work immediately after applying them, and refuse to apply them on failure. This can work for backends like PortAudio since it doesn't require us to actually open the device to check if we can load from it (it has a simple function for this that doesn't require a device to be opened), but I'm not sure about the other backends.
I like working with a single laptop since it's less technology to manage, but I appreciate the offer. I have plans to make some disk space on my current laptop and set up a lightweight Windows VM to debug this a bit more closely. |
Applies various changes in an attempt to resolve certain issues with the PortAudio backend and improve the quality of the code.
This PR fixes DirectSound and MME when using PortAudio, but for some reason WDM-KS and WASAPI still lay down broken. This might have to be looked into later as I couldn't find a solution.