-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdecoderxsffactory.cpp
More file actions
122 lines (107 loc) · 3.3 KB
/
Copy pathdecoderxsffactory.cpp
File metadata and controls
122 lines (107 loc) · 3.3 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#include "decoderxsffactory.h"
#include "xsfhelper.h"
#include "decoder_xsf.h"
#include "xsfmetadatamodel.h"
#include <QMessageBox>
bool DecoderXSFFactory::canDecode(QIODevice *input) const
{
const QFile * const file = qobject_cast<QFile*>(input);
if(!file)
{
return false;
}
XSFHelper helper(file->fileName());
return helper.initialize();
}
DecoderProperties DecoderXSFFactory::properties() const
{
DecoderProperties properties;
properties.name = tr("XSF Plugin");
properties.shortName = "xsf";
properties.filters << "*.2sf" << "*.mini2sf";
properties.filters << "*.gsf" << "*.minigsf";
properties.filters << "*.usf" << "*.miniusf";
properties.filters << "*.ncsf" << "*.minincsf";
properties.filters << "*.snsf" << "*.minisnsf";
properties.filters << "*.pcm" << "*.msu";
properties.description = "Audio Overload File";
properties.protocols << "file";
properties.noInput = true;
properties.hasAbout = true;
return properties;
}
Decoder *DecoderXSFFactory::create(const QString &path, QIODevice *input)
{
Q_UNUSED(input);
return new DecoderXSF(path);
}
TrackInfoList DecoderXSFFactory::createPlayList(const QString &path, TrackInfo::Parts parts, QStringList *)
{
#if QMMP_VERSION_INT < 0x20400
TrackInfo *raw(new TrackInfo(path)), *info = raw;
#else
TrackInfo raw(path), *info = &raw;
#endif
if(parts == TrackInfo::Parts())
{
return {raw};
}
XSFHelper helper(path, true);
if(!helper.initialize())
{
#if QMMP_VERSION_INT < 0x20400
delete info;
#endif
return {};
}
if((parts & TrackInfo::MetaData) && helper.hasTags())
{
info->setValue(Qmmp::TITLE, helper.tag("title"));
info->setValue(Qmmp::ARTIST, helper.tag("artist"));
info->setValue(Qmmp::ALBUM, helper.tag("album"));
info->setValue(Qmmp::GENRE, helper.tag("genre"));
info->setValue(Qmmp::YEAR, helper.tag("year"));
}
if(parts & TrackInfo::Properties)
{
info->setValue(Qmmp::BITRATE, helper.bitrate());
info->setValue(Qmmp::SAMPLERATE, helper.sampleRate());
info->setValue(Qmmp::CHANNELS, helper.channels());
info->setValue(Qmmp::BITS_PER_SAMPLE, helper.depth());
info->setValue(Qmmp::FORMAT_NAME, helper.format());
info->setDuration(helper.totalTime());
}
return {raw};
}
MetaDataModel *DecoderXSFFactory::createMetaDataModel(const QString &path, bool readOnly)
{
Q_UNUSED(readOnly);
return new XSFMetaDataModel(path);
}
#if (QMMP_VERSION_INT < 0x10700) || (0x20000 <= QMMP_VERSION_INT && QMMP_VERSION_INT < 0x20200)
void DecoderXSFFactory::showSettings(QWidget *parent)
{
Q_UNUSED(parent);
}
#else
QDialog *DecoderXSFFactory::createSettings(QWidget *parent)
{
Q_UNUSED(parent);
return nullptr;
}
#endif
void DecoderXSFFactory::showAbout(QWidget *parent)
{
QMessageBox::about(parent, tr("About XSF Reader Plugin"),
tr("Qmmp XSF Reader Plugin") + "\n" +
tr("Written by: Greedysky <greedysky@163.com>") + "\n" +
tr("Based on the source code from the Audio Overload"));
}
QString DecoderXSFFactory::translation() const
{
return QString();
}
#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
#include <QtPlugin>
Q_EXPORT_PLUGIN2(xsf, DecoderXSFFactory)
#endif