Adapt most changes from taglib2

This commit is contained in:
Jonas Kvinge
2020-06-26 23:30:30 +02:00
parent 08882639e0
commit 5f71a558b9
374 changed files with 13708 additions and 4418 deletions

View File

@@ -41,16 +41,14 @@ class IT::File::FilePrivate {
IT::AudioProperties properties;
};
IT::File::File(FileName file, bool readProperties,
AudioProperties::ReadStyle propertiesStyle) : Mod::FileBase(file), d(new FilePrivate(propertiesStyle)) {
IT::File::File(FileName file, bool readProperties, AudioProperties::ReadStyle propertiesStyle) : Mod::FileBase(file), d(new FilePrivate(propertiesStyle)) {
if (isOpen())
read(readProperties);
}
IT::File::File(IOStream *stream, bool readProperties,
AudioProperties::ReadStyle propertiesStyle) : Mod::FileBase(stream), d(new FilePrivate(propertiesStyle)) {
IT::File::File(IOStream *stream, bool readProperties, AudioProperties::ReadStyle propertiesStyle) : Mod::FileBase(stream), d(new FilePrivate(propertiesStyle)) {
if (isOpen())
read(readProperties);
@@ -94,7 +92,7 @@ bool IT::File::save() {
StringList lines = d->tag.comment().split("\n");
for (unsigned short i = 0; i < instrumentCount; ++i) {
seek(192L + length + (static_cast<long>(i) << 2));
unsigned long instrumentOffset = 0;
unsigned int instrumentOffset = 0;
if (!readU32L(instrumentOffset))
return false;
@@ -109,7 +107,7 @@ bool IT::File::save() {
for (unsigned short i = 0; i < sampleCount; ++i) {
seek(192L + length + (static_cast<long>(instrumentCount) << 2) + (static_cast<long>(i) << 2));
unsigned long sampleOffset = 0;
unsigned int sampleOffset = 0;
if (!readU32L(sampleOffset))
return false;
@@ -136,13 +134,13 @@ bool IT::File::save() {
unsigned short special = 0;
unsigned short messageLength = 0;
unsigned long messageOffset = 0;
unsigned int messageOffset = 0;
seek(46);
if (!readU16L(special))
return false;
unsigned long fileSize = File::length();
unsigned int fileSize = File::length();
if (special & AudioProperties::MessageAttached) {
seek(54);
if (!readU16L(messageLength) || !readU32L(messageOffset))
@@ -217,8 +215,8 @@ void IT::File::read(bool) {
seek(messageOffset);
ByteVector messageBytes = readBlock(messageLength);
READ_ASSERT(messageBytes.size() == messageLength);
int index = messageBytes.find(static_cast<char>(0));
if (index > -1)
const size_t index = messageBytes.find(static_cast<char>(0));
if (index != ByteVector::npos())
messageBytes.resize(index, 0);
messageBytes.replace('\r', '\n');
message = messageBytes;

View File

@@ -56,15 +56,15 @@ class TAGLIB_EXPORT File : public Mod::FileBase {
/*!
* Destroys this instance of the File.
*/
virtual ~File();
~File() override;
Mod::Tag *tag() const;
Mod::Tag *tag() const override;
/*!
* Returns the IT::AudioProperties for this file. If no audio properties
* were read then this will return a null pointer.
*/
IT::AudioProperties *audioProperties() const;
IT::AudioProperties *audioProperties() const override;
/*!
* Save the file.
@@ -72,10 +72,10 @@ class TAGLIB_EXPORT File : public Mod::FileBase {
*
* \note Saving Impulse Tracker 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);

View File

@@ -31,21 +31,21 @@ using namespace IT;
class IT::AudioProperties::AudioPropertiesPrivate {
public:
AudioPropertiesPrivate() : channels(0),
lengthInPatterns(0),
instrumentCount(0),
sampleCount(0),
patternCount(0),
version(0),
compatibleVersion(0),
flags(0),
special(0),
globalVolume(0),
mixVolume(0),
tempo(0),
bpmSpeed(0),
panningSeparation(0),
pitchWheelDepth(0) {
explicit AudioPropertiesPrivate() : channels(0),
lengthInPatterns(0),
instrumentCount(0),
sampleCount(0),
patternCount(0),
version(0),
compatibleVersion(0),
flags(0),
special(0),
globalVolume(0),
mixVolume(0),
tempo(0),
bpmSpeed(0),
panningSeparation(0),
pitchWheelDepth(0) {
}
int channels;
@@ -65,7 +65,7 @@ class IT::AudioProperties::AudioPropertiesPrivate {
unsigned char pitchWheelDepth;
};
IT::AudioProperties::AudioProperties(AudioProperties::ReadStyle propertiesStyle) : Strawberry_TagLib::TagLib::AudioProperties(propertiesStyle), d(new AudioPropertiesPrivate()) {}
IT::AudioProperties::AudioProperties(AudioProperties::ReadStyle) : Strawberry_TagLib::TagLib::AudioProperties(), d(new AudioPropertiesPrivate()) {}
IT::AudioProperties::~AudioProperties() {
delete d;
@@ -151,6 +151,10 @@ unsigned char IT::AudioProperties::pitchWheelDepth() const {
return d->pitchWheelDepth;
}
////////////////////////////////////////////////////////////////////////////////
// private members
////////////////////////////////////////////////////////////////////////////////
void IT::AudioProperties::setChannels(int channels) {
d->channels = channels;
}

View File

@@ -54,14 +54,14 @@ class TAGLIB_EXPORT AudioProperties : public Strawberry_TagLib::TagLib::AudioPro
MidiConfEmbedded = 8
};
explicit AudioProperties(AudioProperties::ReadStyle propertiesStyle);
virtual ~AudioProperties();
explicit AudioProperties(AudioProperties::ReadStyle);
~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 short lengthInPatterns() const;
bool stereo() const;
@@ -79,6 +79,7 @@ class TAGLIB_EXPORT AudioProperties : public Strawberry_TagLib::TagLib::AudioPro
unsigned char panningSeparation() const;
unsigned char pitchWheelDepth() const;
private:
void setChannels(int channels);
void setLengthInPatterns(unsigned short lengthInPatterns);
void setInstrumentCount(unsigned short instrumentCount);
@@ -96,9 +97,6 @@ class TAGLIB_EXPORT AudioProperties : public Strawberry_TagLib::TagLib::AudioPro
void setPitchWheelDepth(unsigned char pitchWheelDepth);
private:
explicit AudioProperties(const AudioProperties &);
AudioProperties &operator=(const AudioProperties &);
class AudioPropertiesPrivate;
AudioPropertiesPrivate *d;
};