mirror of
https://github.com/clementine-player/Clementine
synced 2025-01-10 17:13:39 +01:00
Fix cdda playback
QUrl interprets a single number as an ip address, so the track URL cdda://1
would become cdda://0.0.0.1. A previous fix addresses this issue by adding an
extra character "a" to the affected URLs then removing the last instance of the
character upon usage. However, this didn't apply when a path was present
(cdda:///dev/sr0/1), but would still attempt to reverse the change later
(cdd:///dev/sr0/1).
This change applies the fix-up to all cdda urls and moves the conversion
utilities to a single location.
See: 335bc89c9
("Workaround for broken CD playback in Qt5 (#6021)")
This commit is contained in:
parent
bf3d3db234
commit
7e3cd84b5d
@ -45,6 +45,17 @@ class CddaDevice : public ConnectedDevice {
|
||||
|
||||
static QStringList url_schemes() { return QStringList() << "cdda"; }
|
||||
|
||||
// QUrl interprets a single number as an ip address, so the QString cdda://1
|
||||
// would become the QUrl cdda://0.0.0.1. For this reason, we append a single
|
||||
// character to strings when converting to URLs and strip that character
|
||||
// when doing the reverse conversion.
|
||||
static QUrl TrackStrToUrl(const QString& name) { return QUrl(name + "a"); }
|
||||
static QString TrackUrlToStr(const QUrl& url) {
|
||||
QString str = url.toString();
|
||||
str.remove(str.lastIndexOf(QChar('a')), 1);
|
||||
return str;
|
||||
}
|
||||
|
||||
signals:
|
||||
void SongsDiscovered(const SongList& songs);
|
||||
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "core/logging.h"
|
||||
#include "core/timeconstants.h"
|
||||
|
||||
#include "cddadevice.h"
|
||||
#include "cddasongloader.h"
|
||||
|
||||
CddaSongLoader::CddaSongLoader(const QUrl& url, QObject* parent)
|
||||
@ -36,11 +37,13 @@ CddaSongLoader::~CddaSongLoader() {
|
||||
}
|
||||
|
||||
QUrl CddaSongLoader::GetUrlFromTrack(int track_number) const {
|
||||
QString track;
|
||||
if (url_.isEmpty()) {
|
||||
return QUrl(QString("cdda://%1a").arg(track_number));
|
||||
track = QString("cdda://%1").arg(track_number);
|
||||
} else {
|
||||
return QUrl(QString("cdda://%1/%2").arg(url_.path()).arg(track_number));
|
||||
track = QString("cdda://%1/%2").arg(url_.path()).arg(track_number);
|
||||
}
|
||||
return CddaDevice::TrackStrToUrl(track);
|
||||
}
|
||||
|
||||
void CddaSongLoader::LoadSongs() {
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "core/mac_startup.h"
|
||||
#include "core/signalchecker.h"
|
||||
#include "core/utilities.h"
|
||||
#include "devices/cddadevice.h"
|
||||
#include "internet/core/internetmodel.h"
|
||||
#ifdef HAVE_SPOTIFY
|
||||
# include "internet/spotify/spotifyserver.h"
|
||||
@ -203,9 +204,7 @@ GstElement* GstEnginePipeline::CreateDecodeBinFromUrl(const QUrl& url) {
|
||||
#endif
|
||||
QByteArray uri;
|
||||
if (url.scheme() == "cdda") {
|
||||
QString str = url.toString();
|
||||
str.remove(str.lastIndexOf(QChar('a')), 1);
|
||||
uri = str.toUtf8();
|
||||
uri = CddaDevice::TrackUrlToStr(url).toUtf8();
|
||||
} else {
|
||||
uri = Utilities::GetUriForGstreamer(url);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user