Skip to content

Commit 90b1a10

Browse files
committed
fix: Add option to volume control the virtual sink (not recommended)
1 parent d3cea5a commit 90b1a10

File tree

8 files changed

+52
-7
lines changed

8 files changed

+52
-7
lines changed

src/audio/pipewire/PipewireAudioService.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ PipewireAudioService::PipewireAudioService()
1414
{
1515
Glib::init();
1616

17-
mgr = std::make_unique<PwPipelineManager>();
17+
mgr = std::make_unique<PwPipelineManager>(AppConfig::instance().get<bool>(AppConfig::AudioVirtualSinkForceMaxValue));
1818
appMgr = std::make_unique<PwAppManager>(mgr.get());
1919
plugin = new PwJamesDspPlugin(mgr.get(), this);
2020
effects = std::make_unique<FilterContainer>(mgr.get(), plugin, &AppConfig::instance());

src/audio/pipewire/PwPipelineManager.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,7 +1432,7 @@ const struct pw_registry_events registry_events = {
14321432

14331433
} // namespace
14341434

1435-
PwPipelineManager::PwPipelineManager() : header_version(pw_get_headers_version()), library_version(pw_get_library_version()) {
1435+
PwPipelineManager::PwPipelineManager(bool sinkForceMaxVolume) : header_version(pw_get_headers_version()), library_version(pw_get_library_version()) {
14361436
pw_init(nullptr, nullptr);
14371437

14381438
spa_zero(core_listener);
@@ -1494,7 +1494,7 @@ PwPipelineManager::PwPipelineManager() : header_version(pw_get_headers_version()
14941494
pw_properties_set(props_sink, "factory.name", "support.null-audio-sink");
14951495
pw_properties_set(props_sink, PW_KEY_MEDIA_CLASS, tags::pipewire::media_class::sink);
14961496
pw_properties_set(props_sink, "audio.position", "FL,FR");
1497-
pw_properties_set(props_sink, "monitor.channel-volumes", "false");
1497+
pw_properties_set(props_sink, "monitor.channel-volumes", !sinkForceMaxVolume ? "true" : "false");
14981498

14991499
proxy_stream_output_sink = static_cast<pw_proxy*>(
15001500
pw_core_create_object(core, "adapter", PW_TYPE_INTERFACE_Node, PW_VERSION_NODE, &props_sink->dict, 0));

src/audio/pipewire/PwPipelineManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050

5151
class PwPipelineManager {
5252
public:
53-
PwPipelineManager();
53+
PwPipelineManager(bool sinkForceMaxVolume);
5454
PwPipelineManager(const PwPipelineManager&) = delete;
5555
auto operator=(const PwPipelineManager&) -> PwPipelineManager& = delete;
5656
PwPipelineManager(const PwPipelineManager&&) = delete;

src/config/AppConfig.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ AppConfig::AppConfig()
4242
DEFINE_KEY(AudioAppBlocklist, QStringList());
4343
DEFINE_KEY(AudioAppBlocklistInvert, false);
4444
DEFINE_KEY(AudioInactivityTimeout, 10);
45+
DEFINE_KEY(AudioVirtualSinkForceMaxValue, true);
4546

4647
DEFINE_KEY(BenchmarkOnBoot, false);
4748
DEFINE_KEY(BenchmarkCacheC0, "");

src/config/AppConfig.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ class AppConfig :
6666
AudioAppBlocklist,
6767
AudioAppBlocklistInvert,
6868
AudioInactivityTimeout,
69+
AudioVirtualSinkForceMaxValue,
6970

7071
BenchmarkOnBoot,
7172
BenchmarkCacheC0,

src/interface/fragment/SettingsFragment.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,9 @@ SettingsFragment::SettingsFragment(TrayIcon *trayIcon,
9999
* Audio processing
100100
*/
101101
connect(ui->benchmarkOnBoot, &QCheckBox::clicked, this, &SettingsFragment::onBenchmarkOnBootToggled);
102-
connect(ui->benchmarkNow, &QCheckBox::clicked, this, &SettingsFragment::onBenchmarkRunClicked);
103-
connect(ui->benchmarkClear, &QCheckBox::clicked, this, &SettingsFragment::onBenchmarkClearClicked);
102+
connect(ui->benchmarkNow, &QPushButton::clicked, this, &SettingsFragment::onBenchmarkRunClicked);
103+
connect(ui->benchmarkClear, &QPushButton::clicked, this, &SettingsFragment::onBenchmarkClearClicked);
104+
connect(ui->sinkAllowVolumeControl, &QCheckBox::clicked, this, &SettingsFragment::onSinkAllowVolumeControlClicked);
104105
connect(_audioService, &IAudioService::benchmarkDone, this, [this]{ updateBenchmarkStatus(tr("benchmark data loaded")); });
105106

106107
/*
@@ -267,6 +268,7 @@ void SettingsFragment::refreshAll()
267268
ui->eq_alwaysdrawhandles->setChecked(AppConfig::instance().get<bool>(AppConfig::EqualizerShowHandles));
268269

269270
ui->benchmarkOnBoot->setChecked(AppConfig::instance().get<bool>(AppConfig::BenchmarkOnBoot));
271+
ui->sinkAllowVolumeControl->setChecked(!AppConfig::instance().get<bool>(AppConfig::AudioVirtualSinkForceMaxValue));
270272

271273
ui->blocklistInvert->blockSignals(true);
272274
ui->blocklistInvert->setChecked(AppConfig::instance().get<bool>(AppConfig::AudioAppBlocklistInvert));
@@ -460,6 +462,11 @@ void SettingsFragment::onBenchmarkClearClicked()
460462
updateBenchmarkStatus(tr("no benchmark data stored"));
461463
}
462464

465+
void SettingsFragment::onSinkAllowVolumeControlClicked()
466+
{
467+
AppConfig::instance().set(AppConfig::AudioVirtualSinkForceMaxValue, !ui->sinkAllowVolumeControl->isChecked());
468+
}
469+
463470
void SettingsFragment::onLiveprogAutoExtractToggled()
464471
{
465472
AppConfig::instance().set(AppConfig::LiveprogAutoExtract, ui->liveprog_autoextract->isChecked());

src/interface/fragment/SettingsFragment.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ private slots:
6969
void onBenchmarkOnBootToggled();
7070
void onBenchmarkRunClicked();
7171
void onBenchmarkClearClicked();
72+
void onSinkAllowVolumeControlClicked();
7273
void onLiveprogAutoExtractToggled();
7374
void onGithubLinkClicked();
7475
void onAeqDatabaseManageClicked();

src/interface/fragment/SettingsFragment.ui

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<x>0</x>
88
<y>0</y>
99
<width>685</width>
10-
<height>365</height>
10+
<height>400</height>
1111
</rect>
1212
</property>
1313
<property name="minimumSize">
@@ -391,6 +391,41 @@
391391
</layout>
392392
</widget>
393393
</item>
394+
<item>
395+
<widget class="QGroupBox" name="groupBox_2">
396+
<property name="title">
397+
<string>Workarounds</string>
398+
</property>
399+
<layout class="QVBoxLayout" name="verticalLayout_13">
400+
<item>
401+
<widget class="QCheckBox" name="sinkAllowVolumeControl">
402+
<property name="sizePolicy">
403+
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
404+
<horstretch>0</horstretch>
405+
<verstretch>0</verstretch>
406+
</sizepolicy>
407+
</property>
408+
<property name="text">
409+
<string>Allow volume control of the virtual sink device</string>
410+
</property>
411+
</widget>
412+
</item>
413+
<item>
414+
<widget class="QLabel" name="label_10">
415+
<property name="enabled">
416+
<bool>false</bool>
417+
</property>
418+
<property name="text">
419+
<string>Restart required to apply changes. May cause audio loss in some cases.</string>
420+
</property>
421+
<property name="wordWrap">
422+
<bool>true</bool>
423+
</property>
424+
</widget>
425+
</item>
426+
</layout>
427+
</widget>
428+
</item>
394429
<item>
395430
<spacer name="verticalSpacer_5">
396431
<property name="orientation">

0 commit comments

Comments
 (0)