mirror of
https://github.com/strawberrymusicplayer/strawberry
synced 2025-02-09 16:28:54 +01:00
Fix bug not loading engine
This commit is contained in:
parent
a8a714c820
commit
a9e905b301
@ -106,7 +106,7 @@ Player::~Player() {
|
|||||||
settings_.endGroup();
|
settings_.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::CreateEngine(Engine::EngineType enginetype) {
|
Engine::EngineType Player::CreateEngine(Engine::EngineType enginetype) {
|
||||||
|
|
||||||
Engine::EngineType use_enginetype(Engine::None);
|
Engine::EngineType use_enginetype(Engine::None);
|
||||||
|
|
||||||
@ -166,6 +166,8 @@ void Player::CreateEngine(Engine::EngineType enginetype) {
|
|||||||
qFatal("Failed to create engine!");
|
qFatal("Failed to create engine!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return use_enginetype;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::Init() {
|
void Player::Init() {
|
||||||
|
@ -134,7 +134,7 @@ class Player : public PlayerInterface {
|
|||||||
PreviousBehaviour_Restart = 2
|
PreviousBehaviour_Restart = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
void CreateEngine(Engine::EngineType enginetype);
|
Engine::EngineType CreateEngine(Engine::EngineType enginetype);
|
||||||
void Init();
|
void Init();
|
||||||
|
|
||||||
EngineBase *engine() const { return engine_.get(); }
|
EngineBase *engine() const { return engine_.get(); }
|
||||||
|
@ -69,14 +69,17 @@ bool VLCEngine::Init() {
|
|||||||
|
|
||||||
// Create the VLC instance
|
// Create the VLC instance
|
||||||
instance_ = libvlc_new(sizeof(args) / sizeof(*args), args);
|
instance_ = libvlc_new(sizeof(args) / sizeof(*args), args);
|
||||||
|
if (!instance_) return false;
|
||||||
HandleErrors();
|
HandleErrors();
|
||||||
|
|
||||||
// Create the media player
|
// Create the media player
|
||||||
player_ = libvlc_media_player_new(instance_);
|
player_ = libvlc_media_player_new(instance_);
|
||||||
|
if (!player_) return false;
|
||||||
HandleErrors();
|
HandleErrors();
|
||||||
|
|
||||||
// Add event handlers
|
// Add event handlers
|
||||||
libvlc_event_manager_t *player_em = libvlc_media_player_event_manager(player_);
|
libvlc_event_manager_t *player_em = libvlc_media_player_event_manager(player_);
|
||||||
|
if (!player_em) return false;
|
||||||
HandleErrors();
|
HandleErrors();
|
||||||
|
|
||||||
AttachCallback(player_em, libvlc_MediaPlayerEncounteredError, StateChangedCallback);
|
AttachCallback(player_em, libvlc_MediaPlayerEncounteredError, StateChangedCallback);
|
||||||
|
@ -121,9 +121,10 @@ bool XineEngine::Init() {
|
|||||||
qLog(Error) << "Invalid output detected:" << output_ << " - Resetting to default.";
|
qLog(Error) << "Invalid output detected:" << output_ << " - Resetting to default.";
|
||||||
output_ = DefaultOutput();
|
output_ = DefaultOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
audioport_ = xine_open_audio_driver(xine_, (output_.isEmpty() || output_ == kAutoOutput ? nullptr : output_.toUtf8().constData()), nullptr);
|
audioport_ = xine_open_audio_driver(xine_, (output_.isEmpty() || output_ == kAutoOutput ? nullptr : output_.toUtf8().constData()), nullptr);
|
||||||
if (!audioport_) {
|
if (!audioport_) {
|
||||||
emit Error("Xine was unable to initialize any audio drivers.");
|
qLog(Error) << "Xine was unable to initialize any audio drivers.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -353,7 +354,7 @@ void XineEngine::ReloadSettings() {
|
|||||||
|
|
||||||
Engine::Base::ReloadSettings();
|
Engine::Base::ReloadSettings();
|
||||||
|
|
||||||
if (output_ == "") output_ = DefaultOutput();
|
if (output_.isEmpty()) output_ = DefaultOutput();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,23 +85,23 @@ void BackendSettingsPage::Load() {
|
|||||||
|
|
||||||
ui_->combobox_engine->clear();
|
ui_->combobox_engine->clear();
|
||||||
#ifdef HAVE_GSTREAMER
|
#ifdef HAVE_GSTREAMER
|
||||||
ui_->combobox_engine->addItem(IconLoader::Load("gstreamer"), EngineDescription(Engine::GStreamer), Engine::GStreamer);
|
ui_->combobox_engine->addItem(IconLoader::Load("gstreamer"), EngineDescription(Engine::GStreamer), QVariant::fromValue(Engine::GStreamer));
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_XINE
|
#ifdef HAVE_XINE
|
||||||
ui_->combobox_engine->addItem(IconLoader::Load("xine"), EngineDescription(Engine::Xine), Engine::Xine);
|
ui_->combobox_engine->addItem(IconLoader::Load("xine"), EngineDescription(Engine::Xine), QVariant::fromValue(Engine::Xine));
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_VLC
|
#ifdef HAVE_VLC
|
||||||
ui_->combobox_engine->addItem(IconLoader::Load("vlc"), EngineDescription(Engine::VLC), Engine::VLC);
|
ui_->combobox_engine->addItem(IconLoader::Load("vlc"), EngineDescription(Engine::VLC), QVariant::fromValue(Engine::VLC));
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_PHONON
|
#ifdef HAVE_PHONON
|
||||||
ui_->combobox_engine->addItem(IconLoader::Load("speaker"), EngineDescription(Engine::Phonon), Engine::Phonon);
|
ui_->combobox_engine->addItem(IconLoader::Load("speaker"), EngineDescription(Engine::Phonon), QVariant::fromValue(Engine::Phonon));
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_DEEZER
|
#ifdef HAVE_DEEZER
|
||||||
ui_->combobox_engine->addItem(IconLoader::Load("deezer"), EngineDescription(Engine::Deezer), Engine::Deezer);
|
ui_->combobox_engine->addItem(IconLoader::Load("deezer"), EngineDescription(Engine::Deezer), QVariant::fromValue(Engine::Deezer));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
enginetype_current_ = enginetype;
|
enginetype_current_ = enginetype;
|
||||||
output_current_ = s_.value("output", "").toString();
|
output_current_ = s_.value("output", QString()).toString();
|
||||||
device_current_ = s_.value("device", QVariant());
|
device_current_ = s_.value("device", QVariant());
|
||||||
|
|
||||||
ui_->combobox_engine->setCurrentIndex(ui_->combobox_engine->findData(enginetype));
|
ui_->combobox_engine->setCurrentIndex(ui_->combobox_engine->findData(enginetype));
|
||||||
@ -191,10 +191,12 @@ void BackendSettingsPage::Load_Engine(Engine::EngineType enginetype) {
|
|||||||
|
|
||||||
if (engine()->type() != enginetype) {
|
if (engine()->type() != enginetype) {
|
||||||
qLog(Debug) << "Switching engine.";
|
qLog(Debug) << "Switching engine.";
|
||||||
dialog()->app()->player()->CreateEngine(enginetype);
|
Engine::EngineType new_enginetype = dialog()->app()->player()->CreateEngine(enginetype);
|
||||||
dialog()->app()->player()->ReloadSettings();
|
|
||||||
dialog()->app()->player()->Init();
|
dialog()->app()->player()->Init();
|
||||||
dialog()->set_output_changed(false);
|
dialog()->set_output_changed(false);
|
||||||
|
if (new_enginetype != enginetype) {
|
||||||
|
ui_->combobox_engine->setCurrentIndex(ui_->combobox_engine->findData(engine()->type()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
engineloaded_ = true;
|
engineloaded_ = true;
|
||||||
@ -207,7 +209,7 @@ void BackendSettingsPage::Load_Output(QString output, QVariant device) {
|
|||||||
|
|
||||||
if (!EngineInitialised()) return;
|
if (!EngineInitialised()) return;
|
||||||
|
|
||||||
if (output == "") output = engine()->DefaultOutput();
|
if (output.isEmpty()) output = engine()->DefaultOutput();
|
||||||
|
|
||||||
ui_->combobox_output->clear();
|
ui_->combobox_output->clear();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
@ -228,7 +230,7 @@ void BackendSettingsPage::Load_Output(QString output, QVariant device) {
|
|||||||
}
|
}
|
||||||
if (!found) { // Output is invalid for this engine, reset to default output.
|
if (!found) { // Output is invalid for this engine, reset to default output.
|
||||||
output = engine()->DefaultOutput();
|
output = engine()->DefaultOutput();
|
||||||
device = (engine()->CustomDeviceSupport(output) == true ? QVariant("") : QVariant());
|
device = (engine()->CustomDeviceSupport(output) ? QString() : QVariant());
|
||||||
for (int i = 0; i < ui_->combobox_output->count(); ++i) {
|
for (int i = 0; i < ui_->combobox_output->count(); ++i) {
|
||||||
EngineBase::OutputDetails o = ui_->combobox_output->itemData(i).value<EngineBase::OutputDetails>();
|
EngineBase::OutputDetails o = ui_->combobox_output->itemData(i).value<EngineBase::OutputDetails>();
|
||||||
if (o.name == output) {
|
if (o.name == output) {
|
||||||
@ -270,7 +272,7 @@ void BackendSettingsPage::Load_Device(QString output, QVariant device) {
|
|||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
if (engine()->type() != Engine::GStreamer)
|
if (engine()->type() != Engine::GStreamer)
|
||||||
#endif
|
#endif
|
||||||
ui_->combobox_device->addItem(IconLoader::Load("soundcard"), "Automatically select", QVariant(""));
|
ui_->combobox_device->addItem(IconLoader::Load("soundcard"), "Automatically select", QVariant());
|
||||||
|
|
||||||
for (DeviceFinder *f : dialog()->app()->enginedevice()->device_finders_) {
|
for (DeviceFinder *f : dialog()->app()->enginedevice()->device_finders_) {
|
||||||
if (!f->outputs().contains(output)) continue;
|
if (!f->outputs().contains(output)) continue;
|
||||||
@ -283,7 +285,7 @@ void BackendSettingsPage::Load_Device(QString output, QVariant device) {
|
|||||||
if (devices > 0) ui_->combobox_device->setEnabled(true);
|
if (devices > 0) ui_->combobox_device->setEnabled(true);
|
||||||
|
|
||||||
if (engine()->CustomDeviceSupport(output)) {
|
if (engine()->CustomDeviceSupport(output)) {
|
||||||
ui_->combobox_device->addItem(IconLoader::Load("soundcard"), "Custom", QVariant(""));
|
ui_->combobox_device->addItem(IconLoader::Load("soundcard"), "Custom", QVariant());
|
||||||
ui_->lineedit_device->setEnabled(true);
|
ui_->lineedit_device->setEnabled(true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -380,7 +382,6 @@ void BackendSettingsPage::Save() {
|
|||||||
void BackendSettingsPage::Cancel() {
|
void BackendSettingsPage::Cancel() {
|
||||||
if (engine() && engine()->type() != enginetype_current_) { // Reset engine back to the original because user cancelled.
|
if (engine() && engine()->type() != enginetype_current_) { // Reset engine back to the original because user cancelled.
|
||||||
dialog()->app()->player()->CreateEngine(enginetype_current_);
|
dialog()->app()->player()->CreateEngine(enginetype_current_);
|
||||||
dialog()->app()->player()->ReloadSettings();
|
|
||||||
dialog()->app()->player()->Init();
|
dialog()->app()->player()->Init();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user