-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCoverArtBackend.h
59 lines (51 loc) · 1.92 KB
/
CoverArtBackend.h
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
#ifndef COVERARTBACKEND_H
#define COVERARTBACKEND_H
#include <QObject>
#include <QFuture>
#include <DBApi.h>
#include "include/artwork.h"
#undef __ARTWORK_H
#include "include/artwork2.h"
// abstract CoverArtBackend definition
class CoverArtBackend : public QObject {
Q_OBJECT
public:
explicit CoverArtBackend(QObject *parent = nullptr, DB_functions_t *funcs = nullptr);
virtual QFuture<char *> loadCoverArt(DB_playItem_t *) = 0;
virtual const char * getDefaultCoverArt() = 0;
virtual void unloadCoverArt(const char*) = 0;
DB_functions_t *db;
};
class CoverArtLegacy : public CoverArtBackend {
Q_OBJECT
public:
CoverArtLegacy(QObject *parent = nullptr, DB_functions_t *funcs = nullptr);
~CoverArtLegacy();
// virtual functions implementation
QFuture<char *> loadCoverArt(DB_playItem_t *);
const char *getDefaultCoverArt();
void unloadCoverArt(const char*);
// static functions for threaded callback
static char *getArtwork(const QString fname, const QString artist, const QString album, DB_artwork_plugin_t *plug);
static void artwork_callback(const char *fname, const char *artist, const char *album, void *user_data);
protected:
DB_artwork_plugin_t *plug;
char *script_album_byte = nullptr;
char *script_artist_byte = nullptr;
};
class CoverArtNew : public CoverArtBackend {
Q_OBJECT
public:
CoverArtNew(QObject *parent = nullptr, DB_functions_t *funcs = nullptr);
// virtual functions implementation
QFuture<char *> loadCoverArt(DB_playItem_t *);
const char *getDefaultCoverArt();
void unloadCoverArt(const char *);
// static functions for threaded callback
static char *getArtwork(DB_playItem_t *it, CoverArtNew *can);
static void artwork_callback(int error, ddb_cover_query_t *query, ddb_cover_info_t *cover);
// variables
QHash<const char *, ddb_cover_info_t *> ht;
ddb_artwork_plugin_t *plug;
};
#endif // COVERARTBACKEND_H