-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[GSoC] [WIP] PipeWire support #16590
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
8401088
rename SoundDeviceId.portAudioIndex to deviceIndex
pri-yan-shu a505458
implement PipewireEnumerator and SoundDevicePipewire
pri-yan-shu 7f767bd
Implement PipeWire hotplug
pri-yan-shu 185d7a5
infer pw_filter port index from port names instead of unreliable PW_K…
pri-yan-shu cb3b805
Use std::atomic to load and store state accessed in callback
pri-yan-shu 481a555
Respect pipewire clock.rate and clock.allowed-rates metadata
pri-yan-shu bea4b27
Handle cases when PipeWire server is not running
pri-yan-shu e4c555c
Improve pipewire members naming and deinitialization
pri-yan-shu 2e665d3
Make Mixxx PipeWire ports static, get rid of atomic variables
pri-yan-shu 8ac7d56
Safeguard port creation when PipeWire server not connected
pri-yan-shu 0323184
Connect single SoundDevice port to Mixxx port and internally make cha…
pri-yan-shu 276f171
Check for hidden input/output before creating PipeWire ports
pri-yan-shu 033b92a
Set AudioInputBuffers to zero in case of null PipeWire buffer
pri-yan-shu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
daschuer marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| #[=======================================================================[.rst: | ||
| FindPipeWire | ||
| -------- | ||
|
|
||
| Finds the PipeWire library. | ||
|
|
||
| Imported Targets | ||
| ^^^^^^^^^^^^^^^^ | ||
|
|
||
| This module provides the following imported targets, if found: | ||
|
|
||
| ``PipeWire::PipeWire`` | ||
| The PipeWire library | ||
|
|
||
| Result Variables | ||
| ^^^^^^^^^^^^^^^^ | ||
|
|
||
| This will define the following variables: | ||
|
|
||
| ``PipeWire_FOUND`` | ||
| True if the system has the PipeWire library. | ||
|
|
||
| #]=======================================================================] | ||
|
|
||
| find_package(PkgConfig REQUIRED) | ||
| pkg_check_modules(PIPEWIRE REQUIRED IMPORTED_TARGET libpipewire-0.3) | ||
|
|
||
| include(FindPackageHandleStandardArgs) | ||
|
|
||
| find_package_handle_standard_args( | ||
| PipeWire | ||
| REQUIRED_VARS PIPEWIRE_FOUND | ||
| VERSION_VAR PIPEWIRE_VERSION | ||
| ) | ||
|
|
||
| if(PipeWire_FOUND AND NOT TARGET PipeWire::PipeWire) | ||
| add_library(PipeWire::PipeWire INTERFACE IMPORTED) | ||
| set_target_properties( | ||
| PipeWire::PipeWire | ||
| PROPERTIES INTERFACE_LINK_LIBRARIES PkgConfig::PIPEWIRE | ||
| ) | ||
| endif() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,12 +6,15 @@ | |
| #include <vector> | ||
|
|
||
| #include "control/controlproxy.h" | ||
| #include "defs_urls.h" | ||
| #include "engine/enginebuffer.h" | ||
| #include "engine/enginemixer.h" | ||
| #include "mixer/playermanager.h" | ||
| #include "moc_dlgprefsound.cpp" | ||
| #include "preferences/dialog/dlgprefsounditem.h" | ||
| #include "soundio/sounddevice.h" | ||
| #include "soundio/soundmanager.h" | ||
| #include "soundio/soundmanagerutil.h" | ||
| #include "util/rlimit.h" | ||
| #include "util/scopedoverridecursor.h" | ||
|
|
||
|
|
@@ -94,6 +97,21 @@ DlgPrefSound::DlgPrefSound(QWidget* pParent, | |
| this, | ||
| &DlgPrefSound::refreshDevices); | ||
|
|
||
| connect(m_pSoundManager.get(), | ||
| &SoundManager::deviceAdded, | ||
| this, | ||
| &DlgPrefSound::addDevice); | ||
|
|
||
| connect(m_pSoundManager.get(), | ||
| &SoundManager::deviceRemoved, | ||
| this, | ||
| &DlgPrefSound::removeDevice); | ||
|
|
||
| connect(m_pSoundManager.get(), | ||
| &SoundManager::deviceChannelsUpdated, | ||
| this, | ||
| &DlgPrefSound::updateDeviceChannels); | ||
|
|
||
| apiComboBox->clear(); | ||
| apiComboBox->addItem(SoundManagerConfig::kEmptyComboBox, | ||
| SoundManagerConfig::kDefaultAPI); | ||
|
|
@@ -108,16 +126,8 @@ DlgPrefSound::DlgPrefSound(QWidget* pParent, | |
| QStringLiteral("(?)"), | ||
| MIXXX_MANUAL_SOUND_API_URL)); | ||
|
|
||
| sampleRateComboBox->clear(); | ||
| const auto sampleRates = m_pSoundManager->getSampleRates(); | ||
| for (const auto& sampleRate : sampleRates) { | ||
| if (sampleRate.isValid()) { | ||
| // no ridiculous sample rate values. prohibiting zero means | ||
| // avoiding a potential div-by-0 error in ::updateLatencies | ||
| sampleRateComboBox->addItem(tr("%1 Hz").arg(sampleRate.value()), | ||
| QVariant::fromValue(sampleRate)); | ||
| } | ||
| } | ||
| updateSampleRates(sampleRates); | ||
| connect(sampleRateComboBox, | ||
| QOverload<int>::of(&QComboBox::currentIndexChanged), | ||
| this, | ||
|
|
@@ -508,14 +518,23 @@ void DlgPrefSound::connectSoundItem(DlgPrefSoundItem* pItem) { | |
| connect(this, &DlgPrefSound::writePaths, pItem, &DlgPrefSoundItem::writePath); | ||
| if (pItem->isInput()) { | ||
| connect(this, &DlgPrefSound::refreshInputDevices, pItem, &DlgPrefSoundItem::refreshDevices); | ||
| connect(this, &DlgPrefSound::addInputDevice, pItem, &DlgPrefSoundItem::addDevice); | ||
| connect(this, &DlgPrefSound::removeInputDevice, pItem, &DlgPrefSoundItem::removeDevice); | ||
| } else { | ||
| connect(this, | ||
| &DlgPrefSound::refreshOutputDevices, | ||
| pItem, | ||
| &DlgPrefSoundItem::refreshDevices); | ||
| connect(this, &DlgPrefSound::addOutputDevice, pItem, &DlgPrefSoundItem::addDevice); | ||
| connect(this, &DlgPrefSound::removeOutputDevice, pItem, &DlgPrefSoundItem::removeDevice); | ||
| } | ||
| connect(this, &DlgPrefSound::updatingAPI, pItem, &DlgPrefSoundItem::save); | ||
| connect(this, &DlgPrefSound::updatedAPI, pItem, &DlgPrefSoundItem::reload); | ||
| connect(this, | ||
| &DlgPrefSound::deviceChannelsUpdated, | ||
| pItem, | ||
| &DlgPrefSoundItem::updateDeviceChannels); | ||
| connect(this, &DlgPrefSound::deviceRouteUpdated, pItem, &DlgPrefSoundItem::updateDeviceRoute); | ||
| } | ||
|
|
||
| void DlgPrefSound::insertItem(DlgPrefSoundItem *pItem, QVBoxLayout *pLayout) { | ||
|
|
@@ -797,6 +816,62 @@ void DlgPrefSound::refreshDevices() { | |
| emit refreshInputDevices(m_inputDevices); | ||
| } | ||
|
|
||
| void DlgPrefSound::addDevice(SoundDevicePointer pDevice) { | ||
| const bool hasInputs = pDevice->getNumInputChannels().isValid(); | ||
| const bool hasOutputs = pDevice->getNumOutputChannels().isValid(); | ||
|
|
||
| if (hasInputs) { | ||
| m_inputDevices.append(pDevice); | ||
| emit addInputDevice(pDevice); | ||
| } | ||
| if (hasOutputs) { | ||
| m_outputDevices.append(pDevice); | ||
| emit addOutputDevice(pDevice); | ||
| } | ||
| } | ||
|
|
||
| void DlgPrefSound::removeDevice(SoundDevicePointer pDevice) { | ||
| const bool hasInputs = pDevice->getNumInputChannels().isValid(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. An old issue: |
||
| const bool hasOutputs = pDevice->getNumOutputChannels().isValid(); | ||
|
|
||
| if (hasInputs && m_inputDevices.removeOne(pDevice)) { | ||
| emit removeInputDevice(pDevice); | ||
| } | ||
|
|
||
| if (hasOutputs && m_outputDevices.removeOne(pDevice)) { | ||
| emit removeOutputDevice(pDevice); | ||
| } | ||
| } | ||
|
|
||
| void DlgPrefSound::updateDeviceChannels(SoundDevicePointer pDevice) { | ||
| const bool hasInputs = pDevice->getNumInputChannels().isValid(); | ||
| const bool hasOutputs = pDevice->getNumOutputChannels().isValid(); | ||
| const bool hadInputs = m_inputDevices.contains(pDevice); | ||
| const bool hadOutputs = m_outputDevices.contains(pDevice); | ||
| const bool listsModified = (hasInputs ^ hadInputs) || (hasOutputs ^ hadOutputs); | ||
|
|
||
| if (!listsModified) { | ||
| emit deviceChannelsUpdated(pDevice); | ||
| return; | ||
| } | ||
|
|
||
| if (hadInputs && !hasInputs) { | ||
| m_inputDevices.removeOne(pDevice); | ||
| emit removeInputDevice(pDevice); | ||
| } else if (!hadInputs && hasInputs) { | ||
| m_inputDevices.append(pDevice); | ||
| emit addInputDevice(pDevice); | ||
| } | ||
|
|
||
| if (hadOutputs && !hasOutputs) { | ||
| m_outputDevices.removeOne(pDevice); | ||
| emit removeOutputDevice(pDevice); | ||
| } else if (!hadOutputs && hasOutputs) { | ||
| m_outputDevices.append(pDevice); | ||
| emit addOutputDevice(pDevice); | ||
| } | ||
| } | ||
|
|
||
| /// Called when any of the combo boxes in this dialog are changed. Enables the | ||
| /// apply button and marks that settings have been changed so that | ||
| /// DlgPrefSound::slotApply knows to apply them. | ||
|
|
@@ -1099,3 +1174,15 @@ void DlgPrefSound::checkLatencyCompensation() { | |
| bool DlgPrefSound::okayToClose() const { | ||
| return m_configValid; | ||
| } | ||
|
|
||
| void DlgPrefSound::updateSampleRates(const QList<mixxx::audio::SampleRate>& sampleRates) { | ||
| sampleRateComboBox->clear(); | ||
| for (const auto& sampleRate : sampleRates) { | ||
| if (sampleRate.isValid()) { | ||
| // no ridiculous sample rate values. prohibiting zero means | ||
| // avoiding a potential div-by-0 error in ::updateLatencies | ||
| sampleRateComboBox->addItem(tr("%1 Hz").arg(sampleRate.value()), | ||
| QVariant::fromValue(sampleRate)); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Please disable Pipewire by default!
The proposal is still not approved and thus we shouldn't make this feature available till we agreed we want to keep it such a way.
CC @mixxxdj/developers
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.
(just stumbled upon this because I don't have libpipewire-3, yet)
I agree. Default off until it's mature / safe/polished enough for test use.
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.
done: #16713
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.
@ronso0 we require actually
libpipewire-0.3Was it just a typo and you have
libpipewire-0.3or is there a distro out there that does not provide it?I am asking because then we may adjust the CMake code accordingly.
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.
Yes, libpipewire-0.3
Just set the flag to Off until I update my distro.
If I require it before that I'll find a way.
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.
Ah, no problem we can make Pipwire optional, depending on the existence of that file.
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.
Heads up this makes pipewire dependency optional, it is compiled in by default (helpful for CI) and pipewire features can be accessed by
--developerflag. Is that fine?