Fix setting output/device for Xine and VLC backend

- Fixed setting output and device on Xine and VLC backend
- Fixed track slider for Xine, VLC and Phonon
- Improved backend settings to better support multiple backends
- Added group by samplerate and bitdepth in collection
- Fixed crash on exit when existing instance of the application is already runnung caused by NVIDIA driver
- Changed Q_OS_MAC to Q_OS_MACOS
This commit is contained in:
Jonas Kvinge
2018-06-28 01:15:32 +02:00
parent 6978983dd3
commit 985b91e5f4
56 changed files with 2799 additions and 2589 deletions

View File

@@ -2,6 +2,7 @@
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
* Copyright 2018, Jonas Kvinge <jonas@jkvinge.net>
*
* Strawberry is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -60,6 +61,8 @@
#include <iostream>
#endif // Q_OS_WIN32
#include "main.h"
#include "core/logging.h"
#include "qtsingleapplication.h"
@@ -132,6 +135,7 @@ int main(int argc, char* argv[]) {
qLog(Info) << "Strawberry is already running - activating existing window";
}
if (a.sendMessage(options.Serialize(), 5000)) {
main_exit_safe(0);
return 0;
}
// Couldn't send the message so start anyway
@@ -175,8 +179,8 @@ int main(int argc, char* argv[]) {
QCoreApplication::setAttribute(Qt::AA_NativeWindows, true);
#endif
// Set the permissions on the config file on Unix - it can contain passwords for internet services so it's important that other users can't read it.
// On Windows these are stored in the registry instead.
// Set the permissions on the config file on Unix - it can contain passwords for internet services so it's important that other users can't read it.
// On Windows these are stored in the registry instead.
#ifdef Q_OS_UNIX
{
QSettings s;
@@ -226,17 +230,44 @@ int main(int argc, char* argv[]) {
int ret = a.exec();
#ifdef Q_OS_LINUX
QFile self_maps("/proc/self/maps");
if (self_maps.open(QIODevice::ReadOnly)) {
QByteArray data = self_maps.readAll();
if (data.contains("libnvidia-tls.so.")) {
qLog(Warning) << "Exiting immediately to work around NVIDIA driver bug";
_exit(ret);
}
self_maps.close();
}
#endif
main_exit_safe(ret);
return ret;
}
void main_exit_safe(int ret) {
#ifdef Q_OS_LINUX
bool have_nvidia = false;
QFile proc_modules("/proc/modules");
if (proc_modules.open(QIODevice::ReadOnly)) {
forever {
QByteArray line = proc_modules.readLine();
if (line.startsWith("nvidia ") || line.startsWith("nvidia_")) {
have_nvidia = true;
}
if (proc_modules.atEnd()) break;
}
proc_modules.close();
}
QFile self_maps("/proc/self/maps");
if (self_maps.open(QIODevice::ReadOnly)) {
forever {
QByteArray line = self_maps.readLine();
if (line.startsWith("libnvidia-")) {
have_nvidia = true;
}
if (self_maps.atEnd()) break;
}
self_maps.close();
}
if (have_nvidia) {
qLog(Warning) << "Exiting immediately to work around NVIDIA driver bug.";
_exit(ret);
}
#endif
}

28
src/core/main.h Normal file
View File

@@ -0,0 +1,28 @@
/*
* Strawberry Music Player
* Copyright 2018, Jonas Kvinge <jonas@jkvinge.net>
*
* Strawberry is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Strawberry is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef MAIN_H
#define MAIN_H
#include "config.h"
int main(int argc, char* argv[]);
void main_exit_safe(int ret);
#endif // MAIN_H

View File

@@ -741,7 +741,6 @@ void MainWindow::ReloadAllSettings() {
app_->player()->ReloadSettings();
osd_->ReloadSettings();
collection_view_->ReloadSettings();
app_->player()->engine()->ReloadSettings();
ui_->playlist->view()->ReloadSettings();
}

View File

@@ -75,8 +75,6 @@ using std::shared_ptr;
Player::Player(Application *app, QObject *parent)
: PlayerInterface(parent),
app_(app),
//engine_(new GstEngine(app_->task_manager())),
//engine_(CreateEngine()),
stream_change_type_(Engine::First),
last_state_(Engine::Empty),
nb_errors_received_(0),
@@ -88,7 +86,7 @@ Player::Player(Application *app, QObject *parent)
QSettings s;
s.beginGroup(BackendSettingsPage::kSettingsGroup);
Engine::EngineType enginetype = Engine::EngineTypeFromName(s.value("engine", BackendSettingsPage::EngineText_GStreamer).toString().toLower());
Engine::EngineType enginetype = Engine::EngineTypeFromName(s.value("engine", EngineName(Engine::GStreamer)).toString().toLower());
s.endGroup();
CreateEngine(enginetype);
@@ -129,19 +127,19 @@ EngineBase *Player::CreateEngine(Engine::EngineType enginetype) {
enginebase = new XineEngine(app_->task_manager());
break;
#endif
#ifdef HAVE_PHONON
case Engine::Phonon:
engine=true;
enginetype=Engine::Phonon;
enginebase = new PhononEngine(app_->task_manager());
break;
#endif
#ifdef HAVE_VLC
case Engine::VLC:
engine=true;
enginetype=Engine::VLC;
enginebase = new VLCEngine(app_->task_manager());
break;
#endif
#ifdef HAVE_PHONON
case Engine::Phonon:
engine=true;
enginetype=Engine::Phonon;
enginebase = new PhononEngine(app_->task_manager());
break;
#endif
default:
if (i > 1) { qFatal("No engine available!"); return nullptr; }
@@ -149,7 +147,7 @@ EngineBase *Player::CreateEngine(Engine::EngineType enginetype) {
s.beginGroup(BackendSettingsPage::kSettingsGroup);
s.setValue("engine", "");
s.setValue("output", "");
s.setValue("device", "");
s.setValue("device", QVariant(""));
s.endGroup();
enginetype = Engine::None;
break;
@@ -158,7 +156,7 @@ EngineBase *Player::CreateEngine(Engine::EngineType enginetype) {
QSettings s;
s.beginGroup(BackendSettingsPage::kSettingsGroup);
s.setValue("engine", Engine::EngineNameFromType(enginetype));
s.setValue("engine", Engine::EngineName(enginetype));
s.endGroup();
if (enginebase == nullptr) {
@@ -226,7 +224,7 @@ void Player::ReloadSettings() {
seek_step_sec_ = s.value("seek_step_sec", 10).toInt();
s.endGroup();
engine_->ReloadSettings();
if (engine_.get()) engine_->ReloadSettings();
}

View File

@@ -671,7 +671,7 @@ bool IsLaptop() {
return !(status.BatteryFlag & 128); // 128 = no system battery
#elif defined(Q_OS_LINUX)
return !QDir("/proc/acpi/battery").entryList(QDir::Dirs | QDir::NoDotAndDotDot).isEmpty();
#elif defined(Q_OS_MAC)
#elif defined(Q_OS_MACOS)
ScopedCFTypeRef<CFTypeRef> power_sources(IOPSCopyPowerSourcesInfo());
ScopedCFTypeRef<CFArrayRef> power_source_list(IOPSCopyPowerSourcesList(power_sources.get()));
for (CFIndex i = 0; i < CFArrayGetCount(power_source_list.get()); ++i) {