Skip to content
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

SDL driver's input and output device configuration via combo box #7421

Merged
merged 12 commits into from
Aug 10, 2024

Conversation

michaelgregorius
Copy link
Contributor

This pull request cherry-picks the changes from pull request #5990 which enable the configuration of the SDL driver's input and output devices via combo boxes. The feature was extracted into this PR because it is questionable if and when #5990 will be merged and the combo box feature is already useful on it's own. It looks as follows:

5990-PlaybackAndInputDeviceSelection

My comments in #5990 regarding this feature started around here: #5990 (comment)

This feature was also proposed independently here: #6070 (comment)

Similar designs for the other drivers should be done in separate pull requests as they will all have different API on how to retrieve the devices and change them.

Up to now the SDL audio driver attempted to use the default recording
device. This might not be what users want or expect, especially since the
actually used device is not visible anywhere. So if recording does not
work for the users they have no way to find out what's wrong.

Extend the settings screen of the SDL driver with a combo box that allows
to select the input device to be used. Store the selected device name in
a new attribute called "inputdevice" in the "audiosdl" section of the
configuration file.

Use the information from the configuration when attempting to inialize
the input device. Fall back to the default device if that does not work.

(cherry picked from commit 33139b9)
Provide the setting "[System Default]" which instructs the SDL driver to
use the default device of the system as the input device. In the
configuration file this option is represented as an empty string. This
should play well with the current existing configuration of the users.

(cherry picked from commit 29c43c2)
Let users configure the output device that's used by the SDL driver.
Code-wise the implementation is very similar to the input device
configuration.

Use a `QComboBox` instead of a `QLineEdit` for `m_device` and rename it
to `m_playbackDeviceComboBox`.

Rename `s_defaultInputDevice` to `s_systemDefaultDevice` because it is
used in the context of playback and input devices.

(cherry picked from commit 1ab45e4)
Make sure that labels are always shown by setting the row wrap policy of
the form layout to wrap long rows.

(cherry picked from commit a123d0e)
Rename "Device" to "Playback device" to make clear what the setting
refers to.

(cherry picked from commit 1f0cda4)
Introduce const expressions to get rid of repeated strings with a risk
of typos.

(cherry picked from commit f9ea970)
Copy link
Contributor

@Rossmaxx Rossmaxx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments. Tbh i don't really understand some of the changes, so can't write a better review.

include/AudioSdl.h Show resolved Hide resolved
include/AudioSdl.h Outdated Show resolved Hide resolved
src/core/audio/AudioSdl.cpp Outdated Show resolved Hide resolved
Apply some more changes that have been made to `AudioSdl` in the
recording branch.
Also use a conditional ternary operator for the input device setup.
Move the population of the input and playback device combo boxes into
the methods `populatePlaybackDeviceComboBox` and
`populateInputDeviceComboBox`.
Sort the devices names alphabetically in the input and playback combo
boxes. The default devices is always shown as the first entry.
@michaelgregorius
Copy link
Contributor Author

@LMMS/developers, I have just noticed that these changes will currently only work for SDL2 builds.

Are there any SDL1 builds? According to SDL2's Wikipedia page SDL2 was released in 2013 so I guess most distributions should already have support for SDL2. Or put differently, many distribution will likely not provide SDL1 packages anymore.

Removing support for SDL1 would greatly improve the source code for the SDL back end.

@Rossmaxx
Copy link
Contributor

Rossmaxx commented Aug 4, 2024

I vote for complete removal of SDL 1. I believe the final votes lie with either @tresf or @PhysSong

@firewall1110
Copy link
Contributor

firewall1110 commented Aug 4, 2024

I vote for complete removal of SDL 1 too, but my opinion is:
(1) complete this PR (merge it to master without any care about obsolete dead SDL1 code);
(2) open new PR "Removing obsolete and mostly dead SDL1 code".

Edited: Even better : open new issue "Obsolete and mostly dead SDL1 code" with mark good first issue.

@michaelgregorius
Copy link
Contributor Author

I agree. It should be done in two steps.

@tresf
Copy link
Member

tresf commented Aug 5, 2024

I vote for complete removal of SDL 1. I believe the final votes lie with either @tresf or @PhysSong

No objections.

@PhysSong
Copy link
Member

PhysSong commented Aug 5, 2024

I also agree with dropping SDL2 support.

@sakertooth
Copy link
Contributor

sakertooth commented Aug 5, 2024

I'm also in favor for complete removal of SDL 1 support.

@michaelgregorius
Copy link
Contributor Author

I also agree with dropping SDL2 support.

I guess you meant SDL1? 😅

@michaelgregorius
Copy link
Contributor Author

In that case I'd like to ask for a code review so this one can go in. Or just for @Rossmaxx to green-light this if he's okay with the current state.

I will then create a separate issue to remove the SDL1 related code and perhaps give it a spin myself.

Copy link
Contributor

@Rossmaxx Rossmaxx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine.

@Rossmaxx
Copy link
Contributor

Rossmaxx commented Aug 6, 2024

Tbh i would wait for another cod review.

@michaelgregorius
Copy link
Contributor Author

I have added @zonkmachine as an additional reviewer as he was also active in #5990. If someone else wants to review feel free to do so.

AudioSdl::setupWidget::setupWidget( QWidget * _parent ) :
AudioDeviceSetupWidget( AudioSdl::name(), _parent )
{
QFormLayout * form = new QFormLayout(this);
form->setRowWrapPolicy(QFormLayout::WrapLongRows);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reasons for this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because otherwise the labels might get hidden if the content of the combo boxes becomes very long (which is the case for my sound devices). See commit 94b43f5.

src/core/audio/AudioSdl.cpp Outdated Show resolved Hide resolved
src/core/audio/AudioSdl.cpp Outdated Show resolved Hide resolved
Use `AudioDeviceSetupWidget` instead of `QObject` to translate "[System
Default]".

Fix copy/paste error in comment.
@michaelgregorius michaelgregorius merged commit 74c73e5 into LMMS:master Aug 10, 2024
11 checks passed
@michaelgregorius michaelgregorius deleted the SDLDriverConfigCombobox branch August 10, 2024 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants