-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy pathcoverartcache.h
More file actions
92 lines (78 loc) · 2.5 KB
/
coverartcache.h
File metadata and controls
92 lines (78 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#pragma once
#include <QObject>
#include <QPair>
#include <QPixmap>
#include <QSet>
#include <QtDebug>
#include "library/coverart.h"
#include "track/track_decl.h"
#include "util/singleton.h"
class CoverArtCache : public QObject, public Singleton<CoverArtCache> {
Q_OBJECT
public:
static void requestCover(
const QObject* pRequester,
const CoverInfo& coverInfo) {
requestCoverImpl(pRequester, TrackPointer(), coverInfo);
}
static void requestTrackCover(
const QObject* pRequester,
const TrackPointer& pTrack);
static QPixmap getCachedCover(
const CoverInfo& coverInfo,
int desiredWidth);
static void requestUncachedCover(
const QObject* pRequester,
const CoverInfo& coverInfo,
int desiredWidth);
static void requestUncachedCover(
const QObject* pRequester,
const TrackPointer& pTrack,
int desiredWidth);
// Only public for testing
struct FutureResult {
FutureResult()
: requestedCacheKey(CoverImageUtils::defaultCacheKey()) {
}
FutureResult(
mixxx::cache_key_t requestedCacheKeyArg)
: requestedCacheKey(requestedCacheKeyArg) {
}
mixxx::cache_key_t requestedCacheKey;
CoverArt coverArt;
};
// Load cover from path indicated in coverInfo. WARNING: This is run in a
// worker thread.
static FutureResult loadCover(
TrackPointer pTrack,
CoverInfo coverInfo,
int desiredWidth);
private slots:
// Called when loadCover is complete in the main thread.
void coverLoaded();
signals:
void coverFound(
const QObject* requester,
const CoverInfo& coverInfo,
const QPixmap& pixmap);
protected:
CoverArtCache();
~CoverArtCache() override = default;
friend class Singleton<CoverArtCache>;
private:
static void requestCoverImpl(
const QObject* pRequester,
const TrackPointer& /*optional*/ pTrack,
const CoverInfo& coverInfo,
int desiredWidth = 0); // <= 0: original size
void tryLoadCover(
const QObject* pRequester,
const TrackPointer& pTrack,
const CoverInfo& info,
int desiredWidth);
struct RequestData {
const QObject* pRequester;
int desiredWidth;
};
QMultiHash<mixxx::cache_key_t, RequestData> m_runningRequests;
};