Use one instance of NetworkAccessManager
This commit is contained in:
@@ -24,6 +24,8 @@
|
||||
#include <QString>
|
||||
#include <QUrl>
|
||||
|
||||
#include "core/application.h"
|
||||
#include "core/networkaccessmanager.h"
|
||||
#include "collection/collectionmodel.h"
|
||||
#include "cddasongloader.h"
|
||||
#include "connecteddevice.h"
|
||||
@@ -35,7 +37,7 @@ class DeviceManager;
|
||||
|
||||
CddaDevice::CddaDevice(const QUrl &url, DeviceLister *lister, const QString &unique_id, DeviceManager *manager, Application *app, int database_id, bool first_time, QObject *parent)
|
||||
: ConnectedDevice(url, lister, unique_id, manager, app, database_id, first_time, parent),
|
||||
cdda_song_loader_(url) {
|
||||
cdda_song_loader_(url, app->network()) {
|
||||
|
||||
QObject::connect(&cdda_song_loader_, &CddaSongLoader::SongsLoaded, this, &CddaDevice::SongsLoaded);
|
||||
QObject::connect(&cdda_song_loader_, &CddaSongLoader::SongsDurationLoaded, this, &CddaDevice::SongsLoaded);
|
||||
|
||||
@@ -39,11 +39,13 @@
|
||||
|
||||
#include "cddasongloader.h"
|
||||
#include "core/logging.h"
|
||||
#include "core/networkaccessmanager.h"
|
||||
#include "utilities/timeconstants.h"
|
||||
|
||||
CddaSongLoader::CddaSongLoader(const QUrl &url, QObject *parent)
|
||||
CddaSongLoader::CddaSongLoader(const QUrl &url, NetworkAccessManager *network, QObject *parent)
|
||||
: QObject(parent),
|
||||
url_(url),
|
||||
network_(network),
|
||||
cdda_(nullptr),
|
||||
cdio_(nullptr) {}
|
||||
|
||||
@@ -195,7 +197,7 @@ void CddaSongLoader::LoadSongs() {
|
||||
QString musicbrainz_discid(string_mb);
|
||||
qLog(Info) << "MusicBrainz discid: " << musicbrainz_discid;
|
||||
|
||||
MusicBrainzClient *musicbrainz_client = new MusicBrainzClient;
|
||||
MusicBrainzClient *musicbrainz_client = new MusicBrainzClient(network_);
|
||||
QObject::connect(musicbrainz_client, &MusicBrainzClient::DiscIdFinished, this, &CddaSongLoader::AudioCDTagsLoaded);
|
||||
musicbrainz_client->StartDiscIdRequest(musicbrainz_discid);
|
||||
g_free(string_mb);
|
||||
|
||||
@@ -40,12 +40,14 @@
|
||||
# include "musicbrainz/musicbrainzclient.h"
|
||||
#endif
|
||||
|
||||
class NetworkAccessManager;
|
||||
|
||||
// This class provides a (hopefully) nice, high level interface to get CD information and load tracks
|
||||
class CddaSongLoader : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CddaSongLoader(const QUrl &url = QUrl(), QObject *parent = nullptr);
|
||||
explicit CddaSongLoader(const QUrl &url, NetworkAccessManager *network, QObject *parent = nullptr);
|
||||
~CddaSongLoader() override;
|
||||
|
||||
// Load songs. Signals declared below will be emitted anytime new information will be available.
|
||||
@@ -68,7 +70,8 @@ class CddaSongLoader : public QObject {
|
||||
#endif
|
||||
|
||||
private:
|
||||
QUrl url_;
|
||||
const QUrl url_;
|
||||
NetworkAccessManager *network_;
|
||||
GstElement *cdda_;
|
||||
CdIo_t *cdio_;
|
||||
QMutex mutex_load_;
|
||||
|
||||
Reference in New Issue
Block a user