TTKMusicPlayer  3.7.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
musicfplconfigmanager.cpp
Go to the documentation of this file.
2 
4 {
5  uint unk1; // not sure??
6  uint file_ofz; // filename string offset
7  uint subsong; // subsong index value
8  uint fsize; // filesize
9  uint unk2; // ??
10  uint unk3; // ??
11  uint unk4; // ??
12  char duration_dbl[8]; // track duration data (converted later)
13  float rpg_album; // replay gain, album
14  float rpg_track; // replay gain, track
15  float rpk_album; // replay gain, album peak
16  float rpk_track; // replay gain, track peak
17  uint keys_dex; // number of key/pointers that follow
18  uint key_primary; // number of primary info keys
19  uint key_second; // number of secondary info key combos
20  uint key_sec_offset; // index of secondary key start
21 };
22 
23 
27 {
28 
29 }
30 
31 bool MusicFPLConfigManager::readBuffer(MusicSongItemList &items)
32 {
33  const QFileInfo fin(m_file.fileName());
34  MusicSongItem item;
35  item.m_itemName = fin.baseName();
36 
37  // read 16-byte signature
38  char magic[16] = {0};
39  m_file.read(magic, 16);
40 
41  // load primary data string into memory
42  uint dataSize;
43  m_file.read((char*)&dataSize, 4);
44 
45  char *dataPrime = new char[dataSize]{0};
46  // read in primary string to memory
47  m_file.read(dataPrime, dataSize);
48 
49  // read playlist count integer
50  uint plSize;
51  m_file.read((char*)&plSize, 4);
52 
53  uint keyRunner[512];
54  double duration = 0.0f;
55 
56  FPLTrackChunk chunkRunner;
57  for(size_t i = 0; i < plSize && !m_file.atEnd(); ++i)
58  {
59  m_file.read((char*)&chunkRunner, sizeof(FPLTrackChunk));
60  // keys_dex sanity check
61  if(chunkRunner.keys_dex > 512)
62  {
63  delete[] dataPrime;
64  m_file.close();
65  return false;
66  }
67 
68  m_file.read((char*)&keyRunner, sizeof(uint) * (chunkRunner.keys_dex - 3));
69  memcpy((void*)&duration, chunkRunner.duration_dbl, 8);
70 
71  QString path = dataPrime + chunkRunner.file_ofz;
72  path.remove("file://");
73  path = fin.absolutePath() + TTK_SEPARATOR + path;
74  item.m_songs << MusicSong(path, TTKTime::formatDuration(duration * TTK_DN_S2MS));
75  }
76 
77  delete[] dataPrime;
78  m_file.close();
79 
80  if(!item.m_songs.isEmpty())
81  {
82  items << item;
83  }
84  return true;
85 }
86 
87 bool MusicFPLConfigManager::writeBuffer(const MusicSongItemList &items)
88 {
89  Q_UNUSED(items);
90  return false;
91 }
virtual bool readBuffer(MusicSongItemList &items) overridefinal
virtual bool writeBuffer(const MusicSongItemList &items) overridefinal
#define TTK_SEPARATOR
Definition: ttkglobal.h:195
The class of the read write interface.
#define TTK_DN_S2MS
Definition: ttkglobal.h:276
The class of the music song item.
Definition: musicsong.h:161
QString m_itemName
Definition: musicsong.h:164
The class of the music song info.
Definition: musicsong.h:28
The class of the ttk file interface.
static qint64 formatDuration(const QString &time) noexcept
Definition: ttktime.cpp:123