-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Refactor PortAudio backend #7444
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. |
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. |
I set the default to 2 in the code, so I'm confused. |
Do you mind linking to the code? |
I made some more sweeping changes because I didn't like the scoping issues (i.e., having to handle both input and output logic at the same time). Instead, I encapsulated this logic into classes. More importantly though, I stopped updating the config after the stream has opened. I'm not sure if that will fix the problem, but I couldn't find any other issue. |
const auto defaultNumChannels = QString::number(DEFAULT_CHANNELS);
const auto selectedNumChannels = ConfigManager::inst()->value(tag(), channelsAttribute(m_direction), defaultNumChannels);
m_channelModel.setValue(selectedNumChannels.toInt()); This is the code that gets ran when we need to populate the combo boxes for both the input and output devices. |
I tested again and it selected the Yeti by default this time and it showed 2, but switching to a 1-channel mic and back shows the bug. (if the video is blurry it may still be processing) |
Thanks, the video helped. This happens because when you switch devices, only the channel range (i.e., the allowed minimum and maximum channel range) are updated. The channel value itself isn't updated because PortAudio only provides the maximum number of channels, but not a value that says "this is the number of channels this device is expected to use". Should we be always trying a default value of |
Hmm... well at some point the code path assumed that 2 was OK, then a code path assumed that 1 was OK. I think preferring 2 if supported is a good default for now. We can't really know what the future will hold in regards to this (the future recording) feature, but I can say that I've always recorded in stereo when available, but this may not represent the masses. Regardless, having a default code path that's consistent is always preferred, easy enough to change later. |
I can see this is being worked on very actively. I'll reassign myself and test Linux and Windows when it's time. Please request a review then! |
That happened because the channel count wasn't specified in the config, so it defaulted to |
Wait nevermind, scratch off what I just said... it wasn't saved to the config since you never pressed "OK", so it should've used |
1. Do not manually edit the device combo boxes and channel box after changing the index on the backend combo box or the device combo box respectively, as this is already handled in the signal-slot connection 2. Do not capture by reference inside the lambda when making Qt connections, as the variables will go out of scope shortly. Capture by value instead. 3. Set channel count when refreshing channel range
Hopefully its fixed now. |
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.
Tested on macOS Sonoma, passes with mono and stereo inputs. Playback works as expected.
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.