Adapt most changes from taglib2
This commit is contained in:
14
3rdparty/taglib/mod/modfile.cpp
vendored
14
3rdparty/taglib/mod/modfile.cpp
vendored
@@ -67,14 +67,6 @@ Mod::AudioProperties *Mod::File::audioProperties() const {
|
||||
return &d->properties;
|
||||
}
|
||||
|
||||
PropertyMap Mod::File::properties() const {
|
||||
return d->tag.properties();
|
||||
}
|
||||
|
||||
PropertyMap Mod::File::setProperties(const PropertyMap &properties) {
|
||||
return d->tag.setProperties(properties);
|
||||
}
|
||||
|
||||
bool Mod::File::save() {
|
||||
|
||||
if (readOnly()) {
|
||||
@@ -84,13 +76,13 @@ bool Mod::File::save() {
|
||||
seek(0);
|
||||
writeString(d->tag.title(), 20);
|
||||
StringList lines = d->tag.comment().split("\n");
|
||||
unsigned int n = std::min(lines.size(), d->properties.instrumentCount());
|
||||
for (unsigned int i = 0; i < n; ++i) {
|
||||
size_t n = std::min<size_t>(lines.size(), d->properties.instrumentCount());
|
||||
for (size_t i = 0; i < n; ++i) {
|
||||
writeString(lines[i], 22);
|
||||
seek(8, Current);
|
||||
}
|
||||
|
||||
for (unsigned int i = n; i < d->properties.instrumentCount(); ++i) {
|
||||
for (size_t i = n; i < d->properties.instrumentCount(); ++i) {
|
||||
writeString(String(), 22);
|
||||
seek(8, Current);
|
||||
}
|
||||
|
||||
21
3rdparty/taglib/mod/modfile.h
vendored
21
3rdparty/taglib/mod/modfile.h
vendored
@@ -61,25 +61,14 @@ class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::Mod::FileBase {
|
||||
/*!
|
||||
* Destroys this instance of the File.
|
||||
*/
|
||||
virtual ~File();
|
||||
~File() override;
|
||||
|
||||
Mod::Tag *tag() const;
|
||||
Mod::Tag *tag() const override;
|
||||
|
||||
/*!
|
||||
* Implements the unified property interface -- export function.
|
||||
* Forwards to Mod::Tag::properties().
|
||||
*/
|
||||
PropertyMap properties() const;
|
||||
|
||||
/*!
|
||||
* Implements the unified property interface -- import function.
|
||||
* Forwards to Mod::Tag::setProperties().
|
||||
*/
|
||||
PropertyMap setProperties(const PropertyMap &);
|
||||
/*!
|
||||
* Returns the Mod::AudioProperties for this file. If no audio properties were read then this will return a null pointer.
|
||||
*/
|
||||
Mod::AudioProperties *audioProperties() const;
|
||||
Mod::AudioProperties *audioProperties() const override;
|
||||
|
||||
/*!
|
||||
* Save the file.
|
||||
@@ -87,10 +76,10 @@ class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::Mod::FileBase {
|
||||
*
|
||||
* \note Saving Protracker tags is not supported.
|
||||
*/
|
||||
bool save();
|
||||
bool save() override;
|
||||
|
||||
private:
|
||||
explicit File(const File &);
|
||||
File(const File &);
|
||||
File &operator=(const File &);
|
||||
|
||||
void read(bool readProperties);
|
||||
|
||||
32
3rdparty/taglib/mod/modfilebase.cpp
vendored
32
3rdparty/taglib/mod/modfilebase.cpp
vendored
@@ -34,18 +34,18 @@ Mod::FileBase::FileBase(FileName file) : Strawberry_TagLib::TagLib::File(file) {
|
||||
|
||||
Mod::FileBase::FileBase(IOStream *stream) : Strawberry_TagLib::TagLib::File(stream) {}
|
||||
|
||||
void Mod::FileBase::writeString(const String &s, unsigned long size, char padding) {
|
||||
void Mod::FileBase::writeString(const String &s, unsigned int size, char padding) {
|
||||
ByteVector data(s.data(String::Latin1));
|
||||
data.resize(size, padding);
|
||||
writeBlock(data);
|
||||
}
|
||||
|
||||
bool Mod::FileBase::readString(String &s, unsigned long size) {
|
||||
bool Mod::FileBase::readString(String &s, unsigned int size) {
|
||||
|
||||
ByteVector data(readBlock(size));
|
||||
if (data.size() < size) return false;
|
||||
int index = data.find(static_cast<char>(0));
|
||||
if (index > -1) {
|
||||
const size_t index = data.find(static_cast<char>(0));
|
||||
if (index != ByteVector::npos()) {
|
||||
data.resize(index);
|
||||
}
|
||||
data.replace('\xff', ' ');
|
||||
@@ -61,19 +61,19 @@ void Mod::FileBase::writeByte(unsigned char _byte) {
|
||||
}
|
||||
|
||||
void Mod::FileBase::writeU16L(unsigned short number) {
|
||||
writeBlock(ByteVector::fromShort(number, false));
|
||||
writeBlock(ByteVector::fromUInt16LE(number));
|
||||
}
|
||||
|
||||
void Mod::FileBase::writeU32L(unsigned long number) {
|
||||
writeBlock(ByteVector::fromUInt(number, false));
|
||||
void Mod::FileBase::writeU32L(unsigned int number) {
|
||||
writeBlock(ByteVector::fromUInt32LE(number));
|
||||
}
|
||||
|
||||
void Mod::FileBase::writeU16B(unsigned short number) {
|
||||
writeBlock(ByteVector::fromShort(number, true));
|
||||
writeBlock(ByteVector::fromUInt16BE(number));
|
||||
}
|
||||
|
||||
void Mod::FileBase::writeU32B(unsigned long number) {
|
||||
writeBlock(ByteVector::fromUInt(number, true));
|
||||
void Mod::FileBase::writeU32B(unsigned int number) {
|
||||
writeBlock(ByteVector::fromUInt32BE(number));
|
||||
}
|
||||
|
||||
bool Mod::FileBase::readByte(unsigned char &_byte) {
|
||||
@@ -89,16 +89,16 @@ bool Mod::FileBase::readU16L(unsigned short &number) {
|
||||
|
||||
ByteVector data(readBlock(2));
|
||||
if (data.size() < 2) return false;
|
||||
number = data.toUShort(false);
|
||||
number = data.toUInt16LE(0);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
bool Mod::FileBase::readU32L(unsigned long &number) {
|
||||
bool Mod::FileBase::readU32L(unsigned int &number) {
|
||||
|
||||
ByteVector data(readBlock(4));
|
||||
if (data.size() < 4) return false;
|
||||
number = data.toUInt(false);
|
||||
number = data.toUInt32LE(0);
|
||||
return true;
|
||||
|
||||
}
|
||||
@@ -107,16 +107,16 @@ bool Mod::FileBase::readU16B(unsigned short &number) {
|
||||
|
||||
ByteVector data(readBlock(2));
|
||||
if (data.size() < 2) return false;
|
||||
number = data.toUShort(true);
|
||||
number = data.toUInt16BE(0);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
bool Mod::FileBase::readU32B(unsigned long &number) {
|
||||
bool Mod::FileBase::readU32B(unsigned int &number) {
|
||||
|
||||
ByteVector data(readBlock(4));
|
||||
if (data.size() < 4) return false;
|
||||
number = data.toUInt(true);
|
||||
number = data.toUInt32BE(0);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
14
3rdparty/taglib/mod/modfilebase.h
vendored
14
3rdparty/taglib/mod/modfilebase.h
vendored
@@ -43,19 +43,19 @@ class TAGLIB_EXPORT FileBase : public Strawberry_TagLib::TagLib::File {
|
||||
explicit FileBase(FileName file);
|
||||
explicit FileBase(IOStream *stream);
|
||||
|
||||
void writeString(const String &s, unsigned long size, char padding = 0);
|
||||
void writeString(const String &s, unsigned int size, char padding = 0);
|
||||
void writeByte(unsigned char byte);
|
||||
void writeU16L(unsigned short number);
|
||||
void writeU32L(unsigned long number);
|
||||
void writeU32L(unsigned int number);
|
||||
void writeU16B(unsigned short number);
|
||||
void writeU32B(unsigned long number);
|
||||
void writeU32B(unsigned int number);
|
||||
|
||||
bool readString(String &s, unsigned long size);
|
||||
bool readByte(unsigned char &byte);
|
||||
bool readString(String &s, unsigned int size);
|
||||
bool readByte(unsigned char &_byte);
|
||||
bool readU16L(unsigned short &number);
|
||||
bool readU32L(unsigned long &number);
|
||||
bool readU32L(unsigned int &number);
|
||||
bool readU16B(unsigned short &number);
|
||||
bool readU32B(unsigned long &number);
|
||||
bool readU32B(unsigned int &number);
|
||||
};
|
||||
|
||||
} // namespace Mod
|
||||
|
||||
8
3rdparty/taglib/mod/modfileprivate.h
vendored
8
3rdparty/taglib/mod/modfileprivate.h
vendored
@@ -38,9 +38,9 @@
|
||||
|
||||
#define READ_BYTE(setter) READ(setter, unsigned char, readByte)
|
||||
#define READ_U16L(setter) READ(setter, unsigned short, readU16L)
|
||||
#define READ_U32L(setter) READ(setter, unsigned long, readU32L)
|
||||
#define READ_U32L(setter) READ(setter, unsigned int, readU32L)
|
||||
#define READ_U16B(setter) READ(setter, unsigned short, readU16B)
|
||||
#define READ_U32B(setter) READ(setter, unsigned long, readU32B)
|
||||
#define READ_U32B(setter) READ(setter, unsigned int, readU32B)
|
||||
|
||||
#define READ_STRING(setter, size) \
|
||||
{ \
|
||||
@@ -55,9 +55,9 @@
|
||||
|
||||
#define READ_BYTE_AS(name) READ_AS(unsigned char, name, readByte)
|
||||
#define READ_U16L_AS(name) READ_AS(unsigned short, name, readU16L)
|
||||
#define READ_U32L_AS(name) READ_AS(unsigned long, name, readU32L)
|
||||
#define READ_U32L_AS(name) READ_AS(unsigned int, name, readU32L)
|
||||
#define READ_U16B_AS(name) READ_AS(unsigned short, name, readU16B)
|
||||
#define READ_U32B_AS(name) READ_AS(unsigned long, name, readU32B)
|
||||
#define READ_U32B_AS(name) READ_AS(unsigned int, name, readU32B)
|
||||
|
||||
#define READ_STRING_AS(name, size) \
|
||||
String name; \
|
||||
|
||||
12
3rdparty/taglib/mod/modproperties.cpp
vendored
12
3rdparty/taglib/mod/modproperties.cpp
vendored
@@ -31,14 +31,18 @@ using namespace Mod;
|
||||
|
||||
class Mod::AudioProperties::AudioPropertiesPrivate {
|
||||
public:
|
||||
AudioPropertiesPrivate() : channels(0), instrumentCount(0), lengthInPatterns(0) {}
|
||||
explicit AudioPropertiesPrivate() : channels(0), instrumentCount(0), lengthInPatterns(0) {}
|
||||
|
||||
int channels;
|
||||
unsigned int instrumentCount;
|
||||
unsigned char lengthInPatterns;
|
||||
};
|
||||
|
||||
Mod::AudioProperties::AudioProperties(AudioProperties::ReadStyle propertiesStyle) : Strawberry_TagLib::TagLib::AudioProperties(propertiesStyle), d(new AudioPropertiesPrivate()) {
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// public members
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Mod::AudioProperties::AudioProperties(AudioProperties::ReadStyle) : Strawberry_TagLib::TagLib::AudioProperties(), d(new AudioPropertiesPrivate()) {
|
||||
}
|
||||
|
||||
Mod::AudioProperties::~AudioProperties() {
|
||||
@@ -73,6 +77,10 @@ unsigned char Mod::AudioProperties::lengthInPatterns() const {
|
||||
return d->lengthInPatterns;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// private members
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void Mod::AudioProperties::setChannels(int channels) {
|
||||
d->channels = channels;
|
||||
}
|
||||
|
||||
21
3rdparty/taglib/mod/modproperties.h
vendored
21
3rdparty/taglib/mod/modproperties.h
vendored
@@ -34,30 +34,27 @@ namespace TagLib {
|
||||
namespace Mod {
|
||||
|
||||
class TAGLIB_EXPORT AudioProperties : public Strawberry_TagLib::TagLib::AudioProperties {
|
||||
friend class File;
|
||||
|
||||
public:
|
||||
explicit AudioProperties(AudioProperties::ReadStyle propertiesStyle);
|
||||
virtual ~AudioProperties();
|
||||
~AudioProperties() override;
|
||||
|
||||
int lengthInSeconds() const;
|
||||
int lengthInMilliseconds() const;
|
||||
int bitrate() const;
|
||||
int sampleRate() const;
|
||||
int channels() const;
|
||||
int lengthInSeconds() const override;
|
||||
int lengthInMilliseconds() const override;
|
||||
int bitrate() const override;
|
||||
int sampleRate() const override;
|
||||
int channels() const override;
|
||||
|
||||
unsigned int instrumentCount() const;
|
||||
unsigned char lengthInPatterns() const;
|
||||
|
||||
private:
|
||||
void setChannels(int channels);
|
||||
|
||||
void setInstrumentCount(unsigned int instrumentCount);
|
||||
void setLengthInPatterns(unsigned char lengthInPatterns);
|
||||
|
||||
private:
|
||||
friend class File;
|
||||
|
||||
explicit AudioProperties(const AudioProperties&);
|
||||
AudioProperties &operator=(const AudioProperties&);
|
||||
|
||||
class AudioPropertiesPrivate;
|
||||
AudioPropertiesPrivate *d;
|
||||
};
|
||||
|
||||
9
3rdparty/taglib/mod/modtag.cpp
vendored
9
3rdparty/taglib/mod/modtag.cpp
vendored
@@ -27,13 +27,14 @@
|
||||
#include "modtag.h"
|
||||
#include "tstringlist.h"
|
||||
#include "tpropertymap.h"
|
||||
#include "tpicturemap.h"
|
||||
|
||||
using namespace Strawberry_TagLib::TagLib;
|
||||
using namespace Mod;
|
||||
|
||||
class Mod::Tag::TagPrivate {
|
||||
public:
|
||||
TagPrivate() {}
|
||||
explicit TagPrivate() {}
|
||||
|
||||
String title;
|
||||
String comment;
|
||||
@@ -74,6 +75,10 @@ unsigned int Mod::Tag::track() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Strawberry_TagLib::TagLib::PictureMap Mod::Tag::pictures() const {
|
||||
return PictureMap();
|
||||
}
|
||||
|
||||
String Mod::Tag::trackerName() const {
|
||||
return d->trackerName;
|
||||
}
|
||||
@@ -101,6 +106,8 @@ void Mod::Tag::setYear(unsigned int) {
|
||||
void Mod::Tag::setTrack(unsigned int) {
|
||||
}
|
||||
|
||||
void Mod::Tag::setPictures(const PictureMap&) {}
|
||||
|
||||
void Mod::Tag::setTrackerName(const String &trackerName) {
|
||||
d->trackerName = trackerName;
|
||||
}
|
||||
|
||||
40
3rdparty/taglib/mod/modtag.h
vendored
40
3rdparty/taglib/mod/modtag.h
vendored
@@ -47,43 +47,45 @@ namespace Mod {
|
||||
class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag {
|
||||
public:
|
||||
explicit Tag();
|
||||
virtual ~Tag();
|
||||
~Tag() override;
|
||||
|
||||
/*!
|
||||
* Returns the track name; if no track name is present in the tag String::null will be returned.
|
||||
*/
|
||||
virtual String title() const;
|
||||
String title() const override;
|
||||
|
||||
/*!
|
||||
* Not supported by module files. Therefore always returns String::null.
|
||||
*/
|
||||
virtual String artist() const;
|
||||
String artist() const override;
|
||||
|
||||
/*!
|
||||
* Not supported by module files. Therefore always returns String::null.
|
||||
*/
|
||||
virtual String album() const;
|
||||
String album() const override;
|
||||
|
||||
/*!
|
||||
* Returns the track comment derived from the instrument/sample/pattern
|
||||
* names; if no comment is present in the tag String::null will be returned.
|
||||
*/
|
||||
virtual String comment() const;
|
||||
String comment() const override;
|
||||
|
||||
/*!
|
||||
* Not supported by module files. Therefore always returns String::null.
|
||||
*/
|
||||
virtual String genre() const;
|
||||
String genre() const override;
|
||||
|
||||
/*!
|
||||
* Not supported by module files. Therefore always returns 0.
|
||||
*/
|
||||
virtual unsigned int year() const;
|
||||
unsigned int year() const override;
|
||||
|
||||
/*!
|
||||
* Not supported by module files. Therefore always returns 0.
|
||||
*/
|
||||
virtual unsigned int track() const;
|
||||
unsigned int track() const override;
|
||||
|
||||
PictureMap pictures() const override;
|
||||
|
||||
/*!
|
||||
* Returns the name of the tracker used to create/edit the module file.
|
||||
@@ -100,17 +102,17 @@ class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag {
|
||||
* The length limits per file type are (1 character = 1 byte):
|
||||
* Mod 20 characters, S3M 27 characters, IT 25 characters and XM 20 characters.
|
||||
*/
|
||||
virtual void setTitle(const String &title);
|
||||
void setTitle(const String &title) override;
|
||||
|
||||
/*!
|
||||
* Not supported by module files and therefore ignored.
|
||||
*/
|
||||
virtual void setArtist(const String &artist);
|
||||
void setArtist(const String &artist) override;
|
||||
|
||||
/*!
|
||||
* Not supported by module files and therefore ignored.
|
||||
*/
|
||||
virtual void setAlbum(const String &album);
|
||||
void setAlbum(const String &album) override;
|
||||
|
||||
/*!
|
||||
* Sets the comment to \a comment.
|
||||
@@ -126,22 +128,24 @@ class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag {
|
||||
* The line length limits per file type are (1 character = 1 byte):
|
||||
* Mod 22 characters, S3M 27 characters, IT 25 characters and XM 22 characters.
|
||||
*/
|
||||
virtual void setComment(const String &comment);
|
||||
void setComment(const String &comment) override;
|
||||
|
||||
/*!
|
||||
* Not supported by module files and therefore ignored.
|
||||
*/
|
||||
virtual void setGenre(const String &genre);
|
||||
void setGenre(const String &genre) override;
|
||||
|
||||
/*!
|
||||
* Not supported by module files and therefore ignored.
|
||||
*/
|
||||
virtual void setYear(unsigned int year);
|
||||
void setYear(unsigned int year) override;
|
||||
|
||||
/*!
|
||||
* Not supported by module files and therefore ignored.
|
||||
*/
|
||||
virtual void setTrack(unsigned int track);
|
||||
void setTrack(unsigned int track) override;
|
||||
|
||||
void setPictures(const PictureMap &l) override;
|
||||
|
||||
/*!
|
||||
* Sets the tracker name to \a trackerName.
|
||||
@@ -158,17 +162,17 @@ class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag {
|
||||
* Implements the unified property interface -- export function.
|
||||
* Since the module tag is very limited, the exported map is as well.
|
||||
*/
|
||||
PropertyMap properties() const;
|
||||
PropertyMap properties() const override;
|
||||
|
||||
/*!
|
||||
* Implements the unified property interface -- import function.
|
||||
* Because of the limitations of the module file tag, any tags besides COMMENT, TITLE and, if it is an XM file, TRACKERNAME, will be returned.
|
||||
* Additionally, if the map contains tags with multiple values, all but the first will be contained in the returned map of unsupported properties.
|
||||
*/
|
||||
PropertyMap setProperties(const PropertyMap &);
|
||||
PropertyMap setProperties(const PropertyMap &) override;
|
||||
|
||||
private:
|
||||
explicit Tag(const Tag&);
|
||||
Tag(const Tag&);
|
||||
Tag &operator=(const Tag&);
|
||||
|
||||
class TagPrivate;
|
||||
|
||||
Reference in New Issue
Block a user