Code tidy

This commit is contained in:
Jonas Kvinge 2021-07-23 21:30:08 +02:00
parent f144c982e3
commit a353631892
4 changed files with 12 additions and 8 deletions

View File

@ -28,6 +28,8 @@
#include "song.h"
#include "urlhandler.h"
UrlHandler::UrlHandler(QObject *parent) : QObject(parent) {}
UrlHandler::LoadResult::LoadResult(const QUrl &original_url, const Type type, const QUrl &stream_url, const Song::FileType filetype, const int samplerate, const int bit_depth, const qint64 length_nanosec, const QString &error) :
original_url_(original_url),
type_(type),
@ -48,5 +50,3 @@ UrlHandler::LoadResult::LoadResult(const QUrl &original_url, const Type type, co
length_nanosec_(-1),
error_(error)
{}
UrlHandler::UrlHandler(QObject *parent) : QObject(parent) {}

View File

@ -65,6 +65,7 @@ class UrlHandler : public QObject {
// Might be something unplayable like lastfm://...
QUrl original_url_;
// Result type
Type type_;
// The actual url to something that gstreamer can play.

View File

@ -38,11 +38,11 @@ SubsonicUrlHandler::SubsonicUrlHandler(Application *app, SubsonicService *servic
UrlHandler::LoadResult SubsonicUrlHandler::StartLoading(const QUrl &url) {
if (!server_url().isValid()) {
return LoadResult(url, LoadResult::Error, url, Song::FileType_Stream, -1, -1, -1, tr("Subsonic server URL is invalid."));
return LoadResult(url, LoadResult::Error, tr("Subsonic server URL is invalid."));
}
if (username().isEmpty() || password().isEmpty()) {
return LoadResult(url, LoadResult::Error, url, Song::FileType_Stream, -1, -1, -1, tr("Missing Subsonic username or password."));
return LoadResult(url, LoadResult::Error, tr("Missing Subsonic username or password."));
}
ParamList params = ParamList() << Param("c", service_->client_name())
@ -62,8 +62,9 @@ UrlHandler::LoadResult SubsonicUrlHandler::StartLoading(const QUrl &url) {
if (!stream_url.path().isEmpty() && stream_url.path().right(1) == "/") {
stream_url.setPath(stream_url.path() + QString("rest/stream.view"));
}
else
else {
stream_url.setPath(stream_url.path() + QString("/rest/stream.view"));
}
stream_url.setQuery(url_query);

View File

@ -54,10 +54,12 @@ void TidalUrlHandler::GetStreamURLFinished(const QUrl &original_url, const QUrl
if (task_id_ == -1) return;
CancelTask();
if (error.isEmpty())
if (error.isEmpty()) {
emit AsyncLoadComplete(LoadResult(original_url, LoadResult::TrackAvailable, stream_url, filetype, samplerate, bit_depth, duration));
else
emit AsyncLoadComplete(LoadResult(original_url, LoadResult::Error, stream_url, filetype, -1, -1, -1, error));
}
else {
emit AsyncLoadComplete(LoadResult(original_url, LoadResult::Error, error));
}
}