Compare commits

...

5 Commits

Author SHA1 Message Date
Jonas Kvinge
6102679496 Change GuiPrivate to XcbQpaPrivate 2025-12-29 00:48:46 +01:00
Strawberry Bot
da2f28811a New translations 2025-12-29 00:02:45 +01:00
Jonas Kvinge
0bfa736081 GstEnginePipeline: Add audioresample elements 2025-12-28 22:01:42 +01:00
Jonas Kvinge
1392bcbbe1 FilesystemMusicStorage: Fallback to delete if moving to trash fails
Fixes #1679
2025-12-28 21:28:49 +01:00
Jonas Kvinge
11705889f1 Show playlist load errors
Fixes #1470
2025-12-28 20:54:36 +01:00
12 changed files with 97 additions and 41 deletions

View File

@@ -218,16 +218,16 @@ set(QT_VERSION_MAJOR 6)
set(QT_MIN_VERSION 6.4.0)
set(QT_DEFAULT_MAJOR_VERSION ${QT_VERSION_MAJOR})
set(QT_COMPONENTS Core Concurrent Gui Widgets Network Sql)
set(QT_OPTIONAL_COMPONENTS GuiPrivate LinguistTools Test)
set(QT_OPTIONAL_COMPONENTS LinguistTools Test)
if(UNIX AND NOT APPLE)
list(APPEND QT_OPTIONAL_COMPONENTS DBus)
list(APPEND QT_OPTIONAL_COMPONENTS DBus XcbQpaPrivate)
endif()
set(QT_NO_PRIVATE_MODULE_WARNING ON)
find_package(Qt${QT_VERSION_MAJOR} ${QT_MIN_VERSION} COMPONENTS ${QT_COMPONENTS} REQUIRED OPTIONAL_COMPONENTS ${QT_OPTIONAL_COMPONENTS})
if(TARGET "Qt${QT_VERSION_MAJOR}::GuiPrivate")
set(QT_GUI_PRIVATE_FOUND ON)
if(TARGET "Qt${QT_VERSION_MAJOR}::XcbQpaPrivate")
set(QT_XCB_QPA_PRIVATE_FOUND ON)
endif()
if(Qt${QT_VERSION_MAJOR}DBus_FOUND)
@@ -369,8 +369,8 @@ if(APPLE OR WIN32)
)
endif()
optional_component(QPA_QPLATFORMNATIVEINTERFACE ON "QPA Platform Native Interface"
DEPENDS "Qt Gui Private" QT_GUI_PRIVATE_FOUND
optional_component(QT_XCB_QPA_PRIVATE ON "XCB QPA Platform Native Interface"
DEPENDS "Qt XCB QPA Private" QT_XCB_QPA_PRIVATE_FOUND
)
optional_component(STREAMTAGREADER ON "Stream tagreader"
@@ -1549,7 +1549,7 @@ target_link_libraries(strawberry_lib PUBLIC
Qt${QT_VERSION_MAJOR}::Network
Qt${QT_VERSION_MAJOR}::Sql
$<$<BOOL:${HAVE_DBUS}>:Qt${QT_VERSION_MAJOR}::DBus>
$<$<BOOL:${HAVE_QPA_QPLATFORMNATIVEINTERFACE}>:Qt${QT_VERSION_MAJOR}::GuiPrivate>
$<$<BOOL:${HAVE_QT_XCB_QPA_PRIVATE}>:Qt${QT_VERSION_MAJOR}::XcbQpaPrivate>
ICU::uc
ICU::i18n
$<$<BOOL:${HAVE_STREAMTAGREADER}>:PkgConfig::LIBSPARSEHASH>

View File

@@ -43,7 +43,7 @@
#cmakedefine INSTALL_TRANSLATIONS
#define TRANSLATIONS_DIR "${CMAKE_INSTALL_PREFIX}/share/strawberry/translations"
#cmakedefine HAVE_QPA_QPLATFORMNATIVEINTERFACE
#cmakedefine HAVE_QT_XCB_QPA_PRIVATE
#cmakedefine HAVE_QX11APPLICATION
#cmakedefine ENABLE_WIN32_CONSOLE

View File

@@ -110,21 +110,32 @@ bool FilesystemMusicStorage::CopyToStorage(const CopyJob &job, QString &error_te
bool FilesystemMusicStorage::DeleteFromStorage(const DeleteJob &job) {
QString path = job.metadata_.url().toLocalFile();
QFileInfo fileInfo(path);
const QString path = job.metadata_.url().toLocalFile();
const QFileInfo fileInfo(path);
#if QT_VERSION >= QT_VERSION_CHECK(6, 9, 0)
if (job.use_trash_ && QFile::supportsMoveToTrash()) {
#else
if (job.use_trash_) {
#endif
return QFile::moveToTrash(path);
if (QFile::moveToTrash(path)) {
return true;
}
qLog(Warning) << "Moving file to trash failed for" << path << ", falling back to direct deletion";
}
bool success = false;
if (fileInfo.isDir()) {
return Utilities::RemoveRecursive(path);
success = Utilities::RemoveRecursive(path);
}
else {
success = QFile::remove(path);
}
return QFile::remove(path);
if (!success) {
qLog(Error) << "Failed to delete file" << path;
}
return success;
}

View File

@@ -98,6 +98,9 @@ SongLoader::SongLoader(const SharedPtr<UrlHandlers> url_handlers,
QObject::connect(timeout_timer_, &QTimer::timeout, this, &SongLoader::Timeout);
QObject::connect(playlist_parser_, &PlaylistParser::Error, this, &SongLoader::ParserError);
QObject::connect(cue_parser_, &CueParser::Error, this, &SongLoader::ParserError);
}
SongLoader::~SongLoader() {
@@ -106,6 +109,10 @@ SongLoader::~SongLoader() {
}
void SongLoader::ParserError(const QString &error) {
errors_ << error;
}
SongLoader::Result SongLoader::Load(const QUrl &url) {
if (url.isEmpty()) return Result::Error;
@@ -287,6 +294,7 @@ SongLoader::Result SongLoader::LoadLocalAsync(const QString &filename) {
}
if (parser) { // It's a playlist!
QObject::connect(parser, &ParserBase::Error, this, &SongLoader::ParserError, static_cast<Qt::ConnectionType>(Qt::QueuedConnection | Qt::UniqueConnection));
qLog(Debug) << "Parsing using" << parser->name();
LoadPlaylist(parser, filename);
return Result::Success;
@@ -706,6 +714,10 @@ void SongLoader::MagicReady() {
StopTypefindAsync(true);
}
if (parser_) {
QObject::connect(parser_, &ParserBase::Error, this, &SongLoader::ParserError, static_cast<Qt::ConnectionType>(Qt::QueuedConnection | Qt::UniqueConnection));
}
state_ = State::WaitingForData;
if (!IsPipelinePlaying()) {

View File

@@ -99,6 +99,7 @@ class SongLoader : public QObject {
void ScheduleTimeout();
void Timeout();
void StopTypefind();
void ParserError(const QString &error);
#ifdef HAVE_AUDIOCD
void AudioCDTracksLoadErrorSlot(const QString &error);

View File

@@ -178,7 +178,6 @@ GstEnginePipeline::GstEnginePipeline(QObject *parent)
audiobin_(nullptr),
audiosink_(nullptr),
audioqueue_(nullptr),
audioqueueconverter_(nullptr),
volume_(nullptr),
volume_sw_(nullptr),
volume_fading_(nullptr),
@@ -187,6 +186,7 @@ GstEnginePipeline::GstEnginePipeline(QObject *parent)
equalizer_(nullptr),
equalizer_preamp_(nullptr),
eventprobe_(nullptr),
bufferprobe_(nullptr),
logged_unsupported_analyzer_format_(false),
about_to_finish_(false),
finish_requested_(false),
@@ -436,7 +436,7 @@ void GstEnginePipeline::Disconnect() {
}
if (buffer_probe_cb_id_.has_value()) {
GstPad *pad = gst_element_get_static_pad(audioqueueconverter_, "src");
GstPad *pad = gst_element_get_static_pad(bufferprobe_, "src");
if (pad) {
gst_pad_remove_probe(pad, buffer_probe_cb_id_.value());
gst_object_unref(pad);
@@ -674,8 +674,13 @@ bool GstEnginePipeline::InitAudioBin(QString &error) {
return false;
}
audioqueueconverter_ = CreateElement(u"audioconvert"_s, u"audioqueueconverter"_s, audiobin_, error);
if (!audioqueueconverter_) {
GstElement *audioqueueconverter = CreateElement(u"audioconvert"_s, u"audioqueueconverter"_s, audiobin_, error);
if (!audioqueueconverter) {
return false;
}
GstElement *audioqueueresampler = CreateElement(u"audioresample"_s, u"audioqueueresampler"_s, audiobin_, error);
if (!audioqueueresampler) {
return false;
}
@@ -684,6 +689,11 @@ bool GstEnginePipeline::InitAudioBin(QString &error) {
return false;
}
GstElement *audiosinkresampler = CreateElement(u"audioresample"_s, u"audiosinkresampler"_s, audiobin_, error);
if (!audiosinkresampler) {
return false;
}
// Create the volume element if it's enabled.
if (volume_enabled_ && !volume_) {
volume_sw_ = CreateElement(u"volume"_s, u"volume_sw"_s, audiobin_, error);
@@ -761,7 +771,8 @@ bool GstEnginePipeline::InitAudioBin(QString &error) {
}
eventprobe_ = audioqueueconverter_;
eventprobe_ = audioqueueconverter;
bufferprobe_ = audioqueueconverter;
// Create the replaygain elements if it's enabled.
GstElement *rgvolume = nullptr;
@@ -847,12 +858,17 @@ bool GstEnginePipeline::InitAudioBin(QString &error) {
// Link all elements
if (!gst_element_link(audioqueue_, audioqueueconverter_)) {
if (!gst_element_link(audioqueue_, audioqueueconverter)) {
error = u"Failed to link audio queue to audio queue converter."_s;
return false;
}
GstElement *element_link = audioqueueconverter_; // The next element to link from.
if (!gst_element_link(audioqueueconverter, audioqueueresampler)) {
error = u"Failed to link audio queue converter to audio queue resampler."_s;
return false;
}
GstElement *element_link = audioqueueresampler; // The next element to link from.
// Link replaygain elements if enabled.
if (rg_enabled_ && rgvolume && rglimiter && rgconverter) {
@@ -928,6 +944,11 @@ bool GstEnginePipeline::InitAudioBin(QString &error) {
return false;
}
if (!gst_element_link(audiosinkconverter, audiosinkresampler)) {
error = "Failed to link audio sink converter to audio sink resampler."_L1;
return false;
}
{
GstCaps *caps = gst_caps_new_empty_simple("audio/x-raw");
if (!caps) {
@@ -938,16 +959,16 @@ bool GstEnginePipeline::InitAudioBin(QString &error) {
qLog(Debug) << "Setting channels to" << channels_;
gst_caps_set_simple(caps, "channels", G_TYPE_INT, channels_, nullptr);
}
const bool link_filtered_result = gst_element_link_filtered(audiosinkconverter, audiosink_, caps);
const bool link_filtered_result = gst_element_link_filtered(audiosinkresampler, audiosink_, caps);
gst_caps_unref(caps);
if (!link_filtered_result) {
error = "Failed to link audio sink converter to audio sink with filter for "_L1 + output_;
error = "Failed to link audio sink resampler to audio sink with filter for "_L1 + output_;
return false;
}
}
{ // Add probes and handlers.
GstPad *pad = gst_element_get_static_pad(audioqueueconverter_, "src");
GstPad *pad = gst_element_get_static_pad(bufferprobe_, "src");
if (pad) {
buffer_probe_cb_id_ = gst_pad_add_probe(pad, GST_PAD_PROBE_TYPE_BUFFER, BufferProbeCallback, this, nullptr);
gst_object_unref(pad);

View File

@@ -355,7 +355,6 @@ class GstEnginePipeline : public QObject {
GstElement *audiobin_;
GstElement *audiosink_;
GstElement *audioqueue_;
GstElement *audioqueueconverter_;
GstElement *volume_;
GstElement *volume_sw_;
GstElement *volume_fading_;
@@ -364,6 +363,7 @@ class GstEnginePipeline : public QObject {
GstElement *equalizer_;
GstElement *equalizer_preamp_;
GstElement *eventprobe_;
GstElement *bufferprobe_;
std::optional<gulong> upstream_events_probe_cb_id_;
std::optional<gulong> buffer_probe_cb_id_;

View File

@@ -51,7 +51,7 @@
#include <QFlags>
#include <QtEvents>
#ifdef HAVE_QPA_QPLATFORMNATIVEINTERFACE
#ifdef HAVE_QT_XCB_QPA_PRIVATE
# include <qpa/qplatformnativeinterface.h>
#endif
@@ -215,7 +215,7 @@ void OSDPretty::ScreenRemoved(QScreen *screen) {
bool OSDPretty::IsTransparencyAvailable() {
#ifdef HAVE_QPA_QPLATFORMNATIVEINTERFACE
#ifdef HAVE_QT_XCB_QPA_PRIVATE
if (qApp && QGuiApplication::platformName() == "xcb"_L1) {
QPlatformNativeInterface *native = QGuiApplication::platformNativeInterface();
QScreen *screen = popup_screen_ == nullptr ? QGuiApplication::primaryScreen() : popup_screen_;

View File

@@ -80,12 +80,13 @@ void SongLoaderInserter::Load(Playlist *destination, const int row, const bool p
songs_ << loader->songs();
playlist_name_ = loader->playlist_name();
}
else {
const QStringList errors = loader->errors();
for (const QString &error : errors) {
Q_EMIT Error(error);
}
// Always check for errors, even on success (e.g., playlist parsed but some songs failed to load)
const QStringList errors = loader->errors();
for (const QString &error : errors) {
Q_EMIT Error(error);
}
delete loader;
}
@@ -192,11 +193,13 @@ void SongLoaderInserter::AsyncLoad() {
const SongLoader::Result result = loader->LoadFilenamesBlocking();
task_manager_->SetTaskProgress(async_load_id, static_cast<quint64>(++async_progress));
// Always check for errors, even on success (e.g., playlist parsed but some songs failed to load)
const QStringList errors = loader->errors();
for (const QString &error : errors) {
Q_EMIT Error(error);
}
if (result == SongLoader::Result::Error) {
const QStringList errors = loader->errors();
for (const QString &error : errors) {
Q_EMIT Error(error);
}
continue;
}

View File

@@ -112,10 +112,18 @@ void ParserBase::LoadSong(const QString &filename_or_url, const qint64 beginning
}
}
// Check if the file exists before trying to read it
if (!QFile::exists(filename)) {
qLog(Error) << "File does not exist:" << filename;
Q_EMIT Error(tr("File %1 does not exist").arg(filename));
return;
}
if (tagreader_client_) {
const TagReaderResult result = tagreader_client_->ReadFileBlocking(filename, song);
if (!result.success()) {
qLog(Error) << "Could not read file" << filename << result.error_string();
Q_EMIT Error(tr("Could not read file %1: %2").arg(filename, result.error_string()));
}
}

View File

@@ -5526,7 +5526,7 @@ Are you sure you want to continue?</source>
<name>RadioParadiseService</name>
<message>
<source>Getting %1 channels</source>
<translation>Получение %1 каналов</translation>
<translation>Получение каналов %1</translation>
</message>
</context>
<context>
@@ -6191,7 +6191,7 @@ Are you sure you want to continue?</source>
<name>SomaFMService</name>
<message>
<source>Getting %1 channels</source>
<translation>Получение %1 каналов</translation>
<translation>Получение каналов %1</translation>
</message>
</context>
<context>

View File

@@ -1187,7 +1187,7 @@ If there are no matches then it will use the largest image in the directory.</tr
</message>
<message>
<source>Queue to play next</source>
<translation>Sıradaki Yap</translation>
<translation>Sıradaki yap</translation>
</message>
<message>
<source>Search for this</source>
@@ -3496,7 +3496,7 @@ If there are no matches then it will use the largest image in the directory.</tr
</message>
<message>
<source>Queue to play next</source>
<translation>Sıradaki Yap</translation>
<translation>Sıradaki yap</translation>
</message>
<message>
<source>Unskip track</source>
@@ -4431,7 +4431,7 @@ If there are no matches then it will use the largest image in the directory.</tr
</message>
<message>
<source>&amp;Hide %1</source>
<translation>&amp;%1&apos;i sakla</translation>
<translation>&amp;%1 ögesini sakla</translation>
</message>
</context>
<context>
@@ -6407,7 +6407,7 @@ Devam etmek istediğinizden emin misiniz?</translation>
</message>
<message>
<source>Queue to play next</source>
<translation>Sıradaki Yap</translation>
<translation>Sıradaki yap</translation>
</message>
<message>
<source>Remove from favorites</source>