Fix pulseaudio device selection
This commit is contained in:
parent
8df599ffe5
commit
d45f8672cd
|
@ -19,6 +19,7 @@
|
||||||
project(strawberry)
|
project(strawberry)
|
||||||
cmake_minimum_required(VERSION 2.8.11)
|
cmake_minimum_required(VERSION 2.8.11)
|
||||||
cmake_policy(SET CMP0054 NEW)
|
cmake_policy(SET CMP0054 NEW)
|
||||||
|
cmake_policy(SET CMP0072 NEW)
|
||||||
|
|
||||||
include(CheckCXXCompilerFlag)
|
include(CheckCXXCompilerFlag)
|
||||||
include(CheckIncludeFiles)
|
include(CheckIncludeFiles)
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#cmakedefine HAVE_GIO
|
#cmakedefine HAVE_GIO
|
||||||
#cmakedefine HAVE_DBUS
|
#cmakedefine HAVE_DBUS
|
||||||
#cmakedefine HAVE_UDISKS2
|
#cmakedefine HAVE_UDISKS2
|
||||||
|
#cmakedefine HAVE_ALSA
|
||||||
#cmakedefine HAVE_DEVICEKIT
|
#cmakedefine HAVE_DEVICEKIT
|
||||||
#cmakedefine HAVE_IMOBILEDEVICE
|
#cmakedefine HAVE_IMOBILEDEVICE
|
||||||
#cmakedefine HAVE_LIBARCHIVE
|
#cmakedefine HAVE_LIBARCHIVE
|
||||||
|
|
|
@ -543,7 +543,7 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSD *osd, co
|
||||||
// Windows 7 thumbbar buttons
|
// Windows 7 thumbbar buttons
|
||||||
thumbbar_->SetActions(QList<QAction*>() << ui_->action_previous_track << ui_->action_play_pause << ui_->action_stop << ui_->action_next_track << nullptr); // spacer
|
thumbbar_->SetActions(QList<QAction*>() << ui_->action_previous_track << ui_->action_play_pause << ui_->action_stop << ui_->action_next_track << nullptr); // spacer
|
||||||
|
|
||||||
#if (defined(Q_OS_DARWIN) && defined(HAVE_SPARKLE)) || defined(Q_OS_WIN32)
|
#if (defined(Q_OS_DARWIN) && defined(HAVE_SPARKLE))
|
||||||
// Add check for updates item to application menu.
|
// Add check for updates item to application menu.
|
||||||
QAction *check_updates = ui_->menu_tools->addAction(tr("Check for updates..."));
|
QAction *check_updates = ui_->menu_tools->addAction(tr("Check for updates..."));
|
||||||
check_updates->setMenuRole(QAction::ApplicationSpecificRole);
|
check_updates->setMenuRole(QAction::ApplicationSpecificRole);
|
||||||
|
|
|
@ -48,6 +48,9 @@ QString DeviceFinder::GuessIconName(const QString &description) {
|
||||||
if (description_lower.contains("headset")) {
|
if (description_lower.contains("headset")) {
|
||||||
return "headset";
|
return "headset";
|
||||||
}
|
}
|
||||||
|
if (description_lower.contains("pulseaudio")) {
|
||||||
|
return "pulseaudio";
|
||||||
|
}
|
||||||
|
|
||||||
return "soundcard";
|
return "soundcard";
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
#include "devicefinder.h"
|
#include "devicefinder.h"
|
||||||
#include "enginedevice.h"
|
#include "enginedevice.h"
|
||||||
|
|
||||||
#ifdef Q_OS_LINUX
|
#ifdef HAVE_ALSA
|
||||||
# include "alsadevicefinder.h"
|
# include "alsadevicefinder.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ void EngineDevice::Init() {
|
||||||
|
|
||||||
QList<DeviceFinder*> device_finders;
|
QList<DeviceFinder*> device_finders;
|
||||||
|
|
||||||
#ifdef Q_OS_LINUX
|
#ifdef HAVE_ALSA
|
||||||
device_finders.append(new AlsaDeviceFinder);
|
device_finders.append(new AlsaDeviceFinder);
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_LIBPULSE
|
#ifdef HAVE_LIBPULSE
|
||||||
|
|
|
@ -67,21 +67,6 @@
|
||||||
# include "ext/gstafc/gstafcsrc.h"
|
# include "ext/gstafc/gstafcsrc.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef Q_OS_LINUX
|
|
||||||
# include "alsadevicefinder.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_LIBPULSE
|
|
||||||
# include "pulsedevicefinder.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef Q_OS_DARWIN
|
|
||||||
# include "osxdevicefinder.h"
|
|
||||||
#endif
|
|
||||||
#ifdef Q_OS_WIN32
|
|
||||||
# include "directsounddevicefinder.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "settings/backendsettingspage.h"
|
#include "settings/backendsettingspage.h"
|
||||||
|
|
||||||
using std::shared_ptr;
|
using std::shared_ptr;
|
||||||
|
@ -852,7 +837,13 @@ shared_ptr<GstEnginePipeline> GstEngine::CreatePipeline(const QByteArray &url, q
|
||||||
|
|
||||||
bool GstEngine::ALSADeviceSupport(const QString &name) {
|
bool GstEngine::ALSADeviceSupport(const QString &name) {
|
||||||
|
|
||||||
return (name == kALSASink || name == kOSSSink || name == kPulseSink);
|
return (name == kALSASink || name == kOSSSink);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GstEngine::PulseDeviceSupport(const QString &name) {
|
||||||
|
|
||||||
|
return (name == kPulseSink);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -87,6 +87,7 @@ class GstEngine : public Engine::Base, public GstBufferConsumer {
|
||||||
const Engine::Scope &scope(int chunk_length);
|
const Engine::Scope &scope(int chunk_length);
|
||||||
|
|
||||||
static bool ALSADeviceSupport(const QString &name);
|
static bool ALSADeviceSupport(const QString &name);
|
||||||
|
static bool PulseDeviceSupport(const QString &name);
|
||||||
|
|
||||||
GstElement *CreateElement(const QString &factoryName, GstElement *bin = 0, bool fatal = true, bool showerror = true);
|
GstElement *CreateElement(const QString &factoryName, GstElement *bin = 0, bool fatal = true, bool showerror = true);
|
||||||
|
|
||||||
|
|
|
@ -123,7 +123,7 @@ void PulseDeviceFinder::GetSinkInfoCallback(pa_context *c, const pa_sink_info *i
|
||||||
Device dev;
|
Device dev;
|
||||||
dev.description = QString::fromUtf8(info->description);
|
dev.description = QString::fromUtf8(info->description);
|
||||||
dev.value = QString::fromUtf8(info->name);
|
dev.value = QString::fromUtf8(info->name);
|
||||||
dev.iconname = QString::fromUtf8(pa_proplist_gets(info->proplist, "device.iconname"));
|
dev.iconname = GuessIconName(dev.description);
|
||||||
|
|
||||||
state->devices.append(dev);
|
state->devices.append(dev);
|
||||||
}
|
}
|
||||||
|
|
|
@ -193,7 +193,7 @@ void BackendSettingsPage::Load_Engine(Engine::EngineType enginetype) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BackendSettingsPage::Load_Device(QString output, QVariant device, bool alsa) {
|
void BackendSettingsPage::Load_Device(QString output, QVariant device, bool alsa, bool pulseaudio) {
|
||||||
|
|
||||||
int devices = 0;
|
int devices = 0;
|
||||||
DeviceFinder::Device dfdevice;
|
DeviceFinder::Device dfdevice;
|
||||||
|
@ -206,11 +206,12 @@ void BackendSettingsPage::Load_Device(QString output, QVariant device, bool alsa
|
||||||
ui_->combobox_device->addItem(IconLoader::Load("soundcard"), "Automatically select", "");
|
ui_->combobox_device->addItem(IconLoader::Load("soundcard"), "Automatically select", "");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (alsa) ui_->lineedit_device->setEnabled(true);
|
if (alsa || pulseaudio) ui_->lineedit_device->setEnabled(true);
|
||||||
else ui_->lineedit_device->setEnabled(false);
|
else ui_->lineedit_device->setEnabled(false);
|
||||||
|
|
||||||
for (DeviceFinder *f : dialog()->app()->enginedevice()->device_finders_) {
|
for (DeviceFinder *f : dialog()->app()->enginedevice()->device_finders_) {
|
||||||
if (f->name() == "alsa" && !alsa) continue;
|
if (f->name() == "alsa" && !alsa) continue;
|
||||||
|
if (f->name() == "pulseaudio" && !pulseaudio) continue;
|
||||||
for (const DeviceFinder::Device &d : f->ListDevices()) {
|
for (const DeviceFinder::Device &d : f->ListDevices()) {
|
||||||
devices++;
|
devices++;
|
||||||
ui_->combobox_device->addItem(IconLoader::Load(d.iconname), d.description, d.value);
|
ui_->combobox_device->addItem(IconLoader::Load(d.iconname), d.description, d.value);
|
||||||
|
@ -218,7 +219,7 @@ void BackendSettingsPage::Load_Device(QString output, QVariant device, bool alsa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (alsa) ui_->combobox_device->addItem(IconLoader::Load("soundcard"), "Custom", QVariant(""));
|
if (alsa || pulseaudio) ui_->combobox_device->addItem(IconLoader::Load("soundcard"), "Custom", QVariant(""));
|
||||||
|
|
||||||
bool found = false;
|
bool found = false;
|
||||||
if (devices > 0) ui_->combobox_device->setEnabled(true);
|
if (devices > 0) ui_->combobox_device->setEnabled(true);
|
||||||
|
@ -269,7 +270,7 @@ void BackendSettingsPage::Gst_Load(QString output, QVariant device) {
|
||||||
engineloaded_=Engine::GStreamer;
|
engineloaded_=Engine::GStreamer;
|
||||||
ui_->groupbox_replaygain->setEnabled(true);
|
ui_->groupbox_replaygain->setEnabled(true);
|
||||||
|
|
||||||
Load_Device(output, device, GstEngine::ALSADeviceSupport(output));
|
Load_Device(output, device, GstEngine::ALSADeviceSupport(output), GstEngine::PulseDeviceSupport(output));
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -477,7 +478,7 @@ void BackendSettingsPage::Xine_OutputChanged(int index) {
|
||||||
void BackendSettingsPage::Gst_OutputChanged(int index) {
|
void BackendSettingsPage::Gst_OutputChanged(int index) {
|
||||||
|
|
||||||
EngineBase::OutputDetails output = ui_->combobox_output->itemData(index).value<EngineBase::OutputDetails>();
|
EngineBase::OutputDetails output = ui_->combobox_output->itemData(index).value<EngineBase::OutputDetails>();
|
||||||
Load_Device(output.name, QVariant(), GstEngine::ALSADeviceSupport(output.name));
|
Load_Device(output.name, QVariant(), GstEngine::ALSADeviceSupport(output.name), GstEngine::PulseDeviceSupport(output.name));
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -67,7 +67,7 @@ private:
|
||||||
void OutputChanged(int index, Engine::EngineType enginetype);
|
void OutputChanged(int index, Engine::EngineType enginetype);
|
||||||
|
|
||||||
void Load_Engine(Engine::EngineType enginetype);
|
void Load_Engine(Engine::EngineType enginetype);
|
||||||
void Load_Device(QString output, QVariant device, bool alsa);
|
void Load_Device(QString output, QVariant device, bool alsa, bool pulseaudio);
|
||||||
|
|
||||||
#ifdef HAVE_XINE
|
#ifdef HAVE_XINE
|
||||||
void Xine_Load(QString output, QVariant device);
|
void Xine_Load(QString output, QVariant device);
|
||||||
|
|
Loading…
Reference in New Issue